Passed
Push — feature/40 ( c9d26f...67d730 )
by Max
02:40
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
 */
10
class The
11
{
12
13
    /**
14
     * Ctor.
15
     * 
16
     * @param mixed   $subject
17
     * @param Closure $context
18
     */
19
    public function __construct(
20
        /**
21
         * Element to be put into the context.
22
         * 
23
         * @var mixed
24
         */
25
        private mixed $subject,
26
27
        /**
28
         * Context for the element.
29
         * 
30
         * @var Closure
31
         */
32
        private Closure $context
33
    ) {
34
    }
35
36
    /**
37
     * Applies context to subject and returns subject.
38
     *
39
     * @return mixed
40
     */
41
    public function value(): array
42
    {
43
        ($this->context)($this->subject);
44
        return $this->subject;
45
    }
46
}
47