Passed
Push — master ( 0676a7...01ab94 )
by Artem
11:54
created

SupportTicket::__get()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
c 0
b 0
f 0
rs 10
cc 2
nc 1
nop 1
1
<?php
2
3
// ---------------------------------------------------------------------
4
//
5
//  Copyright (C) 2018-2024 Artem Rodygin
6
//
7
//  You should have received a copy of the MIT License along with
8
//  this file. If not, see <https://opensource.org/licenses/MIT>.
9
//
10
// ---------------------------------------------------------------------
11
12
namespace Linode\Support;
13
14
use Linode\Entity;
15
use Linode\Linode\LinodeEntity;
16
use Linode\Support\Repository\SupportTicketReplyRepository;
17
18
/**
19
 * A Support Ticket opened on your Account.
20
 *
21
 * @property int                                   $id          The ID of the Support Ticket.
22
 * @property string                                $summary     The summary or title for this Ticket.
23
 * @property string                                $opened_by   The User who opened this Ticket.
24
 * @property string                                $opened      The date and time this Ticket was created.
25
 * @property string                                $description The full details of the issue or question.
26
 * @property null|LinodeEntity                     $entity      The entity this Ticket was opened for.
27
 * @property string                                $gravatar_id The Gravatar ID of the User who opened this Ticket.
28
 * @property string                                $status      The current status of this Ticket.
29
 * @property bool                                  $closable    Whether the Support Ticket may be closed.
30
 * @property null|string                           $updated_by  The User who last updated this Ticket.
31
 * @property string                                $updated     The date and time this Ticket was last updated.
32
 * @property null|string                           $closed      The date and time this Ticket was closed.
33
 * @property string[]                              $attachments A list of filenames representing attached files associated with this Ticket.
34
 * @property SupportTicketReplyRepositoryInterface $replies     Support ticket replies.
35
 */
36
class SupportTicket extends Entity
37
{
38
    // Available fields.
39
    public const FIELD_ID          = 'id';
40
    public const FIELD_SUMMARY     = 'summary';
41
    public const FIELD_OPENED_BY   = 'opened_by';
42
    public const FIELD_OPENED      = 'opened';
43
    public const FIELD_DESCRIPTION = 'description';
44
    public const FIELD_ENTITY      = 'entity';
45
    public const FIELD_GRAVATAR_ID = 'gravatar_id';
46
    public const FIELD_STATUS      = 'status';
47
    public const FIELD_CLOSABLE    = 'closable';
48
    public const FIELD_UPDATED_BY  = 'updated_by';
49
    public const FIELD_UPDATED     = 'updated';
50
    public const FIELD_CLOSED      = 'closed';
51
    public const FIELD_ATTACHMENTS = 'attachments';
52
53
    // Extra fields for POST/PUT requests.
54
    public const FIELD_DOMAIN_ID         = 'domain_id';
55
    public const FIELD_LINODE_ID         = 'linode_id';
56
    public const FIELD_LONGVIEWCLIENT_ID = 'longviewclient_id';
57
    public const FIELD_NODEBALANCER_ID   = 'nodebalancer_id';
58
    public const FIELD_VOLUME_ID         = 'volume_id';
59
60
    // `FIELD_STATUS` values.
61
    public const STATUS_CLOSED = 'closed';
62
    public const STATUS_NEW    = 'new';
63
    public const STATUS_OPEN   = 'open';
64
65
    /**
66
     * @codeCoverageIgnore This method was autogenerated.
67
     */
68
    public function __get(string $name): mixed
69
    {
70
        return match ($name) {
71
            self::FIELD_ENTITY => null === $this->data[$name] ? null : new LinodeEntity($this->client, $this->data[$name]),
72
            'replies'          => new SupportTicketReplyRepository($this->client, $this->id),
73
            default            => parent::__get($name),
74
        };
75
    }
76
}
77