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.
Passed
Push — master ( d5e237...a4054c )
by Alexander
20:51 queued 10:03
created

ContentBlock::decorate()   C

Complexity

Conditions 7
Paths 9

Size

Total Lines 32
Code Lines 22

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 32
rs 6.7272
cc 7
eloc 22
nc 9
nop 3
1
<?php
2
3
namespace app\modules\core\decorators;
4
5
use app;
6
7
use Yii;
8
use app\modules\core\helpers\ContentBlockHelper;
9
use yii\caching\TagDependency;
10
use devgroup\TagDependencyHelper\ActiveRecordHelper;
11
12
class ContentBlock extends PreDecorator
13
{
14
    /**
15
     * Handle decoration
16
     * @param \yii\base\Controller $controller
17
     * @param string $viewFile
18
     * @param array $params
19
     * @return void
20
     */
21
    public function decorate($controller, $viewFile, $params)
22
    {
23
        if (!Yii::$app->getModule("backend")->isBackend() && !empty($params['model'])) {
24
            $baseContentKey = get_class($params['model'])
25
                . ':'
26
                . (isset($params['model']->id) ? $params['model']->id : '')
27
                . ':';
28
            $view = $controller->view;
29
            $dependency = new TagDependency([
30
                'tags' => [
31
                    ActiveRecordHelper::getCommonTag(app\modules\core\models\ContentBlock::className()),
32
                    ActiveRecordHelper::getCommonTag(get_class($params['model']))
33
                ]
34
            ]);
35
            $view->title = $this->processChunks(
36
                $view->title,
37
                $baseContentKey . "title",
38
                $dependency
39
            );
40
            if ($view->blocks !== null) {
41
                foreach ($view->blocks as $blockName => &$blockContent) {
42
                    if (!empty($blockContent)) {
43
                        $blockContent = $this->processChunks(
44
                            $blockContent,
45
                            $baseContentKey . $blockName,
46
                            $dependency
47
                        );
48
                    }
49
                }
50
            }
51
        }
52
    }
53
54
    /**
55
     * @param $content
56
     * @param $contentKey
57
     * @param $dependency
58
     * @return string
59
     */
60
    private function processChunks($content, $contentKey, $dependency)
61
    {
62
        return ContentBlockHelper::compileContentString(
63
            $content,
64
            $contentKey,
65
            $dependency
66
        );
67
    }
68
}
69