| Total Complexity | 6 |
| Total Lines | 50 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 7 | class BlameableService |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Get configurations for the given Model. |
||
| 11 | * |
||
| 12 | * @param \Illuminate\Database\Eloquent\Model $model |
||
| 13 | * |
||
| 14 | * @return string[] |
||
| 15 | */ |
||
| 16 | private function getConfigurations(Model $model): array |
||
| 17 | { |
||
| 18 | $modelConfigurations = method_exists($model, 'blameable') ? |
||
| 19 | $model->blameable() : []; |
||
| 20 | |||
| 21 | return array_merge((array) config('blameable'), $modelConfigurations); |
||
|
|
|||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Get current configuration value for the given attributes. |
||
| 26 | * |
||
| 27 | * @param \Illuminate\Database\Eloquent\Model $model |
||
| 28 | * @param string $key |
||
| 29 | * |
||
| 30 | * @return string|null |
||
| 31 | */ |
||
| 32 | public function getConfiguration(Model $model, string $key): ?string |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * Set Model's attribute value for the given key. |
||
| 41 | * |
||
| 42 | * @param Model $model |
||
| 43 | * @param string $key |
||
| 44 | * @param int|string|null $userId |
||
| 45 | * |
||
| 46 | * @return bool |
||
| 47 | */ |
||
| 48 | public function setAttribute(Model $model, string $key, $userId): bool |
||
| 59 |