| Conditions | 5 |
| Paths | 5 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php namespace G2R\Gitlab; |
||
| 17 | public static function load($data) |
||
| 18 | { |
||
| 19 | $data = json_decode($data); |
||
| 20 | |||
| 21 | if (!isset($data->object_kind)) { |
||
| 22 | throw new Exception('Object kind not found in the hook data'); |
||
| 23 | } |
||
| 24 | |||
| 25 | if (!in_array($data->object_kind, ['push', 'build'])) { |
||
| 26 | throw new Exception('Unknown Object kind from the hook'); |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($data->object_kind === 'push') { |
||
| 30 | return new Push($data); |
||
| 31 | } |
||
| 32 | |||
| 33 | if ($data->tag) { |
||
| 34 | return new Tag($data); |
||
| 35 | } |
||
| 36 | |||
| 37 | return new Build($data); |
||
| 38 | } |
||
| 39 | } |
||
| 40 |