Passed
Branch develop (1da827)
by Портнов
08:21 queued 03:02
created
src/Core/Workers/WorkerNotifyError.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -64,7 +64,7 @@
 block discarded – undo
64 64
                 continue;
65 65
             }
66 66
             if (Util::isJson($text_error)) {
67
-                $data       = json_decode($text_error, true);
67
+                $data = json_decode($text_error, true);
68 68
                 $test_email .= "<hr>";
69 69
                 $test_email .= "{$section}";
70 70
                 $test_email .= "<hr>";
Please login to merge, or discard this patch.
src/Common/Providers/ManagedCacheProvider.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         }
48 48
         $di->setShared(
49 49
             self::SERVICE_NAME,
50
-            function () use ($tempDir){
50
+            function() use ($tempDir){
51 51
                 $serializerFactory = new SerializerFactory();
52 52
 
53 53
                 $options = [
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
                     'storageDir'        => $tempDir,
57 57
                 ];
58 58
 
59
-                $adapter = new Stream ($serializerFactory, $options);
59
+                $adapter = new Stream($serializerFactory, $options);
60 60
 
61 61
                 return new Cache($adapter);
62 62
             }
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
         }
48 48
         $di->setShared(
49 49
             self::SERVICE_NAME,
50
-            function () use ($tempDir){
50
+            function () use ($tempDir)
51
+            {
51 52
                 $serializerFactory = new SerializerFactory();
52 53
 
53 54
                 $options = [
Please login to merge, or discard this patch.
src/Common/Providers/ModelsCacheProvider.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
         $di->setShared(
49 49
             self::SERVICE_NAME,
50
-            function () use ($tempDir){
50
+            function() use ($tempDir){
51 51
                 $serializerFactory = new SerializerFactory();
52 52
                 $options = [
53 53
                     'defaultSerializer' => 'php',
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                     'storageDir' => $tempDir
56 56
                 ];
57 57
 
58
-                $adapter = new Stream ($serializerFactory, $options);
58
+                $adapter = new Stream($serializerFactory, $options);
59 59
                 return new Cache($adapter);
60 60
             }
61 61
         );
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -47,7 +47,8 @@
 block discarded – undo
47 47
 
48 48
         $di->setShared(
49 49
             self::SERVICE_NAME,
50
-            function () use ($tempDir){
50
+            function () use ($tempDir)
51
+            {
51 52
                 $serializerFactory = new SerializerFactory();
52 53
                 $options = [
53 54
                     'defaultSerializer' => 'php',
Please login to merge, or discard this patch.
src/PBXCoreREST/Workers/WorkerApiCommands.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
         while ($this->needRestart === false) {
57 57
             $beanstalk->wait();
58 58
         }
59
-        if ($this->needRestart){
59
+        if ($this->needRestart) {
60 60
             Processes::restartAllWorkers();
61 61
         }
62 62
     }
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
                 $res->messages[] = "Unknown processor - {$processor} in prepareAnswer";
103 103
             }
104 104
         } catch (Throwable $exception) {
105
-            $res->messages[] = 'Exception on WorkerApiCommands - ' . $exception->getMessage();
106
-            $request        = [];
105
+            $res->messages[] = 'Exception on WorkerApiCommands - '.$exception->getMessage();
106
+            $request = [];
107 107
         } finally {
108 108
             $message->reply(json_encode($res->getResult()));
109 109
             if ($res->success) {
Please login to merge, or discard this patch.
src/PBXCoreREST/Workers/WorkerLongPoolAPI.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             $this->setChannelsData();
48 48
             if (is_array($data) && isset($data['infos'])) {
49 49
                 foreach ($data['infos'] as $channel_data) {
50
-                    $url = 'http://localhost/pbxcore/api/long/pub?id=' . $channel_data['channel'];
50
+                    $url = 'http://localhost/pbxcore/api/long/pub?id='.$channel_data['channel'];
51 51
 
52 52
                     $data_for_send = $this->execFunction($channel_data['channel']);
53 53
                     if ($data_for_send) {
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
                         $this->postData($url, "$data_for_send\n");
56 56
                     }
57 57
 
58
-                    if ( ! isset($COMMON_CNANNELS[$channel_data['channel']])) {
58
+                    if (!isset($COMMON_CNANNELS[$channel_data['channel']])) {
59 59
                         continue;
60 60
                     }
61 61
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     private function execFunction($channel, $common_chan = null)
133 133
     {
134 134
         clearstatcache();
135
-        if ( ! $this->checkAction($channel, $common_chan)) {
135
+        if (!$this->checkAction($channel, $common_chan)) {
136 136
             return '';
137 137
         }
138 138
         $data_for_send = null;
@@ -163,18 +163,18 @@  discard block
 block discarded – undo
163 163
      */
164 164
     private function checkAction($channel, $common_chan = null)
165 165
     {
166
-        if ( ! $common_chan) {
166
+        if (!$common_chan) {
167 167
             $actions = $GLOBALS['ACTIONS'];
168 168
         } else {
169 169
             $actions = $GLOBALS['COMMON_CNANNELS'][$common_chan];
170 170
         }
171 171
 
172 172
         $enable = false;
173
-        if ( ! $actions) {
173
+        if (!$actions) {
174 174
             return $enable;
175 175
         }
176 176
         // $data = null;
177
-        $now  = time();
177
+        $now = time();
178 178
 
179 179
         $action_data = $actions[$channel] ?? null;
180 180
         if ($action_data !== null) {
Please login to merge, or discard this patch.
src/Core/Workers/WorkerAmiListener.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      */
62 62
     public function callback($parameters): void
63 63
     {
64
-        if ($this->replyOnPingRequest($parameters)){
64
+        if ($this->replyOnPingRequest($parameters)) {
65 65
            return;
66 66
         }
67 67
 
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
         }
101 101
 
102 102
         if ($message_is_sent === false) {
103
-            Util::sysLogMsg('CDR_AMI_Connector', "Error send data to queue. " . $error);
103
+            Util::sysLogMsg('CDR_AMI_Connector', "Error send data to queue. ".$error);
104 104
         }
105 105
         // Логируем оповещение.
106 106
         Util::logMsgDb('WorkerCallEvents::class', json_decode($result, true));
Please login to merge, or discard this patch.
src/Core/Workers/WorkerCdr.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
             ]
90 90
         ];
91 91
 
92
-        $results   = Users::find($parameters);
92
+        $results = Users::find($parameters);
93 93
         foreach ($results as $record) {
94 94
             if (empty($record->email)) {
95 95
                 continue;
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
      */
159 159
     private function getActiveIdChannels(): array
160 160
     {
161
-        $am           = Util::getAstManager('off');
161
+        $am = Util::getAstManager('off');
162 162
         return $am->GetChannels(true);
163 163
     }
164 164
 
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
             $this->no_answered_calls[$row['linkedid']]['NOANSWER'] = false;
174 174
             return;
175 175
         }
176
-        if ( ! array_key_exists($row['dst_num'], $this->internal_numbers)) {
176
+        if (!array_key_exists($row['dst_num'], $this->internal_numbers)) {
177 177
             // dst_num - не является номером сотрудника. Это исходящий.
178 178
             return;
179 179
         }
@@ -238,8 +238,8 @@  discard block
 block discarded – undo
238 238
             if (!empty($row['recordingfile'])) {
239 239
                 // Удаляем файлы
240 240
                 $p_info = pathinfo($row['recordingfile']);
241
-                $fileName = $p_info['dirname'] . '/' . $p_info['filename'];
242
-                $file_list = [$fileName . '.mp3', $fileName . '.wav', $fileName . '_in.wav', $fileName . '_out.wav',];
241
+                $fileName = $p_info['dirname'].'/'.$p_info['filename'];
242
+                $file_list = [$fileName.'.mp3', $fileName.'.wav', $fileName.'_in.wav', $fileName.'_out.wav', ];
243 243
                 foreach ($file_list as $file) {
244 244
                     if (!file_exists($file) || is_dir($file)) {
245 245
                         continue;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
     /**
263 263
      */
264
-    private function getCheckResult(){
264
+    private function getCheckResult() {
265 265
         $result_data = $this->client_queue->getBody();
266 266
         // Получаем результат.
267 267
         $result = json_decode($result_data, true);
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
             }
273 273
             $result = $file_data;
274 274
         }
275
-        if ( ! is_array($result) && ! is_object($result)) {
275
+        if (!is_array($result) && !is_object($result)) {
276 276
             $result = [];
277 277
         }
278 278
         return $result;
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
                 Processes::mwExec("rm -rf {$row['recordingfile']}");
298 298
             }
299 299
         } elseif (!empty($row['recordingfile']) &&
300
-            !file_exists(Util::trimExtensionForFile($row['recordingfile']) . '.wav') &&
300
+            !file_exists(Util::trimExtensionForFile($row['recordingfile']).'.wav') &&
301 301
             !file_exists($row['recordingfile'])) {
302 302
             /** @var CallDetailRecordsTmp $rec_data */
303 303
             $rec_data = CallDetailRecordsTmp::findFirst("linkedid='{$row['linkedid']}' AND dst_chan='{$row['dst_chan']}'");
Please login to merge, or discard this patch.
src/Core/Workers/Cron/WorkerSafeScriptsCore.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $arrWorkers = $this->prepareWorkersList();
46 46
         ReactKernel::start(
47
-            function () use ($arrWorkers) {
47
+            function() use ($arrWorkers) {
48 48
                 // Parallel execution https://github.com/recoilphp/recoil
49 49
                 foreach ($arrWorkers as $workersWithCurrentType) {
50 50
                     foreach ($workersWithCurrentType as $worker) {
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     private function prepareWorkersList(): array
65 65
     {
66
-        $arrWorkers        = [
66
+        $arrWorkers = [
67 67
             self::CHECK_BY_AMI           =>
68 68
                 [
69 69
                     WorkerAmiListener::class,
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public function restartWorker($workerClassName): ?Generator
112 112
     {
113
-        Processes::processPHPWorker($workerClassName, 'start','restart');
113
+        Processes::processPHPWorker($workerClassName, 'start', 'restart');
114 114
         yield;
115 115
     }
116 116
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
         PBX::waitFullyBooted();
127 127
         $arrWorkers = $this->prepareWorkersList();
128 128
         ReactKernel::start(
129
-            function () use ($arrWorkers) {
129
+            function() use ($arrWorkers) {
130 130
                 // Parallel execution https://github.com/recoilphp/recoil
131 131
                 foreach ($arrWorkers as $workerType => $workersWithCurrentType) {
132 132
                     foreach ($workersWithCurrentType as $worker) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
         } catch (Throwable $e) {
178 178
             global $errorLogger;
179 179
             $errorLogger->captureException($e);
180
-            Util::sysLogMsg($workerClassName . '_EXCEPTION', $e->getMessage());
180
+            Util::sysLogMsg($workerClassName.'_EXCEPTION', $e->getMessage());
181 181
         }
182 182
         yield;
183 183
     }
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
         } catch (Throwable $e) {
251 251
             global $errorLogger;
252 252
             $errorLogger->captureException($e);
253
-            Util::sysLogMsg($workerClassName . '_EXCEPTION', $e->getMessage());
253
+            Util::sysLogMsg($workerClassName.'_EXCEPTION', $e->getMessage());
254 254
         }
255 255
         yield;
256 256
     }
Please login to merge, or discard this patch.
src/Core/Workers/WorkerCallEvents.php 1 patch
Spacing   +86 added lines, -86 removed lines patch added patch discarded remove patch
@@ -34,8 +34,8 @@  discard block
 block discarded – undo
34 34
      */
35 35
     public function MixMonitor($channel, $file_name = null, $sub_dir = null, $full_name = null): string
36 36
     {
37
-        $resFile = $this->mixMonitorChannels[$channel]??'';
38
-        if($resFile !== ''){
37
+        $resFile = $this->mixMonitorChannels[$channel] ?? '';
38
+        if ($resFile !== '') {
39 39
             return $resFile;
40 40
         }
41 41
         $resFile           = '';
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         if ($this->record_calls) {
44 44
             [$f, $options] = $this->setMonitorFilenameOptions($full_name, $sub_dir, $file_name);
45 45
             $arr = $this->am->GetChannels(false);
46
-            if(!in_array($channel, $arr, true)){
46
+            if (!in_array($channel, $arr, true)) {
47 47
                 return '';
48 48
             }
49 49
             $srcFile = "{$f}.wav";
@@ -85,9 +85,9 @@  discard block
 block discarded – undo
85 85
      */
86 86
     public function StopMixMonitor($channel): void
87 87
     {
88
-        if(isset($this->mixMonitorChannels[$channel])){
88
+        if (isset($this->mixMonitorChannels[$channel])) {
89 89
             unset($this->mixMonitorChannels[$channel]);
90
-        }else{
90
+        } else {
91 91
             return;
92 92
         }
93 93
         if ($this->record_calls) {
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
         foreach ($m_data as $row) {
126 126
             $row->writeAttribute('endtime', $data['start']);
127 127
             $res = $row->update();
128
-            if ( ! $res) {
128
+            if (!$res) {
129 129
                 Util::sysLogMsg('Action_app_end', implode(' ', $row->getMessages()));
130 130
             }
131 131
         }
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
             // мобильный и внутренний номер.
145 145
             $filter = [
146 146
                 '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:org_id:) AND endtime = ""',
147
-                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'],],
147
+                'bind' => ['UNIQUEID' => $data['UNIQUEID'], 'org_id' => $data['org_id'], ],
148 148
             ];
149 149
         } else {
150 150
             $filter = [
@@ -160,14 +160,14 @@  discard block
 block discarded – undo
160 160
         /** @var CallDetailRecordsTmp $row */
161 161
         $m_data = CallDetailRecordsTmp::find($filter);
162 162
         foreach ($m_data as $row) {
163
-            if ( ! is_object($row)) {
163
+            if (!is_object($row)) {
164 164
                 continue;
165 165
             }
166 166
             ///
167 167
             // Проверим, если более одного канала SIP/256 при входящем.
168 168
             $column_chan_name = ('ORIGINATE' === $row->dialstatus) ? 'src_chan' : 'dst_chan';
169 169
 
170
-            if ( ! empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
170
+            if (!empty($row->$column_chan_name) && $data['dst_chan'] !== $row->$column_chan_name) {
171 171
                 if ($row_create) {
172 172
                     continue;
173 173
                 }
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
                     $new_row->writeAttribute($attribute, $value);
182 182
                 }
183 183
                 $new_row->writeAttribute($column_chan_name, $data['dst_chan']);
184
-                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'] . '_' . $data['dst_chan']);
184
+                $new_row->writeAttribute('UNIQUEID', $data['UNIQUEID'].'_'.$data['dst_chan']);
185 185
                 // Подмена $row;
186 186
                 $row        = $new_row;
187 187
                 $row_create = true;
@@ -197,14 +197,14 @@  discard block
 block discarded – undo
197 197
                 $row->writeAttribute('dst_chan', $data['dst_chan']);
198 198
             }
199 199
 
200
-            if (isset($data['to_account']) && ! empty($data['to_account'])) {
200
+            if (isset($data['to_account']) && !empty($data['to_account'])) {
201 201
                 $row->writeAttribute($account_col, $data['to_account']);
202 202
             }
203
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
203
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
204 204
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
205 205
             }
206 206
             $res = $row->save();
207
-            if ( ! $res) {
207
+            if (!$res) {
208 208
                 Util::sysLogMsg('Action_dial_create_chan', implode(' ', $row->getMessages()));
209 209
             }
210 210
         }
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
             // Событие возникает, когда мы пытаемся перехватить вызов на соседний телефон.
225 225
             $filter = [
226 226
                 'UNIQUEID=:UNIQUEID:',
227
-                'bind' => ['UNIQUEID' => $data['old_id'],],
227
+                'bind' => ['UNIQUEID' => $data['old_id'], ],
228 228
             ];
229 229
             /** @var CallDetailRecordsTmp $m_data */
230 230
             $m_data = CallDetailRecordsTmp::find($filter);
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
                 $new_data['dst_chan']       = $data['agi_channel'];
239 239
                 $new_data['dst_num']        = $data['dst_num'];
240 240
                 $new_data['UNIQUEID']       = $data['id'];
241
-                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'],  'pickup_'.$new_data['UNIQUEID']);
241
+                $new_data['recordingfile']  = $this->MixMonitor($new_data['dst_chan'], 'pickup_'.$new_data['UNIQUEID']);
242 242
 
243 243
                 unset($new_data['id'], $new_data['end']);
244 244
                 self::insertDataToDbM($new_data);
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
                 $this->am->UserEvent('CdrConnector', ['AgiData' => $AgiData]);
251 251
             }
252 252
         } else {
253
-            if ( ! empty($data['ENDCALLONANSWER'])) {
253
+            if (!empty($data['ENDCALLONANSWER'])) {
254 254
                 // Переменная ENDCALLONANSWER устанавливается при начале работы умной маршуртизации.
255 255
                 // Как только произошел ответ на вызов, отметим вызов на приложение как завершенный.
256 256
                 $filter = [
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
                     $row->writeAttribute('endtime', $data['answer']);
268 268
                     $row->writeAttribute('is_app', 1);
269 269
                     $res = $row->save();
270
-                    if ( ! $res) {
270
+                    if (!$res) {
271 271
                         Util::sysLogMsg('ENDCALLONANSWER', implode(' ', $row->getMessages()));
272 272
                     }
273 273
                 }
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
                     '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
290 290
                     'bind' => [
291 291
                         'UNIQUEID'      => $data['id'],
292
-                        'UNIQUEID_CHAN' => $data['id'] . '_' . $data['agi_channel'],
292
+                        'UNIQUEID_CHAN' => $data['id'].'_'.$data['agi_channel'],
293 293
                     ],
294 294
                 ];
295 295
             }
@@ -302,7 +302,7 @@  discard block
 block discarded – undo
302 302
                         continue;
303 303
                     }
304 304
                     // Найдем все прочие CDR по данному originate и отметим как завершенные.
305
-                    $filter      = [
305
+                    $filter = [
306 306
                         'linkedid=:linkedid: AND endtime <> "" AND src_chan <> :src_chan:',
307 307
                         'bind' => [
308 308
                             'linkedid' => $row->linkedid,
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
                             $orgn_row->writeAttribute('endtime', $data['answer']);
317 317
                         }
318 318
                         $orgn_row->writeAttribute('dst_chan', '');
319
-                        $orgn_row->writeAttribute('UNIQUEID', $data['id'] . '_' . $orgn_row->src_chan);
319
+                        $orgn_row->writeAttribute('UNIQUEID', $data['id'].'_'.$orgn_row->src_chan);
320 320
                         $orgn_row->update();
321 321
                     }
322 322
 
@@ -328,13 +328,13 @@  discard block
 block discarded – undo
328 328
                 }
329 329
 
330 330
                 $row->writeAttribute('answer', $data['answer']);
331
-                $recFile = $data['recordingfile']??'';
332
-                if(!empty($recFile)){
331
+                $recFile = $data['recordingfile'] ?? '';
332
+                if (!empty($recFile)) {
333 333
                     $this->mixMonitorChannels[$data['agi_channel']] = $recFile;
334 334
                     $row->writeAttribute('recordingfile', $recFile);
335 335
                 }
336 336
                 $res = $row->save();
337
-                if ( !$res) {
337
+                if (!$res) {
338 338
                     Util::sysLogMsg('Action_dial_answer', implode(' ', $row->getMessages()));
339 339
                 }
340 340
             }
@@ -360,10 +360,10 @@  discard block
 block discarded – undo
360 360
         $this->hangupChanCheckSipTrtansfer($data, $channels);
361 361
 
362 362
         // Очистим память.
363
-        if(isset($this->checkChanHangupTransfer[$data['agi_channel']])){
363
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
364 364
             unset($this->checkChanHangupTransfer[$data['agi_channel']]);
365 365
         }
366
-        if(isset($this->mixMonitorChannels[$data['agi_channel']])){
366
+        if (isset($this->mixMonitorChannels[$data['agi_channel']])) {
367 367
             unset($this->mixMonitorChannels[$data['agi_channel']]);
368 368
         }
369 369
     }
@@ -375,24 +375,24 @@  discard block
 block discarded – undo
375 375
      */
376 376
     private function hangupChanCheckSipTrtansfer($data, $channels):void{
377 377
         $not_local = (stripos($data['agi_channel'], 'local/') === false);
378
-        if($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
378
+        if ($not_local === false || $data['OLD_LINKEDID'] !== $data['linkedid']) {
379 379
             return;
380 380
         }
381 381
         $active_chans = $this->am->GetChannels(false);
382 382
         // Намек на SIP трансфер.
383 383
         foreach ($channels as $data_chan) {
384
-            if ( ! in_array($data_chan['chan'], $active_chans, true)) {
384
+            if (!in_array($data_chan['chan'], $active_chans, true)) {
385 385
                 // Вызов уже завершен. Не интересно.
386 386
                 continue;
387 387
             }
388 388
             $BRIDGEPEER = $this->am->GetVar($data_chan['chan'], 'BRIDGEPEER', null, false);
389
-            if ( ! in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
389
+            if (!in_array($BRIDGEPEER, $active_chans, true) || !is_string($BRIDGEPEER)) {
390 390
                 // Вызов уже завершен. Не интересно.
391 391
                 continue;
392 392
             }
393 393
 
394 394
             $linkedid = $this->am->GetVar($data_chan['chan'], 'CHANNEL(linkedid)', null, false);
395
-            if ( empty($linkedid) || $linkedid === $data['linkedid']) {
395
+            if (empty($linkedid) || $linkedid === $data['linkedid']) {
396 396
                 continue;
397 397
             }
398 398
 
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
             $n_data['start']         = date('Y-m-d H:i:s');
406 406
             $n_data['answer']        = date('Y-m-d H:i:s');
407 407
             $n_data['linkedid']      = $linkedid;
408
-            $n_data['UNIQUEID']      = $data['linkedid'] . Util::generateRandomString();
408
+            $n_data['UNIQUEID']      = $data['linkedid'].Util::generateRandomString();
409 409
             $n_data['transfer']      = '0';
410 410
             $n_data['recordingfile'] = $this->MixMonitor($n_data['dst_chan'], $n_data['UNIQUEID']);
411 411
             $n_data['did']           = $data_chan['did'];
@@ -437,7 +437,7 @@  discard block
 block discarded – undo
437 437
      * @param array $channels
438 438
      */
439 439
     private function hangupChanEndCalls(array $data, array &$transfer_calls, array &$channels):void{
440
-        $filter         = [
440
+        $filter = [
441 441
             'linkedid=:linkedid: AND endtime = "" AND (src_chan=:src_chan: OR dst_chan=:dst_chan:)',
442 442
             'bind' => [
443 443
                 'linkedid' => $data['linkedid'],
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
             }
455 455
             if ($row->dialstatus === 'ORIGINATE') {
456 456
                 $row->writeAttribute('dialstatus', '');
457
-                if($row->answer === ''){
458
-                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan,'-') +1);
457
+                if ($row->answer === '') {
458
+                    $newId = $row->linkedid.'_'.$row->src_num.'_'.substr($row->src_chan, strpos($row->src_chan, '-') + 1);
459 459
                     $row->writeAttribute('UNIQUEID', $newId);
460 460
                 }
461 461
             }
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
469 469
             }
470 470
             $res = $row->update();
471
-            if ( ! $res) {
471
+            if (!$res) {
472 472
                 Util::sysLogMsg('Action_hangup_chan', implode(' ', $row->getMessages()));
473 473
             }
474 474
 
@@ -500,14 +500,14 @@  discard block
 block discarded – undo
500 500
      */
501 501
     public function Action_CreateRowTransfer($action, $data, $calls_data = null): void
502 502
     {
503
-        if( isset($this->checkChanHangupTransfer[$data['agi_channel']]) ) {
503
+        if (isset($this->checkChanHangupTransfer[$data['agi_channel']])) {
504 504
             return;
505 505
         }
506 506
 
507 507
         $this->checkChanHangupTransfer[$data['agi_channel']] = $action;
508 508
 
509 509
         if (null === $calls_data) {
510
-            $filter     = [
510
+            $filter = [
511 511
                 'linkedid=:linkedid: AND endtime = "" AND transfer=1 AND (src_chan=:chan: OR dst_chan=:chan:)',
512 512
                 'bind'  => [
513 513
                     'linkedid' => $data['linkedid'],
@@ -529,8 +529,8 @@  discard block
 block discarded – undo
529 529
                     $insert_data[$fname_chan] = $row_data['dst_chan'];
530 530
                     $insert_data[$fname_num]  = $row_data['dst_num'];
531 531
                 } else {
532
-                    $fname_chan = ! isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
533
-                    $fname_num  = ! isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
532
+                    $fname_chan = !isset($insert_data['src_chan']) ? 'src_chan' : 'dst_chan';
533
+                    $fname_num  = !isset($insert_data['src_num']) ? 'src_num' : 'dst_num';
534 534
 
535 535
                     $insert_data[$fname_chan] = $row_data['src_chan'];
536 536
                     $insert_data[$fname_num]  = $row_data['src_num'];
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             $this->StopMixMonitor($insert_data['dst_chan']);
542 542
             $recordingfile = $this->MixMonitor(
543 543
                 $insert_data['dst_chan'],
544
-                'transfer_' . $insert_data['src_num'] . '_' . $insert_data['dst_num'] . '_' . $data['linkedid']
544
+                'transfer_'.$insert_data['src_num'].'_'.$insert_data['dst_num'].'_'.$data['linkedid']
545 545
             );
546 546
             //
547 547
             $insert_data['action']        = "{$action}_end_trasfer";
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
             $this->am->UserEvent('CdrConnector', ['AgiData' => $AgiData]);
563 563
 
564 564
             self::insertDataToDbM($insert_data);
565
-        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && ! empty($calls_data[0]['recordingfile'])) {
565
+        } elseif (empty($calls_data[0]['answer']) && count($calls_data) === 1 && !empty($calls_data[0]['recordingfile'])) {
566 566
             // Возобновление записи разговора при срыве переадресации.
567 567
             $row_data = $calls_data[0];
568 568
             $chan     = ($data['agi_channel'] === $row_data['src_chan']) ? $row_data['dst_chan'] : $row_data['src_chan'];
@@ -578,12 +578,12 @@  discard block
 block discarded – undo
578 578
             /** @var CallDetailRecordsTmp $row */
579 579
             $not_ended_cdr = null;
580 580
             $transferNotComplete = false;
581
-            foreach ($cdr as $row){
582
-                if($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
581
+            foreach ($cdr as $row) {
582
+                if ($row->transfer === '1' && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
583 583
                     $not_ended_cdr = $row;
584 584
                 }
585
-                if($row->answer === '' && $row->endtime === ''
586
-                    && ($row->src_chan === $chan || $row->dst_chan === $chan) ){
585
+                if ($row->answer === '' && $row->endtime === ''
586
+                    && ($row->src_chan === $chan || $row->dst_chan === $chan)) {
587 587
                     $transferNotComplete = true;
588 588
                 }
589 589
             }
@@ -661,7 +661,7 @@  discard block
 block discarded – undo
661 661
      */
662 662
     public function Action_transfer_dial_create_chan($data): void
663 663
     {
664
-        $filter     = [
664
+        $filter = [
665 665
             'UNIQUEID=:UNIQUEID: AND endtime = "" AND answer = ""',
666 666
             'bind' => [
667 667
                 'UNIQUEID' => $data['transfer_UNIQUEID'],
@@ -674,7 +674,7 @@  discard block
 block discarded – undo
674 674
         foreach ($m_data as $row) {
675 675
             ///
676 676
             // Проверим, если более одного канала SIP/256 при входящем.
677
-            if ( ! empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
677
+            if (!empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) {
678 678
                 if ($row_create) {
679 679
                     continue;
680 680
                 }
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
                     $new_row->writeAttribute($attribute, $value);
689 689
                 }
690 690
                 $new_row->writeAttribute('dst_chan', $data['dst_chan']);
691
-                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'] . '_' . $data['dst_chan']);
691
+                $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'].'_'.$data['dst_chan']);
692 692
                 // $new_row->save();
693 693
                 // Подмена $row;
694 694
                 $row        = $new_row;
@@ -700,11 +700,11 @@  discard block
 block discarded – undo
700 700
 
701 701
             $row->writeAttribute('dst_chan', $data['dst_chan']);
702 702
             $row->writeAttribute('recordingfile', $data['recordingfile']);
703
-            if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) {
703
+            if (isset($data['dst_call_id']) && !empty($data['dst_call_id'])) {
704 704
                 $row->writeAttribute('dst_call_id', $data['dst_call_id']);
705 705
             }
706 706
             $res = $row->save();
707
-            if ( ! $res) {
707
+            if (!$res) {
708 708
                 Util::sysLogMsg('Action_transfer_dial_create_chan', implode(' ', $row->getMessages()));
709 709
             }
710 710
         }
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
             '(UNIQUEID=:UNIQUEID: OR UNIQUEID=:UNIQUEID_CHAN:) AND answer = "" AND endtime = ""',
722 722
             'bind' => [
723 723
                 'UNIQUEID'      => $data['transfer_UNIQUEID'],
724
-                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'] . '_' . $data['agi_channel'],
724
+                'UNIQUEID_CHAN' => $data['transfer_UNIQUEID'].'_'.$data['agi_channel'],
725 725
             ],
726 726
         ];
727 727
 
@@ -730,13 +730,13 @@  discard block
 block discarded – undo
730 730
         $m_data = CallDetailRecordsTmp::find($filter);
731 731
         foreach ($m_data as $row) {
732 732
             $row->writeAttribute('answer', $data['answer']);
733
-            $recFile = $data['recordingfile']??'';
734
-            if(!empty($recFile)){
733
+            $recFile = $data['recordingfile'] ?? '';
734
+            if (!empty($recFile)) {
735 735
                 $this->mixMonitorChannels[$data['agi_channel']] = $recFile;
736 736
                 $row->writeAttribute('recordingfile', $recFile);
737 737
             }
738 738
             $res = $row->save();
739
-            if ( !$res) {
739
+            if (!$res) {
740 740
                 Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
741 741
             }
742 742
         }
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
                 // Завершим вызов в CDR.
771 771
                 $row->writeAttribute('endtime', $data['end']);
772 772
                 $row->writeAttribute('transfer', 0);
773
-                if ( ! $row->save()) {
773
+                if (!$row->save()) {
774 774
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
775 775
                 }
776 776
             }
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
                 // Ответа не было. Переадресация отменена.
806 806
                 $row->writeAttribute('endtime', $data['end']);
807 807
                 $row->writeAttribute('transfer', 0);
808
-                if ( ! $row->save()) {
808
+                if (!$row->save()) {
809 809
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
810 810
                 }
811 811
             }
@@ -825,7 +825,7 @@  discard block
 block discarded – undo
825 825
                 $this->MixMonitor($row->dst_chan, $info['filename'], $subdir);
826 826
                 // Снимем со строк признак переадресации.
827 827
                 $row->writeAttribute('transfer', 0);
828
-                if ( ! $row->save()) {
828
+                if (!$row->save()) {
829 829
                     Util::sysLogMsg('Action_transfer_dial_answer', implode(' ', $row->getMessages()));
830 830
                 }
831 831
             }
@@ -901,7 +901,7 @@  discard block
 block discarded – undo
901 901
 
902 902
                 $f_list = $m_data->toArray();
903 903
                 foreach ($data as $attribute => $value) {
904
-                    if ( ! array_key_exists($attribute, $f_list)) {
904
+                    if (!array_key_exists($attribute, $f_list)) {
905 905
                         continue;
906 906
                     }
907 907
                     $m_data->writeAttribute($attribute, $value);
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
             $row->writeAttribute('answer', $data['answer']);
973 973
             $row->writeAttribute('endtime', $data['answer']);
974 974
             $res = $row->save();
975
-            if ( ! $res) {
975
+            if (!$res) {
976 976
                 Util::sysLogMsg('Action_queue_answer', implode(' ', $row->getMessages()));
977 977
             }
978 978
         }
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
                 $row->writeAttribute('dialstatus', $data['dialstatus']);
1002 1002
             }
1003 1003
             $res = $row->save();
1004
-            if ( ! $res) {
1004
+            if (!$res) {
1005 1005
                 Util::sysLogMsg('Action_queue_end', implode(' ', $row->getMessages()));
1006 1006
             }
1007 1007
         }
@@ -1031,11 +1031,11 @@  discard block
 block discarded – undo
1031 1031
             if ($dest_chan === $row->dst_chan) {
1032 1032
                 $is_local        = (stripos($data['src_chan'], 'local/') !== false);
1033 1033
                 $is_stored_local = (stripos($row->src_chan, 'local/') !== false);
1034
-                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && ! $is_stored_local) {
1034
+                if ($row->UNIQUEID === $data['UNIQUEID'] && $is_local && !$is_stored_local) {
1035 1035
                     $data['src_chan'] = $row->src_chan;
1036 1036
                 }
1037 1037
                 if (file_exists($row->recordingfile) || file_exists(
1038
-                        Util::trimExtensionForFile($row->recordingfile) . '.wav'
1038
+                        Util::trimExtensionForFile($row->recordingfile).'.wav'
1039 1039
                     )) {
1040 1040
                     // Переопределим путь к файлу записи разговора. Для конферецнии файл один.
1041 1041
                     $recordingfile = $row->recordingfile;
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
             // Подменим ID на идентификатор конференции.
1048 1048
             $row->writeAttribute('linkedid', $data['meetme_id']);
1049 1049
             $res = $row->save();
1050
-            if ( ! $res) {
1050
+            if (!$res) {
1051 1051
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1052 1052
             }
1053 1053
         }
@@ -1064,11 +1064,11 @@  discard block
 block discarded – undo
1064 1064
             $row->writeAttribute('transfer', 0);
1065 1065
             $row->writeAttribute('linkedid', $data['meetme_id']);
1066 1066
 
1067
-            if ( ! empty($recordingfile)) {
1067
+            if (!empty($recordingfile)) {
1068 1068
                 $row->writeAttribute('recordingfile', $recordingfile);
1069 1069
             }
1070 1070
             $res = $row->save();
1071
-            if ( ! $res) {
1071
+            if (!$res) {
1072 1072
                 Util::sysLogMsg('Action_hangup_chan_meetme', implode(' ', $row->getMessages()));
1073 1073
             }
1074 1074
         }
@@ -1107,9 +1107,9 @@  discard block
 block discarded – undo
1107 1107
      */
1108 1108
     public function callEventsWorker($tube): void
1109 1109
     {
1110
-        $data      = json_decode($tube->getBody(), true);
1111
-        $funcName = "Action_".$data['action']??'';
1112
-        if ( method_exists($this, $funcName) ) {
1110
+        $data = json_decode($tube->getBody(), true);
1111
+        $funcName = "Action_".$data['action'] ?? '';
1112
+        if (method_exists($this, $funcName)) {
1113 1113
             $this->$funcName($data);
1114 1114
         }
1115 1115
         $tube->reply(json_encode(true));
@@ -1139,14 +1139,14 @@  discard block
 block discarded – undo
1139 1139
     public function updateDataInDbM($data): bool
1140 1140
     {
1141 1141
         if (empty($data['UNIQUEID'])) {
1142
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1142
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1143 1143
 
1144 1144
             return false;
1145 1145
         }
1146 1146
 
1147 1147
         $filter = [
1148 1148
             "UNIQUEID=:id:",
1149
-            'bind' => ['id' => $data['UNIQUEID'],],
1149
+            'bind' => ['id' => $data['UNIQUEID'], ],
1150 1150
         ];
1151 1151
         /** @var CallDetailRecordsTmp $m_data */
1152 1152
         $m_data = CallDetailRecordsTmp::findFirst($filter);
@@ -1155,7 +1155,7 @@  discard block
 block discarded – undo
1155 1155
         }
1156 1156
         $f_list = $m_data->toArray();
1157 1157
         foreach ($data as $attribute => $value) {
1158
-            if ( ! array_key_exists($attribute, $f_list)) {
1158
+            if (!array_key_exists($attribute, $f_list)) {
1159 1159
                 continue;
1160 1160
             }
1161 1161
             if ('UNIQUEID' === $attribute) {
@@ -1164,7 +1164,7 @@  discard block
 block discarded – undo
1164 1164
             $m_data->writeAttribute($attribute, $value);
1165 1165
         }
1166 1166
         $res = $m_data->save();
1167
-        if ( ! $res) {
1167
+        if (!$res) {
1168 1168
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1169 1169
         }
1170 1170
 
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
     public static function insertDataToDbM($data): bool
1204 1204
     {
1205 1205
         if (empty($data['UNIQUEID'])) {
1206
-            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty ' . json_encode($data));
1206
+            Util::sysLogMsg(__FUNCTION__, 'UNIQUEID is empty '.json_encode($data));
1207 1207
 
1208 1208
             return false;
1209 1209
         }
@@ -1225,7 +1225,7 @@  discard block
 block discarded – undo
1225 1225
         } elseif (isset($data['IS_ORGNT']) && $data['IS_ORGNT'] !== false && $data['action'] === 'dial') {
1226 1226
             if (empty($m_data->endtime)) {
1227 1227
                 // Если это оригинация dial может прийти дважды.
1228
-                if(!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']){
1228
+                if (!empty($m_data->src_num) && $m_data->src_num === $data['dst_num']) {
1229 1229
                     $m_data->dst_num = $data['src_num'];
1230 1230
                     $m_data->save();
1231 1231
                 }
@@ -1250,7 +1250,7 @@  discard block
 block discarded – undo
1250 1250
             $new_m_data->transfer     = $data['transfer'];
1251 1251
 
1252 1252
             $res = $new_m_data->save();
1253
-            if ( ! $res) {
1253
+            if (!$res) {
1254 1254
                 Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1255 1255
             }
1256 1256
 
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
 
1260 1260
         $f_list = $m_data->toArray();
1261 1261
         foreach ($data as $attribute => $value) {
1262
-            if ( ! array_key_exists($attribute, $f_list)) {
1262
+            if (!array_key_exists($attribute, $f_list)) {
1263 1263
                 continue;
1264 1264
             }
1265 1265
             if ($is_new === false && 'UNIQUEID' === $attribute) {
@@ -1268,7 +1268,7 @@  discard block
 block discarded – undo
1268 1268
             $m_data->writeAttribute($attribute, $value);
1269 1269
         }
1270 1270
         $res = $m_data->save();
1271
-        if ( ! $res) {
1271
+        if (!$res) {
1272 1272
             Util::sysLogMsg(__FUNCTION__, implode(' ', $m_data->getMessages()));
1273 1273
         }
1274 1274
 
@@ -1283,12 +1283,12 @@  discard block
 block discarded – undo
1283 1283
         $q      = $tube->getBody();
1284 1284
         $filter = json_decode($q, true);
1285 1285
 
1286
-        if($this->filterNotValid($filter)){
1286
+        if ($this->filterNotValid($filter)) {
1287 1287
             $tube->reply('[]');
1288 1288
             return;
1289 1289
         }
1290 1290
 
1291
-        $res    = null;
1291
+        $res = null;
1292 1292
         try {
1293 1293
             if (isset($filter['miko_tmp_db'])) {
1294 1294
                 $res = CallDetailRecordsTmp::find($filter);
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
             }
1308 1308
             $filter['add_pack_query']['bind'][$filter['columns']] = $arr;
1309 1309
 
1310
-            if($this->filterNotValid($filter['add_pack_query'])){
1310
+            if ($this->filterNotValid($filter['add_pack_query'])) {
1311 1311
                 $tube->reply('[]');
1312 1312
                 return;
1313 1313
             }
@@ -1323,7 +1323,7 @@  discard block
 block discarded – undo
1323 1323
         if (isset($filter['miko_result_in_file'])) {
1324 1324
             $di         = Di::getDefault();
1325 1325
             $dirsConfig = $di->getShared('config');
1326
-            $filename   = $dirsConfig->path('core.tempDir') . '/' . md5(microtime(true));
1326
+            $filename   = $dirsConfig->path('core.tempDir').'/'.md5(microtime(true));
1327 1327
             file_put_contents($filename, $res_data);
1328 1328
             Util::addRegularWWWRights($filename);
1329 1329
             $res_data = json_encode($filename);
@@ -1339,16 +1339,16 @@  discard block
 block discarded – undo
1339 1339
      *
1340 1340
      * @return bool
1341 1341
      */
1342
-    private function filterNotValid($filter){
1342
+    private function filterNotValid($filter) {
1343 1343
         $haveErrors = false;
1344
-        if(isset($filter['bind'])){
1345
-            if(is_array($filter)){
1344
+        if (isset($filter['bind'])) {
1345
+            if (is_array($filter)) {
1346 1346
                 foreach ($filter['bind'] as $bindValue) {
1347
-                    if(empty($bindValue)){
1347
+                    if (empty($bindValue)) {
1348 1348
                         $haveErrors = true;
1349 1349
                     }
1350 1350
                 }
1351
-            }else{
1351
+            } else {
1352 1352
                 $haveErrors = true;
1353 1353
             }
1354 1354
         }
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
 
1358 1358
     public function errorHandler($m): void
1359 1359
     {
1360
-        Util::sysLogMsg(self::class . '_ERROR', $m);
1360
+        Util::sysLogMsg(self::class.'_ERROR', $m);
1361 1361
     }
1362 1362
 }
1363 1363
 
Please login to merge, or discard this patch.