| Conditions | 2 |
| Paths | 2 |
| Total Lines | 23 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 11 | public static function make(string $key, string $type) |
||
| 12 | { |
||
| 13 | [$tab, $label] = explode('.', $key); |
||
| 14 | |||
| 15 | $resolveValueCallback = function (Field $field) { |
||
| 16 | // We access the value property of the Option model |
||
| 17 | return $field->model->value; |
||
| 18 | }; |
||
| 19 | |||
| 20 | $fillResourceCallback = function (Model $model, Request $request) { |
||
| 21 | // We need to replace the "." with an "_" because dot notation acts like array access |
||
| 22 | $value = $request->input(Str::replaceFirst('.', '_', $model->key)); |
||
| 23 | // We Write the value into the value property of the Option model |
||
| 24 | $model->value = $value; |
||
| 25 | }; |
||
| 26 | |||
| 27 | switch ($type) { |
||
| 28 | case 'text': |
||
| 29 | return TextField::make($key, $label, $resolveValueCallback, $fillResourceCallback); |
||
| 30 | default: |
||
| 31 | throw new \Exception('unknown field type'); |
||
| 32 | } |
||
| 33 | } |
||
| 34 | } |
||
| 35 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.