| @@ 20-97 (lines=78) @@ | ||
| 17 | * |
|
| 18 | * @package RunOpenCode\Bundle\ExchangeRate\Event |
|
| 19 | */ |
|
| 20 | class FetchErrorEvent extends Event implements \IteratorAggregate, \ArrayAccess |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * @var array |
|
| 24 | */ |
|
| 25 | private $errors; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @var \DateTime |
|
| 29 | */ |
|
| 30 | private $date; |
|
| 31 | ||
| 32 | public function __construct(array $errors, \DateTime $date) |
|
| 33 | { |
|
| 34 | $this->errors = $errors; |
|
| 35 | $this->date = $date; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Get errors. |
|
| 40 | * |
|
| 41 | * @return array |
|
| 42 | */ |
|
| 43 | public function getErrors() |
|
| 44 | { |
|
| 45 | return $this->errors; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Get date for which rates are fetched. |
|
| 50 | * |
|
| 51 | * @return \DateTime |
|
| 52 | */ |
|
| 53 | public function getDate() |
|
| 54 | { |
|
| 55 | return $this->date; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * {@inheritdoc} |
|
| 60 | */ |
|
| 61 | public function getIterator() |
|
| 62 | { |
|
| 63 | return new \ArrayIterator($this->errors); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * {@inheritdoc} |
|
| 68 | */ |
|
| 69 | public function offsetExists($offset) |
|
| 70 | { |
|
| 71 | return isset($this->errors[$offset]); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * {@inheritdoc} |
|
| 76 | */ |
|
| 77 | public function offsetGet($offset) |
|
| 78 | { |
|
| 79 | return $this->errors[$offset]; |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * {@inheritdoc} |
|
| 84 | */ |
|
| 85 | public function offsetSet($offset, $value) |
|
| 86 | { |
|
| 87 | throw new LogicException(sprintf('Method "%s" of class "%s" can not be invoked in this context.', __FUNCTION__, __CLASS__)); |
|
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * {@inheritdoc} |
|
| 92 | */ |
|
| 93 | public function offsetUnset($offset) |
|
| 94 | { |
|
| 95 | throw new LogicException(sprintf('Method "%s" of class "%s" can not be invoked in this context.', __FUNCTION__, __CLASS__)); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||
| @@ 20-97 (lines=78) @@ | ||
| 17 | * |
|
| 18 | * @package RunOpenCode\Bundle\ExchangeRate\Event |
|
| 19 | */ |
|
| 20 | class FetchSuccessEvent extends Event implements \IteratorAggregate, \ArrayAccess |
|
| 21 | { |
|
| 22 | /** |
|
| 23 | * @var array |
|
| 24 | */ |
|
| 25 | private $rates; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @var \DateTime |
|
| 29 | */ |
|
| 30 | private $date; |
|
| 31 | ||
| 32 | public function __construct(array $rates, \DateTime $date) |
|
| 33 | { |
|
| 34 | $this->rates = $rates; |
|
| 35 | $this->date = $date; |
|
| 36 | } |
|
| 37 | ||
| 38 | /** |
|
| 39 | * Get fetched rates. |
|
| 40 | * |
|
| 41 | * @return array |
|
| 42 | */ |
|
| 43 | public function getRates() |
|
| 44 | { |
|
| 45 | return $this->rates; |
|
| 46 | } |
|
| 47 | ||
| 48 | /** |
|
| 49 | * Get date for which rates are fetched. |
|
| 50 | * |
|
| 51 | * @return \DateTime |
|
| 52 | */ |
|
| 53 | public function getDate() |
|
| 54 | { |
|
| 55 | return $this->date; |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * {@inheritdoc} |
|
| 60 | */ |
|
| 61 | public function getIterator() |
|
| 62 | { |
|
| 63 | return new \ArrayIterator($this->rates); |
|
| 64 | } |
|
| 65 | ||
| 66 | /** |
|
| 67 | * {@inheritdoc} |
|
| 68 | */ |
|
| 69 | public function offsetExists($offset) |
|
| 70 | { |
|
| 71 | return isset($this->rates[$offset]); |
|
| 72 | } |
|
| 73 | ||
| 74 | /** |
|
| 75 | * {@inheritdoc} |
|
| 76 | */ |
|
| 77 | public function offsetGet($offset) |
|
| 78 | { |
|
| 79 | return $this->rates[$offset]; |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * {@inheritdoc} |
|
| 84 | */ |
|
| 85 | public function offsetSet($offset, $value) |
|
| 86 | { |
|
| 87 | throw new LogicException(sprintf('Method "%s" of class "%s" can not be invoked in this context.', __FUNCTION__, __CLASS__)); |
|
| 88 | } |
|
| 89 | ||
| 90 | /** |
|
| 91 | * {@inheritdoc} |
|
| 92 | */ |
|
| 93 | public function offsetUnset($offset) |
|
| 94 | { |
|
| 95 | throw new LogicException(sprintf('Method "%s" of class "%s" can not be invoked in this context.', __FUNCTION__, __CLASS__)); |
|
| 96 | } |
|
| 97 | } |
|
| 98 | ||