FieldSettingsManager   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 16
ccs 5
cts 5
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 10 2
1
<?php
2
3
namespace Glorand\Model\Settings\Managers;
4
5
use Glorand\Model\Settings\Contracts\SettingsManagerContract;
6
7
/**
8
 * Class FieldSettingsManager
9
 * @package Glorand\Model\Settings\Managers
10
 * @property \Illuminate\Database\Eloquent\Model|\Glorand\Model\Settings\Traits\HasSettingsField $model
11
 */
12
class FieldSettingsManager extends AbstractSettingsManager
13
{
14
    /**
15
     * @param  array  $settings
16
     * @return \Glorand\Model\Settings\Contracts\SettingsManagerContract
17
     */
18 87
    public function apply(array $settings = []): SettingsManagerContract
19
    {
20 87
        $this->validate($settings);
21 87
22 87
        $this->model->{$this->model->getSettingsFieldName()} = json_encode($settings);
23
        if ($this->model->isPersistSettings()) {
24
            $this->model->save();
0 ignored issues
show
Bug introduced by
The method save() does not exist on Glorand\Model\Settings\Traits\HasSettingsField. 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 ignore-call  annotation

24
            $this->model->/** @scrutinizer ignore-call */ 
25
                          save();
Loading history...
25 87
        }
26
27
        return $this;
28
    }
29
}
30