Skip to content

Commit 1010597

Browse files
Add logic condition identification
1 parent 503bdb9 commit 1010597

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

src/Config/Condition.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,16 @@ public function __construct(string $exec, array $args = [])
4848
$this->args = $args;
4949
}
5050

51+
/**
52+
* Check if this condition is a logic condition
53+
*
54+
* @return bool
55+
*/
56+
public function isLogicCondition(): bool
57+
{
58+
return in_array(strtoupper($this->exec), ['OR', 'AND']);
59+
}
60+
5161
/**
5262
* Exec getter
5363
*

tests/unit/Config/ConditionTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,16 @@ public function testGetEmptyArgs(): void
2828

2929
$this->assertEquals([], $config->getArgs());
3030
}
31+
32+
public function testCanIdentifyLogicConditions(): void
33+
{
34+
$config1 = new Condition('OR');
35+
$this->assertTrue($config1->isLogicCondition());
36+
37+
$config2 = new Condition('AND');
38+
$this->assertTrue($config2->isLogicCondition());
39+
40+
$config3 = new Condition('\\Foo\\Bar');
41+
$this->assertFalse($config3->isLogicCondition());
42+
}
3143
}

0 commit comments

Comments
 (0)