Fields   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 50
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addField() 0 4 1
A get() 0 4 1
A types() 0 4 1
A members() 0 4 2
A isEmpty() 0 4 1
1
<?php
2
/**
3
 * Author: Nil Portugués Calderó <[email protected]>
4
 * Date: 12/14/15
5
 * Time: 7:13 PM.
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace NilPortugues\Api\JsonApi\Http\Request\Parameters;
11
12
class Fields
13
{
14
    /**
15
     * @var array
16
     */
17
    protected $fields = [];
18
19
    /**
20
     * @param string $type
21
     * @param string $fieldName
22
     */
23
    public function addField($type, $fieldName)
24
    {
25
        $this->fields[(string) $type][] = (string) $fieldName;
26
    }
27
28
    /**
29
     * @return array
30
     */
31
    public function get()
32
    {
33
        return $this->fields;
34
    }
35
36
    /**
37
     * @return string[]
38
     */
39
    public function types()
40
    {
41
        return array_keys($this->fields);
42
    }
43
44
    /**
45
     * @param string $type
46
     *
47
     * @return array
48
     */
49
    public function members($type)
50
    {
51
        return (array_key_exists($type, $this->fields)) ? $this->fields[$type] : [];
52
    }
53
54
    /**
55
     * @return bool
56
     */
57
    public function isEmpty()
58
    {
59
        return 0 === count($this->fields);
60
    }
61
}
62