Completed
Branch master (ffe81d)
by Neomerx
04:33
created

EncodingParameters::isEmpty()   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 5
nc 5
nop 0
crap 5
1
<?php namespace Neomerx\JsonApi\Encoder\Parameters;
2
3
/**
4
 * Copyright 2015-2018 [email protected]
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 * http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
18
19
use Neomerx\JsonApi\Contracts\Encoder\Parameters\EncodingParametersInterface;
20
use Neomerx\JsonApi\Factories\Exceptions;
21
22
/**
23
 * @package Neomerx\JsonApi
24
 */
25
class EncodingParameters implements EncodingParametersInterface
26
{
27
    /**
28
     * @var array|null
29
     */
30
    private $includePaths;
31
32
    /**
33
     * @var array|null
34
     */
35
    private $fieldSets;
36
37
    /**
38
     * @param string[]|null $includePaths
39
     * @param array|null    $fieldSets
40
     */
41 73
    public function __construct(array $includePaths = null, array $fieldSets = null)
42
    {
43 73
        $this->fieldSets    = $fieldSets;
44 73
        $this->includePaths = $includePaths;
45 73
    }
46
47
    /**
48
     * @inheritdoc
49
     */
50 66
    public function getIncludePaths(): ?array
51
    {
52 66
        return $this->includePaths;
53
    }
54
55
    /**
56
     * @inheritdoc
57
     */
58 4
    public function getFieldSets(): ?array
59
    {
60 4
        return $this->fieldSets;
61
    }
62
63
    /**
64
     * @inheritdoc
65
     *
66
     * @SuppressWarnings(PHPMD.StaticAccess)
67
     */
68 61
    public function getFieldSet(string $type): ?array
69
    {
70 61
        is_string($type) === true ?: Exceptions::throwInvalidArgument('type', $type);
71
72 61
        return (isset($this->fieldSets[$type]) === true ? $this->fieldSets[$type] : null);
73
    }
74
}
75