Passed
Push — master ( 0602c9...8f96ba )
by Thierry
02:02
created

PluginTrait::getPluginManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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\Plugin\Code\Generator as CodeGenerator;
7
use Jaxon\Plugin\Manager as PluginManager;
8
use Jaxon\Request\Plugin\FileUpload;
9
use Jaxon\Request\Support\FileUpload as FileUploadSupport;
10
use Jaxon\Response\Manager as ResponseManager;
11
use Jaxon\Response\Plugin\DataBag;
12
use Jaxon\Response\Plugin\JQuery as JQueryPlugin;
13
14
trait PluginTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait PluginTrait
Loading history...
15
{
16
    /**
17
     * Register the values into the container
18
     *
19
     * @return void
20
     */
21
    private function registerPlugins()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
22
    {
23
        // Plugin Manager
24
        $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

24
        $this->/** @scrutinizer ignore-call */ 
25
               set(PluginManager::class, function($c) {
Loading history...
25
            return new PluginManager($c->g(Jaxon::class), $c->g(CodeGenerator::class));
26
        });
27
        // File upload support
28
        $this->set(FileUploadSupport::class, function() {
29
            return new FileUploadSupport();
30
        });
31
        // File upload plugin
32
        $this->set(FileUpload::class, function($c) {
33
            return new FileUpload($c->g(ResponseManager::class), $c->g(FileUploadSupport::class));
34
        });
35
        // JQuery response plugin
36
        $this->set(JQueryPlugin::class, function() {
37
            return new JQueryPlugin();
38
        });
39
        // DataBag response plugin
40
        $this->set(DataBag::class, function() {
41
            return new DataBag();
42
        });
43
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
44
45
    /**
46
     * Get the plugin manager
47
     *
48
     * @return PluginManager
49
     */
50
    public function getPluginManager()
51
    {
52
        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

52
        return $this->/** @scrutinizer ignore-call */ g(PluginManager::class);
Loading history...
53
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
54
}
55