Completed
Push — master ( 494025...63e9a9 )
by Joshua
14s queued 11s
created

Collection::getMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the -SeamsCMSDeliverySdk package.
7
 *
8
 * (c) Seams-CMS.com
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace SeamsCMS\Delivery\Model;
15
16
use SeamsCMS\Delivery\Exception\MissingFieldsException;
17
18
/**
19
 * Class Collection
20
 * @package SeamsCMS\Delivery\Model
21
 */
22
abstract class Collection
23
{
24
    use HydratorTrait {
25
        fromArray as private fromArrayTrait;
26
    }
27
28
    /** @var array */
29
    protected $entries;
30
31
    /** @var CollectionMeta */
32
    protected $meta;
33
34
35
    /**
36
     * Collection constructor.
37
     *
38
     */
39 9
    protected function __construct()
40
    {
41 9
    }
42
43
    /**
44
     * @return array
45
     */
46 3
    public function getEntries(): array
47
    {
48 3
        return $this->entries;
49
    }
50
51
    /**
52
     * @return CollectionMeta
53
     */
54 1
    public function getMeta(): CollectionMeta
55
    {
56 1
        return $this->meta;
57
    }
58
59
    /**
60
     * @param array $data
61
     * @return mixed
62
     */
63 10
    public static function fromArray(array $data)
64
    {
65 10
        if (! isset($data['meta'])) {
66 1
            throw MissingFieldsException::metaNotFound();
67
        }
68
69 9
        $data['meta'] = CollectionMeta::fromArray($data['meta']);
70
71 9
        return self::fromArrayTrait($data);
72
    }
73
}
74