| @@ 160-171 (lines=12) @@ | ||
| 157 | * @throws BadResponseError For any other HTTP error which does not have a 404 Not Found status. |
|
| 158 | * @throws \Exception For any other type of fatal error. |
|
| 159 | */ |
|
| 160 | public function objectExists($name) |
|
| 161 | { |
|
| 162 | try { |
|
| 163 | $this->getObject($name)->retrieve(); |
|
| 164 | return true; |
|
| 165 | } catch (BadResponseError $e) { |
|
| 166 | if ($e->getResponse()->getStatusCode() === 404) { |
|
| 167 | return false; |
|
| 168 | } |
|
| 169 | throw $e; |
|
| 170 | } |
|
| 171 | } |
|
| 172 | ||
| 173 | /** |
|
| 174 | * Creates a single object according to the values provided. |
|
| @@ 72-83 (lines=12) @@ | ||
| 69 | * @return bool TRUE if exists, FALSE if it doesn't |
|
| 70 | * @throws BadResponseError Thrown for any non 404 status error |
|
| 71 | */ |
|
| 72 | public function containerExists($name) |
|
| 73 | { |
|
| 74 | try { |
|
| 75 | $this->execute($this->api->headContainer(), ['name' => $name]); |
|
| 76 | return true; |
|
| 77 | } catch (BadResponseError $e) { |
|
| 78 | if ($e->getResponse()->getStatusCode() === 404) { |
|
| 79 | return false; |
|
| 80 | } |
|
| 81 | throw $e; |
|
| 82 | } |
|
| 83 | } |
|
| 84 | } |
|
| 85 | ||