Code Duplication    Length = 55-55 lines in 2 locations

src/Definition/Source/AbstractDefinitionSource.php 1 location

@@ 17-71 (lines=55) @@
14
 *
15
 * @author Andrzej Kostrzewa <[email protected]>
16
 */
17
abstract class AbstractDefinitionSource implements DefinitionSourceInterface
18
{
19
    /**
20
     * @var array
21
     */
22
    protected $definitions = [];
23
24
    /**
25
     * DefinitionSource constructor.
26
     *
27
     * @param array $definitions
28
     */
29
    public function __construct(array $definitions)
30
    {
31
        $this->definitions = $definitions;
32
    }
33
34
    /**
35
     * Add definitions to the DI.
36
     *
37
     * @param array $definitions
38
     */
39
    public function add(array $definitions)
40
    {
41
        $this->definitions = array_merge($this->definitions, $definitions);
42
    }
43
44
    /**
45
     * Returns true if the DI can return an entry for the given name.
46
     * Returns false otherwise.
47
     *
48
     * @param $name
49
     *
50
     * @return bool
51
     */
52
    public function has($name)
53
    {
54
        if (!is_string($name)) {
55
            return false;
56
        }
57
58
        return isset($this->definitions[$name]) || array_key_exists($name, $this->definitions);
59
    }
60
61
    /**
62
     * Set the DI definition for the entry name.
63
     *
64
     * @param $name
65
     * @param $value
66
     */
67
    public function set($name, $value)
68
    {
69
        $this->definitions[$name] = $value;
70
    }
71
}
72

src/Definition/Source/DefinitionSource.php 1 location

@@ 17-71 (lines=55) @@
14
 *
15
 * @author Andrzej Kostrzewa <[email protected]>
16
 */
17
abstract class DefinitionSource implements DefinitionSourceInterface
18
{
19
    /**
20
     * @var array
21
     */
22
    protected $definitions = [];
23
24
    /**
25
     * DefinitionSource constructor.
26
     *
27
     * @param array $definitions
28
     */
29
    public function __construct(array $definitions)
30
    {
31
        $this->definitions = $definitions;
32
    }
33
34
    /**
35
     * Add definitions to the DI.
36
     *
37
     * @param array $definitions
38
     */
39
    public function add(array $definitions)
40
    {
41
        $this->definitions = array_merge($this->definitions, $definitions);
42
    }
43
44
    /**
45
     * Returns true if the DI can return an entry for the given name.
46
     * Returns false otherwise.
47
     *
48
     * @param $name
49
     *
50
     * @return bool
51
     */
52
    public function has($name)
53
    {
54
        if (!is_string($name)) {
55
            return false;
56
        }
57
58
        return isset($this->definitions[$name]) || array_key_exists($name, $this->definitions);
59
    }
60
61
    /**
62
     * Set the DI definition for the entry name.
63
     *
64
     * @param $name
65
     * @param $value
66
     */
67
    public function set($name, $value)
68
    {
69
        $this->definitions[$name] = $value;
70
    }
71
}
72