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.

CollectionParamConverter   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 5
dl 0
loc 47
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A apply() 0 17 4
A supports() 0 4 1
1
<?php
2
3
4
namespace Netgen\Bundle\InformationCollectionBundle\ParamConverter;
5
6
use Netgen\InformationCollection\API\Service\InformationCollection;
7
use Netgen\InformationCollection\API\Value\Collection;
8
use Netgen\InformationCollection\API\Value\Filter\CollectionId;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ParamConverter;
10
use Sensio\Bundle\FrameworkExtraBundle\Request\ParamConverter\ParamConverterInterface;
11
use Symfony\Component\HttpFoundation\Request;
12
13
final class CollectionParamConverter implements ParamConverterInterface
14
{
15
    /**
16
     * @var InformationCollection
17
     */
18
    protected $informationCollection;
19
20
    public function __construct(InformationCollection $informationCollection)
21
    {
22
        $this->informationCollection = $informationCollection;
23
    }
24
25
    /**
26
     * Stores the object in the request.
27
     *
28
     * @param ParamConverter $configuration Contains the name, class and options of the object
29
     *
30
     * @return bool True if the object has been successfully set, else false
31
     */
32
    public function apply(Request $request, ParamConverter $configuration)
33
    {
34
        if (!$request->attributes->has('collectionId')) {
35
            return false;
36
        }
37
38
        $collectionId = $request->attributes->get('collectionId');
39
        if (!$collectionId && $configuration->isOptional()) {
40
            return false;
41
        }
42
43
        $request->attributes->set(
44
            $configuration->getName(), $this->informationCollection->getCollection(new CollectionId($collectionId))
45
        );
46
47
        return true;
48
    }
49
50
    /**
51
     * Checks if the object is supported.
52
     *
53
     * @return bool True if the object is supported, else false
54
     */
55
    public function supports(ParamConverter $configuration)
56
    {
57
        return is_a($configuration->getClass(), Collection::class, true);
58
    }
59
}
60