Passed
Push — master ( 2ab801...3e09d8 )
by Shahrad
10:07
created
src/lib/Plugin.php 1 patch
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -14,106 +14,106 @@
 block discarded – undo
14 14
 class Plugin
15 15
 {
16 16
 
17
-	/**
18
-	 * The Update types
19
-	 *
20
-	 * @var array
21
-	 */
22
-	protected array $update_types = [
23
-		'Message',
24
-		'EditedMessage',
25
-		'ChannelPost',
26
-		'EditedChannelPost',
27
-		'InlineQuery',
28
-		'ChosenInlineResult',
29
-		'CallbackQuery',
30
-		'ShippingQuery',
31
-		'PreCheckoutQuery',
32
-	];
33
-
34
-	/**
35
-	 * @var WebhookHandler
36
-	 */
37
-	protected WebhookHandler $hook;
38
-
39
-	/**
40
-	 * @var \Generator
41
-	 */
42
-	protected \Generator $returns;
43
-
44
-	/**
45
-	 * @var bool
46
-	 */
47
-	protected bool $kill_on_yield = true;
48
-
49
-	/**
50
-	 * Check for the exit of the plugin.
51
-	 *
52
-	 * @param \Generator $return
53
-	 * @return void
54
-	 */
55
-	public function __checkExit(\Generator $return): void
56
-	{
57
-		if ($return->valid()) {
58
-			if ($return->current() !== null && $this->kill_on_yield === true) {
59
-				$this->kill();
60
-			}
61
-		}
62
-
63
-		if ($return->valid()) {
64
-			$return->next();
65
-			$this->__checkExit($return);
66
-		}
67
-	}
68
-
69
-	/**
70
-	 * Identify the update type. e.g. Message, EditedMessage, etc.
71
-	 *
72
-	 * @param Update $update
73
-	 * @return string|null
74
-	 */
75
-	public function __identify(Update $update): ?string
76
-	{
77
-		$type = $update->getUpdateType();
78
-
79
-		if ($type === null) {
80
-			return null;
81
-		}
82
-
83
-		return str_replace('_', '', ucwords($type, '_'));
84
-	}
85
-
86
-	/**
87
-	 * Execute the plugin.
88
-	 *
89
-	 * @param WebhookHandler $receiver
90
-	 * @param Update $update
91
-	 * @return void
92
-	 */
93
-	public function __execute(WebhookHandler $receiver, Update $update): void
94
-	{
95
-		$this->hook = $receiver;
96
-
97
-		if (method_exists($this, 'onReceivedUpdate')) {
98
-			$return = $this->onReceivedUpdate($update);
99
-			$this->__checkExit($return);
100
-		}
101
-
102
-		$type = $this->__identify($update);
103
-		if (method_exists($this, ($method = 'on' . $type)) && $type !== null) {
104
-			$return = $this->$method($update);
105
-			$this->__checkExit($return);
106
-		}
107
-	}
108
-
109
-	/**
110
-	 * Kill the plugin.
111
-	 *
112
-	 * @return void
113
-	 */
114
-	public function kill(): void
115
-	{
116
-		$this->hook->kill();
117
-	}
17
+    /**
18
+     * The Update types
19
+     *
20
+     * @var array
21
+     */
22
+    protected array $update_types = [
23
+        'Message',
24
+        'EditedMessage',
25
+        'ChannelPost',
26
+        'EditedChannelPost',
27
+        'InlineQuery',
28
+        'ChosenInlineResult',
29
+        'CallbackQuery',
30
+        'ShippingQuery',
31
+        'PreCheckoutQuery',
32
+    ];
33
+
34
+    /**
35
+     * @var WebhookHandler
36
+     */
37
+    protected WebhookHandler $hook;
38
+
39
+    /**
40
+     * @var \Generator
41
+     */
42
+    protected \Generator $returns;
43
+
44
+    /**
45
+     * @var bool
46
+     */
47
+    protected bool $kill_on_yield = true;
48
+
49
+    /**
50
+     * Check for the exit of the plugin.
51
+     *
52
+     * @param \Generator $return
53
+     * @return void
54
+     */
55
+    public function __checkExit(\Generator $return): void
56
+    {
57
+        if ($return->valid()) {
58
+            if ($return->current() !== null && $this->kill_on_yield === true) {
59
+                $this->kill();
60
+            }
61
+        }
62
+
63
+        if ($return->valid()) {
64
+            $return->next();
65
+            $this->__checkExit($return);
66
+        }
67
+    }
68
+
69
+    /**
70
+     * Identify the update type. e.g. Message, EditedMessage, etc.
71
+     *
72
+     * @param Update $update
73
+     * @return string|null
74
+     */
75
+    public function __identify(Update $update): ?string
76
+    {
77
+        $type = $update->getUpdateType();
78
+
79
+        if ($type === null) {
80
+            return null;
81
+        }
82
+
83
+        return str_replace('_', '', ucwords($type, '_'));
84
+    }
85
+
86
+    /**
87
+     * Execute the plugin.
88
+     *
89
+     * @param WebhookHandler $receiver
90
+     * @param Update $update
91
+     * @return void
92
+     */
93
+    public function __execute(WebhookHandler $receiver, Update $update): void
94
+    {
95
+        $this->hook = $receiver;
96
+
97
+        if (method_exists($this, 'onReceivedUpdate')) {
98
+            $return = $this->onReceivedUpdate($update);
99
+            $this->__checkExit($return);
100
+        }
101
+
102
+        $type = $this->__identify($update);
103
+        if (method_exists($this, ($method = 'on' . $type)) && $type !== null) {
104
+            $return = $this->$method($update);
105
+            $this->__checkExit($return);
106
+        }
107
+    }
108
+
109
+    /**
110
+     * Kill the plugin.
111
+     *
112
+     * @return void
113
+     */
114
+    public function kill(): void
115
+    {
116
+        $this->hook->kill();
117
+    }
118 118
 
119 119
 }
120 120
\ No newline at end of file
Please login to merge, or discard this patch.