Completed
Push — master ( 741f1a...42bbb8 )
by Bernhard
03:50
created

BookingFactory::getAllMetaTicketIds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 2
cp 0
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

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.

Loading history...
49
50
            case Clipping::CLIPPING_TAG_REAR:
51 4
                return new Clipping(false, $time);
52
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

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.

Loading history...
53
54
            case Pause::PAUSE_TAG_START:
55 4
                return new Pause($comment, false, $time);
56
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

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.

Loading history...
57
58
            case Pause::PAUSE_TAG_END:
59 4
                return new Pause($comment, true, $time);
60
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

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.

Loading history...
61
62
            default:
63 4
                return new Booking($comment, $ticketId, $time, $pushed);
64
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

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.

Loading history...
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