@@ 15-49 (lines=35) @@ | ||
12 | ||
13 | use Yii; |
|
14 | ||
15 | class HddResourceDecorator extends AbstractServerResourceDecorator |
|
16 | { |
|
17 | public function displayTitle() |
|
18 | { |
|
19 | return Yii::t('hipanel:server:order', 'SSD'); |
|
20 | } |
|
21 | ||
22 | public function displayPrepaidAmount() |
|
23 | { |
|
24 | return Yii::t('yii', '{nFormatted} GB', ['nFormatted' => $this->getPrepaidQuantity()]); // Gb |
|
25 | } |
|
26 | ||
27 | public function getOverusePrice() |
|
28 | { |
|
29 | return 0.2; // TODO: move to config |
|
30 | } |
|
31 | ||
32 | public function getPrepaidQuantity() |
|
33 | { |
|
34 | $part = $this->resource->part; |
|
35 | preg_match('/((\d{1,5}) GB)$/i', $part->partno, $matches); |
|
36 | ||
37 | return (int)$matches[2]; |
|
38 | } |
|
39 | ||
40 | public function displayUnit() |
|
41 | { |
|
42 | return Yii::t('hipanel', 'GB'); |
|
43 | } |
|
44 | ||
45 | public function toUnit(): string |
|
46 | { |
|
47 | return 'gb'; |
|
48 | } |
|
49 | } |
|
50 |
@@ 15-49 (lines=35) @@ | ||
12 | ||
13 | use Yii; |
|
14 | ||
15 | class RamResourceDecorator extends AbstractServerResourceDecorator |
|
16 | { |
|
17 | public function displayTitle() |
|
18 | { |
|
19 | return Yii::t('hipanel:server:order', 'RAM'); |
|
20 | } |
|
21 | ||
22 | public function getPrepaidQuantity() |
|
23 | { |
|
24 | $part = $this->resource->part; |
|
25 | preg_match('/((\d{1,5}) MB)$/i', $part->partno, $matches); |
|
26 | ||
27 | return $matches[2] / 1024; |
|
28 | } |
|
29 | ||
30 | public function getOverusePrice() |
|
31 | { |
|
32 | return 4; // TODO: move to config |
|
33 | } |
|
34 | ||
35 | public function displayUnit() |
|
36 | { |
|
37 | return Yii::t('hipanel', 'GB'); |
|
38 | } |
|
39 | ||
40 | public function toUnit(): string |
|
41 | { |
|
42 | return 'gb'; |
|
43 | } |
|
44 | ||
45 | public function displayPrepaidAmount() |
|
46 | { |
|
47 | return Yii::t('yii', '{nFormatted} GB', ['nFormatted' => $this->getPrepaidQuantity()]); |
|
48 | } |
|
49 | } |
|
50 |