Completed
Push — development ( eb9524...db4517 )
by Andrij
28:49 queued 02:09
created

Page   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 3
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getPages() 0 18 3
1
<?php
2
3
namespace xbanners\src\BannerPagesTypes;
4
5
use CI;
6
7
/**
8
 * Created by PhpStorm.
9
 * User: mark
10
 * Date: 23.03.15
11
 * Time: 19:19
12
 */
0 ignored issues
show
introduced by
There must be no blank lines after the class comment
Loading history...
13
14
class Page extends BasePageType
15
{
0 ignored issues
show
introduced by
Opening brace of a class must be on the same line as the definition
Loading history...
16
17
    public function __construct($locale) {
18
        $this->locale = $locale;
19
        $this->localeId = $this->getLocaleId();
20
        $this->tpl_name = 'page';
21
    }
22
23
    public function getPages() {
24
        $pages = CI::$APP->db
25
            ->where('lang', $this->localeId)
26
            ->order_by('title')
27
            ->get('content');
28
29
        $pages = $pages ? $pages->result_array() : [];
30
31
        $data = [];
32
        foreach ($pages as $page) {
33
            $data[$page['id']] = [
34
                'id' => $page['id'],
35
                'name' => $page['title'],
36
            ];
37
        }
38
39
        return $data;
40
    }
41
}