diff --git a/src/FuncCondition.php b/src/FuncCondition.php index 64387a5..d857f94 100644 --- a/src/FuncCondition.php +++ b/src/FuncCondition.php @@ -13,6 +13,11 @@ public function __construct(callable $func) $this->_func = $func; } + public static function i(callable $func) + { + return new static($func); + } + public function match(Context $context): bool { return ($this->_func)($context); diff --git a/tests/FuncConditionTest.php b/tests/FuncConditionTest.php index 6731533..429ca91 100644 --- a/tests/FuncConditionTest.php +++ b/tests/FuncConditionTest.php @@ -30,6 +30,6 @@ public function testInstance() { $c = $this->_makeContext(); self::assertTrue((new FuncCondition(function (Context $ctx) { return $ctx->meta()->has('a'); }))->match($c)); - self::assertFalse((new FuncCondition(function (Context $ctx) { return $ctx->meta()->has('b'); }))->match($c)); + self::assertFalse((FuncCondition::i(function (Context $ctx) { return $ctx->meta()->has('b'); }))->match($c)); } }