HtmlString.php 1.0 KB

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