Find::find()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Cocur\Chain\Link;
4
5
/**
6
 * Find.
7
 *
8
 * @author    Christoph Rosse
9
 * @copyright 2017 Christoph Rosse
10
 */
11
trait Find
12
{
13
    /**
14
     * Find an element by a comparison callback.
15
     *
16
     * @param callable $callback
17
     *
18
     * @return mixed|bool Found element, `false` if no result is found
19
     */
20 2
    public function find(callable $callback)
21
    {
22 2
        $result = array_filter($this->array, $callback);
23
24 2
        return empty($result) ? false : current($result);
25
    }
26
}
27