Test Setup Failed
Pull Request — master (#20)
by
unknown
02:00
created

Address   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A setAddressType() 0 8 2
1
<?php
2
3
namespace Scriptotek\Alma\Users;
4
5
use Scriptotek\Alma\Model\SettableModel;
6
7
class Address extends SettableModel
8
{
9
    /**
10
     * Set the type of this address
11
     * Possible values are listed in the 'UserAddressTypes' code table.
12
     *
13
     * @param string $address_type The address type
14
     * @param string $description The description of this address type
15
     */
16
    public function setAddressType($address_type, $description = null)
17
    {
18
        $addressTypeObj = ['value' => $address_type];
19
        if ($description) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $description of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
20
            $addressTypeObj['desc'] = $description;
21
        }
22
        $this->data->address_type = [(object) $addressTypeObj];
23
    }
24
}
25