Created
October 27, 2023 21:50
-
-
Save ghostwriter/97595a51ba36ee148ac6d2840e3b8f72 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
<?php | |
function getOpenBinary(): string | |
{ | |
return match (PHP_OS_FAMILY) { | |
// Using PowerShell allows us to open the file in the background | |
'Windows' => 'powershell Start-Process', | |
'Darwin' => 'open', | |
'Linux' => 'xdg-open', | |
default => throw new Exception(500, | |
sprintf("Unable to find a matching binary for OS family '%s'", PHP_OS_FAMILY) | |
) | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment