Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
44.44% |
4 / 9 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
| exception | |
44.44% |
4 / 9 |
|
25.00% |
1 / 4 |
6.74 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| __toString | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getParameters | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getLocalisedMessage | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * |
| 4 | * This file is part of the phpBB Forum Software package. |
| 5 | * |
| 6 | * @copyright (c) phpBB Limited <https://www.phpbb.com> |
| 7 | * @license GNU General Public License, version 2 (GPL-2.0) |
| 8 | * |
| 9 | * For full copyright and license information, please see |
| 10 | * the docs/CREDITS.txt file. |
| 11 | * |
| 12 | */ |
| 13 | |
| 14 | namespace phpbb\db\migration; |
| 15 | |
| 16 | /** |
| 17 | * The migrator is responsible for applying new migrations in the correct order. |
| 18 | */ |
| 19 | class exception extends \Exception |
| 20 | { |
| 21 | /** |
| 22 | * Extra parameters sent to exception to aid in debugging |
| 23 | * @var array |
| 24 | */ |
| 25 | protected $parameters; |
| 26 | |
| 27 | /** |
| 28 | * Throw an exception. |
| 29 | * |
| 30 | * First argument is the error message. |
| 31 | * Additional arguments will be output with the error message. |
| 32 | */ |
| 33 | public function __construct() |
| 34 | { |
| 35 | $parameters = func_get_args(); |
| 36 | $message = array_shift($parameters); |
| 37 | parent::__construct($message); |
| 38 | |
| 39 | $this->parameters = $parameters; |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Output the error as a string |
| 44 | * |
| 45 | * @return string |
| 46 | */ |
| 47 | public function __toString(): string |
| 48 | { |
| 49 | return $this->message . ': ' . var_export($this->parameters, true); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Get the parameters |
| 54 | * |
| 55 | * @return array |
| 56 | */ |
| 57 | public function getParameters() |
| 58 | { |
| 59 | return $this->parameters; |
| 60 | } |
| 61 | |
| 62 | /** |
| 63 | * Get localised message (with $user->lang()) |
| 64 | * |
| 65 | * @param \phpbb\user $user |
| 66 | * @return string |
| 67 | */ |
| 68 | public function getLocalisedMessage(\phpbb\user $user) |
| 69 | { |
| 70 | $parameters = $this->getParameters(); |
| 71 | array_unshift($parameters, $this->getMessage()); |
| 72 | |
| 73 | return call_user_func_array(array($user, 'lang'), $parameters); |
| 74 | } |
| 75 | } |