Completed
Push — site-config ( 91641c )
by Arnaud
01:42
created

Site::getPages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/*
3
 * Copyright (c) Arnaud Ligny <[email protected]>
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Cecil\Renderer;
10
11
use Cecil\Builder;
12
use Cecil\Collection\Page\Page;
13
use Cecil\Config;
14
use Cecil\Exception\Exception;
15
16
/**
17
 * Class Site.
18
 */
19
class Site
20
{
21
    /**
22
     * Builder object.
23
     *
24
     * @var Builder
25
     */
26
    protected $builder;
27
    /**
28
     * Configuration object.
29
     *
30
     * @var Config
31
     */
32
    protected $config;
33
34
    /**
35
     * Site constructor.
36
     *
37
     * @param Config $config
0 ignored issues
show
Bug introduced by
There is no parameter named $config. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
38
     */
39
    public function __construct(Builder $builder)
40
    {
41
        $this->builder = $builder;
42
        $this->config = $builder->getConfig();
43
    }
44
45
    public function __call($method, $args) {
46
        $camelMethod = 'get'.ucwords($method);
47
        // local method
48
        if (method_exists($this, $camelMethod)) {
49
            return $this->$camelMethod($args);
50
        }
51
        // Config method
52
        if (method_exists($this->config, $camelMethod)) {
53
            return $this->config->$camelMethod($args);
54
        }
55
        // Config Data
56
        return $this->config->get($method);
57
    }
58
59
    public function getPages() {
60
        return $this->builder->getPages()->filter(function (Page $page) {
61
            return $page->getVariable('published');
62
        });
63
    }
64
65
    public function getMenus() {
66
        return $this->builder->getMenus();
67
    }
68
69
    public function getTaxonomies() {
70
        return $this->builder->getTaxonomies();
71
    }
72
73
    public function getTime() {
74
        return time();
75
    }
76
}
77