File tree Expand file tree Collapse file tree 1 file changed +33
-6
lines changed Expand file tree Collapse file tree 1 file changed +33
-6
lines changed Original file line number Diff line number Diff line change @@ -51,16 +51,17 @@ use Maartenpaauw\Specifications\Specification;
5151 */
5252class AdultSpecification implements Specification
5353{
54+ /**
55+ * @inheritDoc
56+ */
5457 public function isSatisfiedBy(mixed $candidate): bool
5558 {
56- return $candidate->age >= 18 ;
59+ return true ;
5760 }
5861}
5962```
6063
61- After implementing the business logic, you can use it in various ways.
62-
63- imagine we have the following class which represents a person with a given age.
64+ Imagine we have the following class which represents a person with a given age.
6465
6566``` php
6667class Person {
@@ -69,8 +70,34 @@ class Person {
6970}
7071```
7172
72- Now we can use the specification by ** directly** calling the ` isSatisfiedBy ` method
73- or ** indirectly** be filtering an eloquent collection by calling the ` matching ` method.
73+ Let's apply the business logic:
74+
75+ ``` diff
76+ <?php
77+
78+ namespace App\Specifications;
79+
80+ use Maartenpaauw\Specifications\Specification;
81+
82+ /**
83+ - * @implements Specification<mixed>
84+ + * @implements Specification<Person>
85+ */
86+ class AdultSpecification implements Specification
87+ {
88+ /**
89+ * @inheritDoc
90+ */
91+ public function isSatisfiedBy(mixed $candidate): bool
92+ {
93+ - return true;
94+ + return $candidate->age >= 18;
95+ }
96+ }
97+ ```
98+
99+ After applying the bussiness logic we can use the specification by ** directly** calling the ` isSatisfiedBy `
100+ method or ** indirectly** be filtering an eloquent collection by calling the ` matching ` method.
74101
75102### Direct
76103
You can’t perform that action at this time.
0 commit comments