Setting   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
c 0
b 0
f 0
dl 0
loc 28
rs 10
ccs 0
cts 10
cp 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 5 1
A get() 0 5 1
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