Completed
Push — master ( f283e7...8452cb )
by Korotkov
02:56 queued 10s
created

Depository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setItem() 0 3 1
A getItem() 0 7 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @author    : Korotkov Danila <[email protected]>
7
 * @license   https://mit-license.org/ MIT
8
 */
9
10
namespace Behavioral\Interpreter;
11
12
/**
13
 * Class Depository
14
 * @package Behavioral\Interpreter
15
 */
16
class Depository implements DepositoryInterface
17
{
18
    /**
19
     * @var array
20
     */
21
    private $depository = [];
22
23
    /**
24
     * @param ItemInterface $item
25
     */
26
    public function setItem(ItemInterface $item): void
27
    {
28
        $this->depository[] = $item;
29
    }
30
31
    /**
32
     * @param int $value
33
     * @return ItemInterface
34
     */
35
    public function getItem(int $value): ItemInterface
36
    {
37
        if (array_key_exists($value, $this->depository)) {
38
            return $this->depository[$value];
39
        }
40
41
        throw new \InvalidArgumentException();
42
    }
43
}
44