[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * @package s9e\TextFormatter 5 * @copyright Copyright (c) 2010-2022 The s9e authors 6 * @license http://www.opensource.org/licenses/mit-license.php The MIT License 7 */ 8 namespace s9e\TextFormatter\Configurator\Validators; 9 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 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |