Code Duplication    Length = 21-21 lines in 2 locations

src/API/Kitsu/KitsuTrait.php 1 location

@@ 176-196 (lines=21) @@
173
	 * @param array $args
174
	 * @return array
175
	 */
176
	protected function postRequest(...$args): array
177
	{
178
		$logger = null;
179
		if ($this->getContainer())
180
		{
181
			$logger = $this->container->getLogger('kitsu-request');
182
		}
183
184
		$response = $this->getResponse('POST', ...$args);
185
		$validResponseCodes = [200, 201];
186
187
		if ( ! in_array((int) $response->getStatus(), $validResponseCodes))
188
		{
189
			if ($logger)
190
			{
191
				$logger->warning('Non 201 response for POST api call', $response->getBody());
192
			}
193
		}
194
195
		return JSON::decode($response->getBody(), TRUE);
196
	}
197
198
	/**
199
	 * Remove some boilerplate for delete requests

src/API/MAL/MALTrait.php 1 location

@@ 187-207 (lines=21) @@
184
	 * @param array $args
185
	 * @return array
186
	 */
187
	protected function postRequest(...$args): array
188
	{
189
		$logger = null;
190
		if ($this->getContainer())
191
		{
192
			$logger = $this->container->getLogger('mal-request');
193
		}
194
195
		$response = $this->getResponse('POST', ...$args);
196
		$validResponseCodes = [200, 201];
197
198
		if ( ! in_array((int) $response->getStatus(), $validResponseCodes))
199
		{
200
			if ($logger)
201
			{
202
				$logger->warning('Non 201 response for POST api call', $response->getBody());
203
			}
204
		}
205
206
		return XML::toArray($response->getBody());
207
	}
208
}