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

FetchErrorEvent   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 33.33%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 78
loc 78
ccs 6
cts 18
cp 0.3333
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 5 5 1
A getErrors() 4 4 1
A getDate() 4 4 1
A getIterator() 4 4 1
A offsetExists() 4 4 1
A offsetGet() 4 4 1
A offsetSet() 4 4 1
A offsetUnset() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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