diff --git a/src/Rules/Because.php b/src/Rules/Because.php index 198c772a..539ac97a 100644 --- a/src/Rules/Because.php +++ b/src/Rules/Because.php @@ -3,6 +3,7 @@ namespace Arkitect\Rules; +use Arkitect\Expression\Expression; use Arkitect\Rules\DSL\ArchRule; use Arkitect\Rules\DSL\BecauseParser; @@ -22,4 +23,11 @@ public function because(string $reason): ArchRule return $this->ruleBuilder->build(); } + + public function andShould(Expression $expression): BecauseParser + { + $this->ruleBuilder->addShould($expression); + + return $this; + } } diff --git a/src/Rules/DSL/BecauseParser.php b/src/Rules/DSL/BecauseParser.php index ca9aa280..87a54097 100644 --- a/src/Rules/DSL/BecauseParser.php +++ b/src/Rules/DSL/BecauseParser.php @@ -3,7 +3,11 @@ namespace Arkitect\Rules\DSL; +use Arkitect\Expression\Expression; + interface BecauseParser { public function because(string $reason): ArchRule; + + public function andShould(Expression $expression): self; } diff --git a/tests/E2E/PHPUnit/CheckClassWithMultipleExpressionsTest.php b/tests/E2E/PHPUnit/CheckClassWithMultipleExpressionsTest.php new file mode 100644 index 00000000..8c7c588c --- /dev/null +++ b/tests/E2E/PHPUnit/CheckClassWithMultipleExpressionsTest.php @@ -0,0 +1,36 @@ +that(new ResideInOneOfTheseNamespaces('App\BadCode')) + ->andThat(new ResideInOneOfTheseNamespaces('App\HappyIsland')) + ->should(new IsNotFinal()) + ->andShould(new IsNotReadonly()) + ->andShould(new IsNotAbstract()) + ->andShould(new IsNotEnum()) + ->andShould(new IsNotInterface()) + ->andShould(new IsNotTrait()) + ->because('some reason'); + + ArchRuleTestCase::assertArchRule($rule, $set); + } +}