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

CustomerPhone::__construct()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 6
nc 3
nop 2
dl 0
loc 12
rs 10
c 1
b 0
f 0
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 a phone number of a customer.
12
 */
13
class CustomerPhone extends BaseResource
14
{
15
  //--------------------------------------------------------------------------------------------------------------------
16
  /**
17
   * @var string|null
18
   */
19
  public $countryCode;
20
21
  /**
22
   * @var string|null
23
   */
24
  public $phoneNumber;
25
26
  //--------------------------------------------------------------------------------------------------------------------
27
  /**
28
   * Object constructor.
29
   *
30
   * @param ClubCollectApiClient $client   The API client.
31
   * @param array                $response The API response.
32
   *
33
   * @throws ClubCollectApiException
34
   */
35
  public function __construct(ClubCollectApiClient $client, array $response)
36
  {
37
    parent::__construct($client);
38
39
    try
40
    {
41
      $this->countryCode = Cast::toOptString($response['country_code']);
42
      $this->phoneNumber = Cast::toOptString($response['phone_number']);
43
    }
44
    catch (\Throwable $exception)
45
    {
46
      throw new ClubCollectApiException([$exception], 'Failed to create a customer phone number');
47
    }
48
  }
49
50
  //--------------------------------------------------------------------------------------------------------------------
51
}
52
53
//----------------------------------------------------------------------------------------------------------------------
54