1 | <?php |
||
13 | class Formatter implements FormatterInterface |
||
14 | { |
||
15 | /** |
||
16 | * @var Match |
||
17 | */ |
||
18 | protected $match; |
||
19 | |||
20 | public function __construct() |
||
21 | { |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * {@inheritdoc} |
||
26 | * |
||
27 | * @return Match |
||
28 | */ |
||
29 | public function getMatch() |
||
33 | |||
34 | /** |
||
35 | * {@inheritdoc} |
||
36 | * |
||
37 | * @param Match $match |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function setMatch(Match $match) |
||
46 | |||
47 | /** |
||
48 | * {@inheritdoc} |
||
49 | * |
||
50 | * @param TemplateInterface $template |
||
51 | * @return mixed|string |
||
52 | */ |
||
53 | public function getMessage(TemplateInterface $template) |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | * |
||
71 | * @param mixed $obj |
||
72 | * @return string |
||
73 | */ |
||
74 | public function objectToString($obj) |
||
75 | { |
||
76 | switch (gettype($obj)) { |
||
77 | case 'boolean': |
||
78 | return var_export($obj, true); |
||
79 | |||
80 | case 'NULL': |
||
81 | return 'null'; |
||
82 | |||
83 | case 'string': |
||
84 | return '"' . $obj . '"'; |
||
85 | } |
||
86 | |||
87 | return rtrim(print_r($obj, true)); |
||
88 | } |
||
89 | |||
90 | /** |
||
91 | * Applies match results to other template variables. |
||
92 | * |
||
93 | * @param TemplateInterface $template |
||
94 | * @return array |
||
95 | */ |
||
96 | protected function getTemplateVars(TemplateInterface $template) |
||
109 | } |
||
110 |