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

ResponseTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 8
dl 0
loc 50
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponseManager() 0 3 1
A registerResponses() 0 12 1
A newResponse() 0 3 1
A getResponse() 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\Response\Response;
7
use Jaxon\Response\Manager as ResponseManager;
8
9
trait ResponseTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait ResponseTrait
Loading history...
10
{
11
    /**
12
     * Register the values into the container
13
     *
14
     * @return void
15
     */
16
    private function registerResponses()
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
17
    {
18
        /*
19
         * Core library objects
20
         */
0 ignored issues
show
Coding Style introduced by
Empty line required after block comment
Loading history...
21
        // Global Response
22
        $this->set(Response::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

22
        $this->/** @scrutinizer ignore-call */ 
23
               set(Response::class, function() {
Loading history...
23
            return new Response();
24
        });
25
        // Response Manager
26
        $this->set(ResponseManager::class, function($c) {
27
            return new ResponseManager($c->g(Jaxon::class));
28
        });
29
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
30
31
    /**
32
     * Get the response manager
33
     *
34
     * @return ResponseManager
35
     */
36
    public function getResponseManager()
37
    {
38
        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

38
        return $this->/** @scrutinizer ignore-call */ g(ResponseManager::class);
Loading history...
39
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
40
41
    /**
42
     * Get the global Response object
43
     *
44
     * @return Response
45
     */
46
    public function getResponse()
47
    {
48
        return $this->g(Response::class);
49
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
50
51
    /**
52
     * Create a new Jaxon response object
53
     *
54
     * @return Response
55
     */
56
    public function newResponse()
57
    {
58
        return new Response();
59
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
60
}
61