Joli\JoliNotif\tests\Util\PharExtractorTest::generatePhar PHP Method

generatePhar() private method

private generatePhar ( string $pharPath, string $fileRelativePath, string $fileContent, boolean $overwrite )
$pharPath string
$fileRelativePath string
$fileContent string
$overwrite boolean
    private function generatePhar($pharPath, $fileRelativePath, $fileContent, $overwrite)
    {
        $rootPackage = dirname(dirname(dirname(__FILE__)));
        $bootstrap = <<<'PHAR_BOOTSTRAP'
<?php

require __DIR__.'/vendor/autoload.php';

$filePath = THE_FILE;
$overwrite = OVERWRITE;

\Joli\JoliNotif\Util\PharExtractor::extractFile(__DIR__.$filePath, $overwrite);

?>
PHAR_BOOTSTRAP;
        $phar = new \Phar($pharPath);
        $phar->buildFromDirectory($rootPackage, '#(src|vendor)#');
        $phar->addFromString('bootstrap.php', str_replace(['THE_FILE', 'OVERWRITE'], ['\'/' . $fileRelativePath . '\'', $overwrite ? 'true' : 'false'], $bootstrap));
        $phar->addFromString($fileRelativePath, $fileContent);
        $phar->setStub($phar->createDefaultStub('bootstrap.php'));
    }