Event   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 85.71%

Importance

Changes 6
Bugs 0 Features 2
Metric Value
wmc 5
c 6
b 0
f 2
lcom 0
cbo 0
dl 0
loc 68
ccs 12
cts 14
cp 0.8571
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A getType() 0 4 1
A getVersion() 0 4 1
A getData() 0 4 1
A getMetadata() 0 4 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