| Conditions | 4 |
| Paths | 3 |
| Total Lines | 68 |
| Code Lines | 57 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 10 | ||
| Bugs | 0 | Features | 3 |
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 |
||
| 58 | public function process($student){ |
||
| 59 | $institution_class = Institution_class::select('id')->where('institution_id',$student['institution_id'])->get()->toArray(); |
||
| 60 | $wrongStudentsClass = Institution_class_student::whereNotIn('institution_class_id',$institution_class) |
||
| 61 | ->orWhere('institution_class_id',0) |
||
| 62 | ->where('student_id',$student['student_id']) |
||
| 63 | ->get()->toArray(); |
||
| 64 | |||
| 65 | if(count($wrongStudentsClass)>0){ |
||
| 66 | Institution_class_student::where('student_id',$student['student_id'])->forceDelete(); |
||
| 67 | Institution_student_admission::where('student_id',$student['student_id'])->forceDelete(); |
||
| 68 | Institution_student::where('student_id',$student['student_id'])->forceDelete(); |
||
| 69 | |||
| 70 | array_walk($wrongStudentsClass,array($this,'updateClassCount')); |
||
| 71 | |||
| 72 | echo "deleted wrong class reference:" .$student['student_id']; |
||
| 73 | |||
| 74 | $institutionClass = Institution_class::getGradeClasses($student['education_grade_id'],$student['institution_id']); |
||
| 75 | |||
| 76 | if(count($institutionClass) == 1){ |
||
| 77 | $start_date = new Carbon($student['start_date']); |
||
| 78 | $end_date = new Carbon($student['end_date']); |
||
| 79 | Institution_student_admission::create( |
||
| 80 | [ |
||
| 81 | 'student_id'=>$student['student_id'], |
||
| 82 | 'institution_class_id'=> $institutionClass[0]['id'], |
||
| 83 | 'start_date' => $student['start_date'], |
||
| 84 | 'start_year' => $start_date->format('Y'), |
||
| 85 | 'end_date' => $student['start_date'], |
||
| 86 | 'end_year' => $end_date->format('Y'), |
||
| 87 | 'education_grade_id' => $student['education_grade_id'], |
||
| 88 | 'institution_id' => $student['institution_id'], |
||
| 89 | 'status_id' => 124, |
||
| 90 | 'academic_period_id' => $student['academic_period_id'], |
||
| 91 | 'created_user_id' => $student['created_user_id'], |
||
| 92 | 'updated_from' => $student['updated_from'] |
||
| 93 | ] |
||
| 94 | ); |
||
| 95 | $institutionClassStudent = [ |
||
| 96 | 'student_id'=>$student['student_id'], |
||
| 97 | 'institution_class_id'=> $institutionClass[0]['id'], |
||
| 98 | 'education_grade_id' => $student['education_grade_id'], |
||
| 99 | 'institution_id' => $student['institution_id'], |
||
| 100 | 'status_id' => 124, |
||
| 101 | 'academic_period_id' => $student['academic_period_id'], |
||
| 102 | 'student_status_id' => 1, |
||
| 103 | 'created_user_id' => $student['created_user_id'], |
||
| 104 | 'updated_from' => $student['updated_from'] |
||
| 105 | ]; |
||
| 106 | Institution_class_student::create($institutionClassStudent); |
||
| 107 | Institution_student::create([ |
||
| 108 | 'student_id'=>$student['student_id'], |
||
| 109 | 'student_status_id' => 1, |
||
| 110 | 'education_grade_id' => $student['education_grade_id'], |
||
| 111 | 'institution_id' => $student['institution_id'], |
||
| 112 | 'academic_period_id' => $student['academic_period_id'], |
||
| 113 | 'created_user_id' => $student['created_user_id'], |
||
| 114 | 'start_date' => $student['start_date'], |
||
| 115 | 'start_year' => $start_date->format('Y'), |
||
| 116 | 'end_date' => $student['start_date'], |
||
| 117 | 'end_year' => $end_date->format('Y'), |
||
| 118 | 'taking_g5_exam' => $student['updated_from'] == 'doe' ? true: false, |
||
| 119 | 'income_at_g5' => $student['income_at_g5'], |
||
| 120 | 'updated_from' => $student['updated_from'], |
||
| 121 | 'exam_center_for_special_education_g5' => $student['exam_center_for_special_education_g5'], |
||
| 122 | 'modified_user_id' => $student['modified_user_id'], |
||
| 123 | ]); |
||
| 124 | echo "updated:" .$student['student_id']; |
||
| 125 | array_walk([$institutionClassStudent],array($this,'updateClassCount')); |
||
|
|
|||
| 126 | } |
||
| 140 |