1 | <?php |
||
23 | abstract class LanguageAdapter implements ArrayAccess |
||
24 | { |
||
25 | /** @var array Array with strings */ |
||
26 | protected $strings = array(); |
||
27 | |||
28 | /** |
||
29 | * Sets a parameter |
||
30 | * |
||
31 | * @param string $id |
||
32 | * @param string $value |
||
33 | */ |
||
34 | 2 | public function offsetSet($id, $value) |
|
38 | |||
39 | /** |
||
40 | * Gets a parameter |
||
41 | * |
||
42 | * @param string $id |
||
43 | * @return string |
||
44 | * |
||
45 | * @throws InvalidArgumentException if the id is not defined |
||
46 | */ |
||
47 | 24 | public function offsetGet($id) |
|
48 | { |
||
49 | 24 | if (!array_key_exists($id, $this->strings)) { |
|
50 | 2 | throw new InvalidArgumentException($id . ' is not defined'); |
|
51 | } |
||
52 | |||
53 | 22 | return $this->strings[$id]; |
|
54 | } |
||
55 | |||
56 | /** |
||
57 | * Checks if a parameter is set. |
||
58 | * |
||
59 | * @param string $id |
||
60 | * @return bool |
||
61 | */ |
||
62 | 4 | public function offsetExists($id) |
|
66 | |||
67 | /** |
||
68 | * Unsets a parameter |
||
69 | * |
||
70 | * @param string $id |
||
71 | * @return void |
||
72 | */ |
||
73 | 2 | public function offsetUnset($id) |
|
77 | |||
78 | /** |
||
79 | * Returns all defined keys |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | 2 | public function keys() |
|
87 | } |
||
88 | |||
90 |
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.
A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.