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

Message   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 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 a message.
12
 */
13
class Message extends BaseResource
14
{
15
  //--------------------------------------------------------------------------------------------------------------------
16
  /**
17
   * @var \DateTime
18
   */
19
  public $date;
20
21
  /**
22
   * @var string
23
   */
24
  public $description;
25
26
  /**
27
   * @var string
28
   */
29
  public $messageId;
30
31
  /**
32
   * @var string
33
   */
34
  public $type;
35
36
  //--------------------------------------------------------------------------------------------------------------------
37
  /**
38
   * Object constructor.
39
   *
40
   * @param ClubCollectApiClient $client   The API client.
41
   * @param array                $response The API response.
42
   *
43
   * @throws ClubCollectApiException
44
   */
45
  public function __construct(ClubCollectApiClient $client, array $response)
46
  {
47
    parent::__construct($client);
48
49
    try
50
    {
51
      $this->date        = Cast::toManDateTime($response['date']);
52
      $this->description = Cast::toManString($response['description']);
53
      $this->messageId   = Cast::toManString($response['message_id']);
54
      $this->type        = Cast::toManString($response['type']);
55
    }
56
    catch (\Throwable $exception)
57
    {
58
      throw new ClubCollectApiException([$exception], 'Failed to create a message');
59
    }
60
  }
61
62
  //--------------------------------------------------------------------------------------------------------------------
63
}
64
65
//----------------------------------------------------------------------------------------------------------------------
66