Passed
Push — master ( 62dee2...4b8e5c )
by Dane
02:13
created

BulkCodeSwitchResponse::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
nc 2
nop 1
dl 0
loc 18
rs 9.9
c 1
b 0
f 0
1
<?php
2
3
namespace AcquiaCloudApi\Response;
4
5
use ArrayObject;
6
7
/**
8
 * @template-extends \ArrayObject<int, object>
9
 */
10
class BulkCodeSwitchResponse extends ArrayObject
11
{
12
    /**
13
     * @param array<object>|object|array<int,array<string,string>> $bulkCodeSwitch
14
     */
15
    public function __construct(array|object $bulkCodeSwitch)
16
    {
17
        if (is_array($bulkCodeSwitch)) {
0 ignored issues
show
introduced by
The condition is_array($bulkCodeSwitch) is always true.
Loading history...
18
            // Handle array of bulk code switches
19
            parent::__construct(
20
                array_map(
21
                    static function ($item) {
22
                        return (object) $item;
23
                    },
24
                    $bulkCodeSwitch
25
                ),
26
                self::ARRAY_AS_PROPS
27
            );
28
        } else {
29
            // Handle single bulk code switch object
30
            parent::__construct(
31
                [$bulkCodeSwitch],
32
                self::ARRAY_AS_PROPS
33
            );
34
        }
35
    }
36
}
37