1 | <?php |
||||
2 | |||||
3 | namespace Glorand\Model\Settings\Traits; |
||||
4 | |||||
5 | use Glorand\Model\Settings\Contracts\SettingsManagerContract; |
||||
6 | use Illuminate\Support\Arr; |
||||
7 | |||||
8 | /** |
||||
9 | * @property array $settingsRules |
||||
10 | 195 | * @property array $defaultSettings |
|||
11 | * @SuppressWarnings(PHPMD.StaticAccess) |
||||
12 | 195 | */ |
|||
13 | 195 | trait HasSettings |
|||
14 | 189 | { |
|||
15 | 6 | public function getRules(): array |
|||
16 | 6 | { |
|||
17 | 3 | if (property_exists($this, 'settingsRules') && is_array($this->settingsRules)) { |
|||
18 | return $this->settingsRules; |
||||
19 | 6 | } |
|||
20 | |||||
21 | return []; |
||||
22 | } |
||||
23 | |||||
24 | public function getDefaultSettings(): array |
||||
25 | { |
||||
26 | if (property_exists($this, 'defaultSettings') |
||||
27 | && is_array($this->defaultSettings)) { |
||||
28 | return Arr::wrap($this->defaultSettings); |
||||
29 | } elseif (($defaultSettings = config('model_settings.defaultSettings.' . $this->getTable())) |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() The method
getTable() does not exist on Glorand\Model\Settings\Traits\HasSettings . Since you implemented __call , consider adding a @method annotation.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
30 | && is_array($defaultSettings)) { |
||||
31 | return Arr::wrap($defaultSettings); |
||||
32 | } |
||||
33 | |||||
34 | return []; |
||||
35 | } |
||||
36 | |||||
37 | public function __call($name, $args) |
||||
38 | { |
||||
39 | if (isset($this->invokeSettingsBy) && $name === $this->invokeSettingsBy) { |
||||
40 | return $this->settings(); |
||||
41 | } |
||||
42 | |||||
43 | return is_callable(['parent', '__call']) ? parent::__call($name, $args) : null; |
||||
44 | } |
||||
45 | |||||
46 | abstract public function getSettingsValue(): array; |
||||
47 | |||||
48 | abstract public function settings(): SettingsManagerContract; |
||||
49 | } |
||||
50 |