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 ( bf1ef2...cd89f1 )
by Pedro
10:51 queued 06:31
created

DbTable::parseRelation()   C

Complexity

Conditions 7
Paths 32

Size

Total Lines 69
Code Lines 37

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 69
rs 6.9081
c 1
b 0
f 0
cc 7
eloc 37
nc 32
nop 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
namespace Classes\AdapterMakerFile\ZendFrameworkOne;
4
5
use Classes\AdapterMakerFile\AbstractAdapter;
6
use Classes\AdapterConfig\ZendFrameworkOne;
7
use Classes\Maker\AbstractMaker;
8
9
/**
10
 * @author Pedro Alarcao <[email protected]>
11
 * @link   https://github.com/pedro151/orm-generator
12
 */
13
class DbTable extends AbstractAdapter
14
{
15
16
    public    $pastName      = 'DbTable';
17
    protected $fileTpl       = "dbtable.php";
18
    protected $fileFixedData = array (
19
        'parentclass' => array (
20
            'name' => "TableAbstract" ,
21
            'tpl'  => "dbtable_abstract.php"
22
        )
23
    );
24
25
    protected $overwrite     = true;
26
27
    /**
28
     * @param \Classes\MakerFile $makerFile
29
     * @param \Classes\Db\DbTable $dbTable
30
     *
31
     * @return array
32
     */
33
    public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable )
34
    {
35
        $referenceMap = '';
36
        $references = array ();
37
        $dependentTables = '';
38
        $dependents = array ();
39
        foreach ( $dbTable->getForeingkeys () as $objColumn )
40
        {
41
            $constrant = $objColumn->getFks ();
42
            $variable =  $constrant->getNameConstrant () . ZendFrameworkOne::SEPARETOR . $objColumn->getName ();
43
44
            $arrClass = array (
45
                $makerFile->getConfig ()->createClassNamespace ( $constrant ),
46
                'DbTable',
47
                AbstractMaker::getClassName ( $constrant->getTable () )
48
            );
49
            $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) );
50
51
            $references[] = sprintf (
52
                "
53
       '%s' => array (
54
            'columns'       => '%s' ,
55
            'refTableClass' => '%s',
56
            'refColumns'    =>'%s'
57
       )",
58
                AbstractMaker::getClassName ( $variable ),
59
                $objColumn->getName (),
60
                $class,
61
                $constrant->getColumn ()
62
63
            );
64
        }
65
66
        if ( sizeof ( $references ) > 0 )
67
        {
68
            $referenceMap = "protected \$_referenceMap = array(" .
69
                join ( ',', $references ) . "\n    );";
70
        }
71
72
        foreach ( $dbTable->getDependences () as $objColumn )
73
        {
74
            foreach ( $objColumn->getDependences () as $dependence )
75
            {
76
                $arrClass = array (
77
                    $makerFile->getConfig ()->createClassNamespace ( $dependence ),
78
                    'DbTable',
79
                    AbstractMaker::getClassName ( $dependence->getTable () )
80
                );
81
                $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) );
82
83
                if(!in_array($class,$dependents)){
84
                   $dependents[] = $class;
85
                }
86
            }
87
        }
88
89
        if ( sizeof ( $dependents ) > 0 )
90
        {
91
            $dependentTables = "protected \$_dependentTables = array(\n        '" .
92
                join ( "',\n        '", $dependents ) . "'\n    );";
93
        }
94
95
96
        return array (
97
            'referenceMap'    => $referenceMap,
98
            'dependentTables' => $dependentTables
99
        );
100
101
    }
102
103
}
104