Define and detect different packet types (2,2e,2+,2.2)

This commit is contained in:
2023-06-25 22:45:02 +12:00
parent fa3653a94b
commit a26f61d75d
10 changed files with 678 additions and 266 deletions

View File

@@ -59,12 +59,22 @@ abstract class FTN
*/
protected static function unpackheader(array $pack): string
{
return join('/',
collect($pack)
->sortBy(function($k,$v) {return $k[0];})
->transform(function($k,$v) {return $k[1].$v;})
->values()
->toArray()
);
// Check that our header is correct
if (app()->environment('local')) {
$c = 0;
foreach (collect($pack) as $item) {
if ($c !== $item[0])
throw new \Exception('Invalid header');
$c += $item[2];
}
}
return collect($pack)
->sortBy(function($k,$v) {return $k[0];})
->transform(function($k,$v) {return $k[1].$v;})
->values()
->join('/');
;
}
}