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

InvocationInterceptor::match()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
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\SDL\Frontend\Context\ContextInterface;
13
use Railt\SDL\Frontend\Definition\InvocationInterface;
14
use Railt\SDL\Frontend\Definition\Storage;
15
16
/**
17
 * Class InvocationInterceptor
18
 */
19
class InvocationInterceptor implements InterceptorInterface
20
{
21
    /**
22
     * @var Storage
23
     */
24
    private $types;
25
26
    /**
27
     * InvocationInterceptor constructor.
28
     * @param Storage $types
29
     */
30
    public function __construct(Storage $types)
31
    {
32
        $this->types = $types;
33
    }
34
35
    /**
36
     * @param mixed $value
37
     * @return bool
38
     */
39
    public function match($value): bool
40
    {
41
        return $value instanceof InvocationInterface;
42
    }
43
44
    /**
45
     * @param ContextInterface $context
46
     * @param mixed $value
47
     * @return array
48
     */
49
    public function resolve(ContextInterface $context, $value): array
50
    {
51
        $value = $this->types->invoke($value);
52
53
        return [$context, $value];
54
    }
55
}
56