Completed
Push — master ( 32da9f...5da014 )
by Sebastian
07:46
created

Bootstrapper::run()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 12
Code Lines 7

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 3
nop 1
1
<?php
2
namespace phpbu\App\Configuration;
3
4
use phpbu\App\Configuration;
5
use phpbu\App\Exception;
6
7
/**
8
 * Bootstrapper
9
 *
10
 * @package    phpbu
11
 * @subpackage app
12
 * @author     Sebastian Feldmann <[email protected]>
13
 * @copyright  Sebastian Feldmann <[email protected]>
14
 * @license    https://opensource.org/licenses/MIT The MIT License (MIT)
15
 * @link       http://phpbu.de/
16
 * @since      Class available since Release 5.0.8
17
 */
18 View Code Duplication
class Bootstrapper
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    /**
21
     * Execute bootstrap runner.
22
     *
23
     * @param  \phpbu\App\Configuration $configuration
24
     * @throws \phpbu\App\Exception
25
     */
26
    public function run(Configuration $configuration)
27
    {
28
        $filename = $configuration->getBootstrap();
29
30
        if (!empty($filename)) {
31
            $pathToFile = stream_resolve_include_path($filename);
32
            if (!$pathToFile || !is_readable($pathToFile)) {
33
                throw new Exception(sprintf('Cannot open bootstrap file "%s".' . PHP_EOL, $filename));
34
            }
35
            require $pathToFile;
36
        }
37
    }
38
}
39