Bootstrap::load()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: polidog
5
 * Date: 2016/07/17.
6
 */
7
8
namespace Polidog\LaravelBundle;
9
10
use Illuminate\Contracts\Foundation\Application;
11
use Polidog\LaravelBundle\Exception\FallbackException;
12
13
class Bootstrap
14
{
15
    /**
16
     * @var string
17
     */
18
    private $bootstrapFile;
19
20
    /**
21
     * @var Application
22
     */
23
    private $app;
24
25
    /**
26
     * Bootstrap constructor.
27
     *
28
     * @param string $bootstrapFile
29
     */
30
    public function __construct($bootstrapFile)
31
    {
32
        $this->bootstrapFile = $bootstrapFile;
33
34
    }
35
36
    public function load()
37
    {
38
        if ($this->app === null) {
39
            if (!file_exists($this->bootstrapFile)) {
40
                throw new FallbackException('Bootstrap file not found. '.$this->bootstrapFile);
41
            }
42
            $this->app = require $this->bootstrapFile;
43
        }
44
45
        return $this->app;
46
    }
47
48
}
49