1<?php 2 3 4namespace ComboStrap; 5 6 7class Html 8{ 9 10 11 /** 12 * @param string $name 13 * @throws ExceptionComboRuntime 14 * Garbage In / Garbage Out design 15 */ 16 public static function validNameGuard(string $name) 17 { 18 /** 19 * If the name is not in lowercase, 20 * the shorthand css selector does not work 21 */ 22 $validName = strtolower($name); 23 if ($validName != $name) { 24 throw new ExceptionComboRuntime("The name ($name) is not a valid name"); 25 } 26 } 27 28 /** 29 * Transform a text into a valid HTML id 30 * @param $string 31 * @return string 32 */ 33 public static function toHtmlId($string): string 34 { 35 /** 36 * sectionId calls cleanID 37 * cleanID delete all things before a ':' 38 * we do then the replace before to not 39 * lost a minus '-' separator 40 */ 41 $string = str_replace(array(':', '.'), '', $string); 42 return sectionID($string, $check); 43 } 44} 45