Passed
Push — Showing-Posts ( 0734d0...3fc5d4 )
by Stone
01:46
created

Tag   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 18
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A list() 0 14 2
A __construct() 0 9 1
1
<?php
2
3
namespace App\Controllers\Admin;
4
5
use App\Models\TagModel;
6
use Core\AdminController;
7
use Core\Constant;
8
use Core\Container;
9
10
class Tag extends AdminController{
11
12
    protected $siteConfig;
13
    protected $pagination;
14
15
    private $tagModel;
16
17
    public function __construct(Container $container)
18
    {
19
        $this->loadModules[] = 'SiteConfig';
20
        $this->loadModules[] = 'pagination';
21
        parent::__construct($container);
22
23
        $this->tagModel = new TagModel($this->container);
24
25
        $this->data['configs'] = $this->siteConfig->getSiteConfig();
26
    }
27
28
    public function list(string $page = "page-1", int $linesPerPage = Constant::LIST_PER_PAGE)
29
    {
30
        $this->onlyAdmin();
31
32
        $totalCategories = $this->tagModel->countTags();
33
        $pagination = $this->pagination->getPagination($page, $totalCategories, $linesPerPage);
34
35
        if($linesPerPage !== Constant::LIST_PER_PAGE){
36
            $this->data['paginationPostsPerPage'] = $linesPerPage;
37
        }
38
39
        $this->data["posts"] = $this->tagModel->getTagList($pagination["offset"], $linesPerPage);
40
        $this->data['pagination'] = $pagination;
41
        $this->renderView("Admin/ListTag");
42
    }
43
}