Completed
Push — extensions-support ( 02f578...4c74a5 )
by Guido
03:38
created

MaterializedPath::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 4
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace LaravelDoctrine\Fluent\Extensions\Gedmo;
4
5
use Gedmo\Tree\Mapping\Driver\Fluent as TreeDriver;
6
use LaravelDoctrine\Fluent\Buildable;
7
use LaravelDoctrine\Fluent\Extensions\ExtensibleClassMetadata;
8
use LaravelDoctrine\Fluent\Fluent;
9
10 View Code Duplication
class MaterializedPath implements Buildable
0 ignored issues
show
Duplication introduced by
This class 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...
11
{
12
    /**
13
     * @var Fluent
14
     */
15
    private $builder;
16
17
    /**
18
     * MaterializedPath constructor.
19
     *
20
     * @param Fluent $builder
21
     */
22 2
    public function __construct(Fluent $builder)
23
    {
24 2
        $this->builder = $builder;
25 2
    }
26
27
    /**
28
     * Execute the build process
29
     */
30 1
    public function build()
31
    {
32
        /** @var ExtensibleClassMetadata $classMetadata */
33 1
        $classMetadata = $this->builder->getBuilder()->getClassMetadata();
34
35 1
        $classMetadata->appendExtension($this->getExtensionName(), [
36 1
            'strategy' => 'materializedPath',
37 1
        ]);
38 1
    }
39
40
    /**
41
     * @return string
42
     */
43 1
    protected function getExtensionName()
44
    {
45 1
        return TreeDriver::EXTENSION_NAME;
46
    }
47
}
48