| Conditions | 8 |
| Paths | 64 |
| Total Lines | 26 |
| Code Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 8 |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | 146 | public function details(): Details |
|
| 15 | { |
||
| 16 | $className = ($this->modelClass()); |
||
|
|
|||
| 17 | $genericModelInstance = new $className; |
||
| 18 | 146 | ||
| 19 | 146 | // Generic model details |
|
| 20 | 146 | $id = Str::slug($this->registration->key(). ($this->hasExistingModel() ? '-'. $this->existingModel()->id : '')); |
|
| 21 | 146 | $key = $this->registration->key(); |
|
| 22 | 146 | $labelSingular = property_exists($genericModelInstance, 'labelSingular') ? $genericModelInstance->labelSingular : Str::singular($key); |
|
| 23 | $labelPlural = property_exists($genericModelInstance, 'labelPlural') ? $genericModelInstance->labelPlural : Str::plural($key); |
||
| 24 | $internal_label = ($this->hasExistingModel() && contract($this->model, ProvidesFlatReference::class)) |
||
| 25 | 146 | ? $this->existingModel()->flatReferenceLabel() |
|
| 26 | : $key; |
||
| 27 | 146 | ||
| 28 | 146 | // Manager index and header info |
|
| 29 | 146 | $title = ($this->hasExistingModel() && $this->existingModel()->title) |
|
| 30 | 146 | ? $this->existingModel()->title |
|
| 31 | 146 | : $labelSingular; |
|
| 32 | 146 | ||
| 33 | 146 | return new Details( |
|
| 34 | $id, |
||
| 35 | $key, |
||
| 36 | $labelSingular.'', |
||
| 37 | $labelPlural.'', |
||
| 38 | $internal_label, |
||
| 39 | $title.'' |
||
| 40 | ); |
||
| 43 |