Skip to content

Commit

Permalink
Class Assert: new PHPYAM_SPRINTF_REPLACEMENT option to redefine the
Browse files Browse the repository at this point in the history
print function used in the isTrue() and isFalse() methods
  • Loading branch information
tbl0605 committed Nov 4, 2024
1 parent 5e601c5 commit 2cbdb25
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/libs/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public final static function isFalse($expression)
throw new AssertException($args[0]);
break;
default:
throw new AssertException(call_user_func_array('sprintf', $args));
$callable = Store::get('PHPYAM_SPRINTF_REPLACEMENT', null);
throw new AssertException(call_user_func_array(is_callable($callable) ? $callable : 'sprintf', $args));
break;
}
}
Expand Down Expand Up @@ -105,7 +106,8 @@ public final static function isTrue($expression)
throw new AssertException($args[0]);
break;
default:
throw new AssertException(call_user_func_array('sprintf', $args));
$callable = Store::get('PHPYAM_SPRINTF_REPLACEMENT', null);
throw new AssertException(call_user_func_array(is_callable($callable) ? $callable : 'sprintf', $args));
break;
}
}
Expand Down

0 comments on commit 2cbdb25

Please sign in to comment.