-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #498 from Vatsim-Scandinavia/fix/vatsim-helper
Fix/vatsim helper
- Loading branch information
Showing
3 changed files
with
210 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,33 @@ | ||
<?php | ||
|
||
namespace App\Helpers\Vatsim; | ||
|
||
namespace App\Helpers; | ||
use Illuminate\Support\Collection; | ||
|
||
/** | ||
* Checks if a position belongs to the division. | ||
* @param string callsign | ||
* @param Collection<string> divisionCallsignPrefixes | ||
*/ | ||
function isDivisionCallsign(string $callsign, Collection $divisionCallsignPrefixes) | ||
{ | ||
$validAtcSuffixes = ["DEL" => true, "GND" => true, "TWR" => true, "APP" => true, "DEP" => true, "CTR" => true, "FSS" => true]; | ||
// Filter away invalid ATC suffixes | ||
$suffix = substr($callsign, -3); | ||
if (!array_key_exists($suffix, $validAtcSuffixes)) { | ||
return false; | ||
} | ||
class Vatsim{ | ||
|
||
/** | ||
* Checks if a position belongs to the division. | ||
* @param string callsign | ||
* @param Collection<string> divisionCallsignPrefixes | ||
*/ | ||
public static function isDivisionCallsign(string $callsign, Collection $divisionCallsignPrefixes) | ||
{ | ||
$validAtcSuffixes = ["DEL" => true, "GND" => true, "TWR" => true, "APP" => true, "DEP" => true, "CTR" => true, "FSS" => true]; | ||
// Filter away invalid ATC suffixes | ||
$suffix = substr($callsign, -3); | ||
if (!array_key_exists($suffix, $validAtcSuffixes)) { | ||
return false; | ||
} | ||
|
||
// PREFIX | ||
if ($divisionCallsignPrefixes->contains(substr($callsign, 0, 4))) { | ||
return true; | ||
// PREFIX | ||
if ($divisionCallsignPrefixes->contains(substr($callsign, 0, 4))) { | ||
return true; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
return false; | ||
} | ||
|
||
|
||
?> |
Oops, something went wrong.