Code Duplication    Length = 20-20 lines in 2 locations

src/API/Kitsu/KitsuTrait.php 1 location

@@ 161-180 (lines=20) @@
158
	 * @param array $options
159
	 * @return array
160
	 */
161
	private function request(string $type, string $url, array $options = []): array
162
	{
163
		$logger = null;
164
		if ($this->getContainer())
165
		{
166
			$logger = $this->container->getLogger('kitsu-request');
167
		}
168
169
		$response = $this->getResponse($type, $url, $options);
170
171
		if ((int) $response->getStatusCode() > 299 || (int) $response->getStatusCode() < 200)
172
		{
173
			if ($logger)
174
			{
175
				$logger->warning('Non 200 response for api call', $response->getBody());
176
			}
177
		}
178
179
		return JSON::decode($response->getBody(), TRUE);
180
	}
181
182
	/**
183
	 * Remove some boilerplate for get requests

src/API/MAL/MALTrait.php 1 location

@@ 176-195 (lines=20) @@
173
	 * @param array $options
174
	 * @return array
175
	 */
176
	private function request(string $type, string $url, array $options = []): array
177
	{
178
		$logger = null;
179
		if ($this->getContainer())
180
		{
181
			$logger = $this->container->getLogger('mal-request');
182
		}
183
184
		$response = $this->getResponse($type, $url, $options);
185
186
		if ((int) $response->getStatus() > 299 || (int) $response->getStatus() < 200)
187
		{
188
			if ($logger)
189
			{
190
				$logger->warning('Non 200 response for api call', $response->getBody());
191
			}
192
		}
193
194
		return XML::toArray((string) $response->getBody());
195
	}
196
197
	/**
198
	 * Remove some boilerplate for get requests