ElementStackable   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 54
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 4 1
A isEmpty() 0 4 1
A count() 0 4 1
A getIterator() 0 4 1
A first() 0 5 1
A last() 0 5 1
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