AppsController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 63
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 3 1
A getById() 0 12 1
A onConstruct() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Api\Controllers;
6
7
use Canvas\Models\Apps;
8
use Phalcon\Http\Response;
0 ignored issues
show
Bug introduced by
The type Phalcon\Http\Response was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Class LanguagesController.
12
 *
13
 * @package Canvas\Api\Controllers
14
 *
15
 */
16
class AppsController extends BaseController
17
{
18
    /*
19
     * fields we accept to create
20
     *
21
     * @var array
22
     */
23
    protected $createFields = [];
24
25
    /*
26
     * fields we accept to create
27
     *
28
     * @var array
29
     */
30
    protected $updateFields = [];
31
32
    /**
33
     * set objects.
34
     *
35
     * @return void
36
     */
37
    public function onConstruct()
38
    {
39
        $this->model = new Apps();
0 ignored issues
show
Bug Best Practice introduced by
The property model does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
40
        $this->additionalSearchFields = [
0 ignored issues
show
Bug Best Practice introduced by
The property additionalSearchFields does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
41
            ['is_deleted', ':', '0'],
42
            ['id', ':', implode('|', $this->userData->getAssociatedApps())],
43
        ];
44
    }
45
46
    /**
47
     * get item.
48
     *
49
     * @param mixed $id
50
     *
51
     * @method GET
52
     * @url /v1/data/{id}
53
     *
54
     * @return \Phalcon\Http\Response
55
     */
56
    public function getById($id = null): Response
57
    {
58
        //find the info
59
        $record = $this->model->findFirstOrFail([
60
            'id = ?0 AND is_deleted = 0 AND id in (' . implode(',', $this->userData->getAssociatedApps()) . ')',
61
            'bind' => [$id],
62
        ]);
63
64
        //get the results and append its relationships
65
        $result = $this->appendRelationshipsToResult($this->request, $record);
66
67
        return $this->response($this->processOutput($result));
68
    }
69
70
    /**
71
     * Delete a Record.
72
     *
73
     * @throws Exception
74
     * @return Response
75
     */
76
    public function delete($id): Response
77
    {
78
        return $this->response('Cant delete app at the moment');
79
    }
80
}
81