Skip to content

PCBC-918 make extra ExistsResult attributes optional #95

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions Couchbase/ExistsResult.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
class ExistsResult extends Result
{
private bool $exists;
private bool $deleted;
private int $expiry;
private int $flags;
private string $cas;
private string $sequenceNumber;
private ?bool $deleted;
private ?int $expiry;
private ?int $flags;
private ?string $sequenceNumber;

/**
* @internal
Expand All @@ -43,11 +43,19 @@ public function __construct(array $response)
{
parent::__construct($response);
$this->exists = $response["exists"];
$this->deleted = $response["deleted"];
$this->expiry = $response["expiry"];
$this->flags = $response["flags"];
$this->cas = $response["cas"];
$this->sequenceNumber = $response["sequenceNumber"];
if (array_key_exists("deleted", $response)) {
$this->deleted = $response["deleted"];
}
if (array_key_exists("expiry", $response)) {
$this->expiry = $response["expiry"];
}
if (array_key_exists("flags", $response)) {
$this->flags = $response["flags"];
}
if (array_key_exists("sequenceNumber", $response)) {
$this->sequenceNumber = $response["sequenceNumber"];
}
}

/**
Expand All @@ -64,10 +72,10 @@ public function exists(): bool
/**
* Returns true if the document had been just deleted.
*
* @return bool
* @return bool|null
* @since 4.0.0
*/
public function deleted(): bool
public function deleted(): ?bool
{
return $this->deleted;
}
Expand All @@ -81,17 +89,17 @@ public function cas(): string
}

/**
* @return string
* @return string|null
*/
public function sequenceNumber(): string
public function sequenceNumber(): ?string
{
return $this->sequenceNumber;
}

/**
* @return int
* @return int|null
*/
public function flags(): int
public function flags(): ?int
{
return $this->flags;
}
Expand Down