Code Duplication    Length = 17-19 lines in 2 locations

src/Request/ParamConverter/DateTimeParamConverter.php 1 location

@@ 22-38 (lines=17) @@
19
     *
20
     * @throws NotFoundHttpException When invalid date given
21
     */
22
    public function apply(Request $request, ParamConverter $configuration)
23
    {
24
        $param = $configuration->getName();
25
        if (!$request->attributes->has($param)) {
26
            return false;
27
        }
28
29
        $value = $request->attributes->get($param);
30
        if (!$value && $configuration->isOptional()) {
31
            return false;
32
        }
33
34
        $request->attributes->set(
35
            $param,
36
            $this->getDateTime($configuration, $value, $param)
37
        );
38
39
        return true;
40
    }
41

src/Request/ParamConverter/EntityParamConverter.php 1 location

@@ 38-56 (lines=19) @@
35
     *
36
     * @return bool
37
     */
38
    public function apply(Request $request, ParamConverter $configuration)
39
    {
40
        $param = $configuration->getName();
41
        if (!$request->attributes->has($param)) {
42
            return false;
43
        }
44
45
        $value = $request->attributes->get($param);
46
        if (!$value && $configuration->isOptional()) {
47
            return false;
48
        }
49
50
        $request->attributes->set(
51
            $param,
52
            $this->getNode($value, $configuration)
53
        );
54
55
        return true;
56
    }
57
58
    /**
59
     * @param string $value