| Conditions | 25 |
| Paths | 15 |
| Total Lines | 85 |
| Code Lines | 62 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 44 | private function parseData($data, $preset) { |
||
| 45 | $keyLog = \App::$cur->log->start('start object model set'); |
||
| 46 | $model = $this->setModel($data); |
||
| 47 | \App::$cur->log->end($keyLog); |
||
| 48 | if ($model) { |
||
| 49 | foreach ($preset as $col => $value) { |
||
| 50 | $model->{$col} = $value; |
||
| 51 | } |
||
| 52 | if (defined('mdebug')) { |
||
| 53 | echo " -> objectStart ({$this->object->id}) "; |
||
| 54 | } |
||
| 55 | $walked = []; |
||
| 56 | foreach ($this->object->params as $param) { |
||
| 57 | if (defined('mdebug')) { |
||
| 58 | echo " -> param ($param->id,$param->type,$param->value) "; |
||
| 59 | } |
||
| 60 | if ($model && $param->type && $param->type != 'item_key') { |
||
| 61 | if ($param->type == 'object') { |
||
| 62 | $object = \App::$cur->migrations->getMigrationObject($this->walker->migration, $param->value); |
||
| 63 | $parser = new \Migrations\Parser\Object; |
||
| 64 | $parser->data = &$data[$param->code]; |
||
| 65 | $parser->object = $object; |
||
| 66 | $parser->parentObject = $this; |
||
| 67 | $parser->parentModel = $model; |
||
| 68 | $parser->walker = $this->walker; |
||
| 69 | if (defined('mdebug')) { |
||
| 70 | echo " -> objectParse "; |
||
| 71 | } |
||
| 72 | $parser->parse(); |
||
| 73 | } else { |
||
| 74 | if ($param->type == 'custom') { |
||
| 75 | $parserName = $param->value; |
||
| 76 | } else { |
||
| 77 | $parserName = '\Migrations\Parser\Object\\' . ucfirst($param->type); |
||
| 78 | } |
||
| 79 | $parser = new $parserName; |
||
| 80 | $parser->data = &$data[$param->code]; |
||
| 81 | $parser->param = $param; |
||
| 82 | $parser->model = $model; |
||
| 83 | $parser->walker = $this->walker; |
||
| 84 | $parser->object = $this; |
||
| 85 | if (defined('mdebug')) { |
||
| 86 | echo " -> parser ($parserName) "; |
||
| 87 | } |
||
| 88 | $parser->parse(); |
||
| 89 | } |
||
| 90 | } |
||
| 91 | if (defined('mdebug')) { |
||
| 92 | echo " -> paramEnd ($param->id,$param->type,$param->value) "; |
||
| 93 | } |
||
| 94 | $walked[$param->code] = true; |
||
| 95 | } |
||
| 96 | |||
| 97 | //check unparsed params |
||
| 98 | foreach ($data as $key => $item) { |
||
| 99 | //skip parsed and attribtes |
||
| 100 | if ($key == '@attributes' || !empty($walked[$key])) { |
||
| 101 | continue; |
||
| 102 | } |
||
| 103 | $param = new \Migrations\Migration\Object\Param(); |
||
| 104 | $param->object_id = $this->object->id; |
||
| 105 | $param->code = $key; |
||
| 106 | $param->save(); |
||
| 107 | $className = get_class($this->object); |
||
| 108 | $this->object = $className::get($this->object->id); |
||
| 109 | } |
||
| 110 | if ($model) { |
||
| 111 | if ($this->object->delete_empty && @json_decode($this->object->delete_empty, true)) { |
||
| 112 | $deleteIf = json_decode($this->object->delete_empty, true); |
||
| 113 | foreach ($deleteIf['params'] as $paramId) { |
||
| 114 | if ($model->{$this->object->params[$paramId]->value} === '') { |
||
| 115 | if($model->pk()){ |
||
| 116 | $model->delete(); |
||
| 117 | } |
||
| 118 | return 0; |
||
| 119 | } |
||
| 120 | } |
||
| 121 | } |
||
| 122 | if (!$model->pk() || !empty($model->_changedParams)) { |
||
| 123 | $model->save(); |
||
| 124 | } |
||
| 125 | return $model->pk(); |
||
| 126 | } |
||
| 127 | } |
||
| 128 | return 0; |
||
| 129 | } |
||
| 223 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths