MemcacheMonitorController::setAuthUtils()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\memcacheMonitor\Controller;
6
7
use SimpleSAML\Configuration;
8
use SimpleSAML\Module\memcacheMonitor\MemcacheMonitor;
9
use SimpleSAML\Session;
10
use SimpleSAML\Utils;
11
use SimpleSAML\XHTML\Template;
12
use Symfony\Component\HttpFoundation\Request;
13
14
/**
15
 * Controller class for the memcacheMonitor module.
16
 *
17
 * This class serves the different views available in the module.
18
 *
19
 * @package SimpleSAML\Module\memcacheMonitor
20
 */
21
class MemcacheMonitorController
22
{
23
    /** @var \SimpleSAML\Configuration */
24
    protected Configuration $config;
25
26
    /** @var \SimpleSAML\Session */
27
    protected Session $session;
28
29
    /** @var \SimpleSAML\Utils\Auth */
30
    protected $authUtils;
31
32
33
    /**
34
     * Controller constructor.
35
     *
36
     * It initializes the global configuration and auth source configuration for the controllers implemented here.
37
     *
38
     * @param \SimpleSAML\Configuration              $config The configuration to use by the controllers.
39
     * @param \SimpleSAML\Session                    $session The session to use by the controllers.
40
     *
41
     * @throws \Exception
42
     */
43
    public function __construct(
44
        Configuration $config,
45
        Session $session,
46
    ) {
47
        $this->config = $config;
48
        $this->session = $session;
49
        $this->authUtils = new Utils\Auth();
50
    }
51
52
53
    /**
54
     * Inject the \SimpleSAML\Utils\Auth dependency.
55
     *
56
     * @param \SimpleSAML\Utils\Auth $authUtils
57
     */
58
    public function setAuthUtils(Utils\Auth $authUtils): void
59
    {
60
        $this->authUtils = $authUtils;
61
    }
62
63
64
    /**
65
     * Show memcache info.
66
     *
67
     * @param \Symfony\Component\HttpFoundation\Request $request
68
     * @return \SimpleSAML\XHTML\Template
69
     *   An HTML template or a redirection if we are not authenticated.
70
     */
71
    public function main(Request $request): Template
0 ignored issues
show
Unused Code introduced by
The parameter $request is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

71
    public function main(/** @scrutinizer ignore-unused */ Request $request): Template

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
72
    {
73
        $this->authUtils->requireAdmin();
74
75
        $memcacheMonitor = new MemcacheMonitor($this->config);
76
        return $memcacheMonitor->renderStats();
77
    }
78
}
79