Completed
Push — master ( 913926...597557 )
by Denis
02:01
created

Container   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 52
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getItems() 0 4 1
A getItem() 0 4 1
A first() 0 4 1
A last() 0 4 1
1
<?php
2
3
namespace PhpJsonRpc\Common\Chain;
4
5
/**
6
 * Container for passing arguments and results over chain
7
 */
8
class Container
9
{
10
    private $items;
11
12
    /**
13
     * Container constructor.
14
     *
15
     * @param array ...$items
16
     */
17
    public function __construct(...$items)
18
    {
19
        $this->items = $items;
20
    }
21
22
    /**
23
     * @return array
24
     */
25
    public function getItems()
26
    {
27
        return $this->items;
28
    }
29
30
    /**
31
     * @param $index
32
     *
33
     * @return mixed|null
34
     */
35
    public function getItem($index)
36
    {
37
        return $this->items[$index] ?? null;
38
    }
39
40
    /**
41
     * Get first item of container
42
     *
43
     * @return mixed
44
     */
45
    public function first()
46
    {
47
        return $this->items[0];
48
    }
49
50
    /**
51
     * Get last item of container
52
     *
53
     * @return mixed
54
     */
55
    public function last()
56
    {
57
        return $this->items[count($this->items) - 1];
58
    }
59
}
60