Conditions | 16 |
Paths | 672 |
Total Lines | 66 |
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 |
||
56 | private function get_Person($individual){ |
||
57 | $g_id = $individual->getId(); |
||
|
|||
58 | $surn = current($individual->getName())->getSurn(); |
||
59 | $givn = current($individual->getName())->getGivn(); |
||
60 | $name = current($individual->getName())->getName(); |
||
61 | $sex = $individual->getSex(); |
||
62 | $attr = $individual->getAttr(); |
||
63 | $events = $individual->getEven(); |
||
64 | $media = $individual->getObje(); |
||
65 | |||
66 | if($givn == "") { |
||
67 | $givn = $name; |
||
68 | } |
||
69 | |||
70 | $sex = $sex === 'F' ? 'female' : 'male'; |
||
71 | $surn = isset($surn) ? $surn : 'No Surname'; |
||
72 | |||
73 | foreach($events as $event){ |
||
74 | $date = $this->get_date($event->getDate()); |
||
75 | $place = $this->get_place($event->getPlac()); |
||
76 | if(isset($date) || isset($place)){ |
||
77 | $place = isset($place) ? $place : 'No place'; |
||
78 | Event::create([ |
||
79 | 'event_type' => 'App\Individual', |
||
80 | 'event_date' => $date, |
||
81 | 'event_id' => 1, |
||
82 | 'name' => mb_convert_encoding($place, 'UTF-8', 'UTF-8'), |
||
83 | 'description' => mb_convert_encoding($place, 'UTF-8', 'UTF-8'), |
||
84 | 'event_type_id' => 1 |
||
85 | ]); |
||
86 | } |
||
87 | }; |
||
88 | |||
89 | foreach($attr as $event){ |
||
90 | $date = $this->get_date($event->getDate()); |
||
91 | $place = $this->get_place($event->getPlac()); |
||
92 | if(count($event->getNote())>0){ |
||
93 | $note = current($event->getNote())->getNote(); |
||
94 | } |
||
95 | else{ |
||
96 | $note = ''; |
||
97 | } |
||
98 | if(isset($date) || isset($place)){ |
||
99 | $place = isset($place) ? $place : 'No place'; |
||
100 | Note::create([ |
||
101 | 'name' => mb_convert_encoding($place, 'UTF-8', 'UTF-8'), |
||
102 | 'date' => mb_convert_encoding($date, 'UTF-8', 'UTF-8'), |
||
103 | 'description' => mb_convert_encoding($note, 'UTF-8', 'UTF-8'), |
||
104 | ]); |
||
105 | } |
||
106 | }; |
||
107 | foreach ($media as $mediafile){ |
||
108 | $title = $mediafile->getTitl(); |
||
109 | $file = $mediafile->getFile(); |
||
110 | if(isset($title) || isset($file)){ |
||
111 | Note::create([ |
||
112 | 'name' => mb_convert_encoding($title, 'UTF-8', 'UTF-8'), |
||
113 | 'description' => mb_convert_encoding($file, 'UTF-8', 'UTF-8') |
||
114 | ]); |
||
115 | } |
||
116 | }; |
||
117 | Individual::create([ |
||
118 | 'first_name' => $name, |
||
119 | 'last_name' => $surn, |
||
120 | 'gender' => $sex, |
||
121 | 'is_active' => false |
||
122 | ]); |
||
175 |