Completed
Push — master ( 194a08...1a7130 )
by Bernhard
9s
created

Pause   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 5
Bugs 1 Features 4
Metric Value
wmc 6
c 5
b 1
f 4
lcom 0
cbo 1
dl 0
loc 67
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A canStartTask() 0 7 2
A canEndTask() 0 7 2
1
<?php
2
3
/**
4
 * \Wicked\Timely\Entities\Pause
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Bernhard Wick <[email protected]>
15
 * @copyright 2016 Bernhard Wick
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/wick-ed/timely
18
 */
19
20
namespace Wicked\Timely\Entities;
21
22
/**
23
 * Pause entity
24
 *
25
 * @author    Bernhard Wick <[email protected]>
26
 * @copyright 2016 Bernhard Wick
27
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
28
 * @link      https://github.com/wick-ed/timely
29
 */
30
class Pause extends Booking
31
{
32
33
    /**
34
     * Constant for the pause start tag
35
     *
36
     * @var string PAUSE_TAG_START
37
     */
38
    const PAUSE_TAG_START = '--ps--';
39
40
    /**
41
     * Constant for the pause end tag
42
     *
43
     * @var string PAUSE_TAG_END
44
     */
45
    const PAUSE_TAG_END = '--pe--';
46
47
    /**
48
     * Default constructor
49
     *
50
     * @param string      $comment  Comment for the pause
51
     * @param boolean     $resuming Whether or not the pause has ended
52
     * @param null|string $time     Time of this booking
53
     */
54
    public function __construct($comment = '', $resuming = false, $time = null)
55
    {
56
        // add the pause tags as special meta ticket IDs
57
        $this->metaTicketIds[] = self::PAUSE_TAG_START;
58
        $this->metaTicketIds[] = self::PAUSE_TAG_END;
59
60
        if ($resuming === true) {
61
            parent::__construct($comment, self::PAUSE_TAG_END, $time);
62
        } else {
63
            parent::__construct($comment, self::PAUSE_TAG_START, $time);
64
        }
65
    }
66
67
    /**
68
     * Whether or not this booking can be the start of a task
69
     *
70
     * @param boolean $includePause Whether or not pauses are included as task building bookings
71
     *
72
     * @return boolean
73
     */
74
    public function canStartTask($includePause = false)
75
    {
76
        if ($includePause) {
77
            return $this->getTicketId() === self::PAUSE_TAG_START;
78
        }
79
        return false;
80
    }
81
82
    /**
83
     * Whether or not this booking can be the end of a task
84
     *
85
     * @param boolean $includePause Whether or not pauses are included as task building bookings
86
     *
87
     * @return boolean
88
     */
89
    public function canEndTask($includePause = false)
90
    {
91
        if ($includePause) {
92
            return $this->getTicketId() === self::PAUSE_TAG_END;
93
        }
94
        return false;
95
    }
96
}
97