Skip to content

Commit

Permalink
Tidied up code formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjomckay committed Sep 30, 2014
1 parent cb91ade commit 6b3c3ac
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 23 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "jonjomckay/symfony-api-problem",
"description": "A Symfony-compatible response for the IETF Problem Details for HTTP APIs RFC",
"name": "jonjomckay/symfony-api-problem",
"description": "A Symfony-compatible response for the IETF Problem Details for HTTP APIs RFC",
"license": "BSD-3-Clause",
"autoload": {
"psr-4": {
"JonjoMcKay\\ApiProblem\\": "src/"
}
},
"require": {
"symfony/http-foundation": "~2.5"
}
"require": {
"symfony/http-foundation": "~2.5"
}
}
32 changes: 17 additions & 15 deletions src/ApiProblem.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ class ApiProblem
* @var array
*/
protected $normalizedProperties = array(
'type' => 'type',
'type' => 'type',
'status' => 'status',
'title' => 'title',
'title' => 'title',
'detail' => 'detail',
);

Expand Down Expand Up @@ -120,11 +120,11 @@ class ApiProblem
* if the status matches any known, the title field will be selected
* from $problemStatusTitles as a result.
*
* @param int $status
* @param int $status
* @param string $detail
* @param string $type
* @param string $title
* @param array $additional
* @param array $additional
*/
public function __construct($status, $detail, $type = null, $title = null, array $additional = array())
{
Expand All @@ -142,7 +142,7 @@ public function __construct($status, $detail, $type = null, $title = null, array

$this->status = $status;
$this->detail = $detail;
$this->title = $title;
$this->title = $title;

if (null !== $type) {
$this->type = $type;
Expand Down Expand Up @@ -174,10 +174,12 @@ public function __get($name)
return $this->additionalDetails[$normalized];
}

throw new \InvalidArgumentException(sprintf(
'Invalid property name "%s"',
$name
));
throw new \InvalidArgumentException(
sprintf(
'Invalid property name "%s"',
$name
)
);
}

/**
Expand All @@ -188,8 +190,8 @@ public function __get($name)
public function toArray()
{
$problem = array(
'type' => $this->type,
'title' => $this->getTitle(),
'type' => $this->type,
'title' => $this->getTitle(),
'status' => $this->getStatus(),
'detail' => $this->getDetail(),
);
Expand All @@ -206,7 +208,7 @@ public function toArray()
*/
public function setDetailIncludesStackTrace($flag)
{
$this->detailIncludesStackTrace = (bool) $flag;
$this->detailIncludesStackTrace = (bool)$flag;
return $this;
}

Expand Down Expand Up @@ -301,9 +303,9 @@ protected function createDetailFromException()
$e = $e->getPrevious();
while ($e) {
$previous[] = array(
'code' => (int) $e->getCode(),
'code' => (int)$e->getCode(),
'message' => trim($e->getMessage()),
'trace' => $e->getTrace(),
'trace' => $e->getTrace(),
);
$e = $e->getPrevious();
}
Expand All @@ -321,7 +323,7 @@ protected function createDetailFromException()
*/
protected function createStatusFromException()
{
$e = $this->detail;
$e = $this->detail;
$status = $e->getCode();

if (!empty($status)) {
Expand Down
6 changes: 3 additions & 3 deletions src/ApiProblemResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApiProblemResponse extends JsonResponse
* @param ApiProblem $apiProblem
*/
public function __construct(ApiProblem $apiProblem)
{
parent::__construct($apiProblem->toArray(), $apiProblem->status);
}
{
parent::__construct($apiProblem->toArray(), $apiProblem->status);
}
}

0 comments on commit 6b3c3ac

Please sign in to comment.