AbstractAliasesRequest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 61
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
c 1
b 1
f 0
lcom 0
cbo 3
dl 61
loc 61
ccs 15
cts 15
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getIndex() 4 4 1
A getType() 4 4 1
A getMethod() 4 4 1
A getAction() 4 4 1
A getBody() 4 4 1
A setBody() 8 8 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license.
17
 */
18
namespace Elastification\Client\Request\Shared;
19
20
use Elastification\Client\Exception\RequestException;
21
use Elastification\Client\Request\RequestMethods;
22
23
/**
24
 * Class AbstractAliasesRequest
25
 *
26
 * @package Elastification\Client\Request\Shared
27
 * @author  Daniel Wendlandt
28
 */
29 View Code Duplication
abstract class AbstractAliasesRequest extends AbstractBaseRequest
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
{
31
    const REQUEST_ACTION = '_aliases';
32
33
    /**
34
     * @var null|string
35
     */
36
    private $body = null;
37
38
    /**
39
     * @inheritdoc
40
     */
41 3
    public function getIndex()
42
    {
43 3
        return null;
44
    }
45
46
    /**
47
     * @inheritdoc
48
     */
49 3
    public function getType()
50
    {
51 3
        return null;
52
    }
53
54
    /**
55
     * @inheritdoc
56
     */
57 3
    public function getMethod()
58
    {
59 3
        return RequestMethods::POST;
60
    }
61
62
    /**
63
     * @inheritdoc
64
     */
65 3
    public function getAction()
66
    {
67 3
        return self::REQUEST_ACTION;
68
    }
69
70
    /**
71
     * @inheritdoc
72
     */
73 3
    public function getBody()
74
    {
75 3
        return $this->body;
76
    }
77
78
    /**
79
     * @inheritdoc
80
     */
81 6
    public function setBody($body)
82
    {
83 6
        if (empty($body)) {
84 3
            throw new RequestException('Body can not be empty');
85
        }
86
87 3
        $this->body = $this->serializer->serialize($body, $this->serializerParams);
88 3
    }
89
}
90