Passed
Push — master ( c1a8c1...b5fef0 )
by Shahrad
02:24
created
src/lib/Entities/Response.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@
 block discarded – undo
42 42
         $data['raw_data'] = $data;
43 43
         $this->response = $data;
44 44
 
45
-        $is_ok = (bool)($data['ok'] ?? false);
45
+        $is_ok = (bool) ($data['ok'] ?? false);
46 46
         $result = $data['result'] ?? null;
47 47
 
48 48
         if ($is_ok) {
Please login to merge, or discard this patch.
src/lib/Entities/UserProfilePhotos.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -37,7 +37,7 @@
 block discarded – undo
37 37
 
38 38
         if ($these_photos = $this->getProperty('photos')) {
39 39
             foreach ($these_photos as $photos) {
40
-                $all_photos[] = array_map(function ($photo) {
40
+                $all_photos[] = array_map(function($photo) {
41 41
                     return new PhotoSize($photo);
42 42
                 }, $photos);
43 43
             }
Please login to merge, or discard this patch.
src/lib/Util/Common.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,9 @@
 block discarded – undo
20 20
      */
21 21
     public static function isJson(?string $string): bool
22 22
     {
23
-        if (!is_string($string)) return false;
23
+        if (!is_string($string)) {
24
+            return false;
25
+        }
24 26
         json_decode($string);
25 27
         return json_last_error() === JSON_ERROR_NONE;
26 28
     }
Please login to merge, or discard this patch.
src/lib/Util/DotEnv.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
             return [];
25 25
         }
26 26
         $data = file_get_contents($path);
27
-        return array_map(function ($item) {
27
+        return array_map(function($item) {
28 28
             return explode('=', $item);
29 29
         }, explode("\n", $data));
30 30
     }
Please login to merge, or discard this patch.
Braces   +8 added lines, -3 removed lines patch added patch discarded remove patch
@@ -37,8 +37,11 @@  discard block
 block discarded – undo
37 37
      */
38 38
     public static function load(string $path = null): self
39 39
     {
40
-        if (empty($path)) $data = self::read(getcwd() . '/.env');
41
-        else $data = self::read($path);
40
+        if (empty($path)) {
41
+            $data = self::read(getcwd() . '/.env');
42
+        } else {
43
+            $data = self::read($path);
44
+        }
42 45
         foreach ($data as $item) {
43 46
             [$key, $value] = $item;
44 47
             if (count($item) == 2) {
@@ -73,7 +76,9 @@  discard block
 block discarded – undo
73 76
     public static function put(string $key, string $value, bool $save = false): void
74 77
     {
75 78
         putenv($key . '=' . $value);
76
-        if ($save) self::saveTo($_SERVER['DOCUMENT_ROOT'] . '/.env', [$key => $value]);
79
+        if ($save) {
80
+            self::saveTo($_SERVER['DOCUMENT_ROOT'] . '/.env', [$key => $value]);
81
+        }
77 82
     }
78 83
 
79 84
     /**
Please login to merge, or discard this patch.
src/lib/Entities/MenuButton/Factory.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
             'default'  => MenuButtonDefault::class,
15 15
         ];
16 16
 
17
-        if (! isset($type[$data['type'] ?? ''])) {
17
+        if (!isset($type[$data['type'] ?? ''])) {
18 18
             return new MenuButtonNotImplemented($data);
19 19
         }
20 20
 
Please login to merge, or discard this patch.
src/lib/Entities/InlineKeyboard.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -10,14 +10,14 @@
 block discarded – undo
10 10
 class InlineKeyboard extends Keyboard
11 11
 {
12 12
 
13
-	/**
14
-	 * Creates instance of Keyboard
15
-	 *
16
-	 * @return InlineKeyboard
17
-	 */
18
-	public static function make(): InlineKeyboard
19
-	{
20
-		return new self();
21
-	}
13
+    /**
14
+     * Creates instance of Keyboard
15
+     *
16
+     * @return InlineKeyboard
17
+     */
18
+    public static function make(): InlineKeyboard
19
+    {
20
+        return new self();
21
+    }
22 22
 
23 23
 }
Please login to merge, or discard this patch.
src/lib/Entities/KeyboardButton.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -34,83 +34,83 @@
 block discarded – undo
34 34
 class KeyboardButton extends Entity
35 35
 {
36 36
 
37
-	/**
38
-	 * @param array|string $data
39
-	 */
40
-	public function __construct($data)
41
-	{
42
-		if (is_string($data)) {
43
-			$data = ['text' => $data];
44
-		}
37
+    /**
38
+     * @param array|string $data
39
+     */
40
+    public function __construct($data)
41
+    {
42
+        if (is_string($data)) {
43
+            $data = ['text' => $data];
44
+        }
45 45
 
46
-		parent::__construct($data);
47
-	}
46
+        parent::__construct($data);
47
+    }
48 48
 
49
-	/**
50
-	 * Creates instance of KeyboardButton
51
-	 *
52
-	 * @param string $string
53
-	 * @return KeyboardButton
54
-	 */
55
-	public static function make(string $string): KeyboardButton
56
-	{
57
-		return new self($string);
58
-	}
49
+    /**
50
+     * Creates instance of KeyboardButton
51
+     *
52
+     * @param string $string
53
+     * @return KeyboardButton
54
+     */
55
+    public static function make(string $string): KeyboardButton
56
+    {
57
+        return new self($string);
58
+    }
59 59
 
60
-	/**
61
-	 * @param string $url
62
-	 * @return $this
63
-	 */
64
-	public function WebApp(string $url): KeyboardButton
65
-	{
66
-		$this->raw_data['web_app'] = new WebAppInfo(['url' => $url]);
60
+    /**
61
+     * @param string $url
62
+     * @return $this
63
+     */
64
+    public function WebApp(string $url): KeyboardButton
65
+    {
66
+        $this->raw_data['web_app'] = new WebAppInfo(['url' => $url]);
67 67
 
68
-		return $this;
69
-	}
68
+        return $this;
69
+    }
70 70
 
71
-	/**
72
-	 * @inheritDoc
73
-	 */
74
-	protected function subEntities(): array
75
-	{
76
-		return [
77
-			'request_poll' => KeyboardButtonPollType::class,
78
-			'web_app' => WebAppInfo::class,
79
-		];
80
-	}
71
+    /**
72
+     * @inheritDoc
73
+     */
74
+    protected function subEntities(): array
75
+    {
76
+        return [
77
+            'request_poll' => KeyboardButtonPollType::class,
78
+            'web_app' => WebAppInfo::class,
79
+        ];
80
+    }
81 81
 
82
-	/**
83
-	 * Check if the passed data array could be a KeyboardButton.
84
-	 *
85
-	 * @param array $data
86
-	 *
87
-	 * @return bool
88
-	 */
89
-	public static function couldBe(array $data): bool
90
-	{
91
-		return array_key_exists('text', $data);
92
-	}
82
+    /**
83
+     * Check if the passed data array could be a KeyboardButton.
84
+     *
85
+     * @param array $data
86
+     *
87
+     * @return bool
88
+     */
89
+    public static function couldBe(array $data): bool
90
+    {
91
+        return array_key_exists('text', $data);
92
+    }
93 93
 
94
-	/**
95
-	 * {@inheritdoc}
96
-	 */
97
-	protected function validate(): void
98
-	{
99
-		if ($this->getProperty('text', '') === '') {
100
-			throw new TelegramException('You must add some text to the button!');
101
-		}
102
-	}
94
+    /**
95
+     * {@inheritdoc}
96
+     */
97
+    protected function validate(): void
98
+    {
99
+        if ($this->getProperty('text', '') === '') {
100
+            throw new TelegramException('You must add some text to the button!');
101
+        }
102
+    }
103 103
 
104
-	/**
105
-	 * {@inheritdoc}
106
-	 */
107
-	public function __call(string $name, array $arguments): mixed
108
-	{
109
-		if (in_array($name, ['setRequestContact', 'setRequestLocation', 'setRequestPoll', 'setWebApp'], true)) {
110
-			unset($this->request_contact, $this->request_location, $this->request_poll, $this->web_app);
111
-		}
104
+    /**
105
+     * {@inheritdoc}
106
+     */
107
+    public function __call(string $name, array $arguments): mixed
108
+    {
109
+        if (in_array($name, ['setRequestContact', 'setRequestLocation', 'setRequestPoll', 'setWebApp'], true)) {
110
+            unset($this->request_contact, $this->request_location, $this->request_poll, $this->web_app);
111
+        }
112 112
 
113
-		return parent::__call($name, $arguments);
114
-	}
113
+        return parent::__call($name, $arguments);
114
+    }
115 115
 
116 116
 }
Please login to merge, or discard this patch.
src/lib/Entities/WebAppInfo.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -19,13 +19,13 @@
 block discarded – undo
19 19
 class WebAppInfo extends Entity
20 20
 {
21 21
 
22
-	public function __construct($data)
23
-	{
24
-		if (is_string($data)) {
25
-			$data = ['url' => $data];
26
-		}
22
+    public function __construct($data)
23
+    {
24
+        if (is_string($data)) {
25
+            $data = ['url' => $data];
26
+        }
27 27
 
28
-		parent::__construct($data);
29
-	}
28
+        parent::__construct($data);
29
+    }
30 30
 
31 31
 }
32 32
\ No newline at end of file
Please login to merge, or discard this patch.
src/lib/Entity.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -141,8 +141,8 @@
 block discarded – undo
141 141
 	public static function escapeMarkdown(string $string): string
142 142
 	{
143 143
 		return str_replace(
144
-			['[', '`', '*', '_',],
145
-			['\[', '\`', '\*', '\_',],
144
+			['[', '`', '*', '_', ],
145
+			['\[', '\`', '\*', '\_', ],
146 146
 			$string
147 147
 		);
148 148
 	}
Please login to merge, or discard this patch.
Indentation   +150 added lines, -150 removed lines patch added patch discarded remove patch
@@ -12,155 +12,155 @@
 block discarded – undo
12 12
 abstract class Entity
13 13
 {
14 14
 
15
-	/**
16
-	 * @var array The raw data passed to this entity
17
-	 */
18
-	protected array $raw_data;
19
-
20
-	/**
21
-	 * Entity constructor.
22
-	 *
23
-	 * @param ?array $data The raw data passed to this entity
24
-	 */
25
-	public function __construct(?array $data)
26
-	{
27
-		if (!empty($data)) {
28
-			$this->assignMemberVariables(($this->raw_data = $data));
29
-			$this->validate();
30
-		}
31
-	}
32
-
33
-	/**
34
-	 * Get the raw data passed to this entity
35
-	 *
36
-	 * @param bool $associated
37
-	 * @return array|string
38
-	 */
39
-	public function getRawData(bool $associated = true): array|string
40
-	{
41
-		return $associated ? $this->raw_data : json_encode($this->raw_data);
42
-	}
43
-
44
-	/**
45
-	 * Helper to set member variables
46
-	 *
47
-	 * @param array $data
48
-	 * @return void
49
-	 */
50
-	protected function assignMemberVariables(array $data): void
51
-	{
52
-		foreach ($data as $key => $value) {
53
-			$this->$key = $value;
54
-		}
55
-	}
56
-
57
-	/**
58
-	 * Get a property from the current Entity
59
-	 *
60
-	 * @param string $property
61
-	 * @param mixed $default
62
-	 *
63
-	 * @return mixed
64
-	 */
65
-	public function getProperty(string $property, mixed $default = null): mixed
66
-	{
67
-		return $this->raw_data[$property] ?? $default;
68
-	}
69
-
70
-	/**
71
-	 * Get the list of the properties that are themselves Entities
72
-	 *
73
-	 * @return array
74
-	 */
75
-	protected function subEntities(): array
76
-	{
77
-		return [];
78
-	}
79
-
80
-	/**
81
-	 * Perform any special entity validation
82
-	 *
83
-	 * @return void
84
-	 */
85
-	protected function validate(): void
86
-	{
87
-		// Do nothing by default
88
-	}
89
-
90
-	/**
91
-	 * @param string $name The name of the property
92
-	 * @param array $arguments The arguments passed to the method
93
-	 * @return mixed
94
-	 */
95
-	public function __call(string $name, array $arguments): mixed
96
-	{
97
-		if (method_exists($this, $name)) {
98
-			return $this->{$name}(...$arguments);
99
-		}
100
-
101
-		if (str_starts_with($name, 'get')) {
102
-			$property_name = strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', substr($name, 3)), '_'));
103
-
104
-			$property = $this->getProperty($property_name);
105
-			$sub_entities = $this->subEntities() ?? [];
106
-
107
-			if (isset($sub_entities[$property_name])) {
108
-				$class_name = $sub_entities[$property_name];
109
-				return Factory::resolveEntityClass($class_name, $property);
110
-			}
111
-
112
-			return $property ?? null;
113
-		}
114
-
115
-		if (str_starts_with($name, 'set')) {
116
-			$property_name = strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', substr($name, 3)), '_'));
117
-
118
-			if (property_exists($this, $property_name)) {
119
-				$this->{$property_name} = $arguments[0];
120
-				$this->raw_data[$property_name] = $arguments[0];
121
-
122
-				return $this;
123
-			}
124
-
125
-		}
126
-
127
-		throw new \BadMethodCallException("Method '$name' does not exist");
128
-	}
129
-
130
-	/**
131
-	 * Escape markdown (v1) special characters
132
-	 *
133
-	 * @see https://core.telegram.org/bots/api#markdown-style
134
-	 *
135
-	 * @param string $string
136
-	 *
137
-	 * @return string
138
-	 */
139
-	public static function escapeMarkdown(string $string): string
140
-	{
141
-		return str_replace(
142
-			['[', '`', '*', '_',],
143
-			['\[', '\`', '\*', '\_',],
144
-			$string
145
-		);
146
-	}
147
-
148
-	/**
149
-	 * Escape markdown (v2) special characters
150
-	 *
151
-	 * @see https://core.telegram.org/bots/api#markdownv2-style
152
-	 *
153
-	 * @param string $string
154
-	 *
155
-	 * @return string
156
-	 */
157
-	public static function escapeMarkdownV2(string $string): string
158
-	{
159
-		return str_replace(
160
-			['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'],
161
-			['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'],
162
-			$string
163
-		);
164
-	}
15
+    /**
16
+     * @var array The raw data passed to this entity
17
+     */
18
+    protected array $raw_data;
19
+
20
+    /**
21
+     * Entity constructor.
22
+     *
23
+     * @param ?array $data The raw data passed to this entity
24
+     */
25
+    public function __construct(?array $data)
26
+    {
27
+        if (!empty($data)) {
28
+            $this->assignMemberVariables(($this->raw_data = $data));
29
+            $this->validate();
30
+        }
31
+    }
32
+
33
+    /**
34
+     * Get the raw data passed to this entity
35
+     *
36
+     * @param bool $associated
37
+     * @return array|string
38
+     */
39
+    public function getRawData(bool $associated = true): array|string
40
+    {
41
+        return $associated ? $this->raw_data : json_encode($this->raw_data);
42
+    }
43
+
44
+    /**
45
+     * Helper to set member variables
46
+     *
47
+     * @param array $data
48
+     * @return void
49
+     */
50
+    protected function assignMemberVariables(array $data): void
51
+    {
52
+        foreach ($data as $key => $value) {
53
+            $this->$key = $value;
54
+        }
55
+    }
56
+
57
+    /**
58
+     * Get a property from the current Entity
59
+     *
60
+     * @param string $property
61
+     * @param mixed $default
62
+     *
63
+     * @return mixed
64
+     */
65
+    public function getProperty(string $property, mixed $default = null): mixed
66
+    {
67
+        return $this->raw_data[$property] ?? $default;
68
+    }
69
+
70
+    /**
71
+     * Get the list of the properties that are themselves Entities
72
+     *
73
+     * @return array
74
+     */
75
+    protected function subEntities(): array
76
+    {
77
+        return [];
78
+    }
79
+
80
+    /**
81
+     * Perform any special entity validation
82
+     *
83
+     * @return void
84
+     */
85
+    protected function validate(): void
86
+    {
87
+        // Do nothing by default
88
+    }
89
+
90
+    /**
91
+     * @param string $name The name of the property
92
+     * @param array $arguments The arguments passed to the method
93
+     * @return mixed
94
+     */
95
+    public function __call(string $name, array $arguments): mixed
96
+    {
97
+        if (method_exists($this, $name)) {
98
+            return $this->{$name}(...$arguments);
99
+        }
100
+
101
+        if (str_starts_with($name, 'get')) {
102
+            $property_name = strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', substr($name, 3)), '_'));
103
+
104
+            $property = $this->getProperty($property_name);
105
+            $sub_entities = $this->subEntities() ?? [];
106
+
107
+            if (isset($sub_entities[$property_name])) {
108
+                $class_name = $sub_entities[$property_name];
109
+                return Factory::resolveEntityClass($class_name, $property);
110
+            }
111
+
112
+            return $property ?? null;
113
+        }
114
+
115
+        if (str_starts_with($name, 'set')) {
116
+            $property_name = strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', substr($name, 3)), '_'));
117
+
118
+            if (property_exists($this, $property_name)) {
119
+                $this->{$property_name} = $arguments[0];
120
+                $this->raw_data[$property_name] = $arguments[0];
121
+
122
+                return $this;
123
+            }
124
+
125
+        }
126
+
127
+        throw new \BadMethodCallException("Method '$name' does not exist");
128
+    }
129
+
130
+    /**
131
+     * Escape markdown (v1) special characters
132
+     *
133
+     * @see https://core.telegram.org/bots/api#markdown-style
134
+     *
135
+     * @param string $string
136
+     *
137
+     * @return string
138
+     */
139
+    public static function escapeMarkdown(string $string): string
140
+    {
141
+        return str_replace(
142
+            ['[', '`', '*', '_',],
143
+            ['\[', '\`', '\*', '\_',],
144
+            $string
145
+        );
146
+    }
147
+
148
+    /**
149
+     * Escape markdown (v2) special characters
150
+     *
151
+     * @see https://core.telegram.org/bots/api#markdownv2-style
152
+     *
153
+     * @param string $string
154
+     *
155
+     * @return string
156
+     */
157
+    public static function escapeMarkdownV2(string $string): string
158
+    {
159
+        return str_replace(
160
+            ['_', '*', '[', ']', '(', ')', '~', '`', '>', '#', '+', '-', '=', '|', '{', '}', '.', '!'],
161
+            ['\_', '\*', '\[', '\]', '\(', '\)', '\~', '\`', '\>', '\#', '\+', '\-', '\=', '\|', '\{', '\}', '\.', '\!'],
162
+            $string
163
+        );
164
+    }
165 165
 
166 166
 }
167 167
\ No newline at end of file
Please login to merge, or discard this patch.