Passed
Push — master ( 729ca2...5212d6 )
by Thierry
02:19
created

CallableClass::target()   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\App;
4
5
use Jaxon\App\Session\SessionInterface;
6
use Jaxon\App\View\ViewRenderer;
7
use Jaxon\Exception\SetupException;
8
use Jaxon\Plugin\Request\CallableClass\CallableClassHelper;
9
use Jaxon\Plugin\Response\DataBag\DataBagContext;
10
use Jaxon\Plugin\Response\JQuery\DomSelector;
11
use Jaxon\Request\Factory\RequestFactory;
12
use Jaxon\Request\TargetInterface;
13
use Jaxon\Response\Response;
14
use Psr\Log\LoggerInterface;
15
16
class CallableClass
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class CallableClass
Loading history...
17
{
18
    /**
19
     * @var Response
20
     */
21
    protected $response = null;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
22
23
    /**
24
     * @var CallableClassHelper
25
     */
26
    protected $xCallableClassHelper = null;
27
28
    /**
29
     * Get the Jaxon request target
30
     *
31
     * @return TargetInterface
32
     */
33
    protected function target(): TargetInterface
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
34
    {
35
        return $this->xCallableClassHelper->xTarget;
36
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
37
38
    /**
39
     * Get an instance of a Jaxon class by name
40
     *
41
     * @param string $sName the class name
42
     *
43
     * @return object|null
44
     * @throws SetupException
45
     */
46
    public function cl(string $sName)
47
    {
48
        $xCallableClass = $this->xCallableClassHelper->xCallableRegistry->getCallableObject($sName);
49
        if($xCallableClass === null)
50
        {
51
            return null;
52
        }
53
        return $xCallableClass->getRegisteredObject();
54
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
55
56
    /**
57
     * Get the request factory.
58
     *
59
     * @return RequestFactory
60
     */
61
    public function rq(): RequestFactory
62
    {
63
        return $this->xCallableClassHelper->xRequestFactory;
64
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
65
66
    /**
67
     * Get the logger
68
     *
69
     * @return LoggerInterface
70
     */
71
    public function logger(): LoggerInterface
72
    {
73
        return $this->xCallableClassHelper->xLogger;
74
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
75
76
    /**
77
     * Get the view renderer
78
     *
79
     * @return ViewRenderer
80
     */
81
    public function view(): ViewRenderer
82
    {
83
        return $this->xCallableClassHelper->xViewRenderer;
84
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
85
86
    /**
87
     * Get the session manager
88
     *
89
     * @return SessionInterface
90
     */
91
    public function session(): SessionInterface
92
    {
93
        return $this->xCallableClassHelper->xSessionManager;
94
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
95
96
    /**
97
     * Get the uploaded files
98
     *
99
     * @return array
100
     */
101
    public function files(): array
102
    {
103
        return $this->xCallableClassHelper->xUploadHandler->files();
104
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
105
106
    /**
107
     * Create a JQuery DomSelector, and link it to the response attribute.
108
     *
109
     * @param string $sPath    The jQuery selector path
110
     * @param string $sContext    A context associated to the selector
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
111
     *
112
     * @return DomSelector
113
     */
114
    public function jq(string $sPath = '', string $sContext = ''): DomSelector
115
    {
116
        return $this->response->jq($sPath, $sContext);
117
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
118
119
    /**
120
     * Get a data bag.
121
     *
122
     * @param string  $sName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
123
     *
124
     * @return DataBagContext
125
     */
126
    public function bag(string $sName): DataBagContext
127
    {
128
        return $this->response->bag($sName);
129
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
130
}
131