Widget::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 10

Duplication

Lines 20
Ratio 100 %

Importance

Changes 9
Bugs 0 Features 0
Metric Value
c 9
b 0
f 0
dl 20
loc 20
rs 9.4286
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
namespace humanity;
3
4
class Widget {
5
6
    public static $js;
7
    public static $css;
8
    public static $title;
9
    public static $description;
10
    public static $keywords;
11
    private static $config;
12
    private static $app;
13
    private static $view;
14
    private static $property;
15
    private static $path;
0 ignored issues
show
Unused Code introduced by
The property $path 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...
16
    private static $uri;
17
18 View Code Duplication
    public function __construct(){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
        # Config
20
        self::$config = (new Config)->get();
21
        # Application
22
        self::$app = new Application;
23
        # View
24
        self::$view = new View;
25
        # Js
26
        self::$js = new Js;
27
        # Css
28
        self::$css = new Css;
29
        # Title
30
        self::$title = new Title;
31
        # Desctiption
32
        self::$description = new Description;
33
        # Keywords
34
        self::$keywords = new Keywords;
35
        # Uri
36
        self::$uri = new Uri;
37
    }
38
39
    public function __get($name){
40
        self::$property= $name;
41
        return new self;
42
    }
43
44
    public function __call($_name,$value){
45
        if(isset($value[0]) && !empty($value[0]) && is_array($value[0])) extract($value[0]);
46
        $file = self::$config['core']['widget'].'/'.self::$property.'/'.$_name.'.phtml';
47
        if(is_file($file)) require($file);
48
    }
49
50
}
51
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
52