Completed
Push — master ( d09259...594c85 )
by mahdi
02:18
created

Driver::detail()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 4
nop 2
dl 0
loc 9
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\InvoiceBuilder;
7
8
abstract class Driver implements DriverInterface
9
{
10
    /**
11
     * Invoice
12
     *
13
     * @var InvoiceBuilder
14
     */
15
    protected $invoice;
16
17
    /**
18
     * Driver constructor.
19
     *
20
     * Driver constructor.
21
     * @param InvoiceBuilder $invoice
22
     * @param $settings
23
     */
24
    abstract public function __construct(InvoiceBuilder $invoice, $settings);
25
26
    /**
27
     * Set payment amount.
28
     *
29
     * @param $amount
30
     * @return $this
31
     * @throws \Exception
32
     */
33
    public function amount($amount)
34
    {
35
        $this->invoice->amount($amount);
36
37
        return $this;
38
    }
39
40
    /**
41
     * Set a piece of data to the details.
42
     *
43
     * @param $key
44
     * @param null $value
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $value is correct as it would always require null to be passed?
Loading history...
45
     * @return $this
46
     */
47
    public function detail($key, $value = null)
48
    {
49
        $key = is_array($key) ? $key : [$key => $value];
50
51
        foreach ($key as $k => $v) {
52
            $this->invoice->detail($key, $value);
53
        }
54
55
        return $this;
56
    }
57
58
    public function setInvoice(InvoiceBuilder $invoice) {
59
        $this->invoice = $invoice;
60
61
        return $this;
62
    }
63
64
    public function getInvoice()
65
    {
66
        return $this->invoice;
67
    }
68
69
    /**
70
     * Purchase the invoice
71
     *
72
     * @return mixed
73
     */
74
    abstract public function purchase();
75
76
    /**
77
     * Pay the invoice
78
     *
79
     * @return mixed
80
     */
81
    abstract public function pay();
82
83
    /**
84
     * Verify the payment
85
     *
86
     * @return object
87
     */
88
    abstract public function verify();
89
}
90