GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

HmacFilter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 6
dl 0
loc 33
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 7 2
A beforeAction() 0 10 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace SamIT\Yii2\UrlSigner;
6
7
8
use SamIT\Yii2\UrlSigner\UrlSigner;
9
use yii\base\ActionFilter;
10
use yii\base\InvalidConfigException;
11
use yii\web\ForbiddenHttpException;
12
use yii\web\Request;
13
14
/**
15
 * Filter that checks for a valid HMAC in the URL.
16
 * @inheritdoc
17
 */
18
class HmacFilter extends ActionFilter
19
{
20
    /**
21
     * @var UrlSigner
22
     */
23
    public $signer;
24
25 10
    public function init(): void
26
    {
27 10
        parent::init();
28 10
        if (!$this->signer instanceof UrlSigner) {
29 4
            throw new InvalidConfigException('Signer is required');
30
        }
31
    }
32
33
34
    /**
35
     * @param \yii\base\Action $action
36
     * @throws \Exception
37
     * @return bool
38
     */
39 4
    public function beforeAction($action)
40
    {
41
        /**
42
         * We obtain the request this way because we do not want to store a reference to any objects with state.
43
         * @var Request $request
44
         */
45 4
        $request = $action->controller->module->get('request');
46 4
        $this->signer->verify($request->queryParams, $action->controller->route);
47 2
        return true;
48
    }
49
50
}
51