idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
1,800
public function executeUpdate ( Session $ session , Transaction $ transaction , $ sql , array $ options = [ ] ) { $ res = $ this -> execute ( $ session , $ sql , [ 'transactionId' => $ transaction -> id ( ) ] + $ options ) ; iterator_to_array ( $ res -> rows ( ) ) ; $ stats = $ res -> stats ( ) ; if ( ! $ stats ) { throw new \ InvalidArgumentException ( 'Partitioned DML response missing stats, possible due to non-DML statement as input.' ) ; } $ statsItem = isset ( $ options [ 'statsItem' ] ) ? $ options [ 'statsItem' ] : 'rowCountExact' ; return $ stats [ $ statsItem ] ; }
Execute a DML statement and return an affected row count .
1,801
public function read ( Session $ session , $ table , KeySet $ keySet , array $ columns , array $ options = [ ] ) { $ options += [ 'index' => null , 'limit' => null , 'offset' => null , 'transactionContext' => null ] ; $ context = $ this -> pluck ( 'transactionContext' , $ options ) ; $ call = function ( $ resumeToken = null ) use ( $ table , $ session , $ columns , $ keySet , $ options ) { if ( $ resumeToken ) { $ options [ 'resumeToken' ] = $ resumeToken ; } return $ this -> connection -> streamingRead ( [ 'table' => $ table , 'session' => $ session -> name ( ) , 'columns' => $ columns , 'keySet' => $ this -> flattenKeySet ( $ keySet ) , 'database' => $ session -> info ( ) [ 'database' ] ] + $ options ) ; } ; return new Result ( $ this , $ session , $ call , $ context , $ this -> mapper ) ; }
Lookup rows in a database .
1,802
public function createTransaction ( Session $ session , array $ res = [ ] , array $ options = [ ] ) { $ res += [ 'id' => null ] ; $ options [ 'isRetry' ] = isset ( $ options [ 'isRetry' ] ) ? $ options [ 'isRetry' ] : false ; return new Transaction ( $ this , $ session , $ res [ 'id' ] , $ options [ 'isRetry' ] ) ; }
Create a Transaction instance from a response object .
1,803
public function snapshot ( Session $ session , array $ options = [ ] ) { $ options += [ 'singleUse' => false , 'className' => Snapshot :: class ] ; if ( ! $ options [ 'singleUse' ] ) { $ res = $ this -> beginTransaction ( $ session , $ options ) ; } else { $ res = [ ] ; } $ className = $ this -> pluck ( 'className' , $ options ) ; return $ this -> createSnapshot ( $ session , $ res + $ options , $ className ) ; }
Create a read - only snapshot transaction .
1,804
public function createSnapshot ( Session $ session , array $ res = [ ] , $ className = Snapshot :: class ) { $ res += [ 'id' => null , 'readTimestamp' => null ] ; if ( $ res [ 'readTimestamp' ] ) { if ( ! ( $ res [ 'readTimestamp' ] instanceof Timestamp ) ) { $ time = $ this -> parseTimeString ( $ res [ 'readTimestamp' ] ) ; $ res [ 'readTimestamp' ] = new Timestamp ( $ time [ 0 ] , $ time [ 1 ] ) ; } } return new $ className ( $ this , $ session , $ res ) ; }
Create a Snapshot instance from a response object .
1,805
private function partitionOptions ( array $ options ) { $ options [ 'partitionOptions' ] = array_filter ( [ 'partitionSizeBytes' => $ this -> pluck ( 'partitionSizeBytes' , $ options , false ) , 'maxPartitions' => $ this -> pluck ( 'maxPartitions' , $ options , false ) ] ) ; return $ options ; }
Normalize options for partition configuration .
1,806
private function beginTransaction ( Session $ session , array $ options = [ ] ) { $ options += [ 'transactionOptions' => [ ] ] ; return $ this -> connection -> beginTransaction ( $ options + [ 'session' => $ session -> name ( ) , 'database' => $ session -> info ( ) [ 'database' ] ] ) ; }
Execute a service call to begin a transaction or snapshot .
1,807
private function flattenKeySet ( KeySet $ keySet ) { $ keys = $ keySet -> keySetObject ( ) ; if ( ! empty ( $ keys [ 'ranges' ] ) ) { foreach ( $ keys [ 'ranges' ] as $ index => $ range ) { foreach ( $ range as $ type => $ rangeKeys ) { $ range [ $ type ] = $ this -> mapper -> encodeValuesAsSimpleType ( $ rangeKeys ) ; } $ keys [ 'ranges' ] [ $ index ] = $ range ; } } if ( ! empty ( $ keys [ 'keys' ] ) ) { $ keys [ 'keys' ] = $ this -> mapper -> encodeValuesAsSimpleType ( $ keys [ 'keys' ] , true ) ; } return $ this -> arrayFilterRemoveNull ( $ keys ) ; }
Convert a KeySet object to an API - ready array .
1,808
public function setTeamMembers ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> team_members = $ arr ; return $ this ; }
Optional . A list of team members involved in this activity . Number of characters allowed is 100 .
1,809
public function setOutputVersionFormat ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Logging \ V2 \ LogSink_VersionFormat :: class ) ; $ this -> output_version_format = $ var ; return $ this ; }
Deprecated . The log entry format to use for this sink s exported log entries . The v2 format is used by default and cannot be changed .
1,810
public function setJobQuery ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ JobQuery :: class ) ; $ this -> job_query = $ var ; return $ this ; }
Optional . Query used to search against jobs such as keyword location filters etc .
1,811
public function setProperty ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Vision \ V1 \ TextAnnotation_TextProperty :: class ) ; $ this -> property = $ var ; return $ this ; }
Additional information detected for the paragraph .
1,812
public function setWords ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ Word :: class ) ; $ this -> words = $ arr ; return $ this ; }
List of words in this paragraph .
1,813
public function setDeviceConfigs ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Iot \ V1 \ DeviceConfig :: class ) ; $ this -> device_configs = $ arr ; return $ this ; }
The device configuration for the last few versions . Versions are listed in decreasing order starting from the most recent one .
1,814
public function setText ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> text = $ arr ; return $ this ; }
Optional . The collection of the agent s responses .
1,815
public function GetJob ( \ Google \ Cloud \ Talent \ V4beta1 \ GetJobRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/google.cloud.talent.v4beta1.JobService/GetJob' , $ argument , [ '\Google\Cloud\Talent\V4beta1\Job' , 'decode' ] , $ metadata , $ options ) ; }
Retrieves the specified job whose status is OPEN or recently EXPIRED within the last 90 days .
1,816
public function UpdateJob ( \ Google \ Cloud \ Talent \ V4beta1 \ UpdateJobRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/google.cloud.talent.v4beta1.JobService/UpdateJob' , $ argument , [ '\Google\Cloud\Talent\V4beta1\Job' , 'decode' ] , $ metadata , $ options ) ; }
Updates specified job .
1,817
public function DeleteJob ( \ Google \ Cloud \ Talent \ V4beta1 \ DeleteJobRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/google.cloud.talent.v4beta1.JobService/DeleteJob' , $ argument , [ '\Google\Protobuf\GPBEmpty' , 'decode' ] , $ metadata , $ options ) ; }
Deletes the specified job .
1,818
public function ListJobs ( \ Google \ Cloud \ Talent \ V4beta1 \ ListJobsRequest $ argument , $ metadata = [ ] , $ options = [ ] ) { return $ this -> _simpleRequest ( '/google.cloud.talent.v4beta1.JobService/ListJobs' , $ argument , [ '\Google\Cloud\Talent\V4beta1\ListJobsResponse' , 'decode' ] , $ metadata , $ options ) ; }
Lists jobs by filter .
1,819
public function setSnapshots ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> snapshots = $ arr ; return $ this ; }
The names of the snapshots that match the request .
1,820
public function setJob ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ Job :: class ) ; $ this -> job = $ var ; return $ this ; }
Required . The Job to be created .
1,821
public function sample ( $ probability ) { if ( $ probability < 0 ) { throw new \ InvalidArgumentException ( 'Probability must be positive' ) ; } if ( $ probability >= 1.0 ) { throw new \ InvalidArgumentException ( 'Probability must be less than 1.0' ) ; } return new SimpleFilter ( ( new RowFilter ) -> setRowSampleFilter ( $ probability ) ) ; }
Matches all cells from a row with probability and matches no cells from the row with probability 1 - probability .
1,822
public function setCompanies ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Talent \ V4beta1 \ Company :: class ) ; $ this -> companies = $ arr ; return $ this ; }
Companies for the current client .
1,823
public function setResults ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Speech \ V1 \ SpeechRecognitionResult :: class ) ; $ this -> results = $ arr ; return $ this ; }
Output only . Sequential list of transcription results corresponding to sequential portions of audio .
1,824
public function readAll ( ) { foreach ( $ this -> stream as $ readRowsResponse ) { foreach ( $ readRowsResponse -> getChunks ( ) as $ chunk ) { switch ( $ this -> state ) { case self :: $ rowStateEnum [ 'NEW_ROW' ] : $ this -> newRow ( $ chunk ) ; break ; case self :: $ rowStateEnum [ 'ROW_IN_PROGRESS' ] : $ this -> rowInProgress ( $ chunk ) ; break ; case self :: $ rowStateEnum [ 'CELL_IN_PROGRESS' ] : $ this -> cellInProgress ( $ chunk ) ; break ; } if ( $ chunk -> getCommitRow ( ) ) { $ row = $ this -> row ; $ rowKey = $ this -> rowKey ; $ this -> commit ( ) ; yield $ rowKey => $ row ; $ this -> numberOfRowsRead ++ ; } } } $ this -> onStreamEnd ( ) ; }
Formats the row s chunks into a friendly format .
1,825
private function validateNewRow ( CellChunk $ chunk ) { $ this -> isError ( $ this -> row , 'A new row cannot have existing state.' ) ; $ this -> isError ( ! $ chunk -> getRowKey ( ) , 'A row key must be set.' ) ; $ this -> isError ( $ chunk -> getResetRow ( ) , 'A new row cannot be reset.' ) ; $ this -> isError ( $ this -> prevRowKey && $ this -> prevRowKey === $ chunk -> getRowKey ( ) , 'A commit happened but the same key followed.' ) ; $ this -> isError ( ! $ chunk -> getFamilyName ( ) , 'A family must be set.' ) ; $ this -> isError ( ! $ chunk -> getQualifier ( ) , 'A column qualifier must be set.' ) ; $ this -> validateValueSizeAndCommitRow ( $ chunk ) ; }
Validates state for a new row .
1,826
private function reset ( ) { $ this -> prevRowKey = null ; $ this -> rowKey = null ; $ this -> state = self :: $ rowStateEnum [ 'NEW_ROW' ] ; $ this -> row = [ ] ; }
Resets the state of formatter .
1,827
private function moveToNextState ( CellChunk $ chunk ) { $ this -> state = $ chunk -> getValueSize ( ) > 0 ? self :: $ rowStateEnum [ 'CELL_IN_PROGRESS' ] : self :: $ rowStateEnum [ 'ROW_IN_PROGRESS' ] ; }
Moves to the next state in processing .
1,828
private function newRow ( CellChunk $ chunk ) { $ this -> validateNewRow ( $ chunk ) ; $ this -> rowKey = $ chunk -> getRowKey ( ) ; $ familyName = $ chunk -> getFamilyName ( ) -> getValue ( ) ; $ qualifierName = $ chunk -> getQualifier ( ) -> getValue ( ) ; $ labels = ( $ chunk -> getLabels ( ) -> getIterator ( ) -> valid ( ) ) ? implode ( iterator_to_array ( $ chunk -> getLabels ( ) -> getIterator ( ) ) ) : '' ; $ this -> row [ $ familyName ] = [ ] ; $ this -> family = & $ this -> row [ $ familyName ] ; $ this -> family [ $ qualifierName ] = [ ] ; $ this -> qualifiers = & $ this -> family [ $ qualifierName ] ; $ qualifier = [ 'value' => $ chunk -> getValue ( ) , 'labels' => $ labels , 'timeStamp' => $ chunk -> getTimestampMicros ( ) ] ; $ this -> qualifierValue = & $ qualifier [ 'value' ] ; $ this -> qualifiers [ ] = & $ qualifier ; $ this -> moveToNextState ( $ chunk ) ; }
Processes a chunk when in the NEW_ROW state .
1,829
private function validateResetRow ( CellChunk $ chunk ) { $ this -> isError ( $ chunk -> getResetRow ( ) && ( $ chunk -> getRowKey ( ) || $ chunk -> getQualifier ( ) || $ chunk -> getValue ( ) || $ chunk -> getTimestampMicros ( ) > 0 ) , 'A reset should have no data.' ) ; }
Validates the reset row condition for a chunk .
1,830
private function validateRowInProgress ( CellChunk $ chunk ) { $ this -> validateResetRow ( $ chunk ) ; $ newRowKey = $ chunk -> getRowKey ( ) ; $ this -> isError ( $ chunk -> getRowKey ( ) && $ newRowKey !== $ this -> rowKey , 'A commit is required between row keys.' ) ; $ this -> isError ( $ chunk -> getFamilyName ( ) && ! $ chunk -> getQualifier ( ) , 'A qualifier must be specified.' ) ; $ this -> validateValueSizeAndCommitRow ( $ chunk ) ; }
Validates state for a row in progress .
1,831
private function rowInProgress ( CellChunk $ chunk ) { $ this -> validateRowInProgress ( $ chunk ) ; if ( $ chunk -> getResetRow ( ) ) { $ this -> reset ( ) ; return ; } if ( $ chunk -> getFamilyName ( ) ) { $ familyName = $ chunk -> getFamilyName ( ) -> getValue ( ) ; if ( ! isset ( $ this -> row [ $ familyName ] ) ) { $ this -> row [ $ familyName ] = [ ] ; } $ this -> family = & $ this -> row [ $ familyName ] ; } if ( $ chunk -> getQualifier ( ) ) { $ qualifierName = $ chunk -> getQualifier ( ) -> getValue ( ) ; if ( ! isset ( $ this -> family [ $ qualifierName ] ) ) { $ this -> family [ $ qualifierName ] = [ ] ; } $ this -> qualifiers = & $ this -> family [ $ qualifierName ] ; } $ labels = ( $ chunk -> getLabels ( ) -> getIterator ( ) -> valid ( ) ) ? implode ( iterator_to_array ( $ chunk -> getLabels ( ) -> getIterator ( ) ) ) : '' ; $ qualifier = [ 'value' => $ chunk -> getValue ( ) , 'labels' => $ labels , 'timeStamp' => $ chunk -> getTimestampMicros ( ) ] ; $ this -> qualifierValue = & $ qualifier [ 'value' ] ; $ this -> qualifiers [ ] = & $ qualifier ; $ this -> moveToNextState ( $ chunk ) ; }
Process a chunk when in ROW_IN_PROGRESS state .
1,832
private function cellInProgress ( CellChunk $ chunk ) { $ this -> validateCellInProgress ( $ chunk ) ; if ( $ chunk -> getResetRow ( ) ) { $ this -> reset ( ) ; return ; } $ this -> qualifierValue = $ this -> qualifierValue . $ chunk -> getValue ( ) ; $ this -> moveToNextState ( $ chunk ) ; }
Process chunk when in CELL_IN_PROGRESS state .
1,833
public function setWebEntities ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ WebDetection \ WebEntity :: class ) ; $ this -> web_entities = $ arr ; return $ this ; }
Deduced entities from similar images on the Internet .
1,834
public function setFullMatchingImages ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ WebDetection \ WebImage :: class ) ; $ this -> full_matching_images = $ arr ; return $ this ; }
Fully matching images from the Internet . Can include resized copies of the query image .
1,835
public function setPartialMatchingImages ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ WebDetection \ WebImage :: class ) ; $ this -> partial_matching_images = $ arr ; return $ this ; }
Partial matching images from the Internet . Those images are similar enough to share some key - point features . For example an original image will likely have partial matching for its crops .
1,836
public function setPagesWithMatchingImages ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ WebDetection \ WebPage :: class ) ; $ this -> pages_with_matching_images = $ arr ; return $ this ; }
Web pages containing the matching images from the Internet .
1,837
public function setVisuallySimilarImages ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Vision \ V1 \ WebDetection \ WebImage :: class ) ; $ this -> visually_similar_images = $ arr ; return $ this ; }
The visually similar image results .
1,838
public function setDegreeType ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ DegreeType :: class ) ; $ this -> degree_type = $ var ; return $ this ; }
Optional . ISCED degree type .
1,839
public function setFieldsOfStudy ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> fields_of_study = $ arr ; return $ this ; }
Optional . Fields of study for the degree . For example Computer science engineering . Number of characters allowed is 100 .
1,840
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
1,841
public function ancestor ( $ kind , $ identifier , array $ options = [ ] ) { $ options += [ 'identifierType' => null ] ; $ pathElement = $ this -> normalizeElement ( $ kind , $ identifier , $ options [ 'identifierType' ] ) ; array_unshift ( $ this -> path , $ pathElement ) ; return $ this ; }
Add a path element to the beginning of the Key path .
1,842
public function ancestorKey ( Key $ key ) { if ( $ key -> state ( ) !== self :: STATE_NAMED ) { throw new InvalidArgumentException ( 'Cannot use an incomplete key as an ancestor' ) ; } $ path = $ key -> path ( ) ; $ this -> path = array_merge ( $ path , $ this -> path ) ; return $ this ; }
Use another Key s path as the current Key s ancestor
1,843
public function state ( ) { $ end = $ this -> pathEnd ( ) ; return ( isset ( $ end [ 'id' ] ) || isset ( $ end [ 'name' ] ) ) ? self :: STATE_NAMED : self :: STATE_INCOMPLETE ; }
Check if the Key is considered Named or Incomplete .
1,844
public function setLastElementIdentifier ( $ value , $ type = Key :: TYPE_ID ) { $ end = $ this -> pathEnd ( ) ; $ end [ $ type ] = ( string ) $ value ; $ elements = array_keys ( $ this -> path ) ; $ lastElement = end ( $ elements ) ; $ this -> path [ $ lastElement ] = $ end ; }
Set the value of the last path element in a Key
1,845
public function pathEndIdentifier ( ) { $ end = $ this -> pathEnd ( ) ; if ( isset ( $ end [ 'id' ] ) ) { return $ end [ 'id' ] ; } if ( isset ( $ end [ 'name' ] ) ) { return $ end [ 'name' ] ; } return null ; }
Get the last pathElement identifier .
1,846
public function pathEndIdentifierType ( ) { $ end = $ this -> pathEnd ( ) ; if ( isset ( $ end [ 'id' ] ) ) { return self :: TYPE_ID ; } if ( isset ( $ end [ 'name' ] ) ) { return self :: TYPE_NAME ; } return null ; }
Get the last pathElement identifier type .
1,847
private function normalizeElement ( $ kind , $ identifier , $ identifierType ) { $ identifierType = $ this -> determineIdentifierType ( $ identifier , $ identifierType ) ; $ element = [ ] ; $ element [ 'kind' ] = $ kind ; if ( ! is_null ( $ identifier ) ) { $ element [ $ identifierType ] = $ identifier ; } return $ element ; }
Determine the identifier type and return the valid pathElement
1,848
private function determineIdentifierType ( $ identifier , $ identifierType ) { $ allowedTypes = [ self :: TYPE_ID , self :: TYPE_NAME ] ; if ( ! is_null ( $ identifierType ) && in_array ( $ identifierType , $ allowedTypes ) ) { return $ identifierType ; } elseif ( ! is_null ( $ identifierType ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid identifier type %s' , $ identifierType ) ) ; } if ( is_numeric ( $ identifier ) ) { return self :: TYPE_ID ; } return self :: TYPE_NAME ; }
Determine whether the given identifier is an ID or a Name
1,849
private function normalizePath ( array $ path ) { if ( $ this -> isAssoc ( $ path ) ) { $ path = [ $ path ] ; } $ res = [ ] ; foreach ( $ path as $ index => $ pathElement ) { if ( ! isset ( $ pathElement [ 'kind' ] ) ) { throw new InvalidArgumentException ( 'Each path element must contain a kind.' ) ; } $ incomplete = ( ! isset ( $ pathElement [ 'id' ] ) && ! isset ( $ pathElement [ 'name' ] ) ) ; if ( $ index < count ( $ path ) - 1 && $ incomplete ) { throw new InvalidArgumentException ( 'Only the final pathElement may omit a name or ID.' ) ; } if ( isset ( $ pathElement [ 'id' ] ) && ! is_string ( $ pathElement [ 'id' ] ) ) { $ pathElement [ 'id' ] = ( string ) $ pathElement [ 'id' ] ; } $ res [ ] = $ pathElement ; } return $ res ; }
Normalize the internal representation of a path
1,850
public function setUsage ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Talent \ V4beta1 \ ContactInfoUsage :: class ) ; $ this -> usage = $ var ; return $ this ; }
Optional . The usage of the address . For example SCHOOL WORK PERSONAL .
1,851
public function run ( ) { $ this -> setupSignalHandlers ( ) ; $ procs = [ ] ; while ( true ) { $ jobs = $ this -> runner -> getJobs ( ) ; foreach ( $ jobs as $ job ) { if ( ! array_key_exists ( $ job -> identifier ( ) , $ procs ) ) { $ procs [ $ job -> identifier ( ) ] = [ ] ; } while ( count ( $ procs [ $ job -> identifier ( ) ] ) > $ job -> numWorkers ( ) ) { echo 'Stopping an excessive child.' . PHP_EOL ; $ proc = array_pop ( $ procs [ $ job -> identifier ( ) ] ) ; $ status = proc_get_status ( $ proc ) ; while ( $ status [ 'running' ] === true ) { @ proc_terminate ( $ proc ) ; usleep ( 50000 ) ; $ status = proc_get_status ( $ proc ) ; } @ proc_close ( $ proc ) ; } for ( $ i = 0 ; $ i < $ job -> numWorkers ( ) ; $ i ++ ) { $ needStart = false ; if ( array_key_exists ( $ i , $ procs [ $ job -> identifier ( ) ] ) ) { $ status = proc_get_status ( $ procs [ $ job -> identifier ( ) ] [ $ i ] ) ; if ( $ status [ 'running' ] !== true ) { $ needStart = true ; } } else { $ needStart = true ; } if ( $ needStart ) { echo 'Starting a child.' . PHP_EOL ; $ procs [ $ job -> identifier ( ) ] [ $ i ] = proc_open ( sprintf ( '%s %d' , $ this -> command , $ job -> id ( ) ) , $ this -> descriptorSpec , $ pipes ) ; } } } usleep ( 1000000 ) ; pcntl_signal_dispatch ( ) ; if ( $ this -> shutdown ) { echo 'Shutting down, waiting for the children' . PHP_EOL ; foreach ( $ procs as $ k => $ v ) { foreach ( $ v as $ proc ) { $ status = proc_get_status ( $ proc ) ; while ( $ status [ 'running' ] === true ) { @ proc_terminate ( $ proc ) ; usleep ( 50000 ) ; $ status = proc_get_status ( $ proc ) ; } @ proc_close ( $ proc ) ; } } echo 'BatchDaemon exiting' . PHP_EOL ; exit ; } $ this -> runner -> loadConfig ( ) ; } }
A loop for the parent .
1,852
public function v2Sign ( ConnectionInterface $ connection , $ expires , $ resource , $ generation , array $ options ) { list ( $ credentials , $ options ) = $ this -> getSigningCredentials ( $ connection , $ options ) ; $ expires = $ this -> normalizeExpiration ( $ expires ) ; $ resource = $ this -> normalizeResource ( $ resource ) ; $ options = $ this -> normalizeOptions ( $ options ) ; $ headers = $ this -> normalizeHeaders ( $ options [ 'headers' ] ) ; $ illegalHeaders = [ 'x-goog-encryption-key' , 'x-goog-encryption-key-sha256' ] ; if ( $ illegal = array_intersect_key ( array_flip ( $ illegalHeaders ) , $ headers ) ) { throw new \ InvalidArgumentException ( sprintf ( '%s %s not allowed in Signed URL headers.' , implode ( ' and ' , array_keys ( $ illegal ) ) , count ( $ illegal ) === 1 ? 'is' : 'are' ) ) ; } ksort ( $ headers ) ; $ toSign = [ $ options [ 'method' ] , $ options [ 'contentMd5' ] , $ options [ 'contentType' ] , $ expires , ] ; $ signedHeaders = [ ] ; foreach ( $ headers as $ name => $ value ) { $ signedHeaders [ ] = $ name . ':' . $ value ; } if ( $ signedHeaders ) { $ toSign = array_merge ( $ toSign , $ signedHeaders ) ; } $ toSign [ ] = $ resource ; $ stringToSign = $ this -> createV2CanonicalRequest ( $ toSign ) ; $ signature = $ credentials -> signBlob ( $ stringToSign , [ 'forceOpenssl' => $ options [ 'forceOpenssl' ] ] ) ; $ params = $ options [ 'queryParams' ] ; $ params [ 'GoogleAccessId' ] = $ credentials -> getClientName ( ) ; $ params [ 'Expires' ] = $ expires ; $ params [ 'Signature' ] = $ signature ; $ params = $ this -> addCommonParams ( $ generation , $ params , $ options ) ; $ queryString = $ this -> buildQueryString ( $ params ) ; $ resource = $ this -> normalizeUriPath ( $ options [ 'cname' ] , $ resource ) ; return 'https://' . $ options [ 'cname' ] . $ resource . '?' . $ queryString ; }
Sign a URL using Google Signed URLs v2 .
1,853
private function normalizeExpiration ( $ expires ) { if ( $ expires instanceof Timestamp ) { $ seconds = $ expires -> get ( ) -> format ( 'U' ) ; } elseif ( $ expires instanceof \ DateTimeInterface ) { $ seconds = $ expires -> format ( 'U' ) ; } elseif ( is_numeric ( $ expires ) ) { $ seconds = ( int ) $ expires ; } else { throw new \ InvalidArgumentException ( 'Invalid expiration.' ) ; } return $ seconds ; }
Normalizes and validates an expiration .
1,854
private function normalizeResource ( $ resource ) { $ pieces = explode ( '/' , trim ( $ resource , '/' ) ) ; array_walk ( $ pieces , function ( & $ piece ) { $ piece = rawurlencode ( $ piece ) ; } ) ; return '/' . implode ( '/' , $ pieces ) ; }
Normalizes and encodes the resource identifier .
1,855
private function normalizeOptions ( array $ options ) { $ options += [ 'method' => 'GET' , 'cname' => self :: DEFAULT_DOWNLOAD_HOST , 'contentMd5' => null , 'contentType' => null , 'headers' => [ ] , 'saveAsName' => null , 'responseDisposition' => null , 'responseType' => null , 'keyFile' => null , 'keyFilePath' => null , 'allowPost' => false , 'forceOpenssl' => false , 'queryParams' => [ ] , 'timestamp' => null ] ; $ allowedMethods = [ 'GET' , 'PUT' , 'POST' , 'DELETE' ] ; $ options [ 'method' ] = strtoupper ( $ options [ 'method' ] ) ; if ( ! in_array ( $ options [ 'method' ] , $ allowedMethods ) ) { throw new \ InvalidArgumentException ( '$options.method must be one of `GET`, `PUT` or `DELETE`.' ) ; } if ( $ options [ 'method' ] === 'POST' && ! $ options [ 'allowPost' ] ) { throw new \ InvalidArgumentException ( 'Invalid method. To create an upload URI, use StorageObject::signedUploadUrl().' ) ; } unset ( $ options [ 'allowPost' ] ) ; $ cnameParts = explode ( '//' , $ options [ 'cname' ] ) ; if ( count ( $ cnameParts ) > 1 ) { $ options [ 'cname' ] = $ cnameParts [ 1 ] ; } $ options [ 'cname' ] = trim ( $ options [ 'cname' ] , '/' ) ; if ( $ options [ 'timestamp' ] ) { if ( ! ( $ options [ 'timestamp' ] instanceof \ DateTimeInterface ) ) { if ( ! is_string ( $ options [ 'timestamp' ] ) ) { throw new \ InvalidArgumentException ( 'User-provided timestamps must be a string or instance of `\DateTimeInterface`.' ) ; } $ options [ 'timestamp' ] = \ DateTimeImmutable :: createFromFormat ( self :: V4_TIMESTAMP_FORMAT , $ options [ 'timestamp' ] , new \ DateTimeZone ( 'UTC' ) ) ; if ( ! $ options [ 'timestamp' ] ) { throw new \ InvalidArgumentException ( 'Given timestamp string is in an invalid format. Provide timestamp formatted as follows: `' . self :: V4_TIMESTAMP_FORMAT . '`. Note that timestamps MUST be in UTC.' ) ; } } } else { $ options [ 'timestamp' ] = new \ DateTimeImmutable ( 'now' , new \ DateTimeZone ( 'UTC' ) ) ; } return $ options ; }
Fixes the user input options filters and validates data .
1,856
private function normalizeHeaders ( array $ headers ) { $ out = [ ] ; foreach ( $ headers as $ name => $ value ) { $ name = strtolower ( trim ( $ name ) ) ; if ( ! is_array ( $ value ) ) { $ value = [ $ value ] ; } foreach ( $ value as & $ headerValue ) { $ headerValue = trim ( $ headerValue ) ; $ headerValue = str_replace ( PHP_EOL , '' , $ headerValue ) ; $ headerValue = preg_replace ( '/\s+/' , ' ' , $ headerValue ) ; } $ out [ $ name ] = implode ( ', ' , $ value ) ; } return $ out ; }
Cleans and normalizes header values .
1,857
private function normalizeUriPath ( $ cname , $ resource ) { if ( $ cname !== self :: DEFAULT_DOWNLOAD_HOST ) { $ resourceParts = explode ( '/' , trim ( $ resource , '/' ) ) ; array_shift ( $ resourceParts ) ; if ( empty ( $ resourceParts ) ) { $ resource = '/' ; } else { $ resource = '/' . implode ( '/' , $ resourceParts ) ; } } return $ resource ; }
Returns a resource formatted for use in a URI .
1,858
private function getSigningCredentials ( ConnectionInterface $ connection , array $ options ) { $ keyFilePath = isset ( $ options [ 'keyFilePath' ] ) ? $ options [ 'keyFilePath' ] : null ; if ( $ keyFilePath ) { if ( ! file_exists ( $ keyFilePath ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Keyfile path %s does not exist.' , $ keyFilePath ) ) ; } $ options [ 'keyFile' ] = self :: jsonDecode ( file_get_contents ( $ keyFilePath ) , true ) ; } $ rw = $ connection -> requestWrapper ( ) ; $ keyFile = isset ( $ options [ 'keyFile' ] ) ? $ options [ 'keyFile' ] : null ; if ( $ keyFile ) { $ scopes = isset ( $ options [ 'scopes' ] ) ? $ options [ 'scopes' ] : $ rw -> scopes ( ) ; $ credentials = CredentialsLoader :: makeCredentials ( $ scopes , $ keyFile ) ; } else { $ credentials = $ rw -> getCredentialsFetcher ( ) ; } if ( ! ( $ credentials instanceof SignBlobInterface ) ) { throw new \ RuntimeException ( sprintf ( 'Credentials object is of type `%s` and is not valid for signing.' , get_class ( $ credentials ) ) ) ; } unset ( $ options [ 'keyFilePath' ] , $ options [ 'keyFile' ] , $ options [ 'scopes' ] ) ; return [ $ credentials , $ options ] ; }
Get the credentials for use with signing .
1,859
private function addCommonParams ( $ generation , array $ params , array $ options ) { if ( $ options [ 'responseType' ] ) { $ params [ 'response-content-type' ] = $ options [ 'responseType' ] ; } if ( $ options [ 'responseDisposition' ] ) { $ params [ 'response-content-disposition' ] = $ options [ 'responseDisposition' ] ; } elseif ( $ options [ 'saveAsName' ] ) { $ params [ 'response-content-disposition' ] = 'attachment; filename=' . '"' . $ options [ 'saveAsName' ] . '"' ; } if ( $ generation ) { $ params [ 'generation' ] = $ generation ; } return $ params ; }
Add parameters common to all signed URL versions .
1,860
public function serialize ( ) { $ vars = get_object_vars ( $ this ) ; $ vars [ 'keySet' ] = $ vars [ 'keySet' ] -> keySetObject ( ) ; return base64_encode ( json_encode ( $ vars + [ BatchClient :: PARTITION_TYPE_KEY => static :: class ] ) ) ; }
Return a stringified representation of the ReadPartition object .
1,861
public static function hydrate ( array $ data ) { return new self ( $ data [ 'token' ] , $ data [ 'table' ] , KeySet :: fromArray ( $ data [ 'keySet' ] ) , $ data [ 'columns' ] , $ data [ 'options' ] ) ; }
Create a ReadPartition object from a deserialized array of partition data .
1,862
public function setMode ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ Datastore \ V1 \ CommitRequest_Mode :: class ) ; $ this -> mode = $ var ; return $ this ; }
The type of commit to perform . Defaults to TRANSACTIONAL .
1,863
public function setStates ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: ENUM , \ Google \ Cloud \ BigQuery \ DataTransfer \ V1 \ TransferState :: class ) ; $ this -> states = $ arr ; return $ this ; }
When specified only transfer runs with requested states are returned .
1,864
public function setRunAttempt ( $ var ) { GPBUtil :: checkEnum ( $ var , \ Google \ Cloud \ BigQuery \ DataTransfer \ V1 \ ListTransferRunsRequest_RunAttempt :: class ) ; $ this -> run_attempt = $ var ; return $ this ; }
Indicates how run attempts are to be pulled .
1,865
public function createCluster ( $ projectId , $ region , $ cluster , array $ optionalArgs = [ ] ) { $ request = new CreateClusterRequest ( ) ; $ request -> setProjectId ( $ projectId ) ; $ request -> setRegion ( $ region ) ; $ request -> setCluster ( $ cluster ) ; if ( isset ( $ optionalArgs [ 'requestId' ] ) ) { $ request -> setRequestId ( $ optionalArgs [ 'requestId' ] ) ; } return $ this -> startOperationsCall ( 'CreateCluster' , $ optionalArgs , $ request , $ this -> getOperationsClient ( ) ) -> wait ( ) ; }
Creates a cluster in a project .
1,866
public function updateCluster ( $ projectId , $ region , $ clusterName , $ cluster , $ updateMask , array $ optionalArgs = [ ] ) { $ request = new UpdateClusterRequest ( ) ; $ request -> setProjectId ( $ projectId ) ; $ request -> setRegion ( $ region ) ; $ request -> setClusterName ( $ clusterName ) ; $ request -> setCluster ( $ cluster ) ; $ request -> setUpdateMask ( $ updateMask ) ; if ( isset ( $ optionalArgs [ 'gracefulDecommissionTimeout' ] ) ) { $ request -> setGracefulDecommissionTimeout ( $ optionalArgs [ 'gracefulDecommissionTimeout' ] ) ; } if ( isset ( $ optionalArgs [ 'requestId' ] ) ) { $ request -> setRequestId ( $ optionalArgs [ 'requestId' ] ) ; } return $ this -> startOperationsCall ( 'UpdateCluster' , $ optionalArgs , $ request , $ this -> getOperationsClient ( ) ) -> wait ( ) ; }
Updates a cluster in a project .
1,867
public function deleteCluster ( $ projectId , $ region , $ clusterName , array $ optionalArgs = [ ] ) { $ request = new DeleteClusterRequest ( ) ; $ request -> setProjectId ( $ projectId ) ; $ request -> setRegion ( $ region ) ; $ request -> setClusterName ( $ clusterName ) ; if ( isset ( $ optionalArgs [ 'clusterUuid' ] ) ) { $ request -> setClusterUuid ( $ optionalArgs [ 'clusterUuid' ] ) ; } if ( isset ( $ optionalArgs [ 'requestId' ] ) ) { $ request -> setRequestId ( $ optionalArgs [ 'requestId' ] ) ; } return $ this -> startOperationsCall ( 'DeleteCluster' , $ optionalArgs , $ request , $ this -> getOperationsClient ( ) ) -> wait ( ) ; }
Deletes a cluster in a project .
1,868
private function buildNestedParams ( $ nestedParams , $ origParam , $ isProto = false ) { $ paramsArray = [ ] ; foreach ( $ nestedParams as $ param ) { $ nestedParam = explode ( ' ' , trim ( $ param ) , 3 ) ; if ( count ( $ nestedParam ) < 3 && ! $ isProto ) { throw new \ Exception ( 'nested param is in an invalid format: ' . $ param ) ; } list ( $ type , $ name , $ description ) = $ nestedParam ; $ name = substr ( $ name , 1 ) ; $ description = preg_replace ( '/\s+/' , ' ' , $ description ) ; $ types = new Collection ( array ( $ type ) , $ origParam -> getDocBlock ( ) ? $ origParam -> getDocBlock ( ) -> getContext ( ) : null ) ; $ paramsArray [ ] = [ 'name' => substr ( $ origParam -> getVariableName ( ) , 1 ) . '.' . $ name , 'description' => $ this -> buildDescription ( $ origParam -> getDocBlock ( ) , $ description , $ origParam ) , 'types' => $ this -> handleTypes ( $ types ) , 'optional' => null , 'nullable' => null ] ; } return $ paramsArray ; }
PHPDoc has no support for nested params currently . this is a workaround until it is implemented .
1,869
public function create ( array $ options = [ ] ) { if ( ! $ this -> topicName ) { throw new InvalidArgumentException ( 'A topic name is required to create a subscription.' ) ; } $ this -> info = $ this -> connection -> createSubscription ( $ options + [ 'name' => $ this -> name , 'topic' => $ this -> topicName ] ) ; return $ this -> info ; }
Execute a service request creating the subscription .
1,870
public function update ( array $ subscription , array $ options = [ ] ) { return $ this -> info = $ this -> connection -> updateSubscription ( [ 'name' => $ this -> name ] + $ options + $ subscription ) ; }
Update the subscription .
1,871
public function reload ( array $ options = [ ] ) { return $ this -> info = $ this -> connection -> getSubscription ( $ options + [ 'subscription' => $ this -> name ] ) ; }
Retrieve info on a subscription from the API .
1,872
public function pull ( array $ options = [ ] ) { $ messages = [ ] ; $ options [ 'returnImmediately' ] = isset ( $ options [ 'returnImmediately' ] ) ? $ options [ 'returnImmediately' ] : false ; $ options [ 'maxMessages' ] = isset ( $ options [ 'maxMessages' ] ) ? $ options [ 'maxMessages' ] : self :: MAX_MESSAGES ; $ response = $ this -> connection -> pull ( $ options + [ 'subscription' => $ this -> name ] ) ; if ( isset ( $ response [ 'receivedMessages' ] ) ) { foreach ( $ response [ 'receivedMessages' ] as $ message ) { $ messages [ ] = $ this -> messageFactory ( $ message , $ this -> connection , $ this -> projectId , $ this -> encode ) ; } } return $ messages ; }
Retrieve new messages from the topic .
1,873
public function acknowledgeBatch ( array $ messages , array $ options = [ ] ) { $ this -> validateBatch ( $ messages , Message :: class ) ; $ this -> connection -> acknowledge ( $ options + [ 'subscription' => $ this -> name , 'ackIds' => $ this -> getMessageAckIds ( $ messages ) ] ) ; }
Acknowledge receipt of multiple messages at once .
1,874
public function modifyAckDeadline ( Message $ message , $ seconds , array $ options = [ ] ) { $ this -> modifyAckDeadlineBatch ( [ $ message ] , $ seconds , $ options ) ; }
Set the acknowledge deadline for a single ackId .
1,875
public function modifyAckDeadlineBatch ( array $ messages , $ seconds , array $ options = [ ] ) { $ this -> validateBatch ( $ messages , Message :: class ) ; $ this -> connection -> modifyAckDeadline ( $ options + [ 'subscription' => $ this -> name , 'ackIds' => $ this -> getMessageAckIds ( $ messages ) , 'ackDeadlineSeconds' => $ seconds ] ) ; }
Set the acknowledge deadline for multiple ackIds .
1,876
public function modifyPushConfig ( array $ pushConfig , array $ options = [ ] ) { $ this -> connection -> modifyPushConfig ( $ options + [ 'subscription' => $ this -> name , 'pushConfig' => $ pushConfig ] ) ; }
Set the push config for the subscription
1,877
public function seekToTime ( Timestamp $ timestamp ) { return $ this -> connection -> seek ( [ 'subscription' => $ this -> name , 'time' => $ timestamp -> formatAsString ( ) ] ) ; }
Seek to a given timestamp .
1,878
public function seekToSnapshot ( Snapshot $ snapshot ) { return $ this -> connection -> seek ( [ 'subscription' => $ this -> name , 'snapshot' => $ snapshot -> name ( ) ] ) ; }
Seek to a given snapshot .
1,879
public function iam ( ) { if ( ! $ this -> iam ) { $ iamConnection = new IamSubscription ( $ this -> connection ) ; $ this -> iam = new Iam ( $ iamConnection , $ this -> name ) ; } return $ this -> iam ; }
Manage the IAM policy for the current Subscription .
1,880
private function getMessageAckIds ( array $ messages ) { $ ackIds = [ ] ; foreach ( $ messages as $ message ) { $ ackIds [ ] = $ message -> ackId ( ) ; } return $ ackIds ; }
Get a list of ackIds from a list of Message objects .
1,881
public function setInput ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ TextToSpeech \ V1 \ SynthesisInput :: class ) ; $ this -> input = $ var ; return $ this ; }
Required . The Synthesizer requires either plain text or SSML as input .
1,882
public function setVoice ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ TextToSpeech \ V1 \ VoiceSelectionParams :: class ) ; $ this -> voice = $ var ; return $ this ; }
Required . The desired voice of the synthesized audio .
1,883
public function setAudioConfig ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ TextToSpeech \ V1 \ AudioConfig :: class ) ; $ this -> audio_config = $ var ; return $ this ; }
Required . The configuration of the synthesized audio .
1,884
public function setSecurityCenterProperties ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ SecurityCenter \ V1 \ Asset_SecurityCenterProperties :: class ) ; $ this -> security_center_properties = $ var ; return $ this ; }
Cloud SCC managed properties . These properties are managed by Cloud SCC and cannot be modified by the user .
1,885
public function setResourceProperties ( $ var ) { $ arr = GPBUtil :: checkMapField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Protobuf \ Value :: class ) ; $ this -> resource_properties = $ arr ; return $ this ; }
Resource managed properties . These properties are managed and defined by the GCP resource and cannot be modified by the user .
1,886
public function setIamPolicy ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ SecurityCenter \ V1 \ Asset_IamPolicy :: class ) ; $ this -> iam_policy = $ var ; return $ this ; }
IAM Policy information associated with the GCP resource described by the Cloud SCC asset . This information is managed and defined by the GCP resource and cannot be modified by the user .
1,887
public function setFilter ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Firestore \ V1beta1 \ ExistenceFilter :: class ) ; $ this -> writeOneof ( 5 , $ var ) ; return $ this ; }
A filter to apply to the set of documents previously returned for the given target . Returned when documents may have been removed from the given target but the exact documents are unknown .
1,888
public function setTransformationSummaries ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dlp \ V2 \ TransformationSummary :: class ) ; $ this -> transformation_summaries = $ arr ; return $ this ; }
Transformations applied to the dataset .
1,889
public function setJobTriggers ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: MESSAGE , \ Google \ Cloud \ Dlp \ V2 \ JobTrigger :: class ) ; $ this -> job_triggers = $ arr ; return $ this ; }
List of triggeredJobs up to page_size in ListJobTriggersRequest .
1,890
public function setValidation ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dataproc \ V1beta2 \ ParameterValidation :: class ) ; $ this -> validation = $ var ; return $ this ; }
Optional . Validation rules to be applied to this parameter s value .
1,891
public function setTags ( $ var ) { $ arr = GPBUtil :: checkRepeatedField ( $ var , \ Google \ Protobuf \ Internal \ GPBType :: STRING ) ; $ this -> tags = $ arr ; return $ this ; }
The list of instance tags applied to all nodes . Tags are used to identify valid sources or targets for network firewalls and are specified by the client during cluster or node pool creation . Each tag within the list must comply with RFC1035 .
1,892
public function encodeValues ( array $ fields ) { $ output = [ ] ; foreach ( $ fields as $ key => $ val ) { $ output [ $ key ] = $ this -> encodeValue ( $ val ) ; } return $ output ; }
Convert a PHP array containing google - cloud - php and simple types to an array ready to be sent to Firestore .
1,893
public function encodeValue ( $ value ) { $ type = gettype ( $ value ) ; switch ( $ type ) { case 'boolean' : return [ 'booleanValue' => $ value ] ; break ; case 'integer' : return [ 'integerValue' => $ value ] ; break ; case 'double' : return [ 'doubleValue' => $ value ] ; break ; case 'string' : return [ 'stringValue' => $ value ] ; break ; case 'resource' : return [ 'bytesValue' => stream_get_contents ( $ value ) ] ; break ; case 'object' : return $ this -> encodeObjectValue ( $ value ) ; break ; case 'array' : if ( ! empty ( $ value ) && $ this -> isAssoc ( $ value ) ) { return $ this -> encodeAssociativeArrayValue ( $ value ) ; } return [ 'arrayValue' => $ this -> encodeArrayValue ( $ value ) ] ; break ; case 'NULL' : return [ 'nullValue' => NullValue :: NULL_VALUE ] ; break ; default : throw new \ RuntimeException ( sprintf ( 'Invalid value type %s' , $ type ) ) ; break ; } }
Encode a Google Cloud PHP value as a Firestore value .
1,894
private function encodeObjectValue ( $ value ) { if ( $ value instanceof \ stdClass ) { return $ this -> encodeAssociativeArrayValue ( ( array ) $ value ) ; } if ( $ value instanceof Blob ) { return [ 'bytesValue' => ( string ) $ value ] ; } if ( $ value instanceof \ DateTimeInterface ) { return [ 'timestampValue' => [ 'seconds' => $ value -> format ( 'U' ) , 'nanos' => ( int ) ( $ value -> format ( 'u' ) * 1000 ) ] ] ; } if ( $ value instanceof Timestamp ) { return [ 'timestampValue' => [ 'seconds' => $ value -> get ( ) -> format ( 'U' ) , 'nanos' => $ value -> nanoSeconds ( ) ] ] ; } if ( $ value instanceof GeoPoint ) { return [ 'geoPointValue' => $ value -> point ( ) ] ; } if ( $ value instanceof DocumentReference || $ value instanceof DocumentSnapshot ) { return [ 'referenceValue' => $ value -> name ( ) ] ; } throw new \ RuntimeException ( sprintf ( 'Object of type %s cannot be encoded to a Firestore value type.' , get_class ( $ value ) ) ) ; }
Encode a value of type object as a Firestore value .
1,895
private function encodeAssociativeArrayValue ( array $ value ) { $ out = [ ] ; foreach ( $ value as $ key => $ item ) { $ out [ $ key ] = $ this -> encodeValue ( $ item ) ; } return [ 'mapValue' => [ 'fields' => $ out ] ] ; }
Encode an associative array as a Firestore Map value .
1,896
public function setDevice ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Iot \ V1 \ Device :: class ) ; $ this -> device = $ var ; return $ this ; }
The device registration details . The field name must be empty . The server generates name from the device registry id and the parent field .
1,897
public function setFollowupEventInput ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Dialogflow \ V2 \ EventInput :: class ) ; $ this -> followup_event_input = $ var ; return $ this ; }
Optional . Makes the platform immediately invoke another DetectIntent call internally with the specified event as input .
1,898
public function setCluster ( $ var ) { GPBUtil :: checkMessage ( $ var , \ Google \ Cloud \ Bigtable \ Admin \ V2 \ Cluster :: class ) ; $ this -> cluster = $ var ; return $ this ; }
The cluster to be created . Fields marked OutputOnly must be left blank .
1,899
public function keySetObject ( ) { $ ranges = [ ] ; foreach ( $ this -> ranges as $ range ) { $ ranges [ ] = $ range -> keyRangeObject ( ) ; } $ set = [ ] ; if ( $ this -> all ) { $ set [ 'all' ] = true ; } if ( $ this -> keys ) { $ set [ 'keys' ] = $ this -> keys ; } if ( $ ranges ) { $ set [ 'ranges' ] = $ ranges ; } return $ set ; }
Format a KeySet object for use in the Spanner API .