Bristol SU Support Package
Module.php
Go to the documentation of this file.
1 <?php
2 
4 
7 
11 class Module implements ModuleContract
12 {
18  protected $alias;
24  protected $name;
30  protected $description;
36  protected $permissions;
42  protected $settings;
54  protected $triggers;
66  protected $services;
67 
73  protected $for;
74 
88 
96  public function setFor(string $for = 'user')
97  {
98  $this->for = $for;
99  }
100 
106  public function getFor(): string
107  {
108  return ($this->for ?? 'user');
109  }
110 
116  public function __toString()
117  {
118  return $this->toJson();
119  }
120 
127  public function toJson($options = 0)
128  {
129  return json_encode($this->toArray(), $options);
130  }
131 
149  public function toArray()
150  {
151  return [
152  'alias' => $this->getAlias(),
153  'name' => $this->getName(),
154  'description' => $this->getDescription(),
155  'permissions' => $this->getPermissions(),
156  'settings' => $this->getSettings(),
157  'triggers' => $this->getTriggers(),
158  'completionConditions' => $this->getCompletionConditions(),
159  'services' => $this->getServices(),
160  'for' => $this->getFor()
161  ];
162  }
163 
169  public function getAlias(): string
170  {
171  return $this->alias;
172  }
173 
179  public function setAlias(string $alias): void
180  {
181  $this->alias = $alias;
182  }
183 
189  public function getName(): string
190  {
191  return $this->name;
192  }
193 
199  public function setName(string $name): void
200  {
201  $this->name = $name;
202  }
203 
209  public function getDescription(): string
210  {
211  return $this->description;
212  }
213 
219  public function setDescription(string $description): void
220  {
221  $this->description = $description;
222  }
223 
229  public function getPermissions(): array
230  {
231  return $this->permissions;
232  }
233 
239  public function setPermissions(array $permissions): void
240  {
241  $this->permissions = $permissions;
242  }
243 
249  public function getSettings(): array
250  {
251  return $this->settings;
252  }
253 
259  public function setSettings(array $settings): void
260  {
261  $this->settings = $settings;
262  }
263 
275  public function getTriggers(): array
276  {
277  return $this->triggers;
278  }
279 
291  public function setTriggers(array $triggers): void
292  {
293  $this->triggers = $triggers;
294  }
295 
301  public function getCompletionConditions(): array
302  {
303  return $this->completionConditions;
304  }
305 
311  public function setCompletionConditions(array $completionConditions): void
312  {
313  $this->completionConditions = $completionConditions;
314  }
315 
326  public function getServices(): array
327  {
328  return $this->services;
329  }
330 
342  public function setServices(array $services): void
343  {
344  $this->services = $services;
345  }
346 }
setFor(string $for='user')
Definition: Module.php:96
setCompletionConditions(array $completionConditions)
Definition: Module.php:311
setPermissions(array $permissions)
Definition: Module.php:239
setTriggers(array $triggers)
Definition: Module.php:291
setDescription(string $description)
Definition: Module.php:219
setServices(array $services)
Definition: Module.php:342
setSettings(array $settings)
Definition: Module.php:259