Completed
Pull Request — master (#1333)
by Maksim
04:20
created

PostAsyncInsertObjectsEvent   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 10.53 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 8
loc 76
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 8 8 1
A getPager() 0 4 1
A getOptions() 0 4 1
A getObjectPersister() 0 4 1
A getErrorMessage() 0 4 1
A getObjectsCount() 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
namespace FOS\ElasticaBundle\Persister\Event;
3
4
use FOS\ElasticaBundle\Persister\ObjectPersisterInterface;
5
use FOS\ElasticaBundle\Provider\PagerInterface;
6
use Symfony\Component\EventDispatcher\Event;
7
8
final class PostAsyncInsertObjectsEvent extends Event implements PersistEvent
9
{
10
    /**
11
     * @var PagerInterface
12
     */
13
    private $pager;
14
15
    /**
16
     * @var ObjectPersisterInterface
17
     */
18
    private $objectPersister;
19
20
    /**
21
     * @var int
22
     */
23
    private $objectsCount;
24
25
    /**
26
     * @var string|null
27
     */
28
    private $errorMessage;
29
30
    /**
31
     * @var array
32
     */
33
    private $options;
34
35 6 View Code Duplication
    public function __construct(PagerInterface $pager, ObjectPersisterInterface $objectPersister, $objectsCount, $errorMessage, array $options)
36
    {
37 6
        $this->pager = $pager;
38 6
        $this->objectPersister = $objectPersister;
39 6
        $this->objectsCount = $objectsCount;
40 6
        $this->errorMessage = $errorMessage;
41 6
        $this->options = $options;
42 6
    }
43
44
    /**
45
     * @return PagerInterface
46
     */
47 1
    public function getPager()
48
    {
49 1
        return $this->pager;
50
    }
51
52
    /**
53
     * @return array
54
     */
55 1
    public function getOptions()
56
    {
57 1
        return $this->options;
58
    }
59
60
    /**
61
     * @return ObjectPersisterInterface
62
     */
63 1
    public function getObjectPersister()
64
    {
65 1
        return $this->objectPersister;
66
    }
67
68
    /**
69
     * @return null|string
70
     */
71 1
    public function getErrorMessage()
72
    {
73 1
        return $this->errorMessage;
74
    }
75
76
    /**
77
     * @return int
78
     */
79 1
    public function getObjectsCount()
80
    {
81 1
        return $this->objectsCount;
82
    }
83
}