Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
ValidatorFilterVar
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
5 / 5
5
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 setMsgContent
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 getValTester
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setValTester
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 testValue
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @author: Doug Wilbourne (dougwilbourne@gmail.com)
5 */
6declare(strict_types=1);
7
8namespace pvc\validator\validator;
9
10use pvc\interfaces\filtervar\FilterVarValidateInterface;
11use pvc\interfaces\msg\MsgInterface;
12use pvc\validator\Validator;
13
14/**
15 * Class ValidatorFilterVar
16 * @extends Validator<string>
17 */
18class ValidatorFilterVar extends Validator
19{
20    /**
21     * @var FilterVarValidateInterface
22     */
23    protected FilterVarValidateInterface $valTester;
24
25    /**
26     * @param MsgInterface $msg
27     * @param FilterVarValidateInterface $valTester
28     */
29    public function __construct(MsgInterface $msg, FilterVarValidateInterface $valTester)
30    {
31        parent::__construct($msg);
32        $this->setValTester($valTester);
33    }
34
35    /**
36     * setMsgContent
37     */
38    protected function setMsgContent(): void
39    {
40        $msgId = 'filter_var_test_failed';
41        $msgParameters = ['label' => $this->getValTester()->getLabel()];
42        $domain = 'Validator';
43        $this->getMsg()->setContent($domain, $msgId, $msgParameters);
44    }
45
46    /**
47     * getValTester
48     * @return FilterVarValidateInterface
49     */
50    public function getValTester(): FilterVarValidateInterface
51    {
52        return $this->valTester;
53    }
54
55    /**
56     * setValTester
57     * @param FilterVarValidateInterface $tester
58     */
59    public function setValTester(FilterVarValidateInterface $tester): void
60    {
61        $this->valTester = $tester;
62    }
63
64    /**
65     * testValue
66     * @param string $data
67     * @return bool
68     */
69    protected function testValue(mixed $data): bool
70    {
71        return $this->getValTester()->validate($data);
72    }
73}