| Conditions | 13 |
| Paths | 27 |
| Total Lines | 46 |
| Code Lines | 28 |
| 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 |
||
| 71 | //No files so it's the first time we attempt to synchronize. |
||
| 72 | $appointmentsOld = []; |
||
| 73 | }else{ |
||
| 74 | //Get the last old appointments data. |
||
| 75 | $appointmentsOldHistory = FileChangesHelper::getJsonContentFromFile($appointmentsOldHistoryFilePath); |
||
| 76 | $appointmentsOld = DetectAppointmentsChangingsService::recursiveArrayObjectToFullArray($appointmentsOldHistory); |
||
| 77 | } |
||
| 78 | //Check if they are changes. |
||
| 79 | $timestamp = time(); |
||
| 80 | $listChangings = $this->detectAppointmentsChangingsService->detectAppointmentsChangings($appointmentsOld,$appointmentsNew,$timestamp); |
||
| 81 | if(!$appointmentsOld || ((isset($listChangings['updated']) && !empty($listChangings['updated'])) |
||
|
|
|||
| 82 | || (isset($listChangings['deleted']) && !empty($listChangings['deleted'])))){ |
||
| 83 | //Changes? So we save the new online appointments |
||
| 84 | FileChangesHelper::saveAppointmentsFileByHistory($this->dirPathHistoryAppointments.'/appointments_'.$eventCode.'.json',json_encode($appointmentsNew)); |
||
| 85 | $output->writeln('Detect changes - Save Changes'); |
||
| 86 | }else{ |
||
| 87 | $output->writeln('Detect changes - No Changes'); |
||
| 88 | } |
||
| 89 | foreach ($this->listeners as $listener){ |
||
| 90 | //Run Listener. For instance,Here we can use ChangingsToFileListeners to save the changes in file. |
||
| 91 | $listener->run($eventCode,$listChangings); |
||
| 92 | } |
||
| 93 | }else{ |
||
| 94 | $output->writeln('Detect changes - Stop.'); |
||
| 95 | } |
||
| 96 | } |
||
| 97 | |||
| 98 | } |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.