Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 20 |
| Senh\Lib\Prices\CountDownHelper | |
0.00% |
0 / 1 |
|
0.00% |
0 / 4 |
20 | |
0.00% |
0 / 20 |
| __construct | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| getPrice1Html | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
| getPriceNHtml | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 7 |
|||
| getPriceHtmlRaw | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace Senh\Lib\Prices; | |
| class CountDownHelper | |
| { | |
| /** | |
| * @var PricesHelper; | |
| */ | |
| protected $pricesHelper; | |
| /** | |
| * CountDownHelper constructor. | |
| * @param PricesHelper $pricesHelper | |
| */ | |
| public function __construct(PricesHelper $pricesHelper) | |
| { | |
| $this->pricesHelper = $pricesHelper; | |
| } | |
| /** | |
| * @param int|string $productId | |
| * @param int $priceFactor | |
| * @param null $priceOverride | |
| */ | |
| public function getPrice1Html($productId, $priceFactor = 1) | |
| { | |
| $originalPrice = $this->pricesHelper->getCurrentVariantPrice1($productId, false) * $priceFactor; | |
| $reducedPrice = $this->pricesHelper->getCurrentVariantPrice1($productId, true) * $priceFactor; | |
| $originalFormattedPrice = $this->pricesHelper->formatPrice($originalPrice); | |
| $reducedFormattedPrice = $this->pricesHelper->formatPrice($reducedPrice); | |
| return $this->getPriceHtmlRaw($originalFormattedPrice, $reducedFormattedPrice); | |
| } | |
| /** | |
| * @param int|string $productId | |
| * @param int $priceFactor | |
| * @param null $priceOverride | |
| */ | |
| public function getPriceNHtml($productId, $priceFactor = 1) | |
| { | |
| $originalPrice = $this->pricesHelper->getCurrentVariantPriceN($productId, false) * $priceFactor; | |
| $reducedPrice = $this->pricesHelper->getCurrentVariantPriceN($productId, true) * $priceFactor; | |
| $originalFormattedPrice = $this->pricesHelper->formatPrice($originalPrice); | |
| $reducedFormattedPrice = $this->pricesHelper->formatPrice($reducedPrice); | |
| return $this->getPriceHtmlRaw($originalFormattedPrice, $reducedFormattedPrice); | |
| } | |
| /** | |
| * @param $price : cents | |
| * @param string $period : '1' or 'N' | |
| */ | |
| protected function getPriceHtmlRaw($originalPriceFormatted, $reducedPriceFormatted) | |
| { | |
| return "<span class=\"korting-countdown-price\" data-original-price='$originalPriceFormatted'>$reducedPriceFormatted</span>"; | |
| } | |
| } |