Skip to content

Commit 06bb5a6

Browse files
committed
Add Input class for catch data from mta server
1 parent 8616b81 commit 06bb5a6

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/Mta.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use MultiTheftAuto\Sdk\Model\Resources;
2626
use MultiTheftAuto\Sdk\Model\Server;
2727
use MultiTheftAuto\Sdk\Response\HttpStatusVerification;
28+
use MultiTheftAuto\Sdk\Utils\Input;
2829
use MultiTheftAuto\Sdk\Utils\Translator;
2930

3031
class Mta
@@ -81,12 +82,7 @@ public function getResource(string $resourceName): Resource
8182

8283
public static function getInput(): ?array
8384
{
84-
$input = file_get_contents('php://input');
85-
if (!$input) {
86-
return null;
87-
}
88-
89-
return Translator::fromServer($input)?? null;
85+
return Translator::fromServer(Input::get())?? null;
9086
}
9187

9288
public static function doReturn(...$arguments): void

src/Utils/Input.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
/*****************************************************************************
4+
*
5+
* PROJECT: MTA PHP SDK
6+
* LICENSE: See LICENSE in the top level directory
7+
* FILE: Input.php
8+
* VERSION: 1.0.0
9+
*
10+
* Multi Theft Auto is available from http://www.multitheftauto.com/
11+
*
12+
*****************************************************************************/
13+
14+
declare(strict_types=1);
15+
16+
namespace MultiTheftAuto\Sdk\Utils;
17+
18+
class Input
19+
{
20+
public static function get(): ?string
21+
{
22+
$input = file_get_contents('php://input');
23+
return $input?? null;
24+
}
25+
}

0 commit comments

Comments
 (0)