Skip to content

Commit

Permalink
Completed content/media types
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelstolt committed Oct 2, 2017
1 parent a0dda2a commit 4bc8981
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -31,8 +31,8 @@ $problem['accounts'] = array(
$json_string = $problem->asJson();

// Now send that JSON string as a response along with the appropriate HTTP error
// code and content type which is available via ApiProblem::CONTENT_TYPE.
// Also check out asXml() for the angle-bracket fans in the room.
// code and content type which is available via ApiProblem::CONTENT_TYPE_JSON.
// Also check out asXml() and ApiProblem::CONTENT_TYPE_XML for the angle-bracket fans in the room.

```

Expand Down
12 changes: 10 additions & 2 deletions src/ApiProblem.php
Expand Up @@ -39,12 +39,20 @@ class ApiProblem implements \ArrayAccess
{

/**
* The content type for a HTTP response carrying
* The content type for a JSON based HTTP response carrying
* problem details.
*
* @var string
*/
const CONTENT_TYPE = 'application/problem+json';
const CONTENT_TYPE_JSON = 'application/problem+json';

/**
* The content type for a XML based HTTP response carrying
* problem details.
*
* @var string
*/
const CONTENT_TYPE_XML = 'application/problem+xml';

/**
* A short, human-readable summary of the problem type.
Expand Down
3 changes: 2 additions & 1 deletion tests/ApiProblemTest.php
Expand Up @@ -32,7 +32,8 @@ public function testConstructor()

public function testContentType()
{
$this->assertEquals('application/problem+json', ApiProblem::CONTENT_TYPE);
$this->assertEquals('application/problem+json', ApiProblem::CONTENT_TYPE_JSON);
$this->assertEquals('application/problem+xml', ApiProblem::CONTENT_TYPE_XML);
}

public function testSimpleExtraProperty()
Expand Down

0 comments on commit 4bc8981

Please sign in to comment.