Skip to content

Commit

Permalink
fixed bug undefined function str()
Browse files Browse the repository at this point in the history
  • Loading branch information
mavinoo committed Sep 17, 2024
1 parent 457a6d8 commit de84512
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/Common/Helpers.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?php declare(strict_types=1);
<?php

declare(strict_types=1);

use Illuminate\Support\Str;

if (!function_exists('batch')) {
/**
Expand All @@ -11,3 +15,31 @@ function batch()
return app('Mavinoo\Batch\Batch');
}
}

if (!function_exists('str')) {
/**
* Get a new stringable object from the given string.
*
* @param string|null $string
*
* @return \Illuminate\Support\Stringable|mixed
*/
function str($string = null)
{
if (func_num_args() === 0) {
return new class {
public function __call($method, $parameters)
{
return Str::$method(...$parameters);
}

public function __toString()
{
return '';
}
};
}

return Str::of($string);
}
}

0 comments on commit de84512

Please sign in to comment.