Code Duplication    Length = 45-45 lines in 2 locations

Serializer/JMSHandlerRegistry.php 1 location

@@ 27-71 (lines=45) @@
24
 *
25
 * @deprecated since FOSRestBundle 3.1, use the option `fos_rest.serializer.disable_jms_handlers` to avoid relying on it.
26
 */
27
class JMSHandlerRegistry implements HandlerRegistryInterface
28
{
29
    private $registry;
30
31
    public function __construct(HandlerRegistryInterface $registry)
32
    {
33
        $this->registry = $registry;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
40
    {
41
        $this->registry->registerSubscribingHandler($handler);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function registerHandler($direction, $typeName, $format, $handler): void
48
    {
49
        $this->registry->registerHandler($direction, $typeName, $format, $handler);
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function getHandler($direction, $typeName, $format)
56
    {
57
        $first = true;
58
        do {
59
            $handler = $this->registry->getHandler($direction, $typeName, $format);
60
            if (null !== $handler) {
61
                if (!$first) {
62
                    @trigger_error(sprintf('Relying on the custom registry %s to inherit the JMS handler of type `%s` is deprecated since FOSRestBundle 3.1. It will be removed in version 4.0. Use the option `fos_rest.serializer.disable_custom_jms_registry` to disable it.', __CLASS__, $typeName), E_USER_DEPRECATED);
63
                }
64
65
                return $handler;
66
            }
67
68
            $first = false;
69
        } while ($typeName = get_parent_class($typeName));
70
    }
71
}
72

Serializer/JMSHandlerRegistryV2.php 1 location

@@ 27-71 (lines=45) @@
24
 *
25
 * @deprecated since FOSRestBundle 3.1, use the option `fos_rest.serializer.disable_custom_jms_registry` to avoid relying on it.
26
 */
27
final class JMSHandlerRegistryV2 implements HandlerRegistryInterface
28
{
29
    private $registry;
30
31
    public function __construct(HandlerRegistryInterface $registry)
32
    {
33
        $this->registry = $registry;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
40
    {
41
        $this->registry->registerSubscribingHandler($handler);
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47
    public function registerHandler(int $direction, string $typeName, string $format, $handler): void
48
    {
49
        $this->registry->registerHandler($direction, $typeName, $format, $handler);
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function getHandler(int $direction, string $typeName, string $format)
56
    {
57
        $first = true;
58
        do {
59
            $handler = $this->registry->getHandler($direction, $typeName, $format);
60
            if (null !== $handler) {
61
                if (!$first) {
62
                    @trigger_error(sprintf('Relying on the custom registry %s to inherit the JMS handler of type `%s` is deprecated since FOSRestBundle 3.1. It will be removed in version 4.0. Use the option `fos_rest.serializer.disable_custom_jms_registry` to disable it.', __CLASS__, $typeName), E_USER_DEPRECATED);
63
                }
64
65
                return $handler;
66
            }
67
68
            $first = false;
69
        } while ($typeName = get_parent_class($typeName));
70
    }
71
}
72