Skip to content

Commit

Permalink
move the normalizing logic to the public function
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Nov 2, 2014
1 parent c9ed7c1 commit e118155
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/Network/Request.php
Expand Up @@ -583,6 +583,16 @@ public function __isset($name) {
* @return bool Whether or not the request is the type you are checking.
*/
public function is($type) {
if (is_array($type)) {
$result = array_map(array($this, 'is'), $type);
return count(array_filter($result)) > 0;
}

$type = strtolower($type);
if (!isset(static::$_detectors[$type])) {
return false;
}

if (!isset($this->_isResults[$type])) {
$this->_isResults[$type] = $this->_is($type);
}
Expand All @@ -598,14 +608,6 @@ public function is($type) {
* @return bool Whether or not the request is the type you are checking.
*/
protected function _is($type) {
if (is_array($type)) {
$result = array_map(array($this, 'is'), $type);
return count(array_filter($result)) > 0;
}
$type = strtolower($type);
if (!isset(static::$_detectors[$type])) {
return false;
}
$detect = static::$_detectors[$type];
if (is_callable($detect)) {
return call_user_func($detect, $this);
Expand Down

0 comments on commit e118155

Please sign in to comment.