Passed
Push — master ( 0235c3...d95c9b )
by Milroy
12:19
created

InteractWithQueryString   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 36
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A paginationParams() 0 3 1
A filters() 0 3 1
A includes() 0 3 1
A sorts() 0 3 1
A getQueryStringParams() 0 7 2
A fields() 0 3 1
1
<?php
2
3
namespace ApiChef\RequestToEloquent;
4
5
use ApiChef\RequestQueryHelper\Fields;
6
use ApiChef\RequestQueryHelper\PaginationParams;
7
use ApiChef\RequestQueryHelper\QueryParamBag;
8
use ApiChef\RequestQueryHelper\Sorts;
9
10
trait InteractWithQueryString
11
{
12
    private ?QueryStringParams $queryStringParams = null;
13
14
    private function getQueryStringParams(): QueryStringParams
15
    {
16
        if ($this->queryStringParams === null) {
17
            $this->queryStringParams = resolve(QueryStringParams::class);
18
        }
19
20
        return $this->queryStringParams;
21
    }
22
23
    private function paginationParams(): PaginationParams
24
    {
25
        return $this->getQueryStringParams()->paginationParams;
26
    }
27
28
    private function includes(): QueryParamBag
29
    {
30
        return $this->getQueryStringParams()->includes;
31
    }
32
33
    private function filters(): QueryParamBag
34
    {
35
        return $this->getQueryStringParams()->filters;
36
    }
37
38
    private function sorts(): Sorts
39
    {
40
        return $this->getQueryStringParams()->sorts;
41
    }
42
43
    private function fields(): Fields
44
    {
45
        return $this->getQueryStringParams()->fields;
46
    }
47
}
48