CreateRefund::__construct()   A
last analyzed

Complexity

Conditions 6
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 13
rs 9.2222
cc 6
nc 4
nop 2
1
<?php
2
3
namespace Evilnet\Dotpay\DotpayApi\Requests;
4
5
use Evilnet\Dotpay\DotpayApi\Contracts\IRequest;
6
use Evilnet\Dotpay\Exceptions\RequestIntegrityException;
7
8
/**
9
 * Class CreateRefund
10
 * @package Evilnet\Dotpay\DotpayApi\Requests
11
 */
12
class CreateRefund extends AbstractRequest implements IRequest
13
{
14
    /**
15
     * @var
16
     */
17
    protected $amount;
18
19
    /**
20
     * @var
21
     */
22
    protected $description;
23
24
    /**
25
     * @var
26
     */
27
    protected $control;
28
29
    /**
30
     * @var
31
     */
32
    protected $operation_number;
33
34
    /**
35
     * CreateRefund constructor.
36
     * @param $operation_number
37
     * @param $data
38
     * @throws RequestIntegrityException
39
     */
40
    public function __construct($operation_number, $data)
41
    {
42
        if(!$operation_number){
43
            throw new RequestIntegrityException("Operation number is not set");
44
        }
45
46
        $this->operation_number = $operation_number;
47
48
        foreach ($data as $key => $value) {
49
            if(!$value || is_numeric($value) && $value <= 0){
50
                throw new RequestIntegrityException();
51
            }
52
            $this->$key = $value;
53
        }
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function method()
60
    {
61
        return 'POST';
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function path()
68
    {
69
        return 'api/v1/payments/'.$this->operation_number.'/refund/';
70
    }
71
}
72