ModuleRepository   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 1
Metric Value
eloc 11
c 2
b 1
f 1
dl 0
loc 33
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A createFromArray() 0 12 2
A get() 0 7 2
A getSettings() 0 3 1
1
<?php
2
3
namespace Chuckbe\Chuckcms\Chuck;
4
5
use Chuckbe\Chuckcms\Models\Module;
6
7
class ModuleRepository
8
{
9
    public static function createFromArray($array)
10
    {
11
        // updateOrCreate the module
12
        $find = Module::where('slug', $array['slug'])->first();
13
14
        if ($find == null) {
15
            $result = Module::create($array);
16
        } else {
17
            $result = $find->update($array);
18
        }
19
20
        return $result;
21
    }
22
23
    public static function get($slug = null)
24
    {
25
        if (!is_null($slug)) {
26
            return Module::where('slug', $slug)->firstOrFail();
27
        }
28
29
        return Module::get();
30
    }
31
32
    /**
33
     * Return the settings array of the module -> method can be phased out.
34
     *
35
     * @var Module
36
     **/
37
    public function getSettings(Module $module)
38
    {
39
        return $module->settings;
0 ignored issues
show
Bug Best Practice introduced by
The property settings does not exist on Chuckbe\Chuckcms\Models\Module. Since you implemented __get, consider adding a @property annotation.
Loading history...
40
    }
41
}
42