Passed
Pull Request — master (#14)
by
unknown
02:47
created

CreateRefund   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 8
eloc 14
dl 0
loc 58
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A method() 0 3 1
A path() 0 3 1
A __construct() 0 13 6
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