Passed
Push — 4 ( 34eb17...84b405 )
by Robbie
08:27 queued 12s
created

TestValidator::getForm()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\Forms\Tests\ValidatorTest;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\Forms\Form;
7
use SilverStripe\Forms\Validator;
8
9
class TestValidator extends Validator implements TestOnly
10
{
11
12
    /**
13
     * Requires a specific field for test purposes.
14
     *
15
     * @param array $data
16
     * @return null
17
     */
18
    public function php($data)
19
    {
20
        foreach ($data as $field => $data) {
0 ignored issues
show
introduced by
$data is overwriting one of the parameters of this function.
Loading history...
21
            $this->validationError($field, 'error');
22
        }
23
24
        return null;
25
    }
26
27
    /**
28
     * Allow us to access the form for test purposes.
29
     *
30
     * @return Form|null
31
     */
32
    public function getForm(): ?Form
33
    {
34
        return $this->form;
35
    }
36
}
37