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.
Test Setup Failed
Push — google-feed ( 14c86b...39b9ea )
by
unknown
10:22
created

DefaultHandler::processData()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 39
Code Lines 29

Duplication

Lines 11
Ratio 28.21 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 11
loc 39
rs 8.439
cc 5
eloc 29
nc 8
nop 1
1
<?php
2
3
namespace app\modules\shop\components\GoogleMerchants;
4
5
6
use app\modules\shop\helpers\CurrencyHelper;
7
use yii\helpers\Url;
8
9
10
class DefaultHandler implements ModificationDataInterface
11
{
12
    public static function processData(ModificationDataEvent $event)
13
    {
14
        $url = htmlspecialchars(Url::toRoute(['@product', 'model' => $event->model]));
15
        $image = htmlspecialchars($event->model->image->getOriginalUrl());
16 View Code Duplication
        if ($event->model->unlimited_count === 1) {
17
            $inStock = 'in stock';
18
        } else {
19
            $inStock = 'out of stock';
20
            foreach ($event->model->getWarehousesState() as $warehouse) {
21
                if ($warehouse->in_warehouse > 0) {
22
                    $inStock = 'in stock';
23
                    break;
24
                }
25
            }
26
        }
27
28
        $price = number_format(
29
                CurrencyHelper::convertCurrencies($event->model->price, $event->model->currency,
30
                    $event->sender->mainCurrency),
31
                2,
32
                '.',
33
                ''
34
            ) . ' ' . $event->sender->mainCurrency->iso_code;
35
36
        $event->data = [
37
            'title' => $event->model->name,
38
            'description' => $event->model->announce,
39
            'link' => $event->sender->host . $url,
40
            'g:id' => $event->model->id,
41
            'g:image_link' => $image,
42
            'g:condition' => 'new',
43
            'g:availability' => $inStock,
44
            'g:price' => $price
45
        ];
46
        if ($event->model->parent_id !== 0) {
47
            $event->data['g:item_group_id'] = $event->model->parent_id;
48
        }
49
50
    }
51
}