Completed
Pull Request — master (#264)
by Luc
27:18 queued 22:30
created

CopyEvent   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 31.37 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 1
dl 16
loc 51
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 16 16 2
A getOriginalEventId() 0 4 1
A getCalendar() 0 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
namespace CultuurNet\UDB3\Event\Commands;
4
5
use CultuurNet\UDB3\CalendarInterface;
6
use CultuurNet\UDB3\Offer\Commands\AbstractCommand;
7
8
class CopyEvent extends AbstractCommand
9
{
10
    /**
11
     * @var string
12
     */
13
    private $originalEventId;
14
15
    /**
16
     * @var CalendarInterface
17
     */
18
    private $calendar;
19
20
    /**
21
     * CopyEvent constructor.
22
     * @param string $eventId
23
     * @param string $originalEventId
24
     * @param CalendarInterface $calendar
25
     */
26 View Code Duplication
    public function __construct(
0 ignored issues
show
Duplication introduced by
This method 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...
27
        $eventId,
28
        $originalEventId,
29
        CalendarInterface $calendar
30
    ) {
31
        parent::__construct($eventId);
32
33
        if (!is_string($originalEventId)) {
34
            throw new \InvalidArgumentException(
35
                'Expected originalEventId to be a string, received ' . gettype($originalEventId)
36
            );
37
        }
38
39
        $this->originalEventId = $originalEventId;
40
        $this->calendar = $calendar;
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function getOriginalEventId()
47
    {
48
        return $this->originalEventId;
49
    }
50
51
    /**
52
     * @return CalendarInterface
53
     */
54
    public function getCalendar()
55
    {
56
        return $this->calendar;
57
    }
58
}
59