Completed
Push — master ( 38d8a4...aea7cd )
by Dmitry
05:51
created

AbstractServerProduct::serializationMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * Server module for HiPanel.
4
 *
5
 * @link      https://github.com/hiqdev/hipanel-module-server
6
 * @package   hipanel-module-server
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hipanel\modules\server\cart;
12
13
use DateTime;
14
use hipanel\modules\finance\cart\AbstractCartPosition;
15
use hipanel\modules\server\models\Server;
16
use Yii;
17
18
/**
19
 * Class AbstractServerProduct is an abstract cart position for server produce.
20
 */
21
abstract class AbstractServerProduct extends AbstractCartPosition
22
{
23
    /**
24
     * @var Server
25
     */
26
    protected $_model;
27
28
    /** {@inheritdoc} */
29
    public function getIcon()
30
    {
31
        return '<i class="fa fa-server"></i>';
32
    }
33
34
    /** {@inheritdoc} */
35 View Code Duplication
    public function getQuantityOptions()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $result = [];
38
        foreach ([1, 3, 6, 12] as $n) {
39
            $date = (new DateTime())->add(new \DateInterval("P{$n}M"));
40
41
            $result[$n] = Yii::t('hipanel:server', '{n, plural, one{# month} other{# months}} till {date}', [
42
                'n' => $n,
43
                'date' => Yii::$app->formatter->asDate($date),
44
            ]);
45
        }
46
47
        return $result;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53
    protected function serializationMap()
54
    {
55
        $parent = parent::serializationMap();
56
        $parent['_model'] = $this->_model;
57
        return $parent;
58
    }
59
}
60