for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace hiqdev\billing\hiapi\charge;
use hiqdev\billing\hiapi\type\TypeSemantics;
use hiqdev\php\billing\bill\BillInterface;
use hiqdev\php\billing\charge\GeneralizerInterface;
use hiqdev\php\units\QuantityInterface;
/**
* Class Aggregator
*
* @author Dmytro Naumenko <[email protected]>
*/
class Aggregator extends \hiqdev\php\billing\charge\Aggregator
{
* @var TypeSemantics
private $typeSemantics;
public function __construct(GeneralizerInterface $generalizer, TypeSemantics $typeSemantics)
parent::__construct($generalizer);
$this->typeSemantics = $typeSemantics;
}
protected function aggregateQuantity(BillInterface $first, BillInterface $other): QuantityInterface
$billType = $first->getType();
if ($this->typeSemantics->isMonthly($billType)) {
return $first->getQuantity();
return $first->getQuantity()->add($other->getQuantity());