| Conditions | 10 | 
| Paths | 10 | 
| Total Lines | 47 | 
| Code Lines | 27 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 1 | ||
| Bugs | 0 | Features | 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  | 
            ||
| 33 | public static function execute(WorkerCallEvents $worker, $data):void  | 
            ||
| 34 |     { | 
            ||
| 35 | $filter = [  | 
            ||
| 36 | 'UNIQUEID=:UNIQUEID: AND endtime = "" AND answer = ""',  | 
            ||
| 37 | 'bind' => [  | 
            ||
| 38 | 'UNIQUEID' => $data['transfer_UNIQUEID'],  | 
            ||
| 39 | ],  | 
            ||
| 40 | ];  | 
            ||
| 41 | $row_create = false;  | 
            ||
| 42 | /** @var CallDetailRecordsTmp $m_data */  | 
            ||
| 43 | /** @var CallDetailRecordsTmp $row */  | 
            ||
| 44 | $m_data = CallDetailRecordsTmp::find($filter);  | 
            ||
| 45 |         foreach ($m_data as $row) { | 
            ||
| 46 | ///  | 
            ||
| 47 | // Проверим, если более одного канала SIP/256 при входящем.  | 
            ||
| 48 |             if ( ! empty($row->dst_chan) && $data['dst_chan'] !== $row->dst_chan) { | 
            ||
| 49 |                 if ($row_create) { | 
            ||
| 50 | continue;  | 
            ||
| 51 | }  | 
            ||
| 52 | // Необходимо дублировать строку звонка.  | 
            ||
| 53 | $new_row = new CallDetailRecordsTmp();  | 
            ||
| 54 | $f_list = $row->toArray();  | 
            ||
| 55 |                 foreach ($f_list as $attribute => $value) { | 
            ||
| 56 |                     if ($attribute === 'id') { | 
            ||
| 57 | continue;  | 
            ||
| 58 | }  | 
            ||
| 59 | $new_row->writeAttribute($attribute, $value);  | 
            ||
| 60 | }  | 
            ||
| 61 |                 $new_row->writeAttribute('dst_chan', $data['dst_chan']); | 
            ||
| 62 |                 $new_row->writeAttribute('UNIQUEID', $data['transfer_UNIQUEID'] . '_' . $data['dst_chan']); | 
            ||
| 63 | // $new_row->save();  | 
            ||
| 64 | // Подмена $row;  | 
            ||
| 65 | $row = $new_row;  | 
            ||
| 66 | $row_create = true;  | 
            ||
| 67 | }  | 
            ||
| 68 | |||
| 69 | // конец проверки  | 
            ||
| 70 | ///  | 
            ||
| 71 | |||
| 72 |             $row->writeAttribute('dst_chan', $data['dst_chan']); | 
            ||
| 73 |             $row->writeAttribute('recordingfile', $data['recordingfile']); | 
            ||
| 74 |             if (isset($data['dst_call_id']) && ! empty($data['dst_call_id'])) { | 
            ||
| 75 |                 $row->writeAttribute('dst_call_id', $data['dst_call_id']); | 
            ||
| 76 | }  | 
            ||
| 77 | $res = $row->save();  | 
            ||
| 78 |             if ( ! $res) { | 
            ||
| 79 |                 Util::sysLogMsg('Action_transfer_dial_create_chan', implode(' ', $row->getMessages()), LOG_DEBUG); | 
            ||
| 80 | }  | 
            ||
| 83 | }  |