@@ -51,8 +51,7 @@ discard block |
||
| 51 | 51 | public function https($value) { |
| 52 | 52 | if (strpos($value, $this->baseUrl) === false) { |
| 53 | 53 | throw new InvalidArgumentException("You can only convert existing Gravatar URLs to HTTPS"); |
| 54 | - } |
|
| 55 | - else { |
|
| 54 | + } else { |
|
| 56 | 55 | return str_replace($this->baseUrl, $this->httpsUrl, $value); |
| 57 | 56 | } |
| 58 | 57 | } |
@@ -66,12 +65,10 @@ discard block |
||
| 66 | 65 | public function size($value, $px = 100) { |
| 67 | 66 | if (!is_numeric($px) || $px < 0 || $px > 2048) { |
| 68 | 67 | throw new InvalidArgumentException("You must pass the size filter a valid number between 0 and 2048"); |
| 69 | - } |
|
| 70 | - else if (strpos($value, $this->baseUrl) === false |
|
| 68 | + } else if (strpos($value, $this->baseUrl) === false |
|
| 71 | 69 | && strpos($value, $this->httpsUrl) === false) { |
| 72 | 70 | throw new InvalidArgumentException("You must pass the size filter an existing Gravatar URL"); |
| 73 | - } |
|
| 74 | - else { |
|
| 71 | + } else { |
|
| 75 | 72 | return $this->query($value, array("size" => $px)); |
| 76 | 73 | } |
| 77 | 74 | } |
@@ -86,15 +83,14 @@ discard block |
||
| 86 | 83 | public function def($value, $default = "mm", $force = false) { |
| 87 | 84 | if (strpos($value, $this->baseUrl) === false && strpos($value, $this->httpsUrl) === false) { |
| 88 | 85 | throw new InvalidArgumentException("You can only a default to existing Gravatar URLs"); |
| 89 | - } |
|
| 90 | - else if (!filter_var($default, FILTER_VALIDATE_URL) && !in_array($default, $this->defaults)) { |
|
| 86 | + } else if (!filter_var($default, FILTER_VALIDATE_URL) && !in_array($default, $this->defaults)) { |
|
| 91 | 87 | throw new InvalidArgumentException("Default must be a URL or valid default"); |
| 92 | - } |
|
| 93 | - else if (!is_bool($force)) { |
|
| 88 | + } else if (!is_bool($force)) { |
|
| 94 | 89 | throw new InvalidArgumentException("The force option for a default must be boolean"); |
| 95 | - } |
|
| 96 | - else { |
|
| 97 | - if (filter_var($default, FILTER_VALIDATE_URL)) $default = urlencode($default); |
|
| 90 | + } else { |
|
| 91 | + if (filter_var($default, FILTER_VALIDATE_URL)) { |
|
| 92 | + $default = urlencode($default); |
|
| 93 | + } |
|
| 98 | 94 | $force = ($force ? "y" : "n"); |
| 99 | 95 | return $this->query($value, array("default" => $default, "forcedefault" => $force)); |
| 100 | 96 | } |
@@ -109,11 +105,9 @@ discard block |
||
| 109 | 105 | public function rating($value, $rating = "g") { |
| 110 | 106 | if (strpos($value, $this->baseUrl) === false && strpos($value, $this->httpsUrl) === false) { |
| 111 | 107 | throw new InvalidArgumentException("You can only add a rating to an existing Gravatar URL"); |
| 112 | - } |
|
| 113 | - else if (!in_array(strtolower($rating), $this->ratings)) { |
|
| 108 | + } else if (!in_array(strtolower($rating), $this->ratings)) { |
|
| 114 | 109 | throw new InvalidArgumentException("Rating must be g,pg,r or x"); |
| 115 | - } |
|
| 116 | - else { |
|
| 110 | + } else { |
|
| 117 | 111 | return $this->query($value, array("rating" => $rating)); |
| 118 | 112 | } |
| 119 | 113 | } |