Completed
Pull Request — master (#64)
by Rafael
02:06
created

Duplicate::toArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
1
<?php
2
3
namespace WeDevBr\Bankly\Types\Card;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
use WeDevBr\Bankly\Validators\Card\DuplicateCardValidator;
7
8
class Duplicate extends \stdClass implements Arrayable
9
{
10
    /** @var string */
11
    public $status;
12
13
    /** @var string */
14
    public $documentNumber;
15
16
    /** @var string */
17
    public $description;
18
19
    /** @var string */
20
    public $password;
21
22
    /** @var \WeDevBr\Bankly\Types\Card\Address */
23
    public $address;
24
25
    /**
26
     * This validate and return an array
27
     *
28
     * @return array
29
     */
30
    public function toArray(): array
31
    {
32
        $this->validate();
33
        if (!is_null($this->address)) {
34
            $this->address = $this->address->toArray();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->address->toArray() of type array is incompatible with the declared type object<WeDevBr\Bankly\Types\Card\Address> of property $address.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
35
        }
36
37
        return (array) $this;
38
    }
39
40
    /**
41
     * This function validate the data for duplicate card
42
     *
43
     * @return self
44
     */
45
    public function validate()
46
    {
47
        $validator = new DuplicateCardValidator($this);
48
        $validator->validate();
49
50
        return $this;
51
    }
52
}
53