Conditions | 3 |
Paths | 3 |
Total Lines | 15 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 3 |
Changes | 2 | ||
Bugs | 0 | Features | 1 |
1 | <?php namespace Bosnadev\Database\Traits; |
||
30 | 6 | protected function provideUuidKey($model) |
|
31 | { |
||
32 | // provide a UUID only if increment is disabled |
||
33 | 6 | if ($model->incrementing === false) { |
|
34 | 3 | $key = $model->getKeyName(); |
|
35 | |||
36 | 3 | if (empty($model->$key)) { |
|
37 | 3 | $model->$key = (string)Uuid::uuid4(); |
|
38 | 3 | } |
|
39 | 3 | } else { |
|
40 | 3 | throw new RuntimeException( |
|
41 | 3 | sprintf('$incrementing must be false on class "%s" to support uuid', get_class($this)) |
|
42 | 3 | ); |
|
43 | } |
||
44 | 3 | } |
|
45 | } |
||
46 |