Skip to content

Commit 0fb0b09

Browse files
committed
make BaseElement::unless() compatible with Conditionable::unless()
1 parent 48dec96 commit 0fb0b09

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/BaseElement.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
abstract class BaseElement implements Htmlable, HtmlElement
1717
{
18-
use Conditionable;
18+
use Conditionable {
19+
unless as trait_unless;
20+
}
1921

2022
use Macroable {
2123
__call as __macro_call;
@@ -332,13 +334,18 @@ public function if(bool $condition, \Closure $callback)
332334
* Conditionally transform the element. Note that since elements are
333335
* immutable, you'll need to return a new instance from the callback.
334336
*
335-
* @param bool $condition
336-
* @param \Closure $callback
337+
* @param mixed $condition
338+
* @param callable $callback
339+
* @param callable|null $default
337340
*
338341
* @return mixed
339342
*/
340-
public function unless(bool $condition, \Closure $callback)
343+
public function unless($condition, callable $callback, callable|null $default = null)
341344
{
345+
if (! is_bool($condition) || ! $callback instanceof \Closure || ! is_null($default)) {
346+
return $this->trait_unless($condition, $callback, $default);
347+
}
348+
342349
return $this->if(! $condition, $callback);
343350
}
344351

0 commit comments

Comments
 (0)