Completed
Push — master ( 470825...143e87 )
by Joram van den
06:11
created

helpers.php ➔ issetor()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
class Ajde extends Ajde_Application
4
{
5
}
6
7
class Config extends Ajde_Config
8
{
9
}
10
11
class Dump extends Ajde_Dump
12
{
13
}
14
15
class Lang extends Ajde_Lang
16
{
17
}
18
19
class Str extends Ajde_Component_String
20
{
21
}
22
23
class Arr extends Ajde_Core_Array
24
{
25
}
26
27
/**
28
 * Return value when it is set, or something else otherwise.
29
 *
30
 * @param      $what
31
 * @param null $else
32
 *
33
 * @return null
34
 */
35
function issetor(&$what, $else = null)
36
{
37
    // @see http://fabien.potencier.org/article/48/the-php-ternary-operator-fast-or-not
38
    if (isset($what)) {
39
        return $what;
40
    } else {
41
        return $else;
42
    }
43
}
44
45
/**
46
 * @param           $var
47
 * @param bool|true $expand
48
 */
49
function dump($var, $expand = true)
50
{
51
    Dump::dump($var, $expand);
52
}
53
54
/**
55
 * Translates the string with Ajde_Lang::translate.
56
 *
57
 * @param string $ident
58
 * @param string $module
59
 *
60
 * @return string
61
 */
62
function trans($ident, $module = null)
63
{
64
    return Lang::trans($ident, $module);
65
}
66
67
/**
68
 * Escapes the string with Ajde_Component_String::escape.
69
 *
70
 * @param string $var
71
 *
72
 * @return string
73
 */
74
function esc($var)
75
{
76
    return Str::escape($var);
77
}
78
79
/**
80
 * Cleans the string with Ajde_Component_String::clean.
81
 *
82
 * @param string $var
83
 *
84
 * @return string
85
 */
86
function clean($var)
87
{
88
    return Str::clean($var);
89
}
90
91
/**
92
 * Shortcut to retrieve config param.
93
 *
94
 * @param $param
95
 *
96
 * @throws Ajde_Exception
97
 *
98
 * @return mixed
99
 */
100
function config($param)
101
{
102
    return Config::get($param);
103
}
104
105
/**
106
 * Shortcut to get setting contents.
107
 *
108
 * @param string $name
109
 *
110
 * @return bool|mixed
111
 */
112
function setting($name)
113
{
114
    return SettingModel::byName($name);
115
}
116