ClosureReaction::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 0
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace MaxGoryunov\SavingIterator\Src;
4
5
use Closure;
6
7
/**
8
 * A reaction which accepts Closure.
9
 * @template T
10
 * @implements Reaction<T>
11
 */
12
final class ClosureReaction implements Reaction
13
{
14
15
    /**
16
     * Ctor.
17
     *
18
     * @phpstan-param Closure(T, string): T $action
19
     * @param Closure $action action to be performed.
20
     */
21
    public function __construct(
22
        /**
23
         * Action to be performed.
24
         *
25
         * @phpstan-var Closure(T, string): T
26
         * @var Closure
27
         */
28
        private Closure $action
29
    ) {
30
    }
31
32
    /**
33
     * {@inheritDoc}
34
     */
35
    public function edited(mixed $subject, string $method): mixed
36
    {
37
        return ($this->action)($subject, $method);
38
    }
39
}
40