Event::getVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace EventStore\StreamFeed;
3
4
/**
5
 * Class Event
6
 * @package EventStore\StreamFeed
7
 */
8
final class Event
9
{
10
    /**
11
     * @var string
12
     */
13
    private $type;
14
15
    /**
16
     * @var integer
17
     */
18
    private $version;
19
20
    /**
21
     * @var array
22
     */
23
    private $data;
24
25
    /**
26
     * @var array
27
     */
28
    private $metadata;
29
30
    /**
31
     * @param string  $type
32
     * @param integer $version
33
     * @param array   $data
34
     * @param array   $metadata
35
     */
36 9
    public function __construct($type, $version, array $data, array $metadata = null)
37
    {
38 9
        $this->type = $type;
39 9
        $this->version = (integer) $version;
40 9
        $this->data = $data;
41 9
        $this->metadata = $metadata;
0 ignored issues
show
Documentation Bug introduced by
It seems like $metadata can be null. However, the property $metadata 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...
42 9
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getType()
48
    {
49
        return $this->type;
50
    }
51
52
    /**
53
     * @return integer
54
     */
55 3
    public function getVersion()
56
    {
57 3
        return $this->version;
58
    }
59
60
    /**
61
     * @return array
62
     */
63 3
    public function getData()
64
    {
65 3
        return $this->data;
66
    }
67
68
    /**
69
     * @return array
70
     */
71 3
    public function getMetadata()
72
    {
73 3
        return $this->metadata;
74
    }
75
}
76