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.

Entity   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 98
Duplicated Lines 52.04 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 8
lcom 0
cbo 7
dl 51
loc 98
rs 10
c 1
b 1
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A parseRelation() 0 7 1
B listParents() 25 25 3
B listDependence() 26 26 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
    public    $pastName      = 'Entity';
17
    protected $fileTpl       = "entity.php";
18
    protected $fileFixedData = array (
19
        'parentclass' => array (
20
            'name' => "AbstractEntity" ,
21
            'tpl'  => "entity_abstract.php"
22
        )
23
    );
24
25
    protected $overwrite     = true;
26
27
    protected $validFunc = array ();
28
29
    private $intersectDependence = false;
0 ignored issues
show
Unused Code introduced by
The property $intersectDependence is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
30
31
    /**
32
     * @param \Classes\MakerFile  $makerFile
33
     * @param \Classes\Db\DbTable $dbTable
34
     *
35
     * @return array
36
     */
37
    public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable )
38
    {
39
        return array (
40
            'mapParents'    => $this->listParents ( $makerFile, $dbTable ),
41
            'mapDependents' => $this->listDependence ( $makerFile, $dbTable )
42
        );
43
    }
44
45
    /**
46
     * @param \Classes\MakerFile  $makerFile
47
     * @param \Classes\Db\DbTable $dbTable
48
     *
49
     * @return array
50
     */
51 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...
52
    {
53
        $mapParents = '';
54
        $references = array ();
55
        foreach ( $dbTable->getForeingkeys () as $objColumn ) {
56
            $constrant    = $objColumn->getFks ();
57
            $references[] = sprintf (
58
                '$this->belongsTo(\'%s\', \'%s\', \'%s\', array(\'alias\' => \'%s\'))',
59
                $objColumn->getName (),
60
                $makerFile->getConfig ()
61
                          ->createClassNamespace ( $constrant ) . Phalcon::SEPARETOR . AbstractMaker::getClassName (
62
                    $constrant->getTable ()
63
                ),
64
                $constrant->getColumn (),
65
                AbstractMaker::getClassName ( $constrant->getTable () )
66
            );
67
        }
68
69
        if ( sizeof ( $references ) > 0 ) {
70
            $mapParents = join ( ";\n\t\t", $references ) . ";\n";
71
        }
72
73
74
        return $mapParents;
75
    }
76
77
    /**
78
     * @param \Classes\MakerFile  $makerFile
79
     * @param \Classes\Db\DbTable $dbTable
80
     *
81
     * @return array
82
     */
83 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...
84
    {
85
        $mapDependence = '';
86
        $references    = array ();
87
        foreach ( $dbTable->getDependences () as $objColumn ) {
88
            foreach ( $objColumn->getDependences () as $dependence ) {
89
                $references[] = sprintf (
90
                    '$this->hasMany(\'%s\', \'%s\', \'%s\', array(\'alias\' => \'%s\'))',
91
                    $objColumn->getName (),
92
                    $makerFile->getConfig ()
93
                              ->createClassNamespace ( $dependence )
94
                    . Phalcon::SEPARETOR
95
                    . AbstractMaker::getClassName ( $dependence->getTable () ),
96
                    $dependence->getColumn (),
97
                    AbstractMaker::getClassName ( $dependence->getTable () )
98
                );
99
100
            }
101
        }
102
103
        if ( sizeof ( $references ) > 0 ) {
104
            $mapDependence = join ( ";\n\t\t", $references ) . ";";
105
        }
106
107
        return $mapDependence;
108
    }
109
110
}
111