AbstractDeleteWarmerRequest   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 70
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getMethod() 4 4 1
A getWarmerName() 4 4 1
A setWarmerName() 4 4 1
A getBody() 4 4 1
A setBody() 4 4 1
A getAction() 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
19
namespace Elastification\Client\Request\Shared\Index;
20
21
use Elastification\Client\Exception\RequestException;
22
use Elastification\Client\Request\RequestMethods;
23
use Elastification\Client\Request\Shared\AbstractBaseRequest;
24
25
/**
26
 * Class AbstractDeleteMappingRequest
27
 *
28
 * @package Elastification\Client\Request\Shared\Index
29
 * @author  Daniel Wendlandt
30
 */
31 View Code Duplication
abstract class AbstractDeleteWarmerRequest 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...
32
{
33
34
    const REQUEST_ACTION = '_warmer';
35
36
    /**
37
     * @var null|string
38
     */
39
    private $warmerName = null;
40
41
    /**
42
     * @inheritdoc
43
     */
44 3
    public function getMethod()
45
    {
46 3
        return RequestMethods::DELETE;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52 6
    public function getAction()
53
    {
54 6
        if (empty($this->warmerName)) {
55 3
            throw new RequestException('Warmer name is not set');
56
        }
57
58 3
        return self::REQUEST_ACTION . '/' . $this->warmerName;
59
    }
60
61
    /**
62
     * Gets the name of the warmer
63
     *
64
     * @return null|string
65
     * @author Daniel Wendlandt
66
     */
67 3
    public function getWarmerName()
68
    {
69 3
        return $this->warmerName;
70
    }
71
72
    /**
73
     * sets the name of the warmer
74
     *
75
     * @param string $warmerName
76
     *
77
     * @author Daniel Wendlandt
78
     */
79 6
    public function setWarmerName($warmerName)
80
    {
81 6
        $this->warmerName = $warmerName;
82 6
    }
83
84
    /**
85
     * @inheritdoc
86
     */
87 3
    public function getBody()
88
    {
89 3
        return null;
90
    }
91
92
    /**
93
     * @inheritdoc
94
     */
95 3
    public function setBody($body)
96
    {
97
        //do nothing
98 3
    }
99
100
}
101