You are here

public function SiteClient::exists in Lockr 7

Same name and namespace in other branches
  1. 7.2 vendor/lockr/lockr-client/src/SiteClient.php \Lockr\SiteClient::exists()

Checks if the current site/env is registered and/or available.

Return value

bool[] Returns a two-value array of booleans:

  • True if the site is registered with Lockr.
  • True if the current env is available.

Throws

ServerException if the server is unavailable or returns an error.

ClientException if there was an unexpected client error.

File

src/Lockr/SiteClient.php, line 41

Class

SiteClient
API for site management operations.

Namespace

Lockr

Code

public function exists() {
  list($status, $body) = $this->client
    ->get('/v1/site/exists');
  $body = json_decode($body, true);
  if (json_last_error() !== JSON_ERROR_NONE || $status >= 500) {
    throw new ServerException();
  }
  if ($status >= 400) {
    throw new ClientException();
  }
  return array(
    isset($body['exists']) ? (bool) $body['exists'] : false,
    isset($body['available']) ? (bool) $body['available'] : false,
  );
}