| Conditions | 3 |
| Paths | 4 |
| Total Lines | 52 |
| Code Lines | 38 |
| 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 |
||
| 40 | protected function insertData() |
||
| 41 | { |
||
| 42 | /* silahkan di rubah sesuai kebutuhan */ |
||
| 43 | foreach($this->readCSV() as $data){ |
||
| 44 | |||
| 45 | |||
| 46 | $this->model->create([ |
||
| 47 | 'nomor_un' => $data['nomor_un'], |
||
| 48 | 'alamat_ortu' => $data['alamat_ortu'], |
||
| 49 | 'nama_ayah' => $data['nama_ayah'], |
||
| 50 | 'nama_ibu' => $data['nama_ibu'], |
||
| 51 | 'kerja_ayah' => $data['kerja_ayah'], |
||
| 52 | 'pendidikan_ayah' => $data['pendidikan_ayah'], |
||
| 53 | 'kerja_ibu' => $data['kerja_ibu'], |
||
| 54 | 'pendidikan_ibu' => $data['pendidikan_ibu'], |
||
| 55 | 'no_telp' => $data['no_telp'], |
||
| 56 | 'user_id' => $data['user_id'], |
||
| 57 | |||
| 58 | ]); |
||
| 59 | |||
| 60 | |||
| 61 | } |
||
| 62 | |||
| 63 | if($this->textInfo){ |
||
| 64 | echo "============[DATA]============\n"; |
||
| 65 | $this->orangeText('nomor_un : ').$this->greenText($data['nomor_un']); |
||
| 66 | echo"\n"; |
||
| 67 | $this->orangeText('alamat_ortu : ').$this->greenText($data['alamat_ortu']); |
||
| 68 | echo"\n"; |
||
| 69 | $this->orangeText('nama_ayah : ').$this->greenText($data['nama_ayah']); |
||
| 70 | echo"\n"; |
||
| 71 | $this->orangeText('nama_ibu : ').$this->greenText($data['nama_ibu']); |
||
| 72 | echo"\n"; |
||
| 73 | $this->orangeText('kerja_ayah : ').$this->greenText($data['kerja_ayah']); |
||
| 74 | echo"\n"; |
||
| 75 | $this->orangeText('pendidikan_ayah : ').$this->greenText($data['pendidikan_ayah']); |
||
| 76 | echo"\n"; |
||
| 77 | $this->orangeText('kerja_ibu : ').$this->greenText($data['kerja_ibu']); |
||
| 78 | echo"\n"; |
||
| 79 | $this->orangeText('pendidikan_ibu : ').$this->greenText($data['pendidikan_ibu']); |
||
| 80 | echo"\n"; |
||
| 81 | $this->orangeText('no_telp : ').$this->greenText($data['no_telp']); |
||
| 82 | echo"\n"; |
||
| 83 | $this->orangeText('user_id : ').$this->greenText($data['user_id']); |
||
| 84 | echo"\n"; |
||
| 85 | |||
| 86 | echo "============[DATA]============\n\n"; |
||
| 87 | } |
||
| 88 | |||
| 89 | $this->greenText('[ SEEDER DONE ]'); |
||
| 90 | echo"\n\n"; |
||
| 91 | } |
||
| 92 | /* text color: orange */ |
||
| 115 |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.