Passed
Push — master ( cd350b...3a08d5 )
by Thierry
03:10
created

CallableTrait::getCodeGenerator()   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\Request\Handler\RequestHandler;
7
use Jaxon\Request\Plugin\CallableClass\Registry;
8
use Jaxon\Request\Plugin\CallableClass\Repository;
9
use Jaxon\Request\Plugin\CallableClass\ClassPlugin;
10
use Jaxon\Request\Plugin\CallableClass\DirPlugin;
11
use Jaxon\Request\Plugin\CallableFunction\FunctionPlugin;
12
use Jaxon\Request\Validator;
13
use Jaxon\Response\ResponseManager;
14
use Jaxon\Utils\Config\Config;
15
use Jaxon\Utils\Template\Engine as TemplateEngine;
16
use Jaxon\Utils\Translation\Translator;
17
18
trait CallableTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait CallableTrait
Loading history...
19
{
20
    /**
21
     * Register the values into the container
22
     *
23
     * @return void
24
     */
25
    private function registerCallables()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
26
    {
27
        // Validator
28
        $this->set(Validator::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

28
        $this->/** @scrutinizer ignore-call */ 
29
               set(Validator::class, function($c) {
Loading history...
29
            return new Validator($c->g(Translator::class), $c->g(Config::class));
30
        });
31
        // Callable objects repository
32
        $this->set(Repository::class, function() {
33
            return new Repository($this);
34
        });
35
        // Callable objects registry
36
        $this->set(Registry::class, function($c) {
37
            return new Registry($this, $c->g(Repository::class), $c->g(Translator::class));
38
        });
39
        // Callable class plugin
40
        $this->set(ClassPlugin::class, function($c) {
41
            return new ClassPlugin($c->g(Config::class), $c->g(RequestHandler::class),
42
                $c->g(ResponseManager::class), $c->g(Registry::class), $c->g(Repository::class),
43
                $c->g(TemplateEngine::class), $c->g(Translator::class), $c->g(Validator::class));
44
        });
45
        // Callable dir plugin
46
        $this->set(DirPlugin::class, function($c) {
47
            return new DirPlugin($c->g(Registry::class), $c->g(Translator::class));
48
        });
49
        // Callable function plugin
50
        $this->set(FunctionPlugin::class, function($c) {
51
            return new FunctionPlugin($c->g(Jaxon::class), $c->g(Config::class),
52
                $c->g(RequestHandler::class), $c->g(ResponseManager::class),
53
                $c->g(TemplateEngine::class), $c->g(Translator::class), $c->g(Validator::class));
54
        });
55
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
56
57
    /**
58
     * Get the callable registry
59
     *
60
     * @return Registry
61
     */
62
    public function getClassRegistry(): Registry
63
    {
64
        return $this->g(Registry::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

64
        return $this->/** @scrutinizer ignore-call */ g(Registry::class);
Loading history...
65
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
66
}
67