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