1 | <?php |
||
55 | class Actionable |
||
56 | { |
||
57 | /** |
||
58 | * the callable code that we represent |
||
59 | * @var callable |
||
60 | */ |
||
61 | private $action; |
||
62 | |||
63 | /** |
||
64 | * the full path to the file where $action's code is defined |
||
65 | * @var string |
||
66 | */ |
||
67 | private $sourceFilename; |
||
68 | |||
69 | /** |
||
70 | * a (possibly empty) list of tags that describe this Actionable |
||
71 | * |
||
72 | * @var array |
||
73 | */ |
||
74 | private $tags = []; |
||
75 | |||
76 | /** |
||
77 | * constructor |
||
78 | * |
||
79 | * @param callable $action |
||
80 | * the callable code that we represent |
||
81 | * @param string $sourceFilename |
||
82 | * the full path to the file where $action's code is defined |
||
83 | * @param array $tags |
||
84 | * a list of tags that describe this Actionable |
||
85 | */ |
||
86 | public function __construct(callable $action, $sourceFilename, $tags = []) |
||
92 | |||
93 | /** |
||
94 | * execute this callable |
||
95 | * |
||
96 | * @param array $params |
||
97 | * the parameters to pass into our callable |
||
98 | * @return mixed |
||
99 | * returns whatever our callable returns |
||
100 | */ |
||
101 | public function __invoke(array $params) |
||
105 | |||
106 | /** |
||
107 | * what is the full path to the PHP file where the action's code is defined? |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function getSourceFilename() |
||
115 | |||
116 | /** |
||
117 | * what is the full list of this Actionable's tags? |
||
118 | * |
||
119 | * @return array |
||
120 | */ |
||
121 | public function getTags() |
||
125 | |||
126 | /** |
||
127 | * does this Actionable have a specific tag? |
||
128 | * |
||
129 | * @param string $tagName |
||
130 | * the tag that we want to check for |
||
131 | * @return boolean |
||
132 | * TRUE if we have this tag |
||
133 | * FALSE otherwise |
||
134 | */ |
||
135 | public function hasTag($tagName) |
||
139 | } |
||
140 |