Completed
Push — master ( b2a65d...63a169 )
by Kirill
02:18
created

DeferredInterceptor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 4
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * This file is part of Railt package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Railt\SDL\Frontend\Interceptor;
11
12
use Railt\Parser\Ast\RuleInterface;
13
use Railt\SDL\Frontend\Context\ContextInterface;
14
use Railt\SDL\Frontend\Deferred\DeferredInterface;
15
use Railt\SDL\Frontend\Deferred\DeferredCollection;
16
17
/**
18
 * Class DeferredInterceptor
19
 */
20 View Code Duplication
class DeferredInterceptor implements InterceptorInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @var DeferredCollection
24
     */
25
    private $storage;
26
27
    /**
28
     * DeferredInterceptor constructor.
29
     * @param DeferredCollection $storage
30
     */
31
    public function __construct(DeferredCollection $storage)
32
    {
33
        $this->storage = $storage;
34
    }
35
36
    /**
37
     * @param RuleInterface $value
38
     * @return bool
39
     */
40
    public function match($value): bool
41
    {
42
        return $value instanceof DeferredInterface;
43
    }
44
45
    /**
46
     * @param ContextInterface $context
47
     * @param mixed $value
48
     * @return array
49
     */
50
    public function resolve(ContextInterface $context, $value): array
51
    {
52
        $this->storage->add($value);
53
54
        return [$context, $value];
55
    }
56
}
57