ListPaymentsRequest::setDate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * PHP version 5.4 and 8
5
 *
6
 * @category  RequestEntity
7
 * @package   Payever\Payments
8
 * @author    payever GmbH <[email protected]>
9
 * @copyright 2017-2021 payever GmbH
10
 * @license   MIT <https://opensource.org/licenses/MIT>
11
 * @link      https://docs.payever.org/shopsystems/api/getting-started
12
 */
13
14
namespace Payever\ExternalIntegration\Payments\Http\RequestEntity;
15
16
use Payever\ExternalIntegration\Core\Http\RequestEntity;
17
use Payever\ExternalIntegration\Payments\Enum\Status;
18
19
/**
20
 * This class represents List Payments RequestInterface Entity
21
 *
22
 * @method string     getAccessToken()
23
 * @method string     getPaymentMethod()
24
 * @method \DateTime|false  getDate()
25
 * @method string     getCurrency()
26
 * @method string     getState()
27
 * @method int|string getLimit()
28
 * @method self       setAccessToken(string $token)
29
 * @method self       setPaymentMethod(string $method)
30
 * @method self       setCurrency(string $currency)
31
 * @method self       setState(string $state)
32
 * @method self       setLimit(int|string $limit)
33
 *
34
 * @SuppressWarnings(PHPMD.StaticAccess)
35
 */
36
class ListPaymentsRequest extends RequestEntity
37
{
38
    /** @var string $accessToken */
39
    protected $accessToken;
40
41
    /** @var string $paymentMethod */
42
    protected $paymentMethod;
43
44
    /** @var \DateTime|bool $date */
45
    protected $date;
46
47
    /** @var string $currency */
48
    protected $currency;
49
50
    /** @var string $state */
51
    protected $state;
52
53
    /** @var int|string $limit */
54
    protected $limit;
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    public function isValid()
60
    {
61
        return parent::isValid() &&
62
            (!$this->date || $this->date instanceof \DateTime) &&
63
            (!$this->state || in_array($this->state, Status::enum())) &&
64
            (!$this->limit || is_integer($this->limit))
65
        ;
66
    }
67
68
    /**
69
     * Sets Date
70
     *
71
     * @param string $date
72
     */
73
    public function setDate($date)
74
    {
75
        if ($date) {
76
            $this->date = date_create($date);
77
        }
78
79
        return $this;
80
    }
81
}
82