Passed
Pull Request — master (#116)
by Max
03:13
created

ContextVeil   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A __call() 0 3 1
1
<?php
2
3
namespace MaxGoryunov\SavingIterator\Src;
4
5
/**
6
 * Veil which applies context to origin if the condition is met.
7
 * @template T of object origin type.
8
 * @implements Indifferent<T>
9
 * @mixin T
10
 */
11
final class ContextVeil implements Indifferent
12
{
13
14
    /**
15
     * Ctor.
16
     * 
17
     * @phpstan-param T $origin
18
     * @param object $origin original element.
19
     */
20
    public function __construct(
21
        /**
22
         * Original element.
23
         *
24
         * @phpstan-var T
25
         * @var object
26
         */
27
        private object $origin
28
    ) {
29
    }
30
31
    /**
32
     * {@inheritDoc}
33
     */
34
    public function __call(string $name, array $arguments): mixed
35
    {
36
        return $this->origin->$name(...$arguments);
37
    }
38
}
39