CallableStringValidator::validate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 3
nc 1
nop 1
crap 2
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
    public function __construct(callable $callable) {
19
      $this->callable = $callable;
20
    }
21
22
23
    public function validate(StringDataElementInterface $element) : ValidationResultInterface {
24
      $validator = $this->callable;
25
      return $validator($element);
26
    }
27
28
  }