-
Notifications
You must be signed in to change notification settings - Fork 16
/
utils.php
69 lines (62 loc) · 1.38 KB
/
utils.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Pimf;
/**
* Return the value of the given item.
* If the given item is a Closure the result of the Closure will be returned.
*
* @param mixed $value
*
* @return mixed
*/
function value($value)
{
return (is_callable($value) && !is_string($value)) ? call_user_func($value) : $value;
}
/**
* Checks if a scalar value is FALSE, without content or only full of whitespaces.
* For non-scalar values will evaluate if value is empty().
*
* @param string $value
*
* @return bool
*/
function is_empty($value)
{
return !isset($value) || (is_scalar($value) ? (trim($value) === '') : empty($value));
}
/**
* @param string $route controller/action
* @param array $params
* @param null $https
* @param bool $asset
*
* @return string
*/
function url($route = '', array $params = array(), $https = null, $asset = false)
{
return \Pimf\Url::compute($route, $params, $https, $asset);
}
/**
* Escape HTML entities in a string.
*
* @param string $value
*
* @return string
*/
function ent($value)
{
return htmlentities($value, ENT_QUOTES, 'UTF-8', false);
}
/**
* Relax the system and free up some memory
*/
function relax()
{
clearstatcache();
// free up the memory that could be lost
// through possible roots that are already
// recorded in the root buffer.
if (function_exists('gc_collect_cycles')) {
gc_collect_cycles();
}
}