DiscussionFilter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 44
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getInputFilter() 0 34 2
A setInputFilter() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Article\Filter;
6
7
use Zend\InputFilter\InputFilter;
8
use Zend\InputFilter\InputFilterAwareInterface;
9
use Zend\InputFilter\InputFilterInterface;
10
11
class DiscussionFilter implements InputFilterAwareInterface
12
{
13
    protected $inputFilter;
14
15
    public function getInputFilter()
16
    {
17
        if (!$this->inputFilter) {
18
            $inputFilter = new InputFilter();
19
20
            $inputFilter->add(
21
                [
22
                    'name'       => 'title',
23
                    'required'   => true,
24
                    'filters'    => [['name' => 'StringTrim']],
25
                    'validators' => [
26
                        ['name' => 'NotEmpty'],
27
                        ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 100]],
28
                    ],
29
                ]
30
            );
31
32
            $inputFilter->add(
33
                [
34
                    'name'       => 'body',
35
                    'required'   => true,
36
                    'filters'    => [['name' => 'StringTrim']],
37
                    'validators' => [
38
                        ['name' => 'NotEmpty'],
39
                        ['name' => 'StringLength', 'options' => ['min' => 2, 'max' => 1500]],
40
                    ],
41
                ]
42
            );
43
44
            $this->inputFilter = $inputFilter;
45
        }
46
47
        return $this->inputFilter;
48
    }
49
50
    public function setInputFilter(InputFilterInterface $inputFilter)
51
    {
52
        throw new \Exception('Not used');
53
    }
54
}
55