Completed
Pull Request — master (#177)
by
unknown
04:33
created

src/bootstrap.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 4 and the first side effect is on line 31.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
if (!class_exists('N98_Magerun_Bootstrap')) {
4
    class N98_Magerun_Bootstrap
5
    {
6
        public static function includeIfExists($file)
7
        {
8
            if (file_exists($file)) {
9
                return include $file;
10
            }
11
        }
12
13
        /**
14
         * @throws ErrorException
15
         * @return \Composer\Autoload\ClassLoader
16
         */
17
        public static function getLoader()
18
        {
19
            if ((!$loader = \N98_Magerun_Bootstrap::includeIfExists(__DIR__.'/../vendor/autoload.php'))
20
                && (!$loader = \N98_Magerun_Bootstrap::includeIfExists(__DIR__.'/../../../autoload.php'))) {
21
                throw new \ErrorException('You must set up the project dependencies, run the following commands:'.PHP_EOL.
0 ignored issues
show
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
22
                    'curl -s http://getcomposer.org/installer | php'.PHP_EOL.
23
                    'php composer.phar install'.PHP_EOL);
24
            }
25
26
            return $loader;
27
        }
28
    }
29
}
30
31
try {
32
    if (version_compare(PHP_VERSION, '5.4.11', '<')) {
33
        throw new \ErrorException('PHP Version is lower than 5.4.11. Please upgrade your runtime.');
34
    }
35
36
    $loader = \N98_Magerun_Bootstrap::getLoader();
37
    $application = new \N98\Magento\Application($loader);
38
39
    return $application;
40
41
} catch (\Exception $e) {
42
    echo $e->getMessage();
43
    exit(1);
44
}
45