Test Failed
Push — master ( 6512d2...c62a67 )
by P.R.
02:58 queued 11s
created

CustomerAddress   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 70
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 2
1
<?php
2
declare(strict_types=1);
3
4
namespace SetBased\ClubCollect\Resource;
5
6
use SetBased\ClubCollect\ClubCollectApiClient;
7
use SetBased\ClubCollect\Exception\ClubCollectApiException;
8
use SetBased\ClubCollect\Helper\Cast;
9
10
/**
11
 * An entity representing the address of a customer.
12
 */
13
class CustomerAddress extends BaseResource
14
{
15
  //--------------------------------------------------------------------------------------------------------------------
16
  /**
17
   * @var string|null
18
   */
19
  public $address1;
20
21
  /**
22
   * @var string|null
23
   */
24
  public $address2;
25
26
  /**
27
   * @var string|null
28
   */
29
  public $city;
30
31
  /**
32
   * @var string|null
33
   */
34
  public $countryCode;
35
36
  /**
37
   * @var string|null
38
   */
39
  public $houseNumber;
40
41
  /**
42
   * @var string|null
43
   */
44
  public $locality;
45
46
  /**
47
   * @var string|null
48
   */
49
  public $state;
50
51
  /**
52
   * @var string|null
53
   */
54
  public $zipCode;
55
56
  //--------------------------------------------------------------------------------------------------------------------
57
  /**
58
   * Object constructor.
59
   *
60
   * @param ClubCollectApiClient $client   The API client.
61
   * @param array                $response The API response.
62
   *
63
   * @throws ClubCollectApiException
64
   */
65
  public function __construct(ClubCollectApiClient $client, array $response)
66
  {
67
    parent::__construct($client);
68
69
    try
70
    {
71
      $this->address1    = Cast::toOptString($response['address1']);
72
      $this->address2    = Cast::toOptString($response['address2']);
73
      $this->city        = Cast::toOptString($response['city']);
74
      $this->countryCode = Cast::toOptString($response['country_code']);
75
      $this->houseNumber = Cast::toOptString($response['house_number']);
76
      $this->locality    = Cast::toOptString($response['locality']);
77
      $this->state       = Cast::toOptString($response['state']);
78
      $this->zipCode     = Cast::toOptString($response['zipcode']);
79
    }
80
    catch (\Throwable $exception)
81
    {
82
      throw new ClubCollectApiException([$exception], 'Failed to create a customer address');
83
    }
84
  }
85
86
  //--------------------------------------------------------------------------------------------------------------------
87
}
88
89
//----------------------------------------------------------------------------------------------------------------------
90