Passed
Push — master ( 6f7a23...2cf817 )
by Thierry
02:29
created

PsrFactory::container()   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
class PsrFactory
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class PsrFactory
Loading history...
25
{
26
    /**
27
     * The container
28
     *
29
     * @var Container
30
     */
31
    protected $di;
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line(s) before first member var; 0 found
Loading history...
32
33
    /**
34
     * The constructor
35
     *
36
     * @param Container $di
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
37
     */
38
    public function __construct(Container $di)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
39
    {
40
        $this->di = $di;
41
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
42
43
    /**
44
     * Set the logger
45
     *
46
     * @param LoggerInterface $xLogger
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
47
     *
48
     * @return $this
49
     */
50
    public function logger(LoggerInterface $xLogger): PsrFactory
51
    {
52
        $this->di->setLogger($xLogger);
53
        return $this;
54
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
55
56
    /**
57
     * Set the container
58
     *
59
     * @param ContainerInterface $xContainer
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
60
     *
61
     * @return $this
62
     */
63
    public function container(ContainerInterface $xContainer): PsrFactory
64
    {
65
        $this->di->setContainer($xContainer);
66
        return $this;
67
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
68
69
    /**
70
     * Get the Jaxon ajax PSR request handler
71
     *
72
     * @return PsrRequestHandler
73
     */
74
    public function handler(): PsrRequestHandler
75
    {
76
        return $this->di->getPsrRequestHandler();
77
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
78
79
    /**
80
     * Get the Jaxon config PSR middleware
81
     *
82
     * @param string $sConfigFile
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
83
     *
84
     * @return PsrConfigMiddleware
85
     */
86
    public function config(string $sConfigFile): PsrConfigMiddleware
87
    {
88
        return $this->di->getPsrConfigMiddleware($sConfigFile);
89
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
90
91
    /**
92
     * Get the Jaxon ajax PSR middleware
93
     *
94
     * @return PsrAjaxMiddleware
95
     */
96
    public function ajax(): PsrAjaxMiddleware
97
    {
98
        return $this->di->getPsrAjaxMiddleware();
99
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
100
}
101