Code Duplication    Length = 27-27 lines in 2 locations

src/Decorators/DecoratorsCollection.php 1 location

@@ 24-50 (lines=27) @@
21
use Pinepain\JsSandbox\Decorators\Definitions\DecoratorInterface;
22
23
24
class DecoratorsCollection implements DecoratorsCollectionInterface
25
{
26
    protected $decorators = [];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function get(string $name): DecoratorInterface
32
    {
33
        if (!isset($this->decorators[$name])) {
34
            throw new OutOfBoundsException("Decorator '{$name}' not found");
35
        }
36
37
        return $this->decorators[$name];
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function put(string $name, DecoratorInterface $extractor)
44
    {
45
        if (isset($this->decorators[$name])) {
46
            throw new OverflowException("Decorator with the same name ('{$name}') already exists");
47
        }
48
        $this->decorators[$name] = $extractor;
49
    }
50
}
51

src/Extractors/ExtractorsCollection.php 1 location

@@ 24-50 (lines=27) @@
21
use Pinepain\JsSandbox\Extractors\PlainExtractors\PlainExtractorInterface;
22
23
24
class ExtractorsCollection implements ExtractorsCollectionInterface
25
{
26
    protected $extractors = [];
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function get(string $name): PlainExtractorInterface
32
    {
33
        if (!isset($this->extractors[$name])) {
34
            throw new OutOfBoundsException("Extractor '{$name}' not found");
35
        }
36
37
        return $this->extractors[$name];
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function put(string $name, PlainExtractorInterface $extractor)
44
    {
45
        if (isset($this->extractors[$name])) {
46
            throw new OverflowException("Extractor with the same name ('{$name}') already exists");
47
        }
48
        $this->extractors[$name] = $extractor;
49
    }
50
}
51