UrnValidator::validate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace AlgoWeb\xsdTypes\AxillaryClasses;
4
5
class UrnValidator
6
{
7
    const URN_REGEXP = '/^urn:[a-z0-9][a-z0-9-]{1,31}:([a-z0-9()+,-.:=@;$_!*\']|%(0[1-9a-f]|[1-9a-f][0-9a-f]))+$/i';
8
9
    /**
10
     * Validate a URN according to RFC 2141.
11
     *
12
     * @param string $urn the URN to validate
13
     *
14
     * @return bool TRUE when the URN is valid, FALSE when invalid
15
     */
16
    public static function validate($urn)
17
    {
18
        return (bool)preg_match(self::URN_REGEXP, $urn);
19
    }
20
}
21