Passed
Push — RefactoringPosts ( 4f49c0...c0b061 )
by Stone
02:54
created

SiteConfig   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSiteConfig() 0 10 2
A getMenu() 0 13 2
1
<?php
2
3
namespace App\Modules;
4
5
use App\Models\CategoryModel;
6
use Core\Modules\Module;
7
use App\Models\ConfigModel;
8
9
class SiteConfig extends Module
10
{
11
    /**
12
     * Gets the entire site configuration and arranges it into a displayable list
13
     * @return array the config ordered and ready to display
14
     * @throws \ReflectionException
15
     */
16
    public function getSiteConfig()
17
    {
18
19
        $configs = new ConfigModel($this->container);
20
        $siteConfig = $configs->getAllConfig();
21
        $data = [];
22
        foreach ($siteConfig as $config) {
23
            $data[$config->configs_name] = $config->configs_value;
24
        }
25
        return $data;
26
    }
27
28
    public function getMenu()
29
    {
30
        $categoryModel = new CategoryModel($this->container);
31
32
        $data = [];
33
        //get the categories from database
34
        $categories = $categoryModel->getCategories();
35
        foreach ($categories as $category) {
36
            $data += [
37
                $category->category_name => '/category/posts/' . $category->categories_slug
38
            ];
39
        }
40
        return $data;
41
    }
42
}