Completed
Push — master ( 870cb1...1f9632 )
by Milroy
07:07 queued 05:53
created

Fields   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 22
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A has() 0 4 1
A get() 0 4 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