GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

WritableEvent::newInstance()   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 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 3
crap 1
1
<?php
2
namespace EventStore;
3
4
use EventStore\ValueObjects\Identity\UUID;
5
6
/**
7
 * Class WritableEvent
8
 * @package EventStore
9
 */
10
final class WritableEvent implements WritableToStream
11
{
12
    /**
13
     * @var UUID
14
     */
15
    private $uuid;
16
17
    /**
18
     * @var string
19
     */
20
    private $type;
21
22
    /**
23
     * @var array
24
     */
25
    private $data;
26
27
    /**
28
     * @var array
29
     */
30
    private $metadata;
31
32
    /**
33
     * @param  string        $type
34
     * @param  array         $data
35
     * @param  array         $metadata
36
     * @return WritableEvent
37
     */
38 25
    public static function newInstance($type, array $data, array $metadata = [])
39
    {
40 25
        return new self(new UUID(), $type, $data, $metadata);
41
    }
42
43
    /**
44
     * @param UUID   $uuid
45
     * @param string $type
46
     * @param array  $data
47
     * @param array  $metadata
48
     */
49 27
    public function __construct(UUID $uuid, $type, array $data, array $metadata = [])
50
    {
51 27
        $this->uuid = $uuid;
52 27
        $this->type = $type;
53 27
        $this->data = $data;
54 27
        $this->metadata = $metadata;
55 27
    }
56
57
    /**
58
     * @return array
59
     */
60 27
    public function toStreamData()
61
    {
62
        return [
63 27
            'eventId'   => $this->uuid->toNative(),
64 27
            'eventType' => $this->type,
65 27
            'data'      => $this->data,
66 27
            'metadata'  => $this->metadata
67
        ];
68
    }
69
}
70