| Total Complexity | 7 |
| Total Lines | 99 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class Summary implements \JsonSerializable |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var float |
||
| 11 | */ |
||
| 12 | protected $subtotal; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var float |
||
| 16 | */ |
||
| 17 | protected $shippingCost; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var float |
||
| 21 | */ |
||
| 22 | protected $totalTax; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @var float |
||
| 26 | */ |
||
| 27 | protected $totalCost; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Summary constructor. |
||
| 31 | * |
||
| 32 | 4 | * @param float $totalCost |
|
| 33 | */ |
||
| 34 | 4 | public function __construct(float $totalCost) |
|
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * @param float $totalCost |
||
| 41 | * |
||
| 42 | 4 | * @return \Kerox\Messenger\Model\Message\Attachment\Template\Receipt\Summary |
|
| 43 | */ |
||
| 44 | 4 | public static function create(float $totalCost): self |
|
| 45 | { |
||
| 46 | 4 | return new self($totalCost); |
|
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * @param float $subtotal |
||
| 51 | * |
||
| 52 | * @return Summary |
||
| 53 | */ |
||
| 54 | 4 | public function setSubtotal(float $subtotal): self |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * @param float $shippingCost |
||
| 63 | * |
||
| 64 | * @return Summary |
||
| 65 | */ |
||
| 66 | 4 | public function setShippingCost(float $shippingCost): self |
|
| 67 | { |
||
| 68 | 4 | $this->shippingCost = $shippingCost; |
|
| 69 | |||
| 70 | 4 | return $this; |
|
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @param float $totalTax |
||
| 75 | * |
||
| 76 | 4 | * @return Summary |
|
| 77 | */ |
||
| 78 | public function setTotalTax(float $totalTax): self |
||
| 79 | 4 | { |
|
| 80 | 4 | $this->totalTax = $totalTax; |
|
| 81 | 4 | ||
| 82 | 4 | return $this; |
|
| 83 | } |
||
| 84 | |||
| 85 | 4 | /** |
|
| 86 | * @return array |
||
| 87 | */ |
||
| 88 | public function toArray(): array |
||
| 89 | { |
||
| 90 | $array = [ |
||
| 91 | 'subtotal' => $this->subtotal, |
||
| 92 | 'shipping_cost' => $this->shippingCost, |
||
| 93 | 'total_tax' => $this->totalTax, |
||
| 94 | 'total_cost' => $this->totalCost, |
||
| 95 | ]; |
||
| 96 | |||
| 97 | return array_filter($array); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @return array |
||
| 102 | */ |
||
| 103 | public function jsonSerialize(): array |
||
| 106 | } |
||
| 107 | } |
||
| 108 |