repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
googleapis/google-cloud-php
Dialogflow/src/V2/Intent.php
Intent.setTrainingPhrases
public function setTrainingPhrases($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent\TrainingPhrase::class); $this->training_phrases = $arr; return $this; }
php
public function setTrainingPhrases($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent\TrainingPhrase::class); $this->training_phrases = $arr; return $this; }
[ "public", "function", "setTrainingPhrases", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Dialogflow", "\\", "V2", "\\", "Intent", "\\", "TrainingPhrase", "::", "class", ")", ";", "$", "this", "->", "training_phrases", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Optional. The collection of examples that the agent is trained on. Generated from protobuf field <code>repeated .google.cloud.dialogflow.v2.Intent.TrainingPhrase training_phrases = 9;</code> @param \Google\Cloud\Dialogflow\V2\Intent\TrainingPhrase[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Optional", ".", "The", "collection", "of", "examples", "that", "the", "agent", "is", "trained", "on", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dialogflow/src/V2/Intent.php#L494-L500
train
googleapis/google-cloud-php
Dialogflow/src/V2/Intent.php
Intent.setMessages
public function setMessages($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent\Message::class); $this->messages = $arr; return $this; }
php
public function setMessages($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent\Message::class); $this->messages = $arr; return $this; }
[ "public", "function", "setMessages", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Dialogflow", "\\", "V2", "\\", "Intent", "\\", "Message", "::", "class", ")", ";", "$", "this", "->", "messages", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Optional. The collection of rich messages corresponding to the `Response` field in the Dialogflow console. Generated from protobuf field <code>repeated .google.cloud.dialogflow.v2.Intent.Message messages = 14;</code> @param \Google\Cloud\Dialogflow\V2\Intent\Message[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Optional", ".", "The", "collection", "of", "rich", "messages", "corresponding", "to", "the", "Response", "field", "in", "the", "Dialogflow", "console", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dialogflow/src/V2/Intent.php#L638-L644
train
googleapis/google-cloud-php
Dialogflow/src/V2/Intent.php
Intent.setFollowupIntentInfo
public function setFollowupIntentInfo($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent\FollowupIntentInfo::class); $this->followup_intent_info = $arr; return $this; }
php
public function setFollowupIntentInfo($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dialogflow\V2\Intent\FollowupIntentInfo::class); $this->followup_intent_info = $arr; return $this; }
[ "public", "function", "setFollowupIntentInfo", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Dialogflow", "\\", "V2", "\\", "Intent", "\\", "FollowupIntentInfo", "::", "class", ")", ";", "$", "this", "->", "followup_intent_info", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Read-only. Information about all followup intents that have this intent as a direct or indirect parent. We populate this field only in the output. Generated from protobuf field <code>repeated .google.cloud.dialogflow.v2.Intent.FollowupIntentInfo followup_intent_info = 18;</code> @param \Google\Cloud\Dialogflow\V2\Intent\FollowupIntentInfo[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Read", "-", "only", ".", "Information", "about", "all", "followup", "intents", "that", "have", "this", "intent", "as", "a", "direct", "or", "indirect", "parent", ".", "We", "populate", "this", "field", "only", "in", "the", "output", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dialogflow/src/V2/Intent.php#L762-L768
train
googleapis/google-cloud-php
BigQuery/src/InsertResponse.php
InsertResponse.failedRows
public function failedRows() { $rows = []; if ($this->isSuccessful()) { return $rows; } foreach ($this->info['insertErrors'] as $error) { $rows[] = $error + [ 'rowData' => $this->rows[$error['index']]['json'] ]; } return $rows; }
php
public function failedRows() { $rows = []; if ($this->isSuccessful()) { return $rows; } foreach ($this->info['insertErrors'] as $error) { $rows[] = $error + [ 'rowData' => $this->rows[$error['index']]['json'] ]; } return $rows; }
[ "public", "function", "failedRows", "(", ")", "{", "$", "rows", "=", "[", "]", ";", "if", "(", "$", "this", "->", "isSuccessful", "(", ")", ")", "{", "return", "$", "rows", ";", "}", "foreach", "(", "$", "this", "->", "info", "[", "'insertErrors'", "]", "as", "$", "error", ")", "{", "$", "rows", "[", "]", "=", "$", "error", "+", "[", "'rowData'", "=>", "$", "this", "->", "rows", "[", "$", "error", "[", "'index'", "]", "]", "[", "'json'", "]", "]", ";", "}", "return", "$", "rows", ";", "}" ]
Returns the rows which failed to insert along with their associated errors and index in the original data set. Example: ``` $rows = $insertResponse->failedRows(); foreach ($rows as $row) { print_r($row['rowData']) . PHP_EOL; foreach ($row['errors'] as $error) { echo $error['reason'] . ': ' . $error['message'] . PHP_EOL; } } ``` @see https://cloud.google.com/bigquery/docs/reference/v2/tabledata/insertAll#response Tabledata insertAll API response documentation. @return array
[ "Returns", "the", "rows", "which", "failed", "to", "insert", "along", "with", "their", "associated", "errors", "and", "index", "in", "the", "original", "data", "set", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/BigQuery/src/InsertResponse.php#L88-L103
train
googleapis/google-cloud-php
Dlp/src/V2/ListDlpJobsResponse.php
ListDlpJobsResponse.setJobs
public function setJobs($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\DlpJob::class); $this->jobs = $arr; return $this; }
php
public function setJobs($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Dlp\V2\DlpJob::class); $this->jobs = $arr; return $this; }
[ "public", "function", "setJobs", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "DlpJob", "::", "class", ")", ";", "$", "this", "->", "jobs", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
A list of DlpJobs that matches the specified filter in the request. Generated from protobuf field <code>repeated .google.privacy.dlp.v2.DlpJob jobs = 1;</code> @param \Google\Cloud\Dlp\V2\DlpJob[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "A", "list", "of", "DlpJobs", "that", "matches", "the", "specified", "filter", "in", "the", "request", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/ListDlpJobsResponse.php#L66-L72
train
googleapis/google-cloud-php
Dlp/src/V2/RecordKey.php
RecordKey.setIdValues
public function setIdValues($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->id_values = $arr; return $this; }
php
public function setIdValues($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->id_values = $arr; return $this; }
[ "public", "function", "setIdValues", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "id_values", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Values of identifying columns in the given row. Order of values matches the order of field identifiers specified in the scanning request. Generated from protobuf field <code>repeated string id_values = 5;</code> @param string[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Values", "of", "identifying", "columns", "in", "the", "given", "row", ".", "Order", "of", "values", "matches", "the", "order", "of", "field", "identifiers", "specified", "in", "the", "scanning", "request", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/RecordKey.php#L109-L115
train
googleapis/google-cloud-php
Bigtable/src/BigtableClient.php
BigtableClient.table
public function table($instanceId, $tableId, array $options = []) { return new Table( $this->gapicClient, GapicClient::tableName($this->projectId, $instanceId, $tableId), $options ); }
php
public function table($instanceId, $tableId, array $options = []) { return new Table( $this->gapicClient, GapicClient::tableName($this->projectId, $instanceId, $tableId), $options ); }
[ "public", "function", "table", "(", "$", "instanceId", ",", "$", "tableId", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "new", "Table", "(", "$", "this", "->", "gapicClient", ",", "GapicClient", "::", "tableName", "(", "$", "this", "->", "projectId", ",", "$", "instanceId", ",", "$", "tableId", ")", ",", "$", "options", ")", ";", "}" ]
Returns a table instance which can be used to read rows and to perform insert, update, and delete operations. Example: ``` $table = $bigtable->table('my-instance', 'my-table'); ``` @param string $instanceId The instance ID. @param string $tableId The table ID. @param array $options [optional] { Configuration options. @type string $appProfileId This value specifies routing for replication. **Defaults to** the "default" application profile. @type array $headers Headers to be passed with each request. } @return Table
[ "Returns", "a", "table", "instance", "which", "can", "be", "used", "to", "read", "rows", "and", "to", "perform", "insert", "update", "and", "delete", "operations", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/BigtableClient.php#L144-L151
train
googleapis/google-cloud-php
ErrorReporting/src/V1beta1/ErrorGroupServiceGrpcClient.php
ErrorGroupServiceGrpcClient.UpdateGroup
public function UpdateGroup(\Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/UpdateGroup', $argument, ['\Google\Cloud\ErrorReporting\V1beta1\ErrorGroup', 'decode'], $metadata, $options); }
php
public function UpdateGroup(\Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest $argument, $metadata = [], $options = []) { return $this->_simpleRequest('/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/UpdateGroup', $argument, ['\Google\Cloud\ErrorReporting\V1beta1\ErrorGroup', 'decode'], $metadata, $options); }
[ "public", "function", "UpdateGroup", "(", "\\", "Google", "\\", "Cloud", "\\", "ErrorReporting", "\\", "V1beta1", "\\", "UpdateGroupRequest", "$", "argument", ",", "$", "metadata", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "_simpleRequest", "(", "'/google.devtools.clouderrorreporting.v1beta1.ErrorGroupService/UpdateGroup'", ",", "$", "argument", ",", "[", "'\\Google\\Cloud\\ErrorReporting\\V1beta1\\ErrorGroup'", ",", "'decode'", "]", ",", "$", "metadata", ",", "$", "options", ")", ";", "}" ]
Replace the data for the specified group. Fails if the group does not exist. @param \Google\Cloud\ErrorReporting\V1beta1\UpdateGroupRequest $argument input argument @param array $metadata metadata @param array $options call options
[ "Replace", "the", "data", "for", "the", "specified", "group", ".", "Fails", "if", "the", "group", "does", "not", "exist", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/ErrorReporting/src/V1beta1/ErrorGroupServiceGrpcClient.php#L56-L62
train
googleapis/google-cloud-php
Bigtable/src/V2/Family.php
Family.setColumns
public function setColumns($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\V2\Column::class); $this->columns = $arr; return $this; }
php
public function setColumns($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\V2\Column::class); $this->columns = $arr; return $this; }
[ "public", "function", "setColumns", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "V2", "\\", "Column", "::", "class", ")", ";", "$", "this", "->", "columns", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Must not be empty. Sorted in order of increasing "qualifier". Generated from protobuf field <code>repeated .google.bigtable.v2.Column columns = 2;</code> @param \Google\Cloud\Bigtable\V2\Column[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Must", "not", "be", "empty", ".", "Sorted", "in", "order", "of", "increasing", "qualifier", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/V2/Family.php#L113-L119
train
googleapis/google-cloud-php
Dataproc/src/V1beta2/ClusterOperationMetadata.php
ClusterOperationMetadata.setWarnings
public function setWarnings($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->warnings = $arr; return $this; }
php
public function setWarnings($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::STRING); $this->warnings = $arr; return $this; }
[ "public", "function", "setWarnings", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "STRING", ")", ";", "$", "this", "->", "warnings", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
Output only. Errors encountered during operation execution. Generated from protobuf field <code>repeated string warnings = 14;</code> @param string[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "Output", "only", ".", "Errors", "encountered", "during", "operation", "execution", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/ClusterOperationMetadata.php#L296-L302
train
googleapis/google-cloud-php
Talent/src/V4beta1/RequestMetadata.php
RequestMetadata.setDeviceInfo
public function setDeviceInfo($var) { GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\DeviceInfo::class); $this->device_info = $var; return $this; }
php
public function setDeviceInfo($var) { GPBUtil::checkMessage($var, \Google\Cloud\Talent\V4beta1\DeviceInfo::class); $this->device_info = $var; return $this; }
[ "public", "function", "setDeviceInfo", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Talent", "\\", "V4beta1", "\\", "DeviceInfo", "::", "class", ")", ";", "$", "this", "->", "device_info", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Optional. The type of device used by the job seeker at the time of the call to the service. Generated from protobuf field <code>.google.cloud.talent.v4beta1.DeviceInfo device_info = 5;</code> @param \Google\Cloud\Talent\V4beta1\DeviceInfo $var @return $this
[ "Optional", ".", "The", "type", "of", "device", "used", "by", "the", "job", "seeker", "at", "the", "time", "of", "the", "call", "to", "the", "service", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/RequestMetadata.php#L373-L379
train
googleapis/google-cloud-php
PubSub/src/V1/ListSubscriptionsResponse.php
ListSubscriptionsResponse.setSubscriptions
public function setSubscriptions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\PubSub\V1\Subscription::class); $this->subscriptions = $arr; return $this; }
php
public function setSubscriptions($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\PubSub\V1\Subscription::class); $this->subscriptions = $arr; return $this; }
[ "public", "function", "setSubscriptions", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "PubSub", "\\", "V1", "\\", "Subscription", "::", "class", ")", ";", "$", "this", "->", "subscriptions", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The subscriptions that match the request. Generated from protobuf field <code>repeated .google.pubsub.v1.Subscription subscriptions = 1;</code> @param \Google\Cloud\PubSub\V1\Subscription[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "subscriptions", "that", "match", "the", "request", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/V1/ListSubscriptionsResponse.php#L70-L76
train
googleapis/google-cloud-php
ErrorReporting/src/V1beta1/ListGroupStatsResponse.php
ListGroupStatsResponse.setErrorGroupStats
public function setErrorGroupStats($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\ErrorReporting\V1beta1\ErrorGroupStats::class); $this->error_group_stats = $arr; return $this; }
php
public function setErrorGroupStats($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\ErrorReporting\V1beta1\ErrorGroupStats::class); $this->error_group_stats = $arr; return $this; }
[ "public", "function", "setErrorGroupStats", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "ErrorReporting", "\\", "V1beta1", "\\", "ErrorGroupStats", "::", "class", ")", ";", "$", "this", "->", "error_group_stats", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The error group stats which match the given request. Generated from protobuf field <code>repeated .google.devtools.clouderrorreporting.v1beta1.ErrorGroupStats error_group_stats = 1;</code> @param \Google\Cloud\ErrorReporting\V1beta1\ErrorGroupStats[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "error", "group", "stats", "which", "match", "the", "given", "request", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/ErrorReporting/src/V1beta1/ListGroupStatsResponse.php#L84-L90
train
googleapis/google-cloud-php
Bigtable/src/V2/Mutation.php
Mutation.setSetCell
public function setSetCell($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_SetCell::class); $this->writeOneof(1, $var); return $this; }
php
public function setSetCell($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_SetCell::class); $this->writeOneof(1, $var); return $this; }
[ "public", "function", "setSetCell", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "V2", "\\", "Mutation_SetCell", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "1", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Set a cell's value. Generated from protobuf field <code>.google.bigtable.v2.Mutation.SetCell set_cell = 1;</code> @param \Google\Cloud\Bigtable\V2\Mutation\SetCell $var @return $this
[ "Set", "a", "cell", "s", "value", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/V2/Mutation.php#L59-L65
train
googleapis/google-cloud-php
Bigtable/src/V2/Mutation.php
Mutation.setDeleteFromColumn
public function setDeleteFromColumn($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_DeleteFromColumn::class); $this->writeOneof(2, $var); return $this; }
php
public function setDeleteFromColumn($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_DeleteFromColumn::class); $this->writeOneof(2, $var); return $this; }
[ "public", "function", "setDeleteFromColumn", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "V2", "\\", "Mutation_DeleteFromColumn", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "2", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Deletes cells from a column. Generated from protobuf field <code>.google.bigtable.v2.Mutation.DeleteFromColumn delete_from_column = 2;</code> @param \Google\Cloud\Bigtable\V2\Mutation\DeleteFromColumn $var @return $this
[ "Deletes", "cells", "from", "a", "column", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/V2/Mutation.php#L85-L91
train
googleapis/google-cloud-php
Bigtable/src/V2/Mutation.php
Mutation.setDeleteFromFamily
public function setDeleteFromFamily($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_DeleteFromFamily::class); $this->writeOneof(3, $var); return $this; }
php
public function setDeleteFromFamily($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_DeleteFromFamily::class); $this->writeOneof(3, $var); return $this; }
[ "public", "function", "setDeleteFromFamily", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "V2", "\\", "Mutation_DeleteFromFamily", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "3", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Deletes cells from a column family. Generated from protobuf field <code>.google.bigtable.v2.Mutation.DeleteFromFamily delete_from_family = 3;</code> @param \Google\Cloud\Bigtable\V2\Mutation\DeleteFromFamily $var @return $this
[ "Deletes", "cells", "from", "a", "column", "family", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/V2/Mutation.php#L111-L117
train
googleapis/google-cloud-php
Bigtable/src/V2/Mutation.php
Mutation.setDeleteFromRow
public function setDeleteFromRow($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_DeleteFromRow::class); $this->writeOneof(4, $var); return $this; }
php
public function setDeleteFromRow($var) { GPBUtil::checkMessage($var, \Google\Cloud\Bigtable\V2\Mutation_DeleteFromRow::class); $this->writeOneof(4, $var); return $this; }
[ "public", "function", "setDeleteFromRow", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "V2", "\\", "Mutation_DeleteFromRow", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "4", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Deletes cells from the entire row. Generated from protobuf field <code>.google.bigtable.v2.Mutation.DeleteFromRow delete_from_row = 4;</code> @param \Google\Cloud\Bigtable\V2\Mutation\DeleteFromRow $var @return $this
[ "Deletes", "cells", "from", "the", "entire", "row", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/V2/Mutation.php#L137-L143
train
googleapis/google-cloud-php
Trace/src/V2/Span/TimeEvent/Annotation.php
Annotation.setDescription
public function setDescription($var) { GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\TruncatableString::class); $this->description = $var; return $this; }
php
public function setDescription($var) { GPBUtil::checkMessage($var, \Google\Cloud\Trace\V2\TruncatableString::class); $this->description = $var; return $this; }
[ "public", "function", "setDescription", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Trace", "\\", "V2", "\\", "TruncatableString", "::", "class", ")", ";", "$", "this", "->", "description", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
A user-supplied message describing the event. The maximum length for the description is 256 bytes. Generated from protobuf field <code>.google.devtools.cloudtrace.v2.TruncatableString description = 1;</code> @param \Google\Cloud\Trace\V2\TruncatableString $var @return $this
[ "A", "user", "-", "supplied", "message", "describing", "the", "event", ".", "The", "maximum", "length", "for", "the", "description", "is", "256", "bytes", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Trace/src/V2/Span/TimeEvent/Annotation.php#L72-L78
train
googleapis/google-cloud-php
Dlp/src/V2/Error.php
Error.setTimestamps
public function setTimestamps($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Timestamp::class); $this->timestamps = $arr; return $this; }
php
public function setTimestamps($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Protobuf\Timestamp::class); $this->timestamps = $arr; return $this; }
[ "public", "function", "setTimestamps", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Protobuf", "\\", "Timestamp", "::", "class", ")", ";", "$", "this", "->", "timestamps", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
The times the error occurred. Generated from protobuf field <code>repeated .google.protobuf.Timestamp timestamps = 2;</code> @param \Google\Protobuf\Timestamp[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "The", "times", "the", "error", "occurred", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/Error.php#L87-L93
train
googleapis/google-cloud-php
Core/src/EmulatorTrait.php
EmulatorTrait.emulatorGapicConfig
private function emulatorGapicConfig($emulatorHost) { // Strip the URL scheme from the input, if it was provided. if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { $search = $scheme . '://'; $emulatorHost = str_replace($search, '', $emulatorHost); } return [ 'serviceAddress' => $emulatorHost, 'transportConfig' => [ 'grpc' => [ 'stubOpts' => [ 'credentials' => \Grpc\ChannelCredentials::createInsecure() ] ] ] ]; }
php
private function emulatorGapicConfig($emulatorHost) { // Strip the URL scheme from the input, if it was provided. if ($scheme = parse_url($emulatorHost, PHP_URL_SCHEME)) { $search = $scheme . '://'; $emulatorHost = str_replace($search, '', $emulatorHost); } return [ 'serviceAddress' => $emulatorHost, 'transportConfig' => [ 'grpc' => [ 'stubOpts' => [ 'credentials' => \Grpc\ChannelCredentials::createInsecure() ] ] ] ]; }
[ "private", "function", "emulatorGapicConfig", "(", "$", "emulatorHost", ")", "{", "// Strip the URL scheme from the input, if it was provided.", "if", "(", "$", "scheme", "=", "parse_url", "(", "$", "emulatorHost", ",", "PHP_URL_SCHEME", ")", ")", "{", "$", "search", "=", "$", "scheme", ".", "'://'", ";", "$", "emulatorHost", "=", "str_replace", "(", "$", "search", ",", "''", ",", "$", "emulatorHost", ")", ";", "}", "return", "[", "'serviceAddress'", "=>", "$", "emulatorHost", ",", "'transportConfig'", "=>", "[", "'grpc'", "=>", "[", "'stubOpts'", "=>", "[", "'credentials'", "=>", "\\", "Grpc", "\\", "ChannelCredentials", "::", "createInsecure", "(", ")", "]", "]", "]", "]", ";", "}" ]
Configure the gapic configuration to use a service emulator. @param string $emulatorHost @return array
[ "Configure", "the", "gapic", "configuration", "to", "use", "a", "service", "emulator", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Core/src/EmulatorTrait.php#L31-L49
train
googleapis/google-cloud-php
Core/src/EmulatorTrait.php
EmulatorTrait.emulatorBaseUri
private function emulatorBaseUri($emulatorHost) { $emulatorUriComponents = parse_url($emulatorHost); $emulatorUriComponents = array_merge(['scheme' => 'http', 'port' => ''], $emulatorUriComponents); $baseUri = "{$emulatorUriComponents['scheme']}://{$emulatorUriComponents['host']}"; $baseUri .= $emulatorUriComponents['port'] ? ":{$emulatorUriComponents['port']}/" : '/'; return $baseUri; }
php
private function emulatorBaseUri($emulatorHost) { $emulatorUriComponents = parse_url($emulatorHost); $emulatorUriComponents = array_merge(['scheme' => 'http', 'port' => ''], $emulatorUriComponents); $baseUri = "{$emulatorUriComponents['scheme']}://{$emulatorUriComponents['host']}"; $baseUri .= $emulatorUriComponents['port'] ? ":{$emulatorUriComponents['port']}/" : '/'; return $baseUri; }
[ "private", "function", "emulatorBaseUri", "(", "$", "emulatorHost", ")", "{", "$", "emulatorUriComponents", "=", "parse_url", "(", "$", "emulatorHost", ")", ";", "$", "emulatorUriComponents", "=", "array_merge", "(", "[", "'scheme'", "=>", "'http'", ",", "'port'", "=>", "''", "]", ",", "$", "emulatorUriComponents", ")", ";", "$", "baseUri", "=", "\"{$emulatorUriComponents['scheme']}://{$emulatorUriComponents['host']}\"", ";", "$", "baseUri", ".=", "$", "emulatorUriComponents", "[", "'port'", "]", "?", "\":{$emulatorUriComponents['port']}/\"", ":", "'/'", ";", "return", "$", "baseUri", ";", "}" ]
Retrieve a valid base uri for a service emulator. @param string $emulatorHost @return string
[ "Retrieve", "a", "valid", "base", "uri", "for", "a", "service", "emulator", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Core/src/EmulatorTrait.php#L56-L64
train
googleapis/google-cloud-php
Core/src/EmulatorTrait.php
EmulatorTrait.getEmulatorBaseUri
public function getEmulatorBaseUri($baseUri, $emulatorHost = null) { if ($emulatorHost) { $baseUri = $this->emulatorBaseUri($emulatorHost); } return $baseUri; }
php
public function getEmulatorBaseUri($baseUri, $emulatorHost = null) { if ($emulatorHost) { $baseUri = $this->emulatorBaseUri($emulatorHost); } return $baseUri; }
[ "public", "function", "getEmulatorBaseUri", "(", "$", "baseUri", ",", "$", "emulatorHost", "=", "null", ")", "{", "if", "(", "$", "emulatorHost", ")", "{", "$", "baseUri", "=", "$", "this", "->", "emulatorBaseUri", "(", "$", "emulatorHost", ")", ";", "}", "return", "$", "baseUri", ";", "}" ]
When emulators are enabled, use them as the service host. This method is deprecated and will be removed in a future major release. @param string $baseUri @param string $emulatorHost [optional] @return string @deprecated @access private
[ "When", "emulators", "are", "enabled", "use", "them", "as", "the", "service", "host", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Core/src/EmulatorTrait.php#L78-L85
train
googleapis/google-cloud-php
OsLogin/src/V1/ImportSshPublicKeyResponse.php
ImportSshPublicKeyResponse.setLoginProfile
public function setLoginProfile($var) { GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1\LoginProfile::class); $this->login_profile = $var; return $this; }
php
public function setLoginProfile($var) { GPBUtil::checkMessage($var, \Google\Cloud\OsLogin\V1\LoginProfile::class); $this->login_profile = $var; return $this; }
[ "public", "function", "setLoginProfile", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "OsLogin", "\\", "V1", "\\", "LoginProfile", "::", "class", ")", ";", "$", "this", "->", "login_profile", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The login profile information for the user. Generated from protobuf field <code>.google.cloud.oslogin.v1.LoginProfile login_profile = 1;</code> @param \Google\Cloud\OsLogin\V1\LoginProfile $var @return $this
[ "The", "login", "profile", "information", "for", "the", "user", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/OsLogin/src/V1/ImportSshPublicKeyResponse.php#L58-L64
train
googleapis/google-cloud-php
Spanner/src/Batch/BatchSnapshot.php
BatchSnapshot.executePartition
public function executePartition(PartitionInterface $partition, array $options = []) { if ($partition instanceof QueryPartition) { return $this->executeQuery($partition); } elseif ($partition instanceof ReadPartition) { return $this->executeRead($partition); } throw new \BadMethodCallException('Unsupported partition type.'); }
php
public function executePartition(PartitionInterface $partition, array $options = []) { if ($partition instanceof QueryPartition) { return $this->executeQuery($partition); } elseif ($partition instanceof ReadPartition) { return $this->executeRead($partition); } throw new \BadMethodCallException('Unsupported partition type.'); }
[ "public", "function", "executePartition", "(", "PartitionInterface", "$", "partition", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "partition", "instanceof", "QueryPartition", ")", "{", "return", "$", "this", "->", "executeQuery", "(", "$", "partition", ")", ";", "}", "elseif", "(", "$", "partition", "instanceof", "ReadPartition", ")", "{", "return", "$", "this", "->", "executeRead", "(", "$", "partition", ")", ";", "}", "throw", "new", "\\", "BadMethodCallException", "(", "'Unsupported partition type.'", ")", ";", "}" ]
Read rows from a partition. Partitions are created by calling {@see Google\Cloud\Spanner\Batch\BatchSnapshot::partitionRead()} or {@see Google\Cloud\Spanner\Batch\BatchSnapshot::partitionQuery()}. Generally, those partitions will be distributed to worker processes, each of which will call this method with the partition it was given. Example: ``` $result = $snapshot->executePartition($partition); ``` @param PartitionInterface $partition The partition to read. @param array $options Configuration Options. @return Result @throws \BadMethodCallException If an invalid partition type is given.
[ "Read", "rows", "from", "a", "partition", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Batch/BatchSnapshot.php#L219-L228
train
googleapis/google-cloud-php
Spanner/src/Batch/BatchSnapshot.php
BatchSnapshot.serialize
public function serialize() { return base64_encode(json_encode([ 'sessionName' => $this->session->name(), 'transactionId' => $this->transactionId, 'readTimestamp' => $this->readTimestamp->formatAsString() ])); }
php
public function serialize() { return base64_encode(json_encode([ 'sessionName' => $this->session->name(), 'transactionId' => $this->transactionId, 'readTimestamp' => $this->readTimestamp->formatAsString() ])); }
[ "public", "function", "serialize", "(", ")", "{", "return", "base64_encode", "(", "json_encode", "(", "[", "'sessionName'", "=>", "$", "this", "->", "session", "->", "name", "(", ")", ",", "'transactionId'", "=>", "$", "this", "->", "transactionId", ",", "'readTimestamp'", "=>", "$", "this", "->", "readTimestamp", "->", "formatAsString", "(", ")", "]", ")", ")", ";", "}" ]
Return a stringified representation of the BatchSnapshot object. Example: ``` $snapshotString = $snapshot->serialize(); ``` @return string
[ "Return", "a", "stringified", "representation", "of", "the", "BatchSnapshot", "object", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Batch/BatchSnapshot.php#L240-L247
train
googleapis/google-cloud-php
Spanner/src/Batch/BatchSnapshot.php
BatchSnapshot.executeQuery
private function executeQuery(QueryPartition $partition) { return $this->execute($partition->sql(), [ 'partitionToken' => $partition->token() ] + $partition->options()); }
php
private function executeQuery(QueryPartition $partition) { return $this->execute($partition->sql(), [ 'partitionToken' => $partition->token() ] + $partition->options()); }
[ "private", "function", "executeQuery", "(", "QueryPartition", "$", "partition", ")", "{", "return", "$", "this", "->", "execute", "(", "$", "partition", "->", "sql", "(", ")", ",", "[", "'partitionToken'", "=>", "$", "partition", "->", "token", "(", ")", "]", "+", "$", "partition", "->", "options", "(", ")", ")", ";", "}" ]
Run executeStreamingSql with a partition. @param QueryPartition $partition The partition. @return Result
[ "Run", "executeStreamingSql", "with", "a", "partition", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Batch/BatchSnapshot.php#L266-L271
train
googleapis/google-cloud-php
Spanner/src/Batch/BatchSnapshot.php
BatchSnapshot.executeRead
private function executeRead(ReadPartition $partition) { return $this->read($partition->table(), $partition->keySet(), $partition->columns(), [ 'partitionToken' => $partition->token() ] + $partition->options()); }
php
private function executeRead(ReadPartition $partition) { return $this->read($partition->table(), $partition->keySet(), $partition->columns(), [ 'partitionToken' => $partition->token() ] + $partition->options()); }
[ "private", "function", "executeRead", "(", "ReadPartition", "$", "partition", ")", "{", "return", "$", "this", "->", "read", "(", "$", "partition", "->", "table", "(", ")", ",", "$", "partition", "->", "keySet", "(", ")", ",", "$", "partition", "->", "columns", "(", ")", ",", "[", "'partitionToken'", "=>", "$", "partition", "->", "token", "(", ")", "]", "+", "$", "partition", "->", "options", "(", ")", ")", ";", "}" ]
Run streamingRead with a partition. @param ReadPartition $partition The partition. @return Result
[ "Run", "streamingRead", "with", "a", "partition", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Spanner/src/Batch/BatchSnapshot.php#L279-L284
train
googleapis/google-cloud-php
Dataproc/src/V1beta2/CreateClusterRequest.php
CreateClusterRequest.setCluster
public function setCluster($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\Cluster::class); $this->cluster = $var; return $this; }
php
public function setCluster($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1beta2\Cluster::class); $this->cluster = $var; return $this; }
[ "public", "function", "setCluster", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dataproc", "\\", "V1beta2", "\\", "Cluster", "::", "class", ")", ";", "$", "this", "->", "cluster", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Required. The cluster to create. Generated from protobuf field <code>.google.cloud.dataproc.v1beta2.Cluster cluster = 2;</code> @param \Google\Cloud\Dataproc\V1beta2\Cluster $var @return $this
[ "Required", ".", "The", "cluster", "to", "create", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1beta2/CreateClusterRequest.php#L156-L162
train
googleapis/google-cloud-php
PubSub/src/V1/UpdateTopicRequest.php
UpdateTopicRequest.setTopic
public function setTopic($var) { GPBUtil::checkMessage($var, \Google\Cloud\PubSub\V1\Topic::class); $this->topic = $var; return $this; }
php
public function setTopic($var) { GPBUtil::checkMessage($var, \Google\Cloud\PubSub\V1\Topic::class); $this->topic = $var; return $this; }
[ "public", "function", "setTopic", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "PubSub", "\\", "V1", "\\", "Topic", "::", "class", ")", ";", "$", "this", "->", "topic", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
The updated topic object. Generated from protobuf field <code>.google.pubsub.v1.Topic topic = 1;</code> @param \Google\Cloud\PubSub\V1\Topic $var @return $this
[ "The", "updated", "topic", "object", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/PubSub/src/V1/UpdateTopicRequest.php#L74-L80
train
googleapis/google-cloud-php
Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php
CloudTasksGapicClient.queueName
public static function queueName($project, $location, $queue) { return self::getQueueNameTemplate()->render([ 'project' => $project, 'location' => $location, 'queue' => $queue, ]); }
php
public static function queueName($project, $location, $queue) { return self::getQueueNameTemplate()->render([ 'project' => $project, 'location' => $location, 'queue' => $queue, ]); }
[ "public", "static", "function", "queueName", "(", "$", "project", ",", "$", "location", ",", "$", "queue", ")", "{", "return", "self", "::", "getQueueNameTemplate", "(", ")", "->", "render", "(", "[", "'project'", "=>", "$", "project", ",", "'location'", "=>", "$", "location", ",", "'queue'", "=>", "$", "queue", ",", "]", ")", ";", "}" ]
Formats a string containing the fully-qualified path to represent a queue resource. @param string $project @param string $location @param string $queue @return string The formatted queue resource. @experimental
[ "Formats", "a", "string", "containing", "the", "fully", "-", "qualified", "path", "to", "represent", "a", "queue", "resource", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php#L259-L266
train
googleapis/google-cloud-php
Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php
CloudTasksGapicClient.taskName
public static function taskName($project, $location, $queue, $task) { return self::getTaskNameTemplate()->render([ 'project' => $project, 'location' => $location, 'queue' => $queue, 'task' => $task, ]); }
php
public static function taskName($project, $location, $queue, $task) { return self::getTaskNameTemplate()->render([ 'project' => $project, 'location' => $location, 'queue' => $queue, 'task' => $task, ]); }
[ "public", "static", "function", "taskName", "(", "$", "project", ",", "$", "location", ",", "$", "queue", ",", "$", "task", ")", "{", "return", "self", "::", "getTaskNameTemplate", "(", ")", "->", "render", "(", "[", "'project'", "=>", "$", "project", ",", "'location'", "=>", "$", "location", ",", "'queue'", "=>", "$", "queue", ",", "'task'", "=>", "$", "task", ",", "]", ")", ";", "}" ]
Formats a string containing the fully-qualified path to represent a task resource. @param string $project @param string $location @param string $queue @param string $task @return string The formatted task resource. @experimental
[ "Formats", "a", "string", "containing", "the", "fully", "-", "qualified", "path", "to", "represent", "a", "task", "resource", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Tasks/src/V2beta2/Gapic/CloudTasksGapicClient.php#L280-L288
train
googleapis/google-cloud-php
Dataproc/src/V1/OrderedJob.php
OrderedJob.setHadoopJob
public function setHadoopJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1\HadoopJob::class); $this->writeOneof(2, $var); return $this; }
php
public function setHadoopJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1\HadoopJob::class); $this->writeOneof(2, $var); return $this; }
[ "public", "function", "setHadoopJob", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dataproc", "\\", "V1", "\\", "HadoopJob", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "2", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Job is a Hadoop job. Generated from protobuf field <code>.google.cloud.dataproc.v1.HadoopJob hadoop_job = 2;</code> @param \Google\Cloud\Dataproc\V1\HadoopJob $var @return $this
[ "Job", "is", "a", "Hadoop", "job", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1/OrderedJob.php#L167-L173
train
googleapis/google-cloud-php
Dataproc/src/V1/OrderedJob.php
OrderedJob.setSparkJob
public function setSparkJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1\SparkJob::class); $this->writeOneof(3, $var); return $this; }
php
public function setSparkJob($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dataproc\V1\SparkJob::class); $this->writeOneof(3, $var); return $this; }
[ "public", "function", "setSparkJob", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dataproc", "\\", "V1", "\\", "SparkJob", "::", "class", ")", ";", "$", "this", "->", "writeOneof", "(", "3", ",", "$", "var", ")", ";", "return", "$", "this", ";", "}" ]
Job is a Spark job. Generated from protobuf field <code>.google.cloud.dataproc.v1.SparkJob spark_job = 3;</code> @param \Google\Cloud\Dataproc\V1\SparkJob $var @return $this
[ "Job", "is", "a", "Spark", "job", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dataproc/src/V1/OrderedJob.php#L193-L199
train
googleapis/google-cloud-php
Dlp/src/V2/BucketingConfig/Bucket.php
Bucket.setMin
public function setMin($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class); $this->min = $var; return $this; }
php
public function setMin($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class); $this->min = $var; return $this; }
[ "public", "function", "setMin", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "Value", "::", "class", ")", ";", "$", "this", "->", "min", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Lower bound of the range, inclusive. Type should be the same as max if used. Generated from protobuf field <code>.google.privacy.dlp.v2.Value min = 1;</code> @param \Google\Cloud\Dlp\V2\Value $var @return $this
[ "Lower", "bound", "of", "the", "range", "inclusive", ".", "Type", "should", "be", "the", "same", "as", "max", "if", "used", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/BucketingConfig/Bucket.php#L80-L86
train
googleapis/google-cloud-php
Dlp/src/V2/BucketingConfig/Bucket.php
Bucket.setMax
public function setMax($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class); $this->max = $var; return $this; }
php
public function setMax($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class); $this->max = $var; return $this; }
[ "public", "function", "setMax", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "Value", "::", "class", ")", ";", "$", "this", "->", "max", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Upper bound of the range, exclusive; type must match min. Generated from protobuf field <code>.google.privacy.dlp.v2.Value max = 2;</code> @param \Google\Cloud\Dlp\V2\Value $var @return $this
[ "Upper", "bound", "of", "the", "range", "exclusive", ";", "type", "must", "match", "min", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/BucketingConfig/Bucket.php#L106-L112
train
googleapis/google-cloud-php
Dlp/src/V2/BucketingConfig/Bucket.php
Bucket.setReplacementValue
public function setReplacementValue($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class); $this->replacement_value = $var; return $this; }
php
public function setReplacementValue($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\Value::class); $this->replacement_value = $var; return $this; }
[ "public", "function", "setReplacementValue", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "Value", "::", "class", ")", ";", "$", "this", "->", "replacement_value", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Replacement value for this bucket. If not provided the default behavior will be to hyphenate the min-max range. Generated from protobuf field <code>.google.privacy.dlp.v2.Value replacement_value = 3;</code> @param \Google\Cloud\Dlp\V2\Value $var @return $this
[ "Replacement", "value", "for", "this", "bucket", ".", "If", "not", "provided", "the", "default", "behavior", "will", "be", "to", "hyphenate", "the", "min", "-", "max", "range", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/BucketingConfig/Bucket.php#L134-L140
train
googleapis/google-cloud-php
Talent/src/V4beta1/DeviceInfo.php
DeviceInfo.setDeviceType
public function setDeviceType($var) { GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\DeviceInfo_DeviceType::class); $this->device_type = $var; return $this; }
php
public function setDeviceType($var) { GPBUtil::checkEnum($var, \Google\Cloud\Talent\V4beta1\DeviceInfo_DeviceType::class); $this->device_type = $var; return $this; }
[ "public", "function", "setDeviceType", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkEnum", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Talent", "\\", "V4beta1", "\\", "DeviceInfo_DeviceType", "::", "class", ")", ";", "$", "this", "->", "device_type", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Optional. Type of the device. Generated from protobuf field <code>.google.cloud.talent.v4beta1.DeviceInfo.DeviceType device_type = 1;</code> @param int $var @return $this
[ "Optional", ".", "Type", "of", "the", "device", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Talent/src/V4beta1/DeviceInfo.php#L76-L82
train
googleapis/google-cloud-php
Bigtable/src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php
BigtableTableAdminGapicClient.snapshotName
public static function snapshotName($project, $instance, $cluster, $snapshot) { return self::getSnapshotNameTemplate()->render([ 'project' => $project, 'instance' => $instance, 'cluster' => $cluster, 'snapshot' => $snapshot, ]); }
php
public static function snapshotName($project, $instance, $cluster, $snapshot) { return self::getSnapshotNameTemplate()->render([ 'project' => $project, 'instance' => $instance, 'cluster' => $cluster, 'snapshot' => $snapshot, ]); }
[ "public", "static", "function", "snapshotName", "(", "$", "project", ",", "$", "instance", ",", "$", "cluster", ",", "$", "snapshot", ")", "{", "return", "self", "::", "getSnapshotNameTemplate", "(", ")", "->", "render", "(", "[", "'project'", "=>", "$", "project", ",", "'instance'", "=>", "$", "instance", ",", "'cluster'", "=>", "$", "cluster", ",", "'snapshot'", "=>", "$", "snapshot", ",", "]", ")", ";", "}" ]
Formats a string containing the fully-qualified path to represent a snapshot resource. @param string $project @param string $instance @param string $cluster @param string $snapshot @return string The formatted snapshot resource. @experimental
[ "Formats", "a", "string", "containing", "the", "fully", "-", "qualified", "path", "to", "represent", "a", "snapshot", "resource", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/Admin/V2/Gapic/BigtableTableAdminGapicClient.php#L259-L267
train
googleapis/google-cloud-php
Dlp/src/V2/InspectDataSourceDetails/RequestedOptions.php
RequestedOptions.setSnapshotInspectTemplate
public function setSnapshotInspectTemplate($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectTemplate::class); $this->snapshot_inspect_template = $var; return $this; }
php
public function setSnapshotInspectTemplate($var) { GPBUtil::checkMessage($var, \Google\Cloud\Dlp\V2\InspectTemplate::class); $this->snapshot_inspect_template = $var; return $this; }
[ "public", "function", "setSnapshotInspectTemplate", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkMessage", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "Dlp", "\\", "V2", "\\", "InspectTemplate", "::", "class", ")", ";", "$", "this", "->", "snapshot_inspect_template", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
If run with an InspectTemplate, a snapshot of its state at the time of this run. Generated from protobuf field <code>.google.privacy.dlp.v2.InspectTemplate snapshot_inspect_template = 1;</code> @param \Google\Cloud\Dlp\V2\InspectTemplate $var @return $this
[ "If", "run", "with", "an", "InspectTemplate", "a", "snapshot", "of", "its", "state", "at", "the", "time", "of", "this", "run", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Dlp/src/V2/InspectDataSourceDetails/RequestedOptions.php#L65-L71
train
googleapis/google-cloud-php
TextToSpeech/src/V1/AudioConfig.php
AudioConfig.setAudioEncoding
public function setAudioEncoding($var) { GPBUtil::checkEnum($var, \Google\Cloud\TextToSpeech\V1\AudioEncoding::class); $this->audio_encoding = $var; return $this; }
php
public function setAudioEncoding($var) { GPBUtil::checkEnum($var, \Google\Cloud\TextToSpeech\V1\AudioEncoding::class); $this->audio_encoding = $var; return $this; }
[ "public", "function", "setAudioEncoding", "(", "$", "var", ")", "{", "GPBUtil", "::", "checkEnum", "(", "$", "var", ",", "\\", "Google", "\\", "Cloud", "\\", "TextToSpeech", "\\", "V1", "\\", "AudioEncoding", "::", "class", ")", ";", "$", "this", "->", "audio_encoding", "=", "$", "var", ";", "return", "$", "this", ";", "}" ]
Required. The format of the requested audio byte stream. Generated from protobuf field <code>.google.cloud.texttospeech.v1.AudioEncoding audio_encoding = 1;</code> @param int $var @return $this
[ "Required", ".", "The", "format", "of", "the", "requested", "audio", "byte", "stream", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/TextToSpeech/src/V1/AudioConfig.php#L144-L150
train
googleapis/google-cloud-php
Bigtable/src/V2/Row.php
Row.setFamilies
public function setFamilies($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\V2\Family::class); $this->families = $arr; return $this; }
php
public function setFamilies($var) { $arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Bigtable\V2\Family::class); $this->families = $arr; return $this; }
[ "public", "function", "setFamilies", "(", "$", "var", ")", "{", "$", "arr", "=", "GPBUtil", "::", "checkRepeatedField", "(", "$", "var", ",", "\\", "Google", "\\", "Protobuf", "\\", "Internal", "\\", "GPBType", "::", "MESSAGE", ",", "\\", "Google", "\\", "Cloud", "\\", "Bigtable", "\\", "V2", "\\", "Family", "::", "class", ")", ";", "$", "this", "->", "families", "=", "$", "arr", ";", "return", "$", "this", ";", "}" ]
May be empty, but only if the entire row is empty. The mutual ordering of column families is not specified. Generated from protobuf field <code>repeated .google.bigtable.v2.Family families = 2;</code> @param \Google\Cloud\Bigtable\V2\Family[]|\Google\Protobuf\Internal\RepeatedField $var @return $this
[ "May", "be", "empty", "but", "only", "if", "the", "entire", "row", "is", "empty", ".", "The", "mutual", "ordering", "of", "column", "families", "is", "not", "specified", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Bigtable/src/V2/Row.php#L105-L111
train
googleapis/google-cloud-php
Core/src/LongRunning/OperationResponseTrait.php
OperationResponseTrait.operationToArray
private function operationToArray($operation, $serializer, array $lroMappers) { $response = $operation->getLastProtoResponse(); if (is_null($response)) { return null; } $response = $serializer->encodeMessage($response); $result = null; if ($operation->isDone()) { $type = $response['metadata']['typeUrl']; $result = $this->deserializeResult($operation, $type, $serializer, $lroMappers); } $error = $operation->getError(); if (!is_null($error)) { $error = $serializer->encodeMessage($error); } $response['response'] = $result; $response['error'] = $error; return $response; }
php
private function operationToArray($operation, $serializer, array $lroMappers) { $response = $operation->getLastProtoResponse(); if (is_null($response)) { return null; } $response = $serializer->encodeMessage($response); $result = null; if ($operation->isDone()) { $type = $response['metadata']['typeUrl']; $result = $this->deserializeResult($operation, $type, $serializer, $lroMappers); } $error = $operation->getError(); if (!is_null($error)) { $error = $serializer->encodeMessage($error); } $response['response'] = $result; $response['error'] = $error; return $response; }
[ "private", "function", "operationToArray", "(", "$", "operation", ",", "$", "serializer", ",", "array", "$", "lroMappers", ")", "{", "$", "response", "=", "$", "operation", "->", "getLastProtoResponse", "(", ")", ";", "if", "(", "is_null", "(", "$", "response", ")", ")", "{", "return", "null", ";", "}", "$", "response", "=", "$", "serializer", "->", "encodeMessage", "(", "$", "response", ")", ";", "$", "result", "=", "null", ";", "if", "(", "$", "operation", "->", "isDone", "(", ")", ")", "{", "$", "type", "=", "$", "response", "[", "'metadata'", "]", "[", "'typeUrl'", "]", ";", "$", "result", "=", "$", "this", "->", "deserializeResult", "(", "$", "operation", ",", "$", "type", ",", "$", "serializer", ",", "$", "lroMappers", ")", ";", "}", "$", "error", "=", "$", "operation", "->", "getError", "(", ")", ";", "if", "(", "!", "is_null", "(", "$", "error", ")", ")", "{", "$", "error", "=", "$", "serializer", "->", "encodeMessage", "(", "$", "error", ")", ";", "}", "$", "response", "[", "'response'", "]", "=", "$", "result", ";", "$", "response", "[", "'error'", "]", "=", "$", "error", ";", "return", "$", "response", ";", "}" ]
Convert a ApiCore OperationResponse object to an array. @param OperationResponse|GaxOperationResponse $operation The operation response @param Serializer|GaxSerializer $serializer The serializer to use for gRPC serialization/deserialization. @param array $lroMappers A list of mappers for deserializing operation results. @return array
[ "Convert", "a", "ApiCore", "OperationResponse", "object", "to", "an", "array", "." ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Core/src/LongRunning/OperationResponseTrait.php#L40-L64
train
googleapis/google-cloud-php
Core/src/LongRunning/OperationResponseTrait.php
OperationResponseTrait.deserializeResult
private function deserializeResult($operation, $type, $serializer, array $mappers) { $mappers = array_filter($mappers, function ($mapper) use ($type) { return $mapper['typeUrl'] === $type; }); if (count($mappers) === 0) { throw new \RuntimeException(sprintf('No mapper exists for operation response type %s.', $type)); } $mapper = current($mappers); $message = $mapper['message']; $response = new $message(); $anyResponse = $operation->getLastProtoResponse()->getResponse(); if (is_null($anyResponse)) { return null; } $response->mergeFromString($anyResponse->getValue()); return $serializer->encodeMessage($response); }
php
private function deserializeResult($operation, $type, $serializer, array $mappers) { $mappers = array_filter($mappers, function ($mapper) use ($type) { return $mapper['typeUrl'] === $type; }); if (count($mappers) === 0) { throw new \RuntimeException(sprintf('No mapper exists for operation response type %s.', $type)); } $mapper = current($mappers); $message = $mapper['message']; $response = new $message(); $anyResponse = $operation->getLastProtoResponse()->getResponse(); if (is_null($anyResponse)) { return null; } $response->mergeFromString($anyResponse->getValue()); return $serializer->encodeMessage($response); }
[ "private", "function", "deserializeResult", "(", "$", "operation", ",", "$", "type", ",", "$", "serializer", ",", "array", "$", "mappers", ")", "{", "$", "mappers", "=", "array_filter", "(", "$", "mappers", ",", "function", "(", "$", "mapper", ")", "use", "(", "$", "type", ")", "{", "return", "$", "mapper", "[", "'typeUrl'", "]", "===", "$", "type", ";", "}", ")", ";", "if", "(", "count", "(", "$", "mappers", ")", "===", "0", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'No mapper exists for operation response type %s.'", ",", "$", "type", ")", ")", ";", "}", "$", "mapper", "=", "current", "(", "$", "mappers", ")", ";", "$", "message", "=", "$", "mapper", "[", "'message'", "]", ";", "$", "response", "=", "new", "$", "message", "(", ")", ";", "$", "anyResponse", "=", "$", "operation", "->", "getLastProtoResponse", "(", ")", "->", "getResponse", "(", ")", ";", "if", "(", "is_null", "(", "$", "anyResponse", ")", ")", "{", "return", "null", ";", "}", "$", "response", "->", "mergeFromString", "(", "$", "anyResponse", "->", "getValue", "(", ")", ")", ";", "return", "$", "serializer", "->", "encodeMessage", "(", "$", "response", ")", ";", "}" ]
Convert an operation response to an array @param OperationResponse|GaxOperationResponse $operation The operation to serialize. @param string $type The Operation type. The type should correspond to a member of $mappers.typeUrl. @param Serializer|GaxSerializer $serializer The gRPC serializer to use for the deserialization. @param array $mappers A list of mappers. @return array|null
[ "Convert", "an", "operation", "response", "to", "an", "array" ]
ff5030ffa1f12904565509a7bc24ecc0bd794a3e
https://github.com/googleapis/google-cloud-php/blob/ff5030ffa1f12904565509a7bc24ecc0bd794a3e/Core/src/LongRunning/OperationResponseTrait.php#L91-L114
train
google/recaptcha
src/ReCaptcha/RequestMethod/CurlPost.php
CurlPost.submit
public function submit(RequestParameters $params) { $handle = $this->curl->init($this->siteVerifyUrl); $options = array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $params->toQueryString(), CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded' ), CURLINFO_HEADER_OUT => false, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => true ); $this->curl->setoptArray($handle, $options); $response = $this->curl->exec($handle); $this->curl->close($handle); if ($response !== false) { return $response; } return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}'; }
php
public function submit(RequestParameters $params) { $handle = $this->curl->init($this->siteVerifyUrl); $options = array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => $params->toQueryString(), CURLOPT_HTTPHEADER => array( 'Content-Type: application/x-www-form-urlencoded' ), CURLINFO_HEADER_OUT => false, CURLOPT_HEADER => false, CURLOPT_RETURNTRANSFER => true, CURLOPT_SSL_VERIFYPEER => true ); $this->curl->setoptArray($handle, $options); $response = $this->curl->exec($handle); $this->curl->close($handle); if ($response !== false) { return $response; } return '{"success": false, "error-codes": ["'.ReCaptcha::E_CONNECTION_FAILED.'"]}'; }
[ "public", "function", "submit", "(", "RequestParameters", "$", "params", ")", "{", "$", "handle", "=", "$", "this", "->", "curl", "->", "init", "(", "$", "this", "->", "siteVerifyUrl", ")", ";", "$", "options", "=", "array", "(", "CURLOPT_POST", "=>", "true", ",", "CURLOPT_POSTFIELDS", "=>", "$", "params", "->", "toQueryString", "(", ")", ",", "CURLOPT_HTTPHEADER", "=>", "array", "(", "'Content-Type: application/x-www-form-urlencoded'", ")", ",", "CURLINFO_HEADER_OUT", "=>", "false", ",", "CURLOPT_HEADER", "=>", "false", ",", "CURLOPT_RETURNTRANSFER", "=>", "true", ",", "CURLOPT_SSL_VERIFYPEER", "=>", "true", ")", ";", "$", "this", "->", "curl", "->", "setoptArray", "(", "$", "handle", ",", "$", "options", ")", ";", "$", "response", "=", "$", "this", "->", "curl", "->", "exec", "(", "$", "handle", ")", ";", "$", "this", "->", "curl", "->", "close", "(", "$", "handle", ")", ";", "if", "(", "$", "response", "!==", "false", ")", "{", "return", "$", "response", ";", "}", "return", "'{\"success\": false, \"error-codes\": [\"'", ".", "ReCaptcha", "::", "E_CONNECTION_FAILED", ".", "'\"]}'", ";", "}" ]
Submit the cURL request with the specified parameters. @param RequestParameters $params Request parameters @return string Body of the reCAPTCHA response
[ "Submit", "the", "cURL", "request", "with", "the", "specified", "parameters", "." ]
9c17232e45d02e864e94bbc80d1dd346f1f7105e
https://github.com/google/recaptcha/blob/9c17232e45d02e864e94bbc80d1dd346f1f7105e/src/ReCaptcha/RequestMethod/CurlPost.php#L70-L95
train
google/recaptcha
src/ReCaptcha/ReCaptcha.php
ReCaptcha.verify
public function verify($response, $remoteIp = null) { // Discard empty solution submissions if (empty($response)) { $recaptchaResponse = new Response(false, array(self::E_MISSING_INPUT_RESPONSE)); return $recaptchaResponse; } $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); $rawResponse = $this->requestMethod->submit($params); $initialResponse = Response::fromJson($rawResponse); $validationErrors = array(); if (isset($this->hostname) && strcasecmp($this->hostname, $initialResponse->getHostname()) !== 0) { $validationErrors[] = self::E_HOSTNAME_MISMATCH; } if (isset($this->apkPackageName) && strcasecmp($this->apkPackageName, $initialResponse->getApkPackageName()) !== 0) { $validationErrors[] = self::E_APK_PACKAGE_NAME_MISMATCH; } if (isset($this->action) && strcasecmp($this->action, $initialResponse->getAction()) !== 0) { $validationErrors[] = self::E_ACTION_MISMATCH; } if (isset($this->threshold) && $this->threshold > $initialResponse->getScore()) { $validationErrors[] = self::E_SCORE_THRESHOLD_NOT_MET; } if (isset($this->timeoutSeconds)) { $challengeTs = strtotime($initialResponse->getChallengeTs()); if ($challengeTs > 0 && time() - $challengeTs > $this->timeoutSeconds) { $validationErrors[] = self::E_CHALLENGE_TIMEOUT; } } if (empty($validationErrors)) { return $initialResponse; } return new Response( false, array_merge($initialResponse->getErrorCodes(), $validationErrors), $initialResponse->getHostname(), $initialResponse->getChallengeTs(), $initialResponse->getApkPackageName(), $initialResponse->getScore(), $initialResponse->getAction() ); }
php
public function verify($response, $remoteIp = null) { // Discard empty solution submissions if (empty($response)) { $recaptchaResponse = new Response(false, array(self::E_MISSING_INPUT_RESPONSE)); return $recaptchaResponse; } $params = new RequestParameters($this->secret, $response, $remoteIp, self::VERSION); $rawResponse = $this->requestMethod->submit($params); $initialResponse = Response::fromJson($rawResponse); $validationErrors = array(); if (isset($this->hostname) && strcasecmp($this->hostname, $initialResponse->getHostname()) !== 0) { $validationErrors[] = self::E_HOSTNAME_MISMATCH; } if (isset($this->apkPackageName) && strcasecmp($this->apkPackageName, $initialResponse->getApkPackageName()) !== 0) { $validationErrors[] = self::E_APK_PACKAGE_NAME_MISMATCH; } if (isset($this->action) && strcasecmp($this->action, $initialResponse->getAction()) !== 0) { $validationErrors[] = self::E_ACTION_MISMATCH; } if (isset($this->threshold) && $this->threshold > $initialResponse->getScore()) { $validationErrors[] = self::E_SCORE_THRESHOLD_NOT_MET; } if (isset($this->timeoutSeconds)) { $challengeTs = strtotime($initialResponse->getChallengeTs()); if ($challengeTs > 0 && time() - $challengeTs > $this->timeoutSeconds) { $validationErrors[] = self::E_CHALLENGE_TIMEOUT; } } if (empty($validationErrors)) { return $initialResponse; } return new Response( false, array_merge($initialResponse->getErrorCodes(), $validationErrors), $initialResponse->getHostname(), $initialResponse->getChallengeTs(), $initialResponse->getApkPackageName(), $initialResponse->getScore(), $initialResponse->getAction() ); }
[ "public", "function", "verify", "(", "$", "response", ",", "$", "remoteIp", "=", "null", ")", "{", "// Discard empty solution submissions", "if", "(", "empty", "(", "$", "response", ")", ")", "{", "$", "recaptchaResponse", "=", "new", "Response", "(", "false", ",", "array", "(", "self", "::", "E_MISSING_INPUT_RESPONSE", ")", ")", ";", "return", "$", "recaptchaResponse", ";", "}", "$", "params", "=", "new", "RequestParameters", "(", "$", "this", "->", "secret", ",", "$", "response", ",", "$", "remoteIp", ",", "self", "::", "VERSION", ")", ";", "$", "rawResponse", "=", "$", "this", "->", "requestMethod", "->", "submit", "(", "$", "params", ")", ";", "$", "initialResponse", "=", "Response", "::", "fromJson", "(", "$", "rawResponse", ")", ";", "$", "validationErrors", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "hostname", ")", "&&", "strcasecmp", "(", "$", "this", "->", "hostname", ",", "$", "initialResponse", "->", "getHostname", "(", ")", ")", "!==", "0", ")", "{", "$", "validationErrors", "[", "]", "=", "self", "::", "E_HOSTNAME_MISMATCH", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "apkPackageName", ")", "&&", "strcasecmp", "(", "$", "this", "->", "apkPackageName", ",", "$", "initialResponse", "->", "getApkPackageName", "(", ")", ")", "!==", "0", ")", "{", "$", "validationErrors", "[", "]", "=", "self", "::", "E_APK_PACKAGE_NAME_MISMATCH", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "action", ")", "&&", "strcasecmp", "(", "$", "this", "->", "action", ",", "$", "initialResponse", "->", "getAction", "(", ")", ")", "!==", "0", ")", "{", "$", "validationErrors", "[", "]", "=", "self", "::", "E_ACTION_MISMATCH", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "threshold", ")", "&&", "$", "this", "->", "threshold", ">", "$", "initialResponse", "->", "getScore", "(", ")", ")", "{", "$", "validationErrors", "[", "]", "=", "self", "::", "E_SCORE_THRESHOLD_NOT_MET", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "timeoutSeconds", ")", ")", "{", "$", "challengeTs", "=", "strtotime", "(", "$", "initialResponse", "->", "getChallengeTs", "(", ")", ")", ";", "if", "(", "$", "challengeTs", ">", "0", "&&", "time", "(", ")", "-", "$", "challengeTs", ">", "$", "this", "->", "timeoutSeconds", ")", "{", "$", "validationErrors", "[", "]", "=", "self", "::", "E_CHALLENGE_TIMEOUT", ";", "}", "}", "if", "(", "empty", "(", "$", "validationErrors", ")", ")", "{", "return", "$", "initialResponse", ";", "}", "return", "new", "Response", "(", "false", ",", "array_merge", "(", "$", "initialResponse", "->", "getErrorCodes", "(", ")", ",", "$", "validationErrors", ")", ",", "$", "initialResponse", "->", "getHostname", "(", ")", ",", "$", "initialResponse", "->", "getChallengeTs", "(", ")", ",", "$", "initialResponse", "->", "getApkPackageName", "(", ")", ",", "$", "initialResponse", "->", "getScore", "(", ")", ",", "$", "initialResponse", "->", "getAction", "(", ")", ")", ";", "}" ]
Calls the reCAPTCHA siteverify API to verify whether the user passes CAPTCHA test and additionally runs any specified additional checks @param string $response The user response token provided by reCAPTCHA, verifying the user on your site. @param string $remoteIp The end user's IP address. @return Response Response from the service.
[ "Calls", "the", "reCAPTCHA", "siteverify", "API", "to", "verify", "whether", "the", "user", "passes", "CAPTCHA", "test", "and", "additionally", "runs", "any", "specified", "additional", "checks" ]
9c17232e45d02e864e94bbc80d1dd346f1f7105e
https://github.com/google/recaptcha/blob/9c17232e45d02e864e94bbc80d1dd346f1f7105e/src/ReCaptcha/ReCaptcha.php#L147-L197
train
laravel/homestead
src/MakeCommand.php
MakeCommand.createSettingsFile
protected function createSettingsFile($format, $options) { $SettingsClass = ($format === 'json') ? JsonSettings::class : YamlSettings::class; $filename = $this->exampleSettingsExists($format) ? "{$this->basePath}/Homestead.{$format}.example" : __DIR__."/../resources/Homestead.{$format}"; $settings = $SettingsClass::fromFile($filename); if (! $this->exampleSettingsExists($format)) { $settings->updateName($options['name']) ->updateHostname($options['hostname']); } $settings->updateIpAddress($options['ip']) ->configureSites($this->projectName, $this->defaultProjectName) ->configureSharedFolders($this->basePath, $this->defaultProjectName) ->save("{$this->basePath}/Homestead.{$format}"); }
php
protected function createSettingsFile($format, $options) { $SettingsClass = ($format === 'json') ? JsonSettings::class : YamlSettings::class; $filename = $this->exampleSettingsExists($format) ? "{$this->basePath}/Homestead.{$format}.example" : __DIR__."/../resources/Homestead.{$format}"; $settings = $SettingsClass::fromFile($filename); if (! $this->exampleSettingsExists($format)) { $settings->updateName($options['name']) ->updateHostname($options['hostname']); } $settings->updateIpAddress($options['ip']) ->configureSites($this->projectName, $this->defaultProjectName) ->configureSharedFolders($this->basePath, $this->defaultProjectName) ->save("{$this->basePath}/Homestead.{$format}"); }
[ "protected", "function", "createSettingsFile", "(", "$", "format", ",", "$", "options", ")", "{", "$", "SettingsClass", "=", "(", "$", "format", "===", "'json'", ")", "?", "JsonSettings", "::", "class", ":", "YamlSettings", "::", "class", ";", "$", "filename", "=", "$", "this", "->", "exampleSettingsExists", "(", "$", "format", ")", "?", "\"{$this->basePath}/Homestead.{$format}.example\"", ":", "__DIR__", ".", "\"/../resources/Homestead.{$format}\"", ";", "$", "settings", "=", "$", "SettingsClass", "::", "fromFile", "(", "$", "filename", ")", ";", "if", "(", "!", "$", "this", "->", "exampleSettingsExists", "(", "$", "format", ")", ")", "{", "$", "settings", "->", "updateName", "(", "$", "options", "[", "'name'", "]", ")", "->", "updateHostname", "(", "$", "options", "[", "'hostname'", "]", ")", ";", "}", "$", "settings", "->", "updateIpAddress", "(", "$", "options", "[", "'ip'", "]", ")", "->", "configureSites", "(", "$", "this", "->", "projectName", ",", "$", "this", "->", "defaultProjectName", ")", "->", "configureSharedFolders", "(", "$", "this", "->", "basePath", ",", "$", "this", "->", "defaultProjectName", ")", "->", "save", "(", "\"{$this->basePath}/Homestead.{$format}\"", ")", ";", "}" ]
Create the homestead settings file. @param string $format @param array $options @return void
[ "Create", "the", "homestead", "settings", "file", "." ]
0c7622a3e2bfe442b8062b3150550fd136f76857
https://github.com/laravel/homestead/blob/0c7622a3e2bfe442b8062b3150550fd136f76857/src/MakeCommand.php#L193-L212
train
laravel/homestead
src/Settings/HomesteadSettings.php
HomesteadSettings.update
public function update($attributes) { $this->attributes = array_merge($this->attributes, array_filter($attributes, function ($attribute) { return ! is_null($attribute); })); return $this; }
php
public function update($attributes) { $this->attributes = array_merge($this->attributes, array_filter($attributes, function ($attribute) { return ! is_null($attribute); })); return $this; }
[ "public", "function", "update", "(", "$", "attributes", ")", "{", "$", "this", "->", "attributes", "=", "array_merge", "(", "$", "this", "->", "attributes", ",", "array_filter", "(", "$", "attributes", ",", "function", "(", "$", "attribute", ")", "{", "return", "!", "is_null", "(", "$", "attribute", ")", ";", "}", ")", ")", ";", "return", "$", "this", ";", "}" ]
Update the homestead settings. @param array $attributes @return static
[ "Update", "the", "homestead", "settings", "." ]
0c7622a3e2bfe442b8062b3150550fd136f76857
https://github.com/laravel/homestead/blob/0c7622a3e2bfe442b8062b3150550fd136f76857/src/Settings/HomesteadSettings.php#L46-L53
train
laravel/homestead
src/Settings/HomesteadSettings.php
HomesteadSettings.configureSites
public function configureSites($projectName, $projectDirectory) { $sites = [ [ 'map' => "{$projectName}.test", 'to' => "/home/vagrant/{$projectDirectory}/public", ], ]; if (isset($this->attributes['sites']) && ! empty($this->attributes['sites'])) { foreach ($this->attributes['sites'] as $index => $user_site) { if (isset($user_site['map'])) { $sites[$index]['map'] = $user_site['map']; } if (isset($user_site['to'])) { $sites[$index]['to'] = $user_site['to']; } if (isset($user_site['type'])) { $sites[$index]['type'] = $user_site['type']; } if (isset($user_site['schedule'])) { $sites[$index]['schedule'] = $user_site['schedule']; } if (isset($user_site['php'])) { $sites[$index]['php'] = $user_site['php']; } if (isset($user_site['xhgui'])) { $sites[$index]['xhgui'] = $user_site['xhgui']; } } } $this->update(['sites' => $sites]); return $this; }
php
public function configureSites($projectName, $projectDirectory) { $sites = [ [ 'map' => "{$projectName}.test", 'to' => "/home/vagrant/{$projectDirectory}/public", ], ]; if (isset($this->attributes['sites']) && ! empty($this->attributes['sites'])) { foreach ($this->attributes['sites'] as $index => $user_site) { if (isset($user_site['map'])) { $sites[$index]['map'] = $user_site['map']; } if (isset($user_site['to'])) { $sites[$index]['to'] = $user_site['to']; } if (isset($user_site['type'])) { $sites[$index]['type'] = $user_site['type']; } if (isset($user_site['schedule'])) { $sites[$index]['schedule'] = $user_site['schedule']; } if (isset($user_site['php'])) { $sites[$index]['php'] = $user_site['php']; } if (isset($user_site['xhgui'])) { $sites[$index]['xhgui'] = $user_site['xhgui']; } } } $this->update(['sites' => $sites]); return $this; }
[ "public", "function", "configureSites", "(", "$", "projectName", ",", "$", "projectDirectory", ")", "{", "$", "sites", "=", "[", "[", "'map'", "=>", "\"{$projectName}.test\"", ",", "'to'", "=>", "\"/home/vagrant/{$projectDirectory}/public\"", ",", "]", ",", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "'sites'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "attributes", "[", "'sites'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "[", "'sites'", "]", "as", "$", "index", "=>", "$", "user_site", ")", "{", "if", "(", "isset", "(", "$", "user_site", "[", "'map'", "]", ")", ")", "{", "$", "sites", "[", "$", "index", "]", "[", "'map'", "]", "=", "$", "user_site", "[", "'map'", "]", ";", "}", "if", "(", "isset", "(", "$", "user_site", "[", "'to'", "]", ")", ")", "{", "$", "sites", "[", "$", "index", "]", "[", "'to'", "]", "=", "$", "user_site", "[", "'to'", "]", ";", "}", "if", "(", "isset", "(", "$", "user_site", "[", "'type'", "]", ")", ")", "{", "$", "sites", "[", "$", "index", "]", "[", "'type'", "]", "=", "$", "user_site", "[", "'type'", "]", ";", "}", "if", "(", "isset", "(", "$", "user_site", "[", "'schedule'", "]", ")", ")", "{", "$", "sites", "[", "$", "index", "]", "[", "'schedule'", "]", "=", "$", "user_site", "[", "'schedule'", "]", ";", "}", "if", "(", "isset", "(", "$", "user_site", "[", "'php'", "]", ")", ")", "{", "$", "sites", "[", "$", "index", "]", "[", "'php'", "]", "=", "$", "user_site", "[", "'php'", "]", ";", "}", "if", "(", "isset", "(", "$", "user_site", "[", "'xhgui'", "]", ")", ")", "{", "$", "sites", "[", "$", "index", "]", "[", "'xhgui'", "]", "=", "$", "user_site", "[", "'xhgui'", "]", ";", "}", "}", "}", "$", "this", "->", "update", "(", "[", "'sites'", "=>", "$", "sites", "]", ")", ";", "return", "$", "this", ";", "}" ]
Configure the nginx sites. @param string $projectName @param string $projectDirectory @return static
[ "Configure", "the", "nginx", "sites", "." ]
0c7622a3e2bfe442b8062b3150550fd136f76857
https://github.com/laravel/homestead/blob/0c7622a3e2bfe442b8062b3150550fd136f76857/src/Settings/HomesteadSettings.php#L101-L141
train
laravel/homestead
src/Settings/HomesteadSettings.php
HomesteadSettings.configureSharedFolders
public function configureSharedFolders($projectPath, $projectDirectory) { $folders = [ [ 'map' => $projectPath, 'to' => "/home/vagrant/{$projectDirectory}", ], ]; if (isset($this->attributes['folders']) && ! empty($this->attributes['folders'])) { foreach ($this->attributes['folders'] as $index => $user_folder) { if (isset($user_folder['map']) && empty($folders[$index]['map'])) { $folders[$index]['map'] = dirname($projectPath).'/'.basename($user_folder['map']); } if (isset($user_folder['to'])) { $folders[$index]['to'] = $user_folder['to']; } if (isset($user_folder['type'])) { $folders[$index]['type'] = $user_folder['type']; } } } $this->update(['folders' => $folders]); return $this; }
php
public function configureSharedFolders($projectPath, $projectDirectory) { $folders = [ [ 'map' => $projectPath, 'to' => "/home/vagrant/{$projectDirectory}", ], ]; if (isset($this->attributes['folders']) && ! empty($this->attributes['folders'])) { foreach ($this->attributes['folders'] as $index => $user_folder) { if (isset($user_folder['map']) && empty($folders[$index]['map'])) { $folders[$index]['map'] = dirname($projectPath).'/'.basename($user_folder['map']); } if (isset($user_folder['to'])) { $folders[$index]['to'] = $user_folder['to']; } if (isset($user_folder['type'])) { $folders[$index]['type'] = $user_folder['type']; } } } $this->update(['folders' => $folders]); return $this; }
[ "public", "function", "configureSharedFolders", "(", "$", "projectPath", ",", "$", "projectDirectory", ")", "{", "$", "folders", "=", "[", "[", "'map'", "=>", "$", "projectPath", ",", "'to'", "=>", "\"/home/vagrant/{$projectDirectory}\"", ",", "]", ",", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "'folders'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "attributes", "[", "'folders'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "[", "'folders'", "]", "as", "$", "index", "=>", "$", "user_folder", ")", "{", "if", "(", "isset", "(", "$", "user_folder", "[", "'map'", "]", ")", "&&", "empty", "(", "$", "folders", "[", "$", "index", "]", "[", "'map'", "]", ")", ")", "{", "$", "folders", "[", "$", "index", "]", "[", "'map'", "]", "=", "dirname", "(", "$", "projectPath", ")", ".", "'/'", ".", "basename", "(", "$", "user_folder", "[", "'map'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "user_folder", "[", "'to'", "]", ")", ")", "{", "$", "folders", "[", "$", "index", "]", "[", "'to'", "]", "=", "$", "user_folder", "[", "'to'", "]", ";", "}", "if", "(", "isset", "(", "$", "user_folder", "[", "'type'", "]", ")", ")", "{", "$", "folders", "[", "$", "index", "]", "[", "'type'", "]", "=", "$", "user_folder", "[", "'type'", "]", ";", "}", "}", "}", "$", "this", "->", "update", "(", "[", "'folders'", "=>", "$", "folders", "]", ")", ";", "return", "$", "this", ";", "}" ]
Configure the shared folders. @param string $projectPath @param string $projectDirectory @return static
[ "Configure", "the", "shared", "folders", "." ]
0c7622a3e2bfe442b8062b3150550fd136f76857
https://github.com/laravel/homestead/blob/0c7622a3e2bfe442b8062b3150550fd136f76857/src/Settings/HomesteadSettings.php#L150-L178
train
zircote/swagger-php
src/Annotations/AbstractAnnotation.php
AbstractAnnotation.mergeProperties
public function mergeProperties($object) { $defaultValues = get_class_vars(get_class($this)); $currentValues = get_object_vars($this); foreach ($object as $property => $value) { if ($property === '_context') { continue; } if ($currentValues[$property] === $defaultValues[$property]) { // Overwrite default values $this->$property = $value; continue; } if ($property === '_unmerged') { $this->_unmerged = array_merge($this->_unmerged, $value); continue; } if ($currentValues[$property] !== $value) { // New value is not the same? if ($defaultValues[$property] === $value) { // but is the same as the default? continue; // Keep current, no notice } $identity = method_exists($object, 'identity') ? $object->identity() : get_class($object); $context1 = $this->_context; $context2 = property_exists($object, '_context') ? $object->_context : 'unknown'; if (is_object($this->$property) && $this->$property instanceof AbstractAnnotation) { $context1 = $this->$property->_context; } Logger::warning('Multiple definitions for ' . $identity . '->' . $property . "\n Using: " . $context1 . "\n Skipping: " . $context2); } } }
php
public function mergeProperties($object) { $defaultValues = get_class_vars(get_class($this)); $currentValues = get_object_vars($this); foreach ($object as $property => $value) { if ($property === '_context') { continue; } if ($currentValues[$property] === $defaultValues[$property]) { // Overwrite default values $this->$property = $value; continue; } if ($property === '_unmerged') { $this->_unmerged = array_merge($this->_unmerged, $value); continue; } if ($currentValues[$property] !== $value) { // New value is not the same? if ($defaultValues[$property] === $value) { // but is the same as the default? continue; // Keep current, no notice } $identity = method_exists($object, 'identity') ? $object->identity() : get_class($object); $context1 = $this->_context; $context2 = property_exists($object, '_context') ? $object->_context : 'unknown'; if (is_object($this->$property) && $this->$property instanceof AbstractAnnotation) { $context1 = $this->$property->_context; } Logger::warning('Multiple definitions for ' . $identity . '->' . $property . "\n Using: " . $context1 . "\n Skipping: " . $context2); } } }
[ "public", "function", "mergeProperties", "(", "$", "object", ")", "{", "$", "defaultValues", "=", "get_class_vars", "(", "get_class", "(", "$", "this", ")", ")", ";", "$", "currentValues", "=", "get_object_vars", "(", "$", "this", ")", ";", "foreach", "(", "$", "object", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "$", "property", "===", "'_context'", ")", "{", "continue", ";", "}", "if", "(", "$", "currentValues", "[", "$", "property", "]", "===", "$", "defaultValues", "[", "$", "property", "]", ")", "{", "// Overwrite default values", "$", "this", "->", "$", "property", "=", "$", "value", ";", "continue", ";", "}", "if", "(", "$", "property", "===", "'_unmerged'", ")", "{", "$", "this", "->", "_unmerged", "=", "array_merge", "(", "$", "this", "->", "_unmerged", ",", "$", "value", ")", ";", "continue", ";", "}", "if", "(", "$", "currentValues", "[", "$", "property", "]", "!==", "$", "value", ")", "{", "// New value is not the same?", "if", "(", "$", "defaultValues", "[", "$", "property", "]", "===", "$", "value", ")", "{", "// but is the same as the default?", "continue", ";", "// Keep current, no notice", "}", "$", "identity", "=", "method_exists", "(", "$", "object", ",", "'identity'", ")", "?", "$", "object", "->", "identity", "(", ")", ":", "get_class", "(", "$", "object", ")", ";", "$", "context1", "=", "$", "this", "->", "_context", ";", "$", "context2", "=", "property_exists", "(", "$", "object", ",", "'_context'", ")", "?", "$", "object", "->", "_context", ":", "'unknown'", ";", "if", "(", "is_object", "(", "$", "this", "->", "$", "property", ")", "&&", "$", "this", "->", "$", "property", "instanceof", "AbstractAnnotation", ")", "{", "$", "context1", "=", "$", "this", "->", "$", "property", "->", "_context", ";", "}", "Logger", "::", "warning", "(", "'Multiple definitions for '", ".", "$", "identity", ".", "'->'", ".", "$", "property", ".", "\"\\n Using: \"", ".", "$", "context1", ".", "\"\\n Skipping: \"", ".", "$", "context2", ")", ";", "}", "}", "}" ]
Merge the properties from the given object into this annotation. Prevents overwriting properties that are already configured. @param object $object
[ "Merge", "the", "properties", "from", "the", "given", "object", "into", "this", "annotation", ".", "Prevents", "overwriting", "properties", "that", "are", "already", "configured", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Annotations/AbstractAnnotation.php#L200-L229
train
zircote/swagger-php
src/Annotations/AbstractAnnotation.php
AbstractAnnotation._validate
private static function _validate($fields, $parents, $skip, $baseRef) { $valid = true; $blacklist = []; if (is_object($fields)) { if (in_array($fields, $skip, true)) { return true; } $skip[] = $fields; $blacklist = property_exists($fields, '_blacklist') ? $fields::$_blacklist : []; } foreach ($fields as $field => $value) { if ($value === null || is_scalar($value) || in_array($field, $blacklist)) { continue; } $ref = $baseRef !== '' ? $baseRef.'/'.urlencode((string)$field) : urlencode((string)$field); if (is_object($value)) { if (method_exists($value, 'validate')) { if (!$value->validate($parents, $skip, $ref)) { $valid = false; } } elseif (!self::_validate($value, $parents, $skip, $ref)) { $valid = false; } } elseif (is_array($value) && !self::_validate($value, $parents, $skip, $ref)) { $valid = false; } } return $valid; }
php
private static function _validate($fields, $parents, $skip, $baseRef) { $valid = true; $blacklist = []; if (is_object($fields)) { if (in_array($fields, $skip, true)) { return true; } $skip[] = $fields; $blacklist = property_exists($fields, '_blacklist') ? $fields::$_blacklist : []; } foreach ($fields as $field => $value) { if ($value === null || is_scalar($value) || in_array($field, $blacklist)) { continue; } $ref = $baseRef !== '' ? $baseRef.'/'.urlencode((string)$field) : urlencode((string)$field); if (is_object($value)) { if (method_exists($value, 'validate')) { if (!$value->validate($parents, $skip, $ref)) { $valid = false; } } elseif (!self::_validate($value, $parents, $skip, $ref)) { $valid = false; } } elseif (is_array($value) && !self::_validate($value, $parents, $skip, $ref)) { $valid = false; } } return $valid; }
[ "private", "static", "function", "_validate", "(", "$", "fields", ",", "$", "parents", ",", "$", "skip", ",", "$", "baseRef", ")", "{", "$", "valid", "=", "true", ";", "$", "blacklist", "=", "[", "]", ";", "if", "(", "is_object", "(", "$", "fields", ")", ")", "{", "if", "(", "in_array", "(", "$", "fields", ",", "$", "skip", ",", "true", ")", ")", "{", "return", "true", ";", "}", "$", "skip", "[", "]", "=", "$", "fields", ";", "$", "blacklist", "=", "property_exists", "(", "$", "fields", ",", "'_blacklist'", ")", "?", "$", "fields", "::", "$", "_blacklist", ":", "[", "]", ";", "}", "foreach", "(", "$", "fields", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", "||", "is_scalar", "(", "$", "value", ")", "||", "in_array", "(", "$", "field", ",", "$", "blacklist", ")", ")", "{", "continue", ";", "}", "$", "ref", "=", "$", "baseRef", "!==", "''", "?", "$", "baseRef", ".", "'/'", ".", "urlencode", "(", "(", "string", ")", "$", "field", ")", ":", "urlencode", "(", "(", "string", ")", "$", "field", ")", ";", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "method_exists", "(", "$", "value", ",", "'validate'", ")", ")", "{", "if", "(", "!", "$", "value", "->", "validate", "(", "$", "parents", ",", "$", "skip", ",", "$", "ref", ")", ")", "{", "$", "valid", "=", "false", ";", "}", "}", "elseif", "(", "!", "self", "::", "_validate", "(", "$", "value", ",", "$", "parents", ",", "$", "skip", ",", "$", "ref", ")", ")", "{", "$", "valid", "=", "false", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "value", ")", "&&", "!", "self", "::", "_validate", "(", "$", "value", ",", "$", "parents", ",", "$", "skip", ",", "$", "ref", ")", ")", "{", "$", "valid", "=", "false", ";", "}", "}", "return", "$", "valid", ";", "}" ]
Recursively validate all annotation properties. @param array|object $fields @param array $parents The path of annotations above this annotation in the tree. @param array [ $skip] Array with objects which are already validated @return boolean
[ "Recursively", "validate", "all", "annotation", "properties", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Annotations/AbstractAnnotation.php#L459-L489
train
zircote/swagger-php
src/Annotations/AbstractAnnotation.php
AbstractAnnotation.validateType
private function validateType($type, $value): bool { if (substr($type, 0, 1) === '[' && substr($type, -1) === ']') { // Array of a specified type? if ($this->validateType('array', $value) === false) { return false; } $itemType = substr($type, 1, -1); foreach ($value as $i => $item) { if ($this->validateType($itemType, $item) === false) { return false; } } return true; } if (is_subclass_of($type, AbstractAnnotation::class)) { $type = 'object'; } return $this->validateDefaultTypes($type, $value); }
php
private function validateType($type, $value): bool { if (substr($type, 0, 1) === '[' && substr($type, -1) === ']') { // Array of a specified type? if ($this->validateType('array', $value) === false) { return false; } $itemType = substr($type, 1, -1); foreach ($value as $i => $item) { if ($this->validateType($itemType, $item) === false) { return false; } } return true; } if (is_subclass_of($type, AbstractAnnotation::class)) { $type = 'object'; } return $this->validateDefaultTypes($type, $value); }
[ "private", "function", "validateType", "(", "$", "type", ",", "$", "value", ")", ":", "bool", "{", "if", "(", "substr", "(", "$", "type", ",", "0", ",", "1", ")", "===", "'['", "&&", "substr", "(", "$", "type", ",", "-", "1", ")", "===", "']'", ")", "{", "// Array of a specified type?", "if", "(", "$", "this", "->", "validateType", "(", "'array'", ",", "$", "value", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "itemType", "=", "substr", "(", "$", "type", ",", "1", ",", "-", "1", ")", ";", "foreach", "(", "$", "value", "as", "$", "i", "=>", "$", "item", ")", "{", "if", "(", "$", "this", "->", "validateType", "(", "$", "itemType", ",", "$", "item", ")", "===", "false", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}", "if", "(", "is_subclass_of", "(", "$", "type", ",", "AbstractAnnotation", "::", "class", ")", ")", "{", "$", "type", "=", "'object'", ";", "}", "return", "$", "this", "->", "validateDefaultTypes", "(", "$", "type", ",", "$", "value", ")", ";", "}" ]
Validates the matching of the property value to a annotation type @param string $type The annotations property type @param mixed $value The property value @return bool @throws \Exception
[ "Validates", "the", "matching", "of", "the", "property", "value", "to", "a", "annotation", "type" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Annotations/AbstractAnnotation.php#L529-L549
train
zircote/swagger-php
src/Annotations/AbstractAnnotation.php
AbstractAnnotation.validateDefaultTypes
private function validateDefaultTypes($type, $value): bool { switch ($type) { case 'string': return is_string($value); case 'boolean': return is_bool($value); case 'integer': return is_int($value); case 'number': return is_numeric($value); case 'object': return is_object($value); case 'array': return $this->validateArrayType($value); case 'scheme': return in_array($value, ['http', 'https', 'ws', 'wss'], true); default: throw new Exception('Invalid type "' . $type . '"'); } }
php
private function validateDefaultTypes($type, $value): bool { switch ($type) { case 'string': return is_string($value); case 'boolean': return is_bool($value); case 'integer': return is_int($value); case 'number': return is_numeric($value); case 'object': return is_object($value); case 'array': return $this->validateArrayType($value); case 'scheme': return in_array($value, ['http', 'https', 'ws', 'wss'], true); default: throw new Exception('Invalid type "' . $type . '"'); } }
[ "private", "function", "validateDefaultTypes", "(", "$", "type", ",", "$", "value", ")", ":", "bool", "{", "switch", "(", "$", "type", ")", "{", "case", "'string'", ":", "return", "is_string", "(", "$", "value", ")", ";", "case", "'boolean'", ":", "return", "is_bool", "(", "$", "value", ")", ";", "case", "'integer'", ":", "return", "is_int", "(", "$", "value", ")", ";", "case", "'number'", ":", "return", "is_numeric", "(", "$", "value", ")", ";", "case", "'object'", ":", "return", "is_object", "(", "$", "value", ")", ";", "case", "'array'", ":", "return", "$", "this", "->", "validateArrayType", "(", "$", "value", ")", ";", "case", "'scheme'", ":", "return", "in_array", "(", "$", "value", ",", "[", "'http'", ",", "'https'", ",", "'ws'", ",", "'wss'", "]", ",", "true", ")", ";", "default", ":", "throw", "new", "Exception", "(", "'Invalid type \"'", ".", "$", "type", ".", "'\"'", ")", ";", "}", "}" ]
Validates default Open Api types @param string $type The property type @param mixed $value The value to validate @return bool @throws \Exception
[ "Validates", "default", "Open", "Api", "types" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Annotations/AbstractAnnotation.php#L560-L580
train
zircote/swagger-php
src/Annotations/AbstractAnnotation.php
AbstractAnnotation.validateArrayType
private function validateArrayType($value): bool { if (is_array($value) === false) { return false; } $count = 0; foreach ($value as $i => $item) { //not a array, but a hash/map if ($count !== $i) { return false; } $count++; } return true; }
php
private function validateArrayType($value): bool { if (is_array($value) === false) { return false; } $count = 0; foreach ($value as $i => $item) { //not a array, but a hash/map if ($count !== $i) { return false; } $count++; } return true; }
[ "private", "function", "validateArrayType", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "is_array", "(", "$", "value", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "count", "=", "0", ";", "foreach", "(", "$", "value", "as", "$", "i", "=>", "$", "item", ")", "{", "//not a array, but a hash/map", "if", "(", "$", "count", "!==", "$", "i", ")", "{", "return", "false", ";", "}", "$", "count", "++", ";", "}", "return", "true", ";", "}" ]
Validate array type @param mixed $value @return bool
[ "Validate", "array", "type" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Annotations/AbstractAnnotation.php#L589-L603
train
zircote/swagger-php
src/Annotations/AbstractAnnotation.php
AbstractAnnotation.nested
private function nested($annotation, $nestedContext) { if (property_exists($annotation, '_context') && $annotation->_context === $this->_context) { $annotation->_context = $nestedContext; } return $annotation; }
php
private function nested($annotation, $nestedContext) { if (property_exists($annotation, '_context') && $annotation->_context === $this->_context) { $annotation->_context = $nestedContext; } return $annotation; }
[ "private", "function", "nested", "(", "$", "annotation", ",", "$", "nestedContext", ")", "{", "if", "(", "property_exists", "(", "$", "annotation", ",", "'_context'", ")", "&&", "$", "annotation", "->", "_context", "===", "$", "this", "->", "_context", ")", "{", "$", "annotation", "->", "_context", "=", "$", "nestedContext", ";", "}", "return", "$", "annotation", ";", "}" ]
Wrap the context with a reference to the annotation it is nested in. @param AbstractAnnotation $annotation @param Context $nestedContext @return AbstractAnnotation
[ "Wrap", "the", "context", "with", "a", "reference", "to", "the", "annotation", "it", "is", "nested", "in", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Annotations/AbstractAnnotation.php#L612-L618
train
zircote/swagger-php
src/Processors/InheritProperties.php
InheritProperties.addAllOfProperty
private function addAllOfProperty(Schema $childSchema, Schema $parentSchema) { $currentSchema = new Schema(['_context' => $childSchema->_context]); $currentSchema->mergeProperties($childSchema); $defaultValues = get_class_vars(Schema::class); foreach (get_object_vars($currentSchema) as $property => $val) { $childSchema->{$property} = $defaultValues[$property]; } $childSchema->schema = $currentSchema->schema; unset($currentSchema->schema); if ($childSchema->allOf === UNDEFINED) { $childSchema->allOf = []; } $childSchema->allOf[] = new Schema( [ '_context' => $parentSchema->_context, 'ref' => Components::SCHEMA_REF . $parentSchema->schema ] ); $childSchema->allOf[] = $currentSchema; }
php
private function addAllOfProperty(Schema $childSchema, Schema $parentSchema) { $currentSchema = new Schema(['_context' => $childSchema->_context]); $currentSchema->mergeProperties($childSchema); $defaultValues = get_class_vars(Schema::class); foreach (get_object_vars($currentSchema) as $property => $val) { $childSchema->{$property} = $defaultValues[$property]; } $childSchema->schema = $currentSchema->schema; unset($currentSchema->schema); if ($childSchema->allOf === UNDEFINED) { $childSchema->allOf = []; } $childSchema->allOf[] = new Schema( [ '_context' => $parentSchema->_context, 'ref' => Components::SCHEMA_REF . $parentSchema->schema ] ); $childSchema->allOf[] = $currentSchema; }
[ "private", "function", "addAllOfProperty", "(", "Schema", "$", "childSchema", ",", "Schema", "$", "parentSchema", ")", "{", "$", "currentSchema", "=", "new", "Schema", "(", "[", "'_context'", "=>", "$", "childSchema", "->", "_context", "]", ")", ";", "$", "currentSchema", "->", "mergeProperties", "(", "$", "childSchema", ")", ";", "$", "defaultValues", "=", "get_class_vars", "(", "Schema", "::", "class", ")", ";", "foreach", "(", "get_object_vars", "(", "$", "currentSchema", ")", "as", "$", "property", "=>", "$", "val", ")", "{", "$", "childSchema", "->", "{", "$", "property", "}", "=", "$", "defaultValues", "[", "$", "property", "]", ";", "}", "$", "childSchema", "->", "schema", "=", "$", "currentSchema", "->", "schema", ";", "unset", "(", "$", "currentSchema", "->", "schema", ")", ";", "if", "(", "$", "childSchema", "->", "allOf", "===", "UNDEFINED", ")", "{", "$", "childSchema", "->", "allOf", "=", "[", "]", ";", "}", "$", "childSchema", "->", "allOf", "[", "]", "=", "new", "Schema", "(", "[", "'_context'", "=>", "$", "parentSchema", "->", "_context", ",", "'ref'", "=>", "Components", "::", "SCHEMA_REF", ".", "$", "parentSchema", "->", "schema", "]", ")", ";", "$", "childSchema", "->", "allOf", "[", "]", "=", "$", "currentSchema", ";", "}" ]
Add to child schema allOf property @param \OpenApi\Annotations\Schema $childSchema @param \OpenApi\Annotations\Schema $parentSchema
[ "Add", "to", "child", "schema", "allOf", "property" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Processors/InheritProperties.php#L84-L108
train
zircote/swagger-php
src/Analyser.php
Analyser.fromComment
public function fromComment($comment, $context = null) { if ($context === null) { $context = new Context(['comment' => $comment]); } else { $context->comment = $comment; } try { self::$context = $context; if ($context->is('annotations') === false) { $context->annotations = []; } $comment = preg_replace_callback( '/^[\t ]*\*[\t ]+/m', function ($match) { // Replace leading tabs with spaces. // Workaround for http://www.doctrine-project.org/jira/browse/DCOM-255 return str_replace("\t", ' ', $match[0]); }, $comment ); $annotations = $this->docParser->parse($comment, $context); self::$context = null; return $annotations; } catch (Exception $e) { self::$context = null; if (preg_match('/^(.+) at position ([0-9]+) in ' . preg_quote((string)$context, '/') . '\.$/', $e->getMessage(), $matches)) { $errorMessage = $matches[1]; $errorPos = (int)$matches[2]; $atPos = strpos($comment, '@'); $context->line += substr_count($comment, "\n", 0, $atPos + $errorPos); $lines = explode("\n", substr($comment, $atPos, $errorPos)); $context->character = strlen(array_pop($lines)) + 1; // position starts at 0 character starts at 1 Logger::warning(new Exception($errorMessage . ' in ' . $context, $e->getCode(), $e)); } else { Logger::warning($e); } return []; } }
php
public function fromComment($comment, $context = null) { if ($context === null) { $context = new Context(['comment' => $comment]); } else { $context->comment = $comment; } try { self::$context = $context; if ($context->is('annotations') === false) { $context->annotations = []; } $comment = preg_replace_callback( '/^[\t ]*\*[\t ]+/m', function ($match) { // Replace leading tabs with spaces. // Workaround for http://www.doctrine-project.org/jira/browse/DCOM-255 return str_replace("\t", ' ', $match[0]); }, $comment ); $annotations = $this->docParser->parse($comment, $context); self::$context = null; return $annotations; } catch (Exception $e) { self::$context = null; if (preg_match('/^(.+) at position ([0-9]+) in ' . preg_quote((string)$context, '/') . '\.$/', $e->getMessage(), $matches)) { $errorMessage = $matches[1]; $errorPos = (int)$matches[2]; $atPos = strpos($comment, '@'); $context->line += substr_count($comment, "\n", 0, $atPos + $errorPos); $lines = explode("\n", substr($comment, $atPos, $errorPos)); $context->character = strlen(array_pop($lines)) + 1; // position starts at 0 character starts at 1 Logger::warning(new Exception($errorMessage . ' in ' . $context, $e->getCode(), $e)); } else { Logger::warning($e); } return []; } }
[ "public", "function", "fromComment", "(", "$", "comment", ",", "$", "context", "=", "null", ")", "{", "if", "(", "$", "context", "===", "null", ")", "{", "$", "context", "=", "new", "Context", "(", "[", "'comment'", "=>", "$", "comment", "]", ")", ";", "}", "else", "{", "$", "context", "->", "comment", "=", "$", "comment", ";", "}", "try", "{", "self", "::", "$", "context", "=", "$", "context", ";", "if", "(", "$", "context", "->", "is", "(", "'annotations'", ")", "===", "false", ")", "{", "$", "context", "->", "annotations", "=", "[", "]", ";", "}", "$", "comment", "=", "preg_replace_callback", "(", "'/^[\\t ]*\\*[\\t ]+/m'", ",", "function", "(", "$", "match", ")", "{", "// Replace leading tabs with spaces.", "// Workaround for http://www.doctrine-project.org/jira/browse/DCOM-255", "return", "str_replace", "(", "\"\\t\"", ",", "' '", ",", "$", "match", "[", "0", "]", ")", ";", "}", ",", "$", "comment", ")", ";", "$", "annotations", "=", "$", "this", "->", "docParser", "->", "parse", "(", "$", "comment", ",", "$", "context", ")", ";", "self", "::", "$", "context", "=", "null", ";", "return", "$", "annotations", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "self", "::", "$", "context", "=", "null", ";", "if", "(", "preg_match", "(", "'/^(.+) at position ([0-9]+) in '", ".", "preg_quote", "(", "(", "string", ")", "$", "context", ",", "'/'", ")", ".", "'\\.$/'", ",", "$", "e", "->", "getMessage", "(", ")", ",", "$", "matches", ")", ")", "{", "$", "errorMessage", "=", "$", "matches", "[", "1", "]", ";", "$", "errorPos", "=", "(", "int", ")", "$", "matches", "[", "2", "]", ";", "$", "atPos", "=", "strpos", "(", "$", "comment", ",", "'@'", ")", ";", "$", "context", "->", "line", "+=", "substr_count", "(", "$", "comment", ",", "\"\\n\"", ",", "0", ",", "$", "atPos", "+", "$", "errorPos", ")", ";", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "substr", "(", "$", "comment", ",", "$", "atPos", ",", "$", "errorPos", ")", ")", ";", "$", "context", "->", "character", "=", "strlen", "(", "array_pop", "(", "$", "lines", ")", ")", "+", "1", ";", "// position starts at 0 character starts at 1", "Logger", "::", "warning", "(", "new", "Exception", "(", "$", "errorMessage", ".", "' in '", ".", "$", "context", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ")", ";", "}", "else", "{", "Logger", "::", "warning", "(", "$", "e", ")", ";", "}", "return", "[", "]", ";", "}", "}" ]
Use doctrine to parse the comment block and return the detected annotations. @param string $comment a T_DOC_COMMENT. @param Context $context @return array Annotations
[ "Use", "doctrine", "to", "parse", "the", "comment", "block", "and", "return", "the", "detected", "annotations", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Analyser.php#L89-L128
train
zircote/swagger-php
src/Serializer.php
Serializer.deserialize
public function deserialize($jsonString, $className) { if (!$this->isValidClassName($className)) { throw new \Exception($className.' is not defined in OpenApi PHP Annotations'); } return $this->doDeserialize(json_decode($jsonString), $className); }
php
public function deserialize($jsonString, $className) { if (!$this->isValidClassName($className)) { throw new \Exception($className.' is not defined in OpenApi PHP Annotations'); } return $this->doDeserialize(json_decode($jsonString), $className); }
[ "public", "function", "deserialize", "(", "$", "jsonString", ",", "$", "className", ")", "{", "if", "(", "!", "$", "this", "->", "isValidClassName", "(", "$", "className", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "className", ".", "' is not defined in OpenApi PHP Annotations'", ")", ";", "}", "return", "$", "this", "->", "doDeserialize", "(", "json_decode", "(", "$", "jsonString", ")", ",", "$", "className", ")", ";", "}" ]
Deserialize a string @param $jsonString @param $className @return Annotations\AbstractAnnotation @throws \Exception
[ "Deserialize", "a", "string" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Serializer.php#L83-L89
train
zircote/swagger-php
src/Serializer.php
Serializer.deserializeFile
public function deserializeFile($filename, $className = 'OpenApi\Annotations\OpenApi') { if (!$this->isValidClassName($className)) { throw new \Exception($className.' is not defined in OpenApi PHP Annotations'); } $jsonString = file_get_contents($filename); return $this->doDeserialize(json_decode($jsonString), $className); }
php
public function deserializeFile($filename, $className = 'OpenApi\Annotations\OpenApi') { if (!$this->isValidClassName($className)) { throw new \Exception($className.' is not defined in OpenApi PHP Annotations'); } $jsonString = file_get_contents($filename); return $this->doDeserialize(json_decode($jsonString), $className); }
[ "public", "function", "deserializeFile", "(", "$", "filename", ",", "$", "className", "=", "'OpenApi\\Annotations\\OpenApi'", ")", "{", "if", "(", "!", "$", "this", "->", "isValidClassName", "(", "$", "className", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "className", ".", "' is not defined in OpenApi PHP Annotations'", ")", ";", "}", "$", "jsonString", "=", "file_get_contents", "(", "$", "filename", ")", ";", "return", "$", "this", "->", "doDeserialize", "(", "json_decode", "(", "$", "jsonString", ")", ",", "$", "className", ")", ";", "}" ]
Deserialize a file @param $filename @param $className @return Annotations\AbstractAnnotation @throws \Exception
[ "Deserialize", "a", "file" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Serializer.php#L101-L108
train
zircote/swagger-php
src/Serializer.php
Serializer.doDeserialize
private function doDeserialize(\stdClass $c, $class) { $annotation = new $class([]); foreach ($c as $property => $value) { if ($property === '$ref') { $property = 'ref'; } if (substr($property, 0, 2) === 'x-') { if ($annotation->x === UNDEFINED) { $annotation->x = []; } $custom = substr($property, 2); $annotation->x[$custom] = $value; } else { $annotation->$property = $this->doDeserializeProperty($annotation, $property, $value); } } return $annotation; }
php
private function doDeserialize(\stdClass $c, $class) { $annotation = new $class([]); foreach ($c as $property => $value) { if ($property === '$ref') { $property = 'ref'; } if (substr($property, 0, 2) === 'x-') { if ($annotation->x === UNDEFINED) { $annotation->x = []; } $custom = substr($property, 2); $annotation->x[$custom] = $value; } else { $annotation->$property = $this->doDeserializeProperty($annotation, $property, $value); } } return $annotation; }
[ "private", "function", "doDeserialize", "(", "\\", "stdClass", "$", "c", ",", "$", "class", ")", "{", "$", "annotation", "=", "new", "$", "class", "(", "[", "]", ")", ";", "foreach", "(", "$", "c", "as", "$", "property", "=>", "$", "value", ")", "{", "if", "(", "$", "property", "===", "'$ref'", ")", "{", "$", "property", "=", "'ref'", ";", "}", "if", "(", "substr", "(", "$", "property", ",", "0", ",", "2", ")", "===", "'x-'", ")", "{", "if", "(", "$", "annotation", "->", "x", "===", "UNDEFINED", ")", "{", "$", "annotation", "->", "x", "=", "[", "]", ";", "}", "$", "custom", "=", "substr", "(", "$", "property", ",", "2", ")", ";", "$", "annotation", "->", "x", "[", "$", "custom", "]", "=", "$", "value", ";", "}", "else", "{", "$", "annotation", "->", "$", "property", "=", "$", "this", "->", "doDeserializeProperty", "(", "$", "annotation", ",", "$", "property", ",", "$", "value", ")", ";", "}", "}", "return", "$", "annotation", ";", "}" ]
Do deserialization. @param \stdClass $c @param string $class The class name of annotation. @return Annotations\AbstractAnnotation
[ "Do", "deserialization", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Serializer.php#L118-L137
train
zircote/swagger-php
src/Serializer.php
Serializer.doDeserializeProperty
private function doDeserializeProperty(Annotations\AbstractAnnotation $annotation, $property, $value) { // property is primitive type if (array_key_exists($property, $annotation::$_types)) { return $this->doDeserializeBaseProperty($annotation::$_types[$property], $value); } // property is embedded annotation foreach ($annotation::$_nested as $class => $declaration) { // property is an annotation if (is_string($declaration) && $declaration === $property) { return $this->doDeserialize($value, $class); } // property is an annotation array if (is_array($declaration) && count($declaration) === 1 && $declaration[0] === $property) { $annotationArr = []; foreach ($value as $v) { $annotationArr[] = $this->doDeserialize($v, $class); } return $annotationArr; } // property is an annotation hash map if (is_array($declaration) && count($declaration) === 2 && $declaration[0] === $property) { $key = $declaration[1]; $annotationHash = []; foreach ($value as $k => $v) { $annotation = $this->doDeserialize($v, $class); $annotation->$key = $k; $annotationHash[$k] = $annotation; } return $annotationHash; } } return $value; }
php
private function doDeserializeProperty(Annotations\AbstractAnnotation $annotation, $property, $value) { // property is primitive type if (array_key_exists($property, $annotation::$_types)) { return $this->doDeserializeBaseProperty($annotation::$_types[$property], $value); } // property is embedded annotation foreach ($annotation::$_nested as $class => $declaration) { // property is an annotation if (is_string($declaration) && $declaration === $property) { return $this->doDeserialize($value, $class); } // property is an annotation array if (is_array($declaration) && count($declaration) === 1 && $declaration[0] === $property) { $annotationArr = []; foreach ($value as $v) { $annotationArr[] = $this->doDeserialize($v, $class); } return $annotationArr; } // property is an annotation hash map if (is_array($declaration) && count($declaration) === 2 && $declaration[0] === $property) { $key = $declaration[1]; $annotationHash = []; foreach ($value as $k => $v) { $annotation = $this->doDeserialize($v, $class); $annotation->$key = $k; $annotationHash[$k] = $annotation; } return $annotationHash; } } return $value; }
[ "private", "function", "doDeserializeProperty", "(", "Annotations", "\\", "AbstractAnnotation", "$", "annotation", ",", "$", "property", ",", "$", "value", ")", "{", "// property is primitive type", "if", "(", "array_key_exists", "(", "$", "property", ",", "$", "annotation", "::", "$", "_types", ")", ")", "{", "return", "$", "this", "->", "doDeserializeBaseProperty", "(", "$", "annotation", "::", "$", "_types", "[", "$", "property", "]", ",", "$", "value", ")", ";", "}", "// property is embedded annotation", "foreach", "(", "$", "annotation", "::", "$", "_nested", "as", "$", "class", "=>", "$", "declaration", ")", "{", "// property is an annotation", "if", "(", "is_string", "(", "$", "declaration", ")", "&&", "$", "declaration", "===", "$", "property", ")", "{", "return", "$", "this", "->", "doDeserialize", "(", "$", "value", ",", "$", "class", ")", ";", "}", "// property is an annotation array", "if", "(", "is_array", "(", "$", "declaration", ")", "&&", "count", "(", "$", "declaration", ")", "===", "1", "&&", "$", "declaration", "[", "0", "]", "===", "$", "property", ")", "{", "$", "annotationArr", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "v", ")", "{", "$", "annotationArr", "[", "]", "=", "$", "this", "->", "doDeserialize", "(", "$", "v", ",", "$", "class", ")", ";", "}", "return", "$", "annotationArr", ";", "}", "// property is an annotation hash map", "if", "(", "is_array", "(", "$", "declaration", ")", "&&", "count", "(", "$", "declaration", ")", "===", "2", "&&", "$", "declaration", "[", "0", "]", "===", "$", "property", ")", "{", "$", "key", "=", "$", "declaration", "[", "1", "]", ";", "$", "annotationHash", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "annotation", "=", "$", "this", "->", "doDeserialize", "(", "$", "v", ",", "$", "class", ")", ";", "$", "annotation", "->", "$", "key", "=", "$", "k", ";", "$", "annotationHash", "[", "$", "k", "]", "=", "$", "annotation", ";", "}", "return", "$", "annotationHash", ";", "}", "}", "return", "$", "value", ";", "}" ]
Deserialize the annotation's property. @param Annotations\AbstractAnnotation $annotation @param string $property @param mixed $value @return mixed
[ "Deserialize", "the", "annotation", "s", "property", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Serializer.php#L148-L184
train
zircote/swagger-php
src/Serializer.php
Serializer.doDeserializeBaseProperty
private function doDeserializeBaseProperty($type, $value) { $isAnnotationClass = is_string($type) && is_subclass_of(trim($type, '[]'), AbstractAnnotation::class); if ($isAnnotationClass) { $isArray = strpos($type, '[') === 0 && substr($type, -1) === ']'; if ($isArray) { $annotationArr = []; $class = trim($type, '[]'); foreach ($value as $v) { $annotationArr[] = $this->doDeserialize($v, $class); } return $annotationArr; } return $this->doDeserialize($value, $type); } return $value; }
php
private function doDeserializeBaseProperty($type, $value) { $isAnnotationClass = is_string($type) && is_subclass_of(trim($type, '[]'), AbstractAnnotation::class); if ($isAnnotationClass) { $isArray = strpos($type, '[') === 0 && substr($type, -1) === ']'; if ($isArray) { $annotationArr = []; $class = trim($type, '[]'); foreach ($value as $v) { $annotationArr[] = $this->doDeserialize($v, $class); } return $annotationArr; } return $this->doDeserialize($value, $type); } return $value; }
[ "private", "function", "doDeserializeBaseProperty", "(", "$", "type", ",", "$", "value", ")", "{", "$", "isAnnotationClass", "=", "is_string", "(", "$", "type", ")", "&&", "is_subclass_of", "(", "trim", "(", "$", "type", ",", "'[]'", ")", ",", "AbstractAnnotation", "::", "class", ")", ";", "if", "(", "$", "isAnnotationClass", ")", "{", "$", "isArray", "=", "strpos", "(", "$", "type", ",", "'['", ")", "===", "0", "&&", "substr", "(", "$", "type", ",", "-", "1", ")", "===", "']'", ";", "if", "(", "$", "isArray", ")", "{", "$", "annotationArr", "=", "[", "]", ";", "$", "class", "=", "trim", "(", "$", "type", ",", "'[]'", ")", ";", "foreach", "(", "$", "value", "as", "$", "v", ")", "{", "$", "annotationArr", "[", "]", "=", "$", "this", "->", "doDeserialize", "(", "$", "v", ",", "$", "class", ")", ";", "}", "return", "$", "annotationArr", ";", "}", "return", "$", "this", "->", "doDeserialize", "(", "$", "value", ",", "$", "type", ")", ";", "}", "return", "$", "value", ";", "}" ]
Deserialize base annotation property @param string $type The property type @param mixed $value The value to deserialization @return array|\OpenApi\Annotations\AbstractAnnotation
[ "Deserialize", "base", "annotation", "property" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Serializer.php#L194-L215
train
zircote/swagger-php
src/Context.php
Context.with
public function with($property) { if (property_exists($this, $property)) { return $this; } if ($this->_parent) { return $this->_parent->with($property); } return false; }
php
public function with($property) { if (property_exists($this, $property)) { return $this; } if ($this->_parent) { return $this->_parent->with($property); } return false; }
[ "public", "function", "with", "(", "$", "property", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "$", "property", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "$", "this", "->", "_parent", ")", "{", "return", "$", "this", "->", "_parent", "->", "with", "(", "$", "property", ")", ";", "}", "return", "false", ";", "}" ]
Return the context containing the specified property. @param string $property @return boolean|Context
[ "Return", "the", "context", "containing", "the", "specified", "property", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Context.php#L88-L98
train
zircote/swagger-php
src/Context.php
Context.getDebugLocation
public function getDebugLocation() { $location = ''; if ($this->class && ($this->method || $this->property)) { $location .= $this->fullyQualifiedName($this->class); if ($this->method) { $location .= ($this->static ? '::' : '->') . $this->method . '()'; } elseif ($this->property) { $location .= ($this->static ? '::$' : '->') . $this->property; } } if ($this->filename) { if ($location !== '') { $location .= ' in '; } $location .= $this->filename; } if ($this->line) { if ($location !== '') { $location .= ' on'; } $location .= ' line ' . $this->line; if ($this->character) { $location .= ':' . $this->character; } } return $location; }
php
public function getDebugLocation() { $location = ''; if ($this->class && ($this->method || $this->property)) { $location .= $this->fullyQualifiedName($this->class); if ($this->method) { $location .= ($this->static ? '::' : '->') . $this->method . '()'; } elseif ($this->property) { $location .= ($this->static ? '::$' : '->') . $this->property; } } if ($this->filename) { if ($location !== '') { $location .= ' in '; } $location .= $this->filename; } if ($this->line) { if ($location !== '') { $location .= ' on'; } $location .= ' line ' . $this->line; if ($this->character) { $location .= ':' . $this->character; } } return $location; }
[ "public", "function", "getDebugLocation", "(", ")", "{", "$", "location", "=", "''", ";", "if", "(", "$", "this", "->", "class", "&&", "(", "$", "this", "->", "method", "||", "$", "this", "->", "property", ")", ")", "{", "$", "location", ".=", "$", "this", "->", "fullyQualifiedName", "(", "$", "this", "->", "class", ")", ";", "if", "(", "$", "this", "->", "method", ")", "{", "$", "location", ".=", "(", "$", "this", "->", "static", "?", "'::'", ":", "'->'", ")", ".", "$", "this", "->", "method", ".", "'()'", ";", "}", "elseif", "(", "$", "this", "->", "property", ")", "{", "$", "location", ".=", "(", "$", "this", "->", "static", "?", "'::$'", ":", "'->'", ")", ".", "$", "this", "->", "property", ";", "}", "}", "if", "(", "$", "this", "->", "filename", ")", "{", "if", "(", "$", "location", "!==", "''", ")", "{", "$", "location", ".=", "' in '", ";", "}", "$", "location", ".=", "$", "this", "->", "filename", ";", "}", "if", "(", "$", "this", "->", "line", ")", "{", "if", "(", "$", "location", "!==", "''", ")", "{", "$", "location", ".=", "' on'", ";", "}", "$", "location", ".=", "' line '", ".", "$", "this", "->", "line", ";", "if", "(", "$", "this", "->", "character", ")", "{", "$", "location", ".=", "':'", ".", "$", "this", "->", "character", ";", "}", "}", "return", "$", "location", ";", "}" ]
Export location for debugging. @return string Example: "file1.php on line 12"
[ "Export", "location", "for", "debugging", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Context.php#L117-L145
train
zircote/swagger-php
src/Context.php
Context.phpdocSummary
public function phpdocSummary() { $content = $this->phpdocContent(); if (!$content) { return UNDEFINED; } $lines = preg_split('/(\n|\r\n)/', $content); $summary = ''; foreach ($lines as $line) { $summary .= $line . "\n"; if ($line === '' || substr($line, -1) === '.') { return trim($summary); } } $summary = trim($summary); if ($summary === '') { return UNDEFINED; } return $summary; }
php
public function phpdocSummary() { $content = $this->phpdocContent(); if (!$content) { return UNDEFINED; } $lines = preg_split('/(\n|\r\n)/', $content); $summary = ''; foreach ($lines as $line) { $summary .= $line . "\n"; if ($line === '' || substr($line, -1) === '.') { return trim($summary); } } $summary = trim($summary); if ($summary === '') { return UNDEFINED; } return $summary; }
[ "public", "function", "phpdocSummary", "(", ")", "{", "$", "content", "=", "$", "this", "->", "phpdocContent", "(", ")", ";", "if", "(", "!", "$", "content", ")", "{", "return", "UNDEFINED", ";", "}", "$", "lines", "=", "preg_split", "(", "'/(\\n|\\r\\n)/'", ",", "$", "content", ")", ";", "$", "summary", "=", "''", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "summary", ".=", "$", "line", ".", "\"\\n\"", ";", "if", "(", "$", "line", "===", "''", "||", "substr", "(", "$", "line", ",", "-", "1", ")", "===", "'.'", ")", "{", "return", "trim", "(", "$", "summary", ")", ";", "}", "}", "$", "summary", "=", "trim", "(", "$", "summary", ")", ";", "if", "(", "$", "summary", "===", "''", ")", "{", "return", "UNDEFINED", ";", "}", "return", "$", "summary", ";", "}" ]
A short piece of text, usually one line, providing the basic function of the associated element. @return string
[ "A", "short", "piece", "of", "text", "usually", "one", "line", "providing", "the", "basic", "function", "of", "the", "associated", "element", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Context.php#L178-L198
train
zircote/swagger-php
src/Context.php
Context.detect
public static function detect($index = 0) { $context = new Context(); $backtrace = debug_backtrace(); $position = $backtrace[$index]; if (isset($position['file'])) { $context->filename = $position['file']; } if (isset($position['line'])) { $context->line = $position['line']; } $caller = isset($backtrace[$index + 1]) ? $backtrace[$index + 1] : null; if (isset($caller['function'])) { $context->method = $caller['function']; if (isset($caller['type']) && $caller['type'] === '::') { $context->static = true; } } if (isset($caller['class'])) { $fqn = explode('\\', $caller['class']); $context->class = array_pop($fqn); if (count($fqn)) { $context->namespace = implode('\\', $fqn); } } // @todo extract namespaces and use statements return $context; }
php
public static function detect($index = 0) { $context = new Context(); $backtrace = debug_backtrace(); $position = $backtrace[$index]; if (isset($position['file'])) { $context->filename = $position['file']; } if (isset($position['line'])) { $context->line = $position['line']; } $caller = isset($backtrace[$index + 1]) ? $backtrace[$index + 1] : null; if (isset($caller['function'])) { $context->method = $caller['function']; if (isset($caller['type']) && $caller['type'] === '::') { $context->static = true; } } if (isset($caller['class'])) { $fqn = explode('\\', $caller['class']); $context->class = array_pop($fqn); if (count($fqn)) { $context->namespace = implode('\\', $fqn); } } // @todo extract namespaces and use statements return $context; }
[ "public", "static", "function", "detect", "(", "$", "index", "=", "0", ")", "{", "$", "context", "=", "new", "Context", "(", ")", ";", "$", "backtrace", "=", "debug_backtrace", "(", ")", ";", "$", "position", "=", "$", "backtrace", "[", "$", "index", "]", ";", "if", "(", "isset", "(", "$", "position", "[", "'file'", "]", ")", ")", "{", "$", "context", "->", "filename", "=", "$", "position", "[", "'file'", "]", ";", "}", "if", "(", "isset", "(", "$", "position", "[", "'line'", "]", ")", ")", "{", "$", "context", "->", "line", "=", "$", "position", "[", "'line'", "]", ";", "}", "$", "caller", "=", "isset", "(", "$", "backtrace", "[", "$", "index", "+", "1", "]", ")", "?", "$", "backtrace", "[", "$", "index", "+", "1", "]", ":", "null", ";", "if", "(", "isset", "(", "$", "caller", "[", "'function'", "]", ")", ")", "{", "$", "context", "->", "method", "=", "$", "caller", "[", "'function'", "]", ";", "if", "(", "isset", "(", "$", "caller", "[", "'type'", "]", ")", "&&", "$", "caller", "[", "'type'", "]", "===", "'::'", ")", "{", "$", "context", "->", "static", "=", "true", ";", "}", "}", "if", "(", "isset", "(", "$", "caller", "[", "'class'", "]", ")", ")", "{", "$", "fqn", "=", "explode", "(", "'\\\\'", ",", "$", "caller", "[", "'class'", "]", ")", ";", "$", "context", "->", "class", "=", "array_pop", "(", "$", "fqn", ")", ";", "if", "(", "count", "(", "$", "fqn", ")", ")", "{", "$", "context", "->", "namespace", "=", "implode", "(", "'\\\\'", ",", "$", "fqn", ")", ";", "}", "}", "// @todo extract namespaces and use statements", "return", "$", "context", ";", "}" ]
Create a Context based on the debug_backtrace @param int $index @return Context
[ "Create", "a", "Context", "based", "on", "the", "debug_backtrace" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Context.php#L259-L287
train
zircote/swagger-php
src/Context.php
Context.fullyQualifiedName
public function fullyQualifiedName($class) { if ($this->namespace) { $namespace = str_replace('\\\\', '\\', '\\' . $this->namespace . '\\'); } else { $namespace = '\\'; // global namespace } if ($this->class === null) { $this->class = ''; } if ($class === null) { return ''; } if (strcasecmp($class, $this->class) === 0) { return $namespace . $this->class; } $pos = strpos($class, '\\'); if ($pos !== false) { if ($pos === 0) { // Fully qualified name (\Foo\Bar) return $class; } // Qualified name (Foo\Bar) if ($this->uses) { foreach ($this->uses as $alias => $aliasedNamespace) { $alias .= '\\'; if (strcasecmp(substr($class, 0, strlen($alias)), $alias) === 0) { // Aliased namespace (use \Long\Namespace as Foo) return '\\' . $aliasedNamespace . substr($class, strlen($alias) - 1); } } } } elseif ($this->uses) { // Unqualified name (Foo) foreach ($this->uses as $alias => $aliasedNamespace) { if (strcasecmp($alias, $class) === 0) { return '\\' . $aliasedNamespace; } } } return $namespace . $class; }
php
public function fullyQualifiedName($class) { if ($this->namespace) { $namespace = str_replace('\\\\', '\\', '\\' . $this->namespace . '\\'); } else { $namespace = '\\'; // global namespace } if ($this->class === null) { $this->class = ''; } if ($class === null) { return ''; } if (strcasecmp($class, $this->class) === 0) { return $namespace . $this->class; } $pos = strpos($class, '\\'); if ($pos !== false) { if ($pos === 0) { // Fully qualified name (\Foo\Bar) return $class; } // Qualified name (Foo\Bar) if ($this->uses) { foreach ($this->uses as $alias => $aliasedNamespace) { $alias .= '\\'; if (strcasecmp(substr($class, 0, strlen($alias)), $alias) === 0) { // Aliased namespace (use \Long\Namespace as Foo) return '\\' . $aliasedNamespace . substr($class, strlen($alias) - 1); } } } } elseif ($this->uses) { // Unqualified name (Foo) foreach ($this->uses as $alias => $aliasedNamespace) { if (strcasecmp($alias, $class) === 0) { return '\\' . $aliasedNamespace; } } } return $namespace . $class; }
[ "public", "function", "fullyQualifiedName", "(", "$", "class", ")", "{", "if", "(", "$", "this", "->", "namespace", ")", "{", "$", "namespace", "=", "str_replace", "(", "'\\\\\\\\'", ",", "'\\\\'", ",", "'\\\\'", ".", "$", "this", "->", "namespace", ".", "'\\\\'", ")", ";", "}", "else", "{", "$", "namespace", "=", "'\\\\'", ";", "// global namespace", "}", "if", "(", "$", "this", "->", "class", "===", "null", ")", "{", "$", "this", "->", "class", "=", "''", ";", "}", "if", "(", "$", "class", "===", "null", ")", "{", "return", "''", ";", "}", "if", "(", "strcasecmp", "(", "$", "class", ",", "$", "this", "->", "class", ")", "===", "0", ")", "{", "return", "$", "namespace", ".", "$", "this", "->", "class", ";", "}", "$", "pos", "=", "strpos", "(", "$", "class", ",", "'\\\\'", ")", ";", "if", "(", "$", "pos", "!==", "false", ")", "{", "if", "(", "$", "pos", "===", "0", ")", "{", "// Fully qualified name (\\Foo\\Bar)", "return", "$", "class", ";", "}", "// Qualified name (Foo\\Bar)", "if", "(", "$", "this", "->", "uses", ")", "{", "foreach", "(", "$", "this", "->", "uses", "as", "$", "alias", "=>", "$", "aliasedNamespace", ")", "{", "$", "alias", ".=", "'\\\\'", ";", "if", "(", "strcasecmp", "(", "substr", "(", "$", "class", ",", "0", ",", "strlen", "(", "$", "alias", ")", ")", ",", "$", "alias", ")", "===", "0", ")", "{", "// Aliased namespace (use \\Long\\Namespace as Foo)", "return", "'\\\\'", ".", "$", "aliasedNamespace", ".", "substr", "(", "$", "class", ",", "strlen", "(", "$", "alias", ")", "-", "1", ")", ";", "}", "}", "}", "}", "elseif", "(", "$", "this", "->", "uses", ")", "{", "// Unqualified name (Foo)", "foreach", "(", "$", "this", "->", "uses", "as", "$", "alias", "=>", "$", "aliasedNamespace", ")", "{", "if", "(", "strcasecmp", "(", "$", "alias", ",", "$", "class", ")", "===", "0", ")", "{", "return", "'\\\\'", ".", "$", "aliasedNamespace", ";", "}", "}", "}", "return", "$", "namespace", ".", "$", "class", ";", "}" ]
Resolve the fully qualified name. @param string $class The class name @return string
[ "Resolve", "the", "fully", "qualified", "name", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Context.php#L296-L341
train
zircote/swagger-php
src/Analysis.php
Analysis.getTraitsOfClass
public function getTraitsOfClass($class) { $definitions = []; // in case there is a hierarchy of classes $classes = $this->getSuperClasses($class); if (is_array($classes)) { foreach ($classes as $subClass) { if (isset($subClass['traits'])) { foreach ($subClass['traits'] as $classTrait) { foreach ($this->traits as $trait) { if ($classTrait === $trait['trait']) { $traitDefinition[$trait['trait']] = $trait; $definitions = array_merge($definitions, $traitDefinition); } } } } } } // trait used by the given class $classDefinition = isset($this->classes[$class]) ? $this->classes[$class] : null; if (!$classDefinition || empty($classDefinition['traits'])) { return $definitions; } $classTraits = $classDefinition['traits']; foreach ($this->traits as $trait) { foreach ($classTraits as $classTrait => $name) { if ($trait['trait'] === $name) { $traitDefinition[$name] = $trait; $definitions = array_merge($definitions, $traitDefinition); } } } return $definitions; }
php
public function getTraitsOfClass($class) { $definitions = []; // in case there is a hierarchy of classes $classes = $this->getSuperClasses($class); if (is_array($classes)) { foreach ($classes as $subClass) { if (isset($subClass['traits'])) { foreach ($subClass['traits'] as $classTrait) { foreach ($this->traits as $trait) { if ($classTrait === $trait['trait']) { $traitDefinition[$trait['trait']] = $trait; $definitions = array_merge($definitions, $traitDefinition); } } } } } } // trait used by the given class $classDefinition = isset($this->classes[$class]) ? $this->classes[$class] : null; if (!$classDefinition || empty($classDefinition['traits'])) { return $definitions; } $classTraits = $classDefinition['traits']; foreach ($this->traits as $trait) { foreach ($classTraits as $classTrait => $name) { if ($trait['trait'] === $name) { $traitDefinition[$name] = $trait; $definitions = array_merge($definitions, $traitDefinition); } } } return $definitions; }
[ "public", "function", "getTraitsOfClass", "(", "$", "class", ")", "{", "$", "definitions", "=", "[", "]", ";", "// in case there is a hierarchy of classes", "$", "classes", "=", "$", "this", "->", "getSuperClasses", "(", "$", "class", ")", ";", "if", "(", "is_array", "(", "$", "classes", ")", ")", "{", "foreach", "(", "$", "classes", "as", "$", "subClass", ")", "{", "if", "(", "isset", "(", "$", "subClass", "[", "'traits'", "]", ")", ")", "{", "foreach", "(", "$", "subClass", "[", "'traits'", "]", "as", "$", "classTrait", ")", "{", "foreach", "(", "$", "this", "->", "traits", "as", "$", "trait", ")", "{", "if", "(", "$", "classTrait", "===", "$", "trait", "[", "'trait'", "]", ")", "{", "$", "traitDefinition", "[", "$", "trait", "[", "'trait'", "]", "]", "=", "$", "trait", ";", "$", "definitions", "=", "array_merge", "(", "$", "definitions", ",", "$", "traitDefinition", ")", ";", "}", "}", "}", "}", "}", "}", "// trait used by the given class", "$", "classDefinition", "=", "isset", "(", "$", "this", "->", "classes", "[", "$", "class", "]", ")", "?", "$", "this", "->", "classes", "[", "$", "class", "]", ":", "null", ";", "if", "(", "!", "$", "classDefinition", "||", "empty", "(", "$", "classDefinition", "[", "'traits'", "]", ")", ")", "{", "return", "$", "definitions", ";", "}", "$", "classTraits", "=", "$", "classDefinition", "[", "'traits'", "]", ";", "foreach", "(", "$", "this", "->", "traits", "as", "$", "trait", ")", "{", "foreach", "(", "$", "classTraits", "as", "$", "classTrait", "=>", "$", "name", ")", "{", "if", "(", "$", "trait", "[", "'trait'", "]", "===", "$", "name", ")", "{", "$", "traitDefinition", "[", "$", "name", "]", "=", "$", "trait", ";", "$", "definitions", "=", "array_merge", "(", "$", "definitions", ",", "$", "traitDefinition", ")", ";", "}", "}", "}", "return", "$", "definitions", ";", "}" ]
Returns an array of traits used by the given class or by classes which it extends @param string $class @return array
[ "Returns", "an", "array", "of", "traits", "used", "by", "the", "given", "class", "or", "by", "classes", "which", "it", "extends" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Analysis.php#L207-L244
train
zircote/swagger-php
src/Analysis.php
Analysis.merged
public function merged() { if (!$this->openapi) { throw new Exception('No openapi target set. Run the MergeIntoOpenApi processor'); } $unmerged = $this->openapi->_unmerged; $this->openapi->_unmerged = []; $analysis = new Analysis([$this->openapi]); $this->openapi->_unmerged = $unmerged; return $analysis; }
php
public function merged() { if (!$this->openapi) { throw new Exception('No openapi target set. Run the MergeIntoOpenApi processor'); } $unmerged = $this->openapi->_unmerged; $this->openapi->_unmerged = []; $analysis = new Analysis([$this->openapi]); $this->openapi->_unmerged = $unmerged; return $analysis; }
[ "public", "function", "merged", "(", ")", "{", "if", "(", "!", "$", "this", "->", "openapi", ")", "{", "throw", "new", "Exception", "(", "'No openapi target set. Run the MergeIntoOpenApi processor'", ")", ";", "}", "$", "unmerged", "=", "$", "this", "->", "openapi", "->", "_unmerged", ";", "$", "this", "->", "openapi", "->", "_unmerged", "=", "[", "]", ";", "$", "analysis", "=", "new", "Analysis", "(", "[", "$", "this", "->", "openapi", "]", ")", ";", "$", "this", "->", "openapi", "->", "_unmerged", "=", "$", "unmerged", ";", "return", "$", "analysis", ";", "}" ]
Build an analysis with only the annotations that are merged into the OpenAPI annotation. @return Analysis
[ "Build", "an", "analysis", "with", "only", "the", "annotations", "that", "are", "merged", "into", "the", "OpenAPI", "annotation", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Analysis.php#L302-L313
train
zircote/swagger-php
src/Analysis.php
Analysis.split
public function split() { $result = new stdClass(); $result->merged = $this->merged(); $result->unmerged = new Analysis(); foreach ($this->annotations as $annotation) { if ($result->merged->annotations->contains($annotation) === false) { $result->unmerged->annotations->attach($annotation, $this->annotations[$annotation]); } } return $result; }
php
public function split() { $result = new stdClass(); $result->merged = $this->merged(); $result->unmerged = new Analysis(); foreach ($this->annotations as $annotation) { if ($result->merged->annotations->contains($annotation) === false) { $result->unmerged->annotations->attach($annotation, $this->annotations[$annotation]); } } return $result; }
[ "public", "function", "split", "(", ")", "{", "$", "result", "=", "new", "stdClass", "(", ")", ";", "$", "result", "->", "merged", "=", "$", "this", "->", "merged", "(", ")", ";", "$", "result", "->", "unmerged", "=", "new", "Analysis", "(", ")", ";", "foreach", "(", "$", "this", "->", "annotations", "as", "$", "annotation", ")", "{", "if", "(", "$", "result", "->", "merged", "->", "annotations", "->", "contains", "(", "$", "annotation", ")", "===", "false", ")", "{", "$", "result", "->", "unmerged", "->", "annotations", "->", "attach", "(", "$", "annotation", ",", "$", "this", "->", "annotations", "[", "$", "annotation", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Split the annotation into two analysis. One with annotations that are merged and one with annotations that are not merged. @return object {merged: Analysis, unmerged: Analysis}
[ "Split", "the", "annotation", "into", "two", "analysis", ".", "One", "with", "annotations", "that", "are", "merged", "and", "one", "with", "annotations", "that", "are", "not", "merged", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Analysis.php#L331-L343
train
zircote/swagger-php
src/Analysis.php
Analysis.&
public static function &processors() { if (!self::$processors) { // Add default processors. self::$processors = [ new MergeIntoOpenApi(), new MergeIntoComponents(), new ImportTraits(), new AugmentSchemas(), new AugmentProperties(), new BuildPaths(), // new HandleReferences(), new InheritProperties(), new AugmentOperations(), new AugmentParameters(), new MergeJsonContent(), new MergeXmlContent(), new OperationId(), new CleanUnmerged(), ]; } return self::$processors; }
php
public static function &processors() { if (!self::$processors) { // Add default processors. self::$processors = [ new MergeIntoOpenApi(), new MergeIntoComponents(), new ImportTraits(), new AugmentSchemas(), new AugmentProperties(), new BuildPaths(), // new HandleReferences(), new InheritProperties(), new AugmentOperations(), new AugmentParameters(), new MergeJsonContent(), new MergeXmlContent(), new OperationId(), new CleanUnmerged(), ]; } return self::$processors; }
[ "public", "static", "function", "&", "processors", "(", ")", "{", "if", "(", "!", "self", "::", "$", "processors", ")", "{", "// Add default processors.", "self", "::", "$", "processors", "=", "[", "new", "MergeIntoOpenApi", "(", ")", ",", "new", "MergeIntoComponents", "(", ")", ",", "new", "ImportTraits", "(", ")", ",", "new", "AugmentSchemas", "(", ")", ",", "new", "AugmentProperties", "(", ")", ",", "new", "BuildPaths", "(", ")", ",", "// new HandleReferences(),", "new", "InheritProperties", "(", ")", ",", "new", "AugmentOperations", "(", ")", ",", "new", "AugmentParameters", "(", ")", ",", "new", "MergeJsonContent", "(", ")", ",", "new", "MergeXmlContent", "(", ")", ",", "new", "OperationId", "(", ")", ",", "new", "CleanUnmerged", "(", ")", ",", "]", ";", "}", "return", "self", "::", "$", "processors", ";", "}" ]
Get direct access to the processors array. @return array reference
[ "Get", "direct", "access", "to", "the", "processors", "array", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Analysis.php#L368-L392
train
zircote/swagger-php
src/Analysis.php
Analysis.unregisterProcessor
public static function unregisterProcessor($processor) { $processors = &self::processors(); $key = array_search($processor, $processors, true); if ($key === false) { throw new Exception('Given processor was not registered'); } unset($processors[$key]); }
php
public static function unregisterProcessor($processor) { $processors = &self::processors(); $key = array_search($processor, $processors, true); if ($key === false) { throw new Exception('Given processor was not registered'); } unset($processors[$key]); }
[ "public", "static", "function", "unregisterProcessor", "(", "$", "processor", ")", "{", "$", "processors", "=", "&", "self", "::", "processors", "(", ")", ";", "$", "key", "=", "array_search", "(", "$", "processor", ",", "$", "processors", ",", "true", ")", ";", "if", "(", "$", "key", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Given processor was not registered'", ")", ";", "}", "unset", "(", "$", "processors", "[", "$", "key", "]", ")", ";", "}" ]
Unregister a processor @param Closure $processor
[ "Unregister", "a", "processor" ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Analysis.php#L409-L417
train
zircote/swagger-php
src/StaticAnalyser.php
StaticAnalyser.fromFile
public function fromFile($filename) { if (function_exists('opcache_get_status') && function_exists('opcache_get_configuration')) { if (empty($GLOBALS['openapi_opcache_warning'])) { $GLOBALS['openapi_opcache_warning'] = true; $status = opcache_get_status(); $config = opcache_get_configuration(); if ($status['opcache_enabled'] && $config['directives']['opcache.save_comments'] == false) { Logger::warning("php.ini \"opcache.save_comments = 0\" interferes with extracting annotations.\n[LINK] http://php.net/manual/en/opcache.configuration.php#ini.opcache.save-comments"); } } } $tokens = token_get_all(file_get_contents($filename)); return $this->fromTokens($tokens, new Context(['filename' => $filename])); }
php
public function fromFile($filename) { if (function_exists('opcache_get_status') && function_exists('opcache_get_configuration')) { if (empty($GLOBALS['openapi_opcache_warning'])) { $GLOBALS['openapi_opcache_warning'] = true; $status = opcache_get_status(); $config = opcache_get_configuration(); if ($status['opcache_enabled'] && $config['directives']['opcache.save_comments'] == false) { Logger::warning("php.ini \"opcache.save_comments = 0\" interferes with extracting annotations.\n[LINK] http://php.net/manual/en/opcache.configuration.php#ini.opcache.save-comments"); } } } $tokens = token_get_all(file_get_contents($filename)); return $this->fromTokens($tokens, new Context(['filename' => $filename])); }
[ "public", "function", "fromFile", "(", "$", "filename", ")", "{", "if", "(", "function_exists", "(", "'opcache_get_status'", ")", "&&", "function_exists", "(", "'opcache_get_configuration'", ")", ")", "{", "if", "(", "empty", "(", "$", "GLOBALS", "[", "'openapi_opcache_warning'", "]", ")", ")", "{", "$", "GLOBALS", "[", "'openapi_opcache_warning'", "]", "=", "true", ";", "$", "status", "=", "opcache_get_status", "(", ")", ";", "$", "config", "=", "opcache_get_configuration", "(", ")", ";", "if", "(", "$", "status", "[", "'opcache_enabled'", "]", "&&", "$", "config", "[", "'directives'", "]", "[", "'opcache.save_comments'", "]", "==", "false", ")", "{", "Logger", "::", "warning", "(", "\"php.ini \\\"opcache.save_comments = 0\\\" interferes with extracting annotations.\\n[LINK] http://php.net/manual/en/opcache.configuration.php#ini.opcache.save-comments\"", ")", ";", "}", "}", "}", "$", "tokens", "=", "token_get_all", "(", "file_get_contents", "(", "$", "filename", ")", ")", ";", "return", "$", "this", "->", "fromTokens", "(", "$", "tokens", ",", "new", "Context", "(", "[", "'filename'", "=>", "$", "filename", "]", ")", ")", ";", "}" ]
Extract and process all doc-comments from a file. @param string $filename Path to a php file. @return Analysis
[ "Extract", "and", "process", "all", "doc", "-", "comments", "from", "a", "file", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/StaticAnalyser.php#L31-L46
train
zircote/swagger-php
src/StaticAnalyser.php
StaticAnalyser.fromCode
public function fromCode($code, $context) { $tokens = token_get_all($code); return $this->fromTokens($tokens, $context); }
php
public function fromCode($code, $context) { $tokens = token_get_all($code); return $this->fromTokens($tokens, $context); }
[ "public", "function", "fromCode", "(", "$", "code", ",", "$", "context", ")", "{", "$", "tokens", "=", "token_get_all", "(", "$", "code", ")", ";", "return", "$", "this", "->", "fromTokens", "(", "$", "tokens", ",", "$", "context", ")", ";", "}" ]
Extract and process all doc-comments from the contents. @param string $code PHP code. (including <?php tags) @param Context $context The original location of the contents. @return Analysis
[ "Extract", "and", "process", "all", "doc", "-", "comments", "from", "the", "contents", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/StaticAnalyser.php#L56-L61
train
zircote/swagger-php
src/StaticAnalyser.php
StaticAnalyser.nextToken
private function nextToken(&$tokens, $context) { while (true) { $token = next($tokens); if ($token[0] === T_WHITESPACE) { continue; } if ($token[0] === T_COMMENT) { $pos = strpos($token[1], '@OA\\'); if ($pos) { $line = $context->line ? $context->line + $token[2] : $token[2]; $commentContext = new Context(['line' => $line], $context); Logger::notice('Annotations are only parsed inside `/**` DocBlocks, skipping ' . $commentContext); } continue; } return $token; } }
php
private function nextToken(&$tokens, $context) { while (true) { $token = next($tokens); if ($token[0] === T_WHITESPACE) { continue; } if ($token[0] === T_COMMENT) { $pos = strpos($token[1], '@OA\\'); if ($pos) { $line = $context->line ? $context->line + $token[2] : $token[2]; $commentContext = new Context(['line' => $line], $context); Logger::notice('Annotations are only parsed inside `/**` DocBlocks, skipping ' . $commentContext); } continue; } return $token; } }
[ "private", "function", "nextToken", "(", "&", "$", "tokens", ",", "$", "context", ")", "{", "while", "(", "true", ")", "{", "$", "token", "=", "next", "(", "$", "tokens", ")", ";", "if", "(", "$", "token", "[", "0", "]", "===", "T_WHITESPACE", ")", "{", "continue", ";", "}", "if", "(", "$", "token", "[", "0", "]", "===", "T_COMMENT", ")", "{", "$", "pos", "=", "strpos", "(", "$", "token", "[", "1", "]", ",", "'@OA\\\\'", ")", ";", "if", "(", "$", "pos", ")", "{", "$", "line", "=", "$", "context", "->", "line", "?", "$", "context", "->", "line", "+", "$", "token", "[", "2", "]", ":", "$", "token", "[", "2", "]", ";", "$", "commentContext", "=", "new", "Context", "(", "[", "'line'", "=>", "$", "line", "]", ",", "$", "context", ")", ";", "Logger", "::", "notice", "(", "'Annotations are only parsed inside `/**` DocBlocks, skipping '", ".", "$", "commentContext", ")", ";", "}", "continue", ";", "}", "return", "$", "token", ";", "}", "}" ]
The next non-whitespace, non-comment token. @param array $tokens @param Context $context @return string|array The next token (or false)
[ "The", "next", "non", "-", "whitespace", "non", "-", "comment", "token", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/StaticAnalyser.php#L325-L344
train
zircote/swagger-php
src/Annotations/OpenApi.php
OpenApi.saveAs
public function saveAs($filename, $format = 'auto') { if ($format === 'auto') { $format = strtolower(substr($filename, -5)) === '.json' ? 'json' : 'yaml'; } if (strtolower($format) === 'json') { $content = $this->toJson(); } else { $content = $this->toYaml(); } if (file_put_contents($filename, $content) === false) { throw new Exception('Failed to saveAs("' . $filename . '", "'.$format.'")'); } }
php
public function saveAs($filename, $format = 'auto') { if ($format === 'auto') { $format = strtolower(substr($filename, -5)) === '.json' ? 'json' : 'yaml'; } if (strtolower($format) === 'json') { $content = $this->toJson(); } else { $content = $this->toYaml(); } if (file_put_contents($filename, $content) === false) { throw new Exception('Failed to saveAs("' . $filename . '", "'.$format.'")'); } }
[ "public", "function", "saveAs", "(", "$", "filename", ",", "$", "format", "=", "'auto'", ")", "{", "if", "(", "$", "format", "===", "'auto'", ")", "{", "$", "format", "=", "strtolower", "(", "substr", "(", "$", "filename", ",", "-", "5", ")", ")", "===", "'.json'", "?", "'json'", ":", "'yaml'", ";", "}", "if", "(", "strtolower", "(", "$", "format", ")", "===", "'json'", ")", "{", "$", "content", "=", "$", "this", "->", "toJson", "(", ")", ";", "}", "else", "{", "$", "content", "=", "$", "this", "->", "toYaml", "(", ")", ";", "}", "if", "(", "file_put_contents", "(", "$", "filename", ",", "$", "content", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Failed to saveAs(\"'", ".", "$", "filename", ".", "'\", \"'", ".", "$", "format", ".", "'\")'", ")", ";", "}", "}" ]
Save the OpenAPI documentation to a file. @param string $filename @throws Exception
[ "Save", "the", "OpenAPI", "documentation", "to", "a", "file", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Annotations/OpenApi.php#L143-L157
train
zircote/swagger-php
src/Util.php
Util.removePrefix
private static function removePrefix($str, $prefix) { if (substr($str, 0, strlen($prefix)) == $prefix) { return substr($str, strlen($prefix)); } return null; }
php
private static function removePrefix($str, $prefix) { if (substr($str, 0, strlen($prefix)) == $prefix) { return substr($str, strlen($prefix)); } return null; }
[ "private", "static", "function", "removePrefix", "(", "$", "str", ",", "$", "prefix", ")", "{", "if", "(", "substr", "(", "$", "str", ",", "0", ",", "strlen", "(", "$", "prefix", ")", ")", "==", "$", "prefix", ")", "{", "return", "substr", "(", "$", "str", ",", "strlen", "(", "$", "prefix", ")", ")", ";", "}", "return", "null", ";", "}" ]
Removes a prefix from the start of a string if it exists, or null otherwise. @param string $str @param string $prefix @return null|string
[ "Removes", "a", "prefix", "from", "the", "start", "of", "a", "string", "if", "it", "exists", "or", "null", "otherwise", "." ]
29e913a345932c7dbe2be531377b58b667ae374f
https://github.com/zircote/swagger-php/blob/29e913a345932c7dbe2be531377b58b667ae374f/src/Util.php#L55-L61
train
orchidsoftware/platform
src/Platform/ItemMenu.php
ItemMenu.route
public function route(string $name, array $parameters = [], bool $absolute = true): self { $this->route = route($name, $parameters, $absolute); $this->active([$this->route, $this->route.'/*']); return $this; }
php
public function route(string $name, array $parameters = [], bool $absolute = true): self { $this->route = route($name, $parameters, $absolute); $this->active([$this->route, $this->route.'/*']); return $this; }
[ "public", "function", "route", "(", "string", "$", "name", ",", "array", "$", "parameters", "=", "[", "]", ",", "bool", "$", "absolute", "=", "true", ")", ":", "self", "{", "$", "this", "->", "route", "=", "route", "(", "$", "name", ",", "$", "parameters", ",", "$", "absolute", ")", ";", "$", "this", "->", "active", "(", "[", "$", "this", "->", "route", ",", "$", "this", "->", "route", ".", "'/*'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Generate the URL to a named route. @param string $name @param array $parameters @param bool $absolute @return ItemMenu
[ "Generate", "the", "URL", "to", "a", "named", "route", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/ItemMenu.php#L156-L163
train
orchidsoftware/platform
src/Screen/Fields/Picture.php
Picture.targetId
public function targetId(): self { $this->set('target', 'id'); $this->addBeforeRender(function () { $value = (string) $this->get('value'); if (! ctype_digit($value)) { return; } /** @var Attachment $attach */ $attach = Dashboard::model(Attachment::class); $url = optional($attach::find($value))->url(); $this->set('url', $url); }); return $this; }
php
public function targetId(): self { $this->set('target', 'id'); $this->addBeforeRender(function () { $value = (string) $this->get('value'); if (! ctype_digit($value)) { return; } /** @var Attachment $attach */ $attach = Dashboard::model(Attachment::class); $url = optional($attach::find($value))->url(); $this->set('url', $url); }); return $this; }
[ "public", "function", "targetId", "(", ")", ":", "self", "{", "$", "this", "->", "set", "(", "'target'", ",", "'id'", ")", ";", "$", "this", "->", "addBeforeRender", "(", "function", "(", ")", "{", "$", "value", "=", "(", "string", ")", "$", "this", "->", "get", "(", "'value'", ")", ";", "if", "(", "!", "ctype_digit", "(", "$", "value", ")", ")", "{", "return", ";", "}", "/** @var Attachment $attach */", "$", "attach", "=", "Dashboard", "::", "model", "(", "Attachment", "::", "class", ")", ";", "$", "url", "=", "optional", "(", "$", "attach", "::", "find", "(", "$", "value", ")", ")", "->", "url", "(", ")", ";", "$", "this", "->", "set", "(", "'url'", ",", "$", "url", ")", ";", "}", ")", ";", "return", "$", "this", ";", "}" ]
The stored value will be in the form of id attachment. @return self
[ "The", "stored", "value", "will", "be", "in", "the", "form", "of", "id", "attachment", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Screen/Fields/Picture.php#L83-L103
train
orchidsoftware/platform
src/Platform/Menu.php
Menu.add
public function add(string $place, ItemMenu $itemMenu) { $arg = get_object_vars($itemMenu); if (array_key_exists('show', $arg) && ! $arg['show']) { return $this; } $this->location = $place; $this->arg = $arg; $this->sort = $arg['sort']; $this->item = [ 'location' => $this->location, 'arg' => $this->arg, 'sort' => $this->sort, ]; $this->container[$this->arg['slug']] = $this->item; return $this; }
php
public function add(string $place, ItemMenu $itemMenu) { $arg = get_object_vars($itemMenu); if (array_key_exists('show', $arg) && ! $arg['show']) { return $this; } $this->location = $place; $this->arg = $arg; $this->sort = $arg['sort']; $this->item = [ 'location' => $this->location, 'arg' => $this->arg, 'sort' => $this->sort, ]; $this->container[$this->arg['slug']] = $this->item; return $this; }
[ "public", "function", "add", "(", "string", "$", "place", ",", "ItemMenu", "$", "itemMenu", ")", "{", "$", "arg", "=", "get_object_vars", "(", "$", "itemMenu", ")", ";", "if", "(", "array_key_exists", "(", "'show'", ",", "$", "arg", ")", "&&", "!", "$", "arg", "[", "'show'", "]", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "location", "=", "$", "place", ";", "$", "this", "->", "arg", "=", "$", "arg", ";", "$", "this", "->", "sort", "=", "$", "arg", "[", "'sort'", "]", ";", "$", "this", "->", "item", "=", "[", "'location'", "=>", "$", "this", "->", "location", ",", "'arg'", "=>", "$", "this", "->", "arg", ",", "'sort'", "=>", "$", "this", "->", "sort", ",", "]", ";", "$", "this", "->", "container", "[", "$", "this", "->", "arg", "[", "'slug'", "]", "]", "=", "$", "this", "->", "item", ";", "return", "$", "this", ";", "}" ]
Adding a new element to the container. @param string $place @param ItemMenu $itemMenu @return $this
[ "Adding", "a", "new", "element", "to", "the", "container", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Menu.php#L79-L100
train
orchidsoftware/platform
src/Platform/Menu.php
Menu.render
public function render(string $location, string $template = 'platform::partials.mainMenu'): string { $this->checkAccess(); return $this->findAllChildren($location) ->sortBy('sort') ->map(function ($value) use ($template) { return view($template, $value)->render(); }) ->implode(' '); }
php
public function render(string $location, string $template = 'platform::partials.mainMenu'): string { $this->checkAccess(); return $this->findAllChildren($location) ->sortBy('sort') ->map(function ($value) use ($template) { return view($template, $value)->render(); }) ->implode(' '); }
[ "public", "function", "render", "(", "string", "$", "location", ",", "string", "$", "template", "=", "'platform::partials.mainMenu'", ")", ":", "string", "{", "$", "this", "->", "checkAccess", "(", ")", ";", "return", "$", "this", "->", "findAllChildren", "(", "$", "location", ")", "->", "sortBy", "(", "'sort'", ")", "->", "map", "(", "function", "(", "$", "value", ")", "use", "(", "$", "template", ")", "{", "return", "view", "(", "$", "template", ",", "$", "value", ")", "->", "render", "(", ")", ";", "}", ")", "->", "implode", "(", "' '", ")", ";", "}" ]
Generate on the menu display. @param string $location @param string $template @return string
[ "Generate", "on", "the", "menu", "display", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Menu.php#L110-L120
train
orchidsoftware/platform
src/Platform/Http/Controllers/Systems/ResourceController.php
ResourceController.show
public function show(string $package, string $path, Dashboard $dashboard) { $dir = $dashboard ->getPublicDirectory() ->get($package); abort_if(is_null($dir), 404); $resources = (new Finder()) ->ignoreUnreadableDirs() ->followLinks() ->in($dir) ->files() ->path(dirname($path)) ->name(basename($path)); $iterator = tap($resources->getIterator()) ->rewind(); $this->resource = $iterator->current(); abort_if(is_null($this->resource), 404); $mime = new MimeTypes(); $mime = $mime->getMimeType($this->resource->getExtension()); return response()->file($this->resource->getRealPath(), [ 'Content-Type' => $mime ?? 'text/plain', 'Cache-Control' => 'public, max-age=31536000', ]); }
php
public function show(string $package, string $path, Dashboard $dashboard) { $dir = $dashboard ->getPublicDirectory() ->get($package); abort_if(is_null($dir), 404); $resources = (new Finder()) ->ignoreUnreadableDirs() ->followLinks() ->in($dir) ->files() ->path(dirname($path)) ->name(basename($path)); $iterator = tap($resources->getIterator()) ->rewind(); $this->resource = $iterator->current(); abort_if(is_null($this->resource), 404); $mime = new MimeTypes(); $mime = $mime->getMimeType($this->resource->getExtension()); return response()->file($this->resource->getRealPath(), [ 'Content-Type' => $mime ?? 'text/plain', 'Cache-Control' => 'public, max-age=31536000', ]); }
[ "public", "function", "show", "(", "string", "$", "package", ",", "string", "$", "path", ",", "Dashboard", "$", "dashboard", ")", "{", "$", "dir", "=", "$", "dashboard", "->", "getPublicDirectory", "(", ")", "->", "get", "(", "$", "package", ")", ";", "abort_if", "(", "is_null", "(", "$", "dir", ")", ",", "404", ")", ";", "$", "resources", "=", "(", "new", "Finder", "(", ")", ")", "->", "ignoreUnreadableDirs", "(", ")", "->", "followLinks", "(", ")", "->", "in", "(", "$", "dir", ")", "->", "files", "(", ")", "->", "path", "(", "dirname", "(", "$", "path", ")", ")", "->", "name", "(", "basename", "(", "$", "path", ")", ")", ";", "$", "iterator", "=", "tap", "(", "$", "resources", "->", "getIterator", "(", ")", ")", "->", "rewind", "(", ")", ";", "$", "this", "->", "resource", "=", "$", "iterator", "->", "current", "(", ")", ";", "abort_if", "(", "is_null", "(", "$", "this", "->", "resource", ")", ",", "404", ")", ";", "$", "mime", "=", "new", "MimeTypes", "(", ")", ";", "$", "mime", "=", "$", "mime", "->", "getMimeType", "(", "$", "this", "->", "resource", "->", "getExtension", "(", ")", ")", ";", "return", "response", "(", ")", "->", "file", "(", "$", "this", "->", "resource", "->", "getRealPath", "(", ")", ",", "[", "'Content-Type'", "=>", "$", "mime", "??", "'text/plain'", ",", "'Cache-Control'", "=>", "'public, max-age=31536000'", ",", "]", ")", ";", "}" ]
Serve the requested resource. @param string $package @param string $path @param Dashboard $dashboard @return \Symfony\Component\HttpFoundation\BinaryFileResponse
[ "Serve", "the", "requested", "resource", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Http/Controllers/Systems/ResourceController.php#L31-L61
train
orchidsoftware/platform
src/Press/Models/Post.php
Post.getEntityObject
public function getEntityObject($slug = null) { if (! is_null($this->entity)) { return $this->entity; } return $this->getEntity($slug ?? $this->getAttribute('type'))->entity; }
php
public function getEntityObject($slug = null) { if (! is_null($this->entity)) { return $this->entity; } return $this->getEntity($slug ?? $this->getAttribute('type'))->entity; }
[ "public", "function", "getEntityObject", "(", "$", "slug", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "entity", ")", ")", "{", "return", "$", "this", "->", "entity", ";", "}", "return", "$", "this", "->", "getEntity", "(", "$", "slug", "??", "$", "this", "->", "getAttribute", "(", "'type'", ")", ")", "->", "entity", ";", "}" ]
Get Behavior Class. @param string|null $slug @throws \Throwable|EntityTypeException @return \Orchid\Press\Entities\Many|\Orchid\Press\Entities\Single|null
[ "Get", "Behavior", "Class", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Press/Models/Post.php#L178-L185
train
orchidsoftware/platform
src/Press/Builders/TaxonomyBuilder.php
TaxonomyBuilder.slug
public function slug($slug = null): self { if (! empty($slug)) { // set this slug to be used in with callback $this->slug = $slug; // exception to filter on specific slug $exception = function ($query) { $query->where('slug', '=', $this->slug); }; // load term to filter return $this->whereHas('term', $exception); } return $this; }
php
public function slug($slug = null): self { if (! empty($slug)) { // set this slug to be used in with callback $this->slug = $slug; // exception to filter on specific slug $exception = function ($query) { $query->where('slug', '=', $this->slug); }; // load term to filter return $this->whereHas('term', $exception); } return $this; }
[ "public", "function", "slug", "(", "$", "slug", "=", "null", ")", ":", "self", "{", "if", "(", "!", "empty", "(", "$", "slug", ")", ")", "{", "// set this slug to be used in with callback", "$", "this", "->", "slug", "=", "$", "slug", ";", "// exception to filter on specific slug", "$", "exception", "=", "function", "(", "$", "query", ")", "{", "$", "query", "->", "where", "(", "'slug'", ",", "'='", ",", "$", "this", "->", "slug", ")", ";", "}", ";", "// load term to filter", "return", "$", "this", "->", "whereHas", "(", "'term'", ",", "$", "exception", ")", ";", "}", "return", "$", "this", ";", "}" ]
Get a term taxonomy by specific slug. @param string @return \Orchid\Press\Builders\TaxonomyBuilder
[ "Get", "a", "term", "taxonomy", "by", "specific", "slug", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Press/Builders/TaxonomyBuilder.php#L43-L59
train
orchidsoftware/platform
src/Screen/Fields/DateTimer.php
DateTimer.noCalendar
public function noCalendar(bool $noCalendar = true) : self { $this->enableTime(); $this->set('data-fields--datetime-no-calendar', var_export($noCalendar, true)); return $this; }
php
public function noCalendar(bool $noCalendar = true) : self { $this->enableTime(); $this->set('data-fields--datetime-no-calendar', var_export($noCalendar, true)); return $this; }
[ "public", "function", "noCalendar", "(", "bool", "$", "noCalendar", "=", "true", ")", ":", "self", "{", "$", "this", "->", "enableTime", "(", ")", ";", "$", "this", "->", "set", "(", "'data-fields--datetime-no-calendar'", ",", "var_export", "(", "$", "noCalendar", ",", "true", ")", ")", ";", "return", "$", "this", ";", "}" ]
Disable calendar for the field and show only time. @param bool $noCalendar @return $this
[ "Disable", "calendar", "for", "the", "field", "and", "show", "only", "time", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Screen/Fields/DateTimer.php#L169-L175
train
orchidsoftware/platform
src/Press/Entities/Many.php
Many.getFilters
public function getFilters(): Collection { $filters = collect(); foreach ($this->filters() as $filter) { $filter = new $filter($this); $filters->push($filter); } return $filters; }
php
public function getFilters(): Collection { $filters = collect(); foreach ($this->filters() as $filter) { $filter = new $filter($this); $filters->push($filter); } return $filters; }
[ "public", "function", "getFilters", "(", ")", ":", "Collection", "{", "$", "filters", "=", "collect", "(", ")", ";", "foreach", "(", "$", "this", "->", "filters", "(", ")", "as", "$", "filter", ")", "{", "$", "filter", "=", "new", "$", "filter", "(", "$", "this", ")", ";", "$", "filters", "->", "push", "(", "$", "filter", ")", ";", "}", "return", "$", "filters", ";", "}" ]
Get all the filters. @return Collection
[ "Get", "all", "the", "filters", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Press/Entities/Many.php#L66-L75
train
orchidsoftware/platform
src/Platform/Updates.php
Updates.getStatus
public function getStatus(): bool { foreach ($this->requestVersion() as $key => $version) { if (! Str::contains($key, 'dev')) { continue; } if (version_compare($version['version'], $this->currentVersion, '>')) { return true; } } return false; }
php
public function getStatus(): bool { foreach ($this->requestVersion() as $key => $version) { if (! Str::contains($key, 'dev')) { continue; } if (version_compare($version['version'], $this->currentVersion, '>')) { return true; } } return false; }
[ "public", "function", "getStatus", "(", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "requestVersion", "(", ")", "as", "$", "key", "=>", "$", "version", ")", "{", "if", "(", "!", "Str", "::", "contains", "(", "$", "key", ",", "'dev'", ")", ")", "{", "continue", ";", "}", "if", "(", "version_compare", "(", "$", "version", "[", "'version'", "]", ",", "$", "this", "->", "currentVersion", ",", "'>'", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Verify that the version of the package you are using is the latest version. @return bool
[ "Verify", "that", "the", "version", "of", "the", "package", "you", "are", "using", "is", "the", "latest", "version", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Updates.php#L93-L106
train
orchidsoftware/platform
src/Platform/Updates.php
Updates.requestVersion
public function requestVersion(): array { try { $versions = json_decode(file_get_contents($this->apiURL), true)['packages']['orchid/platform']; return array_reverse($versions); } catch (\Exception $exception) { Log::alert($exception->getMessage()); return [['version' => '0.0.0']]; } }
php
public function requestVersion(): array { try { $versions = json_decode(file_get_contents($this->apiURL), true)['packages']['orchid/platform']; return array_reverse($versions); } catch (\Exception $exception) { Log::alert($exception->getMessage()); return [['version' => '0.0.0']]; } }
[ "public", "function", "requestVersion", "(", ")", ":", "array", "{", "try", "{", "$", "versions", "=", "json_decode", "(", "file_get_contents", "(", "$", "this", "->", "apiURL", ")", ",", "true", ")", "[", "'packages'", "]", "[", "'orchid/platform'", "]", ";", "return", "array_reverse", "(", "$", "versions", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "Log", "::", "alert", "(", "$", "exception", "->", "getMessage", "(", ")", ")", ";", "return", "[", "[", "'version'", "=>", "'0.0.0'", "]", "]", ";", "}", "}" ]
Make a request for Packagist API. @return array
[ "Make", "a", "request", "for", "Packagist", "API", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Updates.php#L113-L124
train
orchidsoftware/platform
src/Screen/Builder.php
Builder.generateForm
public function generateForm(): string { foreach ($this->fields as $field) { if (is_array($field)) { $this->renderGroup($field); continue; } $this->form .= $this->render($field); } return $this->form; }
php
public function generateForm(): string { foreach ($this->fields as $field) { if (is_array($field)) { $this->renderGroup($field); continue; } $this->form .= $this->render($field); } return $this->form; }
[ "public", "function", "generateForm", "(", ")", ":", "string", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", ")", "{", "if", "(", "is_array", "(", "$", "field", ")", ")", "{", "$", "this", "->", "renderGroup", "(", "$", "field", ")", ";", "continue", ";", "}", "$", "this", "->", "form", ".=", "$", "this", "->", "render", "(", "$", "field", ")", ";", "}", "return", "$", "this", "->", "form", ";", "}" ]
Generate a ready-made html form for display to the user. @throws \Throwable @return string
[ "Generate", "a", "ready", "-", "made", "html", "form", "for", "display", "to", "the", "user", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Screen/Builder.php#L90-L102
train
orchidsoftware/platform
src/Screen/Builder.php
Builder.render
private function render(Field $field) { $field->set('lang', $this->language); $field->set('prefix', $this->buildPrefix($field)); foreach ($this->fill($field->getAttributes()) as $key => $value) { $field->set($key, $value); } return $field->render(); }
php
private function render(Field $field) { $field->set('lang', $this->language); $field->set('prefix', $this->buildPrefix($field)); foreach ($this->fill($field->getAttributes()) as $key => $value) { $field->set($key, $value); } return $field->render(); }
[ "private", "function", "render", "(", "Field", "$", "field", ")", "{", "$", "field", "->", "set", "(", "'lang'", ",", "$", "this", "->", "language", ")", ";", "$", "field", "->", "set", "(", "'prefix'", ",", "$", "this", "->", "buildPrefix", "(", "$", "field", ")", ")", ";", "foreach", "(", "$", "this", "->", "fill", "(", "$", "field", "->", "getAttributes", "(", ")", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "field", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "field", "->", "render", "(", ")", ";", "}" ]
Render field for forms. @param Field $field @throws \Throwable @return mixed
[ "Render", "field", "for", "forms", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Screen/Builder.php#L133-L143
train
orchidsoftware/platform
src/Screen/Builder.php
Builder.getValue
private function getValue(string $key, $value = null) { if (! is_null($this->language)) { $key = $this->language.'.'.$key; } if (! is_null($this->prefix)) { $key = $this->prefix.'.'.$key; } $data = $this->data->getContent($key); // default value if (is_null($data)) { return $value; } if ($value instanceof \Closure) { return $value($data, $this->data); } return $data; }
php
private function getValue(string $key, $value = null) { if (! is_null($this->language)) { $key = $this->language.'.'.$key; } if (! is_null($this->prefix)) { $key = $this->prefix.'.'.$key; } $data = $this->data->getContent($key); // default value if (is_null($data)) { return $value; } if ($value instanceof \Closure) { return $value($data, $this->data); } return $data; }
[ "private", "function", "getValue", "(", "string", "$", "key", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "language", ")", ")", "{", "$", "key", "=", "$", "this", "->", "language", ".", "'.'", ".", "$", "key", ";", "}", "if", "(", "!", "is_null", "(", "$", "this", "->", "prefix", ")", ")", "{", "$", "key", "=", "$", "this", "->", "prefix", ".", "'.'", ".", "$", "key", ";", "}", "$", "data", "=", "$", "this", "->", "data", "->", "getContent", "(", "$", "key", ")", ";", "// default value", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "return", "$", "value", ";", "}", "if", "(", "$", "value", "instanceof", "\\", "Closure", ")", "{", "return", "$", "value", "(", "$", "data", ",", "$", "this", "->", "data", ")", ";", "}", "return", "$", "data", ";", "}" ]
Gets value of Repository. @param string $key @param mixed|null $value @return mixed
[ "Gets", "value", "of", "Repository", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Screen/Builder.php#L210-L232
train
orchidsoftware/platform
src/Platform/Dashboard.php
Dashboard.prefix
public static function prefix(string $path = ''): string { $prefix = config('platform.prefix'); return Str::start($prefix.$path, '/'); }
php
public static function prefix(string $path = ''): string { $prefix = config('platform.prefix'); return Str::start($prefix.$path, '/'); }
[ "public", "static", "function", "prefix", "(", "string", "$", "path", "=", "''", ")", ":", "string", "{", "$", "prefix", "=", "config", "(", "'platform.prefix'", ")", ";", "return", "Str", "::", "start", "(", "$", "prefix", ".", "$", "path", ",", "'/'", ")", ";", "}" ]
Get the route with the dashboard prefix. @param string $path @return string
[ "Get", "the", "route", "with", "the", "dashboard", "prefix", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Dashboard.php#L92-L97
train
orchidsoftware/platform
src/Platform/Dashboard.php
Dashboard.model
public static function model(string $key, string $default = null) { return Arr::get(static::$options, 'models.'.$key, $default ?? $key); }
php
public static function model(string $key, string $default = null) { return Arr::get(static::$options, 'models.'.$key, $default ?? $key); }
[ "public", "static", "function", "model", "(", "string", "$", "key", ",", "string", "$", "default", "=", "null", ")", "{", "return", "Arr", "::", "get", "(", "static", "::", "$", "options", ",", "'models.'", ".", "$", "key", ",", "$", "default", "??", "$", "key", ")", ";", "}" ]
Get the class name for a given Dashboard model. @param string $key @param null|string $default @return string
[ "Get", "the", "class", "name", "for", "a", "given", "Dashboard", "model", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Dashboard.php#L145-L148
train
orchidsoftware/platform
src/Platform/Dashboard.php
Dashboard.getResource
public function getResource($key = null) { if (is_null($key)) { return $this->resources; } return $this->resources->get($key); }
php
public function getResource($key = null) { if (is_null($key)) { return $this->resources; } return $this->resources->get($key); }
[ "public", "function", "getResource", "(", "$", "key", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "resources", ";", "}", "return", "$", "this", "->", "resources", "->", "get", "(", "$", "key", ")", ";", "}" ]
Return CSS\JS. @param null $key @return array|\Illuminate\Support\Collection|mixed
[ "Return", "CSS", "\\", "JS", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Dashboard.php#L235-L242
train
orchidsoftware/platform
src/Access/UserAccess.php
UserAccess.removeRoleBySlug
public function removeRoleBySlug($slug): int { $role = $this->roles()->where('slug', $slug)->first(); return $this->roles()->detach($role); }
php
public function removeRoleBySlug($slug): int { $role = $this->roles()->where('slug', $slug)->first(); return $this->roles()->detach($role); }
[ "public", "function", "removeRoleBySlug", "(", "$", "slug", ")", ":", "int", "{", "$", "role", "=", "$", "this", "->", "roles", "(", ")", "->", "where", "(", "'slug'", ",", "$", "slug", ")", "->", "first", "(", ")", ";", "return", "$", "this", "->", "roles", "(", ")", "->", "detach", "(", "$", "role", ")", ";", "}" ]
Remove Role Slug. @param $slug @return int
[ "Remove", "Role", "Slug", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Access/UserAccess.php#L105-L110
train
orchidsoftware/platform
src/Platform/Models/Role.php
Role.setPermissionsAttribute
public function setPermissionsAttribute(array $permissions = []) { foreach ($permissions as $key => $value) { $permissions[$key] = (bool) $value; } $this->attributes['permissions'] = json_encode($permissions ?? []); }
php
public function setPermissionsAttribute(array $permissions = []) { foreach ($permissions as $key => $value) { $permissions[$key] = (bool) $value; } $this->attributes['permissions'] = json_encode($permissions ?? []); }
[ "public", "function", "setPermissionsAttribute", "(", "array", "$", "permissions", "=", "[", "]", ")", "{", "foreach", "(", "$", "permissions", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "permissions", "[", "$", "key", "]", "=", "(", "bool", ")", "$", "value", ";", "}", "$", "this", "->", "attributes", "[", "'permissions'", "]", "=", "json_encode", "(", "$", "permissions", "??", "[", "]", ")", ";", "}" ]
Set permission as boolean. @param array $permissions
[ "Set", "permission", "as", "boolean", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Platform/Models/Role.php#L63-L69
train
orchidsoftware/platform
src/Press/Providers/PressServiceProvider.php
PressServiceProvider.registerConfig
protected function registerConfig() { $this->publishes([ realpath(PLATFORM_PATH.'/config/press.php') => config_path('press.php'), ], 'config'); $this->mergeConfigFrom( realpath(PLATFORM_PATH.'/config/press.php'), 'press' ); return $this; }
php
protected function registerConfig() { $this->publishes([ realpath(PLATFORM_PATH.'/config/press.php') => config_path('press.php'), ], 'config'); $this->mergeConfigFrom( realpath(PLATFORM_PATH.'/config/press.php'), 'press' ); return $this; }
[ "protected", "function", "registerConfig", "(", ")", "{", "$", "this", "->", "publishes", "(", "[", "realpath", "(", "PLATFORM_PATH", ".", "'/config/press.php'", ")", "=>", "config_path", "(", "'press.php'", ")", ",", "]", ",", "'config'", ")", ";", "$", "this", "->", "mergeConfigFrom", "(", "realpath", "(", "PLATFORM_PATH", ".", "'/config/press.php'", ")", ",", "'press'", ")", ";", "return", "$", "this", ";", "}" ]
Register config. @return $this
[ "Register", "config", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Press/Providers/PressServiceProvider.php#L88-L99
train
orchidsoftware/platform
install-stubs/Orchid/Entities/Post.php
Post.grid
public function grid(): array { return [ TD::set('id', 'ID') ->align(TD::ALIGN_CENTER) ->width('100px') ->filter('numeric') ->sort() ->linkPost(), TD::set('name', 'Name') ->width('250px') ->locale() ->column('content.name') ->filter('text') ->sort() ->linkPost('name'), TD::set('status') ->sort(), TD::set('phone', 'Phone') ->locale() ->column('content.phone') ->filter('text') ->linkPost('phone'), TD::set('publish_at', 'Date of publication') ->filter('date') ->sort() ->align(TD::ALIGN_RIGHT) ->render(function ($item) { return optional($item->publish_at)->toDateString(); }), TD::set('created_at', 'Date of creation') ->filter('date') ->align(TD::ALIGN_RIGHT) ->sort() ->render(function ($item) { return $item->created_at->toDateString(); }), ]; }
php
public function grid(): array { return [ TD::set('id', 'ID') ->align(TD::ALIGN_CENTER) ->width('100px') ->filter('numeric') ->sort() ->linkPost(), TD::set('name', 'Name') ->width('250px') ->locale() ->column('content.name') ->filter('text') ->sort() ->linkPost('name'), TD::set('status') ->sort(), TD::set('phone', 'Phone') ->locale() ->column('content.phone') ->filter('text') ->linkPost('phone'), TD::set('publish_at', 'Date of publication') ->filter('date') ->sort() ->align(TD::ALIGN_RIGHT) ->render(function ($item) { return optional($item->publish_at)->toDateString(); }), TD::set('created_at', 'Date of creation') ->filter('date') ->align(TD::ALIGN_RIGHT) ->sort() ->render(function ($item) { return $item->created_at->toDateString(); }), ]; }
[ "public", "function", "grid", "(", ")", ":", "array", "{", "return", "[", "TD", "::", "set", "(", "'id'", ",", "'ID'", ")", "->", "align", "(", "TD", "::", "ALIGN_CENTER", ")", "->", "width", "(", "'100px'", ")", "->", "filter", "(", "'numeric'", ")", "->", "sort", "(", ")", "->", "linkPost", "(", ")", ",", "TD", "::", "set", "(", "'name'", ",", "'Name'", ")", "->", "width", "(", "'250px'", ")", "->", "locale", "(", ")", "->", "column", "(", "'content.name'", ")", "->", "filter", "(", "'text'", ")", "->", "sort", "(", ")", "->", "linkPost", "(", "'name'", ")", ",", "TD", "::", "set", "(", "'status'", ")", "->", "sort", "(", ")", ",", "TD", "::", "set", "(", "'phone'", ",", "'Phone'", ")", "->", "locale", "(", ")", "->", "column", "(", "'content.phone'", ")", "->", "filter", "(", "'text'", ")", "->", "linkPost", "(", "'phone'", ")", ",", "TD", "::", "set", "(", "'publish_at'", ",", "'Date of publication'", ")", "->", "filter", "(", "'date'", ")", "->", "sort", "(", ")", "->", "align", "(", "TD", "::", "ALIGN_RIGHT", ")", "->", "render", "(", "function", "(", "$", "item", ")", "{", "return", "optional", "(", "$", "item", "->", "publish_at", ")", "->", "toDateString", "(", ")", ";", "}", ")", ",", "TD", "::", "set", "(", "'created_at'", ",", "'Date of creation'", ")", "->", "filter", "(", "'date'", ")", "->", "align", "(", "TD", "::", "ALIGN_RIGHT", ")", "->", "sort", "(", ")", "->", "render", "(", "function", "(", "$", "item", ")", "{", "return", "$", "item", "->", "created_at", "->", "toDateString", "(", ")", ";", "}", ")", ",", "]", ";", "}" ]
Grid View for post type.
[ "Grid", "View", "for", "post", "type", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/install-stubs/Orchid/Entities/Post.php#L243-L286
train
orchidsoftware/platform
src/Attachment/Models/Attachment.php
Attachment.url
public function url($default = null): ?string { $disk = $this->getAttribute('disk'); if (Storage::disk($disk)->exists($this->physicalPath())) { return Storage::disk($disk)->url($this->physicalPath()); } return $default; }
php
public function url($default = null): ?string { $disk = $this->getAttribute('disk'); if (Storage::disk($disk)->exists($this->physicalPath())) { return Storage::disk($disk)->url($this->physicalPath()); } return $default; }
[ "public", "function", "url", "(", "$", "default", "=", "null", ")", ":", "?", "string", "{", "$", "disk", "=", "$", "this", "->", "getAttribute", "(", "'disk'", ")", ";", "if", "(", "Storage", "::", "disk", "(", "$", "disk", ")", "->", "exists", "(", "$", "this", "->", "physicalPath", "(", ")", ")", ")", "{", "return", "Storage", "::", "disk", "(", "$", "disk", ")", "->", "url", "(", "$", "this", "->", "physicalPath", "(", ")", ")", ";", "}", "return", "$", "default", ";", "}" ]
Return the address by which you can access the file. @param string $default @return string|null
[ "Return", "the", "address", "by", "which", "you", "can", "access", "the", "file", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Attachment/Models/Attachment.php#L68-L77
train
orchidsoftware/platform
src/Attachment/Models/Attachment.php
Attachment.getMimeType
public function getMimeType(): string { $mimes = new MimeTypes(); $type = $mimes->getMimeType($this->getAttribute('extension')); return $type ?? 'unknown'; }
php
public function getMimeType(): string { $mimes = new MimeTypes(); $type = $mimes->getMimeType($this->getAttribute('extension')); return $type ?? 'unknown'; }
[ "public", "function", "getMimeType", "(", ")", ":", "string", "{", "$", "mimes", "=", "new", "MimeTypes", "(", ")", ";", "$", "type", "=", "$", "mimes", "->", "getMimeType", "(", "$", "this", "->", "getAttribute", "(", "'extension'", ")", ")", ";", "return", "$", "type", "??", "'unknown'", ";", "}" ]
Get MIME type for file. @return string
[ "Get", "MIME", "type", "for", "file", "." ]
4930f527629e11c404d0a89592e67c857a29b8ff
https://github.com/orchidsoftware/platform/blob/4930f527629e11c404d0a89592e67c857a29b8ff/src/Attachment/Models/Attachment.php#L152-L159
train