Compare::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 4
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 14
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace loophp\collection\Operation;
6
7
use Closure;
8
use Generator;
9
10
/**
11
 * @immutable
12
 *
13
 * @template TKey
14
 * @template T
15
 */
16
final class Compare extends AbstractOperation
17
{
18
    /**
19
     * @return Closure(callable(T, T, TKey, iterable<TKey, T>): T): Closure(iterable<TKey, T>): Generator<TKey, T>
20
     */
21 26
    public function __invoke(): Closure
22
    {
23 26
        return
24
            /**
25
             * @param callable(T, T, TKey, iterable<TKey, T>): T $comparator
26
             *
27
             * @return Closure(iterable<TKey, T>): Generator<TKey,T>
28
             */
29 26
            static function (callable $comparator): Closure {
30
                /** @var Closure(iterable<TKey, T>): Generator<TKey, T> $foldLeft1 */
31 26
                $foldLeft1 = (new FoldLeft1())()($comparator);
32
33
                // Point free style.
34 26
                return $foldLeft1;
35 26
            };
36
    }
37
}
38