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.

ArrayFormatter::getNameAndPayload()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
ccs 6
cts 6
cp 1
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
3
namespace RemiSan\Serializer\Formatter;
4
5
use RemiSan\Serializer\DataFormatter;
6
7
class ArrayFormatter implements DataFormatter
8
{
9
    /**
10
     * @param string $name
11
     * @param array  $payload
12
     *
13
     * @return array
14
     */
15 3
    public function format($name, array $payload)
16
    {
17
        return [
18 3
            'name' => $name,
19 3
            'payload' => $payload,
20 2
        ];
21
    }
22
23
    /**
24
     * @param array $serializedObject
25
     *
26
     * @return array
27
     */
28 6
    public function getNameAndPayload(array $serializedObject)
29
    {
30 6
        if (!$this->isSerializedObject($serializedObject)) {
31 3
            throw new \InvalidArgumentException();
32
        }
33
34
        return [
35 3
            $serializedObject['name'],
36 3
            $serializedObject['payload'],
37 2
        ];
38
    }
39
40
    /**
41
     * @param array $serializedObject
42
     *
43
     * @return bool
44
     */
45 12
    public function isSerializedObject(array $serializedObject)
46
    {
47 12
        return isset($serializedObject['name']) && isset($serializedObject['payload']);
48
    }
49
}
50