| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4.0092 |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | 1 | public function run() |
|
| 15 | { |
||
| 16 | 1 | $this->require('space'); |
|
| 17 | 1 | $this->require('id'); |
|
| 18 | |||
| 19 | 1 | if (!in_array($this->type, ['create', 'update', 'remove'])) { |
|
| 20 | throw new Exception("Invalid type $this->type"); |
||
| 21 | } |
||
| 22 | |||
| 23 | 1 | $method = 'after'.ucfirst($this->type); |
|
| 24 | |||
| 25 | 1 | $entity = $this->findOrFail($this->space, $this->id); |
|
| 26 | |||
| 27 | // afterUpdate trigger will be called on save |
||
| 28 | 1 | if ($this->type != 'update') { |
|
| 29 | 1 | if (method_exists($entity, $method)) { |
|
| 30 | 1 | $entity->$method(); |
|
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | 1 | $entity->save(); |
|
| 35 | 1 | } |
|
| 36 | } |
||
| 37 |