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::parseRelation()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
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