Passed
Push — main ( fef313...79e33c )
by Thierry
11:43
created

CallableClassHelper::cl()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * CallableClassHelper.php
5
 *
6
 * Provides properties to a callable class.
7
 *
8
 * @package jaxon-core
0 ignored issues
show
Coding Style introduced by
Package name "jaxon-core" is not valid; consider "Jaxoncore" instead
Loading history...
9
 * @author Thierry Feuzeu <[email protected]>
10
 * @copyright 2022 Thierry Feuzeu <[email protected]>
11
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
12
 * @link https://github.com/jaxon-php/jaxon-core
13
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
14
15
namespace Jaxon\Plugin\Request\CallableClass;
16
17
use Jaxon\App\Session\SessionInterface;
18
use Jaxon\App\View\ViewRenderer;
19
use Jaxon\Di\Container;
20
use Jaxon\Exception\SetupException;
21
use Jaxon\Request\Factory\Factory;
22
use Jaxon\Request\Factory\RequestFactory;
23
use Jaxon\Request\Target;
24
use Jaxon\Request\Upload\UploadHandlerInterface;
25
use Psr\Log\LoggerInterface;
26
27
use function trim;
28
29
class CallableClassHelper
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class CallableClassHelper
Loading history...
30
{
31
    /**
32
     * @var Factory
33
     */
34
    public $xFactory;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
35
36
    /**
37
     * @var RequestFactory
38
     */
39
    public $xRequestFactory;
40
41
    /**
42
     * @var ViewRenderer
43
     */
44
    public $xViewRenderer;
45
46
    /**
47
     * @var LoggerInterface
48
     */
49
    public $xLogger;
50
51
    /**
52
     * @var UploadHandlerInterface
53
     */
54
    public $xUploadHandler;
55
56
    /**
57
     * @var CallableRegistry
58
     */
59
    public $xCallableRegistry;
60
61
    /**
62
     * @var SessionInterface
63
     */
64
    public $xSessionManager;
65
66
    /**
67
     * @var Target
68
     */
69
    public $xTarget;
70
71
    /**
72
     * The constructor
73
     *
74
     * @param Container $di
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
75
     * @param string $sClassName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
76
     *
77
     * @throws SetupException
78
     */
79
    public function __construct(Container $di, string $sClassName)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
80
    {
81
        $this->xFactory = $di->getFactory();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
82
        $this->xRequestFactory = $this->xFactory->request($sClassName);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
83
        $this->xCallableRegistry = $di->getCallableRegistry();
84
        $this->xViewRenderer = $di->getViewRenderer();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
85
        $this->xLogger = $di->getLogger();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
86
        $this->xUploadHandler = $di->getUploadHandler();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
87
        $this->xSessionManager = $di->getSessionManager();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
88
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
89
90
    /**
91
     * Get an instance of a Jaxon class by name
92
     *
93
     * @param string $sClassName the class name
94
     *
95
     * @return mixed
96
     * @throws SetupException
97
     */
98
    public function cl(string $sClassName)
99
    {
100
        $sClassName = trim($sClassName);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
101
        $xCallableClass = $this->xCallableRegistry->getCallableObject($sClassName);
102
        return !$xCallableClass ? null : $xCallableClass->getRegisteredObject();
0 ignored issues
show
introduced by
$xCallableClass is of type Jaxon\Plugin\Request\CallableClass\CallableObject, thus it always evaluated to true.
Loading history...
103
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
104
105
    /**
106
     * Get the request factory.
107
     *
108
     * @param string $sClassName
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
109
     *
110
     * @return RequestFactory
111
     */
112
    public function rq(string $sClassName = ''): RequestFactory
113
    {
114
        $sClassName = trim($sClassName);
115
        return !$sClassName ? $this->xRequestFactory : $this->xFactory->request($sClassName);
116
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
117
}
118