We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
Conditions | 6 |
Paths | 5 |
Total Lines | 30 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
11 | public function checkUniqueString() |
||
12 | { |
||
13 | $response = ['success' => false, 'message' => trans('backpack::crud.unique_error'), 'meta' => ['link' => null, 'snippet' => null, 'entity_key' => null]]; |
||
14 | |||
15 | $field_name = \Request::input('field_name', null); |
||
16 | $check_value = \Request::input('check_value', null); |
||
17 | $display_name = \Request::input('display_name', null); |
||
18 | |||
19 | if (empty($field_name)) { |
||
20 | $response['message'] = trans('backpack::crud.unique_field_name_missing'); |
||
21 | } elseif (empty($check_value) && $check_value !== '0') { |
||
22 | $response['message'] = trans('backpack::crud.unique_check_value_missing'); |
||
23 | } else { |
||
24 | $existing_entity = $this->crud->model->where([$field_name => $check_value])->first(); |
||
25 | |||
26 | if (! $existing_entity) { |
||
27 | $response['success'] = true; |
||
28 | $response['message'] = null; |
||
29 | } else { |
||
30 | $response['message'] = $this->crud->entity_name.' '.trans('backpack::crud.unique_exists'); |
||
31 | $response['meta'] = [ |
||
32 | 'link' => url($this->crud->route.'/'.$existing_entity->getKey().'/edit'), |
||
33 | 'snippet' => $display_name ? $existing_entity->{$display_name} : $this->crud->entity_name, |
||
34 | 'entity_key' => $existing_entity->getKey(), |
||
35 | ]; |
||
36 | } |
||
37 | } |
||
38 | |||
39 | return $response; |
||
40 | } |
||
41 | } |
||
42 |
This check compares the return type specified in the
@return
annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.