Conditions | 7 |
Paths | 32 |
Total Lines | 69 |
Code Lines | 37 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
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:
If many parameters/temporary variables are present:
1 | <?php |
||
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 | |||
104 |