code
stringlengths 17
247k
| docstring
stringlengths 30
30.3k
| func_name
stringlengths 1
89
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
153
| url
stringlengths 51
209
| license
stringclasses 4
values |
---|---|---|---|---|---|---|---|
public function getChunkInfo()
{
return $this->readOneof(1);
} | Chunk information.
Generated from protobuf field <code>.google.cloud.discoveryengine.v1.AnswerQueryRequest.EndUserSpec.EndUserMetaData.ChunkInfo chunk_info = 1;</code>
@return \Google\Cloud\DiscoveryEngine\V1\AnswerQueryRequest\EndUserSpec\EndUserMetaData\ChunkInfo|null | getChunkInfo | php | googleapis/google-cloud-php | DiscoveryEngine/src/V1/AnswerQueryRequest/EndUserSpec/EndUserMetaData.php | https://github.com/googleapis/google-cloud-php/blob/master/DiscoveryEngine/src/V1/AnswerQueryRequest/EndUserSpec/EndUserMetaData.php | Apache-2.0 |
public function setChunkInfo($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\DiscoveryEngine\V1\AnswerQueryRequest\EndUserSpec\EndUserMetaData\ChunkInfo::class);
$this->writeOneof(1, $var);
return $this;
} | Chunk information.
Generated from protobuf field <code>.google.cloud.discoveryengine.v1.AnswerQueryRequest.EndUserSpec.EndUserMetaData.ChunkInfo chunk_info = 1;</code>
@param \Google\Cloud\DiscoveryEngine\V1\AnswerQueryRequest\EndUserSpec\EndUserMetaData\ChunkInfo $var
@return $this | setChunkInfo | php | googleapis/google-cloud-php | DiscoveryEngine/src/V1/AnswerQueryRequest/EndUserSpec/EndUserMetaData.php | https://github.com/googleapis/google-cloud-php/blob/master/DiscoveryEngine/src/V1/AnswerQueryRequest/EndUserSpec/EndUserMetaData.php | Apache-2.0 |
public function getSavedQuery()
{
return $this->saved_query;
} | Required. The saved_query details. The `name` field must be empty as it
will be generated based on the parent and saved_query_id.
Generated from protobuf field <code>.google.cloud.asset.v1.SavedQuery saved_query = 2 [(.google.api.field_behavior) = REQUIRED];</code>
@return \Google\Cloud\Asset\V1\SavedQuery|null | getSavedQuery | php | googleapis/google-cloud-php | Asset/src/V1/CreateSavedQueryRequest.php | https://github.com/googleapis/google-cloud-php/blob/master/Asset/src/V1/CreateSavedQueryRequest.php | Apache-2.0 |
public function setSavedQuery($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Asset\V1\SavedQuery::class);
$this->saved_query = $var;
return $this;
} | Required. The saved_query details. The `name` field must be empty as it
will be generated based on the parent and saved_query_id.
Generated from protobuf field <code>.google.cloud.asset.v1.SavedQuery saved_query = 2 [(.google.api.field_behavior) = REQUIRED];</code>
@param \Google\Cloud\Asset\V1\SavedQuery $var
@return $this | setSavedQuery | php | googleapis/google-cloud-php | Asset/src/V1/CreateSavedQueryRequest.php | https://github.com/googleapis/google-cloud-php/blob/master/Asset/src/V1/CreateSavedQueryRequest.php | Apache-2.0 |
public function getOrgPolicyViolationInfo()
{
return $this->org_policy_violation_info;
} | Indicates the orgpolicy violations for this resource.
Generated from protobuf field <code>.google.cloud.audit.OrgPolicyViolationInfo org_policy_violation_info = 1;</code>
@return \Google\Cloud\Audit\OrgPolicyViolationInfo|null | getOrgPolicyViolationInfo | php | googleapis/google-cloud-php | CloudCommonProtos/src/Audit/PolicyViolationInfo.php | https://github.com/googleapis/google-cloud-php/blob/master/CloudCommonProtos/src/Audit/PolicyViolationInfo.php | Apache-2.0 |
public function setOrgPolicyViolationInfo($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\Audit\OrgPolicyViolationInfo::class);
$this->org_policy_violation_info = $var;
return $this;
} | Indicates the orgpolicy violations for this resource.
Generated from protobuf field <code>.google.cloud.audit.OrgPolicyViolationInfo org_policy_violation_info = 1;</code>
@param \Google\Cloud\Audit\OrgPolicyViolationInfo $var
@return $this | setOrgPolicyViolationInfo | php | googleapis/google-cloud-php | CloudCommonProtos/src/Audit/PolicyViolationInfo.php | https://github.com/googleapis/google-cloud-php/blob/master/CloudCommonProtos/src/Audit/PolicyViolationInfo.php | Apache-2.0 |
public function getTargetProjectId()
{
return $this->target_project_id;
} | Required. The target_project identifier.
Generated from protobuf field <code>string target_project_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
@return string | getTargetProjectId | php | googleapis/google-cloud-php | VmMigration/src/V1/CreateTargetProjectRequest.php | https://github.com/googleapis/google-cloud-php/blob/master/VmMigration/src/V1/CreateTargetProjectRequest.php | Apache-2.0 |
public function setTargetProjectId($var)
{
GPBUtil::checkString($var, True);
$this->target_project_id = $var;
return $this;
} | Required. The target_project identifier.
Generated from protobuf field <code>string target_project_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
@param string $var
@return $this | setTargetProjectId | php | googleapis/google-cloud-php | VmMigration/src/V1/CreateTargetProjectRequest.php | https://github.com/googleapis/google-cloud-php/blob/master/VmMigration/src/V1/CreateTargetProjectRequest.php | Apache-2.0 |
public function getTargetProject()
{
return $this->target_project;
} | Required. The create request body.
Generated from protobuf field <code>.google.cloud.vmmigration.v1.TargetProject target_project = 3 [(.google.api.field_behavior) = REQUIRED];</code>
@return \Google\Cloud\VMMigration\V1\TargetProject|null | getTargetProject | php | googleapis/google-cloud-php | VmMigration/src/V1/CreateTargetProjectRequest.php | https://github.com/googleapis/google-cloud-php/blob/master/VmMigration/src/V1/CreateTargetProjectRequest.php | Apache-2.0 |
public function setTargetProject($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\VMMigration\V1\TargetProject::class);
$this->target_project = $var;
return $this;
} | Required. The create request body.
Generated from protobuf field <code>.google.cloud.vmmigration.v1.TargetProject target_project = 3 [(.google.api.field_behavior) = REQUIRED];</code>
@param \Google\Cloud\VMMigration\V1\TargetProject $var
@return $this | setTargetProject | php | googleapis/google-cloud-php | VmMigration/src/V1/CreateTargetProjectRequest.php | https://github.com/googleapis/google-cloud-php/blob/master/VmMigration/src/V1/CreateTargetProjectRequest.php | Apache-2.0 |
public function getRunFunction()
{
return $this->run_function;
} | Required. The endpoint to execute when this extension point is activated.
Generated from protobuf field <code>string run_function = 1 [(.google.api.field_behavior) = REQUIRED];</code>
@return string | getRunFunction | php | googleapis/google-cloud-php | GSuiteAddOns/external/protos/Docs/DocsExtensionPoint.php | https://github.com/googleapis/google-cloud-php/blob/master/GSuiteAddOns/external/protos/Docs/DocsExtensionPoint.php | Apache-2.0 |
public function setRunFunction($var)
{
GPBUtil::checkString($var, True);
$this->run_function = $var;
return $this;
} | Required. The endpoint to execute when this extension point is activated.
Generated from protobuf field <code>string run_function = 1 [(.google.api.field_behavior) = REQUIRED];</code>
@param string $var
@return $this | setRunFunction | php | googleapis/google-cloud-php | GSuiteAddOns/external/protos/Docs/DocsExtensionPoint.php | https://github.com/googleapis/google-cloud-php/blob/master/GSuiteAddOns/external/protos/Docs/DocsExtensionPoint.php | Apache-2.0 |
public function setResource($var)
{
GPBUtil::checkMessage($var, \Google\Protobuf\Struct::class);
$this->resource = $var;
return $this;
} | JSON representation of the resource as defined by the corresponding
service providing this resource.
Example:
If the resource is an instance provided by Compute Engine, this field will
contain the JSON representation of the instance as defined by Compute
Engine:
`https://cloud.google.com/compute/docs/reference/rest/v1/instances`.
You can find the resource definition for each supported resource type in
this table:
`https://cloud.google.com/asset-inventory/docs/supported-asset-types`
Generated from protobuf field <code>.google.protobuf.Struct resource = 2;</code>
@param \Google\Protobuf\Struct $var
@return $this | setResource | php | googleapis/google-cloud-php | Asset/src/V1/VersionedResource.php | https://github.com/googleapis/google-cloud-php/blob/master/Asset/src/V1/VersionedResource.php | Apache-2.0 |
public function getKeyRings()
{
return $this->key_rings;
} | The list of [KeyRings][google.cloud.kms.v1.KeyRing].
Generated from protobuf field <code>repeated .google.cloud.kms.v1.KeyRing key_rings = 1;</code>
@return \Google\Protobuf\Internal\RepeatedField | getKeyRings | php | googleapis/google-cloud-php | Kms/src/V1/ListKeyRingsResponse.php | https://github.com/googleapis/google-cloud-php/blob/master/Kms/src/V1/ListKeyRingsResponse.php | Apache-2.0 |
public function setKeyRings($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\Kms\V1\KeyRing::class);
$this->key_rings = $arr;
return $this;
} | The list of [KeyRings][google.cloud.kms.v1.KeyRing].
Generated from protobuf field <code>repeated .google.cloud.kms.v1.KeyRing key_rings = 1;</code>
@param array<\Google\Cloud\Kms\V1\KeyRing>|\Google\Protobuf\Internal\RepeatedField $var
@return $this | setKeyRings | php | googleapis/google-cloud-php | Kms/src/V1/ListKeyRingsResponse.php | https://github.com/googleapis/google-cloud-php/blob/master/Kms/src/V1/ListKeyRingsResponse.php | Apache-2.0 |
public function getMachineName()
{
return $this->machine_name;
} | Machine name.
Generated from protobuf field <code>string machine_name = 2;</code>
@return string | getMachineName | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setMachineName($var)
{
GPBUtil::checkString($var, True);
$this->machine_name = $var;
return $this;
} | Machine name.
Generated from protobuf field <code>string machine_name = 2;</code>
@param string $var
@return $this | setMachineName | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setCoreCount($var)
{
GPBUtil::checkInt32($var);
$this->core_count = $var;
return $this;
} | Number of CPU cores in the machine. Must be non-negative.
Generated from protobuf field <code>int32 core_count = 4;</code>
@param int $var
@return $this | setCoreCount | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setPowerState($var)
{
GPBUtil::checkEnum($var, \Google\Cloud\MigrationCenter\V1\MachineDetails\PowerState::class);
$this->power_state = $var;
return $this;
} | Power state of the machine.
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.MachineDetails.PowerState power_state = 6;</code>
@param int $var
@return $this | setPowerState | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function getArchitecture()
{
return $this->architecture;
} | Architecture details (vendor, CPU architecture).
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.MachineArchitectureDetails architecture = 7;</code>
@return \Google\Cloud\MigrationCenter\V1\MachineArchitectureDetails|null | getArchitecture | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setArchitecture($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\MigrationCenter\V1\MachineArchitectureDetails::class);
$this->architecture = $var;
return $this;
} | Architecture details (vendor, CPU architecture).
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.MachineArchitectureDetails architecture = 7;</code>
@param \Google\Cloud\MigrationCenter\V1\MachineArchitectureDetails $var
@return $this | setArchitecture | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function getGuestOs()
{
return $this->guest_os;
} | Guest OS information.
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.GuestOsDetails guest_os = 8;</code>
@return \Google\Cloud\MigrationCenter\V1\GuestOsDetails|null | getGuestOs | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setGuestOs($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\MigrationCenter\V1\GuestOsDetails::class);
$this->guest_os = $var;
return $this;
} | Guest OS information.
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.GuestOsDetails guest_os = 8;</code>
@param \Google\Cloud\MigrationCenter\V1\GuestOsDetails $var
@return $this | setGuestOs | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setNetwork($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\MigrationCenter\V1\MachineNetworkDetails::class);
$this->network = $var;
return $this;
} | Network details.
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.MachineNetworkDetails network = 9;</code>
@param \Google\Cloud\MigrationCenter\V1\MachineNetworkDetails $var
@return $this | setNetwork | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setDisks($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\MigrationCenter\V1\MachineDiskDetails::class);
$this->disks = $var;
return $this;
} | Disk details.
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.MachineDiskDetails disks = 10;</code>
@param \Google\Cloud\MigrationCenter\V1\MachineDiskDetails $var
@return $this | setDisks | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setPlatform($var)
{
GPBUtil::checkMessage($var, \Google\Cloud\MigrationCenter\V1\PlatformDetails::class);
$this->platform = $var;
return $this;
} | Platform specific information.
Generated from protobuf field <code>.google.cloud.migrationcenter.v1.PlatformDetails platform = 11;</code>
@param \Google\Cloud\MigrationCenter\V1\PlatformDetails $var
@return $this | setPlatform | php | googleapis/google-cloud-php | MigrationCenter/src/V1/MachineDetails.php | https://github.com/googleapis/google-cloud-php/blob/master/MigrationCenter/src/V1/MachineDetails.php | Apache-2.0 |
public function setTransactionId($var)
{
GPBUtil::checkString($var, False);
$this->transaction_id = $var;
return $this;
} | Required. The transaction to roll back.
Generated from protobuf field <code>bytes transaction_id = 2 [(.google.api.field_behavior) = REQUIRED];</code>
@param string $var
@return $this | setTransactionId | php | googleapis/google-cloud-php | Spanner/src/V1/RollbackRequest.php | https://github.com/googleapis/google-cloud-php/blob/master/Spanner/src/V1/RollbackRequest.php | Apache-2.0 |
private function formatMessage($message)
{
$message = $message instanceof Message
? $message->toArray()
: $message;
if (isset($message['data']) && $this->encode) {
$message['data'] = base64_encode($message['data']);
}
if (!array_key_exists('data', $message) && !array_key_exists('attributes', $message)) {
throw new InvalidArgumentException(
'At least one of $data or $attributes must be specified on each
message, but neither was given.'
);
}
return $this->serializer->decodeMessage(
new PubsubMessage(),
$message
);
} | Ensure that the message is in a correct format,
base64_encode the data, and error if the input is too wrong to proceed.
@param Message|array $message
@return PubsubMessage The message protobuf object
@throws \InvalidArgumentException | formatMessage | php | googleapis/google-cloud-php | PubSub/src/Topic.php | https://github.com/googleapis/google-cloud-php/blob/master/PubSub/src/Topic.php | Apache-2.0 |
private function subscriptionFactory($name, array $info = [])
{
return new Subscription(
$this->requestHandler,
$this->serializer,
$this->projectId,
$name,
$this->name,
$this->encode,
$info,
$this->clientConfig
);
} | Create a new subscription instance with the given name and optional
subscription data.
@codingStandardsIgnoreStart
@param string $name
@param array $info [optional] A representation of a
[Subscription](https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions#Subscription)
@return Subscription
@codingStandardsIgnoreEnd | subscriptionFactory | php | googleapis/google-cloud-php | PubSub/src/Topic.php | https://github.com/googleapis/google-cloud-php/blob/master/PubSub/src/Topic.php | Apache-2.0 |
public function getOutputs()
{
return $this->outputs;
} | The prediction output.
Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.Tensor outputs = 1;</code>
@return \Google\Protobuf\Internal\RepeatedField | getOutputs | php | googleapis/google-cloud-php | AiPlatform/src/V1/StreamDirectPredictResponse.php | https://github.com/googleapis/google-cloud-php/blob/master/AiPlatform/src/V1/StreamDirectPredictResponse.php | Apache-2.0 |
public function setOutputs($var)
{
$arr = GPBUtil::checkRepeatedField($var, \Google\Protobuf\Internal\GPBType::MESSAGE, \Google\Cloud\AIPlatform\V1\Tensor::class);
$this->outputs = $arr;
return $this;
} | The prediction output.
Generated from protobuf field <code>repeated .google.cloud.aiplatform.v1.Tensor outputs = 1;</code>
@param array<\Google\Cloud\AIPlatform\V1\Tensor>|\Google\Protobuf\Internal\RepeatedField $var
@return $this | setOutputs | php | googleapis/google-cloud-php | AiPlatform/src/V1/StreamDirectPredictResponse.php | https://github.com/googleapis/google-cloud-php/blob/master/AiPlatform/src/V1/StreamDirectPredictResponse.php | Apache-2.0 |
public function __construct(protected array $kwargs = [])
{
$this->max_length = $kwargs['max_length'] ?? 20;
$this->max_new_tokens = $kwargs['max_new_tokens'] ?? null;
$this->min_length = $kwargs['min_length'] ?? 0;
$this->min_new_tokens = $kwargs['min_new_tokens'] ?? null;
$this->early_stopping = $kwargs['early_stopping'] ?? false;
$this->max_time = $kwargs['max_time'] ?? null;
$this->do_sample = $kwargs['do_sample'] ?? false;
$this->num_beams = $kwargs['num_beams'] ?? 1;
$this->num_beam_groups = $kwargs['num_beam_groups'] ?? 1;
$this->penalty_alpha = $kwargs['penalty_alpha'] ?? null;
$this->use_cache = $kwargs['use_cache'] ?? true;
$this->temperature = $kwargs['temperature'] ?? 1.0;
$this->top_k = $kwargs['top_k'] ?? 50;
$this->top_p = $kwargs['top_p'] ?? 1.0;
$this->typical_p = $kwargs['typical_p'] ?? 1.0;
$this->epsilon_cutoff = $kwargs['epsilon_cutoff'] ?? 0.0;
$this->eta_cutoff = $kwargs['eta_cutoff'] ?? 0.0;
$this->diversity_penalty = $kwargs['diversity_penalty'] ?? 0.0;
$this->repetition_penalty = $kwargs['repetition_penalty'] ?? 1.0;
$this->encoder_repetition_penalty = $kwargs['encoder_repetition_penalty'] ?? 1.0;
$this->length_penalty = $kwargs['length_penalty'] ?? 1.0;
$this->no_repeat_ngram_size = $kwargs['no_repeat_ngram_size'] ?? 0;
$this->bad_words_ids = $kwargs['bad_words_ids'] ?? null;
$this->force_words_ids = $kwargs['force_words_ids'] ?? null;
$this->renormalize_logits = $kwargs['renormalize_logits'] ?? false;
$this->constraints = $kwargs['constraints'] ?? null;
$this->forced_bos_token_id = $kwargs['forced_bos_token_id'] ?? null;
$this->forced_eos_token_id = $kwargs['forced_eos_token_id'] ?? null;
$this->remove_invalid_values = $kwargs['remove_invalid_values'] ?? false;
$this->exponential_decay_length_penalty = $kwargs['exponential_decay_length_penalty'] ?? null;
$this->suppress_tokens = $kwargs['suppress_tokens'] ?? null;
$this->begin_suppress_tokens = $kwargs['begin_suppress_tokens'] ?? null;
$this->forced_decoder_ids = $kwargs['forced_decoder_ids'] ?? null;
$this->num_return_sequences = $kwargs['num_return_sequences'] ?? 1;
$this->output_attentions = $kwargs['output_attentions'] ?? false;
$this->output_hidden_states = $kwargs['output_hidden_states'] ?? false;
$this->output_scores = $kwargs['output_scores'] ?? false;
$this->return_dict_in_generate = $kwargs['return_dict_in_generate'] ?? false;
$this->pad_token_id = $kwargs['pad_token_id'] ?? null;
$this->bos_token_id = $kwargs['bos_token_id'] ?? null;
$this->eos_token_id = $kwargs['eos_token_id'] ?? null;
$this->encoder_no_repeat_ngram_size = $kwargs['encoder_no_repeat_ngram_size'] ?? 0;
$this->decoder_start_token_id = $kwargs['decoder_start_token_id'] ?? null;
$this->generation_kwargs = $kwargs['generation_kwargs'] ?? [];
$this->decoder_input_ids = $kwargs['decoder_input_ids'] ?? null;
} | Create a new GenerationConfig object.
@param array $kwargs The configuration parameters. | __construct | php | CodeWithKyrian/transformers-php | src/Utils/GenerationConfig.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/Utils/GenerationConfig.php | Apache-2.0 |
public function __construct(array $config)
{
parent::__construct($config);
$this->processors = array_map(
fn ($processorConfig) => PostProcessor::fromConfig($processorConfig),
$config['processors']
);
} | Creates a new instance of PostProcessorSequence.
@param array $config The configuration array.
- 'processors' (array): The list of post-processors to apply. | __construct | php | CodeWithKyrian/transformers-php | src/PostProcessors/PostProcessorSequence.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/PostProcessors/PostProcessorSequence.php | Apache-2.0 |
public function toArray()
{
if (count($this->shape) == 0) {
return $this->buffer[$this->offset];
}
$idx = $this->offset;
return $this->unflattenArray($this->buffer, $idx, $this->shape);
} | Convert the tensor into an array. | toArray | php | CodeWithKyrian/transformers-php | src/Tensor/Tensor.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/Tensor/Tensor.php | Apache-2.0 |
public function __construct(
public string $sentence,
public ?int $bosTokenId,
public ?int $eosTokenId)
{
$this->len = mb_strlen($sentence);
$this->beginNodes = array_fill(0, $this->len + 1, []);
$this->endNodes = array_fill(0, $this->len + 1, []);
$bos = new TokenLatticeNode($this->bosTokenId, 0, 0, 0, 0.0);
$eos = new TokenLatticeNode($this->eosTokenId, 1, $this->len, 0, 0.0);
$this->nodes[] = $bos;
$this->nodes[] = $eos;
$this->beginNodes[$this->len][] = $eos;
$this->endNodes[0][] = $bos;
} | Creates a new TokenLattice instance.
@param string $sentence The input sentence to be tokenized.
@param int $bosTokenId The beginning-of-sequence token ID.
@param int $eosTokenId The end-of-sequence token ID. | __construct | php | CodeWithKyrian/transformers-php | src/DataStructures/TokenLattice.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/DataStructures/TokenLattice.php | Apache-2.0 |
public function __construct()
{
$this->root = CharTrieNode::default(256);
} | Creates a new CharTrie instance. | __construct | php | CodeWithKyrian/transformers-php | src/DataStructures/CharTrie.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/DataStructures/CharTrie.php | Apache-2.0 |
public function __construct(
public ?int $tokenId,
public int $nodeId,
public int $pos,
public int $length,
public float $score)
{
} | Represents a node in a token lattice for a given sentence.
@param int $tokenId The ID of the token associated with this node.
@param int $nodeId The ID of this node.
@param int $pos The starting position of the token in the sentence.
@param int $length The length of the token.
@param float $score The score associated with the token. | __construct | php | CodeWithKyrian/transformers-php | src/DataStructures/TokenLatticeNode.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/DataStructures/TokenLatticeNode.php | Apache-2.0 |
public function __construct(GenerationConfig $generateConfig)
{
$this->eosTokenId = $generateConfig['eos_token_id'];
$this->noTimestampsTokenId = $generateConfig['no_timestamps_token_id'];
$this->timestampBegin = $this->noTimestampsTokenId + 1;
$this->beginIndex = count($generateConfig['forced_decoder_ids'] ?? []) + 2;
$forcedDecoderIds = $generateConfig['forced_decoder_ids'] ?? [];
if (count($forcedDecoderIds) > 0 && end($forcedDecoderIds)[1] === $this->noTimestampsTokenId) {
$this->beginIndex -= 1;
}
$this->maxInitialTimestampIndex = $generateConfig['max_initial_timestamp_index'] ?? null;
} | Constructs a new WhisperTimeStampLogitsProcessor. | __construct | php | CodeWithKyrian/transformers-php | src/Generation/LogitsProcessors/WhisperTimeStampLogitsProcessor.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/Generation/LogitsProcessors/WhisperTimeStampLogitsProcessor.php | Apache-2.0 |
public function __construct(public readonly Tensor $logits, public readonly Tensor $predBoxes, public readonly Tensor $predMasks)
{
} | These values are normalized in [0, 1], relative to the size of each individual image in the batch (disregarding possible padding).
@param Tensor $logits Classification logits (including no-object) for all queries.
@param Tensor $predBoxes Normalized boxes coordinates for all queries, represented as (center_x, center_y, width, height).
@param Tensor $predMasks Segmentation masks for all queries. | __construct | php | CodeWithKyrian/transformers-php | src/Models/Output/DetrSegmentationOutput.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/Models/Output/DetrSegmentationOutput.php | Apache-2.0 |
public function __construct(public readonly Tensor $logits, public readonly Tensor $predBoxes)
{
} | These values are normalized in [0, 1], relative to the size of each individual image in the batch (disregarding possible padding).
@param Tensor $logits Classification logits (including no-object) for all queries.
@param Tensor $predBoxes Normalized boxes coordinates for all queries, represented as (center_x, center_y, width, height). | __construct | php | CodeWithKyrian/transformers-php | src/Models/Output/ObjectDetectionOutput.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/Models/Output/ObjectDetectionOutput.php | Apache-2.0 |
public function __construct(
AutoConfig $config,
InferenceSession $session,
public InferenceSession $decoderMergedSession,
public ModelArchitecture $modelArchitecture,
public GenerationConfig $generationConfig
)
{
parent::__construct($config, $session, $this->modelArchitecture);
// Extract configs
$encoderConfig = $this->config['encoder'];
$decoderConfig = $this->config['decoder'];
$decoderConfig = AutoConfig::fromPretrained('', $decoderConfig);
// Validate encoder
$encoderModelType = $encoderConfig['model_type'];
$encoderModel = AutoModel::ENCODER_ONLY_MODEL_MAPPING[$encoderModelType]
?? AutoModel::ENCODER_DECODER_MODEL_MAPPING[$encoderModelType];
if (!$encoderModel) {
Transformers::getLogger()?->warning("Model type for encoder '{$encoderModelType}' not found, assuming encoder-only architecture. Please report this at https://github.com/CodeWithKyrian/transformers-php/issues/new/choose.");
}
// Validate decoder
$decoderModel = AutoModelForCausalLM::MODEL_CLASS_MAPPING[$decoderConfig['model_type']];
if (!$decoderModel) {
throw new \Exception("Unable to construct `VisionEncoderDecoder` due to unsupported decoder: '{$this->config['decoder']['model_type']}'");
}
$decoder = new $decoderModel($decoderConfig, $this->decoderMergedSession, ModelArchitecture::DecoderOnly, $this->generationConfig);
$this->addEncoderPkv = property_exists($decoder, 'numDecoderLayers');
if ($this->addEncoderPkv) {
// Decoder is part of an encoder-decoder model
$this->numDecoderLayers = $decoder->numDecoderLayers;
$this->numDecoderHeads = $decoder->numDecoderHeads;
$this->decoderDimKv = $decoder->decoderDimKv;
$this->numEncoderLayers = $decoder->numEncoderLayers;
$this->numEncoderHeads = $decoder->numEncoderHeads;
$this->encoderDimKv = $decoder->encoderDimKv;
} else {
// Decoder is a decoder-only model
$this->numLayers = $decoder->numLayers;
$this->numHeads = $decoder->numHeads;
$this->dimKv = $decoder->dimKv;
}
} | Creates a new instance of the `VisionEncoderDecoderModel` class.
@param AutoConfig $config The configuration array specifying the hyperparameters and other model settings.
@param mixed $session The ONNX session containing the encoder model.
@param InferenceSession $decoderMergedSession The ONNX session containing the merged decoder model.
@param ModelArchitecture $modelArchitecture
@param GenerationConfig $generationConfig Configuration object for the generation process. | __construct | php | CodeWithKyrian/transformers-php | src/Models/Pretrained/VisionEncoderDecoderModel.php | https://github.com/CodeWithKyrian/transformers-php/blob/master/src/Models/Pretrained/VisionEncoderDecoderModel.php | Apache-2.0 |
private static function getFirstMetadataMatching(array $metadatas, $metadataClasses)
{
$metas = self::getMetadataMatching($metadatas, $metadataClasses);
return array_shift($metas);
} | Get the first metadata matching given class.
@phpstan-template T of object
@phpstan-param class-string<T>|class-string<T>[] $metadataClasses
@phpstan-return T|null
@return object|null | getFirstMetadataMatching | php | overblog/GraphQLBundle | src/Config/Parser/MetadataParser/MetadataParser.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Config/Parser/MetadataParser/MetadataParser.php | MIT |
public function connectionFromPromisedArray($dataPromise, $args = [])
{
$this->checkPromise($dataPromise);
return $dataPromise->then(fn ($data) => $this->connectionFromArray($data, $args));
} | A version of `connectionFromArray` that takes a promised array, and returns a
promised connection.
@param mixed $dataPromise a promise
@param array|ArgumentInterface $args
@return mixed a promise | connectionFromPromisedArray | php | overblog/GraphQLBundle | src/Relay/Connection/ConnectionBuilder.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Relay/Connection/ConnectionBuilder.php | MIT |
public function connectionFromPromisedArraySlice($dataPromise, $args, array $meta)
{
$this->checkPromise($dataPromise);
return $dataPromise->then(fn ($arraySlice) => $this->connectionFromArraySlice($arraySlice, $args, $meta));
} | A version of `connectionFromArraySlice` that takes a promised array slice,
and returns a promised connection.
@param mixed $dataPromise a promise
@param array|ArgumentInterface $args
@return mixed a promise | connectionFromPromisedArraySlice | php | overblog/GraphQLBundle | src/Relay/Connection/ConnectionBuilder.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Relay/Connection/ConnectionBuilder.php | MIT |
public function getResolverArg(string $name)
{
if (in_array($name, self::KNOWN_VAR_NAMES)) {
return $this->__resolverArgs->$name;
}
return null;
} | Returns an argument of the resolver, where this validation is being executed.
@return ResolveInfo|Argument|mixed|null | getResolverArg | php | overblog/GraphQLBundle | src/Validator/ValidationNode.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Validator/ValidationNode.php | MIT |
public function __construct(
?ConstraintValidatorFactoryInterface $constraintValidatorFactory,
?ValidatorInterface $validator,
?TranslatorInterface $translator
) {
$this->defaultValidator = $validator;
$this->defaultTranslator = $translator;
$this->constraintValidatorFactory = $constraintValidatorFactory;
} | InputValidatorFactory constructor. | __construct | php | overblog/GraphQLBundle | src/Validator/InputValidatorFactory.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Validator/InputValidatorFactory.php | MIT |
public static function unprefixExpression(string $expression)
{
$string = substr($expression, strlen(self::EXPRESSION_TRIGGER)) ?: '';
return '' !== $string ? $string : $expression;
} | Removes the expression trigger prefix from a string. If no prefix found,
returns the initial string.
@param string $expression - String expression with a trigger prefix
@return string | unprefixExpression | php | overblog/GraphQLBundle | src/ExpressionLanguage/ExpressionLanguage.php | https://github.com/overblog/GraphQLBundle/blob/master/src/ExpressionLanguage/ExpressionLanguage.php | MIT |
private function getTypeClassInstance(string $type)
{
$classname = isset($this->classesMap[$type]) ? $this->classesMap[$type]['class'] : false;
return $classname ? new $classname() : false;
} | Get the PHP class for a given type.
@return object|false | getTypeClassInstance | php | overblog/GraphQLBundle | src/Transformer/ArgumentsTransformer.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Transformer/ArgumentsTransformer.php | MIT |
public function getInstanceAndValidate(string $argType, $data, ResolveInfo $info, string $argName)
{
$isRequired = '!' === $argType[strlen($argType) - 1];
$isMultiple = '[' === $argType[0];
$isStrictMultiple = false;
if ($isMultiple) {
$isStrictMultiple = '!' === $argType[strpos($argType, ']') - 1];
}
$endIndex = ($isRequired ? 1 : 0) + ($isMultiple ? 1 : 0) + ($isStrictMultiple ? 1 : 0);
$type = substr($argType, $isMultiple ? 1 : 0, $endIndex > 0 ? -$endIndex : strlen($argType));
$gqlType = $this->getType($type, $info);
$result = $this->populateObject($gqlType, $data, $isMultiple, $info);
// We only want to validate input object types and not the scalar or object types that are already validated by the GraphQL library.
$shouldValidate = $gqlType instanceof InputObjectType;
if (null !== $this->validator && $shouldValidate) {
$errors = new ConstraintViolationList();
if (is_object($result)) {
$errors = $this->validator->validate($result);
}
if (is_array($result) && $isMultiple) {
foreach ($result as $element) {
if (is_object($element)) {
$errors->addAll(
$this->validator->validate($element)
);
}
}
}
if (count($errors) > 0) {
throw new InvalidArgumentError($argName, $errors);
}
}
return $result;
} | Given a GraphQL type and an array of data, populate corresponding object recursively
using annotated classes.
@param mixed $data
@return mixed | getInstanceAndValidate | php | overblog/GraphQLBundle | src/Transformer/ArgumentsTransformer.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Transformer/ArgumentsTransformer.php | MIT |
public function getArguments(array $mapping, $data, ResolveInfo $info)
{
$args = [];
$exceptions = [];
foreach ($mapping as $name => $type) {
try {
if (self::RESOLVE_INFO_TOKEN === $type) {
$args[] = $info;
continue;
}
$value = $this->getInstanceAndValidate($type, $data[$name], $info, $name);
$args[] = $value;
} catch (InvalidArgumentError $exception) {
$exceptions[] = $exception;
}
}
if (!empty($exceptions)) {
throw new InvalidArgumentsError($exceptions);
}
return $args;
} | Transform a list of arguments into their corresponding php class and validate them.
@param mixed $data
@return array | getArguments | php | overblog/GraphQLBundle | src/Transformer/ArgumentsTransformer.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Transformer/ArgumentsTransformer.php | MIT |
private function buildType(string $typeDefinition)
{
$typeNode = Parser::parseType($typeDefinition);
$isReference = false;
$type = $this->wrapTypeRecursive($typeNode, $isReference);
if ($isReference) {
// References to other types should be wrapped in a closure
// for performance reasons
return ArrowFunction::new($type);
}
return $type;
} | Converts a native GraphQL type string into the `webonyx/graphql-php`
type literal. References to user-defined types are converted into
TypeResolver method call and wrapped into a closure.
Render examples:
- "String" -> Type::string()
- "String!" -> Type::nonNull(Type::string())
- "[String!] -> Type::listOf(Type::nonNull(Type::string()))
- "[Post]" -> Type::listOf($services->getType('Post'))
@return GeneratorInterface|string | buildType | php | overblog/GraphQLBundle | src/Generator/TypeBuilder.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Generator/TypeBuilder.php | MIT |
private function buildScalarCallback($callback, string $fieldName)
{
if (!is_callable($callback)) {
throw new GeneratorException("Value of '$fieldName' is not callable.");
}
$closure = new ArrowFunction();
if (!is_string($callback)) {
[$class, $method] = $callback;
} else {
[$class, $method] = explode('::', $callback);
}
$className = Utils::resolveQualifier($class);
if ($className === $this->config['class_name']) {
// Create an alias if name of serializer is same as type name
$className = 'Base'.$className;
$this->file->addUse($class, $className);
} else {
$this->file->addUse($class);
}
$closure->setExpression(Literal::new("$className::$method(...\\func_get_args())"));
return $closure;
} | Builds an arrow function that calls a static method.
Render example:
fn() => MyClassName::myMethodName(...\func_get_args())
@param callable $callback - a callable string or a callable array
@return ArrowFunction
@throws GeneratorException | buildScalarCallback | php | overblog/GraphQLBundle | src/Generator/TypeBuilder.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Generator/TypeBuilder.php | MIT |
private function buildPublic($public)
{
if (EL::isStringWithTrigger($public)) {
$expression = $this->expressionConverter->convert($public);
$arrow = ArrowFunction::new(Literal::new($expression));
if (EL::expressionContainsVar('fieldName', $public)) {
$arrow->addArgument('fieldName');
}
if (EL::expressionContainsVar('typeName', $public)) {
$arrow->addArgument('fieldName');
$arrow->addArgument('typeName', '', new Literal('self::NAME'));
}
return $arrow;
}
return $public;
} | Builds an arrow function from a string with an expression prefix,
otherwise just returns the provided value back untouched.
Render example (if expression):
fn($fieldName, $typeName = self::NAME) => ($fieldName == "name")
@param mixed $public
@return ArrowFunction|mixed | buildPublic | php | overblog/GraphQLBundle | src/Generator/TypeBuilder.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Generator/TypeBuilder.php | MIT |
private function buildAccess($access)
{
if (EL::isStringWithTrigger($access)) {
$expression = $this->expressionConverter->convert($access);
return ArrowFunction::new()
->addArguments('value', 'args', 'context', 'info', 'object')
->setExpression(Literal::new($expression));
}
return $access;
} | Builds an arrow function from a string with an expression prefix,
otherwise just returns the provided value back untouched.
Render example (if expression):
fn($value, $args, $context, $info, $object) => $services->get('private_service')->hasAccess()
@param mixed $access
@return ArrowFunction|mixed | buildAccess | php | overblog/GraphQLBundle | src/Generator/TypeBuilder.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Generator/TypeBuilder.php | MIT |
private function buildResolveType($resolveType)
{
if (EL::isStringWithTrigger($resolveType)) {
$expression = $this->expressionConverter->convert($resolveType);
return ArrowFunction::new()
->addArguments('value', 'context', 'info')
->setExpression(Literal::new($expression));
}
return $resolveType;
} | Builds an arrow function from a string with an expression prefix,
otherwise just returns the provided value back untouched.
Render example:
fn($value, $context, $info) => $services->getType($value)
@param mixed $resolveType
@return mixed|ArrowFunction | buildResolveType | php | overblog/GraphQLBundle | src/Generator/TypeBuilder.php | https://github.com/overblog/GraphQLBundle/blob/master/src/Generator/TypeBuilder.php | MIT |
public function register()
{
$this->app->afterResolving(MailManager::class, function (MailManager $mail_manager) {
$mail_manager->extend("sendgrid", function ($config) {
if (! isset($config['api_key'])) {
$config = $this->app['config']->get('services.sendgrid', []);
}
$client = new HttpClient(Arr::get($config, 'guzzle', []));
$endpoint = $config['endpoint'] ?? null;
return new SendgridTransport($client, $config['api_key'], $endpoint);
});
});
} | Register the Sendgrid Transport instance.
@return void | register | php | s-ichikawa/laravel-sendgrid-driver | src/SendgridTransportServiceProvider.php | https://github.com/s-ichikawa/laravel-sendgrid-driver/blob/master/src/SendgridTransportServiceProvider.php | MIT |
public function getCascadeDeletes()
{
return property_exists($this, 'cascadeDeletes') ? $this->cascadeDeletes : [];
} | Get the value of the cascadeDeletes attribute, if it exists.
@return mixed | getCascadeDeletes | php | shiftonelabs/laravel-cascade-deletes | src/CascadesDeletes.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/src/CascadesDeletes.php | MIT |
public function setCascadeDeletes($cascadeDeletes)
{
$this->cascadeDeletes = $cascadeDeletes;
} | Set the cascadeDeletes attribute.
@param mixed $cascadeDeletes
@return void | setCascadeDeletes | php | shiftonelabs/laravel-cascade-deletes | src/CascadesDeletes.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/src/CascadesDeletes.php | MIT |
public function getCascadeDeletesRelationNames()
{
$deletes = $this->getCascadeDeletes();
return array_filter(is_array($deletes) ? $deletes : [$deletes]);
} | Get an array of cascading relation names.
@return array | getCascadeDeletesRelationNames | php | shiftonelabs/laravel-cascade-deletes | src/CascadesDeletes.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/src/CascadesDeletes.php | MIT |
public function getCascadeDeletesRelations()
{
$names = $this->getCascadeDeletesRelationNames();
return array_combine($names, array_map(function ($name) {
$relation = method_exists($this, $name) ? $this->$name() : null;
return $relation instanceof Relation ? $relation : null;
}, $names));
} | Get an array of the cascading relation names mapped to their relation types.
@return array | getCascadeDeletesRelations | php | shiftonelabs/laravel-cascade-deletes | src/CascadesDeletes.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/src/CascadesDeletes.php | MIT |
public function getInvalidCascadeDeletesRelations(?array $relations = null)
{
// This will get the array keys for any item in the array where the
// value is null. If the value is null, that means that the name
// of the relation provided does not return a Relation object.
return array_keys($relations ?: $this->getCascadeDeletesRelations(), null);
} | Get an array of the invalid cascading relation names.
@param array|null $relations
@return array | getInvalidCascadeDeletesRelations | php | shiftonelabs/laravel-cascade-deletes | src/CascadesDeletes.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/src/CascadesDeletes.php | MIT |
public function getCascadeDeletesRelationQuery($relation)
{
$query = $this->$relation();
// If this is a force delete and the related model is using soft deletes,
// we need to use the withTrashed() scope on the relationship query to
// ensure all related records, plus soft deleted, are force deleted.
if ($this->isCascadeDeletesForceDeleting() && !is_null($query->getMacro('withTrashed'))) {
$query = $query->withTrashed();
}
return $query;
} | Get the relationship query to use for the specified relation.
@param string $relation
@return \Illuminate\Database\Eloquent\Relations\Relation | getCascadeDeletesRelationQuery | php | shiftonelabs/laravel-cascade-deletes | src/CascadesDeletes.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/src/CascadesDeletes.php | MIT |
public function isCascadeDeletesForceDeleting()
{
return property_exists($this, 'forceDeleting') && $this->forceDeleting;
} | Check if this cascading delete is a force delete.
@return boolean | isCascadeDeletesForceDeleting | php | shiftonelabs/laravel-cascade-deletes | src/CascadesDeletes.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/src/CascadesDeletes.php | MIT |
public function afterTearDown()
{
$this->schema()->dropIfExists('users');
$this->schema()->dropIfExists('friends');
$this->schema()->dropIfExists('posts');
$this->schema()->dropIfExists('comments');
$this->schema()->dropIfExists('photos');
$this->schema()->dropIfExists('invalid_kids');
$this->schema()->dropIfExists('profiles');
} | Tear down run after each test.
@after | afterTearDown | php | shiftonelabs/laravel-cascade-deletes | tests/IntegrationTest.php | https://github.com/shiftonelabs/laravel-cascade-deletes/blob/master/tests/IntegrationTest.php | MIT |
public function __construct(array $array)
{
$this->invertedArray = \array_flip($array);
} | Constructs the object with the array that will be reused for many intersection computations.
@param array<array-key, array-key> $array | __construct | php | MyIntervals/emogrifier | src/Utilities/ArrayIntersector.php | https://github.com/MyIntervals/emogrifier/blob/master/src/Utilities/ArrayIntersector.php | MIT |
public function __construct(string $css, bool $debug)
{
// CSS Parser currently throws exception with nested at-rules (like `@media`) in strict parsing mode
$parserSettings = ParserSettings::create()->withLenientParsing(!$debug || $this->hasNestedAtRule($css));
// CSS Parser currently throws exception with non-empty whitespace-only CSS in strict parsing mode, so `trim()`
// @see https://github.com/sabberworm/PHP-CSS-Parser/issues/349
$this->sabberwormCssDocument = (new CssParser(\trim($css), $parserSettings))->parse();
} | @param string $css
@param bool $debug
If this is `true`, an exception will be thrown if invalid CSS is encountered.
Otherwise the parser will try to do the best it can. | __construct | php | MyIntervals/emogrifier | src/Css/CssDocument.php | https://github.com/MyIntervals/emogrifier/blob/master/src/Css/CssDocument.php | MIT |
protected function __construct()
{
if (\is_callable([parent::class, '__construct'])) {
parent::__construct();
}
} | Invokes the parent class's constructor if there is one. Since PHPUnit 8.x, `Constraint` (the parent class) does
not have a defined constructor. But...
In PHP, a class that may be extended should have a defined constructor, even if it does nothing.
That way, a child class that needs a constructor can explicitly call its parent's constructor. If it could not,
and then a newer version of the parent class needed a constructor, the newly added constructor would not be
invoked implicitly during instantiation of the child class. In that eventuality, the child class would also need
updating, so there would be a compatibility issue, and potential for uncaught bugs if the child class's
constructor was not updated. | __construct | php | MyIntervals/emogrifier | tests/Support/Constraint/CssConstraint.php | https://github.com/MyIntervals/emogrifier/blob/master/tests/Support/Constraint/CssConstraint.php | MIT |
public function setFromString($coordinates)
{
if (!is_string($coordinates)) {
throw new InvalidArgumentException('The given coordinates should be a string !');
}
try {
$inDecimalDegree = $this->toDecimalDegrees($coordinates);
$this->setLatitude($inDecimalDegree[0]);
$this->setLongitude($inDecimalDegree[1]);
} catch (InvalidArgumentException $e) {
throw $e;
}
} | Creates a valid and acceptable geographic coordinates.
@param string $coordinates
@throws InvalidArgumentException | setFromString | php | thephpleague/geotools | src/Coordinate/Coordinate.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Coordinate.php | MIT |
private function toDecimalDegrees($coordinates)
{
// Degrees, Decimal Minutes format (DD MM.mmm)
// N 40°26.7717 E 79°56.93172
// N40°26.7717E79°56.93172
// N 25°59.86′, W 21°09.81′
if (preg_match('/([ns]{1})\s?([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*[, ]?([we]{1})\s? ?([0-9]{1,3})\D+([0-9]{1,2}\.?\d*)\D*$/i', $coordinates, $match)) {
$latitude = $match[2] + $match[3] / 60;
$longitude = $match[5] + $match[6] / 60;
return [
'N' === strtoupper($match[1]) ? $latitude : -$latitude,
'E' === strtoupper($match[4]) ? $longitude : -$longitude,
];
}
// 40.446195, -79.948862
if (preg_match('/(\-?[0-9]{1,2}\.?\d*)[, ] ?(\-?[0-9]{1,3}\.?\d*)$/', $coordinates, $match)) {
return array($match[1], $match[2]);
}
// 40° 26.7717, -79° 56.93172
if (preg_match('/(\-?[0-9]{1,2})\D+([0-9]{1,2}\.?\d*)[, ] ?(\-?[0-9]{1,3})\D+([0-9]{1,2}\.?\d*)$/i',
$coordinates, $match)) {
return array(
$match[1] < 0
? $match[1] - $match[2] / 60
: $match[1] + $match[2] / 60,
$match[3] < 0
? $match[3] - $match[4] / 60
: $match[3] + $match[4] / 60
);
}
// 40.446195N 79.948862W
if (preg_match('/([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3}\.?\d*)\D*([we]{1})$/i', $coordinates, $match)) {
return array(
'N' === strtoupper($match[2]) ? $match[1] : -$match[1],
'E' === strtoupper($match[4]) ? $match[3] : -$match[3]
);
}
// 40°26.7717S 79°56.93172E
// 25°59.86′N,21°09.81′W
if (preg_match('/([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3})\D+([0-9]{1,2}\.?\d*)\D*([we]{1})$/i',
$coordinates, $match)) {
$latitude = $match[1] + $match[2] / 60;
$longitude = $match[4] + $match[5] / 60;
return array(
'N' === strtoupper($match[3]) ? $latitude : -$latitude,
'E' === strtoupper($match[6]) ? $longitude : -$longitude
);
}
// 40:26:46N, 079:56:55W
// 40:26:46.302N 079:56:55.903W
// 40°26′47″N 079°58′36″W
// 40d 26′ 47″ N 079d 58′ 36″ W
if (preg_match('/([0-9]{1,2})\D+([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([ns]{1})[, ] ?([0-9]{1,3})\D+([0-9]{1,2})\D+([0-9]{1,2}\.?\d*)\D*([we]{1})$/i',
$coordinates, $match)) {
$latitude = $match[1] + ($match[2] * 60 + $match[3]) / 3600;
$longitude = $match[5] + ($match[6] * 60 + $match[7]) / 3600;
return array(
'N' === strtoupper($match[4]) ? $latitude : -$latitude,
'E' === strtoupper($match[8]) ? $longitude : -$longitude
);
}
throw new InvalidArgumentException(
'It should be a valid and acceptable ways to write geographic coordinates !'
);
} | Converts a valid and acceptable geographic coordinates to decimal degrees coordinate.
@param string $coordinates A valid and acceptable geographic coordinates.
@return array An array of coordinate in decimal degree.
@throws InvalidArgumentException
@see http://en.wikipedia.org/wiki/Geographic_coordinate_conversion | toDecimalDegrees | php | thephpleague/geotools | src/Coordinate/Coordinate.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Coordinate.php | MIT |
public function isEqual(Coordinate $coordinate) {
return bccomp($this->latitude, $coordinate->getLatitude(), $this->getPrecision()) === 0 && bccomp($this->longitude, $coordinate->getLongitude(), $this->getPrecision()) === 0;
} | Returns a boolean determining coordinates equality
@param Coordinate $coordinate
@return boolean | isEqual | php | thephpleague/geotools | src/Coordinate/Coordinate.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Coordinate.php | MIT |
public static function createFromName($name = self::WGS84)
{
$name = trim($name);
if (empty($name)) {
throw new InvalidArgumentException('Please provide an ellipsoid name !');
}
if (!array_key_exists($name, self::$referenceEllipsoids)) {
throw new InvalidArgumentException(
sprintf('%s ellipsoid does not exist in selected reference ellipsoids !', $name)
);
}
return self::createFromArray(self::$referenceEllipsoids[$name]);
} | Create the ellipsoid chosen by its name.
@param string $name The name of the ellipsoid to create (optional).
@return Ellipsoid | createFromName | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public static function createFromArray(array $newEllipsoid)
{
if (!isset($newEllipsoid['name']) || !isset($newEllipsoid['a']) || !isset($newEllipsoid['invF'])
|| 3 !== count($newEllipsoid)) {
throw new InvalidArgumentException('Ellipsoid arrays should contain `name`, `a` and `invF` keys !');
}
return new self($newEllipsoid['name'], $newEllipsoid['a'], $newEllipsoid['invF']);
} | Create an ellipsoid from an array.
@param array $newEllipsoid The ellipsoid's parameters to create.
@return Ellipsoid | createFromArray | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public static function checkCoordinatesEllipsoid(CoordinateInterface $a, CoordinateInterface $b)
{
if ($a->getEllipsoid() != $b->getEllipsoid()) {
throw new NotMatchingEllipsoidException('The ellipsoids for both coordinates must match !');
}
} | Check if coordinates have the same ellipsoid.
@param CoordinateInterface $a A coordinate.
@param CoordinateInterface $b A coordinate.
@throws NotMatchingEllipsoidException | checkCoordinatesEllipsoid | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public function getA()
{
return (double) $this->a;
} | Returns the semi-major axis (equatorial radius) in meters.
@return double | getA | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public function getB()
{
return (double) $this->a * (1 - 1 / $this->invF);
} | Computes and returns the semi-minor axis (polar distance) in meters.
@see http://home.online.no/~sigurdhu/WGS84_Eng.html
@return double | getB | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public function getInvF()
{
return (double) $this->invF;
} | Returns the inverse flattening.
@return double | getInvF | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public function getArithmeticMeanRadius()
{
return (double) $this->a * (1 - 1 / $this->invF / 3);
} | Computes and returns the arithmetic mean radius in meters.
@see http://home.online.no/~sigurdhu/WGS84_Eng.html
@return double | getArithmeticMeanRadius | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public static function getAvailableEllipsoidNames()
{
ksort(self::$referenceEllipsoids);
return implode(', ', array_keys(self::$referenceEllipsoids));
} | Returns the list of available ellipsoids sorted by alphabetical order.
@return string The list of available ellipsoids comma separated. | getAvailableEllipsoidNames | php | thephpleague/geotools | src/Coordinate/Ellipsoid.php | https://github.com/thephpleague/geotools/blob/master/src/Coordinate/Ellipsoid.php | MIT |
public function encode(CoordinateInterface $coordinate)
{
$latitude = floor(($coordinate->getLatitude() + 90.0) * 10000.0);
$longitude = floor(($coordinate->getLongitude() + 180.0) * 10000.0);
$position = $latitude * 3600000.0 + $longitude;
$ttNumber = $position * self::BASE;
$checkDigit = 0;
for ($i = 1; $i < 10; ++$i) {
$checkDigit += ($position % self::BASE) * $i;
$position = floor($position / self::BASE);
}
$checkDigit %= self::BASE;
$ttNumber += $checkDigit;
$ttNumber = floor($ttNumber);
$tt = '';
for ($i = 0; $i < 10; ++$i) {
$digit = $ttNumber % self::BASE;
if ($i === 4 || $i === 7) {
$tt = ' ' . $tt;
}
$tt = $this->alphabet[$digit] . $tt;
$ttNumber = floor($ttNumber / self::BASE);
}
return $tt;
} | Encode the coordinate via the 10:10 algorithm.
@param CoordinateInterface $coordinate The coordinate to encode.
@return string | encode | php | thephpleague/geotools | src/Geohash/TenTen.php | https://github.com/thephpleague/geotools/blob/master/src/Geohash/TenTen.php | MIT |
public function getCoordinate()
{
return new Coordinate(array(
($this->latitudeInterval[0] + $this->latitudeInterval[1]) / 2,
($this->longitudeInterval[0] + $this->longitudeInterval[1]) / 2
));
} | Returns the decoded coordinate (The center of the bounding box).
@return CoordinateInterface | getCoordinate | php | thephpleague/geotools | src/Geohash/Geohash.php | https://github.com/thephpleague/geotools/blob/master/src/Geohash/Geohash.php | MIT |
public function getCoordinates()
{
if (null === $this->address) {
return null;
}
return $this->address->getCoordinates();
} | Returns an array of coordinates (latitude, longitude).
@return Coordinates|null | getCoordinates | php | thephpleague/geotools | src/Batch/BatchGeocoded.php | https://github.com/thephpleague/geotools/blob/master/src/Batch/BatchGeocoded.php | MIT |
public function fromArray(array $data = [])
{
if (isset($data['providerName'])) {
$this->providerName = $data['providerName'];
}
if (isset($data['query'])) {
$this->query = $data['query'];
}
if (isset($data['exception'])) {
$this->exception = $data['exception'];
}
//GeoCoder Address::createFromArray expects longitude/latitude keys
$data['address']['longitude'] = $data['address']['coordinates']['longitude'] ?? null;
$data['address']['latitude'] = $data['address']['coordinates']['latitude'] ?? null;
// Shortcut to create the address and set it in this class
$this->setAddress(Address::createFromArray($data['address']));
} | Create an instance from an array, used from cache libraries.
@param array $data | fromArray | php | thephpleague/geotools | src/Batch/BatchGeocoded.php | https://github.com/thephpleague/geotools/blob/master/src/Batch/BatchGeocoded.php | MIT |
public function __call($method, $args)
{
if (null === $this->address) {
return null;
}
return call_user_func_array([$this->address, $method], $args);
} | Router all other methods call directly to our address object
@param $method
@param $args
@return mixed | __call | php | thephpleague/geotools | src/Batch/BatchGeocoded.php | https://github.com/thephpleague/geotools/blob/master/src/Batch/BatchGeocoded.php | MIT |
public function __construct($providerName, $query, $exception = '')
{
$this->providerName = $providerName;
$this->query = $query;
$this->exception = $exception;
} | Construct a Geocoded object with the provider name, its query and exception if any.
@param string $providerName The name of the provider.
@param string $query The query.
@param string $exception The exception message if any. | __construct | php | thephpleague/geotools | src/Batch/BatchResult.php | https://github.com/thephpleague/geotools/blob/master/src/Batch/BatchResult.php | MIT |
public function __construct(ProviderAggregator $geocoder)
{
$this->geocoder = $geocoder;
} | Set the Geocoder instance to use.
@param ProviderAggregator $geocoder The Geocoder instance to use. | __construct | php | thephpleague/geotools | src/Batch/Batch.php | https://github.com/thephpleague/geotools/blob/master/src/Batch/Batch.php | MIT |
public function isCached($providerName, $query)
{
if (null === $this->cache) {
return false;
}
$item = $this->cache->getItem($this->getCacheKey($providerName, $query));
if ($item->isHit()) {
return $item->get();
}
return false;
} | Check against the cache instance if any.
@param string $providerName The name of the provider.
@param string $query The query string.
@return boolean|BatchGeocoded The BatchGeocoded object from the query or the cache instance. | isCached | php | thephpleague/geotools | src/Batch/Batch.php | https://github.com/thephpleague/geotools/blob/master/src/Batch/Batch.php | MIT |
public function cache(BatchGeocoded $geocoded)
{
if (isset($this->cache)) {
$key = $this->getCacheKey($geocoded->getProviderName(), $geocoded->getQuery());
$item = $this->cache->getItem($key);
$item->set($geocoded);
$this->cache->save($item);
}
return $geocoded;
} | Cache the BatchGeocoded object.
@param BatchGeocoded $geocoded The BatchGeocoded object to cache.
@return BatchGeocoded The BatchGeocoded object. | cache | php | thephpleague/geotools | src/Batch/Batch.php | https://github.com/thephpleague/geotools/blob/master/src/Batch/Batch.php | MIT |
public function __construct(CoordinateInterface $coordinates)
{
$this->coordinates = $coordinates;
} | Set the coordinate to convert.
@param CoordinateInterface $coordinates The coordinate to convert. | __construct | php | thephpleague/geotools | src/Convert/Convert.php | https://github.com/thephpleague/geotools/blob/master/src/Convert/Convert.php | MIT |
private function parseCoordinate($coordinate)
{
list($degrees) = explode('.', abs($coordinate));
list($minutes) = explode('.', (abs($coordinate) - $degrees) * 60);
return [
'positive' => $coordinate >= 0,
'degrees' => (string) $degrees,
'decimalMinutes' => (string) round((abs($coordinate) - $degrees) * 60,
ConvertInterface::DECIMAL_MINUTES_PRECISION,
ConvertInterface::DECIMAL_MINUTES_MODE),
'minutes' => (string) $minutes,
'seconds' => (string) round(((abs($coordinate) - $degrees) * 60 - $minutes) * 60),
];
} | Parse decimal degrees coordinate to degrees minutes seconds and decimal minutes coordinate.
@param string $coordinate The coordinate to parse.
@return array The replace pairs values. | parseCoordinate | php | thephpleague/geotools | src/Convert/Convert.php | https://github.com/thephpleague/geotools/blob/master/src/Convert/Convert.php | MIT |
public function toDMS($format = ConvertInterface::DEFAULT_DMS_FORMAT)
{
return $this->toDegreesMinutesSeconds($format);
} | Alias of toDegreesMinutesSeconds function.
@param string $format The way to format the DMS coordinate.
@deprecated This alias is deprecated, use toDegreesMinutesSeconds()
@return string Converted and formatted string. | toDMS | php | thephpleague/geotools | src/Convert/Convert.php | https://github.com/thephpleague/geotools/blob/master/src/Convert/Convert.php | MIT |
public function toDM($format = ConvertInterface::DEFAULT_DM_FORMAT)
{
return $this->toDecimalMinutes($format);
} | Alias of toDecimalMinutes function.
@param string $format The way to format the DMS coordinate.
@deprecated This alias is deprecated, use toDecimalMinutes()
@return string Converted and formatted string. | toDM | php | thephpleague/geotools | src/Convert/Convert.php | https://github.com/thephpleague/geotools/blob/master/src/Convert/Convert.php | MIT |
public function toUTM()
{
return $this->toUniversalTransverseMercator();
} | Alias of toUniversalTransverseMercator function.
@deprecated This alias is deprecated, use toUniversalTransverseMercator()
@return string The converted UTM coordinate in meters | toUTM | php | thephpleague/geotools | src/Convert/Convert.php | https://github.com/thephpleague/geotools/blob/master/src/Convert/Convert.php | MIT |
public function flat()
{
Ellipsoid::checkCoordinatesEllipsoid($this->from, $this->to);
$latA = deg2rad($this->from->getLatitude());
$lngA = deg2rad($this->from->getLongitude());
$latB = deg2rad($this->to->getLatitude());
$lngB = deg2rad($this->to->getLongitude());
$x = ($lngB - $lngA) * cos(($latA + $latB) / 2);
$y = $latB - $latA;
$d = sqrt(($x * $x) + ($y * $y)) * $this->from->getEllipsoid()->getA();
return $this->convertToUserUnit($d);
} | Returns the approximate flat distance between two coordinates
using Pythagoras’ theorem which is not very accurate.
@see http://en.wikipedia.org/wiki/Pythagorean_theorem
@see http://en.wikipedia.org/wiki/Equirectangular_projection
@return double The distance in meters | flat | php | thephpleague/geotools | src/Distance/Distance.php | https://github.com/thephpleague/geotools/blob/master/src/Distance/Distance.php | MIT |
public function greatCircle()
{
Ellipsoid::checkCoordinatesEllipsoid($this->from, $this->to);
$latA = deg2rad($this->from->getLatitude());
$lngA = deg2rad($this->from->getLongitude());
$latB = deg2rad($this->to->getLatitude());
$lngB = deg2rad($this->to->getLongitude());
$degrees = acos(sin($latA) * sin($latB) + cos($latA) * cos($latB) * cos($lngB - $lngA));
if (is_nan($degrees)) {
return 0.0;
}
return $this->convertToUserUnit($degrees * $this->from->getEllipsoid()->getA());
} | Returns the approximate distance between two coordinates
using the spherical trigonometry called Great Circle Distance.
@see http://www.ga.gov.au/earth-monitoring/geodesy/geodetic-techniques/distance-calculation-algorithms.html#circle
@see http://en.wikipedia.org/wiki/Cosine_law
@return double The distance in meters | greatCircle | php | thephpleague/geotools | src/Distance/Distance.php | https://github.com/thephpleague/geotools/blob/master/src/Distance/Distance.php | MIT |
public function haversine()
{
Ellipsoid::checkCoordinatesEllipsoid($this->from, $this->to);
$latA = deg2rad($this->from->getLatitude());
$lngA = deg2rad($this->from->getLongitude());
$latB = deg2rad($this->to->getLatitude());
$lngB = deg2rad($this->to->getLongitude());
$dLat = $latB - $latA;
$dLon = $lngB - $lngA;
$a = (sin($dLat / 2) ** 2) + cos($latA) * cos($latB) * (sin($dLon / 2) ** 2);
$c = 2 * asin(sqrt($a));
return $this->convertToUserUnit($this->from->getEllipsoid()->getArithmeticMeanRadius() * $c);
} | Returns the approximate sea level great circle (Earth) distance between
two coordinates using the Haversine formula which is accurate to around 0.3%.
@see http://www.movable-type.co.uk/scripts/latlong.html
@return double The distance in meters | haversine | php | thephpleague/geotools | src/Distance/Distance.php | https://github.com/thephpleague/geotools/blob/master/src/Distance/Distance.php | MIT |
public function vincenty()
{
Ellipsoid::checkCoordinatesEllipsoid($this->from, $this->to);
$a = $this->from->getEllipsoid()->getA();
$b = $this->from->getEllipsoid()->getB();
$f = 1 / $this->from->getEllipsoid()->getInvF();
$lL = deg2rad($this->to->getLongitude() - $this->from->getLongitude());
$u1 = atan((1 - $f) * tan(deg2rad($this->from->getLatitude())));
$u2 = atan((1 - $f) * tan(deg2rad($this->to->getLatitude())));
$sinU1 = sin($u1);
$cosU1 = cos($u1);
$sinU2 = sin($u2);
$cosU2 = cos($u2);
$lambda = $lL;
$iterLimit = 100;
do {
$sinLambda = sin($lambda);
$cosLambda = cos($lambda);
$sinSigma = sqrt(($cosU2 * $sinLambda) * ($cosU2 * $sinLambda) +
($cosU1 * $sinU2 - $sinU1 * $cosU2 * $cosLambda) * ($cosU1 * $sinU2 - $sinU1 * $cosU2 * $cosLambda));
if (0.0 === $sinSigma) {
return 0.0; // co-incident points
}
$cosSigma = $sinU1 * $sinU2 + $cosU1 * $cosU2 * $cosLambda;
$sigma = atan2($sinSigma, $cosSigma);
$sinAlpha = $cosU1 * $cosU2 * $sinLambda / $sinSigma;
$cosSqAlpha = 1 - $sinAlpha * $sinAlpha;
if ($cosSqAlpha != 0.0) {
$cos2SigmaM = $cosSigma - 2 * $sinU1 * $sinU2 / $cosSqAlpha;
}
else {
$cos2SigmaM = 0.0;
}
$cC = $f / 16 * $cosSqAlpha * (4 + $f * (4 - 3 * $cosSqAlpha));
$lambdaP = $lambda;
$lambda = $lL + (1 - $cC) * $f * $sinAlpha * ($sigma + $cC * $sinSigma *
($cos2SigmaM + $cC * $cosSigma * (-1 + 2 * $cos2SigmaM * $cos2SigmaM)));
} while (abs($lambda - $lambdaP) > 1e-12 && --$iterLimit > 0);
// @codeCoverageIgnoreStart
if (0 === $iterLimit) {
throw new NotConvergingException('Vincenty formula failed to converge !');
}
// @codeCoverageIgnoreEnd
$uSq = $cosSqAlpha * ($a * $a - $b * $b) / ($b * $b);
$aA = 1 + $uSq / 16384 * (4096 + $uSq * (-768 + $uSq * (320 - 175 * $uSq)));
$bB = $uSq / 1024 * (256 + $uSq * (-128 + $uSq * (74 - 47 * $uSq)));
$deltaSigma = $bB * $sinSigma * ($cos2SigmaM + $bB / 4 * ($cosSigma * (-1 + 2 * $cos2SigmaM * $cos2SigmaM) -
$bB / 6 * $cos2SigmaM * (-3 + 4 * $sinSigma * $sinSigma) * (-3 + 4 * $cos2SigmaM * $cos2SigmaM)));
$s = $b * $aA * ($sigma - $deltaSigma);
return $this->convertToUserUnit($s);
} | Returns geodetic distance between between two coordinates using Vincenty inverse
formula for ellipsoids which is accurate to within 0.5mm.
@see http://www.movable-type.co.uk/scripts/latlong-vincenty.html
@return double The distance in meters | vincenty | php | thephpleague/geotools | src/Distance/Distance.php | https://github.com/thephpleague/geotools/blob/master/src/Distance/Distance.php | MIT |
protected function convertToUserUnit($meters)
{
switch ($this->unit) {
case GeotoolsInterface::KILOMETER_UNIT:
return $meters / 1000;
case GeotoolsInterface::MILE_UNIT:
return $meters / GeotoolsInterface::METERS_PER_MILE;
case GeotoolsInterface::FOOT_UNIT:
return $meters / GeotoolsInterface::FEET_PER_METER;
default:
return $meters;
}
} | Converts results in meters to user's unit (if any).
The default returned value is in meters.
@param double $meters
@return double | convertToUserUnit | php | thephpleague/geotools | src/Distance/Distance.php | https://github.com/thephpleague/geotools/blob/master/src/Distance/Distance.php | MIT |
protected function getProvider($provider)
{
$provider = $this->lowerize((trim($provider)));
$provider = array_key_exists($provider, $this->providers)
? $this->providers[$provider]
: $this->providers['google_maps'];
return '\\Geocoder\\Provider\\' . $provider . '\\' . $provider;
} | Returns the provider class name.
The default provider is Google Maps.
@param string $provider The name of the provider to use.
@return string The name of the provider class to use. | getProvider | php | thephpleague/geotools | src/CLI/Command/Geocoder/Command.php | https://github.com/thephpleague/geotools/blob/master/src/CLI/Command/Geocoder/Command.php | MIT |
protected function getProviders()
{
ksort($this->providers);
return implode(', ', array_keys($this->providers));
} | Returns the list of available providers sorted by alphabetical order.
@return string The list of available providers comma separated. | getProviders | php | thephpleague/geotools | src/CLI/Command/Geocoder/Command.php | https://github.com/thephpleague/geotools/blob/master/src/CLI/Command/Geocoder/Command.php | MIT |
protected function getDumper($dumper)
{
$dumper = $this->lowerize((trim($dumper)));
$dumper = array_key_exists($dumper, $this->dumpers)
? $this->dumpers[$dumper]
: $this->dumpers['wkt'];
return '\\Geocoder\\Dumper\\' . $dumper;
} | Returns the dumper class name.
The default dumper is WktDumper.
@param string $dumper The name of the dumper to use.
@return string The name of the dumper class to use. | getDumper | php | thephpleague/geotools | src/CLI/Command/Geocoder/Command.php | https://github.com/thephpleague/geotools/blob/master/src/CLI/Command/Geocoder/Command.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.