Datastore/src/Key.php
public function pathElement($kind, $identifier = null, array $options = [])
    {
        $options += [
            'identifierType' => null
        ];

        if (!empty($this->path) && $this->state() !== Key::STATE_NAMED) {
            throw new InvalidArgumentException(
                'Cannot add pathElement because the previous element is missing an id or name'
            );
        }

        $pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);

        $this->path[] = $pathElement;

        return $this;
    }
public function pathElement($kind, $identifier = null, array $options = [])
    {
        $options += [
            'identifierType' => null
        ];

        if (!empty($this->path) && $this->state() !== Key::STATE_NAMED) {
            throw new InvalidArgumentException(
                'Cannot add pathElement because the previous element is missing an id or name'
            );
        }

        $pathElement = $this->normalizeElement($kind, $identifier, $options['identifierType']);

        $this->path[] = $pathElement;

        return $this;
    }
public function pathElement ( $ kind , $ identifier = null , array $ options = [ ] ) { $ options += [ 'identifierType' => null ] ; if ( ! empty ( $ this -> path ) && $ this -> state ( ) !== Key :: STATE_NAMED ) { throw new InvalidArgumentException ( 'Cannot add pathElement because the previous element is missing an id or name' ) ; } $ pathElement = $ this -> normalizeElement ( $ kind , $ identifier , $ options [ 'identifierType' ] ) ; $ this -> path [ ] = $ pathElement ; return $ this ; }
Add a path element to the end of the Key path

If the previous pathElement is incomplete (has no name or ID specified),
an `InvalidArgumentException` will be thrown. Once an incomplete
pathElement is given, the key cannot be extended any further.

Example:
```
$key->pathElement('Person', 'Jane');
```

```
// In cases where the identifier type is ambiguous, you can choose the
// type to be used.

$key->pathElement('Robots', '1337', [
'identifierType' => Key::TYPE_NAME
]);
```

@see https://cloud.google.com/datastore/reference/rest/v1/Key#PathElement PathElement

@param string $kind The kind.
@param string|int $identifier [optional] The name or ID of the object.
@param array $options {
Configuration Options

@type string $identifierType [optional] If omitted, the type will be
determined internally. Setting this to either `Key::TYPE_ID` or
`Key::TYPE_NAME` will force the pathElement identifier type.
}
@return Key
@throws InvalidArgumentException
Add a path element to the end of the Key path