Skip to content

Commit

Permalink
[Breaking Change] Add support for Document Snapshots in Firestore Que…
Browse files Browse the repository at this point in the history
…ry Cursors (#1162)

cc @schmidt-sebastian

Extracted from #923 and updated to address pull request comments.

Breaking change is the standardization in Query of using `InvalidArgumentException`, replacing various throws of `BadMethodCallException`.

Closes #851.
  • Loading branch information
jdpedrie authored Jul 18, 2018
1 parent 3c5c274 commit 0488b2d
Show file tree
Hide file tree
Showing 7 changed files with 492 additions and 98 deletions.
5 changes: 4 additions & 1 deletion Firestore/src/DocumentSnapshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,10 @@ public function get($fieldPath)
break;
} else {
if (!isset($fields[$part])) {
throw new \InvalidArgumentException('field path does not exist.');
throw new \InvalidArgumentException(sprintf(
'Field path `%s` does not exist.',
$fieldPath
));
}

$fields = $fields[$part];
Expand Down
15 changes: 15 additions & 0 deletions Firestore/src/FieldValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,19 @@ public static function serverTimestamp()
{
return '___google-cloud-php__serverTimestamp___';
}

/**
* Check if the given value is a sentinel.
*
* @param string $value
* @return bool
* @access private
*/
public static function isSentinelValue($value)
{
return in_array($value, [
self::deleteField(),
self::serverTimestamp()
]);
}
}
Loading

0 comments on commit 0488b2d

Please sign in to comment.