Code Duplication    Length = 22-24 lines in 2 locations

src/Persister/PagerPersisterRegistry.php 1 location

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

src/Persister/PersisterRegistry.php 1 location

@@ 16-39 (lines=24) @@
13
14
use Symfony\Component\DependencyInjection\ServiceLocator;
15
16
class PersisterRegistry
17
{
18
    /** @var ServiceLocator */
19
    private $persisters;
20
21
    public function __construct(ServiceLocator $persisters)
22
    {
23
        $this->persisters = $persisters;
24
    }
25
26
    /**
27
     * Gets the persister for an index.
28
     *
29
     * @throws \InvalidArgumentException if no persister was registered for the index
30
     */
31
    public function getPersister(string $index): ObjectPersisterInterface
32
    {
33
        if (!$this->persisters->has($index)) {
34
            throw new \InvalidArgumentException(\sprintf('No persister was registered for index "%s".', $index));
35
        }
36
37
        return $this->persisters->get($index);
38
    }
39
}
40