config()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 9.4285
1
<?php
2
/**
3
 * Creates views from files.
4
 *
5
 * @param string $location  location of a template
6
 * @param array  $data      array of variables to extract
7
 * @return void
8
 */
9
function view($location, $data = [])
10
{
11 2
    ob_start();
12 2
    extract($data);
13 2
    include __DIR__ . '/../views/' . $location;
14 2
    $result = ob_get_contents();
15 2
    ob_end_clean();
16 2
    return $result;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $result returns the type string which is incompatible with the documented return type void.
Loading history...
17
}
18
19
/**
20
 * Returns the current configuration values.
21
 *
22
 * @return array
23
 */
24
function config($file = 'config.php')
25
{
26 14
    static $config;
27 14
    if (!$config) {
28 1
        $config = include __DIR__ . '/../' . $file;
29
    }
30 14
    return $config;
31
}
32