PreInsertObjectsEvent   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 76
Duplicated Lines 9.21 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 0
cbo 1
dl 7
loc 76
ccs 26
cts 26
cp 1
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1
A getPager() 0 4 1
A setPager() 0 4 1
A getOptions() 0 4 1
A setOptions() 0 4 1
A getObjectPersister() 0 4 1
A setObjectPersister() 0 4 1
A getObjects() 0 4 1
A setObjects() 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
/*
4
 * This file is part of the FOSElasticaBundle package.
5
 *
6
 * (c) FriendsOfSymfony <https://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\ElasticaBundle\Persister\Event;
13
14
use FOS\ElasticaBundle\Persister\ObjectPersisterInterface;
15
use FOS\ElasticaBundle\Provider\PagerInterface;
16
use Symfony\Contracts\EventDispatcher\Event;
17
18
final class PreInsertObjectsEvent extends Event implements PersistEvent
19
{
20
    /**
21
     * @var PagerInterface
22
     */
23
    private $pager;
24
25
    /**
26
     * @var ObjectPersisterInterface
27
     */
28
    private $objectPersister;
29
30
    /**
31
     * @var object[]
32
     */
33
    private $objects;
34
35
    /**
36
     * @var array
37
     */
38
    private $options;
39
40 23 View Code Duplication
    public function __construct(PagerInterface $pager, ObjectPersisterInterface $objectPersister, array $objects, array $options)
41
    {
42 23
        $this->pager = $pager;
43 23
        $this->objectPersister = $objectPersister;
44 23
        $this->objects = $objects;
45 23
        $this->options = $options;
46 23
    }
47
48 13
    public function getPager(): PagerInterface
49
    {
50 13
        return $this->pager;
51
    }
52
53 1
    public function setPager(PagerInterface $pager)
54
    {
55 1
        $this->pager = $pager;
56 1
    }
57
58 16
    public function getOptions(): array
59
    {
60 16
        return $this->options;
61
    }
62
63 1
    public function setOptions(array $options)
64
    {
65 1
        $this->options = $options;
66 1
    }
67
68 3
    public function getObjectPersister(): ObjectPersisterInterface
69
    {
70 3
        return $this->objectPersister;
71
    }
72
73 1
    public function setObjectPersister(ObjectPersisterInterface $objectPersister)
74
    {
75 1
        $this->objectPersister = $objectPersister;
76 1
    }
77
78
    /**
79
     * @return object[]
80
     */
81 16
    public function getObjects()
82
    {
83 16
        return $this->objects;
84
    }
85
86
    /**
87
     * @param object[] $objects
88
     */
89 3
    public function setObjects($objects)
90
    {
91 3
        $this->objects = $objects;
92 3
    }
93
}
94