| Conditions | 3 |
| Paths | 3 |
| Total Lines | 67 |
| Code Lines | 56 |
| 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 |
||
| 51 | protected function insertData() |
||
| 52 | { |
||
| 53 | /* silahkan di rubah sesuai kebutuhan */ |
||
| 54 | foreach($this->readCSV() as $data){ |
||
| 55 | |||
| 56 | $this->model->create([ |
||
| 57 | 'id' => $data['id'], |
||
| 58 | 'user_id' => $data['user_id'], |
||
| 59 | 'nama' => $data['nama'], |
||
| 60 | 'npsn' => $data['npsn'], |
||
| 61 | 'jenis_sekolah_id' => $data['jenis_sekolah_id'], |
||
| 62 | 'alamat' => $data['alamat'], |
||
| 63 | 'logo' => $data['logo'], |
||
| 64 | 'foto_gedung' => $data['foto_gedung'], |
||
| 65 | 'province_id' => $data['province_id'], |
||
| 66 | 'city_id' => $data['city_id'], |
||
| 67 | 'district_id' => $data['district_id'], |
||
| 68 | 'village_id' => $data['village_id'], |
||
| 69 | 'no_telp' => $data['no_telp'], |
||
| 70 | 'email' => $data['email'], |
||
| 71 | 'kode_zona' => $data['kode_zona'], |
||
| 72 | 'uuid' => $data['uuid'], |
||
| 73 | |||
| 74 | ]); |
||
| 75 | |||
| 76 | if($this->textInfo){ |
||
| 77 | echo "============[DATA]============\n"; |
||
| 78 | $this->orangeText('nama : ').$this->greenText($data['nama']); |
||
| 79 | echo"\n"; |
||
| 80 | $this->orangeText('npsn : ').$this->greenText($data['npsn']); |
||
| 81 | echo"\n"; |
||
| 82 | $this->orangeText('jenis_sekolah_id : ').$this->greenText($data['jenis_sekolah_id']); |
||
| 83 | echo"\n"; |
||
| 84 | $this->orangeText('alamat : ').$this->greenText($data['alamat']); |
||
| 85 | echo"\n"; |
||
| 86 | $this->orangeText('logo : ').$this->greenText($data['logo']); |
||
| 87 | echo"\n"; |
||
| 88 | $this->orangeText('foto_gedung : ').$this->greenText($data['foto_gedung']); |
||
| 89 | echo"\n"; |
||
| 90 | $this->orangeText('province_id : ').$this->greenText($data['province_id']); |
||
| 91 | echo"\n"; |
||
| 92 | $this->orangeText('city_id : ').$this->greenText($data['city_id']); |
||
| 93 | echo"\n"; |
||
| 94 | $this->orangeText('district_id : ').$this->greenText($data['district_id']); |
||
| 95 | echo"\n"; |
||
| 96 | $this->orangeText('village_id : ').$this->greenText($data['village_id']); |
||
| 97 | echo"\n"; |
||
| 98 | $this->orangeText('no_telp : ').$this->greenText($data['no_telp']); |
||
| 99 | echo"\n"; |
||
| 100 | $this->orangeText('email : ').$this->greenText($data['logo']); |
||
| 101 | echo"\n"; |
||
| 102 | $this->orangeText('kode_zona : ').$this->greenText($data['kode_zona']); |
||
| 103 | echo"\n"; |
||
| 104 | $this->orangeText('user_id : ').$this->greenText($data['user_id']); |
||
| 105 | echo"\n"; |
||
| 106 | $this->orangeText('id : ').$this->greenText($data['id']); |
||
| 107 | echo"\n"; |
||
| 108 | $this->orangeText('uuid : ').$this->greenText($data['uuid']); |
||
| 109 | echo"\n"; |
||
| 110 | echo "============[DATA]============\n\n"; |
||
| 111 | } |
||
| 112 | |||
| 113 | } |
||
| 114 | |||
| 115 | $this->greenText('[ SEEDER DONE ]'); |
||
| 116 | echo"\n\n"; |
||
| 117 | } |
||
| 118 | |||
| 163 |
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.