Person::rules()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace yiibr\brvalidator\tests;
4
5
use yii\base\Model;
6
use yiibr\brvalidator\CnpjValidator;
7
8
/**
9
 * DocumentValidatorTest
10
 */
11
class DocumentValidatorTest extends TestCase
12
{
13
    public function testValidateValue()
14
    {
15
        $person = new Person([
16
            'docnumber' => '1!@#$%¨&*()_-+2"`´[]?\/;, 3'
17
        ]);
18
19
        $person->validate();
20
        $this->assertEquals('123', $person->docnumber);
21
    }
22
}
23
24
25
class Person extends Model {
26
27
    public $docnumber;
28
29
    public function rules()
30
    {
31
        return [
32
            [['docnumber'], CnpjValidator::class, 'digitsOnly' => true]
33
        ];
34
    }
35
}
36