Application::__construct()   A
last analyzed

Complexity

Conditions 6
Paths 4

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 6
eloc 8
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 10
rs 9.2222
1
<?php
2
/**
3
 * This file is part of order_management
4
 * User: Sinan TURGUT <[email protected]>
5
 * Date: 24.06.2019
6
 * php version 7.2
7
 *
8
 * @category Assessment
9
 * @package  OrderManagement
10
 * @author   Sinan TURGUT <[email protected]>
11
 * @license  See LICENSE file
12
 * @link     https://dev.sinanturgut.com.tr
13
 */
14
15
namespace OrderManagement;
16
17
use OrderManagement\Http\Controller\DefaultController;
18
use OrderManagement\Http\Controller\OrderController;
19
use OrderManagement\Worker\OrderQueue\OrderQueueController;
20
use Dotenv\Dotenv;
0 ignored issues
show
Bug introduced by
The type Dotenv\Dotenv 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...
21
22
/**
23
 * Class Application
24
 * @package OrderManagement
25
 */
26
class Application
27
{
28
    /**
29
     * Application constructor.
30
     */
31
    public function __construct()
32
    {
33
        defined('DS') ?: define('DS', DIRECTORY_SEPARATOR);
34
        defined('ENVROOT') ?: define('ENVROOT', dirname(__DIR__) . DS);
35
        if (file_exists(ENVROOT . '.env')) {
36
            $dotenv = new Dotenv(ENVROOT);
37
            try {
38
                $dotenv->load();
39
            } catch (InvalidFileException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
Bug introduced by
The type OrderManagement\InvalidFileException 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...
40
            } catch (InvalidPathException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
Bug introduced by
The type OrderManagement\InvalidPathException 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...
41
            }
42
        }
43
44
    }
45
46
    /**
47
     * @throws \ErrorException
48
     */
49
    public function run()
50
    {
51
        if ($_SERVER['REQUEST_URI'] == '/order/create') {
52
            (new OrderController())->create();
53
54
            return;
55
        }
56
57
        if (isset($GLOBALS['argv'])
58
            && in_array('--queue', $GLOBALS['argv'])
59
        ) {
60
            (new OrderQueueController())->work();
61
        }
62
63
        (new DefaultController())->index();
64
    }
65
}
66