1 <?php
 2 
 3 
 4 
 5 // Requires a "filter/validator" (Create, Update)
 6 abstract class FilteringAction
 7 {
 8     public function __construct(
 9         Payload $payload,
10         Gateway $gateway,
11         Filter $filter
12     ) {
13         $this->payload = $payload;
14         $this->gateway = $gateway;
15         $this->filter = $filter;
16     }
17 }
18 
19 // These dont (Read, Index, Delete)
20 abstract class Action
21 {
22     public function __construct(
23         Payload $payload,
24         Gateway $gateway
25     ) {
26         $this->payload = $payload;
27         $this->gateway = $gateway;
28     }
29 }
30 
31 
32 // Create and Update need a filter to say...
33 // make sure required fields validate etc
34 class Create extends FilteringAction
35 {
36     public function __invoke($input)
37     {
38         if (! $this->filter($input)) {
39             // bad stuff didnt validate
40         }
41         // ...
42     }
43 }
44 
45 // Delete, Read, and Index dont validate the input the same.
46 // They may check for existance of an entity, etc, but not filter an input array
47 // and validate it with that same logic
48 class Delete extends Action
49 {
50 
51     public function __invoke($input)
52     {
53         // Doesnt need a filter like that
54     }
55 }