Fields   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 20
rs 10
c 0
b 0
f 0

3 Methods

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