Create a single Key instance
public key ( string $kind, string | integer $identifier = null, array $options = [] ) : |
||
$kind | string | The kind. |
$identifier | string | integer | [optional] The ID or name. |
$options | array | [optional] { Configuration Options @type string $identifierType If omitted, type will be determined internally. In cases where any ambiguity can be expected (i.e. if you want to create keys with `name` but your values may pass PHP's `is_numeric()` check), this value may be explicitly set using `Key::TYPE_ID` or `Key::TYPE_NAME`. } |
return |
public function testKeyWithNamespaceIdOverride() { $op = new Operation($this->connection->reveal(), 'foo', 'namespace', $this->mapper); $key = $op->key('Person', 'Bob', ['namespaceId' => 'otherNamespace']); $obj = $key->keyObject(); $this->assertEquals('otherNamespace', $obj['partitionId']['namespaceId']); }
/** * Create a single Key instance * * Example: * ``` * $key = $datastore->key('Person', 'Bob'); * ``` * * ``` * // To override the internal detection of identifier type, you can specify * // which type to use. * * $key = $datastore->key('Robots', '1337', [ * 'identifierType' => Key::TYPE_NAME * ]); * ``` * * @see https://cloud.google.com/datastore/reference/rest/v1/Key Key * @see https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement PathElement * * @param string $kind The kind. * @param string|int $identifier [optional] The ID or name. * @param array $options [optional] { * Configuration Options * * @type string $identifierType If omitted, type will be determined * internally. In cases where any ambiguity can be expected (i.e. * if you want to create keys with `name` but your values may * pass PHP's `is_numeric()` check), this value may be * explicitly set using `Key::TYPE_ID` or `Key::TYPE_NAME`. * } * @return Key */ public function key($kind, $identifier = null, array $options = []) { return $this->operation->key($kind, $identifier, $options); }