Passed
Branch master (72fde7)
by Observer
01:31
created

anonymous//bin/qero-packages/winforms-php/VoidFramework/winforms-php-VoidFramework-232fa29/engine/common/Globals.php$0   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 10
eloc 17
dl 0
loc 44
c 0
b 0
f 0
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A Globals.php$0 ➔ __construct() 0 4 1
A Globals.php$0 ➔ close() 0 3 1
A Globals.php$0 ➔ restart() 0 4 1
A Globals.php$0 ➔ __get() 0 3 1
A Globals.php$0 ➔ __call() 0 3 1
A Globals.php$0 ➔ run() 0 12 5
1
<?php
2
3
namespace VoidEngine;
4
5
$APPLICATION = new class
6
{
7
    public $application;
8
    public $executablePath;
9
    
10
    public function __construct ()
11
    {
12
        $this->application    = new WFClass ('System.Windows.Forms.Application');
13
        $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...
14
    }
15
    
16
    public function run ($form = null): void
17
    {
18
        if ($form instanceof WFObject)
19
            $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

19
            $this->application->/** @scrutinizer ignore-call */ 
20
                                run ($form->selector);
Loading history...
20
        
21
        elseif (is_int ($form) && VoidEngine::objectExists ($form))
22
            $this->application->run ($form);
23
        
24
        elseif ($form === null)
25
            $this->application->run ();
26
27
        else throw new \Exception ('$form param must be instance of "VoidEngine\WFObject" ("VoidEngine\Form"), be null or object selector');
28
    }
29
    
30
    public function restart (): void
31
    {
32
        $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

32
        $this->application->/** @scrutinizer ignore-call */ 
33
                            restart ();
Loading history...
33
        $this->close ();
34
    }
35
    
36
    public function close (): void
37
    {
38
        $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

38
        $this->application->/** @scrutinizer ignore-call */ 
39
                            exit ();
Loading history...
39
    }
40
41
    public function __call (string $name, array $args)
42
    {
43
        return $this->application->$name (...$args);
44
    }
45
46
    public function __get (string $name)
47
    {
48
        return $this->application->$name;
49
    }
50
};
51
52
$SCREEN = new class
53
{
54
    public $screen;
55
    
56
    public function __construct ()
57
    {
58
        $this->screen = new WFClass ('System.Windows.Forms.Screen');
59
    }
60
    
61
    public function __get ($name)
62
    {
63
        switch (strtolower ($name))
64
        {
65
            case 'width':
66
            case 'w':
67
                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 bounds 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\WFClass. Since you implemented __get, consider adding a @property annotation.
Loading history...
68
            break;
0 ignored issues
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...
69
            
70
            case 'height':
71
            case 'h':
72
                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...
73
            break;
74
75
            default:
76
                return $this->screen->$name;
77
            break;
78
        }
79
    }
80
    
81
    public function __debugInfo (): array
82
    {
83
        return [
84
            $this->w,
0 ignored issues
show
Bug Best Practice introduced by
The property w does not exist on anonymous//bin/qero-pack...ne/common/Globals.php$1. Since you implemented __get, consider adding a @property annotation.
Loading history...
85
            $this->h
0 ignored issues
show
Bug Best Practice introduced by
The property h does not exist on anonymous//bin/qero-pack...ne/common/Globals.php$1. Since you implemented __get, consider adding a @property annotation.
Loading history...
86
        ];
87
    }
88
};
89