Passed
Push — Showing-Posts ( 822ae4...f3134d )
by Stone
01:58
created

CategoryModel::getCategoryDetails()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Models;
4
5
use Core\Model;
6
7
class CategoryModel extends Model
8
{
9
10
    /**
11
     * get the list of categories and return all the data
12
     * @return array the categories
13
     * @throws \ReflectionException
14
     */
15
    public function getCategories()
16
    {
17
        return $this->getResultSet('categories');
18
    }
19
20
    /**
21
     * get all the menu elements from the database
22
     * @return array the categories and access URL
23
     * @throws \ReflectionException
24
     */
25
    public function getMenu(): array
26
    {
27
        $data = [];
28
        //get the categories from database
29
        $categories = $this->getCategories();
30
        foreach ($categories as $category) {
31
            $data += [
32
                $category->category_name => '/category/posts/' . $category->categories_slug
33
            ];
34
        }
35
        return $data;
36
    }
37
38
    public function getCategoryDetails(int $categoryId)
39
    {
40
        return $this->getRowById($categoryId, "categories");
41
    }
42
}