Passed
Push — master ( 023bbd...40fcac )
by Thierry
02:15
created

PsrFactory::logger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Request\Factory\Psr;
4
5
/**
0 ignored issues
show
Coding Style introduced by
Block comments must be started with /*
Loading history...
6
 * PsrFactory.php
7
 *
8
 * A factory for PSR.
9
 *
10
 * @package jaxon-core
11
 * @author Thierry Feuzeu
12
 * @copyright 2022 Thierry Feuzeu <[email protected]>
13
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
14
 * @link https://github.com/jaxon-php/jaxon-core
15
 */
16
17
use Jaxon\Di\Container;
18
use Jaxon\Request\Handler\Psr\PsrAjaxMiddleware;
19
use Jaxon\Request\Handler\Psr\PsrConfigMiddleware;
20
use Jaxon\Request\Handler\Psr\PsrRequestHandler;
21
use Psr\Container\ContainerInterface;
22
use Psr\Log\LoggerInterface;
23
24
use Closure;
25
26
class PsrFactory
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class PsrFactory
Loading history...
27
{
28
    /**
29
     * The container
30
     *
31
     * @var Container
32
     */
33
    protected $di;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
34
35
    /**
36
     * The constructor
37
     *
38
     * @param Container $di
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
39
     */
40
    public function __construct(Container $di)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
41
    {
42
        $this->di = $di;
43
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
44
45
    /**
46
     * Set the logger
47
     *
48
     * @param LoggerInterface $xLogger
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
49
     *
50
     * @return $this
51
     */
52
    public function logger(LoggerInterface $xLogger): PsrFactory
53
    {
54
        $this->di->setLogger($xLogger);
55
        return $this;
56
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
57
58
    /**
59
     * Set the container
60
     *
61
     * @param ContainerInterface $xContainer
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
62
     *
63
     * @return $this
64
     */
65
    public function container(ContainerInterface $xContainer): PsrFactory
66
    {
67
        $this->di->setContainer($xContainer);
68
        return $this;
69
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
70
71
    /**
72
     * Add a view renderer with an id
73
     *
74
     * @param string $sRenderer    The renderer name
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 4 found
Loading history...
75
     * @param string $sExtension    The extension to append to template names
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
76
     * @param Closure $xClosure    A closure to create the view instance
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter name; 4 found
Loading history...
77
     *
78
     * @return void
79
     */
80
    public function view(string $sRenderer, string $sExtension, Closure $xClosure)
81
    {
82
        $xViewRenderer = $this->di->getViewRenderer();
83
        $xViewRenderer->addNamespace('default', '', $sExtension, $sRenderer);
84
        $xViewRenderer->addRenderer($sRenderer, $xClosure);
85
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
86
87
    /**
88
     * Get the Jaxon ajax PSR request handler
89
     *
90
     * @return PsrRequestHandler
91
     */
92
    public function handler(): PsrRequestHandler
93
    {
94
        return $this->di->getPsrRequestHandler();
95
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
96
97
    /**
98
     * Get the Jaxon config PSR middleware
99
     *
100
     * @param string $sConfigFile
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
101
     *
102
     * @return PsrConfigMiddleware
103
     */
104
    public function config(string $sConfigFile): PsrConfigMiddleware
105
    {
106
        return $this->di->getPsrConfigMiddleware($sConfigFile);
107
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
108
109
    /**
110
     * Get the Jaxon ajax PSR middleware
111
     *
112
     * @return PsrAjaxMiddleware
113
     */
114
    public function ajax(): PsrAjaxMiddleware
115
    {
116
        return $this->di->getPsrAjaxMiddleware();
117
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
118
}
119