ExpectPlugin::createWithConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/**
4
 * This file is part of peridot-expectation package.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace expect\peridot;
13
14
use expect\Expect;
15
use expect\configurator\FileConfigurator;
16
use Evenement\EventEmitterInterface;
17
18
19
/**
20
 * Class ExpectPlugin
21
 * @package expect\peridot
22
 */
23
class ExpectPlugin implements Registrar
24
{
25
26
    /**
27
     * @var string
28
     */
29
    private $configFilePath;
30
31
32
    /**
33
     * @param string|null $configurationFile
0 ignored issues
show
Bug introduced by
There is no parameter named $configurationFile. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
34
     */
35
    public function __construct($configFilePath = null)
36
    {
37
        $this->configFilePath = $configFilePath;
38
    }
39
40
    /**
41
     * @return ExpectPlugin
42
     */
43
    public static function create()
44
    {
45
        return new self();
46
    }
47
48
    /**
49
     * @param string $configFilePath
50
     * @return ExpectPlugin
51
     */
52
    public static function createWithConfig($configFilePath)
53
    {
54
        return new self($configFilePath);
55
    }
56
57
    /**
58
     * @return null|string
59
     */
60
    public function getConfigurationFilePath()
61
    {
62
        return $this->configFilePath;
63
    }
64
65
    /**
66
     * @return bool
67
     */
68
    public function isEmptyConfig()
69
    {
70
        return is_null($this->getConfigurationFilePath());
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function registerTo(EventEmitterInterface $emitter)
77
    {
78
        $emitter->once(static::START_EVENT, [ $this, 'onPeridotStart' ]);
79
    }
80
81
    public function onPeridotStart()
82
    {
83
        if ($this->isEmptyConfig()) {
84
            Expect::configure();
85
        } else {
86
            $configurator = new FileConfigurator($this->getConfigurationFilePath());
87
            Expect::configure($configurator);
88
        }
89
90
        require_once __DIR__  . '/DSL.php';
91
    }
92
93
}
94