FindTest::test()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace Prelude\Tests;
4
5
use function Prelude\find;
6
use function Prelude\equals;
7
8
class FindTest extends \PHPUnit\Framework\TestCase
9
{
10
    public function test()
11
    {
12
        $isEven = function (int $n) { return $n % 2 === 0; };
13
        $isOdd = function (int $n) { return $n % 2 === 1; };
14
15
        $this->assertEquals(3, find($isOdd)([2, 3, 4, 5, 6, 7, 8]));
16
        $this->assertEquals(4, find($isEven)([5, 7, 4, 5, 6, 7, 8]));
17
        $this->assertEquals(10, find(equals(10))([5, 8, 10, 11]));
18
        $this->assertEquals(null, find(equals(10))([]));
19
    }
20
}
21