Code Duplication    Length = 55-55 lines in 2 locations

src/Request/Shared/AbstractDeleteDocumentRequest.php 1 location

@@ 30-84 (lines=55) @@
27
 * @package Elastification\Client\Request\Shared
28
 * @author  Daniel Wendlandt
29
 */
30
abstract class AbstractDeleteDocumentRequest extends AbstractBaseRequest
31
{
32
    /**
33
     * @var null|string
34
     */
35
    private $action = null;
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function getMethod()
41
    {
42
        return RequestMethods::DELETE;
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function getAction()
49
    {
50
        if (null === $this->action) {
51
            throw new RequestException('id can not be empty for this request');
52
        }
53
54
        return $this->action;
55
    }
56
57
    /**
58
     * @inheritdoc
59
     */
60
    public function getBody()
61
    {
62
        return null;
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function setBody($body)
69
    {
70
        //do nothing
71
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76
    public function setId($id)
77
    {
78
        if (empty($id)) {
79
            throw new RequestException('Id can not be empty');
80
        }
81
82
        $this->action = $id;
83
    }
84
}
85

src/Request/Shared/AbstractGetDocumentRequest.php 1 location

@@ 30-84 (lines=55) @@
27
 * @package Elastification\Client\Request\Shared
28
 * @author  Daniel Wendlandt
29
 */
30
abstract class AbstractGetDocumentRequest extends AbstractBaseRequest
31
{
32
    /**
33
     * @var null|string
34
     */
35
    private $action = null;
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function getMethod()
41
    {
42
        return RequestMethods::GET;
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function getAction()
49
    {
50
        if (null === $this->action) {
51
            throw new RequestException('id can not be empty for this request');
52
        }
53
54
        return $this->action;
55
    }
56
57
    /**
58
     * @inheritdoc
59
     */
60
    public function getBody()
61
    {
62
        return null;
63
    }
64
65
    /**
66
     * @inheritdoc
67
     */
68
    public function setBody($body)
69
    {
70
        //do nothing
71
    }
72
73
    /**
74
     * @inheritdoc
75
     */
76
    public function setId($id)
77
    {
78
        if (empty($id)) {
79
            throw new RequestException('Id can not be empty');
80
        }
81
82
        $this->action = $id;
83
    }
84
}
85