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

IAXStackProcessor::getRegistry()   B

Complexity

Conditions 11
Paths 45

Size

Total Lines 64
Code Lines 41

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 41
c 1
b 0
f 0
dl 0
loc 64
rs 7.3166
cc 11
nc 45
nop 0

How to fix   Long Method    Complexity   

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-2023 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\PBXCoreREST\Lib;
21
22
use MikoPBX\PBXCoreREST\Lib\Iax\GetRegistryAction;
23
use Phalcon\Di\Injectable;
24
25
/**
26
 * Class IAXStackProcessor
27
 *
28
 * @package MikoPBX\PBXCoreREST\Lib
29
 *
30
 */
31
class IAXStackProcessor extends Injectable
32
{
33
    /**
34
     * Process the IAX callback request.
35
     *
36
     * @param array $request The request data.
37
     * @return PBXApiResult An object containing the result of the API call.
38
     */
39
    public static function callBack(array $request): PBXApiResult
40
    {
41
        $res = new PBXApiResult();
42
        $res->processor = __METHOD__;
43
        $action = $request['action'];
44
        switch ($action) {
45
            case 'getRegistry':
46
                $res = GetRegistryAction::main();
47
                break;
48
            default:
49
                $res->messages['error'][] = "Unknown action - $action in ".__CLASS__;
50
                break;
51
        }
52
53
        $res->function = $action;
54
55
        return $res;
56
    }
57
}