Completed
Push — master ( aca90e...8ef0e7 )
by Alejandro
10s
created

InputFactoryTrait::createInput()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
ccs 6
cts 6
cp 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Shlinkio\Shlink\Core\Validation;
5
6
use Zend\Filter\StringTrim;
7
use Zend\Filter\StripTags;
8
use Zend\InputFilter\Input;
9
10
trait InputFactoryTrait
11
{
12 7
    public function createInput($name, $required = true): Input
13
    {
14 7
        $input = new Input($name);
15 7
        $input->setRequired($required)
16 7
              ->getFilterChain()->attach(new StripTags())
17 7
                                ->attach(new StringTrim());
18 7
        return $input;
19
    }
20
}
21