Completed
Branch master (e379bd)
by Pierre-Henry
33:06
created

Smarty_Internal_Method_GetConfigVariable   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getConfigVariable() 0 4 1
1
<?php
2
3
/**
4
 * Smarty Method GetConfigVariable
5
 *
6
 * Smarty::getConfigVariable() method
7
 *
8
 * @package    Smarty
9
 * @subpackage PluginsInternal
10
 * @author     Uwe Tews
11
 */
12
class Smarty_Internal_Method_GetConfigVariable
13
{
14
    /**
15
     * Valid for all objects
16
     *
17
     * @var int
18
     */
19
    public $objMap = 7;
20
21
    /**
22
     * gets  a config variable value
23
     *
24
     * @param \Smarty|\Smarty_Internal_Data|\Smarty_Internal_Template $data
25
     * @param string                                                  $varName the name of the config variable
26
     * @param bool                                                    $errorEnable
27
     *
28
     * @return null|string  the value of the config variable
29
     */
30
    public function getConfigVariable(Smarty_Internal_Data $data, $varName = null, $errorEnable = true)
31
    {
32
        return $data->ext->configLoad->_getConfigVariable($data, $varName, $errorEnable);
0 ignored issues
show
Documentation introduced by
The property configLoad does not exist on object<Smarty_Internal_Extension_Handler>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

If the property has read access only, you can use the @property-read annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
33
    }
34
}