Passed
Push — master ( bf2aee...a6dc35 )
by Thierry
02:22
created

ResponseTrait::getResponse()   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\Di\Traits;
4
5
use Jaxon\Config\ConfigManager;
6
use Jaxon\Di\Container;
7
use Jaxon\Plugin\Manager\PluginManager;
8
use Jaxon\Request\Handler\ArgumentManager;
9
use Jaxon\Response\Response;
10
use Jaxon\Response\ResponseManager;
11
use Jaxon\Utils\Translation\Translator;
12
13
use function trim;
14
15
trait ResponseTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait ResponseTrait
Loading history...
16
{
17
    /**
18
     * Register the values into the container
19
     *
20
     * @return void
21
     */
22
    private function registerResponses()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
23
    {
24
        /*
25
         * Core library objects
26
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
27
        // Global Response
28
        $this->set(Response::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(Response::class, function($c) {
Loading history...
29
            return new Response($c->g(Translator::class), $c->g(PluginManager::class));
30
        });
31
        // Response Manager
32
        $this->set(ResponseManager::class, function($c) {
33
            $sCharacterEncoding = trim($c->g(ConfigManager::class)->getOption('core.encoding', ''));
34
            return new ResponseManager($sCharacterEncoding, $c->g(Container::class),
35
                $c->g(ArgumentManager::class), $c->g(Translator::class));
36
        });
37
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
38
39
    /**
40
     * Get the response manager
41
     *
42
     * @return ResponseManager
43
     */
44
    public function getResponseManager(): ResponseManager
45
    {
46
        return $this->g(ResponseManager::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

46
        return $this->/** @scrutinizer ignore-call */ g(ResponseManager::class);
Loading history...
47
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
48
49
    /**
50
     * Get the global Response object
51
     *
52
     * @return Response
53
     */
54
    public function getResponse(): Response
55
    {
56
        return $this->g(Response::class);
57
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
58
59
    /**
60
     * Create a new Jaxon response object
61
     *
62
     * @return Response
63
     */
64
    public function newResponse(): Response
65
    {
66
        return new Response($this->g(Translator::class), $this->g(PluginManager::class));
67
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
68
}
69