Collection::getName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * Object data collection
4
 */
5
6
namespace Asiries335\redisSteamPhp\Data;
7
8
9
final class Collection implements DataInterface
10
{
11
    /**
12
     * Name collection
13
     *
14
     * @var string
15
     */
16
    private $_name;
17
18
    /**
19
     * Messages collection
20
     *
21
     * @var array
22
     */
23
    private $_messages;
24
25
    /**
26
     * Collection create
27
     *
28
     * @param array $data Data collection
29
     *
30
     * @return static
31
     */
32 1
    public static function create(array $data) : self
33
    {
34 1
        $collection = new self();
35
36 1
        $collection->_name = $data[0][0] ?? null;
37
38 1
        foreach ($data[0][1] as $item) {
39 1
            $collection->_messages[] = Message::create($item);
40
        }
41
42 1
        return $collection;
43
    }
44
45
    /**
46
     * Get name collection
47
     *
48
     * @return string
49
     */
50
    public function getName() : string
51
    {
52
        return $this->_name;
53
    }
54
55
    /**
56
     * Get messages collection
57
     *
58
     * @return array
59
     */
60
    public function getMessages() : array
61
    {
62
        return $this->_messages;
63
    }
64
}