SettingMapper::find()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 6
c 0
b 0
f 0
dl 0
loc 11
rs 10
ccs 0
cts 9
cp 0
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
namespace mQueue\Model;
4
5
abstract class SettingMapper extends AbstractMapper
6
{
7
    /**
8
     * Returns the setting, with a default value set if none was found.
9
     *
10
     * @param string $id
11
     * @param mixed $defaultValue
12
     *
13
     * @return Setting
14
     */
15
    public static function find($id, $defaultValue)
16
    {
17
        $result = self::getDbTable()->find([$id])->current();
18
19
        if ($result == null) {
20
            $result = self::getDbTable()->createRow();
21
            $result->id = $id;
22
            $result->value = $defaultValue;
23
        }
24
25
        return $result;
26
    }
27
}
28