Completed
Push — master ( f82605...39b80f )
by Lukáš
36:49 queued 30:33
created

JsonFormat::formatParams()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Lookyman\Rundeck\Api\Format;
5
6
use Psr\Http\Message\RequestInterface;
7
8
class JsonFormat implements FormatInterface
9
{
10
	/**
11
	 * @param callable $handler
12
	 * @return callable
13
	 */
14
	public function setFormat(callable $handler): callable
15
	{
16
		return function (RequestInterface $request, array $options) use ($handler) {
17
			return $handler($request->withAddedHeader('Content-Type', 'application/json')->withAddedHeader('Accept', 'application/json'), $options);
18
		};
19
	}
20
21
	/**
22
	 * @param array $params
23
	 * @return string
24
	 */
25
	public function formatParams(array $params): string
26
	{
27
		return \GuzzleHttp\json_encode($params);
28
	}
29
}
30