GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 660260...e1c224 )
by Pedro
03:36
created

Entity   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 95
Duplicated Lines 55.79 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 8
c 3
b 0
f 0
lcom 0
cbo 7
dl 53
loc 95
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parseRelation() 0 8 1
B listParents() 26 26 3
B listDependence() 27 27 4

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 Classes\AdapterMakerFile\Phalcon;
4
5
use Classes\AdapterConfig\Phalcon;
6
use Classes\AdapterMakerFile\AbstractAdapter;
7
use Classes\Maker\AbstractMaker;
8
9
/**
10
 * @author Pedro Alarcao <[email protected]>
11
 * @link   https://github.com/pedro151/orm-generator
12
 */
13
class Entity extends AbstractAdapter
14
{
15
16
    /**
17
     * @var void
18
     */
19
    public    $pastName  = "entity";
20
    protected $fileTpl   = "entity.php";
21
    protected $overwrite = true;
22
23
    protected $validFunc = array ();
24
25
    /**
26
     * @param \Classes\MakerFile  $makerFile
27
     * @param \Classes\Db\DbTable $dbTable
28
     *
29
     * @return array
30
     */
31
    public function parseRelation ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable )
32
    {
33
34
        return array (
35
            'mapParents'    => $this->listParents ( $makerFile , $dbTable ) ,
36
            'mapDependents' => $this->listDependence ( $makerFile , $dbTable )
37
        );
38
    }
39
40
    /**
41
     * @param \Classes\MakerFile  $makerFile
42
     * @param \Classes\Db\DbTable $dbTable
43
     *
44
     * @return array
45
     */
46 View Code Duplication
    private function listParents ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable )
0 ignored issues
show
Duplication introduced by
This method 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...
47
    {
48
        $mapParents = '';
49
        $references = array ();
50
        foreach ( $dbTable->getForeingkeys () as $objColumn )
51
        {
52
            $constrant = $objColumn->getFks ();
53
            $references[] = sprintf (
54
                "\$this->hasMany('%s', '%s', '%s')" ,
55
                $objColumn->getName () ,
56
                $makerFile->getConfig ()->createClassNamespace ( $constrant )
57
                . Phalcon::SEPARETOR
58
                . AbstractMaker::getClassName ( $constrant->getTable () ) ,
59
                $constrant->getColumn ()
60
61
            );
62
        }
63
64
        if ( sizeof ( $references ) > 0 )
65
        {
66
            $mapParents = join ( ";\n\t\t" , $references ) . ";\n";
67
        }
68
69
70
        return $mapParents;
71
    }
72
73
    /**
74
     * @param \Classes\MakerFile  $makerFile
75
     * @param \Classes\Db\DbTable $dbTable
76
     *
77
     * @return array
78
     */
79 View Code Duplication
    private function listDependence ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable )
0 ignored issues
show
Duplication introduced by
This method 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...
80
    {
81
        $mapDependence = '';
82
        $references = array ();
83
        foreach ( $dbTable->getDependences () as $objColumn )
84
        {
85
            foreach ( $objColumn->getDependences () as $dependence )
86
            {
87
                $references[] = sprintf (
88
                    "\$this->belongsTo('%s', '%s', '%s')" ,
89
                    $objColumn->getName () ,
90
                    $makerFile->getConfig ()->createClassNamespace ( $dependence )
91
                    . Phalcon::SEPARETOR
92
                    . AbstractMaker::getClassName ( $dependence->getTable () ) ,
93
                    $dependence->getColumn ()
94
                );
95
96
            }
97
        }
98
99
        if ( sizeof ( $references ) > 0 )
100
        {
101
            $mapDependence = join ( ";\n\t\t" , $references ) . ";";
102
        }
103
104
        return $mapDependence;
105
    }
106
107
}
108