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
RegexAlphaNumeric
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 * @package: pvc
4 * @author: Doug Wilbourne (dougwilbourne@gmail.com)
5 */
6
7declare(strict_types = 1);
8
9namespace pvc\regex\unicode;
10
11use pvc\regex\Regex;
12
13/**
14 * Class RegexAlphaNumeric
15 */
16class RegexAlphaNumeric extends Regex
17{
18
19    /**
20     * RegexAlphanumeric constructor.
21     *
22     * we want letters represented as a single code point as well as letters modified by trailing
23     * combining marks.  So we verify that the first letter in the subpattern is a letter and that
24     * when the remaining code points in the subpattern are marks.
25     *
26     * Numbers also have a subtlety, because there are numbers, decimal numbers, letter numbers and
27     * 'other numbers'.  This expression is using decimal numbers.
28     *
29     */
30    public function __construct()
31    {
32        $label = 'alphabetic text (only letters)';
33        /**
34         * the u modifier tells the engine to treat the subject and the pattern as UTF-8
35         */
36        $pattern = '/^((\p{L}\p{M}*)|\p{Nd})*$/u';
37        $this->setPattern($pattern);
38        $this->setLabel($label);
39    }
40}