PaymentMethod::account_number()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace OceanApplications\Postmen\Models;
4
5
class PaymentMethod extends Model
6
{
7
    public $type = 'account';
8
    public $account_number;
9
    public $postal_code;
10
    public $country;
11
12
    /**
13
     * @param string $value
14
     *
15
     * @return $this
16
     */
17
    public function account_number($value)
18
    {
19
        $this->account_number = strval($value);
20
21
        return $this;
22
    }
23
24
    /**
25
     * @param string $value
26
     *
27
     * @return $this
28
     */
29
    public function postal_code($value)
30
    {
31
        $this->postal_code = strval($value);
32
33
        return $this;
34
    }
35
36
    /**
37
     * @param string $value
38
     *
39
     * @throws \Exception
40
     *
41
     * @return $this
42
     */
43 View Code Duplication
    public function country($value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        if (in_array($value, $this->acceptedCountries)) {
46
            $this->country = $value;
47
        } else {
48
            $error = 'Country code invalid or not serviceable';
49
            throw new \Exception($error);
50
        }
51
52
        return $this;
53
    }
54
}
55