Completed
Push — 1.1 ( d166b0...e7f438 )
by Patrick
11:31 queued 07:46
created

ClosureTable::build()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Extensions\Gedmo;
4
5
use Gedmo\Tree\Entity\Repository\ClosureTreeRepository;
6
use LaravelDoctrine\Fluent\Buildable;
7
use LaravelDoctrine\Fluent\Builders\Delay;
8
use LaravelDoctrine\Fluent\Fluent;
9
10
class ClosureTable extends TreeStrategy implements Buildable, Delay
11
{
12
    /**
13
     * @var string
14
     */
15
    private $closureClass;
16
17
    /**
18
     * ClosureTable constructor.
19
     *
20
     * @param Fluent $builder
21
     * @param string $class
22
     */
23
    public function __construct(Fluent $builder, $class)
24
    {
25
        parent::__construct($builder);
26
27
        $this->closureClass = $class;
28
    }
29
30
    /**
31
     * Execute the build process
32
     */
33
    public function build()
34
    {
35
        $this->builder->entity()->setRepositoryClass(ClosureTreeRepository::class);
36
37
        parent::build();
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    protected function getValues()
44
    {
45
        return array_merge(parent::getValues(), [
46
            'strategy' => 'closure',
47
            'closure'  => $this->closureClass,
48
        ]);
49
    }
50
}
51