/** * Gets a single software bucket * If no key is set, an empty Bucket object will be returned which will act as a repository * * @param string $key optional * * @return Bucket */ public function bucket($key = null) { if (!$this->id) { throw new Exception("The server has no ID, can\\'t get buckets"); } $bucket = new Bucket($this->patrol); $bucket->defaults(['server_id' => $this->id]); if (is_null($key)) { return $bucket; } try { return $bucket->find($key); } catch (Exception $ex) { if ($ex->getMessage() === "Bucket does not exist") { $bucket->key = $key; return $bucket; } } return null; }