Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
TagName.php
01 <?php
02
03 /**
04 * @package s9e\TextFormatter
05 * @copyright Copyright (c) 2010-2022 The s9e authors
06 * @license http://www.opensource.org/licenses/mit-license.php The MIT License
07 */
08 namespace s9e\TextFormatter\Configurator\Validators;
09
10 use InvalidArgumentException;
11
12 /**
13 * Tag name rules:
14 * - must start with a letter or an underscore
15 * - can only contain letters, numbers, dashes and underscores
16 * - can be prefixed with one prefix following the same rules, separated with one colon
17 * - the prefixes "xsl" and "s9e" are reserved
18 *
19 * Unprefixed names are normalized to uppercase. Prefixed names are preserved as-is.
20 */
21 abstract class TagName
22 {
23 /**
24 * Return whether a string is a valid tag name
25 *
26 * @param string $name
27 * @return bool
28 */
29 public static function isValid($name)
30 {
31 return (bool) preg_match('#^(?:(?!xmlns|xsl|s9e)[a-z_][a-z_0-9]*:)?[a-z_][-a-z_0-9]*$#Di', $name);
32 }
33
34 /**
35 * Normalize a tag name
36 *
37 * @throws InvalidArgumentException if the original name is not valid
38 *
39 * @param string $name Original name
40 * @return string Normalized name
41 */
42 public static function normalize($name)
43 {
44 if (!static::isValid($name))
45 {
46 throw new InvalidArgumentException("Invalid tag name '" . $name . "'");
47 }
48
49 // Non-namespaced tags are uppercased
50 if (strpos($name, ':') === false)
51 {
52 $name = strtoupper($name);
53 }
54
55 return $name;
56 }
57 }