Conditions | 3 |
Paths | 4 |
Total Lines | 52 |
Code Lines | 35 |
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 | 'user_id' => $data['user_id'], |
||
48 | 'master_zona_id' => $data['master_zona_id'], |
||
49 | 'nomor_un' => $data['nomor_un'], |
||
50 | 'sekolah_id' => $data['sekolah_id'], |
||
51 | 'zona_siswa' => $data['zona_siswa'], |
||
52 | 'zona_sekolah' => $data['zona_sekolah'], |
||
53 | 'lokasi_siswa' => $data['lokasi_siswa'], |
||
54 | 'lokasi_sekolah' => $data['lokasi_sekolah'], |
||
55 | 'nilai_zona' => $data['nilai_zona'], |
||
56 | |||
57 | ]); |
||
58 | |||
59 | |||
60 | } |
||
61 | |||
62 | if($this->textInfo){ |
||
63 | echo "============[DATA]============\n"; |
||
64 | $this->orangeText('user_id : ').$this->greenText($data['user_id']); |
||
65 | echo"\n"; |
||
66 | $this->orangeText('master_zona_id : ').$this->greenText($data['master_zona_id']); |
||
67 | echo"\n"; |
||
68 | $this->orangeText('nomor_un : ').$this->greenText($data['nomor_un']); |
||
69 | echo"\n"; |
||
70 | $this->orangeText('sekolah_id : ').$this->greenText($data['sekolah_id']); |
||
71 | echo"\n"; |
||
72 | $this->orangeText('zona_siswa : ').$this->greenText($data['zona_siswa']); |
||
73 | echo"\n"; |
||
74 | $this->orangeText('zona_sekolah : ').$this->greenText($data['zona_sekolah']); |
||
75 | echo"\n"; |
||
76 | $this->orangeText('lokasi_siswa : ').$this->greenText($data['lokasi_siswa']); |
||
77 | echo"\n"; |
||
78 | $this->orangeText('lokasi_sekolah : ').$this->greenText($data['lokasi_sekolah']); |
||
79 | echo"\n"; |
||
80 | $this->orangeText('nilai_zona : ').$this->greenText($data['nilai_zona']); |
||
81 | echo"\n"; |
||
82 | |||
83 | |||
84 | |||
85 | |||
86 | echo "============[DATA]============\n\n"; |
||
87 | } |
||
88 | |||
89 | $this->greenText('[ SEEDER DONE ]'); |
||
90 | echo"\n\n"; |
||
91 | } |
||
92 | /* text color: orange */ |
||
124 |
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.