ContainsAccessor   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 10 1
1
<?php
2
3
namespace Underscore\Accessor;
4
5
use Underscore\Accessor;
6
use Underscore\Collection;
7
8
class ContainsAccessor extends Accessor
9
{
10
    /**
11
     * Checks if a given value is present in a collection using strict equality for comparisons.
12
     *
13
     * Returns bool
14
     *
15
     * @param Collection $collection
16
     * @param mixed      $needle
17
     * @return Collection
18
     */
19
    public function __invoke($collection, $needle)
20
    {
21 3
        $iterator = function ($value) use ($needle) {
22 3
            return $value === $needle;
23 3
        };
24
25 3
        $find = new FindAccessor();
26
27 3
        return $find($collection, $iterator);
28
    }
29
}
30