Passed
Push — master ( bf2aee...a6dc35 )
by Thierry
02:22
created

AppTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 41
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBootstrap() 0 3 1
A registerApp() 0 13 1
A getApp() 0 3 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Di\Traits;
4
5
use Jaxon\Jaxon;
6
use Jaxon\App\App;
7
use Jaxon\App\Bootstrap;
8
use Jaxon\Config\ConfigManager;
9
use Jaxon\Plugin\Manager\PluginManager;
10
use Jaxon\Request\Handler\RequestHandler;
11
use Jaxon\Response\ResponseManager;
12
use Jaxon\Utils\Config\ConfigReader;
0 ignored issues
show
Bug introduced by
The type Jaxon\Utils\Config\ConfigReader 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...
13
use Jaxon\Utils\Translation\Translator;
14
15
trait AppTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait AppTrait
Loading history...
16
{
17
    /**
18
     * Register the values into the container
19
     *
20
     * @return void
21
     */
22
    private function registerApp()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
23
    {
24
        $this->set(ConfigManager::class, function($c) {
0 ignored issues
show
Bug introduced by
It seems like set() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

24
        $this->/** @scrutinizer ignore-call */ 
25
               set(ConfigManager::class, function($c) {
Loading history...
25
            return new ConfigManager($c->g(ConfigReader::class), $c->g(Translator::class));
26
        });
27
        // Jaxon App
28
        $this->set(App::class, function($c) {
29
            return new App($c->g(Jaxon::class), $c->g(ConfigManager::class),
30
                $c->g(ResponseManager::class), $c->g(Translator::class));
31
        });
32
        // Jaxon App bootstrap
33
        $this->set(Bootstrap::class, function($c) {
34
            return new Bootstrap($c->g(ConfigManager::class), $c->g(PluginManager::class), $c->g(RequestHandler::class));
35
        });
36
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
37
38
    /**
39
     * Get the App instance
40
     *
41
     * @return App
42
     */
43
    public function getApp(): App
44
    {
45
        return $this->g(App::class);
0 ignored issues
show
Bug introduced by
It seems like g() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        return $this->/** @scrutinizer ignore-call */ g(App::class);
Loading history...
46
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
47
48
    /**
49
     * Get the App bootstrap
50
     *
51
     * @return Bootstrap
52
     */
53
    public function getBootstrap(): Bootstrap
54
    {
55
        return $this->g(Bootstrap::class);
56
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
57
}
58