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.

CompositeObjectUnserializer   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 31
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A tryToUnserializeValue() 0 15 4
1
<?php
2
/******************************************************************************
3
 * Copyright (c) 2017 Constantin Galbenu <[email protected]>             *
4
 ******************************************************************************/
5
6
namespace Gica\Serialize\ObjectHydrator\ObjectUnserializer;
7
8
9
use Gica\Serialize\ObjectHydrator\Exception\AdapterNotFoundException;
10
use Gica\Serialize\ObjectHydrator\Exception\ValueNotUnserializable;
11
use Gica\Serialize\ObjectHydrator\ObjectUnserializer;
12
13
class CompositeObjectUnserializer implements ObjectUnserializer
14
{
15
16
    /**
17
     * @var ObjectUnserializer[]
18
     */
19
    private $unserializers;
20
21 20
    public function __construct(
22
        array $unserializers = []
23
    )
24
    {
25 20
        $this->unserializers = $unserializers;
26 20
    }
27
28 8
    public function tryToUnserializeValue(string $objectClassName, $serializedValue)
29
    {
30 8
        foreach ($this->unserializers as $adapterLocator) {
31
            try {
32 4
                return $adapterLocator->tryToUnserializeValue($objectClassName, $serializedValue);
33 4
            } catch (AdapterNotFoundException $exception) {
34 1
                continue;
35 4
            } catch (ValueNotUnserializable $exception) {
36 4
                continue;
37
            }
38
        }
39
40 6
        throw new AdapterNotFoundException(
41 6
            sprintf("None of the %d adapter locators could find an adapter", count($this->unserializers)));
42
    }
43
}