/** * {@inheritdoc} */ public function body(HTTPProblem $problem) { $data = ['status' => $problem->status()]; if ($problem->title()) { $data['title'] = $problem->title(); } if (!in_array($problem->type(), [null, 'about:blank'], true)) { $data['type'] = $problem->type(); } if ($problem->detail()) { $data['detail'] = $problem->detail(); } if ($problem->instance()) { $data['instance'] = $problem->instance(); } $data += $problem->extensions(); return json_encode($data, $this->encodingOptions); }
public function testInvalidStatusReturnsUnknownTitle() { $problem = new HTTPProblem(399, 'msg'); $this->assertSame('Unknown', $problem->title()); }