BaseController   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 30
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMainService() 0 4 1
A translateFilters() 0 12 3
A filterRequest() 0 4 1
1
<?php
2
3
namespace Bludata\Lumen\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use Laravel\Lumen\Routing\Controller;
7
8
abstract class BaseController extends Controller
9
{
10
    /**
11
     * @var Bludata\Lumen\Services\BaseService
12
     */
13
    protected $mainService;
14
15
    public function getMainService()
16
    {
17
        return $this->mainService;
18
    }
19
20
    protected function translateFilters($filters)
21
    {
22
        if ($filters instanceof Request) {
23
            if ($filters->has('filters')) {
24
                $filters = json_decode(base64_decode($filters->input('filters')), true);
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $filters. This often makes code more readable.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 80 characters; contains 88 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
25
            } else {
26
                $filters = [];
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $filters. This often makes code more readable.
Loading history...
27
            }
28
        }
29
30
        return $filters;
31
    }
32
33
    public function filterRequest($allInputs, $only)
34
    {
35
        return array_intersect_key($allInputs, array_flip($only));
36
    }
37
}
38