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.
Completed
Push — master ( f8863b...48fd44 )
by Sergey
04:48
created

JsonApiRegistry::getEncoder()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
/*
3
 * This file is part of the reva2/jsonapi.
4
 *
5
 * (c) OrbitScripts LLC <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
12
namespace Reva2\JsonApi\Services;
13
14
use Reva2\JsonApi\Contracts\Services\JsonApiRegistryInterface;
15
16
/**
17
 * JSON API decoders/encoders registry
18
 *
19
 * @package Reva2\JsonApi\Services
20
 * @author Sergey Revenko <[email protected]>
21
 */
22
class JsonApiRegistry implements JsonApiRegistryInterface
23
{
24
    /**
25
     * Decoders map
26
     *
27
     * @var array
28
     */
29
    protected $decoders = [];
30
31
    /**
32
     * Encoders map
33
     *
34
     * @var array
35
     */
36
    protected $encoders = [];
37
38
    /**
39
     * @inheritdoc
40
     */
41 1
    public function registerDecoder($name, \Closure $decoder)
42
    {
43 1
        $this->decoders[$name] = $decoder;
44
45 1
        return $this;
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51 2
    public function getDecoder($name)
52
    {
53 2
        if (!array_key_exists($name, $this->decoders)) {
54 1
            throw new \RuntimeException(sprintf("Decoder with name '%s' is not registered", $name));
55
        }
56
57 1
        return $this->decoders[$name];
58
    }
59
60
    /**
61
     * @inheritdoc
62
     */
63 1
    public function registerEncoder($name, \Closure $encoder)
64
    {
65 1
        $this->encoders[$name] = $encoder;
66
67 1
        return $this;
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73 2
    public function getEncoder($name)
74
    {
75 2
        if (!array_key_exists($name, $this->encoders)) {
76 1
            throw new \RuntimeException(sprintf("Encoder with name '%s' is not registered", $name));
77
        }
78
79 1
        return $this->encoders[$name];
80
    }
81
}
82