| @@ 162-173 (lines=12) @@ | ||
| 159 | * @throws BadResponseError For any other HTTP error which does not have a 404 Not Found status. |
|
| 160 | * @throws \Exception For any other type of fatal error. |
|
| 161 | */ |
|
| 162 | public function objectExists(string $name): bool |
|
| 163 | { |
|
| 164 | try { |
|
| 165 | $this->getObject($name)->retrieve(); |
|
| 166 | return true; |
|
| 167 | } catch (BadResponseError $e) { |
|
| 168 | if ($e->getResponse()->getStatusCode() === 404) { |
|
| 169 | return false; |
|
| 170 | } |
|
| 171 | throw $e; |
|
| 172 | } |
|
| 173 | } |
|
| 174 | ||
| 175 | /** |
|
| 176 | * 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(string $name): bool |
|
| 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 | ||