Fields   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A filled() 0 3 1
A __construct() 0 5 1
A get() 0 3 1
A has() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiChef\RequestQueryHelper;
6
7
use Illuminate\Support\Collection;
8
9
class Fields
10
{
11
    private Collection $fields;
12
13
    public function __construct(array $fields)
14
    {
15 12
        $this->fields = collect($fields)
16
            ->mapWithKeys(function ($value, $key) {
17 12
                return [$key => explode(',', $value)];
18
            });
19 12
    }
20 12
21 12
    public function has($resourceName): bool
22
    {
23 6
        return $this->fields->has($resourceName);
24
    }
25 6
26
    public function get(string $resourceName): array
27
    {
28 6
        return $this->fields->get($resourceName, []);
29
    }
30 6
31
    public function filled(): bool
32
    {
33 3
        return $this->fields->isNotEmpty();
34
    }
35
}
36