Passed
Push — master ( 0456bd...25822b )
by Mihail
07:10
created

ActionYandexConnect   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 20
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A yandexConnect() 0 12 3
1
<?php
2
3
namespace Apps\Controller\Admin\Main;
4
5
6
use Apps\Model\Admin\Main\FormYandexConnect;
7
use Ffcms\Core\App;
8
use Ffcms\Core\Arch\View;
9
use Ffcms\Core\Network\Request;
10
use Ffcms\Core\Network\Response;
11
12
/**
13
 * Trait ActionYandexConnect
14
 * @package Apps\Controller\Admin\Main
15
 * @property Request $request
16
 * @property Response $response
17
 * @property View $view
18
 */
19
trait ActionYandexConnect
20
{
21
22
    /**
23
     * Connect yandex metrika and get token
24
     * @return string|null
25
     * @throws \Ffcms\Core\Exception\SyntaxException
26
     */
27
    public function yandexConnect(): ?string
28
    {
29
        $configs = App::$Properties->getAll('yandex');
30
31
        $model = new FormYandexConnect($configs);
0 ignored issues
show
Bug introduced by zenn
It seems like $configs can also be of type null; however, parameter $configs of Apps\Model\Admin\Main\Fo...xConnect::__construct() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

31
        $model = new FormYandexConnect(/** @scrutinizer ignore-type */ $configs);
Loading history...
32
        if ($model->send() && $model->validate()) {
33
            App::$Session->getFlashBag()->add('success', __('Application ID saved'));
34
            $model->make();
35
        }
36
37
        return $this->view->render('main/yandex_connect', [
38
            'model' => $model
39
        ]);
40
    }
41
}