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

BulkCodeSwitchResponse   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 18 2
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