GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Arrayable::toArrayHyphen()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 9
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 14
rs 9.6111
1
<?php
2
3
namespace Soheilrt\AdobeConnectClient\Client\Traits;
4
5
use Soheilrt\AdobeConnectClient\Client\Helpers\StringCaseTransform as SCT;
6
use Soheilrt\AdobeConnectClient\Client\Helpers\ValueTransform as VT;
7
8
/**
9
 * Override the methods to turn into a valid ArrayableInterface.
10
 */
11
trait Arrayable
12
{
13
    /**
14
     * Retrieves all not null attributes in an associative array.
15
     *
16
     * The keys in hash style: Ex: is-member
17
     * The values as string
18
     *
19
     * @param bool $trimNull remove null values from array
20
     *
21
     * @return string[][]
22
     */
23
    public function toArray($trimNull = true): array
24
    {
25
        if (isset($this->attributes) && is_array($this->attributes)) {
26
            return $this->toArrayHyphen($this->attributes, $trimNull);
27
        }
28
29
        return $this->toArrayHyphen($this, $trimNull);
30
    }
31
32
    private function toArrayHyphen($array, $trimNull): array
33
    {
34
        $hyphen_array = [];
35
        foreach ($array as $key => $value) {
36
            if ($trimNull && !isset($value)) {
37
                continue;
38
            } elseif (is_array($value)) {
39
                $hyphen_array[SCT::toHyphen($key)] = $this->toArrayHyphen($value, $trimNull);
40
            } else {
41
                $hyphen_array[SCT::toHyphen($key)] = VT::toString($value);
42
            }
43
        }
44
45
        return $hyphen_array;
46
    }
47
}
48