Passed
Push — master ( 91110f...81d629 )
by Markus
02:39
created
src/HttpHandler.php 2 patches
Indentation   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -25,43 +25,43 @@  discard block
 block discarded – undo
25 25
 	/**
26 26
 	 * The http client instance.
27 27
 	 *
28
-     * @var \Http\Client\HttpClient
29
-     */
30
-    protected $client;
31
-
32
-    /**
33
-     * The message factory instance.
34
-     *
35
-     * @var \Http\Message\MessageFactory
36
-     */
37
-    protected $messageFactory;
38
-
39
-    /**
40
-     * The options array.
41
-     *
42
-     * @var array
43
-     */
44
-    protected $options = [
45
-    	'uri'             => null,
46
-    	'method'          => 'GET',
47
-    	'headers'         => [
48
-    		'Content-Type' => 'application/json'
49
-    	],
50
-    	'protocolVersion' => '1.1'
51
-    ];
52
-
53
-    /**
54
-     * Initializes a new instance of the {@see HttpHandler} class.
55
-     *
56
-     * @param  array                $options The array of options consisting of the uri, method, headers and protocol
57
-     *                                       version.
58
-     * @param  HttpClient|null      $client  An instance of a psr-7 http client implementation or null when the
59
-     *                                       HttpClientDiscovery should be used to find an instance.
60
-     * @param  MessageFactory|null  $factory An instance of a psr-7 message factory implementation or null when
61
-     *                                       the MessageFactoryDiscovery should be used to find an instance.
62
-     * @param  int                  $level   The minimum logging level at which this handler will be triggered.
63
-     * @param  boolean              $bubble  Whether the messages that are handled can bubble up the stack or not.
64
-     */
28
+	 * @var \Http\Client\HttpClient
29
+	 */
30
+	protected $client;
31
+
32
+	/**
33
+	 * The message factory instance.
34
+	 *
35
+	 * @var \Http\Message\MessageFactory
36
+	 */
37
+	protected $messageFactory;
38
+
39
+	/**
40
+	 * The options array.
41
+	 *
42
+	 * @var array
43
+	 */
44
+	protected $options = [
45
+		'uri'             => null,
46
+		'method'          => 'GET',
47
+		'headers'         => [
48
+			'Content-Type' => 'application/json'
49
+		],
50
+		'protocolVersion' => '1.1'
51
+	];
52
+
53
+	/**
54
+	 * Initializes a new instance of the {@see HttpHandler} class.
55
+	 *
56
+	 * @param  array                $options The array of options consisting of the uri, method, headers and protocol
57
+	 *                                       version.
58
+	 * @param  HttpClient|null      $client  An instance of a psr-7 http client implementation or null when the
59
+	 *                                       HttpClientDiscovery should be used to find an instance.
60
+	 * @param  MessageFactory|null  $factory An instance of a psr-7 message factory implementation or null when
61
+	 *                                       the MessageFactoryDiscovery should be used to find an instance.
62
+	 * @param  int                  $level   The minimum logging level at which this handler will be triggered.
63
+	 * @param  boolean              $bubble  Whether the messages that are handled can bubble up the stack or not.
64
+	 */
65 65
 	public function __construct(
66 66
 		array $options = [],
67 67
 		HttpClient $client = null,
@@ -237,78 +237,78 @@  discard block
 block discarded – undo
237 237
 	public function handleBatch(array $records)
238 238
 	{
239 239
 		foreach ($records as $key => $record) {
240
-	        if ($this->isHandling($record)) {
241
-	        	$record = $this->processRecord($record);
242
-	    		$records['records'][] = $record;
243
-	    	}
240
+			if ($this->isHandling($record)) {
241
+				$record = $this->processRecord($record);
242
+				$records['records'][] = $record;
243
+			}
244 244
 
245 245
 			unset($records[$key]);
246
-	    }
246
+		}
247
+
248
+		$records['formatted'] = $this->getFormatter()->formatBatch($records['records'] ?? []);
247 249
 
248
-	    $records['formatted'] = $this->getFormatter()->formatBatch($records['records'] ?? []);
250
+		$this->write($records);
249 251
 
250
-	    $this->write($records);
252
+		return false === $this->bubble;
253
+	}
254
+
255
+	/**
256
+	 * Gets the default formatter.
257
+	 *
258
+	 * @return \Monolog\Formatter\JsonFormatter
259
+	 */
260
+	protected function getDefaultFormatter() : FormatterInterface
261
+	{
262
+		return new JsonFormatter();
263
+	}
251 264
 
252
-	    return false === $this->bubble;
265
+	/**
266
+	 * Returns the HTTP adapter.
267
+	 *
268
+	 * @return \Http\Client\HttpClient
269
+	 */
270
+	protected function getHttpClient(): HttpClient
271
+	{
272
+		return $this->client;
253 273
 	}
254 274
 
255 275
 	/**
256
-     * Gets the default formatter.
257
-     *
258
-     * @return \Monolog\Formatter\JsonFormatter
259
-     */
260
-    protected function getDefaultFormatter() : FormatterInterface
261
-    {
262
-        return new JsonFormatter();
263
-    }
276
+	 * Returns the message factory.
277
+	 *
278
+	 * @return \Http\Message\MessageFactory
279
+	 */
280
+	protected function getMessageFactory(): MessageFactory
281
+	{
282
+		return $this->messageFactory;
283
+	}
264 284
 
265 285
 	/**
266
-     * Returns the HTTP adapter.
267
-     *
268
-     * @return \Http\Client\HttpClient
269
-     */
270
-    protected function getHttpClient(): HttpClient
271
-    {
272
-        return $this->client;
273
-    }
274
-
275
-    /**
276
-     * Returns the message factory.
277
-     *
278
-     * @return \Http\Message\MessageFactory
279
-     */
280
-    protected function getMessageFactory(): MessageFactory
281
-    {
282
-        return $this->messageFactory;
283
-    }
284
-
285
-    /**
286
-     * Writes the record.
287
-     *
288
-     * @param  array $record
289
-     * @return void
290
-     */
291
-    protected function write(array $record)
292
-    {
293
-    	$uri = $this->getUri();
294
-
295
-    	if (empty($uri)) {
296
-    		return;
297
-    	}
298
-
299
-    	$request = $this->getMessageFactory()->createRequest(
300
-    		$this->getMethod(),
301
-    		$this->getUri(),
302
-    		$this->getHeaders(),
303
-    		$record['formatted'],
304
-    		$this->getProtocolVersion()
305
-    	);
306
-
307
-    	try {
308
-    		$this->getHttpClient()->sendRequest($request);
309
-    	} catch (\Exception $e) {
310
-    		// QUESTION(msschl): How to handle the thrown exceptions???
311
-    		return;
312
-    	}
313
-    }
286
+	 * Writes the record.
287
+	 *
288
+	 * @param  array $record
289
+	 * @return void
290
+	 */
291
+	protected function write(array $record)
292
+	{
293
+		$uri = $this->getUri();
294
+
295
+		if (empty($uri)) {
296
+			return;
297
+		}
298
+
299
+		$request = $this->getMessageFactory()->createRequest(
300
+			$this->getMethod(),
301
+			$this->getUri(),
302
+			$this->getHeaders(),
303
+			$record['formatted'],
304
+			$this->getProtocolVersion()
305
+		);
306
+
307
+		try {
308
+			$this->getHttpClient()->sendRequest($request);
309
+		} catch (\Exception $e) {
310
+			// QUESTION(msschl): How to handle the thrown exceptions???
311
+			return;
312
+		}
313
+	}
314 314
 }
315 315
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -156,7 +156,7 @@
 block discarded – undo
156 156
 	 */
157 157
 	public function getHeaders() : array
158 158
 	{
159
-		return $this->options['headers'] ?? [ 'Content-Type' => 'application/json' ];
159
+		return $this->options['headers'] ?? ['Content-Type' => 'application/json'];
160 160
 	}
161 161
 
162 162
 	/**
Please login to merge, or discard this patch.