Passed
Pull Request — master (#1)
by Gombos
01:47
created

FieldSettingsManager::delete()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 12
ccs 0
cts 10
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Glorand\Model\Settings\Managers;
4
5
use Glorand\Model\Settings\Contracts\SettingsManagerContract;
6
7
class FieldSettingsManager extends AbstractSettingsManager
8
{
9
    public function apply(array $settings = []): SettingsManagerContract
10
    {
11
        $this->model->settings = $settings;
12
        $this->model->save();
13
14
        return $this;
15
    }
16
17
    public function delete(string $path = null): SettingsManagerContract
18
    {
19
        if (!$path) {
20
            $settings = [];
21
        } else {
22
            $settings = $this->all();
23
            array_forget($settings, $path);
24
        }
25
26
        $this->apply($settings);
27
28
        return $this;
29
    }
30
31
    public function set(string $path, $value): SettingsManagerContract
32
    {
33
        $settings = $this->all();
34
        array_set($settings, $path, $value);
35
36
        return $this->apply($settings);
37
    }
38
}
39