Setting::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
ccs 0
cts 4
cp 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
3
namespace mQueue\Model;
4
5
/**
6
 * Settings stored in database (not to be confused with application configuration)
7
 */
8
class Setting extends AbstractModel
9
{
10
    /**
11
     * Returns the setting, with a default value set if none was found.
12
     *
13
     * @param string $id unique name of setting
14
     * @param mixed $defaultValue
15
     *
16
     * @return Setting
17
     */
18
    public static function get($id, $defaultValue)
19
    {
20
        $setting = SettingMapper::find($id, $defaultValue);
21
22
        return $setting;
23
    }
24
25
    /**
26
     * Defines the value of the setting
27
     *
28
     * @param string $id unique name of setting
29
     * @param string $value the value to be set
30
     */
31
    public static function set($id, $value): void
32
    {
33
        $setting = self::get($id, $value);
34
        $setting->value = $value;
0 ignored issues
show
Bug Best Practice introduced by
The property value does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
35
        $setting->save();
36
    }
37
}
38