Passed
Push — master ( bfa63a...41a424 )
by Artem
01:47
created

PaymentMethod::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
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\Account;
13
14
use Linode\Entity;
15
16
/**
17
 * Payment Method Response Object.
18
 *
19
 * @property int        $id         The unique ID of this Payment Method.
20
 * @property string     $type       The type of Payment Method.
21
 * @property bool       $is_default Whether this Payment Method is the default method for automatically processing
22
 *                                  service charges.
23
 * @property string     $created    When the Payment Method was added to the Account.
24
 * @property CreditCard $data       Credit card information.
25
 */
26
class PaymentMethod extends Entity
27
{
28
    // Available fields.
29
    public const FIELD_ID         = 'id';
30
    public const FIELD_TYPE       = 'type';
31
    public const FIELD_IS_DEFAULT = 'is_default';
32
    public const FIELD_CREATED    = 'created';
33
    public const FIELD_DATA       = 'data';
34
35
    // `FIELD_TYPE` values.
36
    public const TYPE_CREDIT_CARD = 'credit_card';
37
    public const TYPE_GOOGLE_PAY  = 'google_pay';
38
39
    /**
40
     * @codeCoverageIgnore This method was autogenerated.
41
     */
42
    public function __get(string $name): mixed
43
    {
44
        return match ($name) {
45
            self::FIELD_DATA => new CreditCard($this->client, $this->data[$name]),
46
            default          => parent::__get($name),
47
        };
48
    }
49
}
50