Passed
Pull Request — master (#507)
by
unknown
04:15 queued 01:58
created

BulkCodeSwitchResponse::getMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace AcquiaCloudApi\Response;
4
5
use ArrayObject;
6
7
class BulkCodeSwitchResponse extends ArrayObject
8
{
9
    /**
10
     * @param array<object>|object $bulkCodeSwitch
11
     */
12
    public function __construct($bulkCodeSwitch)
13
    {
14
        if (is_array($bulkCodeSwitch)) {
15
            // Handle array of bulk code switches
16
            parent::__construct(
17
                array_map(
18
                    static function ($item) {
19
                        return (object) $item;
20
                    },
21
                    $bulkCodeSwitch
22
                ),
23
                self::ARRAY_AS_PROPS
24
            );
25
        } else {
26
            // Handle single bulk code switch object
27
            parent::__construct(
28
                [$bulkCodeSwitch],
29
                self::ARRAY_AS_PROPS
30
            );
31
        }
32
    }
33
34
    /**
35
     * Get the bulk code switch ID.
36
     */
37
    public function getId(): ?string
38
    {
39
        $first = $this[0] ?? null;
40
        return $first?->id ?? null;
41
    }
42
43
    /**
44
     * Get the codebase ID.
45
     */
46
    public function getCodebaseId(): ?string
47
    {
48
        $first = $this[0] ?? null;
49
        return $first?->codebase_id ?? null;
50
    }
51
52
    /**
53
     * Get the reference.
54
     */
55
    public function getReference(): ?string
56
    {
57
        $first = $this[0] ?? null;
58
        return $first?->reference ?? null;
59
    }
60
61
    /**
62
     * Get the status.
63
     */
64
    public function getStatus(): ?string
65
    {
66
        $first = $this[0] ?? null;
67
        return $first?->status ?? null;
68
    }
69
70
    /**
71
     * Get the created timestamp.
72
     */
73
    public function getCreatedAt(): ?string
74
    {
75
        $first = $this[0] ?? null;
76
        return $first?->created_at ?? null;
77
    }
78
79
    /**
80
     * Get the message.
81
     */
82
    public function getMessage(): ?string
83
    {
84
        $first = $this[0] ?? null;
85
        return $first?->message ?? null;
86
    }
87
}
88