1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* \Wicked\Timely\Entities\BookingFactory |
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 wick-ed |
15
|
|
|
* @copyright 2020 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
|
|
|
* Booking factory |
24
|
|
|
* |
25
|
|
|
* @author wick-ed |
26
|
|
|
* @copyright 2020 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 BookingFactory |
31
|
|
|
{ |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Default constructor |
35
|
|
|
* |
36
|
|
|
* @param string $comment Comment for the booking |
37
|
|
|
* @param string $ticketId Optional ticket ID |
38
|
|
|
* @param null|string $time Time of this booking |
39
|
|
|
* @param bool $pushed Pushed to jira worklog |
40
|
|
|
* |
41
|
|
|
* @return \Wicked\Timely\Entities\Booking |
42
|
|
|
*/ |
43
|
4 |
|
public static function getBooking($comment, $ticketId = '', $time = null, $pushed = false) |
44
|
|
|
{ |
45
|
4 |
|
switch ($ticketId) { |
46
|
|
|
case Clipping::CLIPPING_TAG_FRONT: |
47
|
2 |
|
return new Clipping(true, $time); |
48
|
|
|
break; |
|
|
|
|
49
|
|
|
|
50
|
|
|
case Clipping::CLIPPING_TAG_REAR: |
51
|
4 |
|
return new Clipping(false, $time); |
52
|
|
|
break; |
|
|
|
|
53
|
|
|
|
54
|
|
|
case Pause::PAUSE_TAG_START: |
55
|
4 |
|
return new Pause($comment, false, $time); |
56
|
|
|
break; |
|
|
|
|
57
|
|
|
|
58
|
|
|
case Pause::PAUSE_TAG_END: |
59
|
4 |
|
return new Pause($comment, true, $time); |
60
|
|
|
break; |
|
|
|
|
61
|
|
|
|
62
|
|
|
default: |
63
|
4 |
|
return new Booking($comment, $ticketId, $time, $pushed); |
64
|
|
|
break; |
|
|
|
|
65
|
|
|
} |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Returns all known meta booking ticket IDs |
70
|
|
|
* |
71
|
|
|
* @return array |
72
|
|
|
*/ |
73
|
|
|
public static function getAllMetaTicketIds() |
74
|
|
|
{ |
75
|
|
|
return array( |
76
|
|
|
Clipping::CLIPPING_TAG_FRONT => Clipping::CLIPPING_TAG_FRONT, |
77
|
|
|
Clipping::CLIPPING_TAG_REAR => Clipping::CLIPPING_TAG_REAR, |
78
|
|
|
Pause::PAUSE_TAG_START => Pause::PAUSE_TAG_START, |
79
|
|
|
Pause::PAUSE_TAG_END => Pause::PAUSE_TAG_END |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
The break statement is not necessary if it is preceded for example by a return statement:
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.