Passed
Push — master ( 888408...eb1365 )
by Thierry
02:11
created

CallableTrait::getCallableFunctionPlugin()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
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\Container\Traits;
4
5
use Jaxon\Config\ConfigManager;
6
use Jaxon\Jaxon;
7
use Jaxon\Container\Container;
8
use Jaxon\Request\Handler\RequestHandler;
9
use Jaxon\Request\Plugin\CallableClass\CallableRegistry;
10
use Jaxon\Request\Plugin\CallableClass\CallableRepository;
11
use Jaxon\Request\Plugin\CallableClass\CallableClassPlugin;
12
use Jaxon\Request\Plugin\CallableClass\CallableDirPlugin;
13
use Jaxon\Request\Plugin\CallableFunction\CallableFunctionPlugin;
14
use Jaxon\Request\Validator;
15
use Jaxon\Response\ResponseManager;
16
use Jaxon\Utils\Config\Config;
17
use Jaxon\Utils\Template\Engine as TemplateEngine;
18
use Jaxon\Utils\Translation\Translator;
19
20
trait CallableTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait CallableTrait
Loading history...
21
{
22
    /**
23
     * Register the values into the container
24
     *
25
     * @return void
26
     */
27
    private function registerCallables()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
28
    {
29
        // Validator
30
        $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

30
        $this->/** @scrutinizer ignore-call */ 
31
               set(Validator::class, function($c) {
Loading history...
31
            return new Validator($c->g(Translator::class), $c->g(Config::class));
32
        });
33
        // Callable objects repository
34
        $this->set(CallableRepository::class, function($c) {
35
            return new CallableRepository($c->g(Container::class));
36
        });
37
        // Callable objects registry
38
        $this->set(CallableRegistry::class, function($c) {
39
            return new CallableRegistry($c->g(Container::class),
40
                $c->g(CallableRepository::class), $c->g(Translator::class));
41
        });
42
        // Callable class plugin
43
        $this->set(CallableClassPlugin::class, function($c) {
44
            $sPrefix = $c->g(ConfigManager::class)->getOption('core.prefix.class');
45
            return new CallableClassPlugin($sPrefix, $c->g(RequestHandler::class),
46
                $c->g(ResponseManager::class), $c->g(CallableRegistry::class), $c->g(CallableRepository::class),
47
                $c->g(TemplateEngine::class), $c->g(Translator::class), $c->g(Validator::class));
48
        });
49
        // Callable dir plugin
50
        $this->set(CallableDirPlugin::class, function($c) {
51
            return new CallableDirPlugin($c->g(CallableRegistry::class), $c->g(Translator::class));
52
        });
53
        // Callable function plugin
54
        $this->set(CallableFunctionPlugin::class, function($c) {
55
            $sPrefix = $c->g(ConfigManager::class)->getOption('core.prefix.function');
56
            return new CallableFunctionPlugin($sPrefix, $c->g(RequestHandler::class),
57
                $c->g(ResponseManager::class), $c->g(TemplateEngine::class),
58
                $c->g(Translator::class), $c->g(Validator::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 callable registry
64
     *
65
     * @return CallableRegistry
66
     */
67
    public function getClassRegistry(): CallableRegistry
68
    {
69
        return $this->g(CallableRegistry::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(CallableRegistry::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 callable function plugin
74
     *
75
     * @return CallableFunctionPlugin
76
     */
77
    public function getCallableFunctionPlugin(): CallableFunctionPlugin
78
    {
79
        return $this->g(CallableFunctionPlugin::class);
80
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
81
}
82