Completed
Push — master ( 10575c...1b914b )
by Korotkov
04:08 queued 02:36
created

AbstractContainer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 40
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 3 1
A has() 0 3 1
A get() 0 3 2
A __construct() 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 AbstractContainer implements ContainerInterface
16
{
17
    /**
18
     * @var array
19
     */
20
    protected $data;
21
22
    /**
23
     * AbstractRequestMethod constructor.
24
     * @param  array  $data
25
     */
26
    public function __construct(array $data = [])
27
    {
28
        $this->data = $data;
29
    }
30
31
    /**
32
     * @param string|null $key
33
     * @return array
34
     */
35
    public function get(string $key = null)
36
    {
37
        return empty($key) ? $this->data : $this->data[$key];
38
    }
39
40
    /**
41
     * @param array $data
42
     */
43
    public function set(array $data): void
44
    {
45
        $this->data = $data;
46
    }
47
48
    /**
49
     * @param string $key
50
     * @return bool
51
     */
52
    public function has(string $key): bool
53
    {
54
        return isset($this->data[$key]);
55
    }
56
}
57