-
-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into refactor/check-sett…
…ings
- Loading branch information
Showing
3 changed files
with
139 additions
and
45 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the box project. | ||
* | ||
* (c) Kevin Herrera <[email protected]> | ||
* Théo Fidry <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace KevinGH\Box; | ||
|
||
use RuntimeException; | ||
use Symfony\Component\Process\PhpExecutableFinder as SymfonyPhpExecutableFinder; | ||
|
||
final class ExecutableFinder | ||
{ | ||
private static string $boxExecutable; | ||
private static string $phpExecutable; | ||
|
||
public static function findBoxExecutable(): string | ||
{ | ||
if (isset(self::$boxExecutable)) { | ||
return self::$boxExecutable; | ||
} | ||
|
||
self::$boxExecutable = getenv(Constants::BIN) ?: $_SERVER['SCRIPT_NAME']; | ||
|
||
return self::$boxExecutable; | ||
} | ||
|
||
public static function findPhpExecutable(): string | ||
{ | ||
if (isset(self::$phpExecutable)) { | ||
return self::$phpExecutable; | ||
} | ||
|
||
$phpExecutable = (new SymfonyPhpExecutableFinder())->find(); | ||
|
||
if (false === $phpExecutable) { | ||
throw new RuntimeException('Could not find a PHP executable.'); | ||
} | ||
|
||
self::$phpExecutable = $phpExecutable; | ||
|
||
return self::$phpExecutable; | ||
} | ||
} |
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