Completed
Push — master ( 8bf511...3127ce )
by Korotkov
03:22 queued 01:40
created

Container   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 31
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 2
A set() 0 3 1
A has() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Jagepard <[email protected]">
7
 * @copyright Copyright (c) 2019, Jagepard
8
 * @license   https://mit-license.org/ MIT
9
 */
10
11
namespace Rudra\Container;
12
13
use Rudra\Container\Interfaces\ContainerInterface;
14
15
class Container implements ContainerInterface
16
{
17
    /**
18
     * @var array
19
     */
20
    protected $data = [];
21
22
    /**
23
     * @param string|null $key
24
     * @return array
25
     */
26
    public function get(string $key = null)
27
    {
28
        return empty($key) ? $this->data : $this->data[$key];
29
    }
30
31
    /**
32
     * @param array $data
33
     */
34
    public function set(array $data): void
35
    {
36
        $this->data = array_merge($data, $this->data);
37
    }
38
39
    /**
40
     * @param string $key
41
     * @return bool
42
     */
43
    public function has(string $key): bool
44
    {
45
        return array_key_exists($key, $this->data);
46
    }
47
}
48