Completed
Push — master ( 2811d3...4b37a8 )
by Shcherbak
11:11
created

CallableStringValidator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 0
loc 19
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A validate() 0 4 1
1
<?php
2
3
  declare(strict_types=1);
4
5
  namespace Fiv\Form\Validation\StringValidation;
6
7
  use Fiv\Form\Elements\StringDataElementInterface;
8
  use Fiv\Form\Validation\ValidationResultInterface;
9
10
  class CallableStringValidator implements StringValidatorInterface {
11
12
    /**
13
     * @var callable
14
     */
15
    private $callable;
16
17
18 2
    public function __construct(callable $callable) {
19 2
      $this->callable = $callable;
20 2
    }
21
22
23 2
    public function validate(StringDataElementInterface $element) : ValidationResultInterface {
24 2
      $validator = $this->callable;
25 2
      return $validator($element);
26
    }
27
28
  }