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

ClosureTable   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 1
cbo 3
dl 38
loc 38
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A build() 9 9 1
A getExtensionName() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 ClosureTable 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
     * ClosureTable 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' => 'closure',
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