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