Completed
Push — master ( 5d3bf9...5839aa )
by Sebastian
03:18
created

Bootstrap   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 3
dl 0
loc 32
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A run() 0 4 1
A handleBootstrap() 0 12 4
1
<?php
2
namespace phpbu\App\Runner;
3
4
use phpbu\App\Configuration;
5
use phpbu\App\Exception;
6
7
/**
8
 * Bootstrap Runner
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 3.0.0
17
 */
18
class Bootstrap extends Abstraction
19
{
20
    /**
21
     * Execute bootstrap runner.
22
     *
23
     * @param  \phpbu\App\Configuration $configuration
24
     * @throws \phpbu\App\Exception
25
     */
26 4
    public function run(Configuration $configuration)
27
    {
28 4
        $this->handleBootstrap($configuration);
29 4
    }
30 4
31 3
    /**
32
     * Handles the bootstrap file inclusion.
33
     *
34
     * @param  \phpbu\App\Configuration $configuration
35
     * @throws \phpbu\App\Exception
36
     */
37
    protected function handleBootstrap(Configuration $configuration)
38 4
    {
39
        $filename = $configuration->getBootstrap();
40
41 4
        if (!empty($filename)) {
42 1
            $pathToFile = stream_resolve_include_path($filename);
43 4
            if (!$pathToFile || !is_readable($pathToFile)) {
44 4
                throw new Exception(sprintf('Cannot open bootstrap file "%s".' . PHP_EOL, $filename));
45
            }
46
            require $pathToFile;
47
        }
48
    }
49
}
50