Passed
Pull Request — dev (#47)
by Stone
04:17 queued 01:57
created

IncludesModel   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMenu() 0 11 2
1
<?php
2
3
namespace App\Models;
4
5
use Core\Model;
6
7
/**
8
 * Class IncludesModel
9
 * All the included views data (menu, jumbotron, ...)
10
 * the returned data should then be stored in a $data['var'] and the view will check if var is set
11
 * @package App\Models
12
 */
13
class IncludesModel extends Model
14
{
15
    /**
16
     * get all the menu elements from the database
17
     * @return array the categories and access URL
18
     * @throws \ReflectionException
19
     */
20
    public function getMenu(): array
21
    {
22
        $data = [];
23
        //get the categories from database
24
        $categories = $this->getResultSet('categories');
25
        foreach ($categories as $category) {
26
            $data += [
27
                $category->category_name => '/category/' . $category->categories_slug
28
            ];
29
        }
30
        return $data;
31
    }
32
}