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

SiteConfig::getMenu()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 0
dl 0
loc 13
rs 10
c 0
b 0
f 0
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
}