PriorityKeys::getAll()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
/**
4
 * AppserverIo\Messaging\Utils\PriorityKeys
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    Tim Wagner <[email protected]>
15
 * @copyright 2015 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/appserver-io/messaging
18
 * @link      http://www.appserver.io
19
 */
20
21
namespace AppserverIo\Messaging\Utils;
22
23
/**
24
 * This class holds the priority keys used as message priority.
25
 *
26
 * @author    Tim Wagner <[email protected]>
27
 * @copyright 2015 TechDivision GmbH <[email protected]>
28
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
29
 * @link      https://github.com/appserver-io/messaging
30
 * @link      http://www.appserver.io
31
 */
32
class PriorityKeys
33
{
34
35
    /**
36
     * Private constructor for marking the class as utility.
37
     */
38
    final protected function __construct()
39
    {
40
        /* Class is a utility class */
41
    }
42
43
    /**
44
     * Returns the initialized priority key for the passed priority key.
45
     *
46
     * @param integer $key The priority key to return the instance for
47
     *
48
     * @return \AppserverIo\Psr\Pms\PriorityKeyInterface The instance
49
     * @throws \Exception
50
     */
51
    public static function get($key)
52
    {
53
        switch($key) { // check the passed key and return the requested priority key instance
0 ignored issues
show
Coding Style introduced by
Expected 1 space after SWITCH keyword; 0 found
Loading history...
54
            case 1:
55
                return PriorityLow::get();
56
            case 2:
57
                return PriorityMedium::get();
58
            case 3:
59
                return PriorityHigh::get();
60
            default:
61
                throw new \Exception(sprintf('PriorityKey with key %s doesn\'t exist', $key));
62
        }
63
    }
64
65
    /**
66
     * Returns an array with all available priority keys.
67
     *
68
     * @return array The available priority keys
69
     */
70
    public static function getAll()
71
    {
72
        return array(PriorityLow::get(), PriorityMedium::get(), PriorityHigh::get());
73
    }
74
}
75