Code Duplication    Length = 40-40 lines in 2 locations

src/Processors/Factory/AnyFactory.php 1 location

@@ 21-60 (lines=40) @@
18
/**
19
 * @author John Kleijn <[email protected]>
20
 */
21
class AnyFactory implements Factory
22
{
23
    const PRIORITY = 1000;
24
25
    /**
26
     * @var DateTimeSerializer
27
     */
28
    protected $dateTimeSerializer;
29
30
    /**
31
     * DateTimeFactory constructor.
32
     * @param DateTimeSerializer $dateTimeSerializer
33
     */
34
    public function __construct(DateTimeSerializer $dateTimeSerializer)
35
    {
36
        $this->dateTimeSerializer = $dateTimeSerializer;
37
    }
38
39
    /**
40
     * @param Schema           $schema
41
     * @param ProcessorBuilder $builder
42
     * @return Processor|null
43
     */
44
    public function create(Schema $schema, ProcessorBuilder $builder)
45
    {
46
        if (!$schema instanceof AnySchema) {
47
            return null;
48
        }
49
50
        return new AnyProcessor(new AnySchema(), $this->dateTimeSerializer);
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function getPriority(): int
57
    {
58
        return self::PRIORITY;
59
    }
60
}
61

src/Processors/Factory/DateTimeFactory.php 1 location

@@ 21-60 (lines=40) @@
18
/**
19
 * @author John Kleijn <[email protected]>
20
 */
21
class DateTimeFactory implements Factory
22
{
23
    const PRIORITY = 900;
24
25
    /**
26
     * @var DateTimeSerializer
27
     */
28
    protected $dateTimeSerializer;
29
30
    /**
31
     * DateTimeFactory constructor.
32
     * @param DateTimeSerializer $dateTimeSerializer
33
     */
34
    public function __construct(DateTimeSerializer $dateTimeSerializer)
35
    {
36
        $this->dateTimeSerializer = $dateTimeSerializer;
37
    }
38
39
    /**
40
     * @param Schema           $schema
41
     * @param ProcessorBuilder $builder
42
     * @return Processor|null
43
     */
44
    public function create(Schema $schema, ProcessorBuilder $builder)
45
    {
46
        if (!$schema instanceof ScalarSchema || !$schema->isDateTime()) {
47
            return null;
48
        }
49
50
        return new DateTimeProcessor($schema, $this->dateTimeSerializer);
51
    }
52
53
    /**
54
     * @return int
55
     */
56
    public function getPriority(): int
57
    {
58
        return self::PRIORITY;
59
    }
60
}
61