unique() public static method

Get unique string
public static unique ( string $prefix = 'unique' ) : string
$prefix string
return string
Beispiel #1
0
 public function testUnique()
 {
     is(15, strlen(Str::unique()));
     is(8, strlen(Str::unique(null)));
     is(10, strlen(Str::unique('t-')));
     isNotSame(Str::unique(), Str::unique());
 }
Beispiel #2
0
 /**
  * Generates an HTML checkbox/radio list.
  *
  * @param array $options
  * @param string $name
  * @param array $selected
  * @param string|array $attrs
  * @param bool $tpl
  * @return string
  */
 public function render(array $options, $name, $selected = array(), array $attrs = array(), $tpl = false)
 {
     $output = array();
     $this->_setTpl($tpl);
     foreach ($options as $value => $label) {
         $label = trim($label);
         $id = Str::unique($this->_type . '-');
         $value = $this->_cleanValue($value);
         $text = $this->_translate($label);
         $attrs = $this->_checkedOptions($value, $selected, $attrs);
         $output[] = $this->_elementTpl($name, $value, $id, $text, $attrs);
     }
     return implode(PHP_EOL, $output);
 }