Completed
Push — master ( 51b986...23baca )
by Simonas
103:55 queued 96:58
created

CommitEvent::setCommitMode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
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 ONGR\ElasticsearchBundle\Event;
13
14
use Symfony\Component\EventDispatcher\Event;
15
16
class CommitEvent extends Event
17
{
18
    /**
19
     * @var string
20
     */
21
    private $commitMode;
22
23
    /**
24
     * @var array
25
     */
26
    private $bulkParams;
27
28
    /**
29
     * @param string $commitMode
30
     * @param array|null  $bulkParams BulkQueries or BulkResponse, depending on event
31
     */
32
    public function __construct($commitMode, $bulkParams = [])
33
    {
34
        $this->commitMode = $commitMode;
35
        $this->bulkParams = $bulkParams;
0 ignored issues
show
Documentation Bug introduced by
It seems like $bulkParams can be null. However, the property $bulkParams is declared as array. Maybe change the type of the property to array|null or add a type check?

Our type inference engine has found an assignment of a scalar value (like a string, an integer or null) to a property which is an array.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.

To type hint that a parameter can be either an array or null, you can set a type hint of array and a default value of null. The PHP interpreter will then accept both an array or null for that parameter.

function aContainsB(array $needle = null, array  $haystack) {
    if (!$needle) {
        return false;
    }

    return array_intersect($haystack, $needle) == $haystack;
}

The function can be called with either null or an array for the parameter $needle but will only accept an array as $haystack.

Loading history...
36
    }
37
38
    /**
39
     * Returns commit mode
40
     *
41
     * @return string
42
     */
43
    public function getCommitMode()
44
    {
45
        return $this->commitMode;
46
    }
47
48
    /**
49
     * @param string $commitMode
50
     */
51
    public function setCommitMode($commitMode)
52
    {
53
        $this->commitMode = $commitMode;
54
    }
55
56
    /**
57
     * Returns params
58
     *
59
     * @return array
60
     */
61
    public function getBulkParams()
62
    {
63
        return $this->bulkParams;
64
    }
65
66
    /**
67
     * @param array $bulkParams
68
     */
69
    public function setBulkParams($bulkParams)
70
    {
71
        $this->bulkParams = $bulkParams;
72
    }
73
}
74