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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
govCMS/govCMS8 | modules/custom/core/govcms_media/src/Element.php | Element.oxford | public static function oxford(array $items, $conjunction = 'and') {
$count = count($items);
if ($count < 2) {
return (string) reset($items);
}
elseif ($count === 2) {
return reset($items) . ' ' . $conjunction . ' ' . end($items);
}
else {
$items[] = $conjunction . ' ' . array_pop($items);
return implode(', ', $items);
}
} | php | public static function oxford(array $items, $conjunction = 'and') {
$count = count($items);
if ($count < 2) {
return (string) reset($items);
}
elseif ($count === 2) {
return reset($items) . ' ' . $conjunction . ' ' . end($items);
}
else {
$items[] = $conjunction . ' ' . array_pop($items);
return implode(', ', $items);
}
} | [
"public",
"static",
"function",
"oxford",
"(",
"array",
"$",
"items",
",",
"$",
"conjunction",
"=",
"'and'",
")",
"{",
"$",
"count",
"=",
"count",
"(",
"$",
"items",
")",
";",
"if",
"(",
"$",
"count",
"<",
"2",
")",
"{",
"return",
"(",
"string",
")",
"reset",
"(",
"$",
"items",
")",
";",
"}",
"elseif",
"(",
"$",
"count",
"===",
"2",
")",
"{",
"return",
"reset",
"(",
"$",
"items",
")",
".",
"' '",
".",
"$",
"conjunction",
".",
"' '",
".",
"end",
"(",
"$",
"items",
")",
";",
"}",
"else",
"{",
"$",
"items",
"[",
"]",
"=",
"$",
"conjunction",
".",
"' '",
".",
"array_pop",
"(",
"$",
"items",
")",
";",
"return",
"implode",
"(",
"', '",
",",
"$",
"items",
")",
";",
"}",
"}"
] | Formats a set of strings with an Oxford comma.
@param string[] $items
The set of strings to format.
@param string $conjunction
(optional) The translated conjunction to insert before the final item.
Defaults to 'and'.
@return string
The single Oxford-ized string. | [
"Formats",
"a",
"set",
"of",
"strings",
"with",
"an",
"Oxford",
"comma",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Element.php#L112-L125 | train |
govCMS/govCMS8 | modules/custom/core/govcms_media/src/OverrideHelper.php | OverrideHelper.entityClass | public static function entityClass(EntityTypeInterface $entity_type, $replacement_class) {
if (get_parent_class($replacement_class) == $entity_type->getClass()) {
$entity_type->setClass($replacement_class);
}
} | php | public static function entityClass(EntityTypeInterface $entity_type, $replacement_class) {
if (get_parent_class($replacement_class) == $entity_type->getClass()) {
$entity_type->setClass($replacement_class);
}
} | [
"public",
"static",
"function",
"entityClass",
"(",
"EntityTypeInterface",
"$",
"entity_type",
",",
"$",
"replacement_class",
")",
"{",
"if",
"(",
"get_parent_class",
"(",
"$",
"replacement_class",
")",
"==",
"$",
"entity_type",
"->",
"getClass",
"(",
")",
")",
"{",
"$",
"entity_type",
"->",
"setClass",
"(",
"$",
"replacement_class",
")",
";",
"}",
"}"
] | Overrides the entity class for an entity type.
The replacement class is only used if its immediate parent is the class
specified by the entity type.
@param \Drupal\Core\Entity\EntityTypeInterface $entity_type
The entity type definition.
@param string $replacement_class
The class to use. | [
"Overrides",
"the",
"entity",
"class",
"for",
"an",
"entity",
"type",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/OverrideHelper.php#L43-L47 | train |
govCMS/govCMS8 | modules/custom/core/govcms_media/src/OverrideHelper.php | OverrideHelper.entityForm | public static function entityForm(EntityTypeInterface $entity_type, $replacement_class, $operation = 'default') {
if (get_parent_class($replacement_class) == $entity_type->getFormClass($operation)) {
$entity_type->setFormClass($operation, $replacement_class);
}
} | php | public static function entityForm(EntityTypeInterface $entity_type, $replacement_class, $operation = 'default') {
if (get_parent_class($replacement_class) == $entity_type->getFormClass($operation)) {
$entity_type->setFormClass($operation, $replacement_class);
}
} | [
"public",
"static",
"function",
"entityForm",
"(",
"EntityTypeInterface",
"$",
"entity_type",
",",
"$",
"replacement_class",
",",
"$",
"operation",
"=",
"'default'",
")",
"{",
"if",
"(",
"get_parent_class",
"(",
"$",
"replacement_class",
")",
"==",
"$",
"entity_type",
"->",
"getFormClass",
"(",
"$",
"operation",
")",
")",
"{",
"$",
"entity_type",
"->",
"setFormClass",
"(",
"$",
"operation",
",",
"$",
"replacement_class",
")",
";",
"}",
"}"
] | Overrides the class used for an entity form.
The replacement class is only used if its immediate parent is the form
class used for the specified operation.
@param \Drupal\Core\Entity\EntityTypeInterface $entity_type
The entity type definition.
@param string $replacement_class
The class to use.
@param string $operation
(optional) The entity operation. | [
"Overrides",
"the",
"class",
"used",
"for",
"an",
"entity",
"form",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/OverrideHelper.php#L62-L66 | train |
govCMS/govCMS8 | modules/custom/core/govcms_media/src/OverrideHelper.php | OverrideHelper.entityHandler | public static function entityHandler(EntityTypeInterface $entity_type, $handler_type, $replacement_class) {
if (get_parent_class($replacement_class) == $entity_type->getHandlerClass($handler_type)) {
$entity_type->setHandlerClass($handler_type, $replacement_class);
}
} | php | public static function entityHandler(EntityTypeInterface $entity_type, $handler_type, $replacement_class) {
if (get_parent_class($replacement_class) == $entity_type->getHandlerClass($handler_type)) {
$entity_type->setHandlerClass($handler_type, $replacement_class);
}
} | [
"public",
"static",
"function",
"entityHandler",
"(",
"EntityTypeInterface",
"$",
"entity_type",
",",
"$",
"handler_type",
",",
"$",
"replacement_class",
")",
"{",
"if",
"(",
"get_parent_class",
"(",
"$",
"replacement_class",
")",
"==",
"$",
"entity_type",
"->",
"getHandlerClass",
"(",
"$",
"handler_type",
")",
")",
"{",
"$",
"entity_type",
"->",
"setHandlerClass",
"(",
"$",
"handler_type",
",",
"$",
"replacement_class",
")",
";",
"}",
"}"
] | Overrides the class used for an entity handler.
The replacement class is only used if its immediate parent is the handler
class specified by the entity type definition.
@param \Drupal\Core\Entity\EntityTypeInterface $entity_type
The entity type definition.
@param string $handler_type
The handler type.
@param string $replacement_class
The class to use. | [
"Overrides",
"the",
"class",
"used",
"for",
"an",
"entity",
"handler",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/OverrideHelper.php#L81-L85 | train |
govCMS/govCMS8 | modules/custom/core/govcms_media/src/Plugin/EntityBrowser/Widget/FileUpload.php | FileUpload.processUploadElement | public function processUploadElement(array $element, FormStateInterface $form_state) {
$element = AjaxUpload::process($element, $form_state);
$element['upload']['#ajax']['callback'] =
$element['remove']['#ajax']['callback'] = [static::class, 'ajax'];
$element['remove']['#value'] = $this->t('Cancel');
return $element;
} | php | public function processUploadElement(array $element, FormStateInterface $form_state) {
$element = AjaxUpload::process($element, $form_state);
$element['upload']['#ajax']['callback'] =
$element['remove']['#ajax']['callback'] = [static::class, 'ajax'];
$element['remove']['#value'] = $this->t('Cancel');
return $element;
} | [
"public",
"function",
"processUploadElement",
"(",
"array",
"$",
"element",
",",
"FormStateInterface",
"$",
"form_state",
")",
"{",
"$",
"element",
"=",
"AjaxUpload",
"::",
"process",
"(",
"$",
"element",
",",
"$",
"form_state",
")",
";",
"$",
"element",
"[",
"'upload'",
"]",
"[",
"'#ajax'",
"]",
"[",
"'callback'",
"]",
"=",
"$",
"element",
"[",
"'remove'",
"]",
"[",
"'#ajax'",
"]",
"[",
"'callback'",
"]",
"=",
"[",
"static",
"::",
"class",
",",
"'ajax'",
"]",
";",
"$",
"element",
"[",
"'remove'",
"]",
"[",
"'#value'",
"]",
"=",
"$",
"this",
"->",
"t",
"(",
"'Cancel'",
")",
";",
"return",
"$",
"element",
";",
"}"
] | Processes the upload element.
@param array $element
The upload element.
@param \Drupal\Core\Form\FormStateInterface $form_state
The current form state.
@return array
The processed upload element. | [
"Processes",
"the",
"upload",
"element",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/core/govcms_media/src/Plugin/EntityBrowser/Widget/FileUpload.php#L137-L146 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php | ImportProcessorBase.loadEntitiesByProperties | public function loadEntitiesByProperties($entity_type, array $values) {
$entities = $this->entityTypeManager->getStorage($entity_type)->loadByProperties($values);
if (!empty($entities)) {
return $entities;
}
} | php | public function loadEntitiesByProperties($entity_type, array $values) {
$entities = $this->entityTypeManager->getStorage($entity_type)->loadByProperties($values);
if (!empty($entities)) {
return $entities;
}
} | [
"public",
"function",
"loadEntitiesByProperties",
"(",
"$",
"entity_type",
",",
"array",
"$",
"values",
")",
"{",
"$",
"entities",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"$",
"entity_type",
")",
"->",
"loadByProperties",
"(",
"$",
"values",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"entities",
")",
")",
"{",
"return",
"$",
"entities",
";",
"}",
"}"
] | Load entity by property.
@param string $entity_type
Entity type.
@param array $values
An array of properties you want to filter by.
@return \Drupal\Core\Entity\EntityInterface|mixed
An arary of entities.
@throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException | [
"Load",
"entity",
"by",
"property",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php#L77-L83 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php | ImportProcessorBase.mapBasicField | public function mapBasicField(array &$values, $field_name) {
$item = $this->item;
if (!empty($item[$field_name])) {
$values[$field_name] = $item[$field_name];
}
} | php | public function mapBasicField(array &$values, $field_name) {
$item = $this->item;
if (!empty($item[$field_name])) {
$values[$field_name] = $item[$field_name];
}
} | [
"public",
"function",
"mapBasicField",
"(",
"array",
"&",
"$",
"values",
",",
"$",
"field_name",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"item",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"$",
"field_name",
"]",
")",
")",
"{",
"$",
"values",
"[",
"$",
"field_name",
"]",
"=",
"$",
"item",
"[",
"$",
"field_name",
"]",
";",
"}",
"}"
] | Maps a base field.
@param array $values
The values array which is imported.
@param string $field_name
The name of the field. | [
"Maps",
"a",
"base",
"field",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php#L93-L98 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php | ImportProcessorBase.mapParagraphField | public function mapParagraphField(array $paragraphs) {
$entities = \Drupal::classResolver()->getInstanceFromDefinition(InstallHelper::class)->importParagraphs($paragraphs);
if (!empty($entities)) {
return $entities;
}
return [];
} | php | public function mapParagraphField(array $paragraphs) {
$entities = \Drupal::classResolver()->getInstanceFromDefinition(InstallHelper::class)->importParagraphs($paragraphs);
if (!empty($entities)) {
return $entities;
}
return [];
} | [
"public",
"function",
"mapParagraphField",
"(",
"array",
"$",
"paragraphs",
")",
"{",
"$",
"entities",
"=",
"\\",
"Drupal",
"::",
"classResolver",
"(",
")",
"->",
"getInstanceFromDefinition",
"(",
"InstallHelper",
"::",
"class",
")",
"->",
"importParagraphs",
"(",
"$",
"paragraphs",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"entities",
")",
")",
"{",
"return",
"$",
"entities",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Maps a paragraph field.
@param array $paragraphs
An array of paragraph machine names.
@return array
An array of entities. | [
"Maps",
"a",
"paragraph",
"field",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php#L109-L115 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php | ImportProcessorBase.populateMediaField | public function populateMediaField($field_name) {
$item = $this->item;
$assets = [];
if (!empty($item[$field_name])) {
$data = $this->loadDataArray('media_image');
foreach ($item[$field_name] as $k => $value) {
if (!empty($data[$value])) {
$name = $data[$value]['name'];
$entities = $this->loadEntitiesByProperties('media', ['name' => $name]);
foreach ($entities as $entity) {
$assets[] = ['target_id' => $entity->id()];
}
}
}
return $assets;
}
} | php | public function populateMediaField($field_name) {
$item = $this->item;
$assets = [];
if (!empty($item[$field_name])) {
$data = $this->loadDataArray('media_image');
foreach ($item[$field_name] as $k => $value) {
if (!empty($data[$value])) {
$name = $data[$value]['name'];
$entities = $this->loadEntitiesByProperties('media', ['name' => $name]);
foreach ($entities as $entity) {
$assets[] = ['target_id' => $entity->id()];
}
}
}
return $assets;
}
} | [
"public",
"function",
"populateMediaField",
"(",
"$",
"field_name",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"item",
";",
"$",
"assets",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"$",
"field_name",
"]",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataArray",
"(",
"'media_image'",
")",
";",
"foreach",
"(",
"$",
"item",
"[",
"$",
"field_name",
"]",
"as",
"$",
"k",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"$",
"value",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"data",
"[",
"$",
"value",
"]",
"[",
"'name'",
"]",
";",
"$",
"entities",
"=",
"$",
"this",
"->",
"loadEntitiesByProperties",
"(",
"'media'",
",",
"[",
"'name'",
"=>",
"$",
"name",
"]",
")",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"assets",
"[",
"]",
"=",
"[",
"'target_id'",
"=>",
"$",
"entity",
"->",
"id",
"(",
")",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"assets",
";",
"}",
"}"
] | Finds a media asset by name.
@param string $field_name
Field name.
@return array
Returns media entities. | [
"Finds",
"a",
"media",
"asset",
"by",
"name",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php#L143-L161 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php | ImportProcessorBase.mapTaxonomyTermField | public function mapTaxonomyTermField($field_name, $vid) {
$entities = $this->populateTaxonomyTermField($field_name, $vid);
if (!empty($entities)) {
return $entities;
}
return [];
} | php | public function mapTaxonomyTermField($field_name, $vid) {
$entities = $this->populateTaxonomyTermField($field_name, $vid);
if (!empty($entities)) {
return $entities;
}
return [];
} | [
"public",
"function",
"mapTaxonomyTermField",
"(",
"$",
"field_name",
",",
"$",
"vid",
")",
"{",
"$",
"entities",
"=",
"$",
"this",
"->",
"populateTaxonomyTermField",
"(",
"$",
"field_name",
",",
"$",
"vid",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"entities",
")",
")",
"{",
"return",
"$",
"entities",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Maps a taxonomy field.
@param string $field_name
Field name.
@param string $vid
Taxonomy vid.
@return array
Returns media entities. | [
"Maps",
"a",
"taxonomy",
"field",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php#L174-L180 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php | ImportProcessorBase.populateTaxonomyTermField | public function populateTaxonomyTermField($field_name, $vid) {
$item = $this->item;
$terms = [];
if (!empty($item[$field_name])) {
$data = $this->loadDataArray('taxonomy');
foreach ($item[$field_name] as $k => $value) {
if (!empty($data[$value])) {
$name = $data[$value]['name'];
$entities = $this->loadEntitiesByProperties('taxonomy_term', ['name' => $name, 'vid' => $vid]);
foreach ($entities as $entity) {
$terms[] = ['target_id' => $entity->id()];
}
}
}
return $terms;
}
} | php | public function populateTaxonomyTermField($field_name, $vid) {
$item = $this->item;
$terms = [];
if (!empty($item[$field_name])) {
$data = $this->loadDataArray('taxonomy');
foreach ($item[$field_name] as $k => $value) {
if (!empty($data[$value])) {
$name = $data[$value]['name'];
$entities = $this->loadEntitiesByProperties('taxonomy_term', ['name' => $name, 'vid' => $vid]);
foreach ($entities as $entity) {
$terms[] = ['target_id' => $entity->id()];
}
}
}
return $terms;
}
} | [
"public",
"function",
"populateTaxonomyTermField",
"(",
"$",
"field_name",
",",
"$",
"vid",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"item",
";",
"$",
"terms",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"$",
"field_name",
"]",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataArray",
"(",
"'taxonomy'",
")",
";",
"foreach",
"(",
"$",
"item",
"[",
"$",
"field_name",
"]",
"as",
"$",
"k",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"$",
"value",
"]",
")",
")",
"{",
"$",
"name",
"=",
"$",
"data",
"[",
"$",
"value",
"]",
"[",
"'name'",
"]",
";",
"$",
"entities",
"=",
"$",
"this",
"->",
"loadEntitiesByProperties",
"(",
"'taxonomy_term'",
",",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'vid'",
"=>",
"$",
"vid",
"]",
")",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"terms",
"[",
"]",
"=",
"[",
"'target_id'",
"=>",
"$",
"entity",
"->",
"id",
"(",
")",
"]",
";",
"}",
"}",
"}",
"return",
"$",
"terms",
";",
"}",
"}"
] | Finds taxonomy terms by name and vid.
@param string $field_name
Field name.
@param string $vid
Taxonomy vid.
@return array
Returns media entities. | [
"Finds",
"taxonomy",
"terms",
"by",
"name",
"and",
"vid",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php#L193-L211 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php | ImportProcessorBase.populateEntityReferenceField | public function populateEntityReferenceField($field_name) {
$item = $this->item;
$node = [];
if (!empty($item[$field_name])) {
$data = $this->loadDataArray('node');
foreach ($item[$field_name] as $k => $value) {
if (!empty($data[$value])) {
$title = $data[$value]['title'];
$entities = $this->loadEntitiesByProperties('node', ['title' => $title]);
foreach ($entities as $entity) {
$node[] = ['target_id' => $entity->id()];
}
}
}
}
return $node;
} | php | public function populateEntityReferenceField($field_name) {
$item = $this->item;
$node = [];
if (!empty($item[$field_name])) {
$data = $this->loadDataArray('node');
foreach ($item[$field_name] as $k => $value) {
if (!empty($data[$value])) {
$title = $data[$value]['title'];
$entities = $this->loadEntitiesByProperties('node', ['title' => $title]);
foreach ($entities as $entity) {
$node[] = ['target_id' => $entity->id()];
}
}
}
}
return $node;
} | [
"public",
"function",
"populateEntityReferenceField",
"(",
"$",
"field_name",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"item",
";",
"$",
"node",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"$",
"field_name",
"]",
")",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataArray",
"(",
"'node'",
")",
";",
"foreach",
"(",
"$",
"item",
"[",
"$",
"field_name",
"]",
"as",
"$",
"k",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"$",
"value",
"]",
")",
")",
"{",
"$",
"title",
"=",
"$",
"data",
"[",
"$",
"value",
"]",
"[",
"'title'",
"]",
";",
"$",
"entities",
"=",
"$",
"this",
"->",
"loadEntitiesByProperties",
"(",
"'node'",
",",
"[",
"'title'",
"=>",
"$",
"title",
"]",
")",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"node",
"[",
"]",
"=",
"[",
"'target_id'",
"=>",
"$",
"entity",
"->",
"id",
"(",
")",
"]",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"node",
";",
"}"
] | Finds nodes by machine name.
@param string $field_name
Field name.
@return array
Returns entities. | [
"Finds",
"nodes",
"by",
"machine",
"name",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/ImportProcessorBase.php#L239-L257 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.importPages | protected function importPages() {
$data = $this->loadDataArray('node');
if (!empty($data)) {
$uuids = [];
foreach ($data as $item) {
// Prepare content.
$values = [
'type' => $item['type'],
'title' => $item['title'],
];
// Fields mapping starts.
// Set Body Field.
if (!empty($item['body'])) {
$body = $this->getBodyData($item['body']);
if ($body !== FALSE) {
$values['body'] = [
'value' => $body,
'format' => 'rich_text',
];
}
}
if (!empty($item['summary'])) {
$values['body']['summary'] = $item['summary'];
}
// Set node alias if exists.
if (!empty($item['path'])) {
$values['path'] = [
'alias' => $item['path'],
'pathauto' => 0,
];
}
$this->loadProcessorPlugins($values, $item, 'node');
// Set article author.
$values['uid'] = 1;
// Create Node.
$node = $this->entityTypeManager->getStorage('node')->create($values);
$node->setPublished(TRUE);
$node->set('moderation_state', "published");
$node->save();
// Create menu links.
if (!empty($item['menu'])) {
$item['menu']['link'] = [
'uri' => 'internal:/node/' . $node->id(),
];
$menu_link = $this->entityTypeManager->getStorage('menu_link_content')->create($item['menu']);
$menu_link->save();
}
// Set page to front page is 'front_page' is equals TRUE.
if (!empty($item['front_page']) && $item['front_page'] == TRUE) {
\Drupal::service('config.factory')->getEditable('system.site')->set('page.front', '/node/' . $node->id())->save();
}
$uuids[$node->uuid()] = 'node';
}
$this->storeCreatedContentUuids($uuids);
}
return $this;
} | php | protected function importPages() {
$data = $this->loadDataArray('node');
if (!empty($data)) {
$uuids = [];
foreach ($data as $item) {
// Prepare content.
$values = [
'type' => $item['type'],
'title' => $item['title'],
];
// Fields mapping starts.
// Set Body Field.
if (!empty($item['body'])) {
$body = $this->getBodyData($item['body']);
if ($body !== FALSE) {
$values['body'] = [
'value' => $body,
'format' => 'rich_text',
];
}
}
if (!empty($item['summary'])) {
$values['body']['summary'] = $item['summary'];
}
// Set node alias if exists.
if (!empty($item['path'])) {
$values['path'] = [
'alias' => $item['path'],
'pathauto' => 0,
];
}
$this->loadProcessorPlugins($values, $item, 'node');
// Set article author.
$values['uid'] = 1;
// Create Node.
$node = $this->entityTypeManager->getStorage('node')->create($values);
$node->setPublished(TRUE);
$node->set('moderation_state', "published");
$node->save();
// Create menu links.
if (!empty($item['menu'])) {
$item['menu']['link'] = [
'uri' => 'internal:/node/' . $node->id(),
];
$menu_link = $this->entityTypeManager->getStorage('menu_link_content')->create($item['menu']);
$menu_link->save();
}
// Set page to front page is 'front_page' is equals TRUE.
if (!empty($item['front_page']) && $item['front_page'] == TRUE) {
\Drupal::service('config.factory')->getEditable('system.site')->set('page.front', '/node/' . $node->id())->save();
}
$uuids[$node->uuid()] = 'node';
}
$this->storeCreatedContentUuids($uuids);
}
return $this;
} | [
"protected",
"function",
"importPages",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataArray",
"(",
"'node'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"uuids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"// Prepare content.",
"$",
"values",
"=",
"[",
"'type'",
"=>",
"$",
"item",
"[",
"'type'",
"]",
",",
"'title'",
"=>",
"$",
"item",
"[",
"'title'",
"]",
",",
"]",
";",
"// Fields mapping starts.",
"// Set Body Field.",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'body'",
"]",
")",
")",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"getBodyData",
"(",
"$",
"item",
"[",
"'body'",
"]",
")",
";",
"if",
"(",
"$",
"body",
"!==",
"FALSE",
")",
"{",
"$",
"values",
"[",
"'body'",
"]",
"=",
"[",
"'value'",
"=>",
"$",
"body",
",",
"'format'",
"=>",
"'rich_text'",
",",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'summary'",
"]",
")",
")",
"{",
"$",
"values",
"[",
"'body'",
"]",
"[",
"'summary'",
"]",
"=",
"$",
"item",
"[",
"'summary'",
"]",
";",
"}",
"// Set node alias if exists.",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'path'",
"]",
")",
")",
"{",
"$",
"values",
"[",
"'path'",
"]",
"=",
"[",
"'alias'",
"=>",
"$",
"item",
"[",
"'path'",
"]",
",",
"'pathauto'",
"=>",
"0",
",",
"]",
";",
"}",
"$",
"this",
"->",
"loadProcessorPlugins",
"(",
"$",
"values",
",",
"$",
"item",
",",
"'node'",
")",
";",
"// Set article author.",
"$",
"values",
"[",
"'uid'",
"]",
"=",
"1",
";",
"// Create Node.",
"$",
"node",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'node'",
")",
"->",
"create",
"(",
"$",
"values",
")",
";",
"$",
"node",
"->",
"setPublished",
"(",
"TRUE",
")",
";",
"$",
"node",
"->",
"set",
"(",
"'moderation_state'",
",",
"\"published\"",
")",
";",
"$",
"node",
"->",
"save",
"(",
")",
";",
"// Create menu links.",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'menu'",
"]",
")",
")",
"{",
"$",
"item",
"[",
"'menu'",
"]",
"[",
"'link'",
"]",
"=",
"[",
"'uri'",
"=>",
"'internal:/node/'",
".",
"$",
"node",
"->",
"id",
"(",
")",
",",
"]",
";",
"$",
"menu_link",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'menu_link_content'",
")",
"->",
"create",
"(",
"$",
"item",
"[",
"'menu'",
"]",
")",
";",
"$",
"menu_link",
"->",
"save",
"(",
")",
";",
"}",
"// Set page to front page is 'front_page' is equals TRUE.",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'front_page'",
"]",
")",
"&&",
"$",
"item",
"[",
"'front_page'",
"]",
"==",
"TRUE",
")",
"{",
"\\",
"Drupal",
"::",
"service",
"(",
"'config.factory'",
")",
"->",
"getEditable",
"(",
"'system.site'",
")",
"->",
"set",
"(",
"'page.front'",
",",
"'/node/'",
".",
"$",
"node",
"->",
"id",
"(",
")",
")",
"->",
"save",
"(",
")",
";",
"}",
"$",
"uuids",
"[",
"$",
"node",
"->",
"uuid",
"(",
")",
"]",
"=",
"'node'",
";",
"}",
"$",
"this",
"->",
"storeCreatedContentUuids",
"(",
"$",
"uuids",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Imports pages. | [
"Imports",
"pages",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L95-L160 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.importMediaImages | protected function importMediaImages() {
$data = $this->loadDataArray('media_image');
if (!empty($data)) {
$uuids = [];
foreach ($data as $item) {
// Prepare content.
$values = [
'bundle' => $item['bundle'],
'name' => $item['name'],
];
$file = $this->saveFile($item['file']);
if (!empty($file) && $file instanceof File) {
$values['field_media_image'] = [
'target_id' => $file->id(),
'alt' => $item['alt'],
];
}
// Set author.
$values['uid'] = 1;
// Create Media.
$entity = $this->entityTypeManager->getStorage('media')->create($values);
$entity->save();
$uuids[$entity->uuid()] = 'media';
}
$this->storeCreatedContentUuids($uuids);
}
return $this;
} | php | protected function importMediaImages() {
$data = $this->loadDataArray('media_image');
if (!empty($data)) {
$uuids = [];
foreach ($data as $item) {
// Prepare content.
$values = [
'bundle' => $item['bundle'],
'name' => $item['name'],
];
$file = $this->saveFile($item['file']);
if (!empty($file) && $file instanceof File) {
$values['field_media_image'] = [
'target_id' => $file->id(),
'alt' => $item['alt'],
];
}
// Set author.
$values['uid'] = 1;
// Create Media.
$entity = $this->entityTypeManager->getStorage('media')->create($values);
$entity->save();
$uuids[$entity->uuid()] = 'media';
}
$this->storeCreatedContentUuids($uuids);
}
return $this;
} | [
"protected",
"function",
"importMediaImages",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataArray",
"(",
"'media_image'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"uuids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"// Prepare content.",
"$",
"values",
"=",
"[",
"'bundle'",
"=>",
"$",
"item",
"[",
"'bundle'",
"]",
",",
"'name'",
"=>",
"$",
"item",
"[",
"'name'",
"]",
",",
"]",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"saveFile",
"(",
"$",
"item",
"[",
"'file'",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"file",
")",
"&&",
"$",
"file",
"instanceof",
"File",
")",
"{",
"$",
"values",
"[",
"'field_media_image'",
"]",
"=",
"[",
"'target_id'",
"=>",
"$",
"file",
"->",
"id",
"(",
")",
",",
"'alt'",
"=>",
"$",
"item",
"[",
"'alt'",
"]",
",",
"]",
";",
"}",
"// Set author.",
"$",
"values",
"[",
"'uid'",
"]",
"=",
"1",
";",
"// Create Media.",
"$",
"entity",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'media'",
")",
"->",
"create",
"(",
"$",
"values",
")",
";",
"$",
"entity",
"->",
"save",
"(",
")",
";",
"$",
"uuids",
"[",
"$",
"entity",
"->",
"uuid",
"(",
")",
"]",
"=",
"'media'",
";",
"}",
"$",
"this",
"->",
"storeCreatedContentUuids",
"(",
"$",
"uuids",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Import media assets. | [
"Import",
"media",
"assets",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L165-L199 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.importTaxonomyTerms | protected function importTaxonomyTerms() {
$data = $this->loadDataArray('taxonomy');
if (!empty($data)) {
$uuids = [];
foreach ($data as $item) {
// Prepare content.
$values = [
'vid' => $item['vid'],
'name' => $item['name'],
];
// Set author.
$values['uid'] = 1;
// Create Media.
$entity = $this->entityTypeManager->getStorage('taxonomy_term')->create($values);
$entity->save();
$uuids[$entity->uuid()] = 'taxonomy_term';
}
$this->storeCreatedContentUuids($uuids);
}
return $this;
} | php | protected function importTaxonomyTerms() {
$data = $this->loadDataArray('taxonomy');
if (!empty($data)) {
$uuids = [];
foreach ($data as $item) {
// Prepare content.
$values = [
'vid' => $item['vid'],
'name' => $item['name'],
];
// Set author.
$values['uid'] = 1;
// Create Media.
$entity = $this->entityTypeManager->getStorage('taxonomy_term')->create($values);
$entity->save();
$uuids[$entity->uuid()] = 'taxonomy_term';
}
$this->storeCreatedContentUuids($uuids);
}
return $this;
} | [
"protected",
"function",
"importTaxonomyTerms",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataArray",
"(",
"'taxonomy'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"$",
"uuids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"item",
")",
"{",
"// Prepare content.",
"$",
"values",
"=",
"[",
"'vid'",
"=>",
"$",
"item",
"[",
"'vid'",
"]",
",",
"'name'",
"=>",
"$",
"item",
"[",
"'name'",
"]",
",",
"]",
";",
"// Set author.",
"$",
"values",
"[",
"'uid'",
"]",
"=",
"1",
";",
"// Create Media.",
"$",
"entity",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'taxonomy_term'",
")",
"->",
"create",
"(",
"$",
"values",
")",
";",
"$",
"entity",
"->",
"save",
"(",
")",
";",
"$",
"uuids",
"[",
"$",
"entity",
"->",
"uuid",
"(",
")",
"]",
"=",
"'taxonomy_term'",
";",
"}",
"$",
"this",
"->",
"storeCreatedContentUuids",
"(",
"$",
"uuids",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Import taxonomy terms. | [
"Import",
"taxonomy",
"terms",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L204-L229 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.importParagraphs | public function importParagraphs(array $paragraphs) {
$data = $this->loadDataArray('paragraph');
$paragraph_items = [];
$uuids = [];
foreach ($paragraphs as $k => $paragraph_data) {
$item = $data[$paragraph_data];
if (!empty($item)) {
// Prepare content.
$values = [
'type' => $item['type'],
];
if (!empty($item['field_body'])) {
$body = $this->getBodyData($item['field_body']);
if ($body !== FALSE) {
$values['field_body'] = [
'value' => $body,
'format' => 'rich_text',
];
}
}
if (!empty($item['field_title'])) {
$values['field_title'] = $item['field_title'];
}
if (!empty($item['field_heading'])) {
$values['field_heading'] = $item['field_heading'];
}
$this->loadProcessorPlugins($values, $item, 'paragraph');
// Set author.
$values['uid'] = 1;
// Create Media.
$entity = $this->entityTypeManager->getStorage('paragraph')->create($values);
$entity->save();
$uuids[$entity->uuid()] = 'paragraph';
$paragraph_items[] = $entity;
}
}
$this->storeCreatedContentUuids($uuids);
return $paragraph_items;
} | php | public function importParagraphs(array $paragraphs) {
$data = $this->loadDataArray('paragraph');
$paragraph_items = [];
$uuids = [];
foreach ($paragraphs as $k => $paragraph_data) {
$item = $data[$paragraph_data];
if (!empty($item)) {
// Prepare content.
$values = [
'type' => $item['type'],
];
if (!empty($item['field_body'])) {
$body = $this->getBodyData($item['field_body']);
if ($body !== FALSE) {
$values['field_body'] = [
'value' => $body,
'format' => 'rich_text',
];
}
}
if (!empty($item['field_title'])) {
$values['field_title'] = $item['field_title'];
}
if (!empty($item['field_heading'])) {
$values['field_heading'] = $item['field_heading'];
}
$this->loadProcessorPlugins($values, $item, 'paragraph');
// Set author.
$values['uid'] = 1;
// Create Media.
$entity = $this->entityTypeManager->getStorage('paragraph')->create($values);
$entity->save();
$uuids[$entity->uuid()] = 'paragraph';
$paragraph_items[] = $entity;
}
}
$this->storeCreatedContentUuids($uuids);
return $paragraph_items;
} | [
"public",
"function",
"importParagraphs",
"(",
"array",
"$",
"paragraphs",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"loadDataArray",
"(",
"'paragraph'",
")",
";",
"$",
"paragraph_items",
"=",
"[",
"]",
";",
"$",
"uuids",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"paragraphs",
"as",
"$",
"k",
"=>",
"$",
"paragraph_data",
")",
"{",
"$",
"item",
"=",
"$",
"data",
"[",
"$",
"paragraph_data",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
")",
")",
"{",
"// Prepare content.",
"$",
"values",
"=",
"[",
"'type'",
"=>",
"$",
"item",
"[",
"'type'",
"]",
",",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'field_body'",
"]",
")",
")",
"{",
"$",
"body",
"=",
"$",
"this",
"->",
"getBodyData",
"(",
"$",
"item",
"[",
"'field_body'",
"]",
")",
";",
"if",
"(",
"$",
"body",
"!==",
"FALSE",
")",
"{",
"$",
"values",
"[",
"'field_body'",
"]",
"=",
"[",
"'value'",
"=>",
"$",
"body",
",",
"'format'",
"=>",
"'rich_text'",
",",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'field_title'",
"]",
")",
")",
"{",
"$",
"values",
"[",
"'field_title'",
"]",
"=",
"$",
"item",
"[",
"'field_title'",
"]",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"[",
"'field_heading'",
"]",
")",
")",
"{",
"$",
"values",
"[",
"'field_heading'",
"]",
"=",
"$",
"item",
"[",
"'field_heading'",
"]",
";",
"}",
"$",
"this",
"->",
"loadProcessorPlugins",
"(",
"$",
"values",
",",
"$",
"item",
",",
"'paragraph'",
")",
";",
"// Set author.",
"$",
"values",
"[",
"'uid'",
"]",
"=",
"1",
";",
"// Create Media.",
"$",
"entity",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'paragraph'",
")",
"->",
"create",
"(",
"$",
"values",
")",
";",
"$",
"entity",
"->",
"save",
"(",
")",
";",
"$",
"uuids",
"[",
"$",
"entity",
"->",
"uuid",
"(",
")",
"]",
"=",
"'paragraph'",
";",
"$",
"paragraph_items",
"[",
"]",
"=",
"$",
"entity",
";",
"}",
"}",
"$",
"this",
"->",
"storeCreatedContentUuids",
"(",
"$",
"uuids",
")",
";",
"return",
"$",
"paragraph_items",
";",
"}"
] | Import paragraphs. | [
"Import",
"paragraphs",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L234-L283 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.getBodyData | public function getBodyData($body) {
$module_path = $this->moduleHandler->getModule('govcms8_default_content')->getPath();
if (!empty($body)) {
if (is_array($body) && !empty($body['file'])) {
$file = $body['file'];
$body_path = $module_path . '/import/html_body/' . $file;
$body_html = file_get_contents($body_path);
if ($body_html !== FALSE) {
return $body_html;
}
}
else {
return $body;
}
}
} | php | public function getBodyData($body) {
$module_path = $this->moduleHandler->getModule('govcms8_default_content')->getPath();
if (!empty($body)) {
if (is_array($body) && !empty($body['file'])) {
$file = $body['file'];
$body_path = $module_path . '/import/html_body/' . $file;
$body_html = file_get_contents($body_path);
if ($body_html !== FALSE) {
return $body_html;
}
}
else {
return $body;
}
}
} | [
"public",
"function",
"getBodyData",
"(",
"$",
"body",
")",
"{",
"$",
"module_path",
"=",
"$",
"this",
"->",
"moduleHandler",
"->",
"getModule",
"(",
"'govcms8_default_content'",
")",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"body",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"body",
")",
"&&",
"!",
"empty",
"(",
"$",
"body",
"[",
"'file'",
"]",
")",
")",
"{",
"$",
"file",
"=",
"$",
"body",
"[",
"'file'",
"]",
";",
"$",
"body_path",
"=",
"$",
"module_path",
".",
"'/import/html_body/'",
".",
"$",
"file",
";",
"$",
"body_html",
"=",
"file_get_contents",
"(",
"$",
"body_path",
")",
";",
"if",
"(",
"$",
"body_html",
"!==",
"FALSE",
")",
"{",
"return",
"$",
"body_html",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"body",
";",
"}",
"}",
"}"
] | Retrieves the body data from the array value or an HTML file.
@param mixed $body
Body field.
@return mixed
An array of data. | [
"Retrieves",
"the",
"body",
"data",
"from",
"the",
"array",
"value",
"or",
"an",
"HTML",
"file",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L294-L309 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.loadProcessorPlugins | public function loadProcessorPlugins(&$values, $item, $entity_type) {
$manager = \Drupal::service('plugin.manager.import_processor');
$import_processors = $manager->getDefinitions();
foreach ($import_processors as $plugin_id => $import_processor) {
if ($import_processor['type'] == $entity_type . ':' . $item['type']) {
/** @var \Drupal\govcms8_default_content\ImportProcessorBase $processor */
$processor = $manager->createInstance($plugin_id);
$processor->setItem($item);
$processor->process($values);
}
}
} | php | public function loadProcessorPlugins(&$values, $item, $entity_type) {
$manager = \Drupal::service('plugin.manager.import_processor');
$import_processors = $manager->getDefinitions();
foreach ($import_processors as $plugin_id => $import_processor) {
if ($import_processor['type'] == $entity_type . ':' . $item['type']) {
/** @var \Drupal\govcms8_default_content\ImportProcessorBase $processor */
$processor = $manager->createInstance($plugin_id);
$processor->setItem($item);
$processor->process($values);
}
}
} | [
"public",
"function",
"loadProcessorPlugins",
"(",
"&",
"$",
"values",
",",
"$",
"item",
",",
"$",
"entity_type",
")",
"{",
"$",
"manager",
"=",
"\\",
"Drupal",
"::",
"service",
"(",
"'plugin.manager.import_processor'",
")",
";",
"$",
"import_processors",
"=",
"$",
"manager",
"->",
"getDefinitions",
"(",
")",
";",
"foreach",
"(",
"$",
"import_processors",
"as",
"$",
"plugin_id",
"=>",
"$",
"import_processor",
")",
"{",
"if",
"(",
"$",
"import_processor",
"[",
"'type'",
"]",
"==",
"$",
"entity_type",
".",
"':'",
".",
"$",
"item",
"[",
"'type'",
"]",
")",
"{",
"/** @var \\Drupal\\govcms8_default_content\\ImportProcessorBase $processor */",
"$",
"processor",
"=",
"$",
"manager",
"->",
"createInstance",
"(",
"$",
"plugin_id",
")",
";",
"$",
"processor",
"->",
"setItem",
"(",
"$",
"item",
")",
";",
"$",
"processor",
"->",
"process",
"(",
"$",
"values",
")",
";",
"}",
"}",
"}"
] | Helper method used to load the correct plugin. | [
"Helper",
"method",
"used",
"to",
"load",
"the",
"correct",
"plugin",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L314-L325 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.saveFile | public function saveFile($file_name) {
$path = 'public://govcms8-demo';
if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
$source = DRUPAL_ROOT . '/' . drupal_get_path('module', 'govcms8_default_content') . '/import/images/' . $file_name;
$data = file_get_contents($source);
return file_save_data($data, "public://govcms8-demo/" . $file_name, FILE_EXISTS_RENAME);
}
} | php | public function saveFile($file_name) {
$path = 'public://govcms8-demo';
if (file_prepare_directory($path, FILE_CREATE_DIRECTORY)) {
$source = DRUPAL_ROOT . '/' . drupal_get_path('module', 'govcms8_default_content') . '/import/images/' . $file_name;
$data = file_get_contents($source);
return file_save_data($data, "public://govcms8-demo/" . $file_name, FILE_EXISTS_RENAME);
}
} | [
"public",
"function",
"saveFile",
"(",
"$",
"file_name",
")",
"{",
"$",
"path",
"=",
"'public://govcms8-demo'",
";",
"if",
"(",
"file_prepare_directory",
"(",
"$",
"path",
",",
"FILE_CREATE_DIRECTORY",
")",
")",
"{",
"$",
"source",
"=",
"DRUPAL_ROOT",
".",
"'/'",
".",
"drupal_get_path",
"(",
"'module'",
",",
"'govcms8_default_content'",
")",
".",
"'/import/images/'",
".",
"$",
"file_name",
";",
"$",
"data",
"=",
"file_get_contents",
"(",
"$",
"source",
")",
";",
"return",
"file_save_data",
"(",
"$",
"data",
",",
"\"public://govcms8-demo/\"",
".",
"$",
"file_name",
",",
"FILE_EXISTS_RENAME",
")",
";",
"}",
"}"
] | Save a file during the media import. | [
"Save",
"a",
"file",
"during",
"the",
"media",
"import",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L330-L337 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.deleteImportedContent | public function deleteImportedContent() {
$uuids = $this->state->get('govcms8_default_content_uuids', []);
$by_entity_type = array_reduce(array_keys($uuids), function ($carry, $uuid) use ($uuids) {
$entity_type_id = $uuids[$uuid];
$carry[$entity_type_id][] = $uuid;
return $carry;
}, []);
foreach ($by_entity_type as $entity_type_id => $entity_uuids) {
$storage = $this->entityTypeManager->getStorage($entity_type_id);
$entities = $storage->loadByProperties(['uuid' => $entity_uuids]);
$storage->delete($entities);
}
return $this;
} | php | public function deleteImportedContent() {
$uuids = $this->state->get('govcms8_default_content_uuids', []);
$by_entity_type = array_reduce(array_keys($uuids), function ($carry, $uuid) use ($uuids) {
$entity_type_id = $uuids[$uuid];
$carry[$entity_type_id][] = $uuid;
return $carry;
}, []);
foreach ($by_entity_type as $entity_type_id => $entity_uuids) {
$storage = $this->entityTypeManager->getStorage($entity_type_id);
$entities = $storage->loadByProperties(['uuid' => $entity_uuids]);
$storage->delete($entities);
}
return $this;
} | [
"public",
"function",
"deleteImportedContent",
"(",
")",
"{",
"$",
"uuids",
"=",
"$",
"this",
"->",
"state",
"->",
"get",
"(",
"'govcms8_default_content_uuids'",
",",
"[",
"]",
")",
";",
"$",
"by_entity_type",
"=",
"array_reduce",
"(",
"array_keys",
"(",
"$",
"uuids",
")",
",",
"function",
"(",
"$",
"carry",
",",
"$",
"uuid",
")",
"use",
"(",
"$",
"uuids",
")",
"{",
"$",
"entity_type_id",
"=",
"$",
"uuids",
"[",
"$",
"uuid",
"]",
";",
"$",
"carry",
"[",
"$",
"entity_type_id",
"]",
"[",
"]",
"=",
"$",
"uuid",
";",
"return",
"$",
"carry",
";",
"}",
",",
"[",
"]",
")",
";",
"foreach",
"(",
"$",
"by_entity_type",
"as",
"$",
"entity_type_id",
"=>",
"$",
"entity_uuids",
")",
"{",
"$",
"storage",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"$",
"entity_type_id",
")",
";",
"$",
"entities",
"=",
"$",
"storage",
"->",
"loadByProperties",
"(",
"[",
"'uuid'",
"=>",
"$",
"entity_uuids",
"]",
")",
";",
"$",
"storage",
"->",
"delete",
"(",
"$",
"entities",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Deletes any content imported by this module.
@return $this | [
"Deletes",
"any",
"content",
"imported",
"by",
"this",
"module",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L362-L375 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.getUser | protected function getUser($name) {
$user_storage = $this->entityTypeManager->getStorage('user');
$users = $user_storage->loadByProperties(['name' => $name]);;
if (empty($users)) {
// Creating user without any email/password.
$user = $user_storage->create([
'name' => $name,
'status' => 1,
]);
$user->enforceIsNew();
$user->save();
$this->storeCreatedContentUuids([$user->uuid() => 'user']);
return $user->id();
}
$user = reset($users);
return $user->id();
} | php | protected function getUser($name) {
$user_storage = $this->entityTypeManager->getStorage('user');
$users = $user_storage->loadByProperties(['name' => $name]);;
if (empty($users)) {
// Creating user without any email/password.
$user = $user_storage->create([
'name' => $name,
'status' => 1,
]);
$user->enforceIsNew();
$user->save();
$this->storeCreatedContentUuids([$user->uuid() => 'user']);
return $user->id();
}
$user = reset($users);
return $user->id();
} | [
"protected",
"function",
"getUser",
"(",
"$",
"name",
")",
"{",
"$",
"user_storage",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'user'",
")",
";",
"$",
"users",
"=",
"$",
"user_storage",
"->",
"loadByProperties",
"(",
"[",
"'name'",
"=>",
"$",
"name",
"]",
")",
";",
";",
"if",
"(",
"empty",
"(",
"$",
"users",
")",
")",
"{",
"// Creating user without any email/password.",
"$",
"user",
"=",
"$",
"user_storage",
"->",
"create",
"(",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'status'",
"=>",
"1",
",",
"]",
")",
";",
"$",
"user",
"->",
"enforceIsNew",
"(",
")",
";",
"$",
"user",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"storeCreatedContentUuids",
"(",
"[",
"$",
"user",
"->",
"uuid",
"(",
")",
"=>",
"'user'",
"]",
")",
";",
"return",
"$",
"user",
"->",
"id",
"(",
")",
";",
"}",
"$",
"user",
"=",
"reset",
"(",
"$",
"users",
")",
";",
"return",
"$",
"user",
"->",
"id",
"(",
")",
";",
"}"
] | Looks up a user by name, if it is missing the user is created.
@param string $name
Username.
@return int
User ID. | [
"Looks",
"up",
"a",
"user",
"by",
"name",
"if",
"it",
"is",
"missing",
"the",
"user",
"is",
"created",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L386-L402 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.getTerm | protected function getTerm($term_name, $vocabulary_id = 'tags') {
$term_name = trim($term_name);
$term_storage = $this->entityTypeManager->getStorage('taxonomy_term');
$terms = $term_storage->loadByProperties([
'name' => $term_name,
'vid' => $vocabulary_id,
]);
if (!$terms) {
$term = $term_storage->create([
'name' => $term_name,
'vid' => $vocabulary_id,
'path' => ['alias' => '/' . Html::getClass($vocabulary_id) . '/' . Html::getClass($term_name)],
]);
$term->save();
$this->storeCreatedContentUuids([$term->uuid() => 'taxonomy_term']);
return $term->id();
}
$term = reset($terms);
return $term->id();
} | php | protected function getTerm($term_name, $vocabulary_id = 'tags') {
$term_name = trim($term_name);
$term_storage = $this->entityTypeManager->getStorage('taxonomy_term');
$terms = $term_storage->loadByProperties([
'name' => $term_name,
'vid' => $vocabulary_id,
]);
if (!$terms) {
$term = $term_storage->create([
'name' => $term_name,
'vid' => $vocabulary_id,
'path' => ['alias' => '/' . Html::getClass($vocabulary_id) . '/' . Html::getClass($term_name)],
]);
$term->save();
$this->storeCreatedContentUuids([$term->uuid() => 'taxonomy_term']);
return $term->id();
}
$term = reset($terms);
return $term->id();
} | [
"protected",
"function",
"getTerm",
"(",
"$",
"term_name",
",",
"$",
"vocabulary_id",
"=",
"'tags'",
")",
"{",
"$",
"term_name",
"=",
"trim",
"(",
"$",
"term_name",
")",
";",
"$",
"term_storage",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'taxonomy_term'",
")",
";",
"$",
"terms",
"=",
"$",
"term_storage",
"->",
"loadByProperties",
"(",
"[",
"'name'",
"=>",
"$",
"term_name",
",",
"'vid'",
"=>",
"$",
"vocabulary_id",
",",
"]",
")",
";",
"if",
"(",
"!",
"$",
"terms",
")",
"{",
"$",
"term",
"=",
"$",
"term_storage",
"->",
"create",
"(",
"[",
"'name'",
"=>",
"$",
"term_name",
",",
"'vid'",
"=>",
"$",
"vocabulary_id",
",",
"'path'",
"=>",
"[",
"'alias'",
"=>",
"'/'",
".",
"Html",
"::",
"getClass",
"(",
"$",
"vocabulary_id",
")",
".",
"'/'",
".",
"Html",
"::",
"getClass",
"(",
"$",
"term_name",
")",
"]",
",",
"]",
")",
";",
"$",
"term",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"storeCreatedContentUuids",
"(",
"[",
"$",
"term",
"->",
"uuid",
"(",
")",
"=>",
"'taxonomy_term'",
"]",
")",
";",
"return",
"$",
"term",
"->",
"id",
"(",
")",
";",
"}",
"$",
"term",
"=",
"reset",
"(",
"$",
"terms",
")",
";",
"return",
"$",
"term",
"->",
"id",
"(",
")",
";",
"}"
] | Looks up a term by name, if it is missing the term is created.
@param string $term_name
Term name.
@param string $vocabulary_id
Vocabulary ID.
@return int
Term ID. | [
"Looks",
"up",
"a",
"term",
"by",
"name",
"if",
"it",
"is",
"missing",
"the",
"term",
"is",
"created",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L415-L434 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.createFileEntity | protected function createFileEntity($path) {
$uri = $this->fileUnmanagedCopy($path);
$file = $this->entityTypeManager->getStorage('file')->create([
'uri' => $uri,
'status' => 1,
]);
$file->save();
$this->storeCreatedContentUuids([$file->uuid() => 'file']);
return $file->id();
} | php | protected function createFileEntity($path) {
$uri = $this->fileUnmanagedCopy($path);
$file = $this->entityTypeManager->getStorage('file')->create([
'uri' => $uri,
'status' => 1,
]);
$file->save();
$this->storeCreatedContentUuids([$file->uuid() => 'file']);
return $file->id();
} | [
"protected",
"function",
"createFileEntity",
"(",
"$",
"path",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"fileUnmanagedCopy",
"(",
"$",
"path",
")",
";",
"$",
"file",
"=",
"$",
"this",
"->",
"entityTypeManager",
"->",
"getStorage",
"(",
"'file'",
")",
"->",
"create",
"(",
"[",
"'uri'",
"=>",
"$",
"uri",
",",
"'status'",
"=>",
"1",
",",
"]",
")",
";",
"$",
"file",
"->",
"save",
"(",
")",
";",
"$",
"this",
"->",
"storeCreatedContentUuids",
"(",
"[",
"$",
"file",
"->",
"uuid",
"(",
")",
"=>",
"'file'",
"]",
")",
";",
"return",
"$",
"file",
"->",
"id",
"(",
")",
";",
"}"
] | Creates a file entity based on an image path.
@param string $path
Image path.
@return int
File ID. | [
"Creates",
"a",
"file",
"entity",
"based",
"on",
"an",
"image",
"path",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L445-L454 | train |
govCMS/govCMS8 | modules/custom/optional/govcms8_default_content/src/InstallHelper.php | InstallHelper.storeCreatedContentUuids | protected function storeCreatedContentUuids(array $uuids) {
$uuids = $this->state->get('govcms8_default_content_uuids', []) + $uuids;
$this->state->set('govcms8_default_content_uuids', $uuids);
} | php | protected function storeCreatedContentUuids(array $uuids) {
$uuids = $this->state->get('govcms8_default_content_uuids', []) + $uuids;
$this->state->set('govcms8_default_content_uuids', $uuids);
} | [
"protected",
"function",
"storeCreatedContentUuids",
"(",
"array",
"$",
"uuids",
")",
"{",
"$",
"uuids",
"=",
"$",
"this",
"->",
"state",
"->",
"get",
"(",
"'govcms8_default_content_uuids'",
",",
"[",
"]",
")",
"+",
"$",
"uuids",
";",
"$",
"this",
"->",
"state",
"->",
"set",
"(",
"'govcms8_default_content_uuids'",
",",
"$",
"uuids",
")",
";",
"}"
] | Stores record of content entities created by this import.
@param array $uuids
Array of UUIDs where the key is the UUID and the value is the entity
type. | [
"Stores",
"record",
"of",
"content",
"entities",
"created",
"by",
"this",
"import",
"."
] | c5c5b69946bd2e0814a0e7ca3daec23280e33576 | https://github.com/govCMS/govCMS8/blob/c5c5b69946bd2e0814a0e7ca3daec23280e33576/modules/custom/optional/govcms8_default_content/src/InstallHelper.php#L463-L466 | train |
Badcow/DNS | lib/Rdata/LOC.php | LOC.toDms | private function toDms(float $decimal, string $axis = self::LATITUDE): string
{
$d = (int) floor(abs($decimal));
$m = (int) floor((abs($decimal) - $d) * 60);
$s = ((abs($decimal) - $d) * 60 - $m) * 60;
if (self::LATITUDE === $axis) {
$h = ($decimal < 0) ? 'S' : 'N';
} else {
$h = ($decimal < 0) ? 'W' : 'E';
}
return sprintf('%d %d %.3f %s', $d, $m, $s, $h);
} | php | private function toDms(float $decimal, string $axis = self::LATITUDE): string
{
$d = (int) floor(abs($decimal));
$m = (int) floor((abs($decimal) - $d) * 60);
$s = ((abs($decimal) - $d) * 60 - $m) * 60;
if (self::LATITUDE === $axis) {
$h = ($decimal < 0) ? 'S' : 'N';
} else {
$h = ($decimal < 0) ? 'W' : 'E';
}
return sprintf('%d %d %.3f %s', $d, $m, $s, $h);
} | [
"private",
"function",
"toDms",
"(",
"float",
"$",
"decimal",
",",
"string",
"$",
"axis",
"=",
"self",
"::",
"LATITUDE",
")",
":",
"string",
"{",
"$",
"d",
"=",
"(",
"int",
")",
"floor",
"(",
"abs",
"(",
"$",
"decimal",
")",
")",
";",
"$",
"m",
"=",
"(",
"int",
")",
"floor",
"(",
"(",
"abs",
"(",
"$",
"decimal",
")",
"-",
"$",
"d",
")",
"*",
"60",
")",
";",
"$",
"s",
"=",
"(",
"(",
"abs",
"(",
"$",
"decimal",
")",
"-",
"$",
"d",
")",
"*",
"60",
"-",
"$",
"m",
")",
"*",
"60",
";",
"if",
"(",
"self",
"::",
"LATITUDE",
"===",
"$",
"axis",
")",
"{",
"$",
"h",
"=",
"(",
"$",
"decimal",
"<",
"0",
")",
"?",
"'S'",
":",
"'N'",
";",
"}",
"else",
"{",
"$",
"h",
"=",
"(",
"$",
"decimal",
"<",
"0",
")",
"?",
"'W'",
":",
"'E'",
";",
"}",
"return",
"sprintf",
"(",
"'%d %d %.3f %s'",
",",
"$",
"d",
",",
"$",
"m",
",",
"$",
"s",
",",
"$",
"h",
")",
";",
"}"
] | Determine the degree minute seconds value from decimal.
@param float $decimal
@param string $axis
@return string | [
"Determine",
"the",
"degree",
"minute",
"seconds",
"value",
"from",
"decimal",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Rdata/LOC.php#L222-L234 | train |
Badcow/DNS | lib/ZoneBuilder.php | ZoneBuilder.fullyQualify | private static function fullyQualify(string $subdomain, string $parent): string
{
if ('@' === $subdomain) {
return $parent;
}
if ('.' !== substr($subdomain, -1, 1)) {
return $subdomain.'.'.$parent;
}
return $subdomain;
} | php | private static function fullyQualify(string $subdomain, string $parent): string
{
if ('@' === $subdomain) {
return $parent;
}
if ('.' !== substr($subdomain, -1, 1)) {
return $subdomain.'.'.$parent;
}
return $subdomain;
} | [
"private",
"static",
"function",
"fullyQualify",
"(",
"string",
"$",
"subdomain",
",",
"string",
"$",
"parent",
")",
":",
"string",
"{",
"if",
"(",
"'@'",
"===",
"$",
"subdomain",
")",
"{",
"return",
"$",
"parent",
";",
"}",
"if",
"(",
"'.'",
"!==",
"substr",
"(",
"$",
"subdomain",
",",
"-",
"1",
",",
"1",
")",
")",
"{",
"return",
"$",
"subdomain",
".",
"'.'",
".",
"$",
"parent",
";",
"}",
"return",
"$",
"subdomain",
";",
"}"
] | Add the parent domain to the sub-domain if the sub-domain if it is not fully qualified.
@param string $subdomain
@param string $parent
@return string | [
"Add",
"the",
"parent",
"domain",
"to",
"the",
"sub",
"-",
"domain",
"if",
"the",
"sub",
"-",
"domain",
"if",
"it",
"is",
"not",
"fully",
"qualified",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/ZoneBuilder.php#L98-L109 | train |
Badcow/DNS | lib/Parser/Parser.php | Parser.processResourceName | private function processResourceName(\ArrayIterator $iterator, ResourceRecord $resourceRecord): void
{
if ($this->isResourceName($iterator)) {
$this->previousName = $iterator->current();
$iterator->next();
}
$resourceRecord->setName($this->previousName);
} | php | private function processResourceName(\ArrayIterator $iterator, ResourceRecord $resourceRecord): void
{
if ($this->isResourceName($iterator)) {
$this->previousName = $iterator->current();
$iterator->next();
}
$resourceRecord->setName($this->previousName);
} | [
"private",
"function",
"processResourceName",
"(",
"\\",
"ArrayIterator",
"$",
"iterator",
",",
"ResourceRecord",
"$",
"resourceRecord",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isResourceName",
"(",
"$",
"iterator",
")",
")",
"{",
"$",
"this",
"->",
"previousName",
"=",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"}",
"$",
"resourceRecord",
"->",
"setName",
"(",
"$",
"this",
"->",
"previousName",
")",
";",
"}"
] | Processes a ResourceRecord name.
@param \ArrayIterator $iterator
@param ResourceRecord $resourceRecord | [
"Processes",
"a",
"ResourceRecord",
"name",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Parser.php#L130-L138 | train |
Badcow/DNS | lib/Parser/Parser.php | Parser.processTtl | private function processTtl(\ArrayIterator $iterator, ResourceRecord $resourceRecord): void
{
if ($this->isTTL($iterator)) {
$resourceRecord->setTtl($iterator->current());
$iterator->next();
}
} | php | private function processTtl(\ArrayIterator $iterator, ResourceRecord $resourceRecord): void
{
if ($this->isTTL($iterator)) {
$resourceRecord->setTtl($iterator->current());
$iterator->next();
}
} | [
"private",
"function",
"processTtl",
"(",
"\\",
"ArrayIterator",
"$",
"iterator",
",",
"ResourceRecord",
"$",
"resourceRecord",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"isTTL",
"(",
"$",
"iterator",
")",
")",
"{",
"$",
"resourceRecord",
"->",
"setTtl",
"(",
"$",
"iterator",
"->",
"current",
"(",
")",
")",
";",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"}",
"}"
] | Set RR's TTL if there is one.
@param \ArrayIterator $iterator
@param ResourceRecord $resourceRecord | [
"Set",
"RR",
"s",
"TTL",
"if",
"there",
"is",
"one",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Parser.php#L146-L152 | train |
Badcow/DNS | lib/Parser/Parser.php | Parser.processClass | private function processClass(\ArrayIterator $iterator, ResourceRecord $resourceRecord): void
{
if (Classes::isValid(strtoupper($iterator->current()))) {
$resourceRecord->setClass(strtoupper($iterator->current()));
$iterator->next();
}
} | php | private function processClass(\ArrayIterator $iterator, ResourceRecord $resourceRecord): void
{
if (Classes::isValid(strtoupper($iterator->current()))) {
$resourceRecord->setClass(strtoupper($iterator->current()));
$iterator->next();
}
} | [
"private",
"function",
"processClass",
"(",
"\\",
"ArrayIterator",
"$",
"iterator",
",",
"ResourceRecord",
"$",
"resourceRecord",
")",
":",
"void",
"{",
"if",
"(",
"Classes",
"::",
"isValid",
"(",
"strtoupper",
"(",
"$",
"iterator",
"->",
"current",
"(",
")",
")",
")",
")",
"{",
"$",
"resourceRecord",
"->",
"setClass",
"(",
"strtoupper",
"(",
"$",
"iterator",
"->",
"current",
"(",
")",
")",
")",
";",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"}",
"}"
] | Set RR's class if there is one.
@param \ArrayIterator $iterator
@param ResourceRecord $resourceRecord | [
"Set",
"RR",
"s",
"class",
"if",
"there",
"is",
"one",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Parser.php#L160-L166 | train |
Badcow/DNS | lib/Parser/Parser.php | Parser.isResourceName | private function isResourceName(\ArrayIterator $iterator): bool
{
return !(
$this->isTTL($iterator) ||
Classes::isValid(strtoupper($iterator->current())) ||
RDataTypes::isValid(strtoupper($iterator->current()))
);
} | php | private function isResourceName(\ArrayIterator $iterator): bool
{
return !(
$this->isTTL($iterator) ||
Classes::isValid(strtoupper($iterator->current())) ||
RDataTypes::isValid(strtoupper($iterator->current()))
);
} | [
"private",
"function",
"isResourceName",
"(",
"\\",
"ArrayIterator",
"$",
"iterator",
")",
":",
"bool",
"{",
"return",
"!",
"(",
"$",
"this",
"->",
"isTTL",
"(",
"$",
"iterator",
")",
"||",
"Classes",
"::",
"isValid",
"(",
"strtoupper",
"(",
"$",
"iterator",
"->",
"current",
"(",
")",
")",
")",
"||",
"RDataTypes",
"::",
"isValid",
"(",
"strtoupper",
"(",
"$",
"iterator",
"->",
"current",
"(",
")",
")",
")",
")",
";",
"}"
] | Determine if iterant is a resource name.
@param \ArrayIterator $iterator
@return bool | [
"Determine",
"if",
"iterant",
"is",
"a",
"resource",
"name",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Parser.php#L175-L182 | train |
Badcow/DNS | lib/Rdata/Factory.php | Factory.newRdataFromName | public static function newRdataFromName(string $name): RdataInterface
{
if (!self::isTypeImplemented($name)) {
throw new UnsupportedTypeException($name);
}
$namespace = '\\Badcow\\DNS\\Rdata\\';
$className = $namespace.strtoupper($name);
if (!class_exists($className)) {
$className = $namespace.'DNSSEC\\'.strtoupper($name);
}
return new $className();
} | php | public static function newRdataFromName(string $name): RdataInterface
{
if (!self::isTypeImplemented($name)) {
throw new UnsupportedTypeException($name);
}
$namespace = '\\Badcow\\DNS\\Rdata\\';
$className = $namespace.strtoupper($name);
if (!class_exists($className)) {
$className = $namespace.'DNSSEC\\'.strtoupper($name);
}
return new $className();
} | [
"public",
"static",
"function",
"newRdataFromName",
"(",
"string",
"$",
"name",
")",
":",
"RdataInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"isTypeImplemented",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"UnsupportedTypeException",
"(",
"$",
"name",
")",
";",
"}",
"$",
"namespace",
"=",
"'\\\\Badcow\\\\DNS\\\\Rdata\\\\'",
";",
"$",
"className",
"=",
"$",
"namespace",
".",
"strtoupper",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"className",
"=",
"$",
"namespace",
".",
"'DNSSEC\\\\'",
".",
"strtoupper",
"(",
"$",
"name",
")",
";",
"}",
"return",
"new",
"$",
"className",
"(",
")",
";",
"}"
] | Creates a new RData object from a name.
@param string $name
@throws UnsupportedTypeException
@return RdataInterface | [
"Creates",
"a",
"new",
"RData",
"object",
"from",
"a",
"name",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Rdata/Factory.php#L30-L44 | train |
Badcow/DNS | lib/Parser/Normaliser.php | Normaliser.handleComment | private function handleComment(): void
{
if ($this->string->isNot(Tokens::SEMICOLON)) {
return;
}
while ($this->string->isNot(Tokens::LINE_FEED) && $this->string->valid()) {
$this->string->next();
}
} | php | private function handleComment(): void
{
if ($this->string->isNot(Tokens::SEMICOLON)) {
return;
}
while ($this->string->isNot(Tokens::LINE_FEED) && $this->string->valid()) {
$this->string->next();
}
} | [
"private",
"function",
"handleComment",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"string",
"->",
"isNot",
"(",
"Tokens",
"::",
"SEMICOLON",
")",
")",
"{",
"return",
";",
"}",
"while",
"(",
"$",
"this",
"->",
"string",
"->",
"isNot",
"(",
"Tokens",
"::",
"LINE_FEED",
")",
"&&",
"$",
"this",
"->",
"string",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"string",
"->",
"next",
"(",
")",
";",
"}",
"}"
] | Ignores the comment section. | [
"Ignores",
"the",
"comment",
"section",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Normaliser.php#L73-L82 | train |
Badcow/DNS | lib/Parser/Normaliser.php | Normaliser.handleTxt | private function handleTxt(): void
{
if ($this->string->isNot(Tokens::DOUBLE_QUOTES)) {
return;
}
$this->append();
while ($this->string->isNot(Tokens::DOUBLE_QUOTES)) {
if (!$this->string->valid()) {
throw new ParseException('Unbalanced double quotation marks. End of file reached.');
}
//If escape character
if ($this->string->is(Tokens::BACKSLASH)) {
$this->append();
}
if ($this->string->is(Tokens::LINE_FEED)) {
throw new ParseException('Line Feed found within double quotation marks context.', $this->string);
}
$this->append();
}
} | php | private function handleTxt(): void
{
if ($this->string->isNot(Tokens::DOUBLE_QUOTES)) {
return;
}
$this->append();
while ($this->string->isNot(Tokens::DOUBLE_QUOTES)) {
if (!$this->string->valid()) {
throw new ParseException('Unbalanced double quotation marks. End of file reached.');
}
//If escape character
if ($this->string->is(Tokens::BACKSLASH)) {
$this->append();
}
if ($this->string->is(Tokens::LINE_FEED)) {
throw new ParseException('Line Feed found within double quotation marks context.', $this->string);
}
$this->append();
}
} | [
"private",
"function",
"handleTxt",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"string",
"->",
"isNot",
"(",
"Tokens",
"::",
"DOUBLE_QUOTES",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"append",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"string",
"->",
"isNot",
"(",
"Tokens",
"::",
"DOUBLE_QUOTES",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"string",
"->",
"valid",
"(",
")",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"'Unbalanced double quotation marks. End of file reached.'",
")",
";",
"}",
"//If escape character",
"if",
"(",
"$",
"this",
"->",
"string",
"->",
"is",
"(",
"Tokens",
"::",
"BACKSLASH",
")",
")",
"{",
"$",
"this",
"->",
"append",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"string",
"->",
"is",
"(",
"Tokens",
"::",
"LINE_FEED",
")",
")",
"{",
"throw",
"new",
"ParseException",
"(",
"'Line Feed found within double quotation marks context.'",
",",
"$",
"this",
"->",
"string",
")",
";",
"}",
"$",
"this",
"->",
"append",
"(",
")",
";",
"}",
"}"
] | Handle text inside of double quotations. When this function is called, the String pointer MUST be at the
double quotation mark.
@throws ParseException | [
"Handle",
"text",
"inside",
"of",
"double",
"quotations",
".",
"When",
"this",
"function",
"is",
"called",
"the",
"String",
"pointer",
"MUST",
"be",
"at",
"the",
"double",
"quotation",
"mark",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Normaliser.php#L90-L114 | train |
Badcow/DNS | lib/Parser/Normaliser.php | Normaliser.handleMultiline | private function handleMultiline(): void
{
if ($this->string->isNot(Tokens::OPEN_BRACKET)) {
return;
}
$this->string->next();
while ($this->string->valid()) {
$this->handleTxt();
$this->handleComment();
if ($this->string->is(Tokens::LINE_FEED)) {
$this->string->next();
continue;
}
if ($this->string->is(Tokens::CLOSE_BRACKET)) {
$this->string->next();
return;
}
$this->append();
}
throw new ParseException('End of file reached. Unclosed bracket.');
} | php | private function handleMultiline(): void
{
if ($this->string->isNot(Tokens::OPEN_BRACKET)) {
return;
}
$this->string->next();
while ($this->string->valid()) {
$this->handleTxt();
$this->handleComment();
if ($this->string->is(Tokens::LINE_FEED)) {
$this->string->next();
continue;
}
if ($this->string->is(Tokens::CLOSE_BRACKET)) {
$this->string->next();
return;
}
$this->append();
}
throw new ParseException('End of file reached. Unclosed bracket.');
} | [
"private",
"function",
"handleMultiline",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"string",
"->",
"isNot",
"(",
"Tokens",
"::",
"OPEN_BRACKET",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"string",
"->",
"next",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"string",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"handleTxt",
"(",
")",
";",
"$",
"this",
"->",
"handleComment",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"string",
"->",
"is",
"(",
"Tokens",
"::",
"LINE_FEED",
")",
")",
"{",
"$",
"this",
"->",
"string",
"->",
"next",
"(",
")",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"string",
"->",
"is",
"(",
"Tokens",
"::",
"CLOSE_BRACKET",
")",
")",
"{",
"$",
"this",
"->",
"string",
"->",
"next",
"(",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"append",
"(",
")",
";",
"}",
"throw",
"new",
"ParseException",
"(",
"'End of file reached. Unclosed bracket.'",
")",
";",
"}"
] | Move multi-line records onto single line.
@throws ParseException | [
"Move",
"multi",
"-",
"line",
"records",
"onto",
"single",
"line",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Normaliser.php#L121-L147 | train |
Badcow/DNS | lib/Parser/Normaliser.php | Normaliser.removeWhitespace | private function removeWhitespace(): void
{
$string = preg_replace('/ {2,}/', Tokens::SPACE, $this->normalisedString);
$lines = [];
foreach (explode(Tokens::LINE_FEED, $string) as $line) {
if ('' !== $line = trim($line)) {
$lines[] = $line;
}
}
$this->normalisedString = implode(Tokens::LINE_FEED, $lines);
} | php | private function removeWhitespace(): void
{
$string = preg_replace('/ {2,}/', Tokens::SPACE, $this->normalisedString);
$lines = [];
foreach (explode(Tokens::LINE_FEED, $string) as $line) {
if ('' !== $line = trim($line)) {
$lines[] = $line;
}
}
$this->normalisedString = implode(Tokens::LINE_FEED, $lines);
} | [
"private",
"function",
"removeWhitespace",
"(",
")",
":",
"void",
"{",
"$",
"string",
"=",
"preg_replace",
"(",
"'/ {2,}/'",
",",
"Tokens",
"::",
"SPACE",
",",
"$",
"this",
"->",
"normalisedString",
")",
";",
"$",
"lines",
"=",
"[",
"]",
";",
"foreach",
"(",
"explode",
"(",
"Tokens",
"::",
"LINE_FEED",
",",
"$",
"string",
")",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"''",
"!==",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
")",
"{",
"$",
"lines",
"[",
"]",
"=",
"$",
"line",
";",
"}",
"}",
"$",
"this",
"->",
"normalisedString",
"=",
"implode",
"(",
"Tokens",
"::",
"LINE_FEED",
",",
"$",
"lines",
")",
";",
"}"
] | Remove superfluous whitespace characters from string. | [
"Remove",
"superfluous",
"whitespace",
"characters",
"from",
"string",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/Normaliser.php#L152-L163 | train |
Badcow/DNS | lib/Validator.php | Validator.fullyQualifiedDomainName | public static function fullyQualifiedDomainName(string $name): bool
{
$isValid = strlen($name) < 254;
$isValid &= 1 === preg_match('/^(?:(?!-)[a-z0-9\-]{1,63}(?<!-)\.){1,127}$/i', $name);
return $isValid;
} | php | public static function fullyQualifiedDomainName(string $name): bool
{
$isValid = strlen($name) < 254;
$isValid &= 1 === preg_match('/^(?:(?!-)[a-z0-9\-]{1,63}(?<!-)\.){1,127}$/i', $name);
return $isValid;
} | [
"public",
"static",
"function",
"fullyQualifiedDomainName",
"(",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"$",
"isValid",
"=",
"strlen",
"(",
"$",
"name",
")",
"<",
"254",
";",
"$",
"isValid",
"&=",
"1",
"===",
"preg_match",
"(",
"'/^(?:(?!-)[a-z0-9\\-]{1,63}(?<!-)\\.){1,127}$/i'",
",",
"$",
"name",
")",
";",
"return",
"$",
"isValid",
";",
"}"
] | Validate the string is a Fully Qualified Domain Name.
@param string $name
@return bool | [
"Validate",
"the",
"string",
"is",
"a",
"Fully",
"Qualified",
"Domain",
"Name",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Validator.php#L52-L58 | train |
Badcow/DNS | lib/Validator.php | Validator.countClasses | private static function countClasses(Zone $zone): int
{
$classes = [];
foreach ($zone as $rr) {
if (null !== $rr->getClass()) {
$classes[$rr->getClass()] = null;
}
}
return count($classes);
} | php | private static function countClasses(Zone $zone): int
{
$classes = [];
foreach ($zone as $rr) {
if (null !== $rr->getClass()) {
$classes[$rr->getClass()] = null;
}
}
return count($classes);
} | [
"private",
"static",
"function",
"countClasses",
"(",
"Zone",
"$",
"zone",
")",
":",
"int",
"{",
"$",
"classes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"zone",
"as",
"$",
"rr",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"rr",
"->",
"getClass",
"(",
")",
")",
"{",
"$",
"classes",
"[",
"$",
"rr",
"->",
"getClass",
"(",
")",
"]",
"=",
"null",
";",
"}",
"}",
"return",
"count",
"(",
"$",
"classes",
")",
";",
"}"
] | Determine the number of unique non-null classes in a Zone. In a valid zone this MUST be 1.
@param Zone $zone
@return int | [
"Determine",
"the",
"number",
"of",
"unique",
"non",
"-",
"null",
"classes",
"in",
"a",
"Zone",
".",
"In",
"a",
"valid",
"zone",
"this",
"MUST",
"be",
"1",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Validator.php#L232-L243 | train |
Badcow/DNS | lib/AlignedBuilder.php | AlignedBuilder.makeLine | private static function makeLine(string $text, ?string $comment, int $longestVarLength, int $padding): string
{
$output = str_repeat(' ', $padding).str_pad($text, $longestVarLength);
if (null !== $comment) {
$output .= ' '.self::COMMENT_DELIMINATOR.$comment;
}
return $output.PHP_EOL;
} | php | private static function makeLine(string $text, ?string $comment, int $longestVarLength, int $padding): string
{
$output = str_repeat(' ', $padding).str_pad($text, $longestVarLength);
if (null !== $comment) {
$output .= ' '.self::COMMENT_DELIMINATOR.$comment;
}
return $output.PHP_EOL;
} | [
"private",
"static",
"function",
"makeLine",
"(",
"string",
"$",
"text",
",",
"?",
"string",
"$",
"comment",
",",
"int",
"$",
"longestVarLength",
",",
"int",
"$",
"padding",
")",
":",
"string",
"{",
"$",
"output",
"=",
"str_repeat",
"(",
"' '",
",",
"$",
"padding",
")",
".",
"str_pad",
"(",
"$",
"text",
",",
"$",
"longestVarLength",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"comment",
")",
"{",
"$",
"output",
".=",
"' '",
".",
"self",
"::",
"COMMENT_DELIMINATOR",
".",
"$",
"comment",
";",
"}",
"return",
"$",
"output",
".",
"PHP_EOL",
";",
"}"
] | Returns a padded line with comment.
@param string $text
@param string $comment
@param int $longestVarLength
@param int $padding
@return string | [
"Returns",
"a",
"padded",
"line",
"with",
"comment",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/AlignedBuilder.php#L255-L264 | train |
Badcow/DNS | lib/AlignedBuilder.php | AlignedBuilder.getPadding | private static function getPadding(Zone $zone)
{
$name = $ttl = $type = 0;
foreach ($zone as $resourceRecord) {
$name = max($name, strlen($resourceRecord->getName()));
$ttl = max($ttl, strlen($resourceRecord->getTtl()));
$type = max($type, strlen($resourceRecord->getType()));
}
return [
$name,
$ttl,
$type,
$name + $ttl + $type + 6,
];
} | php | private static function getPadding(Zone $zone)
{
$name = $ttl = $type = 0;
foreach ($zone as $resourceRecord) {
$name = max($name, strlen($resourceRecord->getName()));
$ttl = max($ttl, strlen($resourceRecord->getTtl()));
$type = max($type, strlen($resourceRecord->getType()));
}
return [
$name,
$ttl,
$type,
$name + $ttl + $type + 6,
];
} | [
"private",
"static",
"function",
"getPadding",
"(",
"Zone",
"$",
"zone",
")",
"{",
"$",
"name",
"=",
"$",
"ttl",
"=",
"$",
"type",
"=",
"0",
";",
"foreach",
"(",
"$",
"zone",
"as",
"$",
"resourceRecord",
")",
"{",
"$",
"name",
"=",
"max",
"(",
"$",
"name",
",",
"strlen",
"(",
"$",
"resourceRecord",
"->",
"getName",
"(",
")",
")",
")",
";",
"$",
"ttl",
"=",
"max",
"(",
"$",
"ttl",
",",
"strlen",
"(",
"$",
"resourceRecord",
"->",
"getTtl",
"(",
")",
")",
")",
";",
"$",
"type",
"=",
"max",
"(",
"$",
"type",
",",
"strlen",
"(",
"$",
"resourceRecord",
"->",
"getType",
"(",
")",
")",
")",
";",
"}",
"return",
"[",
"$",
"name",
",",
"$",
"ttl",
",",
"$",
"type",
",",
"$",
"name",
"+",
"$",
"ttl",
"+",
"$",
"type",
"+",
"6",
",",
"]",
";",
"}"
] | Get the padding required for a zone.
@param Zone $zone
@return array Array order: name, ttl, type, rdata | [
"Get",
"the",
"padding",
"required",
"for",
"a",
"zone",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/AlignedBuilder.php#L273-L289 | train |
Badcow/DNS | lib/Zone.php | Zone.getClass | public function getClass(): string
{
foreach ($this->resourceRecords as $resourceRecord) {
if (null !== $resourceRecord->getClass()) {
return $resourceRecord->getClass();
}
}
return Classes::INTERNET;
} | php | public function getClass(): string
{
foreach ($this->resourceRecords as $resourceRecord) {
if (null !== $resourceRecord->getClass()) {
return $resourceRecord->getClass();
}
}
return Classes::INTERNET;
} | [
"public",
"function",
"getClass",
"(",
")",
":",
"string",
"{",
"foreach",
"(",
"$",
"this",
"->",
"resourceRecords",
"as",
"$",
"resourceRecord",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"resourceRecord",
"->",
"getClass",
"(",
")",
")",
"{",
"return",
"$",
"resourceRecord",
"->",
"getClass",
"(",
")",
";",
"}",
"}",
"return",
"Classes",
"::",
"INTERNET",
";",
"}"
] | Return the class of the zone, defaults to 'IN'.
@return string | [
"Return",
"the",
"class",
"of",
"the",
"zone",
"defaults",
"to",
"IN",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Zone.php#L182-L191 | train |
Badcow/DNS | lib/Rdata/DNSSEC/Algorithms.php | Algorithms.getMnemonic | public static function getMnemonic(int $algorithmId)
{
if (!array_key_exists($algorithmId, self::$mnemonic)) {
throw new \InvalidArgumentException(sprintf('"%d" id not a valid algorithm.', $algorithmId));
}
return self::$mnemonic[$algorithmId];
} | php | public static function getMnemonic(int $algorithmId)
{
if (!array_key_exists($algorithmId, self::$mnemonic)) {
throw new \InvalidArgumentException(sprintf('"%d" id not a valid algorithm.', $algorithmId));
}
return self::$mnemonic[$algorithmId];
} | [
"public",
"static",
"function",
"getMnemonic",
"(",
"int",
"$",
"algorithmId",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"algorithmId",
",",
"self",
"::",
"$",
"mnemonic",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%d\" id not a valid algorithm.'",
",",
"$",
"algorithmId",
")",
")",
";",
"}",
"return",
"self",
"::",
"$",
"mnemonic",
"[",
"$",
"algorithmId",
"]",
";",
"}"
] | Get the associated mnemonic of an algorithm.
@param int $algorithmId
@return string
@throws \InvalidArgumentException | [
"Get",
"the",
"associated",
"mnemonic",
"of",
"an",
"algorithm",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Rdata/DNSSEC/Algorithms.php#L82-L89 | train |
Badcow/DNS | lib/Ip/Toolbox.php | Toolbox.expandIpv6 | public static function expandIpv6(string $ip): string
{
if (!Validator::ipv6($ip)) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid IPv6 address.', $ip));
}
$hex = unpack('H*hex', inet_pton($ip));
return implode(':', str_split($hex['hex'], 4));
} | php | public static function expandIpv6(string $ip): string
{
if (!Validator::ipv6($ip)) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid IPv6 address.', $ip));
}
$hex = unpack('H*hex', inet_pton($ip));
return implode(':', str_split($hex['hex'], 4));
} | [
"public",
"static",
"function",
"expandIpv6",
"(",
"string",
"$",
"ip",
")",
":",
"string",
"{",
"if",
"(",
"!",
"Validator",
"::",
"ipv6",
"(",
"$",
"ip",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%s\" is not a valid IPv6 address.'",
",",
"$",
"ip",
")",
")",
";",
"}",
"$",
"hex",
"=",
"unpack",
"(",
"'H*hex'",
",",
"inet_pton",
"(",
"$",
"ip",
")",
")",
";",
"return",
"implode",
"(",
"':'",
",",
"str_split",
"(",
"$",
"hex",
"[",
"'hex'",
"]",
",",
"4",
")",
")",
";",
"}"
] | Expands an IPv6 address to its full, non-shorthand representation.
E.g. 2001:db8:9a::42 -> 2001:0db8:009a:0000:0000:0000:0000:0042
@param string $ip IPv6 address
@throws \InvalidArgumentException
@return string | [
"Expands",
"an",
"IPv6",
"address",
"to",
"its",
"full",
"non",
"-",
"shorthand",
"representation",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Ip/Toolbox.php#L29-L38 | train |
Badcow/DNS | lib/Ip/Toolbox.php | Toolbox.contractIpv6 | public static function contractIpv6(string $ip): string
{
if (!Validator::ipv6($ip)) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid IPv6 address.', $ip));
}
return inet_ntop(inet_pton($ip));
} | php | public static function contractIpv6(string $ip): string
{
if (!Validator::ipv6($ip)) {
throw new \InvalidArgumentException(sprintf('"%s" is not a valid IPv6 address.', $ip));
}
return inet_ntop(inet_pton($ip));
} | [
"public",
"static",
"function",
"contractIpv6",
"(",
"string",
"$",
"ip",
")",
":",
"string",
"{",
"if",
"(",
"!",
"Validator",
"::",
"ipv6",
"(",
"$",
"ip",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'\"%s\" is not a valid IPv6 address.'",
",",
"$",
"ip",
")",
")",
";",
"}",
"return",
"inet_ntop",
"(",
"inet_pton",
"(",
"$",
"ip",
")",
")",
";",
"}"
] | Takes a valid IPv6 address and contracts it
to its shorter version.
E.g.: 2001:0000:0000:acad:0000:0000:0000:0001 -> 2001:0:0:acad::1
Note: If there is more than one set of consecutive hextets, the function
will favour the larger of the sets. If both sets of zeroes are the same
the first will be favoured in the omission of zeroes.
E.g.: 2001:0000:0000:ab80:2390:0000:0000:000a -> 2001:0:0:ab80:2390::a
@param string $ip IPv6 address
@throws \InvalidArgumentException
@return string Contracted IPv6 address | [
"Takes",
"a",
"valid",
"IPv6",
"address",
"and",
"contracts",
"it",
"to",
"its",
"shorter",
"version",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Ip/Toolbox.php#L76-L83 | train |
Badcow/DNS | lib/Ip/Toolbox.php | Toolbox.reverseIpv4 | public static function reverseIpv4(string $ip): string
{
$octets = array_reverse(explode('.', $ip));
return implode('.', $octets).'.in-addr.arpa.';
} | php | public static function reverseIpv4(string $ip): string
{
$octets = array_reverse(explode('.', $ip));
return implode('.', $octets).'.in-addr.arpa.';
} | [
"public",
"static",
"function",
"reverseIpv4",
"(",
"string",
"$",
"ip",
")",
":",
"string",
"{",
"$",
"octets",
"=",
"array_reverse",
"(",
"explode",
"(",
"'.'",
",",
"$",
"ip",
")",
")",
";",
"return",
"implode",
"(",
"'.'",
",",
"$",
"octets",
")",
".",
"'.in-addr.arpa.'",
";",
"}"
] | Creates a reverse IPv4 address.
E.g. 192.168.1.213 -> 213.1.168.192.in-addr.arpa.
@param string $ip Valid IPv4 address
@return string Reversed IP address appended with ".in-addr.arpa." | [
"Creates",
"a",
"reverse",
"IPv4",
"address",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Ip/Toolbox.php#L94-L99 | train |
Badcow/DNS | lib/Ip/Toolbox.php | Toolbox.reverseIpv6 | public static function reverseIpv6(string $ip, bool $appendSuffix = true): string
{
try {
$ip = self::expandIpv6($ip);
} catch (\InvalidArgumentException $e) {
$ip = self::expandIncompleteIpv6($ip);
}
$ip = str_replace(':', '', $ip);
$ip = strrev($ip);
$ip = implode('.', str_split($ip));
$ip .= $appendSuffix ? '.ip6.arpa.' : '';
return $ip;
} | php | public static function reverseIpv6(string $ip, bool $appendSuffix = true): string
{
try {
$ip = self::expandIpv6($ip);
} catch (\InvalidArgumentException $e) {
$ip = self::expandIncompleteIpv6($ip);
}
$ip = str_replace(':', '', $ip);
$ip = strrev($ip);
$ip = implode('.', str_split($ip));
$ip .= $appendSuffix ? '.ip6.arpa.' : '';
return $ip;
} | [
"public",
"static",
"function",
"reverseIpv6",
"(",
"string",
"$",
"ip",
",",
"bool",
"$",
"appendSuffix",
"=",
"true",
")",
":",
"string",
"{",
"try",
"{",
"$",
"ip",
"=",
"self",
"::",
"expandIpv6",
"(",
"$",
"ip",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"ip",
"=",
"self",
"::",
"expandIncompleteIpv6",
"(",
"$",
"ip",
")",
";",
"}",
"$",
"ip",
"=",
"str_replace",
"(",
"':'",
",",
"''",
",",
"$",
"ip",
")",
";",
"$",
"ip",
"=",
"strrev",
"(",
"$",
"ip",
")",
";",
"$",
"ip",
"=",
"implode",
"(",
"'.'",
",",
"str_split",
"(",
"$",
"ip",
")",
")",
";",
"$",
"ip",
".=",
"$",
"appendSuffix",
"?",
"'.ip6.arpa.'",
":",
"''",
";",
"return",
"$",
"ip",
";",
"}"
] | Creates a reverse IPv6 address.
E.g. 2001:db8::567:89ab -> b.a.9.8.7.6.5.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa.
@param string $ip A full or partial IPv6 address
@param bool $appendSuffix Whether or not to append ".ip6.arpa.' suffix.
@return string The reversed address appended with ".ip6.arpa." | [
"Creates",
"a",
"reverse",
"IPv6",
"address",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Ip/Toolbox.php#L111-L125 | train |
Badcow/DNS | lib/Parser/ParseException.php | ParseException.getLineNumber | private function getLineNumber(): int
{
$pos = $this->stringIterator->key();
$this->stringIterator->rewind();
$lineNo = 1;
while ($this->stringIterator->key() < $pos) {
if ($this->stringIterator->is(Tokens::LINE_FEED)) {
++$lineNo;
}
$this->stringIterator->next();
}
return $lineNo;
} | php | private function getLineNumber(): int
{
$pos = $this->stringIterator->key();
$this->stringIterator->rewind();
$lineNo = 1;
while ($this->stringIterator->key() < $pos) {
if ($this->stringIterator->is(Tokens::LINE_FEED)) {
++$lineNo;
}
$this->stringIterator->next();
}
return $lineNo;
} | [
"private",
"function",
"getLineNumber",
"(",
")",
":",
"int",
"{",
"$",
"pos",
"=",
"$",
"this",
"->",
"stringIterator",
"->",
"key",
"(",
")",
";",
"$",
"this",
"->",
"stringIterator",
"->",
"rewind",
"(",
")",
";",
"$",
"lineNo",
"=",
"1",
";",
"while",
"(",
"$",
"this",
"->",
"stringIterator",
"->",
"key",
"(",
")",
"<",
"$",
"pos",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stringIterator",
"->",
"is",
"(",
"Tokens",
"::",
"LINE_FEED",
")",
")",
"{",
"++",
"$",
"lineNo",
";",
"}",
"$",
"this",
"->",
"stringIterator",
"->",
"next",
"(",
")",
";",
"}",
"return",
"$",
"lineNo",
";",
"}"
] | Get line number of current entry on the StringIterator.
@return int | [
"Get",
"line",
"number",
"of",
"current",
"entry",
"on",
"the",
"StringIterator",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/ParseException.php#L43-L57 | train |
Badcow/DNS | lib/Parser/RdataHandlers.php | RdataHandlers.dmsToDecimal | public static function dmsToDecimal(int $deg, int $min, float $sec, string $hemisphere): float
{
$multiplier = ('S' === $hemisphere || 'W' === $hemisphere) ? -1 : 1;
return $multiplier * ($deg + ($min / 60) + ($sec / 3600));
} | php | public static function dmsToDecimal(int $deg, int $min, float $sec, string $hemisphere): float
{
$multiplier = ('S' === $hemisphere || 'W' === $hemisphere) ? -1 : 1;
return $multiplier * ($deg + ($min / 60) + ($sec / 3600));
} | [
"public",
"static",
"function",
"dmsToDecimal",
"(",
"int",
"$",
"deg",
",",
"int",
"$",
"min",
",",
"float",
"$",
"sec",
",",
"string",
"$",
"hemisphere",
")",
":",
"float",
"{",
"$",
"multiplier",
"=",
"(",
"'S'",
"===",
"$",
"hemisphere",
"||",
"'W'",
"===",
"$",
"hemisphere",
")",
"?",
"-",
"1",
":",
"1",
";",
"return",
"$",
"multiplier",
"*",
"(",
"$",
"deg",
"+",
"(",
"$",
"min",
"/",
"60",
")",
"+",
"(",
"$",
"sec",
"/",
"3600",
")",
")",
";",
"}"
] | Transform a DMS string to a decimal representation. Used for LOC records.
@param int $deg Degrees
@param int $min Minutes
@param float $sec Seconds
@param string $hemisphere Either 'N', 'S', 'E', or 'W'
@return float | [
"Transform",
"a",
"DMS",
"string",
"to",
"a",
"decimal",
"representation",
".",
"Used",
"for",
"LOC",
"records",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/RdataHandlers.php#L48-L53 | train |
Badcow/DNS | lib/Parser/RdataHandlers.php | RdataHandlers.catchAll | public static function catchAll(string $type, \ArrayIterator $iterator): Rdata\RdataInterface
{
if (!Rdata\Factory::isTypeImplemented($type)) {
return new Rdata\PolymorphicRdata($type, implode(Tokens::SPACE, self::getAllRemaining($iterator)));
}
return call_user_func_array([Rdata\Factory::class, $type], self::getAllRemaining($iterator));
} | php | public static function catchAll(string $type, \ArrayIterator $iterator): Rdata\RdataInterface
{
if (!Rdata\Factory::isTypeImplemented($type)) {
return new Rdata\PolymorphicRdata($type, implode(Tokens::SPACE, self::getAllRemaining($iterator)));
}
return call_user_func_array([Rdata\Factory::class, $type], self::getAllRemaining($iterator));
} | [
"public",
"static",
"function",
"catchAll",
"(",
"string",
"$",
"type",
",",
"\\",
"ArrayIterator",
"$",
"iterator",
")",
":",
"Rdata",
"\\",
"RdataInterface",
"{",
"if",
"(",
"!",
"Rdata",
"\\",
"Factory",
"::",
"isTypeImplemented",
"(",
"$",
"type",
")",
")",
"{",
"return",
"new",
"Rdata",
"\\",
"PolymorphicRdata",
"(",
"$",
"type",
",",
"implode",
"(",
"Tokens",
"::",
"SPACE",
",",
"self",
"::",
"getAllRemaining",
"(",
"$",
"iterator",
")",
")",
")",
";",
"}",
"return",
"call_user_func_array",
"(",
"[",
"Rdata",
"\\",
"Factory",
"::",
"class",
",",
"$",
"type",
"]",
",",
"self",
"::",
"getAllRemaining",
"(",
"$",
"iterator",
")",
")",
";",
"}"
] | Returns RData instances for types that do not have explicitly declared handler methods.
@param string $type
@param \ArrayIterator $iterator
@return Rdata\RdataInterface | [
"Returns",
"RData",
"instances",
"for",
"types",
"that",
"do",
"not",
"have",
"explicitly",
"declared",
"handler",
"methods",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/RdataHandlers.php#L141-L148 | train |
Badcow/DNS | lib/Parser/RdataHandlers.php | RdataHandlers.pop | private static function pop(\ArrayIterator $iterator): string
{
$current = $iterator->current();
$iterator->next();
return $current;
} | php | private static function pop(\ArrayIterator $iterator): string
{
$current = $iterator->current();
$iterator->next();
return $current;
} | [
"private",
"static",
"function",
"pop",
"(",
"\\",
"ArrayIterator",
"$",
"iterator",
")",
":",
"string",
"{",
"$",
"current",
"=",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"return",
"$",
"current",
";",
"}"
] | Return current entry and moves the iterator to the next entry.
@param \ArrayIterator $iterator
@return string | [
"Return",
"current",
"entry",
"and",
"moves",
"the",
"iterator",
"to",
"the",
"next",
"entry",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/RdataHandlers.php#L179-L185 | train |
Badcow/DNS | lib/Parser/RdataHandlers.php | RdataHandlers.getAllRemaining | private static function getAllRemaining(\ArrayIterator $iterator): array
{
$values = [];
while ($iterator->valid()) {
$values[] = $iterator->current();
$iterator->next();
}
return $values;
} | php | private static function getAllRemaining(\ArrayIterator $iterator): array
{
$values = [];
while ($iterator->valid()) {
$values[] = $iterator->current();
$iterator->next();
}
return $values;
} | [
"private",
"static",
"function",
"getAllRemaining",
"(",
"\\",
"ArrayIterator",
"$",
"iterator",
")",
":",
"array",
"{",
"$",
"values",
"=",
"[",
"]",
";",
"while",
"(",
"$",
"iterator",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"}",
"return",
"$",
"values",
";",
"}"
] | Get all the remaining values of an iterator as an array.
@param \ArrayIterator $iterator
@return array | [
"Get",
"all",
"the",
"remaining",
"values",
"of",
"an",
"iterator",
"as",
"an",
"array",
"."
] | 56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7 | https://github.com/Badcow/DNS/blob/56e4456993cd92b5fa1dc29656d9e81fc8d4a9b7/lib/Parser/RdataHandlers.php#L194-L203 | train |
twilio/twilio-php | Twilio/Jwt/ClientToken.php | ClientToken.allowClientIncoming | public function allowClientIncoming($clientName) {
// clientName must be a non-zero length alphanumeric string
if (preg_match('/\W/', $clientName)) {
throw new \InvalidArgumentException(
'Only alphanumeric characters allowed in client name.');
}
if (strlen($clientName) == 0) {
throw new \InvalidArgumentException(
'Client name must not be a zero length string.');
}
$this->clientName = $clientName;
$this->allow('client', 'incoming',
array('clientName' => $clientName));
} | php | public function allowClientIncoming($clientName) {
// clientName must be a non-zero length alphanumeric string
if (preg_match('/\W/', $clientName)) {
throw new \InvalidArgumentException(
'Only alphanumeric characters allowed in client name.');
}
if (strlen($clientName) == 0) {
throw new \InvalidArgumentException(
'Client name must not be a zero length string.');
}
$this->clientName = $clientName;
$this->allow('client', 'incoming',
array('clientName' => $clientName));
} | [
"public",
"function",
"allowClientIncoming",
"(",
"$",
"clientName",
")",
"{",
"// clientName must be a non-zero length alphanumeric string",
"if",
"(",
"preg_match",
"(",
"'/\\W/'",
",",
"$",
"clientName",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Only alphanumeric characters allowed in client name.'",
")",
";",
"}",
"if",
"(",
"strlen",
"(",
"$",
"clientName",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Client name must not be a zero length string.'",
")",
";",
"}",
"$",
"this",
"->",
"clientName",
"=",
"$",
"clientName",
";",
"$",
"this",
"->",
"allow",
"(",
"'client'",
",",
"'incoming'",
",",
"array",
"(",
"'clientName'",
"=>",
"$",
"clientName",
")",
")",
";",
"}"
] | If the user of this token should be allowed to accept incoming
connections then configure the TwilioCapability through this method and
specify the client name.
@param $clientName
@throws \InvalidArgumentException | [
"If",
"the",
"user",
"of",
"this",
"token",
"should",
"be",
"allowed",
"to",
"accept",
"incoming",
"connections",
"then",
"configure",
"the",
"TwilioCapability",
"through",
"this",
"method",
"and",
"specify",
"the",
"client",
"name",
"."
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Jwt/ClientToken.php#L45-L61 | train |
twilio/twilio-php | Twilio/Jwt/ClientToken.php | ClientToken.generateToken | public function generateToken($ttl = 3600) {
$payload = array_merge($this->customClaims, array(
'scope' => array(),
'iss' => $this->accountSid,
'exp' => time() + $ttl,
));
$scopeStrings = array();
foreach ($this->scopes as $scope) {
if ($scope->privilege == "outgoing" && $this->clientName)
$scope->params["clientName"] = $this->clientName;
$scopeStrings[] = $scope->toString();
}
$payload['scope'] = implode(' ', $scopeStrings);
return JWT::encode($payload, $this->authToken, 'HS256');
} | php | public function generateToken($ttl = 3600) {
$payload = array_merge($this->customClaims, array(
'scope' => array(),
'iss' => $this->accountSid,
'exp' => time() + $ttl,
));
$scopeStrings = array();
foreach ($this->scopes as $scope) {
if ($scope->privilege == "outgoing" && $this->clientName)
$scope->params["clientName"] = $this->clientName;
$scopeStrings[] = $scope->toString();
}
$payload['scope'] = implode(' ', $scopeStrings);
return JWT::encode($payload, $this->authToken, 'HS256');
} | [
"public",
"function",
"generateToken",
"(",
"$",
"ttl",
"=",
"3600",
")",
"{",
"$",
"payload",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"customClaims",
",",
"array",
"(",
"'scope'",
"=>",
"array",
"(",
")",
",",
"'iss'",
"=>",
"$",
"this",
"->",
"accountSid",
",",
"'exp'",
"=>",
"time",
"(",
")",
"+",
"$",
"ttl",
",",
")",
")",
";",
"$",
"scopeStrings",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"scopes",
"as",
"$",
"scope",
")",
"{",
"if",
"(",
"$",
"scope",
"->",
"privilege",
"==",
"\"outgoing\"",
"&&",
"$",
"this",
"->",
"clientName",
")",
"$",
"scope",
"->",
"params",
"[",
"\"clientName\"",
"]",
"=",
"$",
"this",
"->",
"clientName",
";",
"$",
"scopeStrings",
"[",
"]",
"=",
"$",
"scope",
"->",
"toString",
"(",
")",
";",
"}",
"$",
"payload",
"[",
"'scope'",
"]",
"=",
"implode",
"(",
"' '",
",",
"$",
"scopeStrings",
")",
";",
"return",
"JWT",
"::",
"encode",
"(",
"$",
"payload",
",",
"$",
"this",
"->",
"authToken",
",",
"'HS256'",
")",
";",
"}"
] | Generates a new token based on the credentials and permissions that
previously has been granted to this token.
@param int $ttl the expiration time of the token (in seconds). Default
value is 3600 (1hr)
@return ClientToken the newly generated token that is valid for $ttl
seconds | [
"Generates",
"a",
"new",
"token",
"based",
"on",
"the",
"credentials",
"and",
"permissions",
"that",
"previously",
"has",
"been",
"granted",
"to",
"this",
"token",
"."
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Jwt/ClientToken.php#L107-L123 | train |
twilio/twilio-php | Twilio/Security/RequestValidator.php | RequestValidator.compare | public
static function compare($a, $b) {
$result = true;
if (strlen($a) != strlen($b)) {
return false;
}
if (!$a && !$b) {
return true;
}
$limit = strlen($a);
for ($i = 0; $i < $limit; ++$i) {
if ($a[$i] != $b[$i]) {
$result = false;
}
}
return $result;
} | php | public
static function compare($a, $b) {
$result = true;
if (strlen($a) != strlen($b)) {
return false;
}
if (!$a && !$b) {
return true;
}
$limit = strlen($a);
for ($i = 0; $i < $limit; ++$i) {
if ($a[$i] != $b[$i]) {
$result = false;
}
}
return $result;
} | [
"public",
"static",
"function",
"compare",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"strlen",
"(",
"$",
"a",
")",
"!=",
"strlen",
"(",
"$",
"b",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"a",
"&&",
"!",
"$",
"b",
")",
"{",
"return",
"true",
";",
"}",
"$",
"limit",
"=",
"strlen",
"(",
"$",
"a",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"limit",
";",
"++",
"$",
"i",
")",
"{",
"if",
"(",
"$",
"a",
"[",
"$",
"i",
"]",
"!=",
"$",
"b",
"[",
"$",
"i",
"]",
")",
"{",
"$",
"result",
"=",
"false",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Time insensitive compare, function's runtime is governed by the length
of the first argument, not the difference between the arguments.
@param $a string First part of the comparison pair
@param $b string Second part of the comparison pair
@return bool True if $a == $b, false otherwise. | [
"Time",
"insensitive",
"compare",
"function",
"s",
"runtime",
"is",
"governed",
"by",
"the",
"length",
"of",
"the",
"first",
"argument",
"not",
"the",
"difference",
"between",
"the",
"arguments",
"."
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Security/RequestValidator.php#L60-L80 | train |
twilio/twilio-php | Twilio/Rest/Messaging/V1/SessionList.php | SessionList.create | public function create($messagingServiceSid, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'MessagingServiceSid' => $messagingServiceSid,
'FriendlyName' => $options['friendlyName'],
'Attributes' => $options['attributes'],
'DateCreated' => Serialize::iso8601DateTime($options['dateCreated']),
'DateUpdated' => Serialize::iso8601DateTime($options['dateUpdated']),
'CreatedBy' => $options['createdBy'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new SessionInstance($this->version, $payload);
} | php | public function create($messagingServiceSid, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'MessagingServiceSid' => $messagingServiceSid,
'FriendlyName' => $options['friendlyName'],
'Attributes' => $options['attributes'],
'DateCreated' => Serialize::iso8601DateTime($options['dateCreated']),
'DateUpdated' => Serialize::iso8601DateTime($options['dateUpdated']),
'CreatedBy' => $options['createdBy'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new SessionInstance($this->version, $payload);
} | [
"public",
"function",
"create",
"(",
"$",
"messagingServiceSid",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'MessagingServiceSid'",
"=>",
"$",
"messagingServiceSid",
",",
"'FriendlyName'",
"=>",
"$",
"options",
"[",
"'friendlyName'",
"]",
",",
"'Attributes'",
"=>",
"$",
"options",
"[",
"'attributes'",
"]",
",",
"'DateCreated'",
"=>",
"Serialize",
"::",
"iso8601DateTime",
"(",
"$",
"options",
"[",
"'dateCreated'",
"]",
")",
",",
"'DateUpdated'",
"=>",
"Serialize",
"::",
"iso8601DateTime",
"(",
"$",
"options",
"[",
"'dateUpdated'",
"]",
")",
",",
"'CreatedBy'",
"=>",
"$",
"options",
"[",
"'createdBy'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"SessionInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
")",
";",
"}"
] | Create a new SessionInstance
@param string $messagingServiceSid The unique id of the SMS Service this
session belongs to.
@param array|Options $options Optional Arguments
@return SessionInstance Newly created SessionInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"SessionInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Messaging/V1/SessionList.php#L46-L66 | train |
twilio/twilio-php | Twilio/Rest/Chat/V1/Service/Channel/InviteList.php | InviteList.create | public function create($identity, $options = array()) {
$options = new Values($options);
$data = Values::of(array('Identity' => $identity, 'RoleSid' => $options['roleSid'], ));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new InviteInstance(
$this->version,
$payload,
$this->solution['serviceSid'],
$this->solution['channelSid']
);
} | php | public function create($identity, $options = array()) {
$options = new Values($options);
$data = Values::of(array('Identity' => $identity, 'RoleSid' => $options['roleSid'], ));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new InviteInstance(
$this->version,
$payload,
$this->solution['serviceSid'],
$this->solution['channelSid']
);
} | [
"public",
"function",
"create",
"(",
"$",
"identity",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'Identity'",
"=>",
"$",
"identity",
",",
"'RoleSid'",
"=>",
"$",
"options",
"[",
"'roleSid'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"InviteInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
",",
"$",
"this",
"->",
"solution",
"[",
"'serviceSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'channelSid'",
"]",
")",
";",
"}"
] | Create a new InviteInstance
@param string $identity A unique string identifier for this User in this
Service.
@param array|Options $options Optional Arguments
@return InviteInstance Newly created InviteInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"InviteInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Chat/V1/Service/Channel/InviteList.php#L46-L64 | train |
twilio/twilio-php | Twilio/Rest/Chat/V1/Service/Channel/InviteList.php | InviteList.stream | public function stream($options = array(), $limit = null, $pageSize = null) {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
} | php | public function stream($options = array(), $limit = null, $pageSize = null) {
$limits = $this->version->readLimits($limit, $pageSize);
$page = $this->page($options, $limits['pageSize']);
return $this->version->stream($page, $limits['limit'], $limits['pageLimit']);
} | [
"public",
"function",
"stream",
"(",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"pageSize",
"=",
"null",
")",
"{",
"$",
"limits",
"=",
"$",
"this",
"->",
"version",
"->",
"readLimits",
"(",
"$",
"limit",
",",
"$",
"pageSize",
")",
";",
"$",
"page",
"=",
"$",
"this",
"->",
"page",
"(",
"$",
"options",
",",
"$",
"limits",
"[",
"'pageSize'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"version",
"->",
"stream",
"(",
"$",
"page",
",",
"$",
"limits",
"[",
"'limit'",
"]",
",",
"$",
"limits",
"[",
"'pageLimit'",
"]",
")",
";",
"}"
] | Streams InviteInstance records from the API as a generator stream.
This operation lazily loads records as efficiently as possible until the
limit
is reached.
The results are returned as a generator, so this operation is memory
efficient.
@param array|Options $options Optional Arguments
@param int $limit Upper limit for the number of records to return. stream()
guarantees to never return more than limit. Default is no
limit
@param mixed $pageSize Number of records to fetch per request, when not set
will use the default value of 50 records. If no
page_size is defined but a limit is defined, stream()
will attempt to read the limit with the most
efficient page size, i.e. min(limit, 1000)
@return \Twilio\Stream stream of results | [
"Streams",
"InviteInstance",
"records",
"from",
"the",
"API",
"as",
"a",
"generator",
"stream",
".",
"This",
"operation",
"lazily",
"loads",
"records",
"as",
"efficiently",
"as",
"possible",
"until",
"the",
"limit",
"is",
"reached",
".",
"The",
"results",
"are",
"returned",
"as",
"a",
"generator",
"so",
"this",
"operation",
"is",
"memory",
"efficient",
"."
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Chat/V1/Service/Channel/InviteList.php#L85-L91 | train |
twilio/twilio-php | Twilio/Rest/Chat/V1/Service/Channel/InviteList.php | InviteList.getContext | public function getContext($sid) {
return new InviteContext(
$this->version,
$this->solution['serviceSid'],
$this->solution['channelSid'],
$sid
);
} | php | public function getContext($sid) {
return new InviteContext(
$this->version,
$this->solution['serviceSid'],
$this->solution['channelSid'],
$sid
);
} | [
"public",
"function",
"getContext",
"(",
"$",
"sid",
")",
"{",
"return",
"new",
"InviteContext",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'serviceSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'channelSid'",
"]",
",",
"$",
"sid",
")",
";",
"}"
] | Constructs a InviteContext
@param string $sid The sid
@return \Twilio\Rest\Chat\V1\Service\Channel\InviteContext | [
"Constructs",
"a",
"InviteContext"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Chat/V1/Service/Channel/InviteList.php#L163-L170 | train |
twilio/twilio-php | Twilio/Rest/Preview/Marketplace/InstalledAddOnList.php | InstalledAddOnList.create | public function create($availableAddOnSid, $acceptTermsOfService, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'AvailableAddOnSid' => $availableAddOnSid,
'AcceptTermsOfService' => Serialize::booleanToString($acceptTermsOfService),
'Configuration' => Serialize::jsonObject($options['configuration']),
'UniqueName' => $options['uniqueName'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new InstalledAddOnInstance($this->version, $payload);
} | php | public function create($availableAddOnSid, $acceptTermsOfService, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'AvailableAddOnSid' => $availableAddOnSid,
'AcceptTermsOfService' => Serialize::booleanToString($acceptTermsOfService),
'Configuration' => Serialize::jsonObject($options['configuration']),
'UniqueName' => $options['uniqueName'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new InstalledAddOnInstance($this->version, $payload);
} | [
"public",
"function",
"create",
"(",
"$",
"availableAddOnSid",
",",
"$",
"acceptTermsOfService",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'AvailableAddOnSid'",
"=>",
"$",
"availableAddOnSid",
",",
"'AcceptTermsOfService'",
"=>",
"Serialize",
"::",
"booleanToString",
"(",
"$",
"acceptTermsOfService",
")",
",",
"'Configuration'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'configuration'",
"]",
")",
",",
"'UniqueName'",
"=>",
"$",
"options",
"[",
"'uniqueName'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"InstalledAddOnInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
")",
";",
"}"
] | Create a new InstalledAddOnInstance
@param string $availableAddOnSid A string that uniquely identifies the
Add-on to install
@param boolean $acceptTermsOfService A boolean reflecting your acceptance of
the Terms of Service
@param array|Options $options Optional Arguments
@return InstalledAddOnInstance Newly created InstalledAddOnInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"InstalledAddOnInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Preview/Marketplace/InstalledAddOnList.php#L48-L66 | train |
twilio/twilio-php | Twilio/Rest/Studio/V1/Flow/EngagementList.php | EngagementList.create | public function create($to, $from, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'To' => $to,
'From' => $from,
'Parameters' => Serialize::jsonObject($options['parameters']),
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new EngagementInstance($this->version, $payload, $this->solution['flowSid']);
} | php | public function create($to, $from, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'To' => $to,
'From' => $from,
'Parameters' => Serialize::jsonObject($options['parameters']),
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new EngagementInstance($this->version, $payload, $this->solution['flowSid']);
} | [
"public",
"function",
"create",
"(",
"$",
"to",
",",
"$",
"from",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'To'",
"=>",
"$",
"to",
",",
"'From'",
"=>",
"$",
"from",
",",
"'Parameters'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'parameters'",
"]",
")",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"EngagementInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
",",
"$",
"this",
"->",
"solution",
"[",
"'flowSid'",
"]",
")",
";",
"}"
] | Create a new EngagementInstance
@param string $to The Contact phone number to start a Studio Flow Engagement.
@param string $from The Twilio phone number to send messages or initiate
calls from during the Flow Engagement.
@param array|Options $options Optional Arguments
@return EngagementInstance Newly created EngagementInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"EngagementInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Studio/V1/Flow/EngagementList.php#L131-L148 | train |
twilio/twilio-php | Twilio/Rest/Accounts/V1/Credential/AwsList.php | AwsList.create | public function create($credentials, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'Credentials' => $credentials,
'FriendlyName' => $options['friendlyName'],
'AccountSid' => $options['accountSid'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new AwsInstance($this->version, $payload);
} | php | public function create($credentials, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'Credentials' => $credentials,
'FriendlyName' => $options['friendlyName'],
'AccountSid' => $options['accountSid'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new AwsInstance($this->version, $payload);
} | [
"public",
"function",
"create",
"(",
"$",
"credentials",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'Credentials'",
"=>",
"$",
"credentials",
",",
"'FriendlyName'",
"=>",
"$",
"options",
"[",
"'friendlyName'",
"]",
",",
"'AccountSid'",
"=>",
"$",
"options",
"[",
"'accountSid'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"AwsInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
")",
";",
"}"
] | Create a new AwsInstance
@param string $credentials A string that contains the AWS access credentials
in the format
<AWS_ACCESS_KEY_ID>:<AWS_SECRET_ACCESS_KEY>
@param array|Options $options Optional Arguments
@return AwsInstance Newly created AwsInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"AwsInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Accounts/V1/Credential/AwsList.php#L129-L146 | train |
twilio/twilio-php | Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationList.php | ReservationList.getContext | public function getContext($sid) {
return new ReservationContext(
$this->version,
$this->solution['workspaceSid'],
$this->solution['taskSid'],
$sid
);
} | php | public function getContext($sid) {
return new ReservationContext(
$this->version,
$this->solution['workspaceSid'],
$this->solution['taskSid'],
$sid
);
} | [
"public",
"function",
"getContext",
"(",
"$",
"sid",
")",
"{",
"return",
"new",
"ReservationContext",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'workspaceSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'taskSid'",
"]",
",",
"$",
"sid",
")",
";",
"}"
] | Constructs a ReservationContext
@param string $sid The sid
@return \Twilio\Rest\Taskrouter\V1\Workspace\Task\ReservationContext | [
"Constructs",
"a",
"ReservationContext"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Taskrouter/V1/Workspace/Task/ReservationList.php#L133-L140 | train |
twilio/twilio-php | Twilio/Rest/Proxy/V1/ServiceContext.php | ServiceContext.getSessions | protected function getSessions() {
if (!$this->_sessions) {
$this->_sessions = new SessionList($this->version, $this->solution['sid']);
}
return $this->_sessions;
} | php | protected function getSessions() {
if (!$this->_sessions) {
$this->_sessions = new SessionList($this->version, $this->solution['sid']);
}
return $this->_sessions;
} | [
"protected",
"function",
"getSessions",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_sessions",
")",
"{",
"$",
"this",
"->",
"_sessions",
"=",
"new",
"SessionList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_sessions",
";",
"}"
] | Access the sessions
@return \Twilio\Rest\Proxy\V1\Service\SessionList | [
"Access",
"the",
"sessions"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Proxy/V1/ServiceContext.php#L116-L122 | train |
twilio/twilio-php | Twilio/Rest/Proxy/V1/ServiceContext.php | ServiceContext.getPhoneNumbers | protected function getPhoneNumbers() {
if (!$this->_phoneNumbers) {
$this->_phoneNumbers = new PhoneNumberList($this->version, $this->solution['sid']);
}
return $this->_phoneNumbers;
} | php | protected function getPhoneNumbers() {
if (!$this->_phoneNumbers) {
$this->_phoneNumbers = new PhoneNumberList($this->version, $this->solution['sid']);
}
return $this->_phoneNumbers;
} | [
"protected",
"function",
"getPhoneNumbers",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_phoneNumbers",
")",
"{",
"$",
"this",
"->",
"_phoneNumbers",
"=",
"new",
"PhoneNumberList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_phoneNumbers",
";",
"}"
] | Access the phoneNumbers
@return \Twilio\Rest\Proxy\V1\Service\PhoneNumberList | [
"Access",
"the",
"phoneNumbers"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Proxy/V1/ServiceContext.php#L129-L135 | train |
twilio/twilio-php | Twilio/Rest/Proxy/V1/ServiceContext.php | ServiceContext.getShortCodes | protected function getShortCodes() {
if (!$this->_shortCodes) {
$this->_shortCodes = new ShortCodeList($this->version, $this->solution['sid']);
}
return $this->_shortCodes;
} | php | protected function getShortCodes() {
if (!$this->_shortCodes) {
$this->_shortCodes = new ShortCodeList($this->version, $this->solution['sid']);
}
return $this->_shortCodes;
} | [
"protected",
"function",
"getShortCodes",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_shortCodes",
")",
"{",
"$",
"this",
"->",
"_shortCodes",
"=",
"new",
"ShortCodeList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_shortCodes",
";",
"}"
] | Access the shortCodes
@return \Twilio\Rest\Proxy\V1\Service\ShortCodeList | [
"Access",
"the",
"shortCodes"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Proxy/V1/ServiceContext.php#L142-L148 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberContext.php | IncomingPhoneNumberContext.getAssignedAddOns | protected function getAssignedAddOns() {
if (!$this->_assignedAddOns) {
$this->_assignedAddOns = new AssignedAddOnList(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->_assignedAddOns;
} | php | protected function getAssignedAddOns() {
if (!$this->_assignedAddOns) {
$this->_assignedAddOns = new AssignedAddOnList(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->_assignedAddOns;
} | [
"protected",
"function",
"getAssignedAddOns",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_assignedAddOns",
")",
"{",
"$",
"this",
"->",
"_assignedAddOns",
"=",
"new",
"AssignedAddOnList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_assignedAddOns",
";",
"}"
] | Access the assignedAddOns
@return \Twilio\Rest\Api\V2010\Account\IncomingPhoneNumber\AssignedAddOnList | [
"Access",
"the",
"assignedAddOns"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/IncomingPhoneNumberContext.php#L133-L143 | train |
twilio/twilio-php | Twilio/Rest/Authy/V1/Service/EntityContext.php | EntityContext.getFactors | protected function getFactors() {
if (!$this->_factors) {
$this->_factors = new FactorList(
$this->version,
$this->solution['serviceSid'],
$this->solution['identity']
);
}
return $this->_factors;
} | php | protected function getFactors() {
if (!$this->_factors) {
$this->_factors = new FactorList(
$this->version,
$this->solution['serviceSid'],
$this->solution['identity']
);
}
return $this->_factors;
} | [
"protected",
"function",
"getFactors",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_factors",
")",
"{",
"$",
"this",
"->",
"_factors",
"=",
"new",
"FactorList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'serviceSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'identity'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_factors",
";",
"}"
] | Access the factors
@return \Twilio\Rest\Authy\V1\Service\Entity\FactorList | [
"Access",
"the",
"factors"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Authy/V1/Service/EntityContext.php#L82-L92 | train |
twilio/twilio-php | Twilio/Rest/Client.php | Client.request | public function request($method, $uri, $params = array(), $data = array(), $headers = array(), $username = null, $password = null, $timeout = null) {
$username = $username ? $username : $this->username;
$password = $password ? $password : $this->password;
$headers['User-Agent'] = 'twilio-php/' . VersionInfo::string() .
' (PHP ' . phpversion() . ')';
$headers['Accept-Charset'] = 'utf-8';
if ($method == 'POST' && !array_key_exists('Content-Type', $headers)) {
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
}
if (!array_key_exists('Accept', $headers)) {
$headers['Accept'] = 'application/json';
}
if ($this->region) {
list($head, $tail) = explode('.', $uri, 2);
if (strpos($tail, $this->region) !== 0) {
$uri = implode('.', array($head, $this->region, $tail));
}
}
return $this->getHttpClient()->request(
$method,
$uri,
$params,
$data,
$headers,
$username,
$password,
$timeout
);
} | php | public function request($method, $uri, $params = array(), $data = array(), $headers = array(), $username = null, $password = null, $timeout = null) {
$username = $username ? $username : $this->username;
$password = $password ? $password : $this->password;
$headers['User-Agent'] = 'twilio-php/' . VersionInfo::string() .
' (PHP ' . phpversion() . ')';
$headers['Accept-Charset'] = 'utf-8';
if ($method == 'POST' && !array_key_exists('Content-Type', $headers)) {
$headers['Content-Type'] = 'application/x-www-form-urlencoded';
}
if (!array_key_exists('Accept', $headers)) {
$headers['Accept'] = 'application/json';
}
if ($this->region) {
list($head, $tail) = explode('.', $uri, 2);
if (strpos($tail, $this->region) !== 0) {
$uri = implode('.', array($head, $this->region, $tail));
}
}
return $this->getHttpClient()->request(
$method,
$uri,
$params,
$data,
$headers,
$username,
$password,
$timeout
);
} | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"headers",
"=",
"array",
"(",
")",
",",
"$",
"username",
"=",
"null",
",",
"$",
"password",
"=",
"null",
",",
"$",
"timeout",
"=",
"null",
")",
"{",
"$",
"username",
"=",
"$",
"username",
"?",
"$",
"username",
":",
"$",
"this",
"->",
"username",
";",
"$",
"password",
"=",
"$",
"password",
"?",
"$",
"password",
":",
"$",
"this",
"->",
"password",
";",
"$",
"headers",
"[",
"'User-Agent'",
"]",
"=",
"'twilio-php/'",
".",
"VersionInfo",
"::",
"string",
"(",
")",
".",
"' (PHP '",
".",
"phpversion",
"(",
")",
".",
"')'",
";",
"$",
"headers",
"[",
"'Accept-Charset'",
"]",
"=",
"'utf-8'",
";",
"if",
"(",
"$",
"method",
"==",
"'POST'",
"&&",
"!",
"array_key_exists",
"(",
"'Content-Type'",
",",
"$",
"headers",
")",
")",
"{",
"$",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/x-www-form-urlencoded'",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'Accept'",
",",
"$",
"headers",
")",
")",
"{",
"$",
"headers",
"[",
"'Accept'",
"]",
"=",
"'application/json'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"region",
")",
"{",
"list",
"(",
"$",
"head",
",",
"$",
"tail",
")",
"=",
"explode",
"(",
"'.'",
",",
"$",
"uri",
",",
"2",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"tail",
",",
"$",
"this",
"->",
"region",
")",
"!==",
"0",
")",
"{",
"$",
"uri",
"=",
"implode",
"(",
"'.'",
",",
"array",
"(",
"$",
"head",
",",
"$",
"this",
"->",
"region",
",",
"$",
"tail",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"getHttpClient",
"(",
")",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"params",
",",
"$",
"data",
",",
"$",
"headers",
",",
"$",
"username",
",",
"$",
"password",
",",
"$",
"timeout",
")",
";",
"}"
] | Makes a request to the Twilio API using the configured http client
Authentication information is automatically added if none is provided
@param string $method HTTP Method
@param string $uri Fully qualified url
@param string[] $params Query string parameters
@param string[] $data POST body data
@param string[] $headers HTTP Headers
@param string $username User for Authentication
@param string $password Password for Authentication
@param int $timeout Timeout in seconds
@return \Twilio\Http\Response Response from the Twilio API | [
"Makes",
"a",
"request",
"to",
"the",
"Twilio",
"API",
"using",
"the",
"configured",
"http",
"client",
"Authentication",
"information",
"is",
"automatically",
"added",
"if",
"none",
"is",
"provided"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Client.php#L190-L224 | train |
twilio/twilio-php | Twilio/Rest/Client.php | Client.validateSslCertificate | public function validateSslCertificate($client) {
$response = $client->request('GET', 'https://api.twilio.com:8443');
if ($response->getStatusCode() < 200 || $response->getStatusCode() > 300) {
throw new TwilioException("Failed to validate SSL certificate");
}
} | php | public function validateSslCertificate($client) {
$response = $client->request('GET', 'https://api.twilio.com:8443');
if ($response->getStatusCode() < 200 || $response->getStatusCode() > 300) {
throw new TwilioException("Failed to validate SSL certificate");
}
} | [
"public",
"function",
"validateSslCertificate",
"(",
"$",
"client",
")",
"{",
"$",
"response",
"=",
"$",
"client",
"->",
"request",
"(",
"'GET'",
",",
"'https://api.twilio.com:8443'",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"<",
"200",
"||",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
">",
"300",
")",
"{",
"throw",
"new",
"TwilioException",
"(",
"\"Failed to validate SSL certificate\"",
")",
";",
"}",
"}"
] | Validates connection to new SSL certificate endpoint
@param CurlClient $client
@throws TwilioException if request fails | [
"Validates",
"connection",
"to",
"new",
"SSL",
"certificate",
"endpoint"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Client.php#L941-L947 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/RecordingContext.php | RecordingContext.getAddOnResults | protected function getAddOnResults() {
if (!$this->_addOnResults) {
$this->_addOnResults = new AddOnResultList(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->_addOnResults;
} | php | protected function getAddOnResults() {
if (!$this->_addOnResults) {
$this->_addOnResults = new AddOnResultList(
$this->version,
$this->solution['accountSid'],
$this->solution['sid']
);
}
return $this->_addOnResults;
} | [
"protected",
"function",
"getAddOnResults",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_addOnResults",
")",
"{",
"$",
"this",
"->",
"_addOnResults",
"=",
"new",
"AddOnResultList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_addOnResults",
";",
"}"
] | Access the addOnResults
@return \Twilio\Rest\Api\V2010\Account\Recording\AddOnResultList | [
"Access",
"the",
"addOnResults"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/RecordingContext.php#L102-L112 | train |
twilio/twilio-php | Twilio/Rest/Autopilot/V1/Assistant/FieldTypeContext.php | FieldTypeContext.getFieldValues | protected function getFieldValues() {
if (!$this->_fieldValues) {
$this->_fieldValues = new FieldValueList(
$this->version,
$this->solution['assistantSid'],
$this->solution['sid']
);
}
return $this->_fieldValues;
} | php | protected function getFieldValues() {
if (!$this->_fieldValues) {
$this->_fieldValues = new FieldValueList(
$this->version,
$this->solution['assistantSid'],
$this->solution['sid']
);
}
return $this->_fieldValues;
} | [
"protected",
"function",
"getFieldValues",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_fieldValues",
")",
"{",
"$",
"this",
"->",
"_fieldValues",
"=",
"new",
"FieldValueList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'assistantSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_fieldValues",
";",
"}"
] | Access the fieldValues
@return \Twilio\Rest\Autopilot\V1\Assistant\FieldType\FieldValueList | [
"Access",
"the",
"fieldValues"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Autopilot/V1/Assistant/FieldTypeContext.php#L114-L124 | train |
twilio/twilio-php | Twilio/Rest/Preview/DeployedDevices/FleetList.php | FleetList.create | public function create($options = array()) {
$options = new Values($options);
$data = Values::of(array('FriendlyName' => $options['friendlyName'], ));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new FleetInstance($this->version, $payload);
} | php | public function create($options = array()) {
$options = new Values($options);
$data = Values::of(array('FriendlyName' => $options['friendlyName'], ));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new FleetInstance($this->version, $payload);
} | [
"public",
"function",
"create",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'FriendlyName'",
"=>",
"$",
"options",
"[",
"'friendlyName'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"FleetInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
")",
";",
"}"
] | Create a new FleetInstance
@param array|Options $options Optional Arguments
@return FleetInstance Newly created FleetInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"FleetInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Preview/DeployedDevices/FleetList.php#L43-L56 | train |
twilio/twilio-php | Twilio/Rest/Voice/V1/DialingPermissions/CountryContext.php | CountryContext.getHighriskSpecialPrefixes | protected function getHighriskSpecialPrefixes() {
if (!$this->_highriskSpecialPrefixes) {
$this->_highriskSpecialPrefixes = new HighriskSpecialPrefixList(
$this->version,
$this->solution['isoCode']
);
}
return $this->_highriskSpecialPrefixes;
} | php | protected function getHighriskSpecialPrefixes() {
if (!$this->_highriskSpecialPrefixes) {
$this->_highriskSpecialPrefixes = new HighriskSpecialPrefixList(
$this->version,
$this->solution['isoCode']
);
}
return $this->_highriskSpecialPrefixes;
} | [
"protected",
"function",
"getHighriskSpecialPrefixes",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_highriskSpecialPrefixes",
")",
"{",
"$",
"this",
"->",
"_highriskSpecialPrefixes",
"=",
"new",
"HighriskSpecialPrefixList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'isoCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_highriskSpecialPrefixes",
";",
"}"
] | Access the highriskSpecialPrefixes
@return \Twilio\Rest\Voice\V1\DialingPermissions\Country\HighriskSpecialPrefixList | [
"Access",
"the",
"highriskSpecialPrefixes"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Voice/V1/DialingPermissions/CountryContext.php#L65-L74 | train |
twilio/twilio-php | Twilio/Rest/Studio/V1/Flow/Engagement/StepContext.php | StepContext.fetch | public function fetch() {
$params = Values::of(array());
$payload = $this->version->fetch(
'GET',
$this->uri,
$params
);
return new StepInstance(
$this->version,
$payload,
$this->solution['flowSid'],
$this->solution['engagementSid'],
$this->solution['sid']
);
} | php | public function fetch() {
$params = Values::of(array());
$payload = $this->version->fetch(
'GET',
$this->uri,
$params
);
return new StepInstance(
$this->version,
$payload,
$this->solution['flowSid'],
$this->solution['engagementSid'],
$this->solution['sid']
);
} | [
"public",
"function",
"fetch",
"(",
")",
"{",
"$",
"params",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"fetch",
"(",
"'GET'",
",",
"$",
"this",
"->",
"uri",
",",
"$",
"params",
")",
";",
"return",
"new",
"StepInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
",",
"$",
"this",
"->",
"solution",
"[",
"'flowSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'engagementSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}"
] | Fetch a StepInstance
@return StepInstance Fetched StepInstance
@throws TwilioException When an HTTP error occurs. | [
"Fetch",
"a",
"StepInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Studio/V1/Flow/Engagement/StepContext.php#L49-L65 | train |
twilio/twilio-php | Twilio/Rest/Video/V1/Room/Participant/PublishedTrackList.php | PublishedTrackList.getContext | public function getContext($sid) {
return new PublishedTrackContext(
$this->version,
$this->solution['roomSid'],
$this->solution['participantSid'],
$sid
);
} | php | public function getContext($sid) {
return new PublishedTrackContext(
$this->version,
$this->solution['roomSid'],
$this->solution['participantSid'],
$sid
);
} | [
"public",
"function",
"getContext",
"(",
"$",
"sid",
")",
"{",
"return",
"new",
"PublishedTrackContext",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'roomSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'participantSid'",
"]",
",",
"$",
"sid",
")",
";",
"}"
] | Constructs a PublishedTrackContext
@param string $sid A 34 character string that uniquely identifies this
resource.
@return \Twilio\Rest\Video\V1\Room\Participant\PublishedTrackContext | [
"Constructs",
"a",
"PublishedTrackContext"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Video/V1/Room/Participant/PublishedTrackList.php#L128-L135 | train |
twilio/twilio-php | Twilio/Rest/Taskrouter/V1/Workspace/WorkerList.php | WorkerList.create | public function create($friendlyName, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'FriendlyName' => $friendlyName,
'ActivitySid' => $options['activitySid'],
'Attributes' => $options['attributes'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new WorkerInstance($this->version, $payload, $this->solution['workspaceSid']);
} | php | public function create($friendlyName, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'FriendlyName' => $friendlyName,
'ActivitySid' => $options['activitySid'],
'Attributes' => $options['attributes'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new WorkerInstance($this->version, $payload, $this->solution['workspaceSid']);
} | [
"public",
"function",
"create",
"(",
"$",
"friendlyName",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'FriendlyName'",
"=>",
"$",
"friendlyName",
",",
"'ActivitySid'",
"=>",
"$",
"options",
"[",
"'activitySid'",
"]",
",",
"'Attributes'",
"=>",
"$",
"options",
"[",
"'attributes'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"WorkerInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
",",
"$",
"this",
"->",
"solution",
"[",
"'workspaceSid'",
"]",
")",
";",
"}"
] | Create a new WorkerInstance
@param string $friendlyName String representing user-friendly name for the
Worker.
@param array|Options $options Optional Arguments
@return WorkerInstance Newly created WorkerInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"WorkerInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Taskrouter/V1/Workspace/WorkerList.php#L149-L166 | train |
twilio/twilio-php | Twilio/Rest/Preview/Sync/Service/SyncListContext.php | SyncListContext.getSyncListItems | protected function getSyncListItems() {
if (!$this->_syncListItems) {
$this->_syncListItems = new SyncListItemList(
$this->version,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
return $this->_syncListItems;
} | php | protected function getSyncListItems() {
if (!$this->_syncListItems) {
$this->_syncListItems = new SyncListItemList(
$this->version,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
return $this->_syncListItems;
} | [
"protected",
"function",
"getSyncListItems",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_syncListItems",
")",
"{",
"$",
"this",
"->",
"_syncListItems",
"=",
"new",
"SyncListItemList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'serviceSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_syncListItems",
";",
"}"
] | Access the syncListItems
@return \Twilio\Rest\Preview\Sync\Service\SyncList\SyncListItemList | [
"Access",
"the",
"syncListItems"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Preview/Sync/Service/SyncListContext.php#L86-L96 | train |
twilio/twilio-php | Twilio/Rest/Preview/Sync/Service/SyncListContext.php | SyncListContext.getSyncListPermissions | protected function getSyncListPermissions() {
if (!$this->_syncListPermissions) {
$this->_syncListPermissions = new SyncListPermissionList(
$this->version,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
return $this->_syncListPermissions;
} | php | protected function getSyncListPermissions() {
if (!$this->_syncListPermissions) {
$this->_syncListPermissions = new SyncListPermissionList(
$this->version,
$this->solution['serviceSid'],
$this->solution['sid']
);
}
return $this->_syncListPermissions;
} | [
"protected",
"function",
"getSyncListPermissions",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_syncListPermissions",
")",
"{",
"$",
"this",
"->",
"_syncListPermissions",
"=",
"new",
"SyncListPermissionList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'serviceSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_syncListPermissions",
";",
"}"
] | Access the syncListPermissions
@return \Twilio\Rest\Preview\Sync\Service\SyncList\SyncListPermissionList | [
"Access",
"the",
"syncListPermissions"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Preview/Sync/Service/SyncListContext.php#L103-L113 | train |
twilio/twilio-php | Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentContext.php | AuthorizationDocumentContext.getDependentHostedNumberOrders | protected function getDependentHostedNumberOrders() {
if (!$this->_dependentHostedNumberOrders) {
$this->_dependentHostedNumberOrders = new DependentHostedNumberOrderList(
$this->version,
$this->solution['sid']
);
}
return $this->_dependentHostedNumberOrders;
} | php | protected function getDependentHostedNumberOrders() {
if (!$this->_dependentHostedNumberOrders) {
$this->_dependentHostedNumberOrders = new DependentHostedNumberOrderList(
$this->version,
$this->solution['sid']
);
}
return $this->_dependentHostedNumberOrders;
} | [
"protected",
"function",
"getDependentHostedNumberOrders",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_dependentHostedNumberOrders",
")",
"{",
"$",
"this",
"->",
"_dependentHostedNumberOrders",
"=",
"new",
"DependentHostedNumberOrderList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_dependentHostedNumberOrders",
";",
"}"
] | Access the dependentHostedNumberOrders
@return \Twilio\Rest\Preview\HostedNumbers\AuthorizationDocument\DependentHostedNumberOrderList | [
"Access",
"the",
"dependentHostedNumberOrders"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Preview/HostedNumbers/AuthorizationDocumentContext.php#L97-L106 | train |
twilio/twilio-php | Twilio/Rest/Fax/V1/FaxList.php | FaxList.create | public function create($to, $mediaUrl, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'To' => $to,
'MediaUrl' => $mediaUrl,
'Quality' => $options['quality'],
'StatusCallback' => $options['statusCallback'],
'From' => $options['from'],
'SipAuthUsername' => $options['sipAuthUsername'],
'SipAuthPassword' => $options['sipAuthPassword'],
'StoreMedia' => Serialize::booleanToString($options['storeMedia']),
'Ttl' => $options['ttl'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new FaxInstance($this->version, $payload);
} | php | public function create($to, $mediaUrl, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'To' => $to,
'MediaUrl' => $mediaUrl,
'Quality' => $options['quality'],
'StatusCallback' => $options['statusCallback'],
'From' => $options['from'],
'SipAuthUsername' => $options['sipAuthUsername'],
'SipAuthPassword' => $options['sipAuthPassword'],
'StoreMedia' => Serialize::booleanToString($options['storeMedia']),
'Ttl' => $options['ttl'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new FaxInstance($this->version, $payload);
} | [
"public",
"function",
"create",
"(",
"$",
"to",
",",
"$",
"mediaUrl",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'To'",
"=>",
"$",
"to",
",",
"'MediaUrl'",
"=>",
"$",
"mediaUrl",
",",
"'Quality'",
"=>",
"$",
"options",
"[",
"'quality'",
"]",
",",
"'StatusCallback'",
"=>",
"$",
"options",
"[",
"'statusCallback'",
"]",
",",
"'From'",
"=>",
"$",
"options",
"[",
"'from'",
"]",
",",
"'SipAuthUsername'",
"=>",
"$",
"options",
"[",
"'sipAuthUsername'",
"]",
",",
"'SipAuthPassword'",
"=>",
"$",
"options",
"[",
"'sipAuthPassword'",
"]",
",",
"'StoreMedia'",
"=>",
"Serialize",
"::",
"booleanToString",
"(",
"$",
"options",
"[",
"'storeMedia'",
"]",
")",
",",
"'Ttl'",
"=>",
"$",
"options",
"[",
"'ttl'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"FaxInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
")",
";",
"}"
] | Create a new FaxInstance
@param string $to The phone number to receive the fax
@param string $mediaUrl The Twilio-hosted URL of the PDF that contains the
fax
@param array|Options $options Optional Arguments
@return FaxInstance Newly created FaxInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"FaxInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Fax/V1/FaxList.php#L141-L164 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php | AvailablePhoneNumberCountryContext.getLocal | protected function getLocal() {
if (!$this->_local) {
$this->_local = new LocalList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_local;
} | php | protected function getLocal() {
if (!$this->_local) {
$this->_local = new LocalList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_local;
} | [
"protected",
"function",
"getLocal",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_local",
")",
"{",
"$",
"this",
"->",
"_local",
"=",
"new",
"LocalList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'countryCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_local",
";",
"}"
] | Access the local
@return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\LocalList | [
"Access",
"the",
"local"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php#L90-L100 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php | AvailablePhoneNumberCountryContext.getTollFree | protected function getTollFree() {
if (!$this->_tollFree) {
$this->_tollFree = new TollFreeList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_tollFree;
} | php | protected function getTollFree() {
if (!$this->_tollFree) {
$this->_tollFree = new TollFreeList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_tollFree;
} | [
"protected",
"function",
"getTollFree",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_tollFree",
")",
"{",
"$",
"this",
"->",
"_tollFree",
"=",
"new",
"TollFreeList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'countryCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_tollFree",
";",
"}"
] | Access the tollFree
@return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\TollFreeList | [
"Access",
"the",
"tollFree"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php#L107-L117 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php | AvailablePhoneNumberCountryContext.getMobile | protected function getMobile() {
if (!$this->_mobile) {
$this->_mobile = new MobileList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_mobile;
} | php | protected function getMobile() {
if (!$this->_mobile) {
$this->_mobile = new MobileList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_mobile;
} | [
"protected",
"function",
"getMobile",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_mobile",
")",
"{",
"$",
"this",
"->",
"_mobile",
"=",
"new",
"MobileList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'countryCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_mobile",
";",
"}"
] | Access the mobile
@return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\MobileList | [
"Access",
"the",
"mobile"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php#L124-L134 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php | AvailablePhoneNumberCountryContext.getNational | protected function getNational() {
if (!$this->_national) {
$this->_national = new NationalList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_national;
} | php | protected function getNational() {
if (!$this->_national) {
$this->_national = new NationalList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_national;
} | [
"protected",
"function",
"getNational",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_national",
")",
"{",
"$",
"this",
"->",
"_national",
"=",
"new",
"NationalList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'countryCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_national",
";",
"}"
] | Access the national
@return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\NationalList | [
"Access",
"the",
"national"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php#L141-L151 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php | AvailablePhoneNumberCountryContext.getVoip | protected function getVoip() {
if (!$this->_voip) {
$this->_voip = new VoipList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_voip;
} | php | protected function getVoip() {
if (!$this->_voip) {
$this->_voip = new VoipList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_voip;
} | [
"protected",
"function",
"getVoip",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_voip",
")",
"{",
"$",
"this",
"->",
"_voip",
"=",
"new",
"VoipList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'countryCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_voip",
";",
"}"
] | Access the voip
@return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\VoipList | [
"Access",
"the",
"voip"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php#L158-L168 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php | AvailablePhoneNumberCountryContext.getSharedCost | protected function getSharedCost() {
if (!$this->_sharedCost) {
$this->_sharedCost = new SharedCostList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_sharedCost;
} | php | protected function getSharedCost() {
if (!$this->_sharedCost) {
$this->_sharedCost = new SharedCostList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_sharedCost;
} | [
"protected",
"function",
"getSharedCost",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_sharedCost",
")",
"{",
"$",
"this",
"->",
"_sharedCost",
"=",
"new",
"SharedCostList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'countryCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_sharedCost",
";",
"}"
] | Access the sharedCost
@return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\SharedCostList | [
"Access",
"the",
"sharedCost"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php#L175-L185 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php | AvailablePhoneNumberCountryContext.getMachineToMachine | protected function getMachineToMachine() {
if (!$this->_machineToMachine) {
$this->_machineToMachine = new MachineToMachineList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_machineToMachine;
} | php | protected function getMachineToMachine() {
if (!$this->_machineToMachine) {
$this->_machineToMachine = new MachineToMachineList(
$this->version,
$this->solution['accountSid'],
$this->solution['countryCode']
);
}
return $this->_machineToMachine;
} | [
"protected",
"function",
"getMachineToMachine",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_machineToMachine",
")",
"{",
"$",
"this",
"->",
"_machineToMachine",
"=",
"new",
"MachineToMachineList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'countryCode'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_machineToMachine",
";",
"}"
] | Access the machineToMachine
@return \Twilio\Rest\Api\V2010\Account\AvailablePhoneNumberCountry\MachineToMachineList | [
"Access",
"the",
"machineToMachine"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/AvailablePhoneNumberCountryContext.php#L192-L202 | train |
twilio/twilio-php | Twilio/Rest/Preview/Understand/Assistant/QueryList.php | QueryList.create | public function create($language, $query, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'Language' => $language,
'Query' => $query,
'Tasks' => $options['tasks'],
'ModelBuild' => $options['modelBuild'],
'Field' => $options['field'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new QueryInstance($this->version, $payload, $this->solution['assistantSid']);
} | php | public function create($language, $query, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'Language' => $language,
'Query' => $query,
'Tasks' => $options['tasks'],
'ModelBuild' => $options['modelBuild'],
'Field' => $options['field'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new QueryInstance($this->version, $payload, $this->solution['assistantSid']);
} | [
"public",
"function",
"create",
"(",
"$",
"language",
",",
"$",
"query",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'Language'",
"=>",
"$",
"language",
",",
"'Query'",
"=>",
"$",
"query",
",",
"'Tasks'",
"=>",
"$",
"options",
"[",
"'tasks'",
"]",
",",
"'ModelBuild'",
"=>",
"$",
"options",
"[",
"'modelBuild'",
"]",
",",
"'Field'",
"=>",
"$",
"options",
"[",
"'field'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"QueryInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
",",
"$",
"this",
"->",
"solution",
"[",
"'assistantSid'",
"]",
")",
";",
"}"
] | Create a new QueryInstance
@param string $language An ISO language-country string of the sample.
@param string $query A user-provided string that uniquely identifies this
resource as an alternative to the sid. It can be up to
2048 characters long.
@param array|Options $options Optional Arguments
@return QueryInstance Newly created QueryInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"QueryInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Preview/Understand/Assistant/QueryList.php#L141-L160 | train |
twilio/twilio-php | Twilio/Jwt/Grants/VoiceGrant.php | VoiceGrant.setOutgoingApplication | public function setOutgoingApplication($sid, $params) {
$this->outgoingApplicationSid = $sid;
$this->outgoingApplicationParams = $params;
return $this;
} | php | public function setOutgoingApplication($sid, $params) {
$this->outgoingApplicationSid = $sid;
$this->outgoingApplicationParams = $params;
return $this;
} | [
"public",
"function",
"setOutgoingApplication",
"(",
"$",
"sid",
",",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"outgoingApplicationSid",
"=",
"$",
"sid",
";",
"$",
"this",
"->",
"outgoingApplicationParams",
"=",
"$",
"params",
";",
"return",
"$",
"this",
";",
"}"
] | Set the outgoing application of the the grant
@param string $sid outgoing application sid of the grant
@param string $params params to pass the the application
@return $this updated grant | [
"Set",
"the",
"outgoing",
"application",
"of",
"the",
"the",
"grant"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Jwt/Grants/VoiceGrant.php#L79-L83 | train |
twilio/twilio-php | Twilio/Rest/Chat/V2/ServiceContext.php | ServiceContext.getChannels | protected function getChannels() {
if (!$this->_channels) {
$this->_channels = new ChannelList($this->version, $this->solution['sid']);
}
return $this->_channels;
} | php | protected function getChannels() {
if (!$this->_channels) {
$this->_channels = new ChannelList($this->version, $this->solution['sid']);
}
return $this->_channels;
} | [
"protected",
"function",
"getChannels",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_channels",
")",
"{",
"$",
"this",
"->",
"_channels",
"=",
"new",
"ChannelList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_channels",
";",
"}"
] | Access the channels
@return \Twilio\Rest\Chat\V2\Service\ChannelList | [
"Access",
"the",
"channels"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Chat/V2/ServiceContext.php#L142-L148 | train |
twilio/twilio-php | Twilio/Rest/Chat/V2/ServiceContext.php | ServiceContext.getRoles | protected function getRoles() {
if (!$this->_roles) {
$this->_roles = new RoleList($this->version, $this->solution['sid']);
}
return $this->_roles;
} | php | protected function getRoles() {
if (!$this->_roles) {
$this->_roles = new RoleList($this->version, $this->solution['sid']);
}
return $this->_roles;
} | [
"protected",
"function",
"getRoles",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_roles",
")",
"{",
"$",
"this",
"->",
"_roles",
"=",
"new",
"RoleList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_roles",
";",
"}"
] | Access the roles
@return \Twilio\Rest\Chat\V2\Service\RoleList | [
"Access",
"the",
"roles"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Chat/V2/ServiceContext.php#L155-L161 | train |
twilio/twilio-php | Twilio/Rest/Chat/V2/ServiceContext.php | ServiceContext.getUsers | protected function getUsers() {
if (!$this->_users) {
$this->_users = new UserList($this->version, $this->solution['sid']);
}
return $this->_users;
} | php | protected function getUsers() {
if (!$this->_users) {
$this->_users = new UserList($this->version, $this->solution['sid']);
}
return $this->_users;
} | [
"protected",
"function",
"getUsers",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_users",
")",
"{",
"$",
"this",
"->",
"_users",
"=",
"new",
"UserList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_users",
";",
"}"
] | Access the users
@return \Twilio\Rest\Chat\V2\Service\UserList | [
"Access",
"the",
"users"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Chat/V2/ServiceContext.php#L168-L174 | train |
twilio/twilio-php | Twilio/Rest/Chat/V2/ServiceContext.php | ServiceContext.getBindings | protected function getBindings() {
if (!$this->_bindings) {
$this->_bindings = new BindingList($this->version, $this->solution['sid']);
}
return $this->_bindings;
} | php | protected function getBindings() {
if (!$this->_bindings) {
$this->_bindings = new BindingList($this->version, $this->solution['sid']);
}
return $this->_bindings;
} | [
"protected",
"function",
"getBindings",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_bindings",
")",
"{",
"$",
"this",
"->",
"_bindings",
"=",
"new",
"BindingList",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'sid'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_bindings",
";",
"}"
] | Access the bindings
@return \Twilio\Rest\Chat\V2\Service\BindingList | [
"Access",
"the",
"bindings"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Chat/V2/ServiceContext.php#L181-L187 | train |
twilio/twilio-php | Twilio/TwiML/VoiceResponse.php | VoiceResponse.dial | public function dial($number = null, $attributes = array()) {
return $this->nest(new Voice\Dial($number, $attributes));
} | php | public function dial($number = null, $attributes = array()) {
return $this->nest(new Voice\Dial($number, $attributes));
} | [
"public",
"function",
"dial",
"(",
"$",
"number",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"nest",
"(",
"new",
"Voice",
"\\",
"Dial",
"(",
"$",
"number",
",",
"$",
"attributes",
")",
")",
";",
"}"
] | Add Dial child.
@param string $number Phone number to dial
@param array $attributes Optional attributes
@return TwiML Child element. | [
"Add",
"Dial",
"child",
"."
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/TwiML/VoiceResponse.php#L37-L39 | train |
twilio/twilio-php | Twilio/TwiML/VoiceResponse.php | VoiceResponse.enqueue | public function enqueue($name = null, $attributes = array()) {
return $this->nest(new Voice\Enqueue($name, $attributes));
} | php | public function enqueue($name = null, $attributes = array()) {
return $this->nest(new Voice\Enqueue($name, $attributes));
} | [
"public",
"function",
"enqueue",
"(",
"$",
"name",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"nest",
"(",
"new",
"Voice",
"\\",
"Enqueue",
"(",
"$",
"name",
",",
"$",
"attributes",
")",
")",
";",
"}"
] | Add Enqueue child.
@param string $name Friendly name
@param array $attributes Optional attributes
@return TwiML Child element. | [
"Add",
"Enqueue",
"child",
"."
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/TwiML/VoiceResponse.php#L57-L59 | train |
twilio/twilio-php | Twilio/TwiML/VoiceResponse.php | VoiceResponse.play | public function play($url = null, $attributes = array()) {
return $this->nest(new Voice\Play($url, $attributes));
} | php | public function play($url = null, $attributes = array()) {
return $this->nest(new Voice\Play($url, $attributes));
} | [
"public",
"function",
"play",
"(",
"$",
"url",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"nest",
"(",
"new",
"Voice",
"\\",
"Play",
"(",
"$",
"url",
",",
"$",
"attributes",
")",
")",
";",
"}"
] | Add Play child.
@param url $url Media URL
@param array $attributes Optional attributes
@return TwiML Child element. | [
"Add",
"Play",
"child",
"."
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/TwiML/VoiceResponse.php#L106-L108 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingList.php | CredentialListMappingList.getContext | public function getContext($sid) {
return new CredentialListMappingContext(
$this->version,
$this->solution['accountSid'],
$this->solution['domainSid'],
$sid
);
} | php | public function getContext($sid) {
return new CredentialListMappingContext(
$this->version,
$this->solution['accountSid'],
$this->solution['domainSid'],
$sid
);
} | [
"public",
"function",
"getContext",
"(",
"$",
"sid",
")",
"{",
"return",
"new",
"CredentialListMappingContext",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'domainSid'",
"]",
",",
"$",
"sid",
")",
";",
"}"
] | Constructs a CredentialListMappingContext
@param string $sid A string that identifies the resource to fetch
@return \Twilio\Rest\Api\V2010\Account\Sip\Domain\CredentialListMappingContext | [
"Constructs",
"a",
"CredentialListMappingContext"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/Sip/Domain/CredentialListMappingList.php#L156-L163 | train |
twilio/twilio-php | Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionList.php | SyncMapPermissionList.getContext | public function getContext($identity) {
return new SyncMapPermissionContext(
$this->version,
$this->solution['serviceSid'],
$this->solution['mapSid'],
$identity
);
} | php | public function getContext($identity) {
return new SyncMapPermissionContext(
$this->version,
$this->solution['serviceSid'],
$this->solution['mapSid'],
$identity
);
} | [
"public",
"function",
"getContext",
"(",
"$",
"identity",
")",
"{",
"return",
"new",
"SyncMapPermissionContext",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"this",
"->",
"solution",
"[",
"'serviceSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'mapSid'",
"]",
",",
"$",
"identity",
")",
";",
"}"
] | Constructs a SyncMapPermissionContext
@param string $identity Identity of the user to whom the Sync Map Permission
applies.
@return \Twilio\Rest\Preview\Sync\Service\SyncMap\SyncMapPermissionContext | [
"Constructs",
"a",
"SyncMapPermissionContext"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Preview/Sync/Service/SyncMap/SyncMapPermissionList.php#L130-L137 | train |
twilio/twilio-php | Twilio/Rest/Notify/V1/Service/NotificationList.php | NotificationList.create | public function create($options = array()) {
$options = new Values($options);
$data = Values::of(array(
'Identity' => Serialize::map($options['identity'], function($e) { return $e; }),
'Tag' => Serialize::map($options['tag'], function($e) { return $e; }),
'Body' => $options['body'],
'Priority' => $options['priority'],
'Ttl' => $options['ttl'],
'Title' => $options['title'],
'Sound' => $options['sound'],
'Action' => $options['action'],
'Data' => Serialize::jsonObject($options['data']),
'Apn' => Serialize::jsonObject($options['apn']),
'Gcm' => Serialize::jsonObject($options['gcm']),
'Sms' => Serialize::jsonObject($options['sms']),
'FacebookMessenger' => Serialize::jsonObject($options['facebookMessenger']),
'Fcm' => Serialize::jsonObject($options['fcm']),
'Segment' => Serialize::map($options['segment'], function($e) { return $e; }),
'Alexa' => Serialize::jsonObject($options['alexa']),
'ToBinding' => Serialize::map($options['toBinding'], function($e) { return $e; }),
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new NotificationInstance($this->version, $payload, $this->solution['serviceSid']);
} | php | public function create($options = array()) {
$options = new Values($options);
$data = Values::of(array(
'Identity' => Serialize::map($options['identity'], function($e) { return $e; }),
'Tag' => Serialize::map($options['tag'], function($e) { return $e; }),
'Body' => $options['body'],
'Priority' => $options['priority'],
'Ttl' => $options['ttl'],
'Title' => $options['title'],
'Sound' => $options['sound'],
'Action' => $options['action'],
'Data' => Serialize::jsonObject($options['data']),
'Apn' => Serialize::jsonObject($options['apn']),
'Gcm' => Serialize::jsonObject($options['gcm']),
'Sms' => Serialize::jsonObject($options['sms']),
'FacebookMessenger' => Serialize::jsonObject($options['facebookMessenger']),
'Fcm' => Serialize::jsonObject($options['fcm']),
'Segment' => Serialize::map($options['segment'], function($e) { return $e; }),
'Alexa' => Serialize::jsonObject($options['alexa']),
'ToBinding' => Serialize::map($options['toBinding'], function($e) { return $e; }),
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new NotificationInstance($this->version, $payload, $this->solution['serviceSid']);
} | [
"public",
"function",
"create",
"(",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'Identity'",
"=>",
"Serialize",
"::",
"map",
"(",
"$",
"options",
"[",
"'identity'",
"]",
",",
"function",
"(",
"$",
"e",
")",
"{",
"return",
"$",
"e",
";",
"}",
")",
",",
"'Tag'",
"=>",
"Serialize",
"::",
"map",
"(",
"$",
"options",
"[",
"'tag'",
"]",
",",
"function",
"(",
"$",
"e",
")",
"{",
"return",
"$",
"e",
";",
"}",
")",
",",
"'Body'",
"=>",
"$",
"options",
"[",
"'body'",
"]",
",",
"'Priority'",
"=>",
"$",
"options",
"[",
"'priority'",
"]",
",",
"'Ttl'",
"=>",
"$",
"options",
"[",
"'ttl'",
"]",
",",
"'Title'",
"=>",
"$",
"options",
"[",
"'title'",
"]",
",",
"'Sound'",
"=>",
"$",
"options",
"[",
"'sound'",
"]",
",",
"'Action'",
"=>",
"$",
"options",
"[",
"'action'",
"]",
",",
"'Data'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'data'",
"]",
")",
",",
"'Apn'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'apn'",
"]",
")",
",",
"'Gcm'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'gcm'",
"]",
")",
",",
"'Sms'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'sms'",
"]",
")",
",",
"'FacebookMessenger'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'facebookMessenger'",
"]",
")",
",",
"'Fcm'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'fcm'",
"]",
")",
",",
"'Segment'",
"=>",
"Serialize",
"::",
"map",
"(",
"$",
"options",
"[",
"'segment'",
"]",
",",
"function",
"(",
"$",
"e",
")",
"{",
"return",
"$",
"e",
";",
"}",
")",
",",
"'Alexa'",
"=>",
"Serialize",
"::",
"jsonObject",
"(",
"$",
"options",
"[",
"'alexa'",
"]",
")",
",",
"'ToBinding'",
"=>",
"Serialize",
"::",
"map",
"(",
"$",
"options",
"[",
"'toBinding'",
"]",
",",
"function",
"(",
"$",
"e",
")",
"{",
"return",
"$",
"e",
";",
"}",
")",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"NotificationInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
",",
"$",
"this",
"->",
"solution",
"[",
"'serviceSid'",
"]",
")",
";",
"}"
] | Create a new NotificationInstance
@param array|Options $options Optional Arguments
@return NotificationInstance Newly created NotificationInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"NotificationInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Notify/V1/Service/NotificationList.php#L46-L77 | train |
twilio/twilio-php | Twilio/Rest/Accounts/V1/Credential/PublicKeyList.php | PublicKeyList.create | public function create($publicKey, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'PublicKey' => $publicKey,
'FriendlyName' => $options['friendlyName'],
'AccountSid' => $options['accountSid'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new PublicKeyInstance($this->version, $payload);
} | php | public function create($publicKey, $options = array()) {
$options = new Values($options);
$data = Values::of(array(
'PublicKey' => $publicKey,
'FriendlyName' => $options['friendlyName'],
'AccountSid' => $options['accountSid'],
));
$payload = $this->version->create(
'POST',
$this->uri,
array(),
$data
);
return new PublicKeyInstance($this->version, $payload);
} | [
"public",
"function",
"create",
"(",
"$",
"publicKey",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"new",
"Values",
"(",
"$",
"options",
")",
";",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'PublicKey'",
"=>",
"$",
"publicKey",
",",
"'FriendlyName'",
"=>",
"$",
"options",
"[",
"'friendlyName'",
"]",
",",
"'AccountSid'",
"=>",
"$",
"options",
"[",
"'accountSid'",
"]",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"create",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"PublicKeyInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
")",
";",
"}"
] | Create a new PublicKeyInstance
@param string $publicKey A URL encoded representation of the public key
@param array|Options $options Optional Arguments
@return PublicKeyInstance Newly created PublicKeyInstance
@throws TwilioException When an HTTP error occurs. | [
"Create",
"a",
"new",
"PublicKeyInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Accounts/V1/Credential/PublicKeyList.php#L127-L144 | train |
twilio/twilio-php | Twilio/Rest/Api/V2010/Account/Queue/MemberContext.php | MemberContext.update | public function update($url, $method) {
$data = Values::of(array('Url' => $url, 'Method' => $method, ));
$payload = $this->version->update(
'POST',
$this->uri,
array(),
$data
);
return new MemberInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['queueSid'],
$this->solution['callSid']
);
} | php | public function update($url, $method) {
$data = Values::of(array('Url' => $url, 'Method' => $method, ));
$payload = $this->version->update(
'POST',
$this->uri,
array(),
$data
);
return new MemberInstance(
$this->version,
$payload,
$this->solution['accountSid'],
$this->solution['queueSid'],
$this->solution['callSid']
);
} | [
"public",
"function",
"update",
"(",
"$",
"url",
",",
"$",
"method",
")",
"{",
"$",
"data",
"=",
"Values",
"::",
"of",
"(",
"array",
"(",
"'Url'",
"=>",
"$",
"url",
",",
"'Method'",
"=>",
"$",
"method",
",",
")",
")",
";",
"$",
"payload",
"=",
"$",
"this",
"->",
"version",
"->",
"update",
"(",
"'POST'",
",",
"$",
"this",
"->",
"uri",
",",
"array",
"(",
")",
",",
"$",
"data",
")",
";",
"return",
"new",
"MemberInstance",
"(",
"$",
"this",
"->",
"version",
",",
"$",
"payload",
",",
"$",
"this",
"->",
"solution",
"[",
"'accountSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'queueSid'",
"]",
",",
"$",
"this",
"->",
"solution",
"[",
"'callSid'",
"]",
")",
";",
"}"
] | Update the MemberInstance
@param string $url The absolute URL of the Queue resource
@param string $method How to pass the update request data
@return MemberInstance Updated MemberInstance
@throws TwilioException When an HTTP error occurs. | [
"Update",
"the",
"MemberInstance"
] | 58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f | https://github.com/twilio/twilio-php/blob/58a8322c5a8ce2ff7d68cd16ff56dc8ab44c168f/Twilio/Rest/Api/V2010/Account/Queue/MemberContext.php#L72-L89 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.