Stats   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 42
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A stats() 0 19 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace SimpleSAML\Module\consentSimpleAdmin\Controller;
6
7
use SimpleSAML\Configuration;
8
use SimpleSAML\Module\consent\Store;
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 consentsimpleadmin module.
16
 *
17
 * This class serves the different views available in the module.
18
 *
19
 * @package simplesamlphp/simplesamlphp-module-consentsimpleadmin
20
 */
21
class Stats
22
{
23
    /**
24
     * Controller constructor.
25
     *
26
     * It initializes the global configuration and session for the controllers implemented here.
27
     *
28
     * @param \SimpleSAML\Configuration $config The configuration to use by the controllers.
29
     * @param \SimpleSAML\Session $session The session to use by the controllers.
30
     */
31
    public function __construct(
32
        protected Configuration $config,
33
        protected Session $session,
34
    ) {
35
    }
36
37
38
39
    /**
40
     * @param \Symfony\Component\HttpFoundation\Request $request The current request.
41
     *
42
     * @return \SimpleSAML\XHTML\Template
43
     */
44
    public function stats(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

44
    public function stats(/** @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...
45
    {
46
        $authUtils = new Utils\Auth();
47
        $authUtils->requireAdmin();
48
49
        // Get config object
50
        $consentconfig = $this->config::getConfig('module_consentSimpleAdmin.php');
51
52
        // Parse consent config
53
        $consent_storage = Store::parseStoreConfig($consentconfig->getValue('store'));
54
55
        // Get all consents for user
56
        $stats = $consent_storage->getStatistics();
57
58
        // Init template
59
        $t = new Template($this->config, 'consentSimpleAdmin:consentstats.twig');
60
        $t->data['stats'] = $stats;
61
62
        return $t;
63
    }
64
}
65