ElementStackable::count()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of cloak.
5
 *
6
 * (c) Noritaka Horio <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace cloak\collection;
13
14
15
/**
16
 * Trait ElementStackable
17
 * @package cloak\collection
18
 */
19
trait ElementStackable
20
{
21
22
    /**
23
     * @var \PhpCollection\Sequence
24
     */
25
    protected $collection;
26
27
28
    public function first()
29
    {
30
        $first = $this->collection->first();
31
        return $first->getOrElse(null);
32
    }
33
34
    public function last()
35
    {
36
        $last = $this->collection->last();
37
        return $last->getOrElse(null);
38
    }
39
40
    /**
41
     * @return array
42
     */
43
    public function toArray()
44
    {
45
        return $this->collection->all();
46
    }
47
48
    /**
49
     * @return int
50
     */
51
    public function isEmpty()
52
    {
53
        return $this->collection->isEmpty();
54
    }
55
56
    /**
57
     * @return int
58
     */
59
    public function count()
60
    {
61
        return $this->collection->count();
62
    }
63
64
    /**
65
     * @return \ArrayIterator|\Traversable
66
     */
67
    public function getIterator()
68
    {
69
        return $this->collection->getIterator();
70
    }
71
72
}
73