4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Intl\ResourceBundle\Util
;
14 use Symfony\Component\Intl\Exception\BadMethodCallException
;
17 * Work-around for a bug in PHP's \ResourceBundle implementation.
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.
22 * @author Bernhard Schussek <bschussek@gmail.com>
24 class ArrayAccessibleResourceBundle
implements \ArrayAccess
, \IteratorAggregate
, \Countable
28 public function __construct(\ResourceBundle
$bundleImpl)
30 $this->bundleImpl
= $bundleImpl;
33 public function get($offset, $fallback = null)
35 $value = $this->bundleImpl
->get($offset, $fallback);
37 return $value instanceof \ResourceBundle
? new static($value) : $value;
40 public function offsetExists($offset)
42 return null !== $this->bundleImpl
[$offset];
45 public function offsetGet($offset)
47 return $this->get($offset);
50 public function offsetSet($offset, $value)
52 throw new BadMethodCallException('Resource bundles cannot be modified.');
55 public function offsetUnset($offset)
57 throw new BadMethodCallException('Resource bundles cannot be modified.');
60 public function getIterator()
62 return $this->bundleImpl
;
65 public function count()
67 return $this->bundleImpl
->count();
70 public function getErrorCode()
72 return $this->bundleImpl
->getErrorCode();
75 public function getErrorMessage()
77 return $this->bundleImpl
->getErrorMessage();