Passed
Push — master ( 302660...3652f8 )
by payever
04:19 queued 01:32
created

CreatePaymentResponse::isValid()   A

Complexity

Conditions 6
Paths 10

Size

Total Lines 5
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 5
rs 9.2222
cc 6
nc 10
nop 0
1
<?php
2
3
/**
4
 * PHP version 5.4 and 8
5
 *
6
 * @category  ResponseEntity
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\ResponseEntity;
15
16
use Payever\ExternalIntegration\Core\Http\MessageEntity\CallEntity;
17
use Payever\ExternalIntegration\Core\Http\MessageEntity\ResultEntity;
18
use Payever\ExternalIntegration\Core\Http\ResponseEntity;
19
use Payever\ExternalIntegration\Payments\Http\MessageEntity\CreatePaymentCallEntity;
20
21
/**
22
 * This class represents Create Payment ResponseInterface Entity
23
 *
24
 * @method string getRedirectUrl()
25
 * @method self   setRedirectUrl(string $url)
26
 */
27
class CreatePaymentResponse extends ResponseEntity
28
{
29
    /** @var string $redirectUrl */
30
    protected $redirectUrl;
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getRequired()
36
    {
37
        return [
38
            'call',
39
            'redirect_url',
40
        ];
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function isValid()
47
    {
48
        return parent::isValid() &&
49
            ($this->call   instanceof CallEntity   && $this->call->isValid()) &&
50
            ($this->result instanceof ResultEntity && $this->result->isValid() || !$this->result)
51
        ;
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57
    public function setCall($call)
58
    {
59
        $this->call = new CreatePaymentCallEntity($call);
60
    }
61
}
62