Completed
Push — master ( 78ae5b...d9d567 )
by Damien
11:44
created

AbstractSettingsController::behaviors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 9.52
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dsmrt
5
 * Date: 3/9/18
6
 * Time: 2:48 PM
7
 */
8
9
namespace flipbox\saml\core\controllers;
10
11
use Craft;
12
use craft\helpers\ArrayHelper;
13
use flipbox\saml\core\AbstractPlugin;
14
15
/**
16
 * Class AbstractGeneralController
17
 * @package flipbox\saml\core\controllers\cp\view
18
 */
19
abstract class AbstractSettingsController extends AbstractController implements \flipbox\saml\core\EnsureSAMLPlugin
20
{
21
22
    /**
23
     * @return array
24
     */
25
    protected function verbs(): array
26
    {
27
        return [
28
            'save' => ['post', 'put'],
29
        ];
30
    }
31
32
    /**
33
     * @return mixed
34
     * @throws \yii\base\InvalidConfigException
35
     */
36
    public function actionSave()
37
    {
38
        /** @var AbstractPlugin $plugin */
39
        $plugin = $this->getPlugin();
0 ignored issues
show
Unused Code introduced by
$plugin is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
40
41
        $settings = [
42
            'entityId' => Craft::$app->request->getRequiredParam('entityId'),
43
            'endpointPrefix' => Craft::$app->request->getRequiredParam('endpointPrefix'),
44
        ];
45
46
        Craft::$app->plugins->savePluginSettings(
47
            $this->getPlugin(),
48
            $settings
49
        );
50
        return $this->redirectToPostedUrl();
51
    }
52
53
    /**
54
     * @return bool
55
     * @throws \yii\web\ForbiddenHttpException
56
     */
57
    public function checkUpdateAccess(): bool
58
    {
59
        return $this->checkAdminAccess();
60
    }
61
}
62