Completed
Pull Request — master (#64)
by Daniel
02:07
created

FilterBar   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 30
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getForm() 0 4 1
A getUrlParametersForFilter() 0 6 1
A getFilterUrlParameters() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\Grid\View;
6
7
use Psi\Component\Grid\GridContext;
8
use Symfony\Component\Form\FormView;
9
10
class FilterBar
11
{
12
    private $form;
13
    private $options;
14
15
    public function __construct(FormView $form, GridContext $options)
16
    {
17
        $this->form = $form;
18
        $this->options = $options;
19
    }
20
21
    public function getForm(): FormView
22
    {
23
        return $this->form;
24
    }
25
26
    public function getUrlParametersForFilter()
27
    {
28
        return array_filter($this->options->getUrlParameters(), function ($key) {
29
            return $key !== 'filter';
30
        }, ARRAY_FILTER_USE_KEY);
31
    }
32
33
    public function getFilterUrlParameters()
34
    {
35
        return array_filter($this->options->getUrlParameters(), function ($key) {
36
            return $key === 'filter';
37
        }, ARRAY_FILTER_USE_KEY);
38
    }
39
}
40