Test Setup Failed
Push — master ( 1595cb...1df194 )
by Kirill
02:11
created

ContextFacadeTrait::setSchema()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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\ExecutionContext;
15
use Railt\TypeSystem\Schema;
16
17
/**
18
 * Trait ContextFacadeTrait
19
 */
20
trait ContextFacadeTrait
21
{
22
    use NameResolverFacadeTrait;
23
    use SchemaFacadeTrait {
24
        setSchema as private _setSchema;
25
    }
26
27
    /**
28
     * @var ExecutionContext
29
     */
30
    protected ExecutionContext $context;
31
32
    /**
33
     * @param Schema $schema
34
     * @return $this
35
     */
36
    public function setSchema(Schema $schema): self
37
    {
38
        $this->_setSchema($schema);
39
40
        $this->context->setSchema($schema);
41
42
        return $this;
43
    }
44
45
    /**
46
     * @return void
47
     * @throws \Throwable
48
     */
49
    private function bootContextFacadeTrait(): void
50
    {
51
        $this->bootSchemaFacadeTrait();
52
        $this->bootNameResolverFacadeTrait();
53
54
        $this->context = new ExecutionContext($this->getNameResolver(), $this->getSchema());
55
    }
56
}
57