| Total Complexity | 4 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 22 | abstract class AbstractServerProduct extends AbstractCartPosition implements DontIncrementQuantityWhenAlreadyInCart |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var Server |
||
| 26 | */ |
||
| 27 | protected $_model; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Number of months for which the server is purchased |
||
| 31 | * @var array |
||
| 32 | */ |
||
| 33 | protected $duration = [1, 3, 6, 12]; |
||
| 34 | |||
| 35 | /** {@inheritdoc} */ |
||
| 36 | public function getIcon() |
||
| 39 | } |
||
| 40 | |||
| 41 | /** {@inheritdoc} */ |
||
| 42 | public function getQuantityOptions() |
||
| 43 | { |
||
| 44 | $result = []; |
||
| 45 | foreach ($this->duration as $n) { |
||
| 46 | $date = (new DateTime())->add(new \DateInterval("P{$n}M")); |
||
| 47 | |||
| 48 | $result[$n] = Yii::t('hipanel:server', '{n, plural, one{# month} other{# months}} till {date}', [ |
||
| 49 | 'n' => $n, |
||
| 50 | 'date' => Yii::$app->formatter->asDate($date), |
||
| 51 | ]); |
||
| 52 | } |
||
| 53 | |||
| 54 | return $result; |
||
| 55 | } |
||
| 56 | |||
| 57 | /** |
||
| 58 | * {@inheritdoc} |
||
| 59 | */ |
||
| 60 | protected function serializationMap() |
||
| 66 | } |
||
| 67 | } |
||
| 68 |