Test Failed
Push — master ( 6bac61...6350a6 )
by Kirill
03:02
created

DocumentContext::getFile()   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 0
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\Backend\Context;
11
12
use Railt\Io\Readable;
13
use Railt\Reflection\Contracts\Definition\TypeDefinition;
14
use Railt\Reflection\Contracts\Document;
15
use Railt\SDL\Backend\Value\ValueInterface;
16
17
/**
18
 * Class DocumentContext
19
 */
20
class DocumentContext extends AbstractContext implements LocalContextInterface
21
{
22
    /**
23
     * @var Document
24
     */
25
    protected $context;
26
27
    /**
28
     * @var ContextInterface
29
     */
30
    private $parent;
31
32
    /**
33
     * LocalContext constructor.
34
     * @param ContextInterface $parent
35
     * @param Document $document
36
     */
37
    public function __construct(ContextInterface $parent, Document $document)
38
    {
39
        $this->parent = $parent;
40
        $this->context = $document;
41
    }
42
43
    /**
44
     * @return Document
45
     */
46
    public function getDocument(): Document
47
    {
48
        return $this->context;
49
    }
50
51
    /**
52
     * @return Readable
53
     */
54
    public function getFile(): Readable
55
    {
56
        return $this->context->getFile();
57
    }
58
59
    /**
60
     * @return ContextInterface|GlobalContext
61
     */
62
    public function getParent(): ContextInterface
63
    {
64
        return $this->parent;
65
    }
66
67
    /**
68
     * @param string $type
69
     * @param array|ValueInterface[] $variables
70
     * @return TypeDefinition
71
     */
72 View Code Duplication
    public function get(string $type, array $variables = []): TypeDefinition
0 ignored issues
show
Duplication introduced by
This method 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...
73
    {
74
        if ($this->has($type)) {
75
            return $this->types[$type]->make($variables);
76
        }
77
78
        return $this->parent->get($type, $variables);
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function __toString(): string
85
    {
86
        return (string)$this->context;
87
    }
88
}
89