@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | } |
49 | 49 | |
50 | 50 | /** |
51 | - * @param $eventCode |
|
51 | + * @param string $eventCode |
|
52 | 52 | * @param null|int $start |
53 | 53 | * @param null|int $maxResult |
54 | 54 | * @return mixed |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | |
210 | 210 | /** |
211 | 211 | * @param array $appointments |
212 | - * @param $timestamp |
|
212 | + * @param string $timestamp |
|
213 | 213 | * @return array |
214 | 214 | */ |
215 | 215 | public static function insertDateTimeChanges(array $appointments, $timestamp) |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | { |
102 | 102 | if (is_object($object)) { |
103 | 103 | |
104 | - return (array)$object; |
|
104 | + return (array) $object; |
|
105 | 105 | } |
106 | 106 | return $object; |
107 | 107 | } |
@@ -243,15 +243,15 @@ discard block |
||
243 | 243 | } |
244 | 244 | $codeCheckDirectory = FileChangesHelper::checkDirectory($this->dirPathHistoryAppointments); |
245 | 245 | if ($codeCheckDirectory === 'no_directory') { |
246 | - $this->logger->error('Path ' . $this->dirPathHistoryAppointments . ' doesn\'t exists.'); |
|
246 | + $this->logger->error('Path '.$this->dirPathHistoryAppointments.' doesn\'t exists.'); |
|
247 | 247 | return; |
248 | 248 | } |
249 | 249 | if ($codeCheckDirectory === 'not_readable') { |
250 | - $this->logger->error('Path ' . $this->dirPathHistoryAppointments . ' is not readable.'); |
|
250 | + $this->logger->error('Path '.$this->dirPathHistoryAppointments.' is not readable.'); |
|
251 | 251 | return; |
252 | 252 | } |
253 | 253 | if ($codeCheckDirectory === 'not_writable') { |
254 | - $this->logger->error('Path ' . $this->dirPathHistoryAppointments . ' is not writable.'); |
|
254 | + $this->logger->error('Path '.$this->dirPathHistoryAppointments.' is not writable.'); |
|
255 | 255 | return; |
256 | 256 | } |
257 | 257 | $this->lock->acquireLock(); |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | if (!$appointmentsOldHistoryFilePath) { |
266 | 266 | //No files so it's the first time we attempt to synchronize. |
267 | 267 | $appointmentsOld = []; |
268 | - } else { |
|
268 | + }else { |
|
269 | 269 | //Get the last old appointments data. |
270 | 270 | $appointmentsOldHistory = FileChangesHelper::getJsonContentFromFile($appointmentsOldHistoryFilePath); |
271 | 271 | $appointmentsOld = self::recursiveArrayObjectToFullArray($appointmentsOldHistory); |
@@ -276,9 +276,9 @@ discard block |
||
276 | 276 | if (!$appointmentsOld || ((isset($listChangings['updated']) && !empty($listChangings['updated'])) |
277 | 277 | || (isset($listChangings['deleted']) && !empty($listChangings['deleted'])))) { |
278 | 278 | //Changes? So we save the new online appointments |
279 | - FileChangesHelper::saveAppointmentsFileByHistory($this->dirPathHistoryAppointments . '/appointments_' . $eventCode . '.json', json_encode($appointmentsNew)); |
|
279 | + FileChangesHelper::saveAppointmentsFileByHistory($this->dirPathHistoryAppointments.'/appointments_'.$eventCode.'.json', json_encode($appointmentsNew)); |
|
280 | 280 | $this->logger->info('Detect changes - Save Changes'); |
281 | - } else { |
|
281 | + }else { |
|
282 | 282 | $this->logger->info('Detect changes - No Changes'); |
283 | 283 | } |
284 | 284 | foreach ($this->listeners as $listener) { |
@@ -10,8 +10,8 @@ discard block |
||
10 | 10 | * @param $dirPath |
11 | 11 | * @return bool |
12 | 12 | */ |
13 | - public static function createDirectory($dirPath){ |
|
14 | - if(!file_exists($dirPath)){ |
|
13 | + public static function createDirectory($dirPath) { |
|
14 | + if (!file_exists($dirPath)) { |
|
15 | 15 | return mkdir($dirPath, 0775, true, null); |
16 | 16 | } |
17 | 17 | return false; |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | * @param string $msg |
24 | 24 | * @return void |
25 | 25 | */ |
26 | - public static function writeFile($path,$msg){ |
|
26 | + public static function writeFile($path, $msg) { |
|
27 | 27 | $f = fopen($path, "w+"); |
28 | 28 | fwrite($f, $msg); |
29 | 29 | fclose($f); |
@@ -42,15 +42,15 @@ discard block |
||
42 | 42 | * @param string $contents |
43 | 43 | * @return void |
44 | 44 | */ |
45 | - public static function saveAppointmentsFileByHistory($filePath,$contents){ |
|
45 | + public static function saveAppointmentsFileByHistory($filePath, $contents) { |
|
46 | 46 | $time = time(); |
47 | 47 | $file = pathinfo($filePath); |
48 | 48 | $fileNamebase = $file['filename']; |
49 | 49 | $filePath = $file['dirname'].'/'.$fileNamebase.'_'.$time.'.json'; |
50 | - if(!file_exists($filePath)){ |
|
51 | - self::writeFile($filePath,''); |
|
50 | + if (!file_exists($filePath)) { |
|
51 | + self::writeFile($filePath, ''); |
|
52 | 52 | } |
53 | - self::writeFile($filePath,$contents); |
|
53 | + self::writeFile($filePath, $contents); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
@@ -58,9 +58,9 @@ discard block |
||
58 | 58 | * @param $path |
59 | 59 | * @return string |
60 | 60 | */ |
61 | - public static function getContentFile($path){ |
|
62 | - if(!file_exists($path)){ |
|
63 | - self::writeFile($path,''); |
|
61 | + public static function getContentFile($path) { |
|
62 | + if (!file_exists($path)) { |
|
63 | + self::writeFile($path, ''); |
|
64 | 64 | } |
65 | 65 | $handle = fopen($path, "rb"); |
66 | 66 | if (FALSE === $handle) { |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param string $path |
80 | 80 | * @return mixed |
81 | 81 | */ |
82 | - public static function getJsonContentFromFile($path){ |
|
82 | + public static function getJsonContentFromFile($path) { |
|
83 | 83 | $contents = self::getContentFile($path); |
84 | 84 | return json_decode($contents, true); |
85 | 85 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * @param string $pathDir |
91 | 91 | * @return array |
92 | 92 | */ |
93 | - public static function getFilesListHistoryAppointmentsByEventCode($eventCode,$pathDir){ |
|
93 | + public static function getFilesListHistoryAppointmentsByEventCode($eventCode, $pathDir) { |
|
94 | 94 | $fileList = array(); |
95 | 95 | $files = glob($pathDir.'/appointments_'.$eventCode.'_*.json'); |
96 | 96 | foreach ($files as $file) { |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * @param string $pathDir |
108 | 108 | * @return string |
109 | 109 | */ |
110 | - public static function getTheLastAppointmentsSaved($eventCode,$pathDir){ |
|
111 | - $fileList = self::getFilesListHistoryAppointmentsByEventCode($eventCode,$pathDir); |
|
110 | + public static function getTheLastAppointmentsSaved($eventCode, $pathDir) { |
|
111 | + $fileList = self::getFilesListHistoryAppointmentsByEventCode($eventCode, $pathDir); |
|
112 | 112 | return array_shift($fileList); |
113 | 113 | } |
114 | 114 | |
@@ -128,20 +128,20 @@ discard block |
||
128 | 128 | |
129 | 129 | public static function commandIsLocked(string $pathDir): bool |
130 | 130 | { |
131 | - return file_exists($pathDir. '/command.lock'); |
|
131 | + return file_exists($pathDir.'/command.lock'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | public static function lockCommand(string $pathDir): void |
135 | 135 | { |
136 | 136 | if (!self::commandIsLocked($pathDir)) { |
137 | - self::writeFile($pathDir. '/command.lock','1'); |
|
137 | + self::writeFile($pathDir.'/command.lock', '1'); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
141 | 141 | public static function unlockCommand(string $pathDir): void |
142 | 142 | { |
143 | 143 | if (self::commandIsLocked($pathDir)) { |
144 | - self::removeFile($pathDir. '/command.lock'); |
|
144 | + self::removeFile($pathDir.'/command.lock'); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | } |
148 | 148 | \ No newline at end of file |