Skip to content

Commit

Permalink
formatting and renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Dec 29, 2017
1 parent 7c523f1 commit 3624d27
Showing 1 changed file with 15 additions and 17 deletions.
32 changes: 15 additions & 17 deletions src/Illuminate/Http/Concerns/InteractsWithContentTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,7 @@ public function isJson()
*/
public function expectsJson()
{
return ($this->ajax() && ! $this->pjax() && $this->wantsAnyContentType()) || $this->wantsJson();
}

/**
* Determine if the current request is asking for any content type in return.
*
* @return bool
*/
public function wantsAnyContentType()
{
$acceptable = $this->getAcceptableContentTypes();

if (count($acceptable) === 0) {
return true;
}

return isset($acceptable[0]) && ($acceptable[0] === '*/*' || $acceptable[0] === '*');
return ($this->ajax() && ! $this->pjax() && $this->acceptsAnyContentType()) || $this->wantsJson();
}

/**
Expand Down Expand Up @@ -134,6 +118,20 @@ public function prefers($contentTypes)
}
}

/**
* Determine if the current request accepts any content type in return.
*
* @return bool
*/
public function acceptsAnyContentType()
{
$acceptable = $this->getAcceptableContentTypes();

return count($acceptable) === 0 || (
isset($acceptable[0]) && ($acceptable[0] === '*/*' || $acceptable[0] === '*')
);
}

/**
* Determines whether a request accepts JSON.
*
Expand Down

0 comments on commit 3624d27

Please sign in to comment.