Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
RegexIdName
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @author: Doug Wilbourne (dougwilbourne@gmail.com)
5 */
6declare(strict_types=1);
7
8namespace pvc\html\val_tester\regex;
9
10use pvc\regex\Regex;
11
12/**
13 * Class RegexIdName
14 * From the w3 spec:
15 * ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]),
16 * hyphens ("-"), underscores ("_"), colons (":"), and periods (".")
17 */
18class RegexIdName extends Regex
19{
20
21    public function __construct()
22    {
23        $label = 'idOrName';
24        $pattern = '/^(?=.*[a-zA-Z])[a-zA-Z0-9\-_\.]*$/';
25        $this->setPattern($pattern);
26        $this->setLabel($label);
27    }
28}