Callback   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 2 1
A __construct() 0 3 1
A validate() 0 2 1
1
<?php
2
3
namespace Logikos\Util\Validation\Validator;
4
5
6
use Logikos\Util\Validation\Validator;
7
8
class Callback implements Validator {
9
  /**
10
   * @var callable
11
   */
12
  private $callable;
13
  private $description;
14
15 12
  public function __construct(callable $callable, $description) {
16 12
    $this->callable    = $callable;
17 12
    $this->description = $description;
18 12
  }
19
20 2
  public function getDescription() {
21 2
    return $this->description;
22
  }
23
24 6
  public function validate($value) : bool {
25 6
    return call_user_func($this->callable, $value);
26
  }
27
}