Passed
Push — v5.x ( 6ac3c7...223ede )
by Thierry
02:17
created

PsrFactory::config()   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 1
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Jaxon\Request\Handler\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 Psr\Container\ContainerInterface;
19
use Psr\Log\LoggerInterface;
20
21
use Closure;
22
23
class PsrFactory
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class PsrFactory
Loading history...
24
{
25
    /**
26
     * The container
27
     *
28
     * @var Container
29
     */
30
    protected $di;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
31
32
    /**
33
     * The constructor
34
     *
35
     * @param Container $di
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
36
     */
37
    public function __construct(Container $di)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
38
    {
39
        $this->di = $di;
40
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
41
42
    /**
43
     * Set the logger
44
     *
45
     * @param LoggerInterface $xLogger
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
46
     *
47
     * @return $this
48
     */
49
    public function logger(LoggerInterface $xLogger): PsrFactory
50
    {
51
        $this->di->setLogger($xLogger);
52
        return $this;
53
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
54
55
    /**
56
     * Set the container
57
     *
58
     * @param ContainerInterface $xContainer
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
59
     *
60
     * @return $this
61
     */
62
    public function container(ContainerInterface $xContainer): PsrFactory
63
    {
64
        $this->di->setContainer($xContainer);
65
        return $this;
66
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
67
68
    /**
69
     * Add a view renderer with an id
70
     *
71
     * @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...
72
     * @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...
73
     * @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...
74
     *
75
     * @return $this
76
     */
77
    public function view(string $sRenderer, string $sExtension, Closure $xClosure): PsrFactory
78
    {
79
        $this->di->getViewRenderer()->setDefaultRenderer($sRenderer, $sExtension, $xClosure);
80
        return $this;
81
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
82
83
    /**
84
     * Get the Jaxon ajax PSR request handler
85
     *
86
     * @return PsrRequestHandler
87
     */
88
    public function handler(): PsrRequestHandler
89
    {
90
        return $this->di->getPsrRequestHandler();
91
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
92
93
    /**
94
     * Get the Jaxon config PSR middleware
95
     *
96
     * @param string $sConfigFile
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
97
     *
98
     * @return PsrConfigMiddleware
99
     */
100
    public function config(string $sConfigFile): PsrConfigMiddleware
101
    {
102
        return $this->di->getPsrConfigMiddleware($sConfigFile);
103
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
104
105
    /**
106
     * Get the Jaxon ajax PSR middleware
107
     *
108
     * @return PsrAjaxMiddleware
109
     */
110
    public function ajax(): PsrAjaxMiddleware
111
    {
112
        return $this->di->getPsrAjaxMiddleware();
113
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
114
}
115