Callback::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 3
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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
}