Passed
Push — master ( d9297f...af2311 )
by Max
01:55 queued 01:05
created

The   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 3
Metric Value
eloc 11
dl 0
loc 39
rs 10
c 3
b 0
f 3
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A act() 0 4 1
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
 * @todo #92:30min Remove extension of SurveyEnvelope because it is not needed
10
 *  anymore.
11
 * @template T subject type
12
 * @extends SurveyEnvelope<T, T>
13
 * @implements Block<mixed>
14
 */
15
class The extends SurveyEnvelope implements Block
16
{
17
18
    /**
19
     * Subject for a context.
20
     *
21
     * @var mixed
22
     */
23
    private mixed $subject;
24
25
    /**
26
     * Ctor.
27
     *
28
     * @phpstan-param T                 $subject repeating element
29
     * @phpstan-param Closure(T): mixed $context context for element
30
     * @param mixed $subject
31
     * @param Closure $context
32
     */
33
    public function __construct(mixed $subject, Closure $context)
34
    {
35
        parent::__construct(
36
            $subject,
37
            $context,
38
            function (mixed $subject, Closure $context): mixed
39
            {
40
                $context($subject);
41
                return $subject;
42
            }
43
        );
44
        $this->subject = $subject;
45
    }
46
47
    /**
48
     * {@inheritDoc}
49
     */
50
    public function act(Closure $context): mixed
51
    {
52
        $context($this->subject);
53
        return $this->subject;
54
    }
55
}
56