Passed
Pull Request — master (#2)
by Tim
04:28
created

MemcacheMonitorController::setAuthUtils()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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

76
    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...
77
    {
78
        $this->authUtils::requireAdmin();
79
80
        $memcacheMonitor = new MemcacheMonitor($this->config);
81
        return $memcacheMonitor->renderStats();
82
    }
83
}
84