| Conditions | 4 |
| Paths | 4 |
| Total Lines | 59 |
| Code Lines | 42 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 5 | ||
| Bugs | 4 | Features | 3 |
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 |
||
| 71 | public function prepare() |
||
| 72 | { |
||
| 73 | // Perform this migration and execute only once |
||
| 74 | if ($this->migrator() != 40) { |
||
| 75 | // Perform SQL table creation |
||
| 76 | $path = __DIR__ . '/../sql/'; |
||
| 77 | foreach (array_slice(scandir($path), 2) as $file) { |
||
| 78 | $this->database->execute($this->readSQL($path . $file, $this->tablePrefix)); |
||
| 79 | } |
||
| 80 | $this->migrator(40); |
||
| 81 | } |
||
| 82 | |||
| 83 | // Initiate migration mechanism |
||
| 84 | $this->database->migration(get_class($this), array($this, 'migrator')); |
||
| 85 | |||
| 86 | // Generate entities classes file |
||
| 87 | $generator = new Generator($this->database); |
||
| 88 | $file = md5($generator->entityHash()).'.php'; |
||
| 89 | if ($this->cache_refresh($file)) { |
||
| 90 | file_put_contents($file, '<?php '.$generator->createEntityClasses()); |
||
| 91 | } |
||
| 92 | |||
| 93 | // Include entities file |
||
| 94 | require($file); |
||
| 95 | |||
| 96 | // Define permanent table relations |
||
| 97 | new TableRelation('material', 'user', 'UserID', 0, 'user_id'); |
||
| 98 | new TableRelation('material', 'gallery', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 99 | new TableRelation('material', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 100 | new TableRelation('material', 'field', 'materialfield.FieldID', TableRelation::T_ONE_TO_MANY); |
||
| 101 | new TableRelation('material', 'structurematerial', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 102 | new TableRelation('material', 'structure', 'structurematerial.StructureID', TableRelation::T_ONE_TO_MANY); |
||
| 103 | new TableRelation('materialfield', 'field', 'FieldID'); |
||
| 104 | new TableRelation('materialfield', 'material', 'MaterialID'); |
||
| 105 | new TableRelation('structurematerial', 'structure', 'StructureID'); |
||
| 106 | new TableRelation('structurematerial', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 107 | new TableRelation('structurematerial', 'material', 'MaterialID', TableRelation::T_ONE_TO_MANY); |
||
| 108 | new TableRelation('structure', 'material', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials'); |
||
| 109 | new TableRelation('structure', 'gallery', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials'); |
||
| 110 | /*new TableRelation( 'structure', 'material', 'MaterialID' );*/ |
||
| 111 | new TableRelation('structure', 'user', 'UserID', 0, 'user_id'); |
||
| 112 | new TableRelation('structure', 'materialfield', 'material.MaterialID', TableRelation::T_ONE_TO_MANY, 'MaterialID', '_mf'); |
||
| 113 | new TableRelation('structure', 'structurematerial', 'StructureID', TableRelation::T_ONE_TO_MANY); |
||
| 114 | new TableRelation('related_materials', 'material', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID'); |
||
| 115 | new TableRelation('related_materials', 'materialfield', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID'); |
||
| 116 | new TableRelation('field', 'structurefield', 'FieldID'); |
||
| 117 | new TableRelation('field', 'structure', 'structurefield.StructureID'); |
||
| 118 | new TableRelation('structurefield', 'field', 'FieldID'); |
||
| 119 | new TableRelation('structurefield', 'materialfield', 'FieldID'); |
||
| 120 | new TableRelation('structurefield', 'material', 'materialfield.MaterialID'); |
||
| 121 | new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id', 'children_relations'); |
||
| 122 | new TableRelation('structure', 'structure', 'children_relations.child_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'children'); |
||
| 123 | new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'child_id', 'parents_relations'); |
||
| 124 | new TableRelation('structure', 'structure', 'parents_relations.parent_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'parents'); |
||
| 125 | new TableRelation('structurematerial', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id'); |
||
| 126 | new TableRelation('groupright', 'right', 'RightID', TableRelation::T_ONE_TO_MANY); |
||
| 127 | |||
| 128 | return parent::prepare(); |
||
| 129 | } |
||
| 130 | |||
| 158 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..