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

UtilTrait::registerUtils()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 25
rs 9.8666
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\Utils\Config\Config;
6
use Jaxon\Utils\File\Minifier;
7
use Jaxon\Utils\Http\URI;
8
use Jaxon\Utils\Template\Engine as TemplateEngine;
9
use Jaxon\Utils\Translation\Translator;
10
use Jaxon\Utils\Validation\Validator;
11
use Lemon\Event\EventDispatcher;
12
13
trait UtilTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait UtilTrait
Loading history...
14
{
15
    /**
16
     * Register the values into the container
17
     *
18
     * @return void
19
     */
20
    private function registerUtils()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
21
    {
22
        // Translator
23
        $this->set(Translator::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

23
        $this->/** @scrutinizer ignore-call */ 
24
               set(Translator::class, function($c) {
Loading history...
24
            return new Translator($c->g('jaxon.core.dir.translation'), $c->g(Config::class));
25
        });
26
        // Validator
27
        $this->set(Validator::class, function($c) {
28
            return new Validator($c->g(Translator::class), $c->g(Config::class));
29
        });
30
        // Template engine
31
        $this->set(TemplateEngine::class, function($c) {
32
            return new TemplateEngine($c->g('jaxon.core.dir.template'));
33
        });
34
        // Minifier
35
        $this->set(Minifier::class, function() {
36
            return new Minifier();
37
        });
38
        // Event Dispatcher
39
        $this->set(EventDispatcher::class, function() {
40
            return new EventDispatcher();
41
        });
42
        // URI decoder
43
        $this->set(URI::class, function() {
44
            return new URI();
45
        });
46
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
47
48
    /**
49
     * Get the translator
50
     *
51
     * @return Translator
52
     */
53
    public function getTranslator()
54
    {
55
        return $this->g(Translator::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

55
        return $this->/** @scrutinizer ignore-call */ g(Translator::class);
Loading history...
56
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
57
58
    /**
59
     * Get the validator
60
     *
61
     * @return Validator
62
     */
63
    public function getValidator()
64
    {
65
        return $this->g(Validator::class);
66
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
67
68
    /**
69
     * Get the template engine
70
     *
71
     * @return TemplateEngine
72
     */
73
    public function getTemplateEngine()
74
    {
75
        return $this->g(TemplateEngine::class);
76
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
77
78
    /**
79
     * Get the minifier
80
     *
81
     * @return Minifier
82
     */
83
    public function getMinifier()
84
    {
85
        return $this->g(Minifier::class);
86
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
87
88
    /**
89
     * Get the event dispatcher
90
     *
91
     * @return EventDispatcher
92
     */
93
    public function getEventDispatcher()
94
    {
95
        return $this->g(EventDispatcher::class);
96
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
97
}
98