1 | <?php |
||
7 | class MessageParserException extends \Exception |
||
8 | { |
||
9 | const JOIN_MULTIPLE_USERS = 'game.parser.exception.join.multiple-users'; |
||
10 | const JOIN_UNREGISTERED_USER = 'game.parser.exception.join.unregistered-users'; |
||
11 | const JOIN_NO_GAME = 'game.parser.exception.join.no-game'; |
||
12 | const JOIN_YOURSELF = 'game.parser.exception.join.yourself'; |
||
13 | const JOIN_GAME_RUNNING = 'game.parser.exception.join.game-running'; |
||
14 | const START_NOT_IN = 'game.parser.exception.start.not-in'; |
||
15 | const LEAVE_NOT_IN = 'game.parser.exception.leave.not-in'; |
||
16 | const CREATE_MULTIPLE = 'game.parser.exception.create.multiple'; |
||
17 | const GAME_NOT_FOUND = 'game.parser.exception.game-not-found'; |
||
18 | const INVALID_USER = 'parser.exception.invalid-user'; |
||
19 | const PARSE_ERROR = 'parser.exception.parse-error'; |
||
20 | |||
21 | /** |
||
22 | * @var LocalizedUser |
||
23 | */ |
||
24 | private $user; |
||
25 | |||
26 | /** |
||
27 | * @var string |
||
28 | */ |
||
29 | private $codeName; |
||
30 | |||
31 | /** |
||
32 | * Constructor |
||
33 | * |
||
34 | * @param LocalizedUser $user |
||
35 | * @param string $codeName |
||
36 | * @param string $message |
||
37 | * @param int $code |
||
38 | * @param \Exception $previous |
||
39 | */ |
||
40 | 39 | public function __construct( |
|
51 | |||
52 | /** |
||
53 | * Returns the user |
||
54 | * |
||
55 | * @return LocalizedUser |
||
56 | */ |
||
57 | public function getUser() |
||
61 | |||
62 | /** |
||
63 | * @return string |
||
64 | */ |
||
65 | 36 | public function getCodeName() |
|
69 | |||
70 | /** |
||
71 | * @param LocalizedUser $user |
||
72 | * @return MessageParserException |
||
73 | */ |
||
74 | 3 | public static function cannotJoinMultipleUsers(LocalizedUser $user) |
|
78 | |||
79 | /** |
||
80 | * @param LocalizedUser $user |
||
81 | * @return MessageParserException |
||
82 | */ |
||
83 | 3 | public static function cannotJoinUnregisteredUser(LocalizedUser $user) |
|
87 | |||
88 | /** |
||
89 | * @param LocalizedUser $user |
||
90 | * @return MessageParserException |
||
91 | */ |
||
92 | 3 | public static function cannotJoinUserWithoutAGame(LocalizedUser $user) |
|
96 | |||
97 | /** |
||
98 | * @param LocalizedUser $user |
||
99 | * @return MessageParserException |
||
100 | */ |
||
101 | 3 | public static function cannotJoinYourself(LocalizedUser $user) |
|
105 | |||
106 | /** |
||
107 | * @param LocalizedUser $user |
||
108 | * @return MessageParserException |
||
109 | */ |
||
110 | 3 | public static function cannotJoinIfGameAlreadyRunning(LocalizedUser $user) |
|
114 | |||
115 | /** |
||
116 | * @param LocalizedUser $user |
||
117 | * @return MessageParserException |
||
118 | */ |
||
119 | 3 | public static function cannotParseMessage(LocalizedUser $user) |
|
123 | |||
124 | /** |
||
125 | * @param LocalizedUser $user |
||
126 | * @return MessageParserException |
||
127 | */ |
||
128 | 3 | public static function cannotStartGameUserIsNotIn(LocalizedUser $user) |
|
132 | |||
133 | /** |
||
134 | * @param LocalizedUser $user |
||
135 | * @return MessageParserException |
||
136 | */ |
||
137 | 3 | public static function cannotLeaveGameUserIsNotIn(LocalizedUser $user) |
|
141 | |||
142 | /** |
||
143 | * @param LocalizedUser $user |
||
144 | * @return MessageParserException |
||
145 | */ |
||
146 | 3 | public static function cannotFindGameForUser(LocalizedUser $user) |
|
154 | |||
155 | /** |
||
156 | * @param LocalizedUser $user |
||
157 | * @return MessageParserException |
||
158 | */ |
||
159 | 3 | public static function cannotCreateMultipleGames(LocalizedUser $user) |
|
163 | |||
164 | /** |
||
165 | * @param LocalizedUser $user |
||
166 | * @return MessageParserException |
||
167 | */ |
||
168 | 6 | public static function invalidUser(LocalizedUser $user) |
|
172 | } |
||
173 |