]> git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/intl/Symfony/Component/Intl/ResourceBundle/Util/ArrayAccessibleResourceBundle.php
twig implementation
[github/wallabag/wallabag.git] / vendor / symfony / intl / Symfony / Component / Intl / ResourceBundle / Util / ArrayAccessibleResourceBundle.php
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Intl\ResourceBundle\Util;
13
14 use Symfony\Component\Intl\Exception\BadMethodCallException;
15
16 /**
17 * Work-around for a bug in PHP's \ResourceBundle implementation.
18 *
19 * More information can be found on https://bugs.php.net/bug.php?id=64356.
20 * This class can be removed once that bug is fixed.
21 *
22 * @author Bernhard Schussek <bschussek@gmail.com>
23 */
24 class ArrayAccessibleResourceBundle implements \ArrayAccess, \IteratorAggregate, \Countable
25 {
26 private $bundleImpl;
27
28 public function __construct(\ResourceBundle $bundleImpl)
29 {
30 $this->bundleImpl = $bundleImpl;
31 }
32
33 public function get($offset, $fallback = null)
34 {
35 $value = $this->bundleImpl->get($offset, $fallback);
36
37 return $value instanceof \ResourceBundle ? new static($value) : $value;
38 }
39
40 public function offsetExists($offset)
41 {
42 return null !== $this->bundleImpl[$offset];
43 }
44
45 public function offsetGet($offset)
46 {
47 return $this->get($offset);
48 }
49
50 public function offsetSet($offset, $value)
51 {
52 throw new BadMethodCallException('Resource bundles cannot be modified.');
53 }
54
55 public function offsetUnset($offset)
56 {
57 throw new BadMethodCallException('Resource bundles cannot be modified.');
58 }
59
60 public function getIterator()
61 {
62 return $this->bundleImpl;
63 }
64
65 public function count()
66 {
67 return $this->bundleImpl->count();
68 }
69
70 public function getErrorCode()
71 {
72 return $this->bundleImpl->getErrorCode();
73 }
74
75 public function getErrorMessage()
76 {
77 return $this->bundleImpl->getErrorMessage();
78 }
79 }