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.

WritableEventCollection::toStreamData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
namespace EventStore;
3
4
use EventStore\Exception\InvalidWritableEventObjectException;
5
6
/**
7
 * Class WritableEventCollection
8
 * @package EventStore
9
 */
10
final class WritableEventCollection implements WritableToStream
11
{
12
    /**
13
     * @var WritableEvent[]
14
     */
15
    private $events = [];
16
17
    /**
18
     * @param array $events
19
     */
20 27
    public function __construct(array $events)
21
    {
22 27
        $this->validateEvents($events);
23 26
        $this->events = $events;
24 26
    }
25
26
    /**
27
     * @return array
28
     */
29
    public function toStreamData()
30
    {
31 26
        return array_map(function (WritableEvent $event) {
32 26
            return $event->toStreamData();
33 26
        }, $this->events);
34
    }
35
36
    /**
37
     * @param array $events
38
     */
39 27
    private function validateEvents(array $events)
40
    {
41 27
        foreach ($events as $event) {
42 27
            if (!$event instanceof WritableEvent) {
43 27
                throw new InvalidWritableEventObjectException();
44
            }
45
        }
46 26
    }
47
}
48