Installer::fixPath PHP Method

fixPath() private static method

Fix paths in Bootstrap.php
private static fixPath ( $app = 'application' )
    private static function fixPath($app = 'application')
    {
        $file = $app . '/' . static::TEST_FOLDER . '/Bootstrap.php';
        $contents = file_get_contents($file);
        if (!file_exists('system')) {
            if (file_exists('vendor/codeigniter/framework/system')) {
                $contents = str_replace('$system_path = \'../../system\';', '$system_path = \'../../vendor/codeigniter/framework/system\';', $contents);
            } else {
                throw new Exception('Can\'t find "system" folder.');
            }
        }
        if (!file_exists('index.php')) {
            if (file_exists('public/index.php')) {
                // CodeIgniter 3.0.6 and after
                $contents = str_replace("define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", "define('FCPATH', realpath(dirname(__FILE__).'/../../public').DIRECTORY_SEPARATOR);", $contents);
                // CodeIgniter 3.0.5 and before
                $contents = str_replace("define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", "define('FCPATH', realpath(dirname(__FILE__).'/../../public').'/');", $contents);
            } elseif (file_exists($app . '/public/index.php')) {
                // CodeIgniter 3.0.6 and after
                $contents = str_replace("define('FCPATH', realpath(dirname(__FILE__).'/../..').DIRECTORY_SEPARATOR);", "define('FCPATH', realpath(dirname(__FILE__).'/../public').DIRECTORY_SEPARATOR);", $contents);
                // CodeIgniter 3.0.5 and before
                $contents = str_replace("define('FCPATH', realpath(dirname(__FILE__).'/../..').'/');", "define('FCPATH', realpath(dirname(__FILE__).'/../public').'/');", $contents);
                if ($app != 'application') {
                    $contents = str_replace("\$application_folder = '../../application';", "\$application_folder = '../../{$app}';", $contents);
                }
            } else {
                throw new Exception('Can\'t find "index.php".');
            }
        }
        file_put_contents($file, $contents);
    }