Completed
Push — master ( 221395...658920 )
by Andrey
02:54
created

Widget.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace humanity;
3
4
class Widget {
5
6
    public static $js;
7
    public static $css;
8
    private static $config;
9
    private static $app;
10
    private static $view;
11
    private static $property;
12
    private static $path;
13
    private static $uri;
0 ignored issues
show
The property $uri is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
14
15
    public function __construct(){
16
        # Config
17
        self::$config = (new Config)->get();
18
        # Url
19
        self::$path = explode('/',parse_url(urldecode($_SERVER['REQUEST_URI']))['path']);
20
        foreach(self::$path as $key=>$value){
21
            $value = trim($value);
22
            if(empty($value)) unset(self::$path[$key]);
23
        }
24
        self::$path = array_values(self::$path);
25
        # Application
26
        self::$app = new Application;
27
        # View
28
        self::$view = new View;
29
        # Js
30
        self::$js = new Js;
31
        # Css
32
        self::$css = new Css;
33
    }
34
35
    public function __get($name){
36
        self::$property= $name;
37
        return new self;
38
    }
39
40
    public function __call($_name,$value){
41
        if(isset($value[0]) && !empty($value[0]) && is_array($value[0])) extract($value[0]);
42
        $file = self::$config['core']['widget'].'/'.self::$property.'/'.$_name.'.phtml';
43
        if(is_file($file)) require($file);
44
    }
45
46
}
47
?>
48