for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of CaptainHook.
*
* (c) Sebastian Feldmann <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CaptainHook\App\Runner\Bootstrap;
use CaptainHook\App\Config;
use RuntimeException;
* Bootstrap Util
* @package CaptainHook
* @author Sebastian Feldmann <[email protected]>
* @link https://github.com/captainhookphp/captainhook
* @since Class available since Release 5.23.3
class Util
{
* Return the bootstrap file to load (can be empty)
* @param bool $isPhar
* @param \CaptainHook\App\Config $config
* @return string
public static function validateBootstrapPath(bool $isPhar, Config $config): string
$bootstrapFile = dirname($config->getPath()) . '/' . $config->getBootstrap();
if (!file_exists($bootstrapFile)) {
// since the phar has its own autoloader we don't need to do anything
// if the bootstrap file is not actively set
if ($isPhar && empty($config->getBootstrap(''))) {
return '';
}
throw new RuntimeException('bootstrap file not found');
return $bootstrapFile;
* Returns the bootstrap command option (can be empty)
public static function bootstrapCmdOption(bool $isPhar, Config $config): string
// nothing to load => no option
return ' --bootstrap=' . $config->getBootstrap();