for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* PHP Billing Library
*
* @link https://github.com/hiqdev/php-billing
* @package php-billing
* @license BSD-3-Clause
* @copyright Copyright (c) 2017-2020, HiQDev (http://hiqdev.com/)
*/
namespace hiqdev\php\billing\charge\modifiers\addons;
use DateInterval;
use DateTimeImmutable;
* Day period addon
* @author Dmytro Naumenko <[email protected]>
class DayPeriod extends Period
{
public function countPeriodsPassed(DateTimeImmutable $since, DateTimeImmutable $time): float
$diff = $time->diff($since);
return $diff->format('%r%a') / $this->value;
}
public function addTo(DateTimeImmutable $since): DateTimeImmutable
return $since->add(new DateInterval("P{$this->value}D"));
public function __toString(): string
return $this->value . ' day' . ($this->value > 1 ? 's' : '');