| 1 | <?php  | 
            ||
| 11 | class PHPUnitBinFile  | 
            ||
| 12 | { | 
            ||
| 13 | // I'm using Paraunit as a vendor package  | 
            ||
| 14 | private const PHPUNIT_REALPATH_FOR_VENDOR = '/../../../../../phpunit/phpunit/phpunit';  | 
            ||
| 15 | // I'm using Paraunit standalone (developing)  | 
            ||
| 16 | private const PHPUNIT_REALPATH_FOR_STANDALONE = '/../../../vendor/phpunit/phpunit/phpunit';  | 
            ||
| 17 | |||
| 18 | /** @var string Realpath to PHPUnit bin location */  | 
            ||
| 19 | private $phpUnitBin;  | 
            ||
| 20 | |||
| 21 | /**  | 
            ||
| 22 | * PHPUnitBinFile constructor.  | 
            ||
| 23 | * @throws \RuntimeException If PHPUnit is not found  | 
            ||
| 24 | */  | 
            ||
| 25 | 41 | public function __construct()  | 
            |
| 26 |     { | 
            ||
| 27 | 41 |         if (\defined('PARAUNIT_PHAR_FILE')) { | 
            |
| 28 | // Paraunit is running as a standalone PHAR archive  | 
            ||
| 29 | // PHPUnit is embedded in the archive, self execute it in special mode  | 
            ||
| 30 | $this->phpUnitBin = PARAUNIT_PHAR_FILE . ' phpunit';  | 
            ||
| 31 | |||
| 32 | return;  | 
            ||
| 33 | }  | 
            ||
| 34 | |||
| 35 | 41 |         if (file_exists(__DIR__ . self::PHPUNIT_REALPATH_FOR_VENDOR)) { | 
            |
| 36 | $this->setPhpUnitBin(__DIR__ . self::PHPUNIT_REALPATH_FOR_VENDOR);  | 
            ||
| 37 | |||
| 38 | return;  | 
            ||
| 39 | }  | 
            ||
| 40 | |||
| 41 | 41 |         if (file_exists(__DIR__ . self::PHPUNIT_REALPATH_FOR_STANDALONE)) { | 
            |
| 42 | 41 | $this->setPhpUnitBin(__DIR__ . self::PHPUNIT_REALPATH_FOR_STANDALONE);  | 
            |
| 43 | |||
| 44 | 41 | return;  | 
            |
| 45 | }  | 
            ||
| 46 | |||
| 47 |         throw new \RuntimeException('PHPUnit bin not found'); | 
            ||
| 48 | }  | 
            ||
| 49 | |||
| 50 | 41 | public function getPhpUnitBin(): string  | 
            |
| 54 | |||
| 55 | private function setPhpUnitBin($phpUnitBin): void  | 
            ||
| 64 | }  | 
            ||
| 65 |