Conditions | 12 |
Paths | 18 |
Total Lines | 41 |
Code Lines | 25 |
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 | public function run(InputInterface $input, OutputInterface $output) |
||
72 | { |
||
73 | $eventCode = null; |
||
74 | //Get the EventCode we need to check. |
||
75 | if($this->filePathEventToCheck && file_exists($this->filePathEventToCheck)){ |
||
76 | $eventCode = FileChangesHelper::getContentFile($this->filePathEventToCheck); |
||
77 | } |
||
78 | //That permits to stop the followings instructions when we are makings changes on Certain. |
||
79 | if(!file_exists($this->fileLockAuthorizeRun.'/detect_appointments_changes.lock') && $eventCode){ |
||
80 | $output->writeln('Detect changes - Run.'); |
||
81 | //Get the online appointments. |
||
82 | $appointmentsNewCertain = $this->detectAppointmentsChangingsService->getCurrentAppoiments($eventCode); |
||
83 | $appointmentsNew = DetectAppointmentsChangingsService::recursiveArrayObjectToFullArray($appointmentsNewCertain); |
||
84 | //Get the last saved appointments to get old data. |
||
85 | $appointmentsOldHistoryFilePath = FileChangesHelper::getTheLastAppointmentsSaved($eventCode,$this->dirPathHistoryAppointments); |
||
86 | if(!$appointmentsOldHistoryFilePath){ |
||
87 | //No files so it's the first time we attempt to synchronize. |
||
88 | $appointmentsOld = []; |
||
89 | }else{ |
||
90 | //Get the last old appointments data. |
||
91 | $appointmentsOldHistory = FileChangesHelper::getJsonContentFromFile($appointmentsOldHistoryFilePath); |
||
92 | $appointmentsOld = DetectAppointmentsChangingsService::recursiveArrayObjectToFullArray($appointmentsOldHistory); |
||
93 | } |
||
94 | //Check if they are changes. |
||
95 | $listChangings = $this->detectAppointmentsChangingsService->detectAppointmentsChangings($appointmentsOld,$appointmentsNew); |
||
96 | if(!$appointmentsOld || ((isset($listChangings['updated']) && !empty($listChangings['updated'])) |
||
97 | || (isset($listChangings['deleted']) && !empty($listChangings['deleted'])))){ |
||
98 | //Changes? So we save the new online appointments |
||
99 | FileChangesHelper::saveAppointmentsFileByHistory($this->dirPathHistoryAppointments.'/appointments_'.$eventCode.'.json',json_encode($appointmentsNew)); |
||
100 | $output->writeln('Detect changes - Save Changes'); |
||
101 | }else{ |
||
102 | $output->writeln('Detect changes - No Changes'); |
||
103 | } |
||
104 | foreach ($this->listeners as $listener){ |
||
105 | //Run Listener. For instance,Here we can use ChangingsToFileListeners to save the changes in file. |
||
106 | $listener->run($eventCode,$listChangings); |
||
107 | } |
||
108 | }else{ |
||
109 | $output->writeln('Detect changes - Stop.'); |
||
110 | } |
||
111 | } |
||
112 | |||
113 | } |
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.