Passed
Push — master ( 5198fb...6eb156 )
by Thierry
02:34
created

PluginTrait::getJQueryPlugin()

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
nc 1
nop 0
dl 0
loc 3
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\Di\Traits;
4
5
use Jaxon\Jaxon;
6
use Jaxon\Config\ConfigManager;
7
use Jaxon\Di\Container;
8
use Jaxon\Plugin\Code\AssetManager;
9
use Jaxon\Plugin\Code\CodeGenerator;
10
use Jaxon\Plugin\Code\MinifierInterface;
11
use Jaxon\Plugin\Manager\PackageManager;
12
use Jaxon\Plugin\Manager\PluginManager;
13
use Jaxon\Request\Handler\ParameterReader;
14
use Jaxon\Response\Plugin\DataBag\DataBagPlugin;
15
use Jaxon\Response\Plugin\JQuery\JQueryPlugin;
16
use Jaxon\Ui\View\ViewManager;
17
use Jaxon\Utils\File\FileMinifier;
18
use Jaxon\Utils\Template\TemplateEngine;
19
use Jaxon\Utils\Translation\Translator;
20
21
trait PluginTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait PluginTrait
Loading history...
22
{
23
    /**
24
     * Register the values into the container
25
     *
26
     * @return void
27
     */
28
    private function registerPlugins()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
29
    {
30
        // Plugin manager
31
        $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

31
        $this->/** @scrutinizer ignore-call */ 
32
               set(PluginManager::class, function($c) {
Loading history...
32
            return new PluginManager($c->g(Container::class), $c->g(CodeGenerator::class), $c->g(Translator::class));
33
        });
34
        // Package manager
35
        $this->set(PackageManager::class, function($c) {
36
            return new PackageManager($c->g(Container::class), $c->g(PluginManager::class), $c->g(ConfigManager::class),
37
                $c->g(ViewManager::class), $c->g(CodeGenerator::class), $c->g(Translator::class));
38
        });
39
        // Code Generation
40
        $this->set(MinifierInterface::class, function() {
41
            return new class extends FileMinifier implements MinifierInterface {};
42
        });
43
        $this->set(AssetManager::class, function($c) {
44
            return new AssetManager($c->g(ConfigManager::class), $c->g(ParameterReader::class),
45
                $c->g(MinifierInterface::class));
46
        });
47
        $this->set(CodeGenerator::class, function($c) {
48
            $sVersion = $c->g(Jaxon::class)->getVersion();
49
            return new CodeGenerator($sVersion, $c->g(Container::class), $c->g(TemplateEngine::class));
50
        });
51
        // JQuery response plugin
52
        $this->set(JQueryPlugin::class, function($c) {
53
            $jQueryNs = $c->g(ConfigManager::class)->getOption('core.jquery.no_conflict', false) ? 'jQuery' : '$';
54
            return new JQueryPlugin($jQueryNs);
55
        });
56
        // DataBagPlugin response plugin
57
        $this->set(DataBagPlugin::class, function($c) {
58
            return new DataBagPlugin($c->g(Container::class));
59
        });
60
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
61
62
    /**
63
     * Get the plugin manager
64
     *
65
     * @return PluginManager
66
     */
67
    public function getPluginManager(): PluginManager
68
    {
69
        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

69
        return $this->/** @scrutinizer ignore-call */ g(PluginManager::class);
Loading history...
70
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
71
72
    /**
73
     * Get the code generator
74
     *
75
     * @return CodeGenerator
76
     */
77
    public function getCodeGenerator(): CodeGenerator
78
    {
79
        return $this->g(CodeGenerator::class);
80
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
81
82
    /**
83
     * Get the asset manager
84
     *
85
     * @return AssetManager
86
     */
87
    public function getAssetManager(): AssetManager
88
    {
89
        return $this->g(AssetManager::class);
90
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
91
92
    /**
93
     * Get the jQuery plugin
94
     *
95
     * @return JQueryPlugin
96
     */
97
    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...
98
    {
99
        return $this->g(JQueryPlugin::class);
100
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
101
}
102