Completed
Pull Request — master (#64)
by Rafael
01:36
created

Duplicate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 45
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 9 2
A validate() 0 7 1
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 ($this->address instanceof Address) {
34
            $this->address = $this->address;
35
        }
36
37
        return json_decode(json_encode($this), true);
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