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 |
TemplateParameterName.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 * Template parameter name rules:
14 * - must start with a letter or an underscore
15 * - can only contain letters, numbers and underscores
16 *
17 * This is much more restrictive than the XSL specs
18 */
19 abstract class TemplateParameterName
20 {
21 /**
22 * Return whether a string is a valid parameter name
23 *
24 * @param string $name Parameter name
25 * @return bool
26 */
27 public static function isValid($name)
28 {
29 return (bool) preg_match('#^[a-z_][-a-z_0-9]*$#Di', $name);
30 }
31
32 /**
33 * Normalize a template parameter name
34 *
35 * @param string $name Original name
36 * @return string Normalized name
37 */
38 public static function normalize($name)
39 {
40 $name = (string) $name;
41
42 if (!static::isValid($name))
43 {
44 throw new InvalidArgumentException("Invalid parameter name '" . $name . "'");
45 }
46
47 return $name;
48 }
49 }