PagerPersisterRegistry::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
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
namespace FOS\ElasticaBundle\Persister;
13
14
use Symfony\Component\DependencyInjection\ServiceLocator;
15
16 View Code Duplication
final class PagerPersisterRegistry
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /** @var ServiceLocator */
19
    private $persisters;
20
21 9
    public function __construct(ServiceLocator $persisters)
22
    {
23 9
        $this->persisters = $persisters;
24 9
    }
25
26
    /**
27
     * @throws \InvalidArgumentException if no pager persister was registered for the given name
28
     */
29 4
    public function getPagerPersister(string $name): PagerPersisterInterface
30
    {
31 4
        if (!$this->persisters->has($name)) {
32 1
            throw new \InvalidArgumentException(\sprintf('No pager persister was registered for the give name "%s".', $name));
33
        }
34
35 3
        return $this->persisters->get($name);
36
    }
37
}
38