Passed
Push — main ( 48c7ef...34571b )
by Breno
01:46
created

Cep   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 21
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A maskPattern() 0 3 1
A __construct() 0 3 1
A unmaskedLength() 0 3 1
A isValidDocument() 0 3 1
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt\Validation\Rules\Brazilian;
5
6
use Attribute;
7
use BrenoRoosevelt\Validation\Rules\Document;
8
9
#[Attribute(Attribute::TARGET_PROPERTY)]
10
class Cep extends Document
11
{
12
    public function __construct(bool $mask = true, ?string $message = 'CEP inválido')
13
    {
14
        parent::__construct($mask, $message);
15
    }
16
17
    public function isValidDocument(string $input): bool
18
    {
19
        return $this->validateNumbersWithCorrectLength($input);
20
    }
21
22
    public function maskPattern(): string
23
    {
24
        return '/^[0-9]{5}\-[0-9]{3}$/';
25
    }
26
27
    public function unmaskedLength(): int
28
    {
29
        return 9;
30
    }
31
}
32