IdnHostname   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 5
c 1
b 0
f 0
dl 0
loc 15
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A validationError() 0 7 3
1
<?php
2
3
namespace Swaggest\JsonSchema\Constraint\Format;
4
5
class IdnHostname
6
{
7
    /**
8
     * @see http://www.unicode.org/faq/idn.html
9
     * @see https://gist.github.com/rxu/0660eef7a2f9e7992db6
10
     * @param string $data
11
     * @return null|string
12
     */
13 4
    public static function validationError($data)
14
    {
15 4
        $error = Iri::unicodeValidationError($data, $sanitized);
16 4
        if ($error !== null) {
17 2
            return $error;
18
        }
19 2
        return preg_match(Uri::HOSTNAME_REGEX, $sanitized) ? null : 'Invalid idn-hostname: ' . $data;
20
    }
21
}