Api::setup()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 13
ccs 0
cts 7
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Canvas\Bootstrap;
6
7
use function Canvas\Core\appPath;
8
use Phalcon\Di\FactoryDefault;
0 ignored issues
show
Bug introduced by
The type Phalcon\Di\FactoryDefault 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
use Phalcon\Mvc\Micro;
0 ignored issues
show
Bug introduced by
The type Phalcon\Mvc\Micro 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...
10
use Canvas\Http\Response;
11
use Throwable;
12
13
/**
14
 * Class Api.
15
 *
16
 * @package Canvas\Bootstrap
17
 *
18
 * @property Micro $application
19
 */
20
class Api extends AbstractBootstrap
21
{
22
    /**
23
     * Run the application.
24
     *
25
     * @return mixed
26
     */
27
    public function run()
28
    {
29
        try {
30
            return $this->application->handle();
31
        } catch (Throwable $e) {
32
            $response = new Response();
33
            $response->handleException($e)->send();
34
        }
35
    }
36
37
    /**
38
     * @return mixed
39
     */
40
    public function setup()
41
    {
42
        //set the default DI
43
        $this->container = new FactoryDefault();
44
        //set all the services
45
46
        /**
47
        * @todo Find a better way to handle unit test file include
48
        */
49
        $this->providers = require appPath('api/config/providers.php');
50
51
        //run my parents setup
52
        parent::setup();
53
    }
54
}
55