Code Duplication    Length = 39-40 lines in 2 locations

src/SDL/Reflection/Builder/Definitions/ObjectBuilder.php 1 location

@@ 24-63 (lines=40) @@
21
/**
22
 * Class ObjectBuilder
23
 */
24
class ObjectBuilder extends BaseObject implements Compilable
25
{
26
    use Compiler;
27
    use FieldsBuilder;
28
    use DirectivesBuilder;
29
30
    /**
31
     * SchemaBuilder constructor.
32
     * @param NodeInterface $ast
33
     * @param DocumentBuilder $document
34
     * @throws \Railt\SDL\Exceptions\TypeConflictException
35
     */
36
    public function __construct(NodeInterface $ast, DocumentBuilder $document)
37
    {
38
        $this->boot($ast, $document);
39
        $this->offset = $this->offsetPrefixedBy('type');
40
    }
41
42
    /**
43
     * @param NodeInterface|RuleInterface $ast
44
     * @return bool
45
     * @throws \Railt\SDL\Exceptions\TypeConflictException
46
     */
47
    protected function onCompile(NodeInterface $ast): bool
48
    {
49
        if ($ast->is('Implements')) {
50
            foreach ($ast->getChildren() as $child) {
51
                $name = $child->getChild(0)->getValue();
52
53
                $interface = $this->load($name);
54
55
                $this->interfaces = $this->unique($this->interfaces, $interface);
56
            }
57
58
            return true;
59
        }
60
61
        return false;
62
    }
63
}
64

src/SDL/Reflection/Builder/Definitions/UnionBuilder.php 1 location

@@ 24-62 (lines=39) @@
21
/**
22
 * Class UnionBuilder
23
 */
24
class UnionBuilder extends BaseUnion implements Compilable
25
{
26
    use Compiler;
27
    use DirectivesBuilder;
28
29
    /**
30
     * UnionBuilder constructor.
31
     * @param NodeInterface $ast
32
     * @param DocumentBuilder $document
33
     * @throws \Railt\SDL\Exceptions\TypeConflictException
34
     */
35
    public function __construct(NodeInterface $ast, DocumentBuilder $document)
36
    {
37
        $this->boot($ast, $document);
38
        $this->offset = $this->offsetPrefixedBy('union');
39
    }
40
41
    /**
42
     * @param NodeInterface|RuleInterface $ast
43
     * @return bool
44
     * @throws TypeConflictException
45
     */
46
    protected function onCompile(NodeInterface $ast): bool
47
    {
48
        if ($ast->is('Relations')) {
49
            foreach ($ast->getChildren() as $relation) {
50
                $name = $relation->getChild(0)->getValue();
51
52
                $child = $this->load($name);
53
54
                $this->types = $this->unique($this->types, $child);
55
            }
56
57
            return true;
58
        }
59
60
        return false;
61
    }
62
}
63