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

CustomerEmail::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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