StreamFeed   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 65
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 6
c 5
b 0
f 1
lcom 1
cbo 3
dl 0
loc 65
ccs 18
cts 18
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntryEmbedMode() 0 4 1
A getJson() 0 4 1
A getLinks() 0 4 1
A __construct() 0 9 2
A getEntries() 0 9 1
1
<?php
2
namespace EventStore\StreamFeed;
3
4
/**
5
 * Class StreamFeed
6
 * @package EventStore\StreamFeed
7
 */
8
final class StreamFeed
9
{
10
    use HasLinks;
11
12
    /**
13
     * @var array
14
     */
15
    private $json;
16
17
    /**
18
     * @var EntryEmbedMode
19
     */
20
    private $entryEmbedMode;
21
22
    /**
23
     * @param array          $jsonFeed
24
     * @param EntryEmbedMode $embedMode
25
     */
26 24
    public function __construct(array $jsonFeed, EntryEmbedMode $embedMode = null)
27
    {
28 24
        if ($embedMode === null) {
29 20
            $embedMode = EntryEmbedMode::NONE();
30
        }
31
32 24
        $this->entryEmbedMode = $embedMode;
33 24
        $this->json           = $jsonFeed;
34 24
    }
35
36
    /**
37
     * @return Entry[]
38
     */
39 11
    public function getEntries()
40
    {
41 11
        return array_map(
42 11
            function (array $jsonEntry) {
43 11
                return new Entry($jsonEntry);
44 11
            },
45 11
            $this->json['entries']
46
        );
47
    }
48
49
    /**
50
     * @return EntryEmbedMode
51
     */
52 11
    public function getEntryEmbedMode()
53
    {
54 11
        return $this->entryEmbedMode;
55
    }
56
57
    /**
58
     * @return array
59
     */
60 3
    public function getJson()
61
    {
62 3
        return $this->json;
63
    }
64
65
    /**
66
     * @return array
67
     */
68 13
    protected function getLinks()
69
    {
70 13
        return $this->json['links'];
71
    }
72
}
73