Passed
Push — b0.3.0 ( e78733...cae81f )
by Sebastian
02:50
created

AbstractCustom   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 44
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getMessage() 0 3 1
1
<?php
2
3
/**
4
 * Linna Filter
5
 *
6
 * @author Sebastian Rapetti <[email protected]>
7
 * @copyright (c) 2018, Sebastian Rapetti
8
 * @license http://opensource.org/licenses/MIT MIT License
9
 */
10
declare(strict_types=1);
11
12
namespace Linna\Filter\Rules;
13
14
use Closure;
15
16
/**
17
 * Abstract Custom
18
 */
19
abstract class AbstractCustom
20
{
21
    /**
22
     * @var array Rule properties
23
     */
24
    public $config = [
25
        'full_class' => '',
26
        'alias' => [],
27
        'args_count' => 0,
28
        'args_type' => [],
29
    ];
30
31
    /**
32
     * @var string Error message
33
     */
34
    protected $message = '';
35
36
    /**
37
     * @var Closure Rule custom function for validate or sanitize.
38
     */
39
    protected $callback;
40
41
    /**
42
     * Class Constructor.
43
     *
44
     * @param Closure $callback
45
     * @param array   $config
46
     * @param string  $message
47
     */
48 7
    public function __construct(Closure $callback, array $config, string $message)
49
    {
50 7
        $this->callback = $callback;
51 7
        $this->config = $config;
52 7
        $this->message = $message;
53 7
    }
54
55
    /**
56
     * Return error message.
57
     *
58
     * @return string Error message
59
     */
60 2
    public function getMessage(): string
61
    {
62 2
        return $this->message;
63
    }
64
}
65