Completed
Push — develop ( 8060c5...f5ccfa )
by jake
02:47
created

Config::helper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Aura\View Provider for Aura\Di
4
 *
5
 * PHP version 5
6
 *
7
 * Copyright (C) 2016 Jake Johns
8
 *
9
 * This software may be modified and distributed under the terms
10
 * of the MIT license.  See the LICENSE file for details.
11
 *
12
 * @category  Config
13
 * @package   Fusible\ViewProvider
14
 * @author    Jake Johns <[email protected]>
15
 * @copyright 2016 Jake Johns
16
 * @license   http://jnj.mit-license.org/2016 MIT License
17
 * @link      https://github.com/fusible/fusible.view-provider
18
 */
19
20
namespace Fusible\ViewProvider;
21
22
use Aura\Di\Container;
23
use Aura\Di\ConfigCollection;
24
25
/**
26
 * Config
27
 *
28
 * @category Config
29
 * @package  Fusible\ViewProvider
30
 * @author   Jake Johns <[email protected]>
31
 * @license  http://jnj.mit-license.org/2016 MIT License
32
 * @link     https://github.com/fusible/fusible.view-provider
33
 *
34
 * @see ContainerConfig
35
 */
36
class Config extends ConfigCollection
37
{
38
    protected $configs = [];
39
40
    /**
41
     * __construct
42
     *
43
     * @param mixed $templates DESCRIPTION
44
     * @param array $helpers   DESCRIPTION
45
     *
46
     * @return mixed
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
47
     *
48
     * @access public
49
     */
50
    public function __construct($templates = null, array $helpers = [])
51
    {
52
        $this->configs = [
53
            ViewConfig::class => new ViewConfig,
54
            ViewHelperConfig::class => new ViewHelperConfig
55
        ];
56
57
        if ($templates) {
58
            $this->view()->addTemplatePath($templates);
59
        }
60
61 9
        if ($helpers) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $helpers of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
62
            $this->helper()->addHelpers($helpers);
63
        }
64 9
    }
65 9
66 9
    /**
67 9
     * View
68
     *
69 9
     * @return mixed
70 9
     *
71 9
     * @access public
72 9
     */
73
    public function view()
74 9
    {
75 9
        return $this->configs[ViewConfig::class];
76
    }
77 9
78 9
    /**
79 9
     * Helper
80 9
     *
81
     * @return mixed
82 9
     * @throws exceptionclass [description]
83 9
     *
84 9
     * @access public
85 9
     */
86
    public function helper()
87 9
    {
88 9
        return $this->configs[ViewHelperConfig::class];
89 9
    }
90
}
91