Completed
Pull Request — master (#1184)
by Vincent
03:16
created

SerializerAwareDataProviderTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setSerializerLocator() 0 4 1
A getSerializer() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace ApiPlatform\Core\DataProvider;
15
16
use Psr\Container\ContainerInterface;
17
use Symfony\Component\Serializer\SerializerInterface;
18
19
/**
20
 * Inject serializer in data providers.
21
 *
22
 * @author Vincent Chalamon <[email protected]>
23
 */
24
trait SerializerAwareDataProviderTrait
25
{
26
    /**
27
     * @var ContainerInterface
28
     */
29
    private $serializerLocator;
30
31
    /**
32
     * @param ContainerInterface $serializerLocator
33
     */
34
    public function setSerializerLocator(ContainerInterface $serializerLocator)
35
    {
36
        $this->serializerLocator = $serializerLocator;
37
    }
38
39
    /**
40
     * @return SerializerInterface
41
     */
42
    private function getSerializer(): SerializerInterface
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
43
    {
44
        return $this->serializerLocator->get('serializer');
45
    }
46
}
47