| 1 | <?php |
||
| 22 | class Plan implements PlanInterface |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * @var int |
||
| 26 | */ |
||
| 27 | protected $id; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * @var string |
||
| 31 | */ |
||
| 32 | protected $name; |
||
| 33 | |||
| 34 | /** |
||
| 35 | * @var Plan|null |
||
| 36 | * XXX not sure to implement |
||
| 37 | */ |
||
| 38 | protected $parent; |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @var CustomerInterface |
||
| 42 | */ |
||
| 43 | protected $seller; |
||
| 44 | |||
| 45 | /** |
||
| 46 | * @var PriceInterface[] |
||
| 47 | */ |
||
| 48 | protected $prices = []; |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @param PriceInterface[] $prices |
||
| 52 | */ |
||
| 53 | 1 | public function __construct( |
|
| 64 | |||
| 65 | /** |
||
| 66 | * @return PriceInterface[] |
||
| 67 | */ |
||
| 68 | public function getPrices() |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Calculate charges for given action. |
||
| 75 | * @param ActionInterface $action |
||
| 76 | * @return Charge[] |
||
| 77 | */ |
||
| 78 | 3 | public function calculateCharges(ActionInterface $action) |
|
| 79 | { |
||
| 80 | 3 | $charges = []; |
|
| 81 | 3 | foreach ($this->prices as $price) { |
|
| 82 | 3 | $charge = $action->calculateCharge($price); |
|
| 83 | 3 | if ($charge !== null) { |
|
| 84 | 3 | $charges[] = $charge; |
|
| 85 | 3 | } |
|
| 86 | 3 | } |
|
| 87 | |||
| 88 | 3 | return $charges; |
|
| 89 | } |
||
| 90 | |||
| 91 | public function jsonSerialize() |
||
| 95 | } |
||
| 96 |