Functions.php 800 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * This file is part of Hyperf.
  5. *
  6. * @link https://www.hyperf.io
  7. * @document https://hyperf.wiki
  8. * @contact group@hyperf.io
  9. * @license https://github.com/hyperf/hyperf/blob/master/LICENSE
  10. */
  11. namespace Hyperf\Stringable;
  12. /**
  13. * Get a new stringable object from the given string.
  14. *
  15. * @param null|string $string
  16. * @return mixed|Stringable
  17. */
  18. function str($string = null)
  19. {
  20. if (func_num_args() === 0) {
  21. return new class() implements \Stringable {
  22. public function __call($method, $parameters)
  23. {
  24. return Str::$method(...$parameters);
  25. }
  26. public function __toString(): string
  27. {
  28. return '';
  29. }
  30. };
  31. }
  32. return Str::of($string);
  33. }