ApiSettings   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 11
lcom 0
cbo 0
dl 0
loc 77
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A isEnabled() 0 4 1
A getCartOptions() 0 4 2
A getCategoriesOptions() 0 4 2
A getCategoryOptions() 0 4 2
A getProductsOptions() 0 4 2
A getProductOptions() 0 4 2
1
<?php namespace Bedard\Shop\Models;
2
3
use Model;
4
5
/**
6
 * Api Settings Model.
7
 */
8
class ApiSettings extends Model
9
{
10
    /**
11
     * @var array   Behaviors
12
     */
13
    public $implement = ['System.Behaviors.SettingsModel'];
14
15
    /**
16
     * @var string  Settings code
17
     */
18
    public $settingsCode = 'bedard_shop_api_settings';
19
20
    /**
21
     * @var string  Settings fields
22
     */
23
    public $settingsFields = 'fields.yaml';
24
25
    /**
26
     * Get the enabled status of the api endpoints.
27
     *
28
     * @return bool
29
     */
30
    public static function isEnabled()
31
    {
32
        return self::get('is_enabled', false);
33
    }
34
35
    /**
36
     * Get options for cart endpoint.
37
     *
38
     * @return array
39
     */
40
    public static function getCartOptions()
41
    {
42
        return self::get('cart') ?: [];
43
    }
44
45
    /**
46
     * Get options for categories endpoint.
47
     *
48
     * @return array
49
     */
50
    public static function getCategoriesOptions()
51
    {
52
        return self::get('categories') ?: [];
53
    }
54
55
    /**
56
     * Get options for category endpoint.
57
     *
58
     * @return array
59
     */
60
    public static function getCategoryOptions()
61
    {
62
        return self::get('category') ?: [];
63
    }
64
65
    /**
66
     * Get options for products endpoint.
67
     *
68
     * @return array
69
     */
70
    public static function getProductsOptions()
71
    {
72
        return self::get('products') ?: [];
73
    }
74
75
    /**
76
     * Get options for product endpoint.
77
     *
78
     * @return array
79
     */
80
    public static function getProductOptions()
81
    {
82
        return self::get('product') ?: [];
83
    }
84
}
85