Completed
Push — master ( 3543bf...07ac7e )
by Nikola
12:28
created

FetchErrorEvent::getErrors()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/*
3
 * This file is part of the Exchange Rate Bundle, an RunOpenCode project.
4
 *
5
 * (c) 2017 RunOpenCode
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace RunOpenCode\Bundle\ExchangeRate\Event;
11
12
use RunOpenCode\Bundle\ExchangeRate\Exception\LogicException;
13
use Symfony\Component\EventDispatcher\Event;
14
15
/**
16
 * Class FetchErrorEvent
17
 *
18
 * @package RunOpenCode\Bundle\ExchangeRate\Event
19
 */
20 View Code Duplication
class FetchErrorEvent extends Event implements \IteratorAggregate, \ArrayAccess
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
21
{
22
    /**
23
     * @var array
24
     */
25
    private $errors;
26
27
    /**
28
     * @var \DateTime
29
     */
30
    private $date;
31
32 2
    public function __construct(array $errors, \DateTime $date)
33
    {
34 2
        $this->errors = $errors;
35 2
        $this->date = $date;
36 2
    }
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 1
    public function offsetGet($offset)
78
    {
79 1
        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