Skip to content

Commit 9922195

Browse files
authored
Merge pull request #26 from maartenpaauw/feature/add-dissatisfies-method-to-has-specifications-trait
Add dissatisfies method to has specifications trait
2 parents ea724b0 + 8bb0789 commit 9922195

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

src/HasSpecifications.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ public function satisfies(Specification $specification): bool
1414
return $specification->isSatisfiedBy($this);
1515
}
1616

17+
/**
18+
* @param Specification<self> $specification
19+
*/
20+
public function dissatisfies(Specification $specification): bool
21+
{
22+
return (new NotSpecification($specification))->isSatisfiedBy($this);
23+
}
24+
1725
/**
1826
* @deprecated use `satisfies()` instead
1927
*

tests/HasSpecificationsTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,8 @@ public function test_it_should_pass_the_candidate_to_the_specification(): void
2323
// Act + Assert
2424
$this->assertTrue($candidate->satisfies(new PositiveSpecification()));
2525
$this->assertFalse($candidate->satisfies(new NegativeSpecification()));
26+
27+
$this->assertFalse($candidate->dissatisfies(new PositiveSpecification()));
28+
$this->assertTrue($candidate->dissatisfies(new NegativeSpecification()));
2629
}
2730
}

0 commit comments

Comments
 (0)