Conditions | 17 |
Paths | 12289 |
Total Lines | 64 |
Code Lines | 44 |
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 |
||
27 | protected function generateConfigProtected() :void |
||
28 | { |
||
29 | $this->extensionGenInternal(); |
||
30 | // Генерация конфигурационных файлов. |
||
31 | $q_conf = ''; |
||
32 | $db_data = $this->getQueueData(); |
||
33 | foreach ($db_data as $queue_data) { |
||
34 | $joinempty = (isset($queue_data['joinempty']) && $queue_data['joinempty'] == 1) ? 'yes' : 'no'; |
||
35 | $leavewhenempty = (isset($queue_data['leavewhenempty']) && $queue_data['leavewhenempty'] == 1) ? 'yes' : 'no'; |
||
36 | $ringinuse = ($queue_data['recive_calls_while_on_a_call'] == 1) ? 'yes' : 'no'; |
||
37 | $announceposition = ($queue_data['announce_position'] == 1) ? 'yes' : 'no'; |
||
38 | $announceholdtime = ($queue_data['announce_hold_time'] == 1) ? 'yes' : 'no'; |
||
39 | |||
40 | $timeout = ($queue_data['seconds_to_ring_each_member'] == '') ? '60' : $queue_data['seconds_to_ring_each_member']; |
||
41 | $wrapuptime = ($queue_data['seconds_for_wrapup'] == '') ? '3' : $queue_data['seconds_for_wrapup']; |
||
42 | $periodic_announce = ''; |
||
43 | if (trim($queue_data['periodic_announce']) != '') { |
||
44 | $announce_file = Util::trimExtensionForFile($queue_data['periodic_announce']); |
||
45 | $periodic_announce = "periodic-announce={$announce_file} \n"; |
||
46 | } |
||
47 | $periodic_announce_frequency = ''; |
||
48 | if (trim($queue_data['periodic_announce_frequency']) != '') { |
||
49 | $periodic_announce_frequency = "periodic-announce-frequency={$queue_data['periodic_announce_frequency']} \n"; |
||
50 | } |
||
51 | $announce_frequency = ''; |
||
52 | if ($announceposition !== 'no' || $announceholdtime !== 'no') { |
||
53 | $announce_frequency .= "announce-frequency=30 \n"; |
||
54 | } |
||
55 | |||
56 | // liner - под этой стратегией понимаем последовательный вызов агентов очереди. |
||
57 | // Каждый новый звонок должен инициировать последовательный вызов начиная с первого агента. |
||
58 | // $strategy = ('linear' === $queue_data['strategy']) ? 'ringall' : $queue_data['strategy']; |
||
59 | $strategy = $queue_data['strategy']; |
||
60 | |||
61 | $q_conf .= "[{$queue_data['uniqid']}]; {$queue_data['name']}\n"; |
||
62 | $q_conf .= "musicclass=default \n"; |
||
63 | $q_conf .= "strategy={$strategy} \n"; |
||
64 | $q_conf .= "timeout={$timeout} \n"; |
||
65 | $q_conf .= "retry=1 \n"; |
||
66 | $q_conf .= "wrapuptime={$wrapuptime} \n"; |
||
67 | $q_conf .= "ringinuse={$ringinuse} \n"; |
||
68 | $q_conf .= "$periodic_announce"; |
||
69 | $q_conf .= "$periodic_announce_frequency"; |
||
70 | $q_conf .= "joinempty={$joinempty} \n"; |
||
71 | $q_conf .= "leavewhenempty={$leavewhenempty} \n"; |
||
72 | $q_conf .= "announce-position={$announceposition} \n"; |
||
73 | $q_conf .= "announce-holdtime={$announceholdtime} \n"; |
||
74 | $q_conf .= "$announce_frequency"; |
||
75 | |||
76 | $penalty = 0; |
||
77 | foreach ($queue_data['agents'] as $agent) { |
||
78 | // if ('linear' === $queue_data['strategy']) { |
||
79 | // $penalty++; |
||
80 | // } |
||
81 | $hint = ''; |
||
82 | if ($agent['isExternal'] != true) { |
||
83 | $hint = ",hint:{$agent['agent']}@internal-hints"; |
||
84 | } |
||
85 | $q_conf .= "member => Local/{$agent['agent']}@internal/n,{$penalty},\"{$agent['agent']}\"{$hint} \n"; |
||
86 | } |
||
87 | $q_conf .= "\n"; |
||
88 | } |
||
89 | |||
90 | Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/queues.conf', $q_conf); |
||
91 | |||
242 | } |