Passed
Push — master ( f68dc4...291d13 )
by Thierry
02:15
created

PluginTrait.php$0 ➔ getDialogPlugin()   A

Complexity

Conditions 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 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\Config\ConfigManager;
7
use Jaxon\App\Dialog\Library\DialogLibraryManager;
8
use Jaxon\App\I18n\Translator;
9
use Jaxon\App\View\ViewRenderer;
10
use Jaxon\Di\Container;
11
use Jaxon\Plugin\Code\AssetManager;
12
use Jaxon\Plugin\Code\CodeGenerator;
13
use Jaxon\Plugin\Code\MinifierInterface;
14
use Jaxon\Plugin\Manager\PackageManager;
15
use Jaxon\Plugin\Manager\PluginManager;
16
use Jaxon\Plugin\Response\DataBag\DataBagPlugin;
17
use Jaxon\Plugin\Response\Dialog\DialogPlugin;
18
use Jaxon\Plugin\Response\JQuery\JQueryPlugin;
19
use Jaxon\Request\Handler\ParameterReader;
20
use Jaxon\Utils\File\FileMinifier;
21
use Jaxon\Utils\Template\TemplateEngine;
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(Translator::class));
35
        });
36
        // Package manager
37
        $this->set(PackageManager::class, function($c) {
38
            return new PackageManager($c->g(Container::class), $c->g(PluginManager::class),
39
                $c->g(ConfigManager::class), $c->g(ViewRenderer::class), $c->g(Translator::class));
40
        });
41
        // Code Generation
42
        $this->set(MinifierInterface::class, function() {
43
            return new class extends FileMinifier implements MinifierInterface
44
            {};
45
        });
46
        $this->set(AssetManager::class, function($c) {
47
            return new AssetManager($c->g(ConfigManager::class), $c->g(ParameterReader::class),
48
                $c->g(MinifierInterface::class));
49
        });
50
        $this->set(CodeGenerator::class, function($c) {
51
            return new CodeGenerator(Jaxon::VERSION, $c->g(Container::class), $c->g(PluginManager::class),
52
                $c->g(TemplateEngine::class));
53
        });
54
55
        // JQuery response plugin
56
        $this->set(JQueryPlugin::class, function($c) {
57
            $jQueryNs = $c->g(ConfigManager::class)->getOption('core.jquery.no_conflict', false) ? 'jQuery' : '$';
58
            return new JQueryPlugin($jQueryNs);
59
        });
60
        // DataBag response plugin
61
        $this->set(DataBagPlugin::class, function($c) {
62
            return new DataBagPlugin($c->g(Container::class));
63
        });
64
        // Dialog response plugin
65
        $this->set(DialogPlugin::class, function($c) {
66
            return new DialogPlugin($c->g(DialogLibraryManager::class));
67
        });
68
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
69
70
    /**
71
     * Get the plugin manager
72
     *
73
     * @return PluginManager
74
     */
75
    public function getPluginManager(): PluginManager
76
    {
77
        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

77
        return $this->/** @scrutinizer ignore-call */ g(PluginManager::class);
Loading history...
78
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
79
80
    /**
81
     * Get the package manager
82
     *
83
     * @return PackageManager
84
     */
85
    public function getPackageManager(): PackageManager
86
    {
87
        return $this->g(PackageManager::class);
88
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
89
90
    /**
91
     * Get the code generator
92
     *
93
     * @return CodeGenerator
94
     */
95
    public function getCodeGenerator(): CodeGenerator
96
    {
97
        return $this->g(CodeGenerator::class);
98
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
99
100
    /**
101
     * Get the asset manager
102
     *
103
     * @return AssetManager
104
     */
105
    public function getAssetManager(): AssetManager
106
    {
107
        return $this->g(AssetManager::class);
108
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
109
110
    /**
111
     * Get the jQuery plugin
112
     *
113
     * @return JQueryPlugin
114
     */
115
    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...
116
    {
117
        return $this->g(JQueryPlugin::class);
118
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
119
120
    /**
121
     * Get the dialog plugin
122
     *
123
     * @return DialogPlugin
124
     */
125
    public function getDialogPlugin(): DialogPlugin
126
    {
127
        return $this->g(DialogPlugin::class);
128
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
129
}
130