Passed
Push — feature/51 ( ffcada...15fa2a )
by Max
02:30
created

The::value()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 4
rs 10
1
<?php
2
3
namespace MaxGoryunov\SavingIterator\Fakes;
4
5
use Closure;
6
7
/**
8
 * Class for applying contexts to elements without changing them.
9
 * @template T subject type.
10
 * @implements Scalar<T>
11
 * 
12
 * @todo #44:20min Classes Let and The do not have proper type hints in
13
 *  constructor and methods. Workarounds with `@var` tags must be removed
14
 *  after that. 
15
 */
16
class The extends SurveyEnvelope
17
{
18
19
    /**
20
     * Ctor.
21
     *
22
     * @param T                 $subject
23
     * @param Closure(T): mixed $context
24
     */
25
    public function __construct(mixed $subject, Closure $context)
26
    {
27
        parent::__construct(
28
            $subject,
29
            $context,
30
            function (mixed $subject, Closure $context): mixed {
31
                $context($subject);
32
                return $subject;
33
            }
34
        );
35
    }
36
}
37