Completed
Push — master ( 725043...fc3a8f )
by Vladimir
07:42
created

PulseColumnNumericValue   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 43
loc 43
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 9 9 2
A updateValue() 12 12 1

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
namespace allejo\DaPulse\Objects;
4
5
/**
6
 * Class PulseColumnTextValue
7
 *
8
 * @package allejo\DaPulse\Objects
9
 * @since   0.2.0
10
 */
11 View Code Duplication
class PulseColumnNumericValue extends PulseColumnValue
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...
12
{
13
    /**
14
     * Get a text column's content
15
     *
16
     * @api
17
     *
18
     * @since  0.2.0
19
     *
20
     * @return string The column's content
21
     */
22
    public function getValue ()
23
    {
24
        if (!isset($this->column_value))
25
        {
26
            $this->column_value = $this->jsonResponse["value"];
27
        }
28
29
        return $this->column_value;
30
    }
31
32
    /**
33
     * Update the text of a text column
34
     *
35
     * @api
36
     *
37
     * @param int|double $text
38
     *
39
     * @since 0.2.0
40
     */
41
    public function updateValue ($text)
42
    {
43
        $url        = sprintf("%s/%d/columns/%s/numeric.json", self::apiEndpoint(), $this->board_id, $this->column_id);
44
        $postParams = array(
45
            "pulse_id" => $this->pulse_id,
46
            "value"    => $text
47
        );
48
49
        self::sendPut($url, $postParams);
50
51
        $this->column_value = $text;
52
    }
53
}