Passed
Branch master (bce341)
by Aleksandr
03:04
created
src/request/MessagesRequest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 	{
64 64
 		$params = [];
65 65
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
66
-		    $params[$key] = $value;
66
+			$params[$key] = $value;
67 67
 		}
68 68
 		return $this->getClient()->getContent('messages.readPrivate', $params, 'carono\etxtru\response\ReadPrivateResponse');
69 69
 	}
Please login to merge, or discard this patch.
src/request/ArticlesArchiveRequest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 	{
19 19
 		$params = [];
20 20
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
21
-		    $params[$key] = $value;
21
+			$params[$key] = $value;
22 22
 		}
23 23
 		return $this->getClient()->getContent('articles_archive.getList', $params, 'carono\etxtru\response\GetListResponse');
24 24
 	}
Please login to merge, or discard this patch.
src/request/TasksArchiveRequest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 	{
19 19
 		$params = [];
20 20
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
21
-		    $params[$key] = $value;
21
+			$params[$key] = $value;
22 22
 		}
23 23
 		return $this->getClient()->getContent('tasks_archive.listTasks', $params, 'carono\etxtru\response\ListTasksResponse');
24 24
 	}
Please login to merge, or discard this patch.
src/request/CorrectionRequest.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	{
19 19
 		$params = [];
20 20
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
21
-		    $params[$key] = $value;
21
+			$params[$key] = $value;
22 22
 		}
23 23
 		return $this->getClient()->getContent('correction.add', $params, 'carono\etxtru\response\AddResponse');
24 24
 	}
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 	{
35 35
 		$params = [];
36 36
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
37
-		    $params[$key] = $value;
37
+			$params[$key] = $value;
38 38
 		}
39 39
 		return $this->getClient()->getContent('correction.import', $params, 'carono\etxtru\response\ImportResponse');
40 40
 	}
Please login to merge, or discard this patch.
src/request/ArticlesRequest.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@
 block discarded – undo
19 19
 	{
20 20
 		$params = [];
21 21
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
22
-		    $params[$key] = $value;
22
+			$params[$key] = $value;
23 23
 		}
24 24
 		return $this->getClient()->getContent('articles.getList', $params, 'carono\etxtru\response\GetListResponse');
25 25
 	}
Please login to merge, or discard this patch.
src/request/TasksRequest.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	{
19 19
 		$params = [];
20 20
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
21
-		    $params[$key] = $value;
21
+			$params[$key] = $value;
22 22
 		}
23 23
 		return $this->getClient()->getContent('tasks.listTasks', $params, 'carono\etxtru\response\ListTasksResponse');
24 24
 	}
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	{
181 181
 		$params = [];
182 182
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
183
-		    $params[$key] = $value;
183
+			$params[$key] = $value;
184 184
 		}
185 185
 		return $this->getClient()->getContent('tasks.saveTask', $params, 'carono\etxtru\response\SaveTaskResponse');
186 186
 	}
Please login to merge, or discard this patch.
src/request/UsersRequest.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	{
19 19
 		$params = [];
20 20
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
21
-		    $params[$key] = $value;
21
+			$params[$key] = $value;
22 22
 		}
23 23
 		return $this->getClient()->getContent('users.getList', $params, 'carono\etxtru\response\GetListResponse');
24 24
 	}
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	{
120 120
 		$params = [];
121 121
 		foreach ($config instanceof \carono\etxtru\ConfigAbstract ? $config->toArray() : $config as $key => $value) {
122
-		    $params[$key] = $value;
122
+			$params[$key] = $value;
123 123
 		}
124 124
 		return $this->getClient()->getContent('users.setReport', $params, 'carono\etxtru\response\SetReportResponse');
125 125
 	}
Please login to merge, or discard this patch.
src/ResponseAbstract.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -6,22 +6,22 @@
 block discarded – undo
6 6
 
7 7
 abstract class ResponseAbstract extends ArrayObject
8 8
 {
9
-    /**
10
-     * @var boolean
11
-     */
12
-    public $success;
13
-    /**
14
-     * @var string
15
-     */
16
-    public $error;
9
+	/**
10
+	 * @var boolean
11
+	 */
12
+	public $success;
13
+	/**
14
+	 * @var string
15
+	 */
16
+	public $error;
17 17
 
18 18
 
19
-    /**
20
-     * @param $property
21
-     * @return mixed|null
22
-     */
23
-    public function getResponseClass($property)
24
-    {
25
-        return isset($this->_responseClasses[$property]) ? $this->_responseClasses[$property] : null;
26
-    }
19
+	/**
20
+	 * @param $property
21
+	 * @return mixed|null
22
+	 */
23
+	public function getResponseClass($property)
24
+	{
25
+		return isset($this->_responseClasses[$property]) ? $this->_responseClasses[$property] : null;
26
+	}
27 27
 }
28 28
\ No newline at end of file
Please login to merge, or discard this patch.
src/Client.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -8,70 +8,70 @@
 block discarded – undo
8 8
 
9 9
 class Client extends ClientAbstract
10 10
 {
11
-    public $apiKey;
12
-    public $url = 'www.etxt.ru/api/json';
13
-    public $method = 'POST';
14
-    public $type = self::TYPE_MULTIPART;
15
-    public $output_type = self::TYPE_JSON;
11
+	public $apiKey;
12
+	public $url = 'www.etxt.ru/api/json';
13
+	public $method = 'POST';
14
+	public $type = self::TYPE_MULTIPART;
15
+	public $output_type = self::TYPE_JSON;
16 16
 
17
-    protected function sign($method)
18
-    {
19
-        $baseParamsArr = [
20
-            'token' => $this->apiKey,
21
-            'method' => $method
22
-        ];
23
-        ksort($baseParamsArr);
24
-        $params = '';
25
-        foreach ($baseParamsArr as $key => $val) {
26
-            $params .= ($key . '=' . $val);
27
-        }
28
-        return md5($params . md5($this->password . 'api-pass'));
29
-    }
17
+	protected function sign($method)
18
+	{
19
+		$baseParamsArr = [
20
+			'token' => $this->apiKey,
21
+			'method' => $method
22
+		];
23
+		ksort($baseParamsArr);
24
+		$params = '';
25
+		foreach ($baseParamsArr as $key => $val) {
26
+			$params .= ($key . '=' . $val);
27
+		}
28
+		return md5($params . md5($this->password . 'api-pass'));
29
+	}
30 30
 
31
-    /**
32
-     * @param $urlRequest
33
-     * @param array $data
34
-     * @param string $responseClass
35
-     * @return mixed
36
-     */
37
-    public function getContent($urlRequest, $data = [], $responseClass = Response::class)
38
-    {
39
-        try {
40
-            $method = $urlRequest;
41
-            $sign = $this->sign($method);
42
-            $urlRequest = '?' . build_query(['token' => $this->apiKey, 'method' => $method, 'sign' => $sign]);
43
-            $content = parent::getContent($urlRequest, $data);
44
-            return self::stdClassToResponse($content, $responseClass);
45
-        } catch (\Exception $e) {
46
-            $this->request->getBody()->rewind();
47
-            $response = new Response();
48
-            $response->success = false;
49
-            $response->error = $this->request->getBody()->getContents();
50
-            return $response;
51
-        }
52
-    }
31
+	/**
32
+	 * @param $urlRequest
33
+	 * @param array $data
34
+	 * @param string $responseClass
35
+	 * @return mixed
36
+	 */
37
+	public function getContent($urlRequest, $data = [], $responseClass = Response::class)
38
+	{
39
+		try {
40
+			$method = $urlRequest;
41
+			$sign = $this->sign($method);
42
+			$urlRequest = '?' . build_query(['token' => $this->apiKey, 'method' => $method, 'sign' => $sign]);
43
+			$content = parent::getContent($urlRequest, $data);
44
+			return self::stdClassToResponse($content, $responseClass);
45
+		} catch (\Exception $e) {
46
+			$this->request->getBody()->rewind();
47
+			$response = new Response();
48
+			$response->success = false;
49
+			$response->error = $this->request->getBody()->getContents();
50
+			return $response;
51
+		}
52
+	}
53 53
 
54
-    /**
55
-     * @param $stdClass
56
-     * @param $responseClass
57
-     * @return ResponseAbstract
58
-     */
59
-    protected static function stdClassToResponse($stdClass, $responseClass)
60
-    {
61
-        /**
62
-         * @var ResponseAbstract $response
63
-         */
64
-        $response = new $responseClass();
65
-        foreach ($stdClass as $key => $value) {
66
-            if (is_array($value) && method_exists($response, 'getResponseClass') && ($class = $response->getResponseClass($key))) {
67
-                foreach ($value as $item) {
68
-                    $response->{$key}[] = self::stdClassToResponse($item, $class);
69
-                }
70
-            } else {
71
-                $response->$key = $value;
72
-            }
73
-        }
74
-        $response->success = !(bool)$response->error;
75
-        return $response;
76
-    }
54
+	/**
55
+	 * @param $stdClass
56
+	 * @param $responseClass
57
+	 * @return ResponseAbstract
58
+	 */
59
+	protected static function stdClassToResponse($stdClass, $responseClass)
60
+	{
61
+		/**
62
+		 * @var ResponseAbstract $response
63
+		 */
64
+		$response = new $responseClass();
65
+		foreach ($stdClass as $key => $value) {
66
+			if (is_array($value) && method_exists($response, 'getResponseClass') && ($class = $response->getResponseClass($key))) {
67
+				foreach ($value as $item) {
68
+					$response->{$key}[] = self::stdClassToResponse($item, $class);
69
+				}
70
+			} else {
71
+				$response->$key = $value;
72
+			}
73
+		}
74
+		$response->success = !(bool)$response->error;
75
+		return $response;
76
+	}
77 77
 }
78 78
\ No newline at end of file
Please login to merge, or discard this patch.