-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathAction.php
46 lines (41 loc) · 1.08 KB
/
Action.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?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\action;
use hiqdev\php\billing\price\PriceInterface;
/**
* Simple Action.
* It is applicable when price is applicable.
* But it can be different see Coupon.
*
* @author Andrii Vasyliev <[email protected]>
*/
class Action extends AbstractAction
{
/**
* {@inheritdoc}
*/
public function isApplicable(PriceInterface $price): bool
{
return $this->saleOccurred() && $price->isApplicable($this);
}
/**
* // TODO: think about moving to Sale::isOccurred()
*
* @throws \Exception
* @return bool whether Sale that belongs to current Action occurs in current month or earlier
*/
private function saleOccurred(): bool
{
if ($this->sale === null) {
return true;
}
return $this->sale->getTime() < $this->getTime()->modify('first day of next month 00:00');
}
}