Company   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 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 an individual organisation.
12
 */
13
class Company 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 $brand;
30
31
  /**
32
   * Company ID, supplied by ClubCollect.
33
   *
34
   * @var string
35
   */
36
  public $companyId;
37
38
  /**
39
   * @var string
40
   */
41
  public $currency;
42
43
  /**
44
   * @var string
45
   */
46
  public $email;
47
48
  /**
49
   * @var string|null
50
   */
51
  public $houseNumber;
52
53
  /**
54
   * @var string
55
   */
56
  public $locale;
57
58
  /**
59
   * @var string
60
   */
61
  public $name;
62
63
  /**
64
   * @var string|null
65
   */
66
  public $zipCode;
67
68
  //--------------------------------------------------------------------------------------------------------------------
69
  /**
70
   * Object constructor.
71
   *
72
   * @param ClubCollectApiClient $client   The API client.
73
   * @param array                $response The API response.
74
   *
75
   * @throws ClubCollectApiException
76
   */
77
  public function __construct(ClubCollectApiClient $client, array $response)
78
  {
79
    parent::__construct($client);
80
81
    try
82
    {
83
      $this->address1    = Cast::toOptString($response['address1']);
84
      $this->address2    = Cast::toOptString($response['address2']);
85
      $this->brand       = Cast::toOptString($response['brand']);
86
      $this->companyId   = Cast::toManString($response['company_id']);
87
      $this->currency    = Cast::toManString($response['currency']);
88
      $this->email       = Cast::toManString($response['email']);
89
      $this->houseNumber = Cast::toOptString($response['house_number']);
90
      $this->locale      = Cast::toManString($response['locale']);
91
      $this->name        = Cast::toManString($response['name']);
92
      $this->zipCode     = Cast::toOptString($response['zipcode']);
93
    }
94
    catch (\Throwable $exception)
95
    {
96
      throw new ClubCollectApiException([$exception], 'Failed to create a company');
97
    }
98
  }
99
100
  //--------------------------------------------------------------------------------------------------------------------
101
}
102
103
//----------------------------------------------------------------------------------------------------------------------
104