Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
RegexXMLElementName | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
12 / 12 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | /** |
3 | * @package: pvc |
4 | * @author: Doug Wilbourne (dougwilbourne@gmail.com) |
5 | */ |
6 | |
7 | declare(strict_types = 1); |
8 | |
9 | namespace pvc\regex\xml; |
10 | |
11 | use pvc\regex\Regex; |
12 | |
13 | /** |
14 | * Class RegexXMLElementName |
15 | */ |
16 | class RegexXMLElementName extends Regex |
17 | { |
18 | public function __construct() |
19 | { |
20 | $label = 'XMLElementName'; |
21 | |
22 | // use a look-ahead negative assertion so no characters are consumed, case-insensitive match |
23 | $pat_cannot_start_with_xml = '(?!(?i)xml)'; |
24 | |
25 | $pat_first_character_must_be_alpha = '[a-zA-Z]'; |
26 | |
27 | // "word" characters plus hyphen, period |
28 | $pat_contains_only_letters_digits_underscores_hyphens_periods_and_no_whitespace = '[\w\-\.]*'; |
29 | |
30 | $pattern = ''; |
31 | $pattern .= '/^'; |
32 | $pattern .= $pat_cannot_start_with_xml; |
33 | $pattern .= $pat_first_character_must_be_alpha; |
34 | $pattern .= $pat_contains_only_letters_digits_underscores_hyphens_periods_and_no_whitespace; |
35 | $pattern .= '$/'; |
36 | $this->setPattern($pattern); |
37 | $this->setLabel($label); |
38 | } |
39 | } |