Passed
Push — master ( 5b7bca...888408 )
by Thierry
02:13
created

PluginTrait::getJQueryPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Container\Traits;
4
5
use Jaxon\Jaxon;
6
use Jaxon\Config\ConfigManager;
7
use Jaxon\Container\Container;
8
use Jaxon\Plugin\Code\AssetManager;
9
use Jaxon\Plugin\Code\CodeGenerator;
10
use Jaxon\Plugin\PluginManager;
11
use Jaxon\Request\Handler\UploadHandler;
12
use Jaxon\Request\Upload\UploadManager;
13
use Jaxon\Request\Validator;
14
use Jaxon\Response\Plugin\DataBag\DataBagPlugin;
15
use Jaxon\Response\Plugin\JQuery\JQueryPlugin;
16
use Jaxon\Response\ResponseManager;
17
use Jaxon\Utils\Config\Config;
18
use Jaxon\Utils\File\Minifier;
19
use Jaxon\Utils\Http\UriDetector;
20
use Jaxon\Utils\Template\Engine as TemplateEngine;
21
use Jaxon\Utils\Translation\Translator;
22
23
trait PluginTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait PluginTrait
Loading history...
24
{
25
    /**
26
     * Register the values into the container
27
     *
28
     * @return void
29
     */
30
    private function registerPlugins()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
31
    {
32
        // Plugin manager
33
        $this->set(PluginManager::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

33
        $this->/** @scrutinizer ignore-call */ 
34
               set(PluginManager::class, function($c) {
Loading history...
34
            return new PluginManager($c->g(Container::class), $c->g(Config::class),
35
                $c->g(Translator::class), $c->g(ConfigManager::class), $c->g(CodeGenerator::class));
36
        });
37
        // Code Generation
38
        $this->set(AssetManager::class, function($c) {
39
            return new AssetManager($c->g(Config::class), $c->g(UriDetector::class), $c->g(Minifier::class));
40
        });
41
        $this->set(CodeGenerator::class, function($c) {
42
            return new CodeGenerator($c->g(Jaxon::class), $c->g(TemplateEngine::class), $c->g(AssetManager::class));
43
        });
44
        // File upload manager
45
        $this->set(UploadManager::class, function($c) {
46
            return new UploadManager($c->g(Config::class), $c->g(Validator::class), $c->g(Translator::class));
47
        });
48
        // File upload plugin
49
        $this->set(UploadHandler::class, function($c) {
50
            return !$c->g(Config::class)->getOption('core.upload.enabled') ? null :
0 ignored issues
show
Coding Style introduced by
Expected 1 space after ":"; newline found
Loading history...
51
                new UploadHandler($c->g(UploadManager::class), $c->g(Translator::class), $c->g(ResponseManager::class));
52
        });
53
        // JQuery response plugin
54
        $this->set(JQueryPlugin::class, function($c) {
55
            return new JQueryPlugin($c->g(Config::class));
56
        });
57
        // DataBagPlugin response plugin
58
        $this->set(DataBagPlugin::class, function() {
59
            return new DataBagPlugin();
60
        });
61
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
62
63
    /**
64
     * Get the plugin manager
65
     *
66
     * @return PluginManager
67
     */
68
    public function getPluginManager(): PluginManager
69
    {
70
        return $this->g(PluginManager::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

70
        return $this->/** @scrutinizer ignore-call */ g(PluginManager::class);
Loading history...
71
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
72
73
    /**
74
     * Get the code generator
75
     *
76
     * @return CodeGenerator
77
     */
78
    public function getCodeGenerator(): CodeGenerator
79
    {
80
        return $this->g(CodeGenerator::class);
81
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
82
83
    /**
84
     * Get the upload handler
85
     *
86
     * @return UploadHandler|null
87
     */
88
    public function getUploadHandler(): ?UploadHandler
89
    {
90
        return $this->g(UploadHandler::class);
91
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
92
93
    /**
94
     * Get the jQuery plugin
95
     *
96
     * @return JQueryPlugin
97
     */
98
    public function getJQueryPlugin(): JQueryPlugin
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
99
    {
100
        return $this->g(JQueryPlugin::class);
101
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
102
}
103