summaryrefslogtreecommitdiff
path: root/src/helpers.php
blob: a410b27e8768e89dab3b13b1e0fadaaf727e3496 (plain)
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
<?php
// Some useful functions

use Engelsystem\Config\Config;
use Engelsystem\Http\Request;

/**
 * Get or set config values
 *
 * @param string|array $key
 * @param mixed        $default
 * @return mixed|Config
 */
function config($key = null, $default = null)
{
    if (empty($key)) {
        return Config::getInstance();
    }

    if (is_array($key)) {
        Config::getInstance()->set($key);
    }

    return Config::getInstance()->get($key, $default);
}

/**
 * @param string $key
 * @param mixed  $default
 * @return Request|mixed
 */
function request($key = null, $default = null)
{
    $request = Request::getInstance();

    if (is_null($key)) {
        return $request;
    }

    return $request->input($key, $default);
}