Passed
Branch v1.x-dev (23ead1)
by Benjamin
04:07
created

includeIfExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
function includeIfExists($file)
4
{
5
    if (file_exists($file)) {
6
        return include $file;
7
    }
8
}
9
10
if (
11
    (!$loader = includeIfExists(__DIR__.'/vendor/autoload.php')) && // Standalone like CI
12
    (!$loader = includeIfExists(__DIR__.'/../../../autoload.php')) && // As vendor
13
    (!$loader = includeIfExists(__DIR__.'/../../../vendor/autoload.php')) // Dev mode
14
) {
15
    die('You must set up the project dependencies, run the following commands:'.PHP_EOL.
16
        'curl -sS https://getcomposer.org/installer | php'.PHP_EOL.
17
        'php composer.phar install'.PHP_EOL);
18
}
19