Conditions | 4 |
Paths | 4 |
Total Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 4.128 |
Changes | 0 |
1 | <?php |
||
40 | 5 | public function setSetting(array $settings) |
|
41 | { |
||
42 | 5 | if (count($settings)<=0) { |
|
43 | 1 | return false; |
|
44 | } |
||
45 | |||
46 | 5 | foreach ($settings as $key => $val) { |
|
47 | 5 | $var = $this->model->where('key', $key)->first(); |
|
|
|||
48 | 5 | if ($var) { |
|
49 | $var->value = $val; |
||
50 | $var->save(); |
||
51 | } else { |
||
52 | 5 | $var = $this->model->create(['key' => $key, 'value' => $val]); |
|
53 | } |
||
54 | } |
||
55 | |||
56 | 5 | return $var; |
|
57 | } |
||
58 | |||
93 |
If you implement
__call
and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.This is often the case, when
__call
is implemented by a parent class and only the child class knows which methods exist: