Passed
Pull Request — master (#43)
by
unknown
01:45
created

Setting   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
1
<?php
2
3
namespace CommerceGuys\AuthNet\DataTypes;
4
5
/**
6
 * Represents a single setting used in HostedPaymentSettings.
7
 *
8
 * @see \CommerceGuys\AuthNet\DataTypes\HostedPaymentSettings
9
 */
10
class Setting extends BaseDataType
11
{
12
13
    protected $propertyMap = [
14
        'settingName',
15
        'settingValue',
16
    ];
17
18
    /**
19
     * Constructs a new Setting object.
20
     *
21
     * @param string $name
22
     *   The name of the setting (e.g., hostedPaymentReturnOptions).
23
     * @param mixed $value
24
     *   The value, which will be JSON-encoded if it's an array.
25
     */
26
    public function __construct(string $name, $value)
27
    {
28
        parent::__construct();
29
        $this->properties['settingName'] = $name;
30
        // Encode the value.
31
        if (is_array($value)) {
32
            $value = json_encode($value, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT);
33
        }
34
        $this->properties['settingValue'] = $value;
35
    }
36
37
}
38