Completed
Push — master ( 4f2a17...deb4c2 )
by
unknown
09:16
created
src/Services/DetectAppointmentsChangingsService.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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) {
Please login to merge, or discard this patch.
src/Helpers/FileChangesHelper.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
Please login to merge, or discard this patch.
src/Listeners/ChangingsToFileListeners.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,22 +29,22 @@  discard block
 block discarded – undo
29 29
      * @param array $elements
30 30
      * @return void
31 31
      */
32
-    public function run(string $eventCode,array $elements, array $options = [])
32
+    public function run(string $eventCode, array $elements, array $options = [])
33 33
     {
34
-        if(isset($elements['updated'])){
35
-            foreach ($elements['updated'] as $element){
36
-                if(!is_array($element)){
34
+        if (isset($elements['updated'])) {
35
+            foreach ($elements['updated'] as $element) {
36
+                if (!is_array($element)) {
37 37
                     $element = [$element];
38 38
                 }
39
-                $this->updateUpdateListFile($eventCode,$element);
39
+                $this->updateUpdateListFile($eventCode, $element);
40 40
             }
41 41
         }
42
-        if(isset($elements['deleted'])){
43
-            foreach ($elements['deleted'] as $element){
44
-                if(!is_array($element)){
42
+        if (isset($elements['deleted'])) {
43
+            foreach ($elements['deleted'] as $element) {
44
+                if (!is_array($element)) {
45 45
                     $element = [$element];
46 46
                 }
47
-                $this->updateDeleteListFile($eventCode,$element);
47
+                $this->updateDeleteListFile($eventCode, $element);
48 48
             }
49 49
         }
50 50
     }
@@ -55,10 +55,10 @@  discard block
 block discarded – undo
55 55
      * @param array $element
56 56
      * @return void
57 57
      */
58
-    private function updateFile($filePath,array $element){
58
+    private function updateFile($filePath, array $element) {
59 59
         $content = FileChangesHelper::getJsonContentFromFile($filePath);
60 60
         $content[] = $element;
61
-        FileChangesHelper::writeFile($filePath,json_encode($content));
61
+        FileChangesHelper::writeFile($filePath, json_encode($content));
62 62
     }
63 63
 
64 64
     /**
@@ -66,10 +66,10 @@  discard block
 block discarded – undo
66 66
      * @param array $element
67 67
      * @return void
68 68
      */
69
-    private function updateUpdateListFile($eventCode,array $element){
69
+    private function updateUpdateListFile($eventCode, array $element) {
70 70
         FileChangesHelper::createDirectory($this->dirPathChangings);
71 71
         $fileName = 'update_'.$eventCode.'.json';
72
-        $this->updateFile($this->dirPathChangings.'/'.$fileName,$element);
72
+        $this->updateFile($this->dirPathChangings.'/'.$fileName, $element);
73 73
     }
74 74
 
75 75
     /**
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
      * @param array $element
78 78
      * @return void
79 79
      */
80
-    private function updateDeleteListFile($eventCode,array $element){
80
+    private function updateDeleteListFile($eventCode, array $element) {
81 81
         FileChangesHelper::createDirectory($this->dirPathChangings);
82 82
         $fileName = 'delete_'.$eventCode.'.json';
83
-        $this->updateFile($this->dirPathChangings.'/'.$fileName,$element);
83
+        $this->updateFile($this->dirPathChangings.'/'.$fileName, $element);
84 84
     }
85 85
 }
86 86
\ No newline at end of file
Please login to merge, or discard this patch.