| Total Complexity | 6 |
| Total Lines | 100 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | abstract class Driver implements DriverInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Invoice |
||
| 12 | * |
||
| 13 | * @var Invoice |
||
| 14 | */ |
||
| 15 | protected $invoice; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * Driver's settings |
||
| 19 | * |
||
| 20 | * @var |
||
| 21 | */ |
||
| 22 | protected $settings; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Driver constructor. |
||
| 26 | * |
||
| 27 | * Driver constructor. |
||
| 28 | * @param Invoice $invoice |
||
| 29 | * @param $settings |
||
| 30 | */ |
||
| 31 | abstract public function __construct(Invoice $invoice, $settings); |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Set payment amount. |
||
| 35 | * |
||
| 36 | * @param $amount |
||
| 37 | * @return $this |
||
| 38 | * @throws \Exception |
||
| 39 | */ |
||
| 40 | public function amount($amount) |
||
| 41 | { |
||
| 42 | $this->invoice->amount($amount); |
||
| 43 | |||
| 44 | return $this; |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * Set a piece of data to the details. |
||
| 49 | * |
||
| 50 | * @param $key |
||
| 51 | * @param $value|null |
||
| 52 | * @return $this|DriverInterface |
||
| 53 | */ |
||
| 54 | public function detail($key, $value = null) |
||
| 55 | { |
||
| 56 | $key = is_array($key) ? $key : [$key => $value]; |
||
| 57 | |||
| 58 | foreach ($key as $k => $v) { |
||
| 59 | $this->invoice->detail($key, $value); |
||
| 60 | } |
||
| 61 | |||
| 62 | return $this; |
||
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * Set invoice. |
||
| 67 | * |
||
| 68 | * @param Invoice $invoice |
||
| 69 | * @return $this |
||
| 70 | */ |
||
| 71 | public function invoice(Invoice $invoice) |
||
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Retrieve invoice. |
||
| 80 | * |
||
| 81 | * @return Invoice |
||
| 82 | */ |
||
| 83 | public function getInvoice() |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * Purchase the invoice |
||
| 90 | * |
||
| 91 | * @return mixed |
||
| 92 | */ |
||
| 93 | abstract public function purchase(); |
||
| 94 | |||
| 95 | /** |
||
| 96 | * Pay the invoice |
||
| 97 | * |
||
| 98 | * @return mixed |
||
| 99 | */ |
||
| 100 | abstract public function pay(); |
||
| 101 | |||
| 102 | /** |
||
| 103 | * Verify the payment |
||
| 104 | * |
||
| 105 | * @return mixed |
||
| 106 | */ |
||
| 107 | abstract public function verify(); |
||
| 108 | } |
||
| 109 |