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

Fields::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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