v1.php 882 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'label' . DS . 'v1.php';
  4. class statusLabel extends label
  5. {
  6. /**
  7. * @var mixed[]
  8. */
  9. protected static $defineProps = array
  10. (
  11. 'text?:string',
  12. 'status?: string'
  13. );
  14. public function build()
  15. {
  16. list($text, $status) = $this->prop(array('text', 'status'));
  17. return span
  18. (
  19. setClass($status ? "status-$status" : 'status'),
  20. set($this->getRestProps()),
  21. $text,
  22. $this->children()
  23. );
  24. }
  25. /**
  26. * @param mixed ...$children
  27. * @return $this
  28. * @param string $status
  29. * @param string $text
  30. */
  31. public static function create($status, $text, ...$children)
  32. {
  33. $props = array('status' => $status, 'text' => $text);
  34. return new static(set($props), ...$children);
  35. }
  36. }