|
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 |
|
|
|
|
|
|
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
|
|
|
|