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   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 38
ccs 12
cts 12
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A toStreamData() 0 6 1
A validateEvents() 0 8 3
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