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

Container::first()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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