Completed
Pull Request — master (#193)
by
unknown
01:50
created

Sprint::getStartDate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: meshulam
5
 * Date: 23/09/2017
6
 * Time: 14:17.
7
 */
8
9
namespace JiraRestApi\Sprint;
10
11
use JiraRestApi\ClassSerialize;
12
13
class Sprint implements \JsonSerializable
14
{
15
    use ClassSerialize;
16
17
    /**
18
     * return only if Project query by key(not id).
19
     *
20
     * @var string
21
     */
22
    public $expand;
23
24
    /* @var string */
25
    public $self;
26
27
    /* @var string */
28
    public $id;
29
30
    /* @var string*/
31
    public $name;
32
33
    /* @var string */
34
    //public $type;
35
36
    /* @var string */
37
    public $state;
38
39
    /* @var DateTime */
0 ignored issues
show
Bug introduced by
The type JiraRestApi\Sprint\DateTime was not found. Did you mean DateTime? If so, make sure to prefix the type with \.
Loading history...
40
    public $startDate;
41
42
    /* @var DateTime */
43
    public $endDate;
44
45
    /* @var string */
46
    public $originBoardId;
47
48
    /* @var string */
49
    public $goal;
50
51
    /* @var string */
52
    public $estimatedVelocity = null;
53
54
    /* @var string */
55
    public $completedVelocity = null;
56
57
    // public function __construct() {
58
    //     $this->startDate = new \DateTime();
59
    //     $this->endDate = new \DateTime();
60
    // }
61
62
    public function jsonSerialize()
63
    {
64
        return array_filter(get_object_vars($this));
65
    }
66
67
    public function setName($sprintName)
68
    {
69
        $this->name = $sprintName;
70
71
        return $sprintName;
72
    }
73
74
    public function getName()
75
    {
76
        return $this->name;
77
    }
78
79
    public function getGoal()
80
    {
81
        return str_replace(["\n\r", "\n", "\r"], '', $this->goal);
82
    }
83
84
    public function getStartDate($format = 'Y-m-d H:i:s')
85
    {
86
        if (!is_null($this->startDate)) {
87
            $date = new \DateTime($this->startDate);
88
89
            return date_format($date, $format);
90
        }
91
    }
92
93
    public function getEndDate($format = 'Y-m-d H:i:s')
94
    {
95
        if (!is_null($this->endDate)) {
96
            $date = new \DateTime($this->endDate);
97
98
            return date_format($date, $format);
99
        }
100
    }
101
}
102