Fields::filled()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
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