Passed
Push — master ( 232fa2...89a9e2 )
by Observer
01:17
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
$APPLICATION = new class
6
{
7
    public WFClass $application;
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_STRING, expecting T_FUNCTION or T_CONST on line 7 at column 11
Loading history...
8
    public string $executablePath;
9
    
10
    public function __construct ()
11
    {
12
        $this->application    = new WFClass ('System.Windows.Forms.Application');
13
        $this->executablePath = $this->application->executablePath;
14
    }
15
    
16
    public function run ($form = null): void
17
    {
18
        if ($form instanceof WFObject)
19
            $this->application->run ($form->selector);
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 ();
33
        $this->close ();
34
    }
35
    
36
    public function close (): void
37
    {
38
        $this->application->exit ();
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 WFObject $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;
68
            break;
69
            
70
            case 'height':
71
            case 'h':
72
                return $this->screen->primaryScreen->bounds->height;
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,
85
            $this->h
86
        ];
87
    }
88
};
89