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

CallableTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 16
dl 0
loc 54
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCodeGenerator() 0 3 1
A registerCallables() 0 26 1
A getCallableRegistry() 0 3 1
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\Request\Handler\Handler as RequestHandler;
8
use Jaxon\Request\Plugin\CallableClass;
9
use Jaxon\Request\Plugin\CallableDir;
10
use Jaxon\Request\Plugin\CallableFunction;
11
use Jaxon\Request\Support\CallableRegistry;
12
use Jaxon\Request\Support\CallableRepository;
13
use Jaxon\Response\Manager as ResponseManager;
14
use Jaxon\Utils\Http\URI;
15
use Jaxon\Utils\Template\Engine as TemplateEngine;
16
17
trait CallableTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait CallableTrait
Loading history...
18
{
19
    /**
20
     * Register the values into the container
21
     *
22
     * @return void
23
     */
24
    private function registerCallables()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
25
    {
26
        // Callable objects repository
27
        $this->set(CallableRepository::class, function() {
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

27
        $this->/** @scrutinizer ignore-call */ 
28
               set(CallableRepository::class, function() {
Loading history...
28
            return new CallableRepository($this);
29
        });
30
        // Callable objects registry
31
        $this->set(CallableRegistry::class, function($c) {
32
            return new CallableRegistry($c->g(CallableRepository::class));
33
        });
34
        // Callable class plugin
35
        $this->set(CallableClass::class, function($c) {
36
            return new CallableClass($c->g(RequestHandler::class), $c->g(ResponseManager::class),
37
                $c->g(CallableRegistry::class), $c->g(CallableRepository::class));
38
        });
39
        // Callable dir plugin
40
        $this->set(CallableDir::class, function($c) {
41
            return new CallableDir($c->g(CallableRegistry::class));
42
        });
43
        // Callable function plugin
44
        $this->set(CallableFunction::class, function($c) {
45
            return new CallableFunction($this, $c->g(RequestHandler::class), $c->g(ResponseManager::class));
46
        });
47
        // Code Generator
48
        $this->set(CodeGenerator::class, function($c) {
49
            return new CodeGenerator($c->g(Jaxon::class), $c->g(URI::class), $c->g(TemplateEngine::class));
50
        });
51
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
52
53
    /**
54
     * Get the callable registry
55
     *
56
     * @return CallableRegistry
57
     */
58
    public function getCallableRegistry()
59
    {
60
        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

60
        return $this->/** @scrutinizer ignore-call */ g(CallableRegistry::class);
Loading history...
61
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
62
63
    /**
64
     * Get the code generator
65
     *
66
     * @return CodeGenerator
67
     */
68
    public function getCodeGenerator()
69
    {
70
        return $this->g(CodeGenerator::class);
71
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
72
}
73