Passed
Branch master (9ba99c)
by mahdi
03:23 queued 01:28
created

Driver::invoice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Shetabit\Payment\Abstracts;
4
5
use Shetabit\Payment\Contracts\DriverInterface;
6
use Shetabit\Payment\Invoice;
7
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)
72
    {
73
        $this->invoice = $invoice;
74
75
        return $this;
76
    }
77
78
    /**
79
     * Retrieve invoice.
80
     *
81
     * @return Invoice
82
     */
83
    public function getInvoice()
84
    {
85
        return $this->invoice;
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