Code Duplication    Length = 47-50 lines in 3 locations

src/Internal/ParameterHandler/FieldParamHandler.php 1 location

@@ 19-68 (lines=50) @@
16
 *
17
 * @author Nate Brunette <[email protected]>
18
 */
19
final class FieldParamHandler extends AbstractParameterHandler
20
{
21
    /**
22
     * @var StringConverter
23
     */
24
    private $converter;
25
26
    /**
27
     * @var string
28
     */
29
    private $name;
30
31
    /**
32
     * @var bool
33
     */
34
    private $encoded;
35
36
    /**
37
     * Constructor
38
     *
39
     * @param string $name
40
     * @param StringConverter $converter
41
     * @param bool $encoded
42
     */
43
    public function __construct(StringConverter $converter, string $name, bool $encoded)
44
    {
45
        $this->converter = $converter;
46
        $this->name = $name;
47
        $this->encoded = $encoded;
48
    }
49
50
    /**
51
     * Set a value to the [@see RequestBuilder] for parameter type
52
     *
53
     * @param RequestBuilder $requestBuilder
54
     * @param mixed $value
55
     * @return void
56
     * @throws \RuntimeException
57
     */
58
    public function apply(RequestBuilder $requestBuilder, $value): void
59
    {
60
        if ($value === null) {
61
            return;
62
        }
63
64
        foreach ($this->getListValues($value) as $element) {
65
            $requestBuilder->addField($this->name, $this->converter->convert($element), $this->encoded);
66
        }
67
    }
68
}
69

src/Internal/ParameterHandler/PartParamHandler.php 1 location

@@ 19-65 (lines=47) @@
16
 *
17
 * @author Nate Brunette <[email protected]>
18
 */
19
final class PartParamHandler extends AbstractParameterHandler
20
{
21
    /**
22
     * @var RequestBodyConverter
23
     */
24
    private $converter;
25
26
    /**
27
     * @var string
28
     */
29
    private $name;
30
31
    /**
32
     * @var string
33
     */
34
    private $encoding;
35
36
    /**
37
     * Constructor
38
     *
39
     * @param RequestBodyConverter $converter
40
     * @param string $name
41
     * @param string $encoding
42
     */
43
    public function __construct(RequestBodyConverter $converter, string $name, string $encoding)
44
    {
45
        $this->converter = $converter;
46
        $this->name = $name;
47
        $this->encoding = $encoding;
48
    }
49
50
    /**
51
     * Set a value to the [@see RequestBuilder] for parameter type
52
     *
53
     * @param RequestBuilder $requestBuilder
54
     * @param mixed $value
55
     * @return void
56
     */
57
    public function apply(RequestBuilder $requestBuilder, $value): void
58
    {
59
        if ($value === null) {
60
            return;
61
        }
62
63
        $this->handlePart($requestBuilder, $this->converter, $this->name, $value, $this->encoding);
64
    }
65
}
66

src/Internal/ParameterHandler/QueryParamHandler.php 1 location

@@ 19-68 (lines=50) @@
16
 *
17
 * @author Nate Brunette <[email protected]>
18
 */
19
final class QueryParamHandler extends AbstractParameterHandler
20
{
21
    /**
22
     * @var StringConverter
23
     */
24
    private $converter;
25
26
    /**
27
     * @var string
28
     */
29
    private $name;
30
31
    /**
32
     * @var bool
33
     */
34
    private $encoded;
35
36
    /**
37
     * Constructor
38
     *
39
     * @param string $name
40
     * @param StringConverter $converter
41
     * @param bool $encoded
42
     */
43
    public function __construct(StringConverter $converter, string $name, bool $encoded)
44
    {
45
        $this->converter = $converter;
46
        $this->name = $name;
47
        $this->encoded = $encoded;
48
    }
49
50
    /**
51
     * Set a value to the [@see RequestBuilder] for parameter type
52
     *
53
     * @param RequestBuilder $requestBuilder
54
     * @param mixed $value
55
     * @return void
56
     * @throws \RuntimeException
57
     */
58
    public function apply(RequestBuilder $requestBuilder, $value): void
59
    {
60
        if ($value === null) {
61
            return;
62
        }
63
64
        foreach ($this->getListValues($value) as $element) {
65
            $requestBuilder->addQuery($this->name, $this->converter->convert($element), $this->encoded);
66
        }
67
    }
68
}
69