Skip to content

Commit

Permalink
typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrs committed Jul 25, 2014
1 parent 911e24c commit 0bd02e1
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/Hi.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace ondrs\Hi;


class Hi
class Hi
{

/** @var string */
Expand Down Expand Up @@ -82,18 +82,22 @@ public function to($name, $gender = NULL)
{
$url = $this->url . '?name=' . urlencode($name);

if($this->type !== NULL)
if ($this->type !== NULL) {
$url .= '&type=' . urlencode($this->type);
}

if($gender !== NULL)
if ($gender !== NULL) {
$url .= '&gender=' . urlencode($gender);
}

$json = $this->fetchUrl($url);

if($json->success)
if ($json->success) {
return $json->results[0];
else
} else {
return FALSE;
}

}


Expand All @@ -106,15 +110,18 @@ private function fetchUrl($url)
{
$response = @file_get_contents($url);

if(!$response)
if (!$response) {
throw new Exception("Cannot fetch URL '$url'");
}

$json = @json_decode($response);

if($json)
if ($json) {
return $json;
else
} else {
throw new Exception('Malformed JSON');
}


}

Expand All @@ -124,4 +131,4 @@ private function fetchUrl($url)
class Exception extends \Exception
{

}
}

0 comments on commit 0bd02e1

Please sign in to comment.