Completed
Pull Request — master (#210)
by ignace nyamagana
02:08
created

CallableValidatorAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
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 25
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A validate() 0 4 1
1
<?php
2
/**
3
* This file is part of the League.csv library
4
*
5
* @license http://opensource.org/licenses/MIT
6
* @link https://github.com/thephpleague/csv/
7
* @version 9.0.0
8
* @package League.csv
9
*
10
* For the full copyright and license information, please view the LICENSE
11
* file that was distributed with this source code.
12
*/
13
declare(strict_types=1);
14
15
namespace League\Csv\Plugin;
16
17
use League\Csv\RecordValidatorInterface as RecordValidator;
18
19
/**
20
 * An Adapter Class to convert a callable into
21
 * a RecordValidatorInterface implementing object
22
 *
23
 * @package League.csv
24
 * @since   9.0.0
25
 * @author  Ignace Nyamagana Butera <[email protected]>
26
 */
27
class CallableValidatorAdapter implements RecordValidator
28
{
29
    /**
30
     * @var callable
31
     */
32
    protected $callable;
33
34
    /**
35
     * New instance
36
     *
37
     * @param callable $callable
38
     */
39 2
    public function __construct(callable $callable)
40
    {
41 2
        $this->callable = $callable;
42 2
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47 2
    public function validate(array $record): bool
48
    {
49 2
        return ($this->callable)($record);
50
    }
51
}
52