Passed
Push — feature/52 ( 26e983...2a77ff )
by Max
03:01 queued 02:33
created

Let::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace MaxGoryunov\SavingIterator\Fakes;
4
5
use Closure;
6
7
/**
8
 * Allows to use context instead of creating a new variable.
9
 * 
10
 * @template X subject type
11
 * @template Y result type
12
 * @extends SurveyEnvelope<X, Y>
13
 */
14
class Let extends SurveyEnvelope
15
{
16
17
    /**
18
     * Ctor.
19
     *
20
     * @phpstan-param X             $subject repeated element
21
     * @phpstan-param Closure(X): Y $context context for element
22
     * @param mixed   $subject element to be put into context
23
     * @param Closure $context context for element
24
     */
25
    public function __construct(mixed $subject, Closure $context)
26
    {
27
        parent::__construct(
28
            $subject,
29
            $context,
30
            fn(mixed $subject, Closure $context): mixed => $context($subject)
31
        );
32
    }
33
}
34