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

InvocationInterceptor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A match() 0 4 1
A resolve() 0 6 1
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