Passed
Pull Request — master (#57)
by Max
02:30
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
 * @todo #44:25min Classes Let and The contain some repeated cdde which could
11
 *  be extracted into a separate class.
12
 * @template X subject type
13
 * @template Y result type
14
 * @implements \MaxGoryunov\SavingIterator\Src\Scalar<Y>
15
 */
16
class Let extends SurveyEnvelope
17
{
18
19
    /**
20
     * Ctor.
21
     *
22
     * @phpstan-param X             $subject repeated element
23
     * @phpstan-param Closure(X): Y $context context for element
24
     * @param mixed   $subject element to be put into context
25
     * @param Closure $context context for element
26
     */
27
    public function __construct(mixed $subject, Closure $context)
28
    {
29
        parent::__construct(
30
            $subject,
31
            $context,
32
            fn(mixed $subject, Closure $context): mixed => $context($subject)
33
        );
34
    }
35
}
36