Passed
Push — master ( 7f8b3f...7ac9f0 )
by Observer
01:45
created

Globals.php$0 ➔ run()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
nc 4
nop 1
dl 0
loc 12
c 1
b 0
f 0
cc 5
rs 9.6111
1
<?php
2
3
namespace VoidEngine;
4
5
register_superglobals ('APPLICATION', 'SCREEN');
0 ignored issues
show
Bug introduced by
The function register_superglobals 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

5
/** @scrutinizer ignore-call */ 
6
register_superglobals ('APPLICATION', 'SCREEN');
Loading history...
6
7
$APPLICATION = new class
8
{
9
    public WFClass $application;
10
    public string $executablePath;
11
    
12
    public function __construct ()
13
    {
14
        $this->application    = new WFClass ('System.Windows.Forms.Application');
15
        $this->executablePath = $this->application->executablePath;
0 ignored issues
show
Bug Best Practice introduced by
The property executablePath does not exist on VoidEngine\WFClass. Since you implemented __get, consider adding a @property annotation.
Loading history...
16
    }
17
    
18
    public function run ($form = null): void
19
    {
20
        if ($form instanceof WFObject)
21
            $this->application->run ($form->selector);
0 ignored issues
show
Bug Best Practice introduced by
The property $selector is declared protected in VoidEngine\WFObject. Since you implement __get, consider adding a @property or @property-read.
Loading history...
Bug introduced by
The method run() does not exist on VoidEngine\WFClass. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

21
            $this->application->/** @scrutinizer ignore-call */ 
22
                                run ($form->selector);
Loading history...
22
        
23
        elseif (is_int ($form) && \VoidCore::objectExists ($form))
1 ignored issue
show
Bug introduced by
The type VoidCore was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
            $this->application->run ($form);
25
        
26
        elseif ($form === null)
27
            $this->application->run ();
28
29
        else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector');
30
    }
31
    
32
    public function restart (): void
33
    {
34
        $this->application->restart ();
0 ignored issues
show
Bug introduced by
The method restart() does not exist on VoidEngine\WFClass. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

34
        $this->application->/** @scrutinizer ignore-call */ 
35
                            restart ();
Loading history...
35
        $this->close ();
36
    }
37
    
38
    public function close (): void
39
    {
40
        $this->application->exit ();
0 ignored issues
show
Bug introduced by
The method exit() does not exist on VoidEngine\WFClass. Since you implemented __call, consider adding a @method annotation. ( Ignorable by Annotation )

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

40
        $this->application->/** @scrutinizer ignore-call */ 
41
                            exit ();
Loading history...
41
    }
42
43
    public function __call (string $name, array $args)
44
    {
45
        return $this->application->$name (...$args);
46
    }
47
48
    public function __get (string $name)
49
    {
50
        return $this->application->$name;
51
    }
52
};
53
54
$SCREEN = new class
55
{
56
    public WFObject $screen;
57
    
58
    public function __construct ()
59
    {
60
        $this->screen = new WFClass ('System.Windows.Forms.Screen');
61
    }
62
    
63
    public function __get ($name)
64
    {
65
        switch (strtolower ($name))
66
        {
67
            case 'width':
68
            case 'w':
69
                return $this->screen->primaryScreen->bounds->width;
0 ignored issues
show
Bug Best Practice introduced by
The property width does not exist on VoidEngine\WFObject. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property primaryScreen does not exist on VoidEngine\WFObject. Since you implemented __get, consider adding a @property annotation.
Loading history...
Bug Best Practice introduced by
The property bounds does not exist on VoidEngine\WFObject. Since you implemented __get, consider adding a @property annotation.
Loading history...
70
            break;
1 ignored issue
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
71
            
72
            case 'height':
73
            case 'h':
74
                return $this->screen->primaryScreen->bounds->height;
0 ignored issues
show
Bug Best Practice introduced by
The property height does not exist on VoidEngine\WFObject. Since you implemented __get, consider adding a @property annotation.
Loading history...
75
            break;
76
77
            default:
78
                return $this->screen->$name;
79
            break;
80
        }
81
    }
82
    
83
    public function __debugInfo (): array
84
    {
85
        return [
86
            $this->w,
0 ignored issues
show
Bug Best Practice introduced by
The property w does not exist on anonymous//engine/common/Globals.php$1. Since you implemented __get, consider adding a @property annotation.
Loading history...
87
            $this->h
0 ignored issues
show
Bug Best Practice introduced by
The property h does not exist on anonymous//engine/common/Globals.php$1. Since you implemented __get, consider adding a @property annotation.
Loading history...
88
        ];
89
    }
90
};
91