Skip to content

Commit

Permalink
Use __isset, you wally
Browse files Browse the repository at this point in the history
  • Loading branch information
datashaman committed Nov 14, 2016
1 parent 6e04cf7 commit a046706
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/Response/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __get($name)
E_USER_NOTICE);
}

public function has($name)
public function __isset($name)
{
return
in_array($name, ['index', 'type', 'id', 'score', 'source'])
Expand All @@ -50,6 +50,20 @@ public function has($name)
&& array_has($this->hit['_source'], $name);
}

public function get($name, $default = null)
{
if (!isset($this->$name)) {
return $default;
}

return $this->$name;
}

public function has($name)
{
return isset($this->$name);
}

public function toArray()
{
return $this->hit;
Expand Down

0 comments on commit a046706

Please sign in to comment.