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.
Completed
Push — master ( 8bc62f...4296d1 )
by Alexsandr
05:11
created

DefaultController::actionIndex()   B

Complexity

Conditions 6
Paths 11

Size

Total Lines 42

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 42

Importance

Changes 0
Metric Value
dl 0
loc 42
ccs 0
cts 21
cp 0
rs 8.6257
c 0
b 0
f 0
cc 6
nc 11
nop 0
crap 42
1
<?php
2
/**
3
 * @link https://github.com/corpsepk/yii2-yandex-market-yml
4
 * @copyright Copyright (c) 2016 Corpsepk
5
 * @license http://opensource.org/licenses/MIT
6
 */
7
8
namespace corpsepk\yml\controllers;
9
10
use Yii;
11
use yii\web\Controller;
12
use corpsepk\yml\YandexMarketYml;
13
14
/**
15
 * @author Corpsepk
16
 * @package corpsepk\yml
17
 */
18
class DefaultController extends Controller
19
{
20
    public function actionIndex()
21
    {
22
        /**
23
         * @var YandexMarketYml $module
24
         */
25
        $module = $this->module;
26
27
        $ymlData = $module->cacheProvider->get($module->cacheKey);
28
29
        if (!$ymlData) {
30
            $shop = $module->buildShop();
31
            $shop->validate();
32
33
            if ($shop->hasErrors()) {
34
                $module->logErrors($shop);
35
36
                if (YII_ENV_DEV) {
37
                    // Render errors in `dev` environment
38
                    return $this->render('errors', ['shop' => $shop]);
39
                }
40
            }
41
42
            $ymlData = $module->buildYml($shop);
43
44
            // Build cache if no errors
45
            if (!$shop->hasErrors()) {
46
                $module->cacheProvider->set($module->cacheKey, $ymlData, $module->cacheExpire);
47
            }
48
        }
49
50
        Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
51
        $headers = Yii::$app->response->headers;
52
        $headers->add('Content-Type', 'application/xml');
53
54
        if ($module->enableGzip) {
55
            $ymlData = gzencode($ymlData);
56
            $headers->add('Content-Encoding', 'gzip');
57
            $headers->add('Content-Length', strlen($ymlData));
58
        }
59
60
        return $ymlData;
61
    }
62
}
63