Oihana PHP Arango

probeExists.php

Table of Contents

Functions

probeExists()  : bool
Turns a server request into an existence answer: `true` when it succeeds, `false` on a 404, and the original failure for anything else.

Functions

probeExists()

Turns a server request into an existence answer: `true` when it succeeds, `false` on a 404, and the original failure for anything else.

probeExists(callable $request) : bool

Every resource handle of the client answers the same question the same way — Analyzer::exists(), View::exists(), Graph::exists(), Transaction::exists(), Collection::exists() and the two documentExists() of Collection and GraphCollection. Only the request differs (the verb, the path, and which handle carries the transport), which is why it travels as a closure rather than as parameters.

A 404 is the only failure read as an answer. The net is HttpException — the type the response factory produces for an ordinary HTTP status — and deliberately not its parent ArangoException: the sibling classes ConflictException (409), MaintenanceException (503) and NetworkException (0) describe a server that could not answer, not a resource that is missing, and must reach the caller untouched.

Parameters
$request : callable

The request to run; its return value is discarded.

Tags
throws
ArangoException

Any failure other than a 404, unchanged.

example
use function oihana\arango\clients\helpers\probeExists;

public function exists() : bool
{
    return probeExists( fn() => $this->database->request( method : HttpMethod::GET , path : $this->path() ) ) ;
}
since
1.6.0
author

Marc Alcaraz

Return values
bool

true when the request succeeds, false on a 404.

On this page

Search results