Total Complexity | 5 |
Total Lines | 45 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
13 | class FieldSettingsManager extends AbstractSettingsManager |
||
14 | { |
||
15 | /** |
||
16 | * @param array $settings |
||
17 | * @return \Glorand\Model\Settings\Contracts\SettingsManagerContract |
||
18 | 12 | */ |
|
19 | public function apply(array $settings = []): SettingsManagerContract |
||
20 | 12 | { |
|
21 | 12 | $this->model->{$this->model->getSettingsFieldName()} = json_encode($settings); |
|
22 | 12 | if ($this->model->isPersistSettings()) { |
|
23 | $this->model->save(); |
||
1 ignored issue
–
show
|
|||
24 | } |
||
25 | 12 | ||
26 | return $this; |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string|null $path |
||
31 | * @return \Glorand\Model\Settings\Contracts\SettingsManagerContract |
||
32 | 3 | */ |
|
33 | public function delete(string $path = null): SettingsManagerContract |
||
34 | 3 | { |
|
35 | 3 | if (!$path) { |
|
36 | $settings = []; |
||
37 | 1 | } else { |
|
38 | 1 | $settings = $this->all(); |
|
39 | Arr::forget($settings, $path); |
||
40 | } |
||
41 | 3 | ||
42 | $this->apply($settings); |
||
43 | 3 | ||
44 | return $this; |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param string $path |
||
49 | * @param mixed $value |
||
50 | 1 | * @return \Glorand\Model\Settings\Contracts\SettingsManagerContract |
|
51 | */ |
||
52 | 1 | public function set(string $path, $value): SettingsManagerContract |
|
58 | } |
||
59 | } |
||
60 |