1 | <?php |
||
13 | class MessageFileLanguage { |
||
14 | |||
15 | /** |
||
16 | * The path to the folder to be loaded |
||
17 | * @var string |
||
18 | */ |
||
19 | private $folder; |
||
20 | |||
21 | /** |
||
22 | * The array of messages in the folder loaded. |
||
23 | * @var array<string, string> |
||
24 | */ |
||
25 | private $msg = []; |
||
26 | |||
27 | /** |
||
28 | * Language load |
||
29 | * @var string |
||
30 | */ |
||
31 | private $language = null; |
||
32 | |||
33 | /** |
||
34 | * Loads all message for a language |
||
35 | * @param string $folder |
||
36 | * @param string $language |
||
37 | */ |
||
38 | public function __construct($folder, $language) { |
||
46 | |||
47 | /** |
||
48 | * Saves the file for current language |
||
49 | */ |
||
50 | public function save() { |
||
84 | |||
85 | /** |
||
86 | * Delete file of language (Delete language too) |
||
87 | * @param $language string Language to delete |
||
88 | */ |
||
89 | private function deleteFile() { |
||
94 | |||
95 | /** |
||
96 | * Set message for a key |
||
97 | * @param $key string Message key |
||
98 | * @param $message string Message |
||
99 | */ |
||
100 | public function setMessage($key, $message) { |
||
103 | |||
104 | /** |
||
105 | * Sets messages |
||
106 | * |
||
107 | * @param $translations array<string, string> To set many messages in one time. The array is key message. |
||
108 | */ |
||
109 | public function setMessages(array $translations) { |
||
116 | |||
117 | /** |
||
118 | * Returns a message for the key $key. |
||
119 | * @var $key string Key of translation search. |
||
120 | */ |
||
121 | public function getMessage($key) { |
||
128 | |||
129 | /** |
||
130 | * Sets the message |
||
131 | * @var $key Remove a message for key |
||
132 | */ |
||
133 | public function deleteMessage($key) { |
||
141 | |||
142 | /** |
||
143 | * Returns all messages for this file. |
||
144 | * @return array<string, string> Return the array of message (key, value) |
||
145 | */ |
||
146 | public function getAllMessages() { |
||
149 | } |
||
150 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.