Completed
Push — master ( 95cc27...d32772 )
by Vladimir
05:08 queued 03:05
created

PulseColumnNumericValue::setValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\DaPulse\Objects;
9
10
/**
11
 * Class PulseColumnTextValue
12
 *
13
 * @package allejo\DaPulse\Objects
14
 * @since   0.2.0
15
 */
16
class PulseColumnNumericValue extends PulseColumnValue
17
{
18
    /**
19
     * Get a numeric column's content
20
     *
21
     * @api
22
     *
23
     * @since  0.3.0 Docs correctly specify a numeric return type
24
     * @since  0.2.0
25
     *
26
     * @return int|double|null Null is returned if there is no value set for this column
27
     */
28 3
    public function getValue ()
29
    {
30 3
        return parent::getValue();
31
    }
32
33
    /**
34
     * Update the value of a numeric column
35
     *
36
     * @api
37
     *
38
     * @param int|double $number
39
     *
40
     * @since 0.3.0 \InvalidArgumentException is now thrown
41
     * @since 0.2.0
42
     *
43
     * @throws \InvalidArgumentException if $number is not a numeric value
44
     */
45 5 View Code Duplication
    public function updateValue ($number)
0 ignored issues
show
Duplication introduced by
This method 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...
46
    {
47 5
        if (!is_numeric($number))
48
        {
49 4
            throw new \InvalidArgumentException('$number is expected to be a numeric type');
50
        }
51
52 1
        $url        = sprintf("%s/%d/columns/%s/numeric.json", self::apiEndpoint(), $this->board_id, $this->column_id);
53
        $postParams = [
54 1
            "pulse_id" => $this->pulse_id,
55 1
            "value"    => $number
56
        ];
57
58 1
        $result = self::sendPut($url, $postParams);
59 1
        $this->setValue($result);
60 1
    }
61
62 2
    protected function setValue ($response)
63
    {
64 2
        $this->column_value = $response["value"];
65
    }
66
}