Passed
Push — develop ( 4e1ac1...67fb71 )
by Портнов
04:46 queued 13s
created

HepConf   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 10
c 1
b 0
f 0
dl 0
loc 18
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generateConfigProtected() 0 8 1
A reload() 0 4 1
1
<?php
2
/*
3
 * MikoPBX - free phone system for small business
4
 * Copyright (C) 2017-2020 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\Asterisk\Configs;
21
22
23
use MikoPBX\Core\System\Processes;
24
use MikoPBX\Core\System\Util;
25
26
class HepConf extends CoreConfigClass
27
{
28
    protected string $description = 'cdr.conf';
29
30
    protected function generateConfigProtected(): void
31
    {
32
        $conf = "[general]\n" .
33
            "enabled=yes\n" .
34
            "capture_address = 172.16.156.197:9060\n" .
35
            ";capture_password = foo\n" .
36
            "capture_id = 1234 \n";
37
        Util::fileWriteContent($this->config->path('asterisk.astetcdir') . '/hep.conf', $conf);
38
    }
39
40
    public static function reload()
41
    {
42
        $asteriskPath = Util::which('asterisk');
43
        Processes::mwExec("{$asteriskPath} -rx 'module reload res_hep.so'", $out);
44
    }
45
}