Passed
Branch master (bb0da2)
by Marcio
12:00
created

search_lib()   A

Complexity

Conditions 6
Paths 4

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
rs 9.2222
c 0
b 0
f 0
cc 6
nc 4
nop 3
1
<?php
2
3
/**
4
 * KNUT7 K7F (https://marciozebedeu.com/)
5
 * KNUT7 K7F (tm) : Rapid Development Framework (https://marciozebedeu.com/)
6
 *
7
 * Licensed under The MIT License
8
 * For full copyright and license information, please see the LICENSE.txt
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @link      https://github.com/knut7/framework/ for the canonical source repository
12
 * @copyright (c) 2015.  KNUT7  Software Technologies AO Inc. (https://marciozebedeu.com/)
13
 * @license   https://marciozebedeu.com/license/new-bsd New BSD License
14
 * @author    Marcio Zebedeu - [email protected]
15
 * @version   1.0.2
16
 */
17
18
namespace Ballybran\Config;
19
20
/**
21
 *
22
 * Also spl_autoload_register (Take a look at it if you like)
23
 *
24
 */
25
spl_autoload_register(function($class) {
26
27
    if (file_exists(str_replace('\\', DS, $class) . '.php')) {
28
        $file = str_replace('\\', DS, $class) . '.php';
29
30
        require_once $file;
31
    }
32
33
});
34
35
36
37
function __autoload($class)
38
{
39
    $libs = './';
40
    $ext = '.php';
41
    $file = search_lib($libs, $class . $ext);
0 ignored issues
show
Bug introduced by
The function search_lib was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

41
    $file = /** @scrutinizer ignore-call */ search_lib($libs, $class . $ext);
Loading history...
42
    // Se encontrou inclui o arquivo
43
    if (false !== $file) {
44
        require_once $file;
45
    }
46
    // Se não encontrar o arquivo lança um erro na tela. :)
47
    else {
48
        $msg = "Autoload fatal erro: Can't find the file {$class}!";
49
        error_log($msg);
50
        exit('<br><br><strong>' . $msg . '</strong>');
0 ignored issues
show
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
51
    }
52
}
53