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

AbstractContainer::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
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