| Conditions | 3 |
| Paths | 3 |
| Total Lines | 70 |
| 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 |
||
| 40 | protected function insertData() |
||
| 41 | { |
||
| 42 | /* silahkan di rubah sesuai kebutuhan */ |
||
| 43 | foreach($this->readCSV() as $data){ |
||
| 44 | |||
| 45 | $this->model->create([ |
||
| 46 | 'user_id' => $data['user_id'], |
||
| 47 | 'nomor_un' => $data['nomor_un'], |
||
| 48 | 'nomor_kk' => $data['nomor_kk'], |
||
| 49 | 'nisn' => $data['nisn'], |
||
| 50 | 'nama_siswa' => $data['nama_siswa'], |
||
| 51 | 'bahasa_indonesia' => $data['bahasa_indonesia'], |
||
| 52 | 'bahasa_inggris' => $data['bahasa_inggris'], |
||
| 53 | 'matematika' => $data['matematika'], |
||
| 54 | 'ipa' => $data['ipa'], |
||
| 55 | 'tempat_lahir' => $data['tempat_lahir'], |
||
| 56 | 'tanggal_lahir' => $data['tanggal_lahir'], |
||
| 57 | 'jenis_kelamin' => $data['jenis_kelamin'], |
||
| 58 | 'nama_ortu' => $data['nama_ortu'], |
||
| 59 | 'alamat' => $data['alamat'], |
||
| 60 | 'npsn_asal_sekolah' => $data['npsn_asal_sekolah'], |
||
| 61 | 'asal_sekolah' => $data['asal_sekolah'], |
||
| 62 | |||
| 63 | ]); |
||
| 64 | |||
| 65 | if($this->textInfo){ |
||
| 66 | echo "============[DATA]============\n"; |
||
| 67 | $this->orangeText('nama_siswa : ').$this->greenText($data['nama_siswa']); |
||
| 68 | echo"\n"; |
||
| 69 | $this->orangeText('nomor_un : ').$this->greenText($data['nomor_un']); |
||
| 70 | echo"\n"; |
||
| 71 | $this->orangeText('nomor_kk : ').$this->greenText($data['nomor_kk']); |
||
| 72 | echo"\n"; |
||
| 73 | $this->orangeText('nama_siswa : ').$this->greenText($data['nama_siswa']); |
||
| 74 | echo"\n"; |
||
| 75 | $this->orangeText('bahasa_indonesia : ').$this->greenText($data['bahasa_indonesia']); |
||
| 76 | echo"\n"; |
||
| 77 | $this->orangeText('bahasa_inggris : ').$this->greenText($data['bahasa_inggris']); |
||
| 78 | echo"\n"; |
||
| 79 | $this->orangeText('matematika : ').$this->greenText($data['matematika']); |
||
| 80 | echo"\n"; |
||
| 81 | $this->orangeText('ipa : ').$this->greenText($data['ipa']); |
||
| 82 | echo"\n"; |
||
| 83 | $this->orangeText('nisn : ').$this->greenText($data['nisn']); |
||
| 84 | echo"\n"; |
||
| 85 | $this->orangeText('tempat_lahir : ').$this->greenText($data['tempat_lahir']); |
||
| 86 | echo"\n"; |
||
| 87 | $this->orangeText('tanggal_lahir : ').$this->greenText($data['tanggal_lahir']); |
||
| 88 | echo"\n"; |
||
| 89 | $this->orangeText('jenis_kelamin : ').$this->greenText($data['jenis_kelamin']); |
||
| 90 | echo"\n"; |
||
| 91 | $this->orangeText('nama_ortu : ').$this->greenText($data['nama_ortu']); |
||
| 92 | echo"\n"; |
||
| 93 | $this->orangeText('alamat : ').$this->greenText($data['alamat']); |
||
| 94 | echo"\n"; |
||
| 95 | $this->orangeText('npsn_asal_sekolah : ').$this->greenText($data['npsn_asal_sekolah']); |
||
| 96 | echo"\n"; |
||
| 97 | $this->orangeText('asal_sekolah : ').$this->greenText($data['asal_sekolah']); |
||
| 98 | echo"\n"; |
||
| 99 | |||
| 100 | echo "============[DATA]============\n\n"; |
||
| 101 | } |
||
| 102 | |||
| 103 | } |
||
| 104 | |||
| 105 | |||
| 106 | |||
| 107 | $this->greenText('[ SEEDER DONE ]'); |
||
| 108 | echo"\n\n"; |
||
| 109 | } |
||
| 110 | /* text color: orange */ |
||
| 150 |
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.