Completed
Push — master ( c07f69...57c551 )
by Vladimir
05:20
created

PulseColumnTimelineValue::getValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 2
eloc 6
nc 2
nop 0
1
<?php
2
3
namespace allejo\DaPulse\Objects;
4
5
/**
6
 * Class PulseColumnTextValue
7
 *
8
 * @package allejo\DaPulse\Objects
9
 * @since   0.2.1
10
 */
11
class PulseColumnTimelineValue extends PulseColumnValue
12
{
13
    /**
14
     * Get a timeline column's content
15
     *
16
     * @api
17
     *
18
     * @since  0.2.1
19
     *
20
     * @return \DateTime[] The timeline's begin and end dates
21
     *
22
     *     array(
23
     *       'from' => \DateTime
24
     *       'to'   => \DateTime
25
     *     )
26
     */
27
    public function getValue ()
28
    {
29
        if (!isset($this->column_value))
30
        {
31
            $this->column_value = array(
32
                'from' => new \DateTime($this->jsonResponse["value"]["from"]),
33
                'to'   => new \DateTime($this->jsonResponse["value"]["to"])
34
            );
35
        }
36
37
        return $this->column_value;
38
    }
39
40
    /**
41
     * Update the values of a timeline column
42
     *
43
     * @api
44
     *
45
     * @param \DateTime $from
46
     * @param \DateTime $to
47
     *
48
     * @since 0.2.1
49
     */
50
    public function updateValue ($from, $to)
0 ignored issues
show
Comprehensibility introduced by
Avoid variables with short names like $to. Configured minimum length is 3.

Short variable names may make your code harder to understand. Variable names should be self-descriptive. This check looks for variable names who are shorter than a configured minimum.

Loading history...
51
    {
52
        $url        = sprintf("%s/%d/columns/%s/timeline.json", self::apiEndpoint(), $this->board_id, $this->column_id);
53
        $postParams = array(
54
            "pulse_id" => $this->pulse_id,
55
            "from"     => $from->format('Y-m-d'),
56
            "to"       => $to->format('Y-m-d')
57
        );
58
59
        self::sendPut($url, $postParams);
60
61
        $this->column_value = array(
62
            'from' => $from,
63
            'to'   => $to
64
        );
65
    }
66
}