Test Setup Failed
Push — master ( 1595cb...050b68 )
by Kirill
21:00
created

ContextFacadeTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A bootContextFacadeTrait() 0 5 1
A getContext() 0 3 1
A setSchema() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of Railt package.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Railt\SDL\Compiler;
13
14
use Railt\SDL\Backend\Context;
15
use Railt\TypeSystem\Schema;
16
17
/**
18
 * Trait ContextFacadeTrait
19
 */
20
trait ContextFacadeTrait
21
{
22
    use SchemaFacadeTrait {
23
        setSchema as private _setSchema;
24
    }
25
26
    /**
27
     * @var Context
28
     */
29
    protected Context $context;
30
31
    /**
32
     * @return Context
33
     */
34
    public function getContext(): Context
35
    {
36
        return $this->context;
37
    }
38
39
    /**
40
     * @return void
41
     * @throws \Throwable
42
     */
43
    private function bootContextFacadeTrait(): void
44
    {
45
        $this->bootSchemaFacadeTrait();
46
47
        $this->context = new Context($this->getSchema());
48
    }
49
50
    /**
51
     * @param Schema $schema
52
     * @return $this
53
     */
54
    public function setSchema(Schema $schema): self
55
    {
56
        $this->_setSchema($schema);
57
        $this->context->setSchema($schema);
58
59
        return $this;
60
    }
61
}
62