1 | <?php |
||
24 | class Art |
||
25 | { |
||
26 | /** |
||
27 | * @param Exception $exception |
||
28 | * @return string |
||
29 | */ |
||
30 | public static function forException(Exception $exception) |
||
31 | { |
||
32 | return self::calculateArt(get_class($exception), $exception->getMessage()); |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * @param string $className |
||
37 | * @param string $message |
||
38 | * @return string |
||
39 | */ |
||
40 | private static function calculateArt($className, $message) |
||
46 | |||
47 | /** |
||
48 | * Strip variable arguments from exception messages. |
||
49 | * |
||
50 | * Some exception messages are formatted using sprintf, and result in a |
||
51 | * unique art-code for each distinct message. In order for the art-code to |
||
52 | * be useful it must be the same for each distinct error situation without |
||
53 | * taking into account variable parts of the message. |
||
54 | * |
||
55 | * This method strips all strings inside quotes. This is not perfect |
||
56 | * because it relies on sprintf arguments to always be quoted inside the |
||
57 | * message. |
||
58 | * |
||
59 | * @param $message |
||
60 | * @return string |
||
61 | */ |
||
62 | private static function stripVariableArgumentsFromMessage($message) |
||
66 | } |
||
67 |