HtmlString.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. namespace Illuminate\Support;
  3. use Illuminate\Contracts\Support\Htmlable;
  4. use Stringable;
  5. class HtmlString implements Htmlable, Stringable
  6. {
  7. /**
  8. * The HTML string.
  9. *
  10. * @var string
  11. */
  12. protected $html;
  13. /**
  14. * Create a new HTML string instance.
  15. *
  16. * @param string $html
  17. * @return void
  18. */
  19. public function __construct($html = '')
  20. {
  21. $this->html = $html;
  22. }
  23. /**
  24. * Get the HTML string.
  25. *
  26. * @return string
  27. */
  28. public function toHtml()
  29. {
  30. return $this->html;
  31. }
  32. /**
  33. * Determine if the given HTML string is empty.
  34. *
  35. * @return bool
  36. */
  37. public function isEmpty()
  38. {
  39. return $this->html === '';
  40. }
  41. /**
  42. * Determine if the given HTML string is not empty.
  43. *
  44. * @return bool
  45. */
  46. public function isNotEmpty()
  47. {
  48. return ! $this->isEmpty();
  49. }
  50. /**
  51. * Get the HTML string.
  52. *
  53. * @return string
  54. */
  55. public function __toString()
  56. {
  57. return $this->toHtml();
  58. }
  59. }