CollectionValueAccessorTrait::has()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 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
}