Conditions | 10 |
Paths | 25 |
Total Lines | 44 |
Code Lines | 32 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | 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 |
||
25 | public function walk() { |
||
26 | $walked = []; |
||
27 | //walk know pathes |
||
28 | foreach ($this->map->paths(['where' => ['path', $this->curPath]]) as $path) { |
||
29 | if (isset($this->data[$path->item])) { |
||
30 | if ($path->type == 'container') { //create walker for container |
||
31 | $walker = new Walker(); |
||
32 | $walker->migration = $this->migration; |
||
33 | $walker->map = $this->map; |
||
34 | $walker->data = &$this->data[$path->item]; |
||
35 | $walker->curPath = $this->curPath . $path->item . '/'; |
||
36 | $walker->mapPath = $path; |
||
37 | $walker->mapPathParent = $this->mapPath; |
||
38 | $walker->migtarionLog = $this->migtarionLog; |
||
39 | $walker->walk(); |
||
40 | } elseif ($path->type == 'object') { //start parse path data |
||
41 | $this->startObjectParse($path->object_id, $this->data[$path->item]); |
||
42 | } |
||
43 | } |
||
44 | $walked[$path->item] = true; |
||
45 | } |
||
46 | //check unparsed paths |
||
47 | foreach ($this->data as $key => &$data) { |
||
48 | //skip parsed and attribtes |
||
49 | if ($key == '@attributes' || !empty($walked[$key])) { |
||
50 | continue; |
||
51 | } |
||
52 | //search object for parse |
||
53 | $object = Migration\Object::get([ |
||
54 | ['code', $key], |
||
55 | ['migration_id', $this->migration->id] |
||
56 | ]); |
||
57 | if ($object) { //parse as object |
||
58 | $this->startObjectParse($object, $data); |
||
59 | } else { //create new map path for configure unknown path |
||
60 | $this->mapPath = new Migration\Map\Path(); |
||
61 | $this->mapPath->parent_id = $this->mapPathParent ? $this->mapPathParent->id : 0; |
||
62 | $this->mapPath->path = $this->curPath; |
||
63 | $this->mapPath->item = $key; |
||
64 | $this->mapPath->migration_map_id = $this->map->id; |
||
65 | $this->mapPath->save(); |
||
66 | } |
||
67 | } |
||
68 | } |
||
69 | |||
106 |