AuthorizePaymentRequest::isValid()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 3
nc 3
nop 0
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
18
/**
19
 * This class represents Authorize RequestInterface Entity
20
 *
21
 * @method string    getCustomerId()
22
 * @method string    getInvoiceId()
23
 * @method \DateTime|false getInvoiceDate()
24
 * @method self      setCustomerId(string $id)
25
 * @method self      setInvoiceId(string $id)
26
 */
27
class AuthorizePaymentRequest extends RequestEntity
28
{
29
    /** @var string $customerId */
30
    protected $customerId;
31
32
    /** @var string $invoiceId */
33
    protected $invoiceId;
34
35
    /** @var \DateTime|bool $invoiceDate */
36
    protected $invoiceDate;
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function isValid()
42
    {
43
        return parent::isValid() &&
44
            (!$this->invoiceDate || $this->invoiceDate instanceof \DateTime)
45
        ;
46
    }
47
48
    /**
49
     * Sets Invoice Date
50
     *
51
     * @param string $invoiceDate
52
     *
53
     * @return $this
54
     */
55
    public function setInvoiceDate($invoiceDate)
56
    {
57
        if ($invoiceDate) {
58
            $this->invoiceDate = date_create($invoiceDate);
59
        }
60
61
        return $this;
62
    }
63
}
64