CollectionValueAccessorTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 30
ccs 8
cts 8
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 4 1
A first() 0 5 1
A last() 0 5 1
1
<?php
2
namespace TRex\Collection;
3
4
trait CollectionValueAccessorTrait
5
{
6
    /**
7
     * @param mixed $value
8
     * @param bool $isStrict
9
     * @return bool
10
     */
11 2
    public function has($value, $isStrict = true)
12
    {
13 2
        return in_array($value, (array)$this, $isStrict);
14
    }
15
16
    /**
17
     * @return mixed|null
18
     */
19 1
    public function first()
20
    {
21 1
        $array = (array)$this;
22 1
        return array_shift($array);
23
    }
24
25
    /**
26
     * @return mixed|null
27
     */
28 1
    public function last()
29
    {
30 1
        $array = (array)$this;
31 1
        return array_pop($array);
32
    }
33
}