Passed
Push — develop ( 368e3d...115c7b )
by Nikolay
12:16
created

ProcessCustomFiles::getDependencyTable()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 119
Code Lines 67

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 67
c 1
b 0
f 0
dl 0
loc 119
rs 8.72
cc 1
nc 1
nop 0

How to fix   Long Method   

Long Method

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:

1
<?php
2
/*
3
 * MikoPBX - free phone system for small business
4
 * Copyright © 2017-2024 Alexey Portnov and Nikolay Beketov
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License along with this program.
17
 * If not, see <https://www.gnu.org/licenses/>.
18
 */
19
20
namespace MikoPBX\Core\Workers\Libs\WorkerModelsEvents;
21
22
use MikoPBX\Core\Workers\WorkerModelsEvents;
23
use Phalcon\Di\Injectable;
24
25
class ProcessCustomFiles extends Injectable
26
{
27
    /**
28
     * Initializes the Custom files dependency table.
29
     */
30
    public static function getDependencyTable(): array
31
    {
32
        $tables = [];
33
34
        $tables[] = [
35
            'filePath' => '*',
36
            'functions' => [
37
                WorkerModelsEvents::R_PBX_CORE_RELOAD,
38
                WorkerModelsEvents::R_ADVICE,
39
            ],
40
        ];
41
42
        $tables[] = [
43
            'filePath' => '/etc/asterisk/manager.conf',
44
            'functions' => [
45
                WorkerModelsEvents::R_MANAGERS
46
            ],
47
        ];
48
49
        $tables[] = [
50
            'filePath' => '/etc/asterisk/musiconhold.conf',
51
            'functions' => [
52
                WorkerModelsEvents::R_MOH
53
            ],
54
        ];
55
56
        $tables[] = [
57
            'filePath' => '/etc/asterisk/modules.conf',
58
            'functions' => [
59
                WorkerModelsEvents::R_MODULES_CONF
60
            ],
61
        ];
62
63
        $tables[] = [
64
            'filePath' => '/etc/asterisk/hep.conf',
65
            'functions' => [
66
                WorkerModelsEvents::R_HEP
67
            ],
68
        ];
69
70
        $tables[] = [
71
            'filePath' => '/etc/asterisk/http.conf',
72
            'functions' => [
73
                WorkerModelsEvents::R_MANAGERS
74
            ],
75
        ];
76
77
        $tables[] = [
78
            'filePath' => '/var/spool/cron/crontabs/root',
79
            'functions' => [
80
                WorkerModelsEvents::R_CRON
81
            ],
82
        ];
83
84
        $tables[] = [
85
            'filePath' => '/etc/asterisk/queues.conf',
86
            'functions' => [
87
                WorkerModelsEvents::R_QUEUES
88
            ],
89
        ];
90
91
        $tables[] = [
92
            'filePath' => '/etc/asterisk/features.conf',
93
            'functions' => [
94
                WorkerModelsEvents::R_FEATURES
95
            ],
96
        ];
97
98
        $tables[] = [
99
            'filePath' => '/etc/ntp.conf',
100
            'functions' => [
101
                WorkerModelsEvents::R_NTP
102
            ],
103
        ];
104
105
        $tables[] = [
106
            'filePath' => '/etc/asterisk/ooh323.conf',
107
            'functions' => [
108
                WorkerModelsEvents::R_H323
109
            ],
110
        ];
111
112
        $tables[] = [
113
            'filePath' => '/etc/asterisk/rtp.conf',
114
            'functions' => [
115
                WorkerModelsEvents::R_RTP
116
            ],
117
        ];
118
119
        // Restart network if the file /etc/static-routes was changed
120
        $tables[] = [
121
            'filePath' => '/etc/static-routes',
122
            'functions' => [
123
                WorkerModelsEvents::R_NETWORK
124
            ],
125
        ];
126
127
        $tables[] = [
128
            'filePath' => '/etc/openvpn.ovpn',
129
            'functions' => [
130
                WorkerModelsEvents::R_NETWORK
131
            ],
132
        ];
133
134
        $tables[] = [
135
            'filePath' => '/etc/firewall_additional',
136
            'functions' => [
137
                WorkerModelsEvents::R_FIREWALL
138
            ],
139
        ];
140
141
        $tables[] = [
142
            'filePath' => '/etc/fail2ban/jail.local',
143
            'functions' => [
144
                WorkerModelsEvents::R_FIREWALL
145
            ],
146
        ];
147
148
        return $tables;
149
    }
150
}