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.

ArrayResponse   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 42.86%

Importance

Changes 0
Metric Value
wmc 5
eloc 10
c 0
b 0
f 0
dl 0
loc 47
ccs 6
cts 14
cp 0.4286
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponseName() 0 3 1
A __construct() 0 4 1
A __isset() 0 5 1
A __get() 0 5 1
A transformPropertyName() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pheanstalk\Response;
6
7
use Pheanstalk\Contract\ResponseInterface;
8
9
/**
10
 * A response with an ArrayObject interface to key => value data.
11
 */
12
class ArrayResponse extends \ArrayObject implements ResponseInterface
13
{
14
    private $name;
15
16
    /**
17
     * @param string $name
18
     * @param array  $data
19
     */
20 54
    public function __construct(string $name, array $data)
21
    {
22 54
        $this->name = $name;
23 54
        parent::__construct($data);
24 54
    }
25
26 45
    public function getResponseName(): string
27
    {
28 45
        return $this->name;
29
    }
30
31
    /**
32
     * Object property access to ArrayObject data.
33
     */
34
    public function __get($property)
35
    {
36
        $key = $this->transformPropertyName($property);
37
38
        return $this[$key] ?? null;
39
    }
40
41
    /**
42
     * Object property access to ArrayObject data.
43
     */
44
    public function __isset($property)
45
    {
46
        $key = $this->transformPropertyName($property);
47
48
        return isset($this[$key]);
49
    }
50
51
    // ----------------------------------------
52
53
    /**
54
     * Tranform underscored property name to hyphenated array key.
55
     */
56
    private function transformPropertyName(string $propertyName): string
57
    {
58
        return str_replace('_', '-', $propertyName);
59
    }
60
}
61