1 | <?php |
||
20 | class Phrase |
||
21 | { |
||
22 | /** |
||
23 | * Default phrase renderer. Allows stacking renderers that "don't know about each other" |
||
24 | * |
||
25 | * @var RendererInterface |
||
26 | */ |
||
27 | private static $renderer; |
||
28 | |||
29 | /** |
||
30 | * String for rendering |
||
31 | * |
||
32 | * @var string |
||
33 | */ |
||
34 | private $text; |
||
35 | |||
36 | /** |
||
37 | * Arguments for placeholder values |
||
38 | * |
||
39 | * @var array |
||
40 | */ |
||
41 | private $arguments; |
||
42 | |||
43 | /** |
||
44 | * Set default Phrase renderer |
||
45 | * |
||
46 | * @param RendererInterface $renderer |
||
47 | * |
||
48 | * @return void |
||
49 | */ |
||
50 | public static function setRenderer(RendererInterface $renderer) |
||
54 | |||
55 | /** |
||
56 | * Get default Phrase renderer |
||
57 | * |
||
58 | * @return RendererInterface |
||
59 | */ |
||
60 | public static function getRenderer() |
||
67 | |||
68 | /** |
||
69 | * Phrase construct |
||
70 | * |
||
71 | * @param string $text |
||
72 | * @param array $arguments |
||
73 | */ |
||
74 | public function __construct($text, array $arguments = []) |
||
79 | |||
80 | /** |
||
81 | * Get phrase base text |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | public function getText() |
||
89 | |||
90 | /** |
||
91 | * Get phrase message arguments |
||
92 | * |
||
93 | * @return array |
||
94 | */ |
||
95 | public function getArguments() |
||
99 | |||
100 | /** |
||
101 | * Render phrase |
||
102 | * |
||
103 | * @return string |
||
104 | */ |
||
105 | public function render() |
||
113 | |||
114 | /** |
||
115 | * Defers rendering to the last possible moment (when converted to string) |
||
116 | * |
||
117 | * @return string |
||
118 | */ |
||
119 | public function __toString() |
||
123 | } |
||
124 |