Passed
Push — develop ( 578d35...1edb03 )
by Nikolay
13:40 queued 12s
created

PostController   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A callAction() 0 4 1
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\Controllers\Extensions;
21
22
23
use MikoPBX\PBXCoreREST\Controllers\BaseController;
24
use MikoPBX\PBXCoreREST\Lib\ExtensionsManagementProcessor;
25
26
/**
27
 * Handles the POST requests for extensions data.
28
 *
29
 * @RoutePrefix("/pbxcore/api/extensions")
30
 *
31
 * @examples
32
 *
33
 * Get phones represent
34
 *   curl -X POST -d '{"numbers": [225,224,79265244744,6681423434]}' http://127.0.0.1/pbxcore/api/extensions/getPhonesRepresent;
35
 *
36
 */
37
class PostController extends BaseController
38
{
39
    /**
40
     * Handles the call to different actions based on the action name
41
     *
42
     * @param string $actionName The name of the action
43
     *
44
     * Returns CallerID names for the numbers list.
45
     * @Post("/getPhonesRepresent")
46
     *
47
     * Saves a record with associated entities.
48
     * @Post("/saveRecord")
49
     *
50
     * Deletes the extension record with its dependent tables.
51
     * @Post("/deleteRecord")
52
     *
53
     * @return void
54
     */
55
    public function callAction(string $actionName): void
56
    {
57
        $data = $this->request->getPost();
58
        $this->sendRequestToBackendWorker(ExtensionsManagementProcessor::class, $actionName, $data);
59
    }
60
}