Passed
Push — master ( 32cb6d...84b76e )
by Sergey
04:44
created

DnsZoneDomainNameValidator::validate()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * @author: Viskov Sergey
4
 * @date  : 4/12/16
5
 * @time  : 1:00 PM
6
 */
7
8
namespace LTDBeget\dns\configurator\validators;
9
10
/**
11
 * Class DnsZoneDomainNameValidator
12
 *
13
 * @package beget\lib\dns\lib\validators
14
 */
15
class DnsZoneDomainNameValidator
16
{
17
    /**
18
     * @param $hostname
19
     * @return bool
20
     */
21 1
    public static function validate(string $hostname) : bool 
22
    {
23 1
        $hostname = preg_replace('/^\*\./', '', $hostname);
24 1
        if(in_array($hostname, ['@', '*', '.'])) {
25 1
            return true;
26
        }
27
28 1
        return OriginValidator::validate($hostname);
29
    }
30
}
31