repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
lode/jsonapi
src/response.php
response.add_included_resource
public function add_included_resource(\alsvanzelf\jsonapi\resource $resource) { if (property_exists($this, 'included_resources') == false) { throw new \Exception(get_class($this).' can not contain included resources'); } $resource_array = $resource->get_array(); if (empty($resource_array['data']['id'])) { return; } // root-level meta-data if (!empty($resource_array['meta'])) { $this->fill_meta($resource_array['meta']); } $resource_array = $resource_array['data']; $key = $resource->get_type().'/'.$resource->get_id(); $this->included_data[$key] = $resource_array; // make a backup of the actual resource, to pass on to a collection $this->included_resources[$key] = $resource; // allow nesting relationshios foreach ($resource->get_included_resources() as $included_resource) { if (empty($included_resource->primary_id)) { continue; } $included_key = $included_resource->get_type().'/'.$included_resource->get_id(); $this->included_resources[$included_key] = $included_resource; $included_array = $included_resource->get_array(); $included_array = $included_array['data']; $this->included_data[$included_key] = $included_array; } }
php
public function add_included_resource(\alsvanzelf\jsonapi\resource $resource) { if (property_exists($this, 'included_resources') == false) { throw new \Exception(get_class($this).' can not contain included resources'); } $resource_array = $resource->get_array(); if (empty($resource_array['data']['id'])) { return; } // root-level meta-data if (!empty($resource_array['meta'])) { $this->fill_meta($resource_array['meta']); } $resource_array = $resource_array['data']; $key = $resource->get_type().'/'.$resource->get_id(); $this->included_data[$key] = $resource_array; // make a backup of the actual resource, to pass on to a collection $this->included_resources[$key] = $resource; // allow nesting relationshios foreach ($resource->get_included_resources() as $included_resource) { if (empty($included_resource->primary_id)) { continue; } $included_key = $included_resource->get_type().'/'.$included_resource->get_id(); $this->included_resources[$included_key] = $included_resource; $included_array = $included_resource->get_array(); $included_array = $included_array['data']; $this->included_data[$included_key] = $included_array; } }
[ "public", "function", "add_included_resource", "(", "\\", "alsvanzelf", "\\", "jsonapi", "\\", "resource", "$", "resource", ")", "{", "if", "(", "property_exists", "(", "$", "this", ",", "'included_resources'", ")", "==", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "get_class", "(", "$", "this", ")", ".", "' can not contain included resources'", ")", ";", "}", "$", "resource_array", "=", "$", "resource", "->", "get_array", "(", ")", ";", "if", "(", "empty", "(", "$", "resource_array", "[", "'data'", "]", "[", "'id'", "]", ")", ")", "{", "return", ";", "}", "// root-level meta-data", "if", "(", "!", "empty", "(", "$", "resource_array", "[", "'meta'", "]", ")", ")", "{", "$", "this", "->", "fill_meta", "(", "$", "resource_array", "[", "'meta'", "]", ")", ";", "}", "$", "resource_array", "=", "$", "resource_array", "[", "'data'", "]", ";", "$", "key", "=", "$", "resource", "->", "get_type", "(", ")", ".", "'/'", ".", "$", "resource", "->", "get_id", "(", ")", ";", "$", "this", "->", "included_data", "[", "$", "key", "]", "=", "$", "resource_array", ";", "// make a backup of the actual resource, to pass on to a collection", "$", "this", "->", "included_resources", "[", "$", "key", "]", "=", "$", "resource", ";", "// allow nesting relationshios", "foreach", "(", "$", "resource", "->", "get_included_resources", "(", ")", "as", "$", "included_resource", ")", "{", "if", "(", "empty", "(", "$", "included_resource", "->", "primary_id", ")", ")", "{", "continue", ";", "}", "$", "included_key", "=", "$", "included_resource", "->", "get_type", "(", ")", ".", "'/'", ".", "$", "included_resource", "->", "get_id", "(", ")", ";", "$", "this", "->", "included_resources", "[", "$", "included_key", "]", "=", "$", "included_resource", ";", "$", "included_array", "=", "$", "included_resource", "->", "get_array", "(", ")", ";", "$", "included_array", "=", "$", "included_array", "[", "'data'", "]", ";", "$", "this", "->", "included_data", "[", "$", "included_key", "]", "=", "$", "included_array", ";", "}", "}" ]
adds an included resource this will end up in response.included[] prefer using ->add_relation() instead a $resource should have its 'id' set @note this can only be used by resource and collection, not by errors @param \alsvanzelf\jsonapi\resource $resource
[ "adds", "an", "included", "resource", "this", "will", "end", "up", "in", "response", ".", "included", "[]" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/response.php#L359-L397
lode/jsonapi
src/response.php
response.fill_included_resources
public function fill_included_resources($resources) { if ($resources instanceof \alsvanzelf\jsonapi\collection) { $resources = $resources->get_resources(); } foreach ($resources as $resource) { $this->add_included_resource($resource); } }
php
public function fill_included_resources($resources) { if ($resources instanceof \alsvanzelf\jsonapi\collection) { $resources = $resources->get_resources(); } foreach ($resources as $resource) { $this->add_included_resource($resource); } }
[ "public", "function", "fill_included_resources", "(", "$", "resources", ")", "{", "if", "(", "$", "resources", "instanceof", "\\", "alsvanzelf", "\\", "jsonapi", "\\", "collection", ")", "{", "$", "resources", "=", "$", "resources", "->", "get_resources", "(", ")", ";", "}", "foreach", "(", "$", "resources", "as", "$", "resource", ")", "{", "$", "this", "->", "add_included_resource", "(", "$", "resource", ")", ";", "}", "}" ]
fills the included resources this will end up in response.included[] prefer using ->fill_relations() instead @param mixed $resources array of \alsvanzelf\jsonapi\resource objects or \alsvanzelf\jsonapi\collection object @return void
[ "fills", "the", "included", "resources", "this", "will", "end", "up", "in", "response", ".", "included", "[]" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/response.php#L409-L417
lode/jsonapi
src/Document.php
Document.addLink
public function addLink($key, $href, array $meta=[], $level=Document::LEVEL_ROOT) { if ($level === Document::LEVEL_ROOT) { if ($this->links === null) { $this->setLinksObject(new LinksObject()); } $this->links->add($key, $href, $meta); } elseif ($level === Document::LEVEL_JSONAPI) { throw new InputException('level "jsonapi" can not be used for links'); } elseif ($level === Document::LEVEL_RESOURCE) { throw new InputException('level "resource" can only be set on a ResourceDocument'); } else { throw new InputException('unknown level "'.$level.'"'); } }
php
public function addLink($key, $href, array $meta=[], $level=Document::LEVEL_ROOT) { if ($level === Document::LEVEL_ROOT) { if ($this->links === null) { $this->setLinksObject(new LinksObject()); } $this->links->add($key, $href, $meta); } elseif ($level === Document::LEVEL_JSONAPI) { throw new InputException('level "jsonapi" can not be used for links'); } elseif ($level === Document::LEVEL_RESOURCE) { throw new InputException('level "resource" can only be set on a ResourceDocument'); } else { throw new InputException('unknown level "'.$level.'"'); } }
[ "public", "function", "addLink", "(", "$", "key", ",", "$", "href", ",", "array", "$", "meta", "=", "[", "]", ",", "$", "level", "=", "Document", "::", "LEVEL_ROOT", ")", "{", "if", "(", "$", "level", "===", "Document", "::", "LEVEL_ROOT", ")", "{", "if", "(", "$", "this", "->", "links", "===", "null", ")", "{", "$", "this", "->", "setLinksObject", "(", "new", "LinksObject", "(", ")", ")", ";", "}", "$", "this", "->", "links", "->", "add", "(", "$", "key", ",", "$", "href", ",", "$", "meta", ")", ";", "}", "elseif", "(", "$", "level", "===", "Document", "::", "LEVEL_JSONAPI", ")", "{", "throw", "new", "InputException", "(", "'level \"jsonapi\" can not be used for links'", ")", ";", "}", "elseif", "(", "$", "level", "===", "Document", "::", "LEVEL_RESOURCE", ")", "{", "throw", "new", "InputException", "(", "'level \"resource\" can only be set on a ResourceDocument'", ")", ";", "}", "else", "{", "throw", "new", "InputException", "(", "'unknown level \"'", ".", "$", "level", ".", "'\"'", ")", ";", "}", "}" ]
@param string $key @param string $href @param array $meta optional, if given a LinkObject is added, otherwise a link string is added @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT @throws InputException if the $level is Document::LEVEL_JSONAPI, Document::LEVEL_RESOURCE, or unknown
[ "@param", "string", "$key", "@param", "string", "$href", "@param", "array", "$meta", "optional", "if", "given", "a", "LinkObject", "is", "added", "otherwise", "a", "link", "string", "is", "added", "@param", "string", "$level", "one", "of", "the", "Document", "::", "LEVEL_", "*", "constants", "optional", "defaults", "to", "Document", "::", "LEVEL_ROOT" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/Document.php#L95-L112
lode/jsonapi
src/Document.php
Document.setSelfLink
public function setSelfLink($href, array $meta=[], $level=Document::LEVEL_ROOT) { $this->addLink('self', $href, $meta, $level); }
php
public function setSelfLink($href, array $meta=[], $level=Document::LEVEL_ROOT) { $this->addLink('self', $href, $meta, $level); }
[ "public", "function", "setSelfLink", "(", "$", "href", ",", "array", "$", "meta", "=", "[", "]", ",", "$", "level", "=", "Document", "::", "LEVEL_ROOT", ")", "{", "$", "this", "->", "addLink", "(", "'self'", ",", "$", "href", ",", "$", "meta", ",", "$", "level", ")", ";", "}" ]
set the self link on the document @param string $href @param array $meta optional, if given a LinkObject is added, otherwise a link string is added @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT
[ "set", "the", "self", "link", "on", "the", "document" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/Document.php#L121-L123
lode/jsonapi
src/Document.php
Document.addMeta
public function addMeta($key, $value, $level=Document::LEVEL_ROOT) { if ($level === Document::LEVEL_ROOT) { if ($this->meta === null) { $this->setMetaObject(new MetaObject()); } $this->meta->add($key, $value); } elseif ($level === Document::LEVEL_JSONAPI) { if ($this->jsonapi === null) { $this->setJsonapiObject(new JsonapiObject()); } $this->jsonapi->addMeta($key, $value); } elseif ($level === Document::LEVEL_RESOURCE) { throw new InputException('level "resource" can only be set on a ResourceDocument'); } else { throw new InputException('unknown level "'.$level.'"'); } }
php
public function addMeta($key, $value, $level=Document::LEVEL_ROOT) { if ($level === Document::LEVEL_ROOT) { if ($this->meta === null) { $this->setMetaObject(new MetaObject()); } $this->meta->add($key, $value); } elseif ($level === Document::LEVEL_JSONAPI) { if ($this->jsonapi === null) { $this->setJsonapiObject(new JsonapiObject()); } $this->jsonapi->addMeta($key, $value); } elseif ($level === Document::LEVEL_RESOURCE) { throw new InputException('level "resource" can only be set on a ResourceDocument'); } else { throw new InputException('unknown level "'.$level.'"'); } }
[ "public", "function", "addMeta", "(", "$", "key", ",", "$", "value", ",", "$", "level", "=", "Document", "::", "LEVEL_ROOT", ")", "{", "if", "(", "$", "level", "===", "Document", "::", "LEVEL_ROOT", ")", "{", "if", "(", "$", "this", "->", "meta", "===", "null", ")", "{", "$", "this", "->", "setMetaObject", "(", "new", "MetaObject", "(", ")", ")", ";", "}", "$", "this", "->", "meta", "->", "add", "(", "$", "key", ",", "$", "value", ")", ";", "}", "elseif", "(", "$", "level", "===", "Document", "::", "LEVEL_JSONAPI", ")", "{", "if", "(", "$", "this", "->", "jsonapi", "===", "null", ")", "{", "$", "this", "->", "setJsonapiObject", "(", "new", "JsonapiObject", "(", ")", ")", ";", "}", "$", "this", "->", "jsonapi", "->", "addMeta", "(", "$", "key", ",", "$", "value", ")", ";", "}", "elseif", "(", "$", "level", "===", "Document", "::", "LEVEL_RESOURCE", ")", "{", "throw", "new", "InputException", "(", "'level \"resource\" can only be set on a ResourceDocument'", ")", ";", "}", "else", "{", "throw", "new", "InputException", "(", "'unknown level \"'", ".", "$", "level", ".", "'\"'", ")", ";", "}", "}" ]
@param string $key @param mixed $value @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT @throws InputException if the $level is unknown @throws InputException if the $level is Document::LEVEL_RESOURCE
[ "@param", "string", "$key", "@param", "mixed", "$value", "@param", "string", "$level", "one", "of", "the", "Document", "::", "LEVEL_", "*", "constants", "optional", "defaults", "to", "Document", "::", "LEVEL_ROOT" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/Document.php#L133-L154
lode/jsonapi
src/Document.php
Document.applyProfile
public function applyProfile(ProfileInterface $profile) { $this->profiles[] = $profile; if ($this->links === null) { $this->setLinksObject(new LinksObject()); } $link = $profile->getAliasedLink(); if ($link instanceof LinkObject) { $this->links->appendLinkObject('profile', $link); } else { $this->links->append('profile', $link); } }
php
public function applyProfile(ProfileInterface $profile) { $this->profiles[] = $profile; if ($this->links === null) { $this->setLinksObject(new LinksObject()); } $link = $profile->getAliasedLink(); if ($link instanceof LinkObject) { $this->links->appendLinkObject('profile', $link); } else { $this->links->append('profile', $link); } }
[ "public", "function", "applyProfile", "(", "ProfileInterface", "$", "profile", ")", "{", "$", "this", "->", "profiles", "[", "]", "=", "$", "profile", ";", "if", "(", "$", "this", "->", "links", "===", "null", ")", "{", "$", "this", "->", "setLinksObject", "(", "new", "LinksObject", "(", ")", ")", ";", "}", "$", "link", "=", "$", "profile", "->", "getAliasedLink", "(", ")", ";", "if", "(", "$", "link", "instanceof", "LinkObject", ")", "{", "$", "this", "->", "links", "->", "appendLinkObject", "(", "'profile'", ",", "$", "link", ")", ";", "}", "else", "{", "$", "this", "->", "links", "->", "append", "(", "'profile'", ",", "$", "link", ")", ";", "}", "}" ]
apply a profile which adds the link and sets a correct content-type note that the rules from the profile are not automatically enforced applying the rules, and applying them correctly, is manual however the $profile could have custom methods to help @see https://jsonapi.org/format/1.1/#profiles @param ProfileInterface $profile
[ "apply", "a", "profile", "which", "adds", "the", "link", "and", "sets", "a", "correct", "content", "-", "type" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/Document.php#L192-L206
nicmart/StringTemplate
src/StringTemplate/Engine.php
Engine.render
public function render($template, $value) { $result = $template; if (!is_array($value)) $value = array('' => $value); foreach (new NestedKeyIterator(new RecursiveArrayOnlyIterator($value)) as $key => $value) { $result = str_replace($this->left . $key . $this->right, $value, $result); } return $result; }
php
public function render($template, $value) { $result = $template; if (!is_array($value)) $value = array('' => $value); foreach (new NestedKeyIterator(new RecursiveArrayOnlyIterator($value)) as $key => $value) { $result = str_replace($this->left . $key . $this->right, $value, $result); } return $result; }
[ "public", "function", "render", "(", "$", "template", ",", "$", "value", ")", "{", "$", "result", "=", "$", "template", ";", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "$", "value", "=", "array", "(", "''", "=>", "$", "value", ")", ";", "foreach", "(", "new", "NestedKeyIterator", "(", "new", "RecursiveArrayOnlyIterator", "(", "$", "value", ")", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "result", "=", "str_replace", "(", "$", "this", "->", "left", ".", "$", "key", ".", "$", "this", "->", "right", ",", "$", "value", ",", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/nicmart/StringTemplate/blob/612eeb821b33c0b67d3755a5b24471e30d4d737b/src/StringTemplate/Engine.php#L29-L40
lode/jsonapi
src/objects/ErrorObject.php
ErrorObject.fromException
public static function fromException($exception, array $options=[]) { if ($exception instanceof \Exception === false && $exception instanceof \Throwable === false) { throw new InputException('input is not a real exception in php5 or php7'); } $options = array_merge(self::$defaults, $options); $errorObject = new self(); $className = get_class($exception); if (strpos($className, '\\')) { $exploded = explode('\\', $className); $className = end($exploded); } $errorObject->setApplicationCode(Converter::camelCaseToWords($className)); $filePath = $exception->getFile(); if ($options['stripExceptionBasePath'] !== null) { $filePath = str_replace($options['stripExceptionBasePath'], '', $filePath); } $metaObject = MetaObject::fromArray([ 'type' => get_class($exception), 'message' => $exception->getMessage(), 'code' => $exception->getCode(), 'file' => $filePath, 'line' => $exception->getLine(), ]); if ($options['includeExceptionTrace']) { $trace = $exception->getTrace(); if ($options['stripExceptionBasePath'] !== null) { foreach ($trace as &$traceElement) { if (isset($traceElement['file'])) { $traceElement['file'] = str_replace($options['stripExceptionBasePath'], '', $traceElement['file']); } } } $metaObject->add('trace', $trace); } $errorObject->setMetaObject($metaObject); if (Validator::checkHttpStatusCode($exception->getCode())) { $errorObject->setHttpStatusCode($exception->getCode()); } return $errorObject; }
php
public static function fromException($exception, array $options=[]) { if ($exception instanceof \Exception === false && $exception instanceof \Throwable === false) { throw new InputException('input is not a real exception in php5 or php7'); } $options = array_merge(self::$defaults, $options); $errorObject = new self(); $className = get_class($exception); if (strpos($className, '\\')) { $exploded = explode('\\', $className); $className = end($exploded); } $errorObject->setApplicationCode(Converter::camelCaseToWords($className)); $filePath = $exception->getFile(); if ($options['stripExceptionBasePath'] !== null) { $filePath = str_replace($options['stripExceptionBasePath'], '', $filePath); } $metaObject = MetaObject::fromArray([ 'type' => get_class($exception), 'message' => $exception->getMessage(), 'code' => $exception->getCode(), 'file' => $filePath, 'line' => $exception->getLine(), ]); if ($options['includeExceptionTrace']) { $trace = $exception->getTrace(); if ($options['stripExceptionBasePath'] !== null) { foreach ($trace as &$traceElement) { if (isset($traceElement['file'])) { $traceElement['file'] = str_replace($options['stripExceptionBasePath'], '', $traceElement['file']); } } } $metaObject->add('trace', $trace); } $errorObject->setMetaObject($metaObject); if (Validator::checkHttpStatusCode($exception->getCode())) { $errorObject->setHttpStatusCode($exception->getCode()); } return $errorObject; }
[ "public", "static", "function", "fromException", "(", "$", "exception", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "exception", "instanceof", "\\", "Exception", "===", "false", "&&", "$", "exception", "instanceof", "\\", "Throwable", "===", "false", ")", "{", "throw", "new", "InputException", "(", "'input is not a real exception in php5 or php7'", ")", ";", "}", "$", "options", "=", "array_merge", "(", "self", "::", "$", "defaults", ",", "$", "options", ")", ";", "$", "errorObject", "=", "new", "self", "(", ")", ";", "$", "className", "=", "get_class", "(", "$", "exception", ")", ";", "if", "(", "strpos", "(", "$", "className", ",", "'\\\\'", ")", ")", "{", "$", "exploded", "=", "explode", "(", "'\\\\'", ",", "$", "className", ")", ";", "$", "className", "=", "end", "(", "$", "exploded", ")", ";", "}", "$", "errorObject", "->", "setApplicationCode", "(", "Converter", "::", "camelCaseToWords", "(", "$", "className", ")", ")", ";", "$", "filePath", "=", "$", "exception", "->", "getFile", "(", ")", ";", "if", "(", "$", "options", "[", "'stripExceptionBasePath'", "]", "!==", "null", ")", "{", "$", "filePath", "=", "str_replace", "(", "$", "options", "[", "'stripExceptionBasePath'", "]", ",", "''", ",", "$", "filePath", ")", ";", "}", "$", "metaObject", "=", "MetaObject", "::", "fromArray", "(", "[", "'type'", "=>", "get_class", "(", "$", "exception", ")", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'code'", "=>", "$", "exception", "->", "getCode", "(", ")", ",", "'file'", "=>", "$", "filePath", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "]", ")", ";", "if", "(", "$", "options", "[", "'includeExceptionTrace'", "]", ")", "{", "$", "trace", "=", "$", "exception", "->", "getTrace", "(", ")", ";", "if", "(", "$", "options", "[", "'stripExceptionBasePath'", "]", "!==", "null", ")", "{", "foreach", "(", "$", "trace", "as", "&", "$", "traceElement", ")", "{", "if", "(", "isset", "(", "$", "traceElement", "[", "'file'", "]", ")", ")", "{", "$", "traceElement", "[", "'file'", "]", "=", "str_replace", "(", "$", "options", "[", "'stripExceptionBasePath'", "]", ",", "''", ",", "$", "traceElement", "[", "'file'", "]", ")", ";", "}", "}", "}", "$", "metaObject", "->", "add", "(", "'trace'", ",", "$", "trace", ")", ";", "}", "$", "errorObject", "->", "setMetaObject", "(", "$", "metaObject", ")", ";", "if", "(", "Validator", "::", "checkHttpStatusCode", "(", "$", "exception", "->", "getCode", "(", ")", ")", ")", "{", "$", "errorObject", "->", "setHttpStatusCode", "(", "$", "exception", "->", "getCode", "(", ")", ")", ";", "}", "return", "$", "errorObject", ";", "}" ]
@param \Exception|\Throwable $exception @param array $options optional {@see ErrorObject::$defaults} @return ErrorObject @throws InputException if $exception is not \Exception or \Throwable
[ "@param", "\\", "Exception|", "\\", "Throwable", "$exception", "@param", "array", "$options", "optional", "{", "@see", "ErrorObject", "::", "$defaults", "}", "@return", "ErrorObject" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/ErrorObject.php#L71-L120
lode/jsonapi
src/objects/ErrorObject.php
ErrorObject.setHumanExplanation
public function setHumanExplanation($genericTitle, $specificDetails=null, $specificAboutLink=null, $genericTypeLink=null) { $this->setHumanTitle($genericTitle); if ($specificDetails !== null) { $this->setHumanDetails($specificDetails); } if ($specificAboutLink !== null) { $this->setAboutLink($specificAboutLink); } if ($genericTypeLink !== null) { $this->appendTypeLink($genericTypeLink); } }
php
public function setHumanExplanation($genericTitle, $specificDetails=null, $specificAboutLink=null, $genericTypeLink=null) { $this->setHumanTitle($genericTitle); if ($specificDetails !== null) { $this->setHumanDetails($specificDetails); } if ($specificAboutLink !== null) { $this->setAboutLink($specificAboutLink); } if ($genericTypeLink !== null) { $this->appendTypeLink($genericTypeLink); } }
[ "public", "function", "setHumanExplanation", "(", "$", "genericTitle", ",", "$", "specificDetails", "=", "null", ",", "$", "specificAboutLink", "=", "null", ",", "$", "genericTypeLink", "=", "null", ")", "{", "$", "this", "->", "setHumanTitle", "(", "$", "genericTitle", ")", ";", "if", "(", "$", "specificDetails", "!==", "null", ")", "{", "$", "this", "->", "setHumanDetails", "(", "$", "specificDetails", ")", ";", "}", "if", "(", "$", "specificAboutLink", "!==", "null", ")", "{", "$", "this", "->", "setAboutLink", "(", "$", "specificAboutLink", ")", ";", "}", "if", "(", "$", "genericTypeLink", "!==", "null", ")", "{", "$", "this", "->", "appendTypeLink", "(", "$", "genericTypeLink", ")", ";", "}", "}" ]
explain this particular occurence of the error in a human-friendly way @param string $genericTitle title of the generic type of error @param string $specificDetails optional, explanation of the specific error @param string $specificAboutLink optional, explanation of the specific error @param string $genericTypeLink optional, explanation of the generic type of error
[ "explain", "this", "particular", "occurence", "of", "the", "error", "in", "a", "human", "-", "friendly", "way" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/ErrorObject.php#L130-L142
lode/jsonapi
src/objects/ErrorObject.php
ErrorObject.addSource
public function addSource($key, $value) { Validator::checkMemberName($key); $this->source[$key] = $value; }
php
public function addSource($key, $value) { Validator::checkMemberName($key); $this->source[$key] = $value; }
[ "public", "function", "addSource", "(", "$", "key", ",", "$", "value", ")", "{", "Validator", "::", "checkMemberName", "(", "$", "key", ")", ";", "$", "this", "->", "source", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
add the source of the error @param string $key {@see ->blameJsonPointer(), ->blameQueryParameter()} @param string $value
[ "add", "the", "source", "of", "the", "error" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/ErrorObject.php#L225-L229
lode/jsonapi
src/objects/ResourceIdentifierObject.php
ResourceIdentifierObject.fromResourceObject
public static function fromResourceObject(ResourceObject $resourceObject) { $resourceIdentifierObject = new self($resourceObject->type, $resourceObject->id); if ($resourceObject->meta !== null) { $resourceIdentifierObject->setMetaObject($resourceObject->meta); } return $resourceIdentifierObject; }
php
public static function fromResourceObject(ResourceObject $resourceObject) { $resourceIdentifierObject = new self($resourceObject->type, $resourceObject->id); if ($resourceObject->meta !== null) { $resourceIdentifierObject->setMetaObject($resourceObject->meta); } return $resourceIdentifierObject; }
[ "public", "static", "function", "fromResourceObject", "(", "ResourceObject", "$", "resourceObject", ")", "{", "$", "resourceIdentifierObject", "=", "new", "self", "(", "$", "resourceObject", "->", "type", ",", "$", "resourceObject", "->", "id", ")", ";", "if", "(", "$", "resourceObject", "->", "meta", "!==", "null", ")", "{", "$", "resourceIdentifierObject", "->", "setMetaObject", "(", "$", "resourceObject", "->", "meta", ")", ";", "}", "return", "$", "resourceIdentifierObject", ";", "}" ]
@internal @param ResourceObject $resourceObject @return ResourceIdentifierObject
[ "@internal" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/ResourceIdentifierObject.php#L98-L106
lode/jsonapi
src/objects/ResourceIdentifierObject.php
ResourceIdentifierObject.equals
public function equals(ResourceInterface $resource) { if ($this->hasIdentification() === false || $resource->getResource()->hasIdentification() === false) { throw new Exception('can not compare resources if identification is missing'); } return ($this->getIdentificationKey() === $resource->getResource()->getIdentificationKey()); }
php
public function equals(ResourceInterface $resource) { if ($this->hasIdentification() === false || $resource->getResource()->hasIdentification() === false) { throw new Exception('can not compare resources if identification is missing'); } return ($this->getIdentificationKey() === $resource->getResource()->getIdentificationKey()); }
[ "public", "function", "equals", "(", "ResourceInterface", "$", "resource", ")", "{", "if", "(", "$", "this", "->", "hasIdentification", "(", ")", "===", "false", "||", "$", "resource", "->", "getResource", "(", ")", "->", "hasIdentification", "(", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'can not compare resources if identification is missing'", ")", ";", "}", "return", "(", "$", "this", "->", "getIdentificationKey", "(", ")", "===", "$", "resource", "->", "getResource", "(", ")", "->", "getIdentificationKey", "(", ")", ")", ";", "}" ]
@internal @param ResourceInterface $resource @return boolean @throws Exception if one or both are missing identification
[ "@internal" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/ResourceIdentifierObject.php#L116-L122
lode/jsonapi
src/helpers/HttpStatusCodeManager.php
HttpStatusCodeManager.setHttpStatusCode
public function setHttpStatusCode($httpStatusCode) { if (Validator::checkHttpStatusCode($httpStatusCode) === false) { throw new InputException('can not use an invalid http status code'); } $this->httpStatusCode = $httpStatusCode; }
php
public function setHttpStatusCode($httpStatusCode) { if (Validator::checkHttpStatusCode($httpStatusCode) === false) { throw new InputException('can not use an invalid http status code'); } $this->httpStatusCode = $httpStatusCode; }
[ "public", "function", "setHttpStatusCode", "(", "$", "httpStatusCode", ")", "{", "if", "(", "Validator", "::", "checkHttpStatusCode", "(", "$", "httpStatusCode", ")", "===", "false", ")", "{", "throw", "new", "InputException", "(", "'can not use an invalid http status code'", ")", ";", "}", "$", "this", "->", "httpStatusCode", "=", "$", "httpStatusCode", ";", "}" ]
@param int $httpStatusCode @throws InputException if an invalid code is used
[ "@param", "int", "$httpStatusCode" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/helpers/HttpStatusCodeManager.php#L21-L27
lode/jsonapi
src/helpers/Validator.php
Validator.claimUsedFields
public function claimUsedFields(array $fieldNames, $objectContainer, array $options=[]) { $options = array_merge(self::$defaults, $options); foreach ($fieldNames as $fieldName) { if (isset($this->usedFields[$fieldName]) === false) { $this->usedFields[$fieldName] = $objectContainer; continue; } if ($this->usedFields[$fieldName] === $objectContainer) { continue; } /** * @note this is not allowed by the specification */ if ($this->usedFields[$fieldName] === Validator::OBJECT_CONTAINER_TYPE && $options['enforceTypeFieldNamespace'] === false) { continue; } throw new DuplicateException('field name "'.$fieldName.'" already in use at "data.'.$this->usedFields[$fieldName].'"'); } }
php
public function claimUsedFields(array $fieldNames, $objectContainer, array $options=[]) { $options = array_merge(self::$defaults, $options); foreach ($fieldNames as $fieldName) { if (isset($this->usedFields[$fieldName]) === false) { $this->usedFields[$fieldName] = $objectContainer; continue; } if ($this->usedFields[$fieldName] === $objectContainer) { continue; } /** * @note this is not allowed by the specification */ if ($this->usedFields[$fieldName] === Validator::OBJECT_CONTAINER_TYPE && $options['enforceTypeFieldNamespace'] === false) { continue; } throw new DuplicateException('field name "'.$fieldName.'" already in use at "data.'.$this->usedFields[$fieldName].'"'); } }
[ "public", "function", "claimUsedFields", "(", "array", "$", "fieldNames", ",", "$", "objectContainer", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "self", "::", "$", "defaults", ",", "$", "options", ")", ";", "foreach", "(", "$", "fieldNames", "as", "$", "fieldName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "usedFields", "[", "$", "fieldName", "]", ")", "===", "false", ")", "{", "$", "this", "->", "usedFields", "[", "$", "fieldName", "]", "=", "$", "objectContainer", ";", "continue", ";", "}", "if", "(", "$", "this", "->", "usedFields", "[", "$", "fieldName", "]", "===", "$", "objectContainer", ")", "{", "continue", ";", "}", "/**\n\t\t\t * @note this is not allowed by the specification\n\t\t\t */", "if", "(", "$", "this", "->", "usedFields", "[", "$", "fieldName", "]", "===", "Validator", "::", "OBJECT_CONTAINER_TYPE", "&&", "$", "options", "[", "'enforceTypeFieldNamespace'", "]", "===", "false", ")", "{", "continue", ";", "}", "throw", "new", "DuplicateException", "(", "'field name \"'", ".", "$", "fieldName", ".", "'\" already in use at \"data.'", ".", "$", "this", "->", "usedFields", "[", "$", "fieldName", "]", ".", "'\"'", ")", ";", "}", "}" ]
block if already existing in another object, otherwise just overwrite @see https://jsonapi.org/format/1.1/#document-resource-object-fields @param string[] $fieldName @param string $objectContainer one of the Validator::OBJECT_CONTAINER_* constants @param array $options optional {@see Validator::$defaults} @throws DuplicateException
[ "block", "if", "already", "existing", "in", "another", "object", "otherwise", "just", "overwrite" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/helpers/Validator.php#L43-L64
lode/jsonapi
src/helpers/Validator.php
Validator.claimUsedResourceIdentifier
public function claimUsedResourceIdentifier(ResourceInterface $resource) { if ($resource->getResource()->hasIdentification() === false) { throw new InputException('can not validate resource without identifier, set type and id first'); } $resourceKey = $resource->getResource()->getIdentificationKey(); if (isset($this->usedResourceIdentifiers[$resourceKey]) === false) { $this->usedResourceIdentifiers[$resourceKey] = true; return; } throw new DuplicateException('can not have multiple resources with the same identification'); }
php
public function claimUsedResourceIdentifier(ResourceInterface $resource) { if ($resource->getResource()->hasIdentification() === false) { throw new InputException('can not validate resource without identifier, set type and id first'); } $resourceKey = $resource->getResource()->getIdentificationKey(); if (isset($this->usedResourceIdentifiers[$resourceKey]) === false) { $this->usedResourceIdentifiers[$resourceKey] = true; return; } throw new DuplicateException('can not have multiple resources with the same identification'); }
[ "public", "function", "claimUsedResourceIdentifier", "(", "ResourceInterface", "$", "resource", ")", "{", "if", "(", "$", "resource", "->", "getResource", "(", ")", "->", "hasIdentification", "(", ")", "===", "false", ")", "{", "throw", "new", "InputException", "(", "'can not validate resource without identifier, set type and id first'", ")", ";", "}", "$", "resourceKey", "=", "$", "resource", "->", "getResource", "(", ")", "->", "getIdentificationKey", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "usedResourceIdentifiers", "[", "$", "resourceKey", "]", ")", "===", "false", ")", "{", "$", "this", "->", "usedResourceIdentifiers", "[", "$", "resourceKey", "]", "=", "true", ";", "return", ";", "}", "throw", "new", "DuplicateException", "(", "'can not have multiple resources with the same identification'", ")", ";", "}" ]
@param ResourceInterface $resource @throws InputException if no type or id has been set on the resource @throws DuplicateException if the combination of type and id has been set before
[ "@param", "ResourceInterface", "$resource" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/helpers/Validator.php#L85-L97
lode/jsonapi
src/helpers/Validator.php
Validator.checkMemberName
public static function checkMemberName($memberName) { $globallyAllowedCharacters = 'a-zA-Z0-9'; $generallyAllowedCharacters = $globallyAllowedCharacters.'_-'; $regex = '{^ ( ['.$globallyAllowedCharacters.'] | ['.$globallyAllowedCharacters.'] ['.$generallyAllowedCharacters.']* ['.$globallyAllowedCharacters.'] ) $}x'; if (preg_match($regex, $memberName) === 1) { return; } throw new InputException('invalid member name "'.$memberName.'"'); }
php
public static function checkMemberName($memberName) { $globallyAllowedCharacters = 'a-zA-Z0-9'; $generallyAllowedCharacters = $globallyAllowedCharacters.'_-'; $regex = '{^ ( ['.$globallyAllowedCharacters.'] | ['.$globallyAllowedCharacters.'] ['.$generallyAllowedCharacters.']* ['.$globallyAllowedCharacters.'] ) $}x'; if (preg_match($regex, $memberName) === 1) { return; } throw new InputException('invalid member name "'.$memberName.'"'); }
[ "public", "static", "function", "checkMemberName", "(", "$", "memberName", ")", "{", "$", "globallyAllowedCharacters", "=", "'a-zA-Z0-9'", ";", "$", "generallyAllowedCharacters", "=", "$", "globallyAllowedCharacters", ".", "'_-'", ";", "$", "regex", "=", "'{^\n\t\t\t(\n\t\t\t\t['", ".", "$", "globallyAllowedCharacters", ".", "']\n\t\t\t\t\n\t\t\t\t|\n\t\t\t\t\n\t\t\t\t['", ".", "$", "globallyAllowedCharacters", ".", "']\n\t\t\t\t['", ".", "$", "generallyAllowedCharacters", ".", "']*\n\t\t\t\t['", ".", "$", "globallyAllowedCharacters", ".", "']\n\t\t\t)\n\t\t$}x'", ";", "if", "(", "preg_match", "(", "$", "regex", ",", "$", "memberName", ")", "===", "1", ")", "{", "return", ";", "}", "throw", "new", "InputException", "(", "'invalid member name \"'", ".", "$", "memberName", ".", "'\"'", ")", ";", "}" ]
@see https://jsonapi.org/format/1.1/#document-member-names @todo allow non-url safe chars @param string $memberName @throws InputException
[ "@see", "https", ":", "//", "jsonapi", ".", "org", "/", "format", "/", "1", ".", "1", "/", "#document", "-", "member", "-", "names" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/helpers/Validator.php#L108-L129
lode/jsonapi
src/objects/AttributesObject.php
AttributesObject.fromArray
public static function fromArray(array $attributes) { unset($attributes['id']); $attributesObject = new self(); foreach ($attributes as $key => $value) { $attributesObject->add($key, $value); } return $attributesObject; }
php
public static function fromArray(array $attributes) { unset($attributes['id']); $attributesObject = new self(); foreach ($attributes as $key => $value) { $attributesObject->add($key, $value); } return $attributesObject; }
[ "public", "static", "function", "fromArray", "(", "array", "$", "attributes", ")", "{", "unset", "(", "$", "attributes", "[", "'id'", "]", ")", ";", "$", "attributesObject", "=", "new", "self", "(", ")", ";", "foreach", "(", "$", "attributes", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "attributesObject", "->", "add", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "attributesObject", ";", "}" ]
@note if an `id` is set inside $attributes, it is removed from there it is common to find it inside, and not doing so will cause an exception @param array $attributes @return AttributesObject
[ "@note", "if", "an", "id", "is", "set", "inside", "$attributes", "it", "is", "removed", "from", "there", "it", "is", "common", "to", "find", "it", "inside", "and", "not", "doing", "so", "will", "cause", "an", "exception" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/AttributesObject.php#L27-L37
lode/jsonapi
src/objects/LinksObject.php
LinksObject.append
public function append($key, $href, array $meta=[]) { Validator::checkMemberName($key); if (isset($this->links[$key]) === false) { $this->addLinksArray($key, new LinksArray()); } elseif ($this->links[$key] instanceof LinksArray === false) { throw new DuplicateException('can not add to key "'.$key.'", it is not an array of links'); } $this->links[$key]->add($href, $meta); }
php
public function append($key, $href, array $meta=[]) { Validator::checkMemberName($key); if (isset($this->links[$key]) === false) { $this->addLinksArray($key, new LinksArray()); } elseif ($this->links[$key] instanceof LinksArray === false) { throw new DuplicateException('can not add to key "'.$key.'", it is not an array of links'); } $this->links[$key]->add($href, $meta); }
[ "public", "function", "append", "(", "$", "key", ",", "$", "href", ",", "array", "$", "meta", "=", "[", "]", ")", "{", "Validator", "::", "checkMemberName", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "links", "[", "$", "key", "]", ")", "===", "false", ")", "{", "$", "this", "->", "addLinksArray", "(", "$", "key", ",", "new", "LinksArray", "(", ")", ")", ";", "}", "elseif", "(", "$", "this", "->", "links", "[", "$", "key", "]", "instanceof", "LinksArray", "===", "false", ")", "{", "throw", "new", "DuplicateException", "(", "'can not add to key \"'", ".", "$", "key", ".", "'\", it is not an array of links'", ")", ";", "}", "$", "this", "->", "links", "[", "$", "key", "]", "->", "add", "(", "$", "href", ",", "$", "meta", ")", ";", "}" ]
appends a link to an array of links under a specific key @see LinksArray for use cases @param string $key @param string $href @param array $meta optional, if given a LinkObject is added, otherwise a link string is added @throws DuplicateException if another link is already using that $key but is not an array
[ "appends", "a", "link", "to", "an", "array", "of", "links", "under", "a", "specific", "key" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/LinksObject.php#L72-L83
lode/jsonapi
src/objects/LinksObject.php
LinksObject.addLinkString
public function addLinkString($key, $href) { Validator::checkMemberName($key); if (isset($this->links[$key])) { throw new DuplicateException('link with key "'.$key.'" already set'); } $this->links[$key] = $href; }
php
public function addLinkString($key, $href) { Validator::checkMemberName($key); if (isset($this->links[$key])) { throw new DuplicateException('link with key "'.$key.'" already set'); } $this->links[$key] = $href; }
[ "public", "function", "addLinkString", "(", "$", "key", ",", "$", "href", ")", "{", "Validator", "::", "checkMemberName", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "links", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "DuplicateException", "(", "'link with key \"'", ".", "$", "key", ".", "'\" already set'", ")", ";", "}", "$", "this", "->", "links", "[", "$", "key", "]", "=", "$", "href", ";", "}" ]
@param string $key @param string $href @throws DuplicateException if another link is already using that $key
[ "@param", "string", "$key", "@param", "string", "$href" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/LinksObject.php#L95-L103
lode/jsonapi
src/objects/LinksObject.php
LinksObject.addLinkObject
public function addLinkObject($key, LinkObject $linkObject) { Validator::checkMemberName($key); if (isset($this->links[$key])) { throw new DuplicateException('link with key "'.$key.'" already set'); } $this->links[$key] = $linkObject; }
php
public function addLinkObject($key, LinkObject $linkObject) { Validator::checkMemberName($key); if (isset($this->links[$key])) { throw new DuplicateException('link with key "'.$key.'" already set'); } $this->links[$key] = $linkObject; }
[ "public", "function", "addLinkObject", "(", "$", "key", ",", "LinkObject", "$", "linkObject", ")", "{", "Validator", "::", "checkMemberName", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "links", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "DuplicateException", "(", "'link with key \"'", ".", "$", "key", ".", "'\" already set'", ")", ";", "}", "$", "this", "->", "links", "[", "$", "key", "]", "=", "$", "linkObject", ";", "}" ]
@param string $key @param LinkObject $linkObject @throws DuplicateException if another link is already using that $key
[ "@param", "string", "$key", "@param", "LinkObject", "$linkObject" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/LinksObject.php#L111-L119
lode/jsonapi
src/objects/LinksObject.php
LinksObject.addLinksArray
public function addLinksArray($key, LinksArray $linksArray) { Validator::checkMemberName($key); if (isset($this->links[$key])) { throw new DuplicateException('link with key "'.$key.'" already set'); } $this->links[$key] = $linksArray; }
php
public function addLinksArray($key, LinksArray $linksArray) { Validator::checkMemberName($key); if (isset($this->links[$key])) { throw new DuplicateException('link with key "'.$key.'" already set'); } $this->links[$key] = $linksArray; }
[ "public", "function", "addLinksArray", "(", "$", "key", ",", "LinksArray", "$", "linksArray", ")", "{", "Validator", "::", "checkMemberName", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "links", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "DuplicateException", "(", "'link with key \"'", ".", "$", "key", ".", "'\" already set'", ")", ";", "}", "$", "this", "->", "links", "[", "$", "key", "]", "=", "$", "linksArray", ";", "}" ]
@param string $key @param LinksArray $linksArray @throws DuplicateException if another link is already using that $key
[ "@param", "string", "$key", "@param", "LinksArray", "$linksArray" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/LinksObject.php#L127-L135
lode/jsonapi
src/objects/LinksObject.php
LinksObject.appendLinkObject
public function appendLinkObject($key, LinkObject $linkObject) { Validator::checkMemberName($key); if (isset($this->links[$key]) === false) { $this->addLinksArray($key, new LinksArray()); } elseif ($this->links[$key] instanceof LinksArray === false) { throw new DuplicateException('can not add to key "'.$key.'", it is not an array of links'); } $this->links[$key]->addLinkObject($linkObject); }
php
public function appendLinkObject($key, LinkObject $linkObject) { Validator::checkMemberName($key); if (isset($this->links[$key]) === false) { $this->addLinksArray($key, new LinksArray()); } elseif ($this->links[$key] instanceof LinksArray === false) { throw new DuplicateException('can not add to key "'.$key.'", it is not an array of links'); } $this->links[$key]->addLinkObject($linkObject); }
[ "public", "function", "appendLinkObject", "(", "$", "key", ",", "LinkObject", "$", "linkObject", ")", "{", "Validator", "::", "checkMemberName", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "links", "[", "$", "key", "]", ")", "===", "false", ")", "{", "$", "this", "->", "addLinksArray", "(", "$", "key", ",", "new", "LinksArray", "(", ")", ")", ";", "}", "elseif", "(", "$", "this", "->", "links", "[", "$", "key", "]", "instanceof", "LinksArray", "===", "false", ")", "{", "throw", "new", "DuplicateException", "(", "'can not add to key \"'", ".", "$", "key", ".", "'\", it is not an array of links'", ")", ";", "}", "$", "this", "->", "links", "[", "$", "key", "]", "->", "addLinkObject", "(", "$", "linkObject", ")", ";", "}" ]
@param string $key @param LinkObject $linkObject @throws DuplicateException if another link is already using that $key but is not an array
[ "@param", "string", "$key", "@param", "LinkObject", "$linkObject" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/objects/LinksObject.php#L143-L154
lode/jsonapi
src/DataDocument.php
DataDocument.addIncludedResourceObject
public function addIncludedResourceObject(ResourceObject ...$resourceObjects) { foreach ($resourceObjects as $resourceObject) { try { $this->validator->claimUsedResourceIdentifier($resourceObject); } catch (DuplicateException $e) { // silently skip duplicates continue; } $this->includedResources[] = $resourceObject; } }
php
public function addIncludedResourceObject(ResourceObject ...$resourceObjects) { foreach ($resourceObjects as $resourceObject) { try { $this->validator->claimUsedResourceIdentifier($resourceObject); } catch (DuplicateException $e) { // silently skip duplicates continue; } $this->includedResources[] = $resourceObject; } }
[ "public", "function", "addIncludedResourceObject", "(", "ResourceObject", "...", "$", "resourceObjects", ")", "{", "foreach", "(", "$", "resourceObjects", "as", "$", "resourceObject", ")", "{", "try", "{", "$", "this", "->", "validator", "->", "claimUsedResourceIdentifier", "(", "$", "resourceObject", ")", ";", "}", "catch", "(", "DuplicateException", "$", "e", ")", "{", "// silently skip duplicates", "continue", ";", "}", "$", "this", "->", "includedResources", "[", "]", "=", "$", "resourceObject", ";", "}", "}" ]
mainly used when an `included` query parameter is passed and resources are requested separate from what is standard for a response @param ResourceObject ...$resourceObjects
[ "mainly", "used", "when", "an", "included", "query", "parameter", "is", "passed", "and", "resources", "are", "requested", "separate", "from", "what", "is", "standard", "for", "a", "response" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/DataDocument.php#L39-L51
lode/jsonapi
examples/bootstrap_examples.php
ExampleVersionProfile.setVersion
public function setVersion(ResourceInterface $resource, $version) { if ($resource instanceof ResourceDocument) { $resource->addMeta($this->getKeyword('version'), $version, $level=Document::LEVEL_RESOURCE); } else { $resource->addMeta($this->getKeyword('version'), $version); } }
php
public function setVersion(ResourceInterface $resource, $version) { if ($resource instanceof ResourceDocument) { $resource->addMeta($this->getKeyword('version'), $version, $level=Document::LEVEL_RESOURCE); } else { $resource->addMeta($this->getKeyword('version'), $version); } }
[ "public", "function", "setVersion", "(", "ResourceInterface", "$", "resource", ",", "$", "version", ")", "{", "if", "(", "$", "resource", "instanceof", "ResourceDocument", ")", "{", "$", "resource", "->", "addMeta", "(", "$", "this", "->", "getKeyword", "(", "'version'", ")", ",", "$", "version", ",", "$", "level", "=", "Document", "::", "LEVEL_RESOURCE", ")", ";", "}", "else", "{", "$", "resource", "->", "addMeta", "(", "$", "this", "->", "getKeyword", "(", "'version'", ")", ",", "$", "version", ")", ";", "}", "}" ]
optionally helpers for the specific profile
[ "optionally", "helpers", "for", "the", "specific", "profile" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/examples/bootstrap_examples.php#L122-L129
lode/jsonapi
src/ResourceDocument.php
ResourceDocument.add
public function add($key, $value, array $options=[]) { $this->ensureResourceObject(); $this->resource->add($key, $value, $options); }
php
public function add($key, $value, array $options=[]) { $this->ensureResourceObject(); $this->resource->add($key, $value, $options); }
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "ensureResourceObject", "(", ")", ";", "$", "this", "->", "resource", "->", "add", "(", "$", "key", ",", "$", "value", ",", "$", "options", ")", ";", "}" ]
add key-value pairs to the resource's attributes @param string $key @param mixed $value objects will be converted using `get_object_vars()` @param array $options optional {@see ResourceDocument::$defaults}
[ "add", "key", "-", "value", "pairs", "to", "the", "resource", "s", "attributes" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/ResourceDocument.php#L87-L91
lode/jsonapi
src/ResourceDocument.php
ResourceDocument.addRelationship
public function addRelationship($key, $relation, array $links=[], array $meta=[], array $options=[]) { $this->ensureResourceObject(); $options = array_merge(self::$defaults, $options); $relationshipObject = $this->resource->addRelationship($key, $relation, $links, $meta); if ($options['includeContainedResources']) { $this->addIncludedResourceObject(...$relationshipObject->getNestedContainedResourceObjects()); } }
php
public function addRelationship($key, $relation, array $links=[], array $meta=[], array $options=[]) { $this->ensureResourceObject(); $options = array_merge(self::$defaults, $options); $relationshipObject = $this->resource->addRelationship($key, $relation, $links, $meta); if ($options['includeContainedResources']) { $this->addIncludedResourceObject(...$relationshipObject->getNestedContainedResourceObjects()); } }
[ "public", "function", "addRelationship", "(", "$", "key", ",", "$", "relation", ",", "array", "$", "links", "=", "[", "]", ",", "array", "$", "meta", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "ensureResourceObject", "(", ")", ";", "$", "options", "=", "array_merge", "(", "self", "::", "$", "defaults", ",", "$", "options", ")", ";", "$", "relationshipObject", "=", "$", "this", "->", "resource", "->", "addRelationship", "(", "$", "key", ",", "$", "relation", ",", "$", "links", ",", "$", "meta", ")", ";", "if", "(", "$", "options", "[", "'includeContainedResources'", "]", ")", "{", "$", "this", "->", "addIncludedResourceObject", "(", "...", "$", "relationshipObject", "->", "getNestedContainedResourceObjects", "(", ")", ")", ";", "}", "}" ]
add a relation to the resource adds included resources if found inside the relation, unless $options['includeContainedResources'] is set to false @param string $key @param mixed $relation ResourceInterface | ResourceInterface[] | CollectionDocument @param array $links optional @param array $meta optional @param array $options optional {@see ResourceDocument::$defaults}
[ "add", "a", "relation", "to", "the", "resource" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/ResourceDocument.php#L104-L114
lode/jsonapi
src/ResourceDocument.php
ResourceDocument.setSelfLink
public function setSelfLink($href, array $meta=[], $level=Document::LEVEL_RESOURCE) { $this->ensureResourceObject(); if ($level === Document::LEVEL_RESOURCE) { $this->resource->setSelfLink($href, $meta); } else { parent::setSelfLink($href, $meta, $level); } }
php
public function setSelfLink($href, array $meta=[], $level=Document::LEVEL_RESOURCE) { $this->ensureResourceObject(); if ($level === Document::LEVEL_RESOURCE) { $this->resource->setSelfLink($href, $meta); } else { parent::setSelfLink($href, $meta, $level); } }
[ "public", "function", "setSelfLink", "(", "$", "href", ",", "array", "$", "meta", "=", "[", "]", ",", "$", "level", "=", "Document", "::", "LEVEL_RESOURCE", ")", "{", "$", "this", "->", "ensureResourceObject", "(", ")", ";", "if", "(", "$", "level", "===", "Document", "::", "LEVEL_RESOURCE", ")", "{", "$", "this", "->", "resource", "->", "setSelfLink", "(", "$", "href", ",", "$", "meta", ")", ";", "}", "else", "{", "parent", "::", "setSelfLink", "(", "$", "href", ",", "$", "meta", ",", "$", "level", ")", ";", "}", "}" ]
set the self link on the resource @param string $href @param array $meta optional
[ "set", "the", "self", "link", "on", "the", "resource" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/ResourceDocument.php#L139-L148
lode/jsonapi
src/ResourceDocument.php
ResourceDocument.addRelationshipObject
public function addRelationshipObject($key, RelationshipObject $relationshipObject, array $options=[]) { $this->ensureResourceObject(); $options = array_merge(self::$defaults, $options); $this->resource->addRelationshipObject($key, $relationshipObject); if ($options['includeContainedResources']) { $this->addIncludedResourceObject(...$relationshipObject->getNestedContainedResourceObjects()); } }
php
public function addRelationshipObject($key, RelationshipObject $relationshipObject, array $options=[]) { $this->ensureResourceObject(); $options = array_merge(self::$defaults, $options); $this->resource->addRelationshipObject($key, $relationshipObject); if ($options['includeContainedResources']) { $this->addIncludedResourceObject(...$relationshipObject->getNestedContainedResourceObjects()); } }
[ "public", "function", "addRelationshipObject", "(", "$", "key", ",", "RelationshipObject", "$", "relationshipObject", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "ensureResourceObject", "(", ")", ";", "$", "options", "=", "array_merge", "(", "self", "::", "$", "defaults", ",", "$", "options", ")", ";", "$", "this", "->", "resource", "->", "addRelationshipObject", "(", "$", "key", ",", "$", "relationshipObject", ")", ";", "if", "(", "$", "options", "[", "'includeContainedResources'", "]", ")", "{", "$", "this", "->", "addIncludedResourceObject", "(", "...", "$", "relationshipObject", "->", "getNestedContainedResourceObjects", "(", ")", ")", ";", "}", "}" ]
add a RelationshipObject to the resource adds included resources if found inside the RelationshipObject, unless $options['includeContainedResources'] is set to false @param string $key @param RelationshipObject $relationshipObject @param array $options optional {@see ResourceDocument::$defaults}
[ "add", "a", "RelationshipObject", "to", "the", "resource" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/ResourceDocument.php#L201-L211
lode/jsonapi
src/ResourceDocument.php
ResourceDocument.setRelationshipsObject
public function setRelationshipsObject(RelationshipsObject $relationshipsObject, array $options=[]) { $this->ensureResourceObject(); $options = array_merge(self::$defaults, $options); $this->resource->setRelationshipsObject($relationshipsObject); if ($options['includeContainedResources']) { $this->addIncludedResourceObject(...$relationshipsObject->getNestedContainedResourceObjects()); } }
php
public function setRelationshipsObject(RelationshipsObject $relationshipsObject, array $options=[]) { $this->ensureResourceObject(); $options = array_merge(self::$defaults, $options); $this->resource->setRelationshipsObject($relationshipsObject); if ($options['includeContainedResources']) { $this->addIncludedResourceObject(...$relationshipsObject->getNestedContainedResourceObjects()); } }
[ "public", "function", "setRelationshipsObject", "(", "RelationshipsObject", "$", "relationshipsObject", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "ensureResourceObject", "(", ")", ";", "$", "options", "=", "array_merge", "(", "self", "::", "$", "defaults", ",", "$", "options", ")", ";", "$", "this", "->", "resource", "->", "setRelationshipsObject", "(", "$", "relationshipsObject", ")", ";", "if", "(", "$", "options", "[", "'includeContainedResources'", "]", ")", "{", "$", "this", "->", "addIncludedResourceObject", "(", "...", "$", "relationshipsObject", "->", "getNestedContainedResourceObjects", "(", ")", ")", ";", "}", "}" ]
set the RelationshipsObject to the resource adds included resources if found inside the RelationshipObjects inside the RelationshipsObject, unless $options['includeContainedResources'] is set to false @param RelationshipsObject $relationshipsObject @param array $options optional {@see ResourceDocument::$defaults}
[ "set", "the", "RelationshipsObject", "to", "the", "resource" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/ResourceDocument.php#L221-L231
lode/jsonapi
src/ResourceDocument.php
ResourceDocument.setPrimaryResource
public function setPrimaryResource(ResourceInterface $resource, array $options=[]) { if ($resource instanceof ResourceDocument) { throw new InputException('does not make sense to set a document inside a document, use ResourceObject or ResourceIdentifierObject instead'); } $options = array_merge(self::$defaults, $options); $this->resource = $resource; if ($options['includeContainedResources'] && $this->resource instanceof RecursiveResourceContainerInterface) { $this->addIncludedResourceObject(...$this->resource->getNestedContainedResourceObjects()); } }
php
public function setPrimaryResource(ResourceInterface $resource, array $options=[]) { if ($resource instanceof ResourceDocument) { throw new InputException('does not make sense to set a document inside a document, use ResourceObject or ResourceIdentifierObject instead'); } $options = array_merge(self::$defaults, $options); $this->resource = $resource; if ($options['includeContainedResources'] && $this->resource instanceof RecursiveResourceContainerInterface) { $this->addIncludedResourceObject(...$this->resource->getNestedContainedResourceObjects()); } }
[ "public", "function", "setPrimaryResource", "(", "ResourceInterface", "$", "resource", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "resource", "instanceof", "ResourceDocument", ")", "{", "throw", "new", "InputException", "(", "'does not make sense to set a document inside a document, use ResourceObject or ResourceIdentifierObject instead'", ")", ";", "}", "$", "options", "=", "array_merge", "(", "self", "::", "$", "defaults", ",", "$", "options", ")", ";", "$", "this", "->", "resource", "=", "$", "resource", ";", "if", "(", "$", "options", "[", "'includeContainedResources'", "]", "&&", "$", "this", "->", "resource", "instanceof", "RecursiveResourceContainerInterface", ")", "{", "$", "this", "->", "addIncludedResourceObject", "(", "...", "$", "this", "->", "resource", "->", "getNestedContainedResourceObjects", "(", ")", ")", ";", "}", "}" ]
overwrites the primary resource adds included resources if found inside the resource's relationships, unless $options['includeContainedResources'] is set to false @param ResourceInterface $resource @param array $options optional {@see ResourceDocument::$defaults} @throws InputException if the $resource is a ResourceDocument itself
[ "overwrites", "the", "primary", "resource" ]
train
https://github.com/lode/jsonapi/blob/6a96d5e4164338e3bd025058a56b40d53af5b3d1/src/ResourceDocument.php#L247-L259
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.listServers
function listServers($count = 100, $offset = 0, $name = NULL) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; $query['name'] = $name; return new DynamicResponseModel($this->processRestRequest('GET', '/servers/', $query)); }
php
function listServers($count = 100, $offset = 0, $name = NULL) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; $query['name'] = $name; return new DynamicResponseModel($this->processRestRequest('GET', '/servers/', $query)); }
[ "function", "listServers", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ",", "$", "name", "=", "NULL", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "$", "query", "[", "'name'", "]", "=", "$", "name", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/servers/'", ",", "$", "query", ")", ")", ";", "}" ]
Get a list of all servers configured on the account. @param integer $count The number of servers to retrieve in the request, defaults to 100. @param integer $offset The number of servers to "skip" when paging through lists of servers. @param string $name Filter by server name. @return DynamicResponseModel
[ "Get", "a", "list", "of", "all", "servers", "configured", "on", "the", "account", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L46-L53
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.editServer
function editServer($id, $name = NULL, $color = NULL, $rawEmailEnabled = NULL, $smtpApiActivated = NULL, $inboundHookUrl = NULL, $bounceHookUrl = NULL, $openHookUrl = NULL, $postFirstOpenOnly = NULL, $trackOpens = NULL, $inboundDomain = NULL, $inboundSpamThreshold = NULL, $trackLinks = NULL, $clickHookUrl = NULL, $deliveryHookUrl = NULL, $enableSmtpApiErrorHooks = NULL) { $body = array(); $body['name'] = $name; $body['color'] = $color; $body['rawEmailEnabled'] = $rawEmailEnabled; $body['smtpApiActivated'] = $smtpApiActivated; $body['inboundHookUrl'] = $inboundHookUrl; $body['bounceHookUrl'] = $bounceHookUrl; $body['openHookUrl'] = $openHookUrl; $body['postFirstOpenOnly'] = $postFirstOpenOnly; $body['trackOpens'] = $trackOpens; $body['inboundDomain'] = $inboundDomain; $body['inboundSpamThreshold'] = $inboundSpamThreshold; $body['trackLinks'] = $trackLinks; $body["ClickHookUrl"] = $clickHookUrl; $body["DeliveryHookUrl"] = $deliveryHookUrl; $body["EnableSmtpApiErrorHooks"] = $enableSmtpApiErrorHooks; $response = new DynamicResponseModel($this->processRestRequest('PUT', "/servers/$id", $body)); $response["ID"] = $id; return $response; }
php
function editServer($id, $name = NULL, $color = NULL, $rawEmailEnabled = NULL, $smtpApiActivated = NULL, $inboundHookUrl = NULL, $bounceHookUrl = NULL, $openHookUrl = NULL, $postFirstOpenOnly = NULL, $trackOpens = NULL, $inboundDomain = NULL, $inboundSpamThreshold = NULL, $trackLinks = NULL, $clickHookUrl = NULL, $deliveryHookUrl = NULL, $enableSmtpApiErrorHooks = NULL) { $body = array(); $body['name'] = $name; $body['color'] = $color; $body['rawEmailEnabled'] = $rawEmailEnabled; $body['smtpApiActivated'] = $smtpApiActivated; $body['inboundHookUrl'] = $inboundHookUrl; $body['bounceHookUrl'] = $bounceHookUrl; $body['openHookUrl'] = $openHookUrl; $body['postFirstOpenOnly'] = $postFirstOpenOnly; $body['trackOpens'] = $trackOpens; $body['inboundDomain'] = $inboundDomain; $body['inboundSpamThreshold'] = $inboundSpamThreshold; $body['trackLinks'] = $trackLinks; $body["ClickHookUrl"] = $clickHookUrl; $body["DeliveryHookUrl"] = $deliveryHookUrl; $body["EnableSmtpApiErrorHooks"] = $enableSmtpApiErrorHooks; $response = new DynamicResponseModel($this->processRestRequest('PUT', "/servers/$id", $body)); $response["ID"] = $id; return $response; }
[ "function", "editServer", "(", "$", "id", ",", "$", "name", "=", "NULL", ",", "$", "color", "=", "NULL", ",", "$", "rawEmailEnabled", "=", "NULL", ",", "$", "smtpApiActivated", "=", "NULL", ",", "$", "inboundHookUrl", "=", "NULL", ",", "$", "bounceHookUrl", "=", "NULL", ",", "$", "openHookUrl", "=", "NULL", ",", "$", "postFirstOpenOnly", "=", "NULL", ",", "$", "trackOpens", "=", "NULL", ",", "$", "inboundDomain", "=", "NULL", ",", "$", "inboundSpamThreshold", "=", "NULL", ",", "$", "trackLinks", "=", "NULL", ",", "$", "clickHookUrl", "=", "NULL", ",", "$", "deliveryHookUrl", "=", "NULL", ",", "$", "enableSmtpApiErrorHooks", "=", "NULL", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "'name'", "]", "=", "$", "name", ";", "$", "body", "[", "'color'", "]", "=", "$", "color", ";", "$", "body", "[", "'rawEmailEnabled'", "]", "=", "$", "rawEmailEnabled", ";", "$", "body", "[", "'smtpApiActivated'", "]", "=", "$", "smtpApiActivated", ";", "$", "body", "[", "'inboundHookUrl'", "]", "=", "$", "inboundHookUrl", ";", "$", "body", "[", "'bounceHookUrl'", "]", "=", "$", "bounceHookUrl", ";", "$", "body", "[", "'openHookUrl'", "]", "=", "$", "openHookUrl", ";", "$", "body", "[", "'postFirstOpenOnly'", "]", "=", "$", "postFirstOpenOnly", ";", "$", "body", "[", "'trackOpens'", "]", "=", "$", "trackOpens", ";", "$", "body", "[", "'inboundDomain'", "]", "=", "$", "inboundDomain", ";", "$", "body", "[", "'inboundSpamThreshold'", "]", "=", "$", "inboundSpamThreshold", ";", "$", "body", "[", "'trackLinks'", "]", "=", "$", "trackLinks", ";", "$", "body", "[", "\"ClickHookUrl\"", "]", "=", "$", "clickHookUrl", ";", "$", "body", "[", "\"DeliveryHookUrl\"", "]", "=", "$", "deliveryHookUrl", ";", "$", "body", "[", "\"EnableSmtpApiErrorHooks\"", "]", "=", "$", "enableSmtpApiErrorHooks", ";", "$", "response", "=", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'PUT'", ",", "\"/servers/$id\"", ",", "$", "body", ")", ")", ";", "$", "response", "[", "\"ID\"", "]", "=", "$", "id", ";", "return", "$", "response", ";", "}" ]
Modify an existing Server. Any parameters passed with NULL will be ignored (their existing values will not be modified). @param integer $id The ID of the Server we wish to modify. @param string $name Set the name of the server. @param string $color Set the color for the server in the Postmark WebUI (must be: 'purple', 'blue', 'turqoise', 'green', 'red', 'yellow', or 'grey') @param bool $rawEmailEnabled Enable raw email to be sent with inbound. @param bool $smtpApiActivated Specifies whether or not SMTP is enabled on this server. @param string $inboundHookUrl URL to POST to everytime an inbound event occurs. @param string $bounceHookUrl URL to POST to everytime a bounce event occurs. @param string $openHookUrl URL to POST to everytime an open event occurs. @param bool $postFirstOpenOnly If set to true, only the first open by a particular recipient will initiate the open webhook. Any subsequent opens of the same email by the same recipient will not initiate the webhook. @param bool $trackOpens Indicates if all emails being sent through this server have open tracking enabled. @param string $inboundDomain Inbound domain for MX setup. @param integer $inboundSpamThreshold The maximum spam score for an inbound message before it's blocked (range from 0-30). @param string $trackLinks Indicates if all emails being sent through this server have link tracking enabled. @param string $clickHookUrl URL to POST to everytime an click event occurs. @param string $deliveryHookUrl URL to POST to everytime an click event occurs. @param string $enableSmtpApiErrorHooks Specifies whether or not SMTP API Errors will be included with bounce webhooks. @return DynamicResponseModel
[ "Modify", "an", "existing", "Server", ".", "Any", "parameters", "passed", "with", "NULL", "will", "be", "ignored", "(", "their", "existing", "values", "will", "not", "be", "modified", ")", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L89-L116
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.listSenderSignatures
function listSenderSignatures($count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', '/senders/', $query)); }
php
function listSenderSignatures($count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', '/senders/', $query)); }
[ "function", "listSenderSignatures", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/senders/'", ",", "$", "query", ")", ")", ";", "}" ]
Get a "page" of Sender Signatures. @param integer $count The number of Sender Signatures to retrieve with this request. param integer $offset The number of Sender Signatures to 'skip' when 'paging' through them. @return DynamicResponseModel
[ "Get", "a", "page", "of", "Sender", "Signatures", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L173-L180
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.createSenderSignature
function createSenderSignature($fromEmail, $name, $replyToEmail = NULL, $returnPathDomain = NULL) { $body = array(); $body['fromEmail'] = $fromEmail; $body['name'] = $name; $body['replyToEmail'] = $replyToEmail; $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('POST', '/senders/', $body)); }
php
function createSenderSignature($fromEmail, $name, $replyToEmail = NULL, $returnPathDomain = NULL) { $body = array(); $body['fromEmail'] = $fromEmail; $body['name'] = $name; $body['replyToEmail'] = $replyToEmail; $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('POST', '/senders/', $body)); }
[ "function", "createSenderSignature", "(", "$", "fromEmail", ",", "$", "name", ",", "$", "replyToEmail", "=", "NULL", ",", "$", "returnPathDomain", "=", "NULL", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "'fromEmail'", "]", "=", "$", "fromEmail", ";", "$", "body", "[", "'name'", "]", "=", "$", "name", ";", "$", "body", "[", "'replyToEmail'", "]", "=", "$", "replyToEmail", ";", "$", "body", "[", "'returnPathDomain'", "]", "=", "$", "returnPathDomain", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "'/senders/'", ",", "$", "body", ")", ")", ";", "}" ]
Create a new Sender Signature for a given email address. Note that you will need to "verify" this Sender Signature by following a link that will be emailed to the "fromEmail" address specified when calling this method. @param string $fromEmail The email address for the Sender Signature @param string $name The name of the Sender Signature. @param string $replyToEmail The reply-to email address for the Sender Signature. @param string $returnPathDomain The custom Return-Path domain for the Sender Signature. @return DynamicResponseModel
[ "Create", "a", "new", "Sender", "Signature", "for", "a", "given", "email", "address", ".", "Note", "that", "you", "will", "need", "to", "verify", "this", "Sender", "Signature", "by", "following", "a", "link", "that", "will", "be", "emailed", "to", "the", "fromEmail", "address", "specified", "when", "calling", "this", "method", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L203-L212
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.editSenderSignature
function editSenderSignature($id, $name = NULL, $replyToEmail = NULL, $returnPathDomain = NULL) { $body = array(); $body['name'] = $name; $body['replyToEmail'] = $replyToEmail; $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('PUT', "/senders/$id", $body)); }
php
function editSenderSignature($id, $name = NULL, $replyToEmail = NULL, $returnPathDomain = NULL) { $body = array(); $body['name'] = $name; $body['replyToEmail'] = $replyToEmail; $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('PUT', "/senders/$id", $body)); }
[ "function", "editSenderSignature", "(", "$", "id", ",", "$", "name", "=", "NULL", ",", "$", "replyToEmail", "=", "NULL", ",", "$", "returnPathDomain", "=", "NULL", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "'name'", "]", "=", "$", "name", ";", "$", "body", "[", "'replyToEmail'", "]", "=", "$", "replyToEmail", ";", "$", "body", "[", "'returnPathDomain'", "]", "=", "$", "returnPathDomain", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'PUT'", ",", "\"/senders/$id\"", ",", "$", "body", ")", ")", ";", "}" ]
Alter the defaults for a Sender Signature. @param integer $id The ID for the Sender Signature we wish to modify. @param string $name The name of the Sender Signature. @param string $replyToEmail The reply-to email address for the Sender Signature. @param string $returnPathDomain The custom Return-Path domain for the Sender Signature. @return DynamicResponseModel
[ "Alter", "the", "defaults", "for", "a", "Sender", "Signature", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L223-L231
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.listDomains
function listDomains($count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', '/domains/', $query)); }
php
function listDomains($count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', '/domains/', $query)); }
[ "function", "listDomains", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/domains/'", ",", "$", "query", ")", ")", ";", "}" ]
Get a "page" of Domains. @param integer $count The number of Domains to retrieve with this request. param integer $offset The number of Domains to 'skip' when 'paging' through them. @return DynamicResponseModel
[ "Get", "a", "page", "of", "Domains", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L287-L294
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.createDomain
function createDomain($name, $returnPathDomain = NULL) { $body = array(); $body['name'] = $name; $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('POST', '/domains/', $body)); }
php
function createDomain($name, $returnPathDomain = NULL) { $body = array(); $body['name'] = $name; $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('POST', '/domains/', $body)); }
[ "function", "createDomain", "(", "$", "name", ",", "$", "returnPathDomain", "=", "NULL", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "'name'", "]", "=", "$", "name", ";", "$", "body", "[", "'returnPathDomain'", "]", "=", "$", "returnPathDomain", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "'/domains/'", ",", "$", "body", ")", ")", ";", "}" ]
Create a new Domain with the given Name. @param string $name The name of the Domain. @param string $returnPathDomain The custom Return-Path domain for the Sender Signature. @return DynamicResponseModel
[ "Create", "a", "new", "Domain", "with", "the", "given", "Name", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L314-L320
wildbit/postmark-php
src/Postmark/PostmarkAdminClient.php
PostmarkAdminClient.editDomain
function editDomain($id, $returnPathDomain = NULL) { $body = array(); $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('PUT', "/domains/$id", $body)); }
php
function editDomain($id, $returnPathDomain = NULL) { $body = array(); $body['returnPathDomain'] = $returnPathDomain; return new DynamicResponseModel($this->processRestRequest('PUT', "/domains/$id", $body)); }
[ "function", "editDomain", "(", "$", "id", ",", "$", "returnPathDomain", "=", "NULL", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "'returnPathDomain'", "]", "=", "$", "returnPathDomain", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'PUT'", ",", "\"/domains/$id\"", ",", "$", "body", ")", ")", ";", "}" ]
Alter the properties of a Domain. @param integer $id The ID for the Domain we wish to modify. @param string $returnPathDomain The custom Return-Path domain for the Domain. @return DynamicResponseModel
[ "Alter", "the", "properties", "of", "a", "Domain", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkAdminClient.php#L329-L335
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.sendEmail
function sendEmail($from, $to, $subject, $htmlBody = NULL, $textBody = NULL, $tag = NULL, $trackOpens = true, $replyTo = NULL, $cc = NULL, $bcc = NULL, $headers = NULL, $attachments = NULL, $trackLinks = NULL, $metadata = NULL) { $body = array(); $body['From'] = $from; $body['To'] = $to; $body['Cc'] = $cc; $body['Bcc'] = $bcc; $body['Subject'] = $subject; $body['HtmlBody'] = $htmlBody; $body['TextBody'] = $textBody; $body['Tag'] = $tag; $body['ReplyTo'] = $replyTo; $body['Headers'] = $this->fixHeaders($headers); $body['TrackOpens'] = $trackOpens; $body['Attachments'] = $attachments; $body['Metadata'] = $metadata; // Since this parameter can override a per-server setting // we have to check whether it was actually set. // And only include it in the API call if that is the case. if ($trackLinks !== NULL) { $body['TrackLinks'] = $trackLinks; } return new DynamicResponseModel($this->processRestRequest('POST', '/email', $body)); }
php
function sendEmail($from, $to, $subject, $htmlBody = NULL, $textBody = NULL, $tag = NULL, $trackOpens = true, $replyTo = NULL, $cc = NULL, $bcc = NULL, $headers = NULL, $attachments = NULL, $trackLinks = NULL, $metadata = NULL) { $body = array(); $body['From'] = $from; $body['To'] = $to; $body['Cc'] = $cc; $body['Bcc'] = $bcc; $body['Subject'] = $subject; $body['HtmlBody'] = $htmlBody; $body['TextBody'] = $textBody; $body['Tag'] = $tag; $body['ReplyTo'] = $replyTo; $body['Headers'] = $this->fixHeaders($headers); $body['TrackOpens'] = $trackOpens; $body['Attachments'] = $attachments; $body['Metadata'] = $metadata; // Since this parameter can override a per-server setting // we have to check whether it was actually set. // And only include it in the API call if that is the case. if ($trackLinks !== NULL) { $body['TrackLinks'] = $trackLinks; } return new DynamicResponseModel($this->processRestRequest('POST', '/email', $body)); }
[ "function", "sendEmail", "(", "$", "from", ",", "$", "to", ",", "$", "subject", ",", "$", "htmlBody", "=", "NULL", ",", "$", "textBody", "=", "NULL", ",", "$", "tag", "=", "NULL", ",", "$", "trackOpens", "=", "true", ",", "$", "replyTo", "=", "NULL", ",", "$", "cc", "=", "NULL", ",", "$", "bcc", "=", "NULL", ",", "$", "headers", "=", "NULL", ",", "$", "attachments", "=", "NULL", ",", "$", "trackLinks", "=", "NULL", ",", "$", "metadata", "=", "NULL", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "'From'", "]", "=", "$", "from", ";", "$", "body", "[", "'To'", "]", "=", "$", "to", ";", "$", "body", "[", "'Cc'", "]", "=", "$", "cc", ";", "$", "body", "[", "'Bcc'", "]", "=", "$", "bcc", ";", "$", "body", "[", "'Subject'", "]", "=", "$", "subject", ";", "$", "body", "[", "'HtmlBody'", "]", "=", "$", "htmlBody", ";", "$", "body", "[", "'TextBody'", "]", "=", "$", "textBody", ";", "$", "body", "[", "'Tag'", "]", "=", "$", "tag", ";", "$", "body", "[", "'ReplyTo'", "]", "=", "$", "replyTo", ";", "$", "body", "[", "'Headers'", "]", "=", "$", "this", "->", "fixHeaders", "(", "$", "headers", ")", ";", "$", "body", "[", "'TrackOpens'", "]", "=", "$", "trackOpens", ";", "$", "body", "[", "'Attachments'", "]", "=", "$", "attachments", ";", "$", "body", "[", "'Metadata'", "]", "=", "$", "metadata", ";", "// Since this parameter can override a per-server setting", "// we have to check whether it was actually set.", "// And only include it in the API call if that is the case.", "if", "(", "$", "trackLinks", "!==", "NULL", ")", "{", "$", "body", "[", "'TrackLinks'", "]", "=", "$", "trackLinks", ";", "}", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "'/email'", ",", "$", "body", ")", ")", ";", "}" ]
Send an email. @param string $from The sender of the email. (Your account must have an associated Sender Signature for the address used.) @param string $to The recipient of the email. @param string $subject The subject of the email. @param string $htmlBody The HTML content of the message, optional if Text Body is specified. @param string $textBody The text content of the message, optional if HTML Body is specified. @param string $tag A tag associated with this message, useful for classifying sent messages. @param boolean $trackOpens True if you want Postmark to track opens of HTML emails. @param string $replyTo Reply to email address. @param string $cc Carbon Copy recipients, comma-separated @param string $bcc Blind Carbon Copy recipients, comma-separated. @param array $headers Headers to be included with the sent email message. @param array $attachments An array of PostmarkAttachment objects. @param string $trackLinks Can be any of "None", "HtmlAndText", "HtmlOnly", "TextOnly" to enable link tracking. @param array $metadata Add metadata to the message. The metadata is an associative array, and values will be evaluated as strings by Postmark. @return DynamicResponseModel
[ "Send", "an", "email", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L45-L72
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.sendEmailWithTemplate
function sendEmailWithTemplate($from, $to, $templateId, $templateModel, $inlineCss = true, $tag = NULL, $trackOpens = true, $replyTo = NULL, $cc = NULL, $bcc = NULL, $headers = NULL, $attachments = NULL, $trackLinks = NULL, $metadata = NULL) { $body = array(); $body['From'] = $from; $body['To'] = $to; $body['Cc'] = $cc; $body['Bcc'] = $bcc; $body['Tag'] = $tag; $body['ReplyTo'] = $replyTo; $body['Headers'] = $this->fixHeaders($headers); $body['TrackOpens'] = $trackOpens; $body['Attachments'] = $attachments; $body['TemplateModel'] = $templateModel; $body['TemplateId'] = $templateId; $body['InlineCss'] = $inlineCss; $body['Metadata'] = $metadata; // Since this parameter can override a per-server setting // we have to check whether it was actually set. // And only include it in the API call if that is the case. if ($trackLinks !== NULL) { $body['TrackLinks'] = $trackLinks; } return new DynamicResponseModel($this->processRestRequest('POST', '/email/withTemplate', $body)); }
php
function sendEmailWithTemplate($from, $to, $templateId, $templateModel, $inlineCss = true, $tag = NULL, $trackOpens = true, $replyTo = NULL, $cc = NULL, $bcc = NULL, $headers = NULL, $attachments = NULL, $trackLinks = NULL, $metadata = NULL) { $body = array(); $body['From'] = $from; $body['To'] = $to; $body['Cc'] = $cc; $body['Bcc'] = $bcc; $body['Tag'] = $tag; $body['ReplyTo'] = $replyTo; $body['Headers'] = $this->fixHeaders($headers); $body['TrackOpens'] = $trackOpens; $body['Attachments'] = $attachments; $body['TemplateModel'] = $templateModel; $body['TemplateId'] = $templateId; $body['InlineCss'] = $inlineCss; $body['Metadata'] = $metadata; // Since this parameter can override a per-server setting // we have to check whether it was actually set. // And only include it in the API call if that is the case. if ($trackLinks !== NULL) { $body['TrackLinks'] = $trackLinks; } return new DynamicResponseModel($this->processRestRequest('POST', '/email/withTemplate', $body)); }
[ "function", "sendEmailWithTemplate", "(", "$", "from", ",", "$", "to", ",", "$", "templateId", ",", "$", "templateModel", ",", "$", "inlineCss", "=", "true", ",", "$", "tag", "=", "NULL", ",", "$", "trackOpens", "=", "true", ",", "$", "replyTo", "=", "NULL", ",", "$", "cc", "=", "NULL", ",", "$", "bcc", "=", "NULL", ",", "$", "headers", "=", "NULL", ",", "$", "attachments", "=", "NULL", ",", "$", "trackLinks", "=", "NULL", ",", "$", "metadata", "=", "NULL", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "'From'", "]", "=", "$", "from", ";", "$", "body", "[", "'To'", "]", "=", "$", "to", ";", "$", "body", "[", "'Cc'", "]", "=", "$", "cc", ";", "$", "body", "[", "'Bcc'", "]", "=", "$", "bcc", ";", "$", "body", "[", "'Tag'", "]", "=", "$", "tag", ";", "$", "body", "[", "'ReplyTo'", "]", "=", "$", "replyTo", ";", "$", "body", "[", "'Headers'", "]", "=", "$", "this", "->", "fixHeaders", "(", "$", "headers", ")", ";", "$", "body", "[", "'TrackOpens'", "]", "=", "$", "trackOpens", ";", "$", "body", "[", "'Attachments'", "]", "=", "$", "attachments", ";", "$", "body", "[", "'TemplateModel'", "]", "=", "$", "templateModel", ";", "$", "body", "[", "'TemplateId'", "]", "=", "$", "templateId", ";", "$", "body", "[", "'InlineCss'", "]", "=", "$", "inlineCss", ";", "$", "body", "[", "'Metadata'", "]", "=", "$", "metadata", ";", "// Since this parameter can override a per-server setting", "// we have to check whether it was actually set.", "// And only include it in the API call if that is the case.", "if", "(", "$", "trackLinks", "!==", "NULL", ")", "{", "$", "body", "[", "'TrackLinks'", "]", "=", "$", "trackLinks", ";", "}", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "'/email/withTemplate'", ",", "$", "body", ")", ")", ";", "}" ]
Send an email using a template. @param string $from The sender of the email. (Your account must have an associated Sender Signature for the address used.) @param string $to The recipient of the email. @param integer $templateId The ID of the template to use to generate the content of this message. @param array $templateModel The values to combine with the Templated content. @param boolean $inlineCss If the template contains an HTMLBody, CSS is automatically inlined, you may opt-out of this by passing 'false' for this parameter. @param string $tag A tag associated with this message, useful for classifying sent messages. @param boolean $trackOpens True if you want Postmark to track opens of HTML emails. @param string $replyTo Reply to email address. @param string $cc Carbon Copy recipients, comma-separated @param string $bcc Blind Carbon Copy recipients, comma-separated. @param array $headers Headers to be included with the sent email message. @param array $attachments An array of PostmarkAttachment objects. @param string $trackLinks Can be any of "None", "HtmlAndText", "HtmlOnly", "TextOnly" to enable link tracking. @param array $metadata Add metadata to the message. The metadata is an associative array , and values will be evaluated as strings by Postmark. @return DynamicResponseModel
[ "Send", "an", "email", "using", "a", "template", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L93-L123
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.fixHeaders
private function fixHeaders($headers) { $retval = NULL; if ($headers != NULL) { $retval = array(); $index = 0; foreach ($headers as $key => $value) { $retval[$index] = array('Name' => $key, 'Value' => $value); $index++; } } return $retval; }
php
private function fixHeaders($headers) { $retval = NULL; if ($headers != NULL) { $retval = array(); $index = 0; foreach ($headers as $key => $value) { $retval[$index] = array('Name' => $key, 'Value' => $value); $index++; } } return $retval; }
[ "private", "function", "fixHeaders", "(", "$", "headers", ")", "{", "$", "retval", "=", "NULL", ";", "if", "(", "$", "headers", "!=", "NULL", ")", "{", "$", "retval", "=", "array", "(", ")", ";", "$", "index", "=", "0", ";", "foreach", "(", "$", "headers", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "retval", "[", "$", "index", "]", "=", "array", "(", "'Name'", "=>", "$", "key", ",", "'Value'", "=>", "$", "value", ")", ";", "$", "index", "++", ";", "}", "}", "return", "$", "retval", ";", "}" ]
The Postmark API wants an Array of Key-Value pairs, not a dictionary object, therefore, we need to wrap the elements in an array.
[ "The", "Postmark", "API", "wants", "an", "Array", "of", "Key", "-", "Value", "pairs", "not", "a", "dictionary", "object", "therefore", "we", "need", "to", "wrap", "the", "elements", "in", "an", "array", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L129-L140
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.sendEmailBatch
function sendEmailBatch($emailBatch = array()) { $final = array(); foreach ($emailBatch as $email) { foreach ($email as $emailIdx => $emailValue) { if (strtolower($emailIdx) == 'headers') { $email[$emailIdx] = $this->fixHeaders($emailValue); } } array_push($final, $email); } return new DynamicResponseModel($this->processRestRequest('POST', '/email/batch', $final)); }
php
function sendEmailBatch($emailBatch = array()) { $final = array(); foreach ($emailBatch as $email) { foreach ($email as $emailIdx => $emailValue) { if (strtolower($emailIdx) == 'headers') { $email[$emailIdx] = $this->fixHeaders($emailValue); } } array_push($final, $email); } return new DynamicResponseModel($this->processRestRequest('POST', '/email/batch', $final)); }
[ "function", "sendEmailBatch", "(", "$", "emailBatch", "=", "array", "(", ")", ")", "{", "$", "final", "=", "array", "(", ")", ";", "foreach", "(", "$", "emailBatch", "as", "$", "email", ")", "{", "foreach", "(", "$", "email", "as", "$", "emailIdx", "=>", "$", "emailValue", ")", "{", "if", "(", "strtolower", "(", "$", "emailIdx", ")", "==", "'headers'", ")", "{", "$", "email", "[", "$", "emailIdx", "]", "=", "$", "this", "->", "fixHeaders", "(", "$", "emailValue", ")", ";", "}", "}", "array_push", "(", "$", "final", ",", "$", "email", ")", ";", "}", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "'/email/batch'", ",", "$", "final", ")", ")", ";", "}" ]
Send multiple emails as a batch Each email is an associative array of values, but note that the 'Attachments' key must be an array of 'PostmarkAttachment' objects if you intend to send attachments with an email. @param array $emailBatch An array of emails to be sent in one batch. @return DynamicResponseModel
[ "Send", "multiple", "emails", "as", "a", "batch" ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L153-L167
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.getBounces
function getBounces($count = 100, $offset = 0, $type = NULL, $inactive = NULL, $emailFilter = NULL, $tag = NULL, $messageID = NULL, $fromdate = NULL, $todate = NULL) { $query = array(); $query['type'] = $type; $query['inactive'] = $inactive; $query['emailFilter'] = $emailFilter; $query['tag'] = $tag; $query['messageID'] = $messageID; $query['count'] = $count; $query['offset'] = $offset; $query['fromdate'] = $fromdate; $query['todate'] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/bounces', $query)); }
php
function getBounces($count = 100, $offset = 0, $type = NULL, $inactive = NULL, $emailFilter = NULL, $tag = NULL, $messageID = NULL, $fromdate = NULL, $todate = NULL) { $query = array(); $query['type'] = $type; $query['inactive'] = $inactive; $query['emailFilter'] = $emailFilter; $query['tag'] = $tag; $query['messageID'] = $messageID; $query['count'] = $count; $query['offset'] = $offset; $query['fromdate'] = $fromdate; $query['todate'] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/bounces', $query)); }
[ "function", "getBounces", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ",", "$", "type", "=", "NULL", ",", "$", "inactive", "=", "NULL", ",", "$", "emailFilter", "=", "NULL", ",", "$", "tag", "=", "NULL", ",", "$", "messageID", "=", "NULL", ",", "$", "fromdate", "=", "NULL", ",", "$", "todate", "=", "NULL", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'type'", "]", "=", "$", "type", ";", "$", "query", "[", "'inactive'", "]", "=", "$", "inactive", ";", "$", "query", "[", "'emailFilter'", "]", "=", "$", "emailFilter", ";", "$", "query", "[", "'tag'", "]", "=", "$", "tag", ";", "$", "query", "[", "'messageID'", "]", "=", "$", "messageID", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "$", "query", "[", "'fromdate'", "]", "=", "$", "fromdate", ";", "$", "query", "[", "'todate'", "]", "=", "$", "todate", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/bounces'", ",", "$", "query", ")", ")", ";", "}" ]
Get a batch of bounces to be processed. @param integer $count Number of bounces to retrieve @param integer $offset How many bounces to skip (when paging through bounces.) @param string $type The bounce type. (see http://developer.postmarkapp.com/developer-api-bounce.html#bounce-types) @param bool $inactive Specifies if the bounce caused Postmark to deactivate this email. @param string $emailFilter Filter by email address @param string $tag Filter by tag @param string $messageID Filter by MessageID @param string $fromdate Filter for bounces after is date. @param string $todate Filter for bounces before this date. @return DynamicResponseModel
[ "Get", "a", "batch", "of", "bounces", "to", "be", "processed", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L192-L208
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.getOutboundMessages
function getOutboundMessages($count = 100, $offset = 0, $recipient = NULL, $fromEmail = NULL, $tag = NULL, $subject = NULL, $status = NULL, $fromdate = NULL, $todate = NULL, $metadata = NULL) { $query = array(); $query["recipient"] = $recipient; $query["fromemail"] = $fromEmail; $query["tag"] = $tag; $query["subject"] = $subject; $query["count"] = $count; $query["offset"] = $offset; $query["status"] = $status; $query["fromdate"] = $fromdate; $query["todate"] = $todate; if($metadata != NULL) { foreach($metadata as $key => $value) { $query["metadata_$key"] = $value; } } return new DynamicResponseModel($this->processRestRequest('GET', '/messages/outbound', $query)); }
php
function getOutboundMessages($count = 100, $offset = 0, $recipient = NULL, $fromEmail = NULL, $tag = NULL, $subject = NULL, $status = NULL, $fromdate = NULL, $todate = NULL, $metadata = NULL) { $query = array(); $query["recipient"] = $recipient; $query["fromemail"] = $fromEmail; $query["tag"] = $tag; $query["subject"] = $subject; $query["count"] = $count; $query["offset"] = $offset; $query["status"] = $status; $query["fromdate"] = $fromdate; $query["todate"] = $todate; if($metadata != NULL) { foreach($metadata as $key => $value) { $query["metadata_$key"] = $value; } } return new DynamicResponseModel($this->processRestRequest('GET', '/messages/outbound', $query)); }
[ "function", "getOutboundMessages", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ",", "$", "recipient", "=", "NULL", ",", "$", "fromEmail", "=", "NULL", ",", "$", "tag", "=", "NULL", ",", "$", "subject", "=", "NULL", ",", "$", "status", "=", "NULL", ",", "$", "fromdate", "=", "NULL", ",", "$", "todate", "=", "NULL", ",", "$", "metadata", "=", "NULL", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "\"recipient\"", "]", "=", "$", "recipient", ";", "$", "query", "[", "\"fromemail\"", "]", "=", "$", "fromEmail", ";", "$", "query", "[", "\"tag\"", "]", "=", "$", "tag", ";", "$", "query", "[", "\"subject\"", "]", "=", "$", "subject", ";", "$", "query", "[", "\"count\"", "]", "=", "$", "count", ";", "$", "query", "[", "\"offset\"", "]", "=", "$", "offset", ";", "$", "query", "[", "\"status\"", "]", "=", "$", "status", ";", "$", "query", "[", "\"fromdate\"", "]", "=", "$", "fromdate", ";", "$", "query", "[", "\"todate\"", "]", "=", "$", "todate", ";", "if", "(", "$", "metadata", "!=", "NULL", ")", "{", "foreach", "(", "$", "metadata", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "query", "[", "\"metadata_$key\"", "]", "=", "$", "value", ";", "}", "}", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/messages/outbound'", ",", "$", "query", ")", ")", ";", "}" ]
Search messages that have been sent using this Server. @param integer $count How many messages to retrieve at once (defaults to 100) @param integer $offset How many messages to skip when 'paging' through the massages (defaults to 0) @param string $recipient Filter by recipient. @param string $fromEmail Filter by sender email address. @param string $tag Filter by tag. @param string $subject Filter by subject. @param string $status The current status for the outbound messages to return defaults to 'sent' @param string $fromdate Filter to messages on or after YYYY-MM-DD @param string $todate Filter to messages on or before YYYY-MM-DD @param string $metadata An associatative array of key-values that must all match values included in the metadata of matching sent messages. @return DynamicResponseModel
[ "Search", "messages", "that", "have", "been", "sent", "using", "this", "Server", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L321-L343
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.getInboundMessages
function getInboundMessages($count = 100, $offset = 0, $recipient = NULL, $fromEmail = NULL, $tag = NULL, $subject = NULL, $mailboxHash = NULL, $status = NULL, $fromdate = NULL, $todate = NULL) { $query = array(); $query['recipient'] = $recipient; $query['fromemail'] = $fromEmail; $query['tag'] = $tag; $query['subject'] = $subject; $query['mailboxhash'] = $mailboxHash; $query['count'] = $count; $query['status'] = $status; $query['offset'] = $offset; $query['fromdate'] = $fromdate; $query['todate'] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/messages/inbound', $query)); }
php
function getInboundMessages($count = 100, $offset = 0, $recipient = NULL, $fromEmail = NULL, $tag = NULL, $subject = NULL, $mailboxHash = NULL, $status = NULL, $fromdate = NULL, $todate = NULL) { $query = array(); $query['recipient'] = $recipient; $query['fromemail'] = $fromEmail; $query['tag'] = $tag; $query['subject'] = $subject; $query['mailboxhash'] = $mailboxHash; $query['count'] = $count; $query['status'] = $status; $query['offset'] = $offset; $query['fromdate'] = $fromdate; $query['todate'] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/messages/inbound', $query)); }
[ "function", "getInboundMessages", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ",", "$", "recipient", "=", "NULL", ",", "$", "fromEmail", "=", "NULL", ",", "$", "tag", "=", "NULL", ",", "$", "subject", "=", "NULL", ",", "$", "mailboxHash", "=", "NULL", ",", "$", "status", "=", "NULL", ",", "$", "fromdate", "=", "NULL", ",", "$", "todate", "=", "NULL", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'recipient'", "]", "=", "$", "recipient", ";", "$", "query", "[", "'fromemail'", "]", "=", "$", "fromEmail", ";", "$", "query", "[", "'tag'", "]", "=", "$", "tag", ";", "$", "query", "[", "'subject'", "]", "=", "$", "subject", ";", "$", "query", "[", "'mailboxhash'", "]", "=", "$", "mailboxHash", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'status'", "]", "=", "$", "status", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "$", "query", "[", "'fromdate'", "]", "=", "$", "fromdate", ";", "$", "query", "[", "'todate'", "]", "=", "$", "todate", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/messages/inbound'", ",", "$", "query", ")", ")", ";", "}" ]
Get messages sent to the inbound email address associated with this Server. @param integer $count The number of inbounce messages to retrieve in the request (defaults to 100) @param integer $offset The number of messages to 'skip' when 'paging' through messages (defaults to 0) @param string $recipient Filter by the message recipient @param string $fromEmail Filter by the message sender @param string $tag Filter by the message tag @param string $subject Filter by the message subject @param string $mailboxHash Filter by the mailboxHash @param string $status Filter by status ('blocked' or 'processed') @param string $fromdate Filter to messages on or after YYYY-MM-DD @param string $todate Filter to messages on or before YYYY-MM-DD @return DynamicResponseModel
[ "Get", "messages", "sent", "to", "the", "inbound", "email", "address", "associated", "with", "this", "Server", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L380-L397
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.getOpenStatistics
function getOpenStatistics($count = 100, $offset = 0, $recipient = NULL, $tag = NULL, $clientName = NULL, $clientCompany = NULL, $clientFamily = NULL, $osName = NULL, $osFamily = NULL, $osCompany = NULL, $platform = NULL, $country = NULL, $region = NULL, $city = NULL) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; $query['recipient'] = $recipient; $query['tag'] = $tag; $query['client_name'] = $clientName; $query['client_company'] = $clientCompany; $query['client_family'] = $clientFamily; $query['os_name'] = $osName; $query['os_family'] = $osFamily; $query['os_company'] = $osCompany; $query['platform'] = $platform; $query['country'] = $country; $query['region'] = $region; $query['city'] = $city; return new DynamicResponseModel($this->processRestRequest('GET', '/messages/outbound/opens', $query)); }
php
function getOpenStatistics($count = 100, $offset = 0, $recipient = NULL, $tag = NULL, $clientName = NULL, $clientCompany = NULL, $clientFamily = NULL, $osName = NULL, $osFamily = NULL, $osCompany = NULL, $platform = NULL, $country = NULL, $region = NULL, $city = NULL) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; $query['recipient'] = $recipient; $query['tag'] = $tag; $query['client_name'] = $clientName; $query['client_company'] = $clientCompany; $query['client_family'] = $clientFamily; $query['os_name'] = $osName; $query['os_family'] = $osFamily; $query['os_company'] = $osCompany; $query['platform'] = $platform; $query['country'] = $country; $query['region'] = $region; $query['city'] = $city; return new DynamicResponseModel($this->processRestRequest('GET', '/messages/outbound/opens', $query)); }
[ "function", "getOpenStatistics", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ",", "$", "recipient", "=", "NULL", ",", "$", "tag", "=", "NULL", ",", "$", "clientName", "=", "NULL", ",", "$", "clientCompany", "=", "NULL", ",", "$", "clientFamily", "=", "NULL", ",", "$", "osName", "=", "NULL", ",", "$", "osFamily", "=", "NULL", ",", "$", "osCompany", "=", "NULL", ",", "$", "platform", "=", "NULL", ",", "$", "country", "=", "NULL", ",", "$", "region", "=", "NULL", ",", "$", "city", "=", "NULL", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "$", "query", "[", "'recipient'", "]", "=", "$", "recipient", ";", "$", "query", "[", "'tag'", "]", "=", "$", "tag", ";", "$", "query", "[", "'client_name'", "]", "=", "$", "clientName", ";", "$", "query", "[", "'client_company'", "]", "=", "$", "clientCompany", ";", "$", "query", "[", "'client_family'", "]", "=", "$", "clientFamily", ";", "$", "query", "[", "'os_name'", "]", "=", "$", "osName", ";", "$", "query", "[", "'os_family'", "]", "=", "$", "osFamily", ";", "$", "query", "[", "'os_company'", "]", "=", "$", "osCompany", ";", "$", "query", "[", "'platform'", "]", "=", "$", "platform", ";", "$", "query", "[", "'country'", "]", "=", "$", "country", ";", "$", "query", "[", "'region'", "]", "=", "$", "region", ";", "$", "query", "[", "'city'", "]", "=", "$", "city", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/messages/outbound/opens'", ",", "$", "query", ")", ")", ";", "}" ]
Get statistics for tracked messages, optionally filtering by various open event properties. @param integer $count The number of open statistics to retrieve in this request. @param integer $offset The number of statistics to 'skip' when paging through statistics. @param string $recipient Filter by recipient. @param string $tag Filter by tag. @param string $clientName Filter by Email Client name. @param string $clientCompany Filter by Email Client Company's name. @param string $clientFamily Filter by Email Client's Family name. @param string $osName Filter by Email Client's Operating System Name. @param string $osFamily Filter by Email Client's Operating System's Family. @param string $osCompany Filter by Email Client's Operating System's Company. @param string $platform Filter by Email Client's Platform Name. @param string $country Filter by Country. @param string $region Filter by Region. @param string $city Filter by City. @return DynamicResponseModel
[ "Get", "statistics", "for", "tracked", "messages", "optionally", "filtering", "by", "various", "open", "event", "properties", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L449-L471
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.getOpenStatisticsForMessage
function getOpenStatisticsForMessage($id, $count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', "/messages/outbound/opens/$id", $query)); }
php
function getOpenStatisticsForMessage($id, $count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', "/messages/outbound/opens/$id", $query)); }
[ "function", "getOpenStatisticsForMessage", "(", "$", "id", ",", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "\"/messages/outbound/opens/$id\"", ",", "$", "query", ")", ")", ";", "}" ]
Get information about individual opens for a sent message. @param integer $id The ID for the message that we want statistics for. @param integer $count How many statistics should we retrieve? @param integer $offset How many should we 'skip' when 'paging' through statistics. @return DynamicResponseModel
[ "Get", "information", "about", "individual", "opens", "for", "a", "sent", "message", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L524-L531
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.getClickStatisticsForMessage
function getClickStatisticsForMessage($id, $count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', "/messages/outbound/clicks/$id", $query)); }
php
function getClickStatisticsForMessage($id, $count = 100, $offset = 0) { $query = array(); $query['count'] = $count; $query['offset'] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', "/messages/outbound/clicks/$id", $query)); }
[ "function", "getClickStatisticsForMessage", "(", "$", "id", ",", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'count'", "]", "=", "$", "count", ";", "$", "query", "[", "'offset'", "]", "=", "$", "offset", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "\"/messages/outbound/clicks/$id\"", ",", "$", "query", ")", ")", ";", "}" ]
Get information about individual clicks for a sent message. @param integer $id The ID for the message that we want statistics for. @param integer $count How many statistics should we retrieve? @param integer $offset How many should we 'skip' when 'paging' through statistics. @return DynamicResponseModel
[ "Get", "information", "about", "individual", "clicks", "for", "a", "sent", "message", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L541-L548
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.getOutboundClickStatistics
function getOutboundClickStatistics($tag = NULL, $fromdate = NULL, $todate = NULL) { $query = array(); $query['tag'] = $tag; $query['fromdate'] = $fromdate; $query['todate'] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/stats/outbound/clicks', $query)); }
php
function getOutboundClickStatistics($tag = NULL, $fromdate = NULL, $todate = NULL) { $query = array(); $query['tag'] = $tag; $query['fromdate'] = $fromdate; $query['todate'] = $todate; return new DynamicResponseModel($this->processRestRequest('GET', '/stats/outbound/clicks', $query)); }
[ "function", "getOutboundClickStatistics", "(", "$", "tag", "=", "NULL", ",", "$", "fromdate", "=", "NULL", ",", "$", "todate", "=", "NULL", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "'tag'", "]", "=", "$", "tag", ";", "$", "query", "[", "'fromdate'", "]", "=", "$", "fromdate", ";", "$", "query", "[", "'todate'", "]", "=", "$", "todate", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/stats/outbound/clicks'", ",", "$", "query", ")", ")", ";", "}" ]
Get click statistics for the messages sent using this Server, optionally filtering on message tag, and a to and from date. @param string $tag Filter by tag. @param string $fromdate must be of the format 'YYYY-MM-DD' @param string $todate must be of the format 'YYYY-MM-DD' @return DynamicResponseModel
[ "Get", "click", "statistics", "for", "the", "messages", "sent", "using", "this", "Server", "optionally", "filtering", "on", "message", "tag", "and", "a", "to", "and", "from", "date", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L730-L738
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.createTagTrigger
function createTagTrigger($matchName, $trackOpens = true) { $body = array(); $body["MatchName"] = $matchName; $body["TrackOpens"] = $trackOpens; return new DynamicResponseModel($this->processRestRequest('POST', '/triggers/tags', $body)); }
php
function createTagTrigger($matchName, $trackOpens = true) { $body = array(); $body["MatchName"] = $matchName; $body["TrackOpens"] = $trackOpens; return new DynamicResponseModel($this->processRestRequest('POST', '/triggers/tags', $body)); }
[ "function", "createTagTrigger", "(", "$", "matchName", ",", "$", "trackOpens", "=", "true", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "\"MatchName\"", "]", "=", "$", "matchName", ";", "$", "body", "[", "\"TrackOpens\"", "]", "=", "$", "trackOpens", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "'/triggers/tags'", ",", "$", "body", ")", ")", ";", "}" ]
Create a Tag Trigger. @param string $matchName Name of the tag that will activate this trigger. @param boolean $trackOpens Indicates if this trigger activates open tracking. @return DynamicResponseModel
[ "Create", "a", "Tag", "Trigger", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L806-L812
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.searchTagTriggers
function searchTagTriggers($count = 100, $offset = 0, $matchName = NULL) { $query = array(); $query["count"] = $count; $query["offset"] = $offset; $query["match_name"] = $matchName; return new DynamicResponseModel($this->processRestRequest('GET', '/triggers/tags', $query)); }
php
function searchTagTriggers($count = 100, $offset = 0, $matchName = NULL) { $query = array(); $query["count"] = $count; $query["offset"] = $offset; $query["match_name"] = $matchName; return new DynamicResponseModel($this->processRestRequest('GET', '/triggers/tags', $query)); }
[ "function", "searchTagTriggers", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ",", "$", "matchName", "=", "NULL", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "\"count\"", "]", "=", "$", "count", ";", "$", "query", "[", "\"offset\"", "]", "=", "$", "offset", ";", "$", "query", "[", "\"match_name\"", "]", "=", "$", "matchName", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/triggers/tags'", ",", "$", "query", ")", ")", ";", "}" ]
Locate Tag Triggers matching the filter criteria. @param integer $count The number of triggers to return with this request. @param integer $offset The number of triggers to 'skip' when 'paging' through tag triggers. @param string $matchName @return DynamicResponseModel
[ "Locate", "Tag", "Triggers", "matching", "the", "filter", "criteria", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L832-L840
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.editTagTrigger
function editTagTrigger($id, $matchName, $trackOpens = true) { $body = array(); $body["MatchName"] = $matchName; $body["TrackOpens"] = $trackOpens; return new DynamicResponseModel($this->processRestRequest('PUT', "/triggers/tags/$id", $body)); }
php
function editTagTrigger($id, $matchName, $trackOpens = true) { $body = array(); $body["MatchName"] = $matchName; $body["TrackOpens"] = $trackOpens; return new DynamicResponseModel($this->processRestRequest('PUT', "/triggers/tags/$id", $body)); }
[ "function", "editTagTrigger", "(", "$", "id", ",", "$", "matchName", ",", "$", "trackOpens", "=", "true", ")", "{", "$", "body", "=", "array", "(", ")", ";", "$", "body", "[", "\"MatchName\"", "]", "=", "$", "matchName", ";", "$", "body", "[", "\"TrackOpens\"", "]", "=", "$", "trackOpens", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'PUT'", ",", "\"/triggers/tags/$id\"", ",", "$", "body", ")", ")", ";", "}" ]
Edit an existing Tag Trigger @param integer $id The ID of the Tag Trigger we wish to modify. @param string $matchName Name of the tag that will activate this trigger. @param boolean $trackOpens Indicates if this trigger activates open tracking. @return DynamicResponseModel
[ "Edit", "an", "existing", "Tag", "Trigger" ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L850-L856
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.listInboundRuleTriggers
function listInboundRuleTriggers($count = 100, $offset = 0) { $query = array(); $query["count"] = $count; $query["offset"] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', '/triggers/inboundrules', $query)); }
php
function listInboundRuleTriggers($count = 100, $offset = 0) { $query = array(); $query["count"] = $count; $query["offset"] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', '/triggers/inboundrules', $query)); }
[ "function", "listInboundRuleTriggers", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "\"count\"", "]", "=", "$", "count", ";", "$", "query", "[", "\"offset\"", "]", "=", "$", "offset", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "'/triggers/inboundrules'", ",", "$", "query", ")", ")", ";", "}" ]
Get a list of all existing Inbound Rule Triggers. @param integer $count The number of rule triggers to return with this request. @param integer $offset The number of triggers to 'skip' when 'paging' through rule triggers. @return DynamicResponseModel
[ "Get", "a", "list", "of", "all", "existing", "Inbound", "Rule", "Triggers", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L888-L895
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.createTemplate
function createTemplate($name, $subject, $htmlBody, $textBody) { $template = array(); $template["name"] = $name; $template["subject"] = $subject; $template["htmlBody"] = $htmlBody; $template["textBody"] = $textBody; return new DynamicResponseModel($this->processRestRequest('POST', "/templates", $template)); }
php
function createTemplate($name, $subject, $htmlBody, $textBody) { $template = array(); $template["name"] = $name; $template["subject"] = $subject; $template["htmlBody"] = $htmlBody; $template["textBody"] = $textBody; return new DynamicResponseModel($this->processRestRequest('POST', "/templates", $template)); }
[ "function", "createTemplate", "(", "$", "name", ",", "$", "subject", ",", "$", "htmlBody", ",", "$", "textBody", ")", "{", "$", "template", "=", "array", "(", ")", ";", "$", "template", "[", "\"name\"", "]", "=", "$", "name", ";", "$", "template", "[", "\"subject\"", "]", "=", "$", "subject", ";", "$", "template", "[", "\"htmlBody\"", "]", "=", "$", "htmlBody", ";", "$", "template", "[", "\"textBody\"", "]", "=", "$", "textBody", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "\"/templates\"", ",", "$", "template", ")", ")", ";", "}" ]
Create a template @param string $name The friendly name for this template. @param string $subject The template to be used for the 'subject' of emails sent using this template. @param string $htmlBody The template to be used for the 'htmlBody' of emails sent using this template, optional if 'textBody' is not NULL. @param string $textBody The template to be used for the 'textBody' of emails sent using this template, optional if 'htmlBody' is not NULL. @return DynamicResponseModel
[ "Create", "a", "template" ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L927-L934
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.editTemplate
function editTemplate($id, $name = NULL, $subject = NULL, $htmlBody = NULL, $textBody = NULL) { $template = array(); $template["name"] = $name; $template["subject"] = $subject; $template["htmlBody"] = $htmlBody; $template["textBody"] = $textBody; return new DynamicResponseModel($this->processRestRequest('PUT', "/templates/$id", $template)); }
php
function editTemplate($id, $name = NULL, $subject = NULL, $htmlBody = NULL, $textBody = NULL) { $template = array(); $template["name"] = $name; $template["subject"] = $subject; $template["htmlBody"] = $htmlBody; $template["textBody"] = $textBody; return new DynamicResponseModel($this->processRestRequest('PUT', "/templates/$id", $template)); }
[ "function", "editTemplate", "(", "$", "id", ",", "$", "name", "=", "NULL", ",", "$", "subject", "=", "NULL", ",", "$", "htmlBody", "=", "NULL", ",", "$", "textBody", "=", "NULL", ")", "{", "$", "template", "=", "array", "(", ")", ";", "$", "template", "[", "\"name\"", "]", "=", "$", "name", ";", "$", "template", "[", "\"subject\"", "]", "=", "$", "subject", ";", "$", "template", "[", "\"htmlBody\"", "]", "=", "$", "htmlBody", ";", "$", "template", "[", "\"textBody\"", "]", "=", "$", "textBody", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'PUT'", ",", "\"/templates/$id\"", ",", "$", "template", ")", ")", ";", "}" ]
Edit a template @param integer $id The ID of the template you wish to update. @param string $name The friendly name for this template. @param string $subject The template to be used for the 'subject' of emails sent using this template. @param string $htmlBody The template to be used for the 'htmlBody' of emails sent using this template. @param string $textBody The template to be used for the 'textBody' of emails sent using this template. @return DynamicResponseModel
[ "Edit", "a", "template" ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L947-L955
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.listTemplates
function listTemplates($count = 100, $offset = 0) { $query = array(); $query["count"] = $count; $query["offset"] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', "/templates", $query)); }
php
function listTemplates($count = 100, $offset = 0) { $query = array(); $query["count"] = $count; $query["offset"] = $offset; return new DynamicResponseModel($this->processRestRequest('GET', "/templates", $query)); }
[ "function", "listTemplates", "(", "$", "count", "=", "100", ",", "$", "offset", "=", "0", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "\"count\"", "]", "=", "$", "count", ";", "$", "query", "[", "\"offset\"", "]", "=", "$", "offset", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'GET'", ",", "\"/templates\"", ",", "$", "query", ")", ")", ";", "}" ]
Get all templates associated with the Server. @param integer $count The total number of templates to get at once (default is 100) @param integer $offset The number of templates to "Skip" before returning results. @return DynamicResponseModel
[ "Get", "all", "templates", "associated", "with", "the", "Server", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L975-L982
wildbit/postmark-php
src/Postmark/PostmarkClient.php
PostmarkClient.validateTemplate
function validateTemplate($subject = NULL, $htmlBody = NULL, $textBody = NULL, $testRenderModel = NULL, $inlineCssForHtmlTestRender = true) { $query = array(); $query["subject"] = $subject; $query["htmlBody"] = $htmlBody; $query["textBody"] = $textBody; $query["testRenderModel"] = $testRenderModel; $query["inlineCssForHtmlTestRender"] = $inlineCssForHtmlTestRender; return new DynamicResponseModel($this->processRestRequest('POST', "/templates/validate", $query)); }
php
function validateTemplate($subject = NULL, $htmlBody = NULL, $textBody = NULL, $testRenderModel = NULL, $inlineCssForHtmlTestRender = true) { $query = array(); $query["subject"] = $subject; $query["htmlBody"] = $htmlBody; $query["textBody"] = $textBody; $query["testRenderModel"] = $testRenderModel; $query["inlineCssForHtmlTestRender"] = $inlineCssForHtmlTestRender; return new DynamicResponseModel($this->processRestRequest('POST', "/templates/validate", $query)); }
[ "function", "validateTemplate", "(", "$", "subject", "=", "NULL", ",", "$", "htmlBody", "=", "NULL", ",", "$", "textBody", "=", "NULL", ",", "$", "testRenderModel", "=", "NULL", ",", "$", "inlineCssForHtmlTestRender", "=", "true", ")", "{", "$", "query", "=", "array", "(", ")", ";", "$", "query", "[", "\"subject\"", "]", "=", "$", "subject", ";", "$", "query", "[", "\"htmlBody\"", "]", "=", "$", "htmlBody", ";", "$", "query", "[", "\"textBody\"", "]", "=", "$", "textBody", ";", "$", "query", "[", "\"testRenderModel\"", "]", "=", "$", "testRenderModel", ";", "$", "query", "[", "\"inlineCssForHtmlTestRender\"", "]", "=", "$", "inlineCssForHtmlTestRender", ";", "return", "new", "DynamicResponseModel", "(", "$", "this", "->", "processRestRequest", "(", "'POST'", ",", "\"/templates/validate\"", ",", "$", "query", ")", ")", ";", "}" ]
Confirm that your template content can be parsed/rendered, get a test rendering of your template, and a suggested model to use with your templates. @param string $subject The Subject template you wish to test. @param string $htmlBody The HTML template you wish to test @param string $textBody The number of templates to "Skip" before returning results. @param object $testRenderModel The model to be used when doing test renders of the templates that successfully parse in this request. @param bool $inlineCssForHtmlTestRender If htmlBody is specified, the test render will automatically do CSS Inlining for the HTML content. You may opt-out of this behavior by passing 'false' for this parameter. @return DynamicResponseModel
[ "Confirm", "that", "your", "template", "content", "can", "be", "parsed", "/", "rendered", "get", "a", "test", "rendering", "of", "your", "template", "and", "a", "suggested", "model", "to", "use", "with", "your", "templates", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClient.php#L994-L1004
wildbit/postmark-php
src/Postmark/Models/DynamicResponseModel.php
DynamicResponseModel.offsetGet
public function offsetGet($offset) { $result = parent::offsetGet($offset); if ($result != NULL && is_array($result)) { $result = new DynamicResponseModel($result); } return $result; }
php
public function offsetGet($offset) { $result = parent::offsetGet($offset); if ($result != NULL && is_array($result)) { $result = new DynamicResponseModel($result); } return $result; }
[ "public", "function", "offsetGet", "(", "$", "offset", ")", "{", "$", "result", "=", "parent", "::", "offsetGet", "(", "$", "offset", ")", ";", "if", "(", "$", "result", "!=", "NULL", "&&", "is_array", "(", "$", "result", ")", ")", "{", "$", "result", "=", "new", "DynamicResponseModel", "(", "$", "result", ")", ";", "}", "return", "$", "result", ";", "}" ]
Infrastructure. Allows indexer to return a DynamicResponseModel.
[ "Infrastructure", ".", "Allows", "indexer", "to", "return", "a", "DynamicResponseModel", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/Models/DynamicResponseModel.php#L56-L62
wildbit/postmark-php
src/Postmark/PostmarkClientBase.php
PostmarkClientBase.getClient
protected function getClient() { if(!$this->client) { $this->client = new Client([ RequestOptions::VERIFY => self::$VERIFY_SSL, RequestOptions::TIMEOUT => $this->timeout, ]); } return $this->client; }
php
protected function getClient() { if(!$this->client) { $this->client = new Client([ RequestOptions::VERIFY => self::$VERIFY_SSL, RequestOptions::TIMEOUT => $this->timeout, ]); } return $this->client; }
[ "protected", "function", "getClient", "(", ")", "{", "if", "(", "!", "$", "this", "->", "client", ")", "{", "$", "this", "->", "client", "=", "new", "Client", "(", "[", "RequestOptions", "::", "VERIFY", "=>", "self", "::", "$", "VERIFY_SSL", ",", "RequestOptions", "::", "TIMEOUT", "=>", "$", "this", "->", "timeout", ",", "]", ")", ";", "}", "return", "$", "this", "->", "client", ";", "}" ]
Return the injected GuzzleHttp\Client or create a default instance @return Client
[ "Return", "the", "injected", "GuzzleHttp", "\\", "Client", "or", "create", "a", "default", "instance" ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClientBase.php#L68-L76
wildbit/postmark-php
src/Postmark/PostmarkClientBase.php
PostmarkClientBase.processRestRequest
protected function processRestRequest($method = NULL, $path = NULL, array $body = []) { $client = $this->getClient(); $options = [ RequestOptions::HTTP_ERRORS => false, RequestOptions::HEADERS => [ 'User-Agent' => "Postmark-PHP (PHP Version:{$this->version}, OS:{$this->os})", 'Accept' => 'application/json', 'Content-Type' => 'application/json', $this->authorization_header => $this->authorization_token ], ]; if(!empty($body)) { $cleanParams = array_filter($body, function($value) { return $value !== null; }); switch ($method) { case 'GET': case 'HEAD': case 'DELETE': case 'OPTIONS': $options[RequestOptions::QUERY] = $cleanParams; break; case 'PUT': case 'POST': case 'PATCH': $options[RequestOptions::JSON] = $cleanParams; break; } } $response = $client->request($method, self::$BASE_URL . $path, $options); switch ($response->getStatusCode()) { case 200: return json_decode($response->getBody(), true); case 401: $ex = new PostmarkException(); $ex->message = 'Unauthorized: Missing or incorrect API token in header. ' . 'Please verify that you used the correct token when you constructed your client.'; $ex->httpStatusCode = 401; throw $ex; case 500: $ex = new PostmarkException(); $ex->httpStatusCode = 500; $ex->message = 'Internal Server Error: This is an issue with Postmark’s servers processing your request. ' . 'In most cases the message is lost during the process, ' . 'and Postmark is notified so that we can investigate the issue.'; throw $ex; case 503: $ex = new PostmarkException(); $ex->httpStatusCode = 503; $ex->message = 'The Postmark API is currently unavailable, please try your request later.'; throw $ex; // This should cover case 422, and any others that are possible: default: $ex = new PostmarkException(); $body = json_decode($response->getBody(), true); $ex->httpStatusCode = $response->getStatusCode(); $ex->postmarkApiErrorCode = $body['ErrorCode']; $ex->message = $body['Message']; throw $ex; } }
php
protected function processRestRequest($method = NULL, $path = NULL, array $body = []) { $client = $this->getClient(); $options = [ RequestOptions::HTTP_ERRORS => false, RequestOptions::HEADERS => [ 'User-Agent' => "Postmark-PHP (PHP Version:{$this->version}, OS:{$this->os})", 'Accept' => 'application/json', 'Content-Type' => 'application/json', $this->authorization_header => $this->authorization_token ], ]; if(!empty($body)) { $cleanParams = array_filter($body, function($value) { return $value !== null; }); switch ($method) { case 'GET': case 'HEAD': case 'DELETE': case 'OPTIONS': $options[RequestOptions::QUERY] = $cleanParams; break; case 'PUT': case 'POST': case 'PATCH': $options[RequestOptions::JSON] = $cleanParams; break; } } $response = $client->request($method, self::$BASE_URL . $path, $options); switch ($response->getStatusCode()) { case 200: return json_decode($response->getBody(), true); case 401: $ex = new PostmarkException(); $ex->message = 'Unauthorized: Missing or incorrect API token in header. ' . 'Please verify that you used the correct token when you constructed your client.'; $ex->httpStatusCode = 401; throw $ex; case 500: $ex = new PostmarkException(); $ex->httpStatusCode = 500; $ex->message = 'Internal Server Error: This is an issue with Postmark’s servers processing your request. ' . 'In most cases the message is lost during the process, ' . 'and Postmark is notified so that we can investigate the issue.'; throw $ex; case 503: $ex = new PostmarkException(); $ex->httpStatusCode = 503; $ex->message = 'The Postmark API is currently unavailable, please try your request later.'; throw $ex; // This should cover case 422, and any others that are possible: default: $ex = new PostmarkException(); $body = json_decode($response->getBody(), true); $ex->httpStatusCode = $response->getStatusCode(); $ex->postmarkApiErrorCode = $body['ErrorCode']; $ex->message = $body['Message']; throw $ex; } }
[ "protected", "function", "processRestRequest", "(", "$", "method", "=", "NULL", ",", "$", "path", "=", "NULL", ",", "array", "$", "body", "=", "[", "]", ")", "{", "$", "client", "=", "$", "this", "->", "getClient", "(", ")", ";", "$", "options", "=", "[", "RequestOptions", "::", "HTTP_ERRORS", "=>", "false", ",", "RequestOptions", "::", "HEADERS", "=>", "[", "'User-Agent'", "=>", "\"Postmark-PHP (PHP Version:{$this->version}, OS:{$this->os})\"", ",", "'Accept'", "=>", "'application/json'", ",", "'Content-Type'", "=>", "'application/json'", ",", "$", "this", "->", "authorization_header", "=>", "$", "this", "->", "authorization_token", "]", ",", "]", ";", "if", "(", "!", "empty", "(", "$", "body", ")", ")", "{", "$", "cleanParams", "=", "array_filter", "(", "$", "body", ",", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "null", ";", "}", ")", ";", "switch", "(", "$", "method", ")", "{", "case", "'GET'", ":", "case", "'HEAD'", ":", "case", "'DELETE'", ":", "case", "'OPTIONS'", ":", "$", "options", "[", "RequestOptions", "::", "QUERY", "]", "=", "$", "cleanParams", ";", "break", ";", "case", "'PUT'", ":", "case", "'POST'", ":", "case", "'PATCH'", ":", "$", "options", "[", "RequestOptions", "::", "JSON", "]", "=", "$", "cleanParams", ";", "break", ";", "}", "}", "$", "response", "=", "$", "client", "->", "request", "(", "$", "method", ",", "self", "::", "$", "BASE_URL", ".", "$", "path", ",", "$", "options", ")", ";", "switch", "(", "$", "response", "->", "getStatusCode", "(", ")", ")", "{", "case", "200", ":", "return", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "case", "401", ":", "$", "ex", "=", "new", "PostmarkException", "(", ")", ";", "$", "ex", "->", "message", "=", "'Unauthorized: Missing or incorrect API token in header. '", ".", "'Please verify that you used the correct token when you constructed your client.'", ";", "$", "ex", "->", "httpStatusCode", "=", "401", ";", "throw", "$", "ex", ";", "case", "500", ":", "$", "ex", "=", "new", "PostmarkException", "(", ")", ";", "$", "ex", "->", "httpStatusCode", "=", "500", ";", "$", "ex", "->", "message", "=", "'Internal Server Error: This is an issue with Postmark’s servers processing your request. ' .", "", "'In most cases the message is lost during the process, '", ".", "'and Postmark is notified so that we can investigate the issue.'", ";", "throw", "$", "ex", ";", "case", "503", ":", "$", "ex", "=", "new", "PostmarkException", "(", ")", ";", "$", "ex", "->", "httpStatusCode", "=", "503", ";", "$", "ex", "->", "message", "=", "'The Postmark API is currently unavailable, please try your request later.'", ";", "throw", "$", "ex", ";", "// This should cover case 422, and any others that are possible:", "default", ":", "$", "ex", "=", "new", "PostmarkException", "(", ")", ";", "$", "body", "=", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "$", "ex", "->", "httpStatusCode", "=", "$", "response", "->", "getStatusCode", "(", ")", ";", "$", "ex", "->", "postmarkApiErrorCode", "=", "$", "body", "[", "'ErrorCode'", "]", ";", "$", "ex", "->", "message", "=", "$", "body", "[", "'Message'", "]", ";", "throw", "$", "ex", ";", "}", "}" ]
The base request method for all API access. @param string $method The request VERB to use (GET, POST, PUT, DELETE) @param string $path The API path. @param array $body The content to be used (either as the query, or the json post/put body) @return object @throws PostmarkException
[ "The", "base", "request", "method", "for", "all", "API", "access", "." ]
train
https://github.com/wildbit/postmark-php/blob/70162fe99ac0a80e599f76ae84e4b6e655081e04/src/Postmark/PostmarkClientBase.php#L105-L172
SimpleBus/MessageBus
src/Subscriber/Resolver/NameBasedMessageSubscriberResolver.php
NameBasedMessageSubscriberResolver.resolve
public function resolve($message) { $name = $this->messageNameResolver->resolve($message); return $this->messageSubscribers->filter($name); }
php
public function resolve($message) { $name = $this->messageNameResolver->resolve($message); return $this->messageSubscribers->filter($name); }
[ "public", "function", "resolve", "(", "$", "message", ")", "{", "$", "name", "=", "$", "this", "->", "messageNameResolver", "->", "resolve", "(", "$", "message", ")", ";", "return", "$", "this", "->", "messageSubscribers", "->", "filter", "(", "$", "name", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/SimpleBus/MessageBus/blob/83f90059b286db91a9e73ff17504b8c16b5f042a/src/Subscriber/Resolver/NameBasedMessageSubscriberResolver.php#L29-L34
SimpleBus/MessageBus
src/Recorder/AggregatesRecordedMessages.php
AggregatesRecordedMessages.recordedMessages
public function recordedMessages() { $allRecordedMessages = []; foreach ($this->messageRecorders as $messageRecorder) { $allRecordedMessages = array_merge($allRecordedMessages, $messageRecorder->recordedMessages()); } return $allRecordedMessages; }
php
public function recordedMessages() { $allRecordedMessages = []; foreach ($this->messageRecorders as $messageRecorder) { $allRecordedMessages = array_merge($allRecordedMessages, $messageRecorder->recordedMessages()); } return $allRecordedMessages; }
[ "public", "function", "recordedMessages", "(", ")", "{", "$", "allRecordedMessages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "messageRecorders", "as", "$", "messageRecorder", ")", "{", "$", "allRecordedMessages", "=", "array_merge", "(", "$", "allRecordedMessages", ",", "$", "messageRecorder", "->", "recordedMessages", "(", ")", ")", ";", "}", "return", "$", "allRecordedMessages", ";", "}" ]
Get messages recorded by all known message recorders. {@inheritdoc}
[ "Get", "messages", "recorded", "by", "all", "known", "message", "recorders", "." ]
train
https://github.com/SimpleBus/MessageBus/blob/83f90059b286db91a9e73ff17504b8c16b5f042a/src/Recorder/AggregatesRecordedMessages.php#L24-L33
SimpleBus/MessageBus
src/Name/NamedMessageNameResolver.php
NamedMessageNameResolver.resolve
public function resolve($message) { if (!($message instanceof NamedMessage)) { throw CouldNotResolveMessageName::forMessage($message, 'Message should be an instance of NamedMessage'); } $name = $message::messageName(); if (!is_string($name) || empty($name)) { throw CouldNotResolveMessageName::forMessage( $message, sprintf( 'Static method "%s::messageName()" should return a non-empty string', get_class($message) ) ); } return $name; }
php
public function resolve($message) { if (!($message instanceof NamedMessage)) { throw CouldNotResolveMessageName::forMessage($message, 'Message should be an instance of NamedMessage'); } $name = $message::messageName(); if (!is_string($name) || empty($name)) { throw CouldNotResolveMessageName::forMessage( $message, sprintf( 'Static method "%s::messageName()" should return a non-empty string', get_class($message) ) ); } return $name; }
[ "public", "function", "resolve", "(", "$", "message", ")", "{", "if", "(", "!", "(", "$", "message", "instanceof", "NamedMessage", ")", ")", "{", "throw", "CouldNotResolveMessageName", "::", "forMessage", "(", "$", "message", ",", "'Message should be an instance of NamedMessage'", ")", ";", "}", "$", "name", "=", "$", "message", "::", "messageName", "(", ")", ";", "if", "(", "!", "is_string", "(", "$", "name", ")", "||", "empty", "(", "$", "name", ")", ")", "{", "throw", "CouldNotResolveMessageName", "::", "forMessage", "(", "$", "message", ",", "sprintf", "(", "'Static method \"%s::messageName()\" should return a non-empty string'", ",", "get_class", "(", "$", "message", ")", ")", ")", ";", "}", "return", "$", "name", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/SimpleBus/MessageBus/blob/83f90059b286db91a9e73ff17504b8c16b5f042a/src/Name/NamedMessageNameResolver.php#L12-L31
SimpleBus/MessageBus
src/Bus/Middleware/FinishesHandlingMessageBeforeHandlingNext.php
FinishesHandlingMessageBeforeHandlingNext.handle
public function handle($message, callable $next) { $this->queue[] = $message; if (!$this->isHandling) { $this->isHandling = true; while ($message = array_shift($this->queue)) { try { $next($message); } catch (Exception $exception) { $this->isHandling = false; throw $exception; } } $this->isHandling = false; } }
php
public function handle($message, callable $next) { $this->queue[] = $message; if (!$this->isHandling) { $this->isHandling = true; while ($message = array_shift($this->queue)) { try { $next($message); } catch (Exception $exception) { $this->isHandling = false; throw $exception; } } $this->isHandling = false; } }
[ "public", "function", "handle", "(", "$", "message", ",", "callable", "$", "next", ")", "{", "$", "this", "->", "queue", "[", "]", "=", "$", "message", ";", "if", "(", "!", "$", "this", "->", "isHandling", ")", "{", "$", "this", "->", "isHandling", "=", "true", ";", "while", "(", "$", "message", "=", "array_shift", "(", "$", "this", "->", "queue", ")", ")", "{", "try", "{", "$", "next", "(", "$", "message", ")", ";", "}", "catch", "(", "Exception", "$", "exception", ")", "{", "$", "this", "->", "isHandling", "=", "false", ";", "throw", "$", "exception", ";", "}", "}", "$", "this", "->", "isHandling", "=", "false", ";", "}", "}" ]
Completely finishes handling the current message, before allowing other middlewares to start handling new messages. {@inheritdoc}
[ "Completely", "finishes", "handling", "the", "current", "message", "before", "allowing", "other", "middlewares", "to", "start", "handling", "new", "messages", "." ]
train
https://github.com/SimpleBus/MessageBus/blob/83f90059b286db91a9e73ff17504b8c16b5f042a/src/Bus/Middleware/FinishesHandlingMessageBeforeHandlingNext.php#L25-L44
SimpleBus/MessageBus
src/Handler/Resolver/NameBasedMessageHandlerResolver.php
NameBasedMessageHandlerResolver.resolve
public function resolve($message) { $name = $this->messageNameResolver->resolve($message); return $this->messageHandlers->get($name); }
php
public function resolve($message) { $name = $this->messageNameResolver->resolve($message); return $this->messageHandlers->get($name); }
[ "public", "function", "resolve", "(", "$", "message", ")", "{", "$", "name", "=", "$", "this", "->", "messageNameResolver", "->", "resolve", "(", "$", "message", ")", ";", "return", "$", "this", "->", "messageHandlers", "->", "get", "(", "$", "name", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/SimpleBus/MessageBus/blob/83f90059b286db91a9e73ff17504b8c16b5f042a/src/Handler/Resolver/NameBasedMessageHandlerResolver.php#L30-L35
akamai/AkamaiOPEN-edgegrid-php-client
src/Handler/Verbose.php
Verbose.getBody
protected function getBody(\Psr\Http\Message\MessageInterface $message) { $body = trim($message->getBody()); if ($message->getBody()->getSize() === 0 || empty($body)) { if ($message instanceof \Psr\Http\Message\ResponseInterface) { return 'No response body returned'; } return 'No request body sent'; } $result = json_decode($body); if ($result !== null) { return json_encode($result, JSON_PRETTY_PRINT); } return $body; }
php
protected function getBody(\Psr\Http\Message\MessageInterface $message) { $body = trim($message->getBody()); if ($message->getBody()->getSize() === 0 || empty($body)) { if ($message instanceof \Psr\Http\Message\ResponseInterface) { return 'No response body returned'; } return 'No request body sent'; } $result = json_decode($body); if ($result !== null) { return json_encode($result, JSON_PRETTY_PRINT); } return $body; }
[ "protected", "function", "getBody", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "MessageInterface", "$", "message", ")", "{", "$", "body", "=", "trim", "(", "$", "message", "->", "getBody", "(", ")", ")", ";", "if", "(", "$", "message", "->", "getBody", "(", ")", "->", "getSize", "(", ")", "===", "0", "||", "empty", "(", "$", "body", ")", ")", "{", "if", "(", "$", "message", "instanceof", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ResponseInterface", ")", "{", "return", "'No response body returned'", ";", "}", "return", "'No request body sent'", ";", "}", "$", "result", "=", "json_decode", "(", "$", "body", ")", ";", "if", "(", "$", "result", "!==", "null", ")", "{", "return", "json_encode", "(", "$", "result", ",", "JSON_PRETTY_PRINT", ")", ";", "}", "return", "$", "body", ";", "}" ]
Get response body @param \Psr\Http\Message\MessageInterface $message @return string
[ "Get", "response", "body" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Handler/Verbose.php#L176-L192
akamai/AkamaiOPEN-edgegrid-php-client
src/Cli.php
Cli.parseArguments
protected function parseArguments() { $args = $this->getNamedArgs(); $this->climate->arguments->add($args); if ($_SERVER['argc'] === 1) { $this->help(); return false; } if ($this->climate->arguments->defined('help')) { $this->help(); return; } if ($this->climate->arguments->defined('version')) { echo $this->version(); return; } try { $this->climate->arguments->parse($_SERVER['argv']); $padding = count($args); foreach ($this->climate->arguments->toArray() as $arg) { if ($arg === null) { --$padding; } } $argSize = count($_SERVER['argv']) - $padding - 1; for ($i = 0; $i < $argSize; $i++) { $args['arg-' . $i] = []; } $this->climate->arguments->add($args); $this->climate->arguments->parse($_SERVER['argv']); } catch (\Exception $e) { } return true; }
php
protected function parseArguments() { $args = $this->getNamedArgs(); $this->climate->arguments->add($args); if ($_SERVER['argc'] === 1) { $this->help(); return false; } if ($this->climate->arguments->defined('help')) { $this->help(); return; } if ($this->climate->arguments->defined('version')) { echo $this->version(); return; } try { $this->climate->arguments->parse($_SERVER['argv']); $padding = count($args); foreach ($this->climate->arguments->toArray() as $arg) { if ($arg === null) { --$padding; } } $argSize = count($_SERVER['argv']) - $padding - 1; for ($i = 0; $i < $argSize; $i++) { $args['arg-' . $i] = []; } $this->climate->arguments->add($args); $this->climate->arguments->parse($_SERVER['argv']); } catch (\Exception $e) { } return true; }
[ "protected", "function", "parseArguments", "(", ")", "{", "$", "args", "=", "$", "this", "->", "getNamedArgs", "(", ")", ";", "$", "this", "->", "climate", "->", "arguments", "->", "add", "(", "$", "args", ")", ";", "if", "(", "$", "_SERVER", "[", "'argc'", "]", "===", "1", ")", "{", "$", "this", "->", "help", "(", ")", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'help'", ")", ")", "{", "$", "this", "->", "help", "(", ")", ";", "return", ";", "}", "if", "(", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'version'", ")", ")", "{", "echo", "$", "this", "->", "version", "(", ")", ";", "return", ";", "}", "try", "{", "$", "this", "->", "climate", "->", "arguments", "->", "parse", "(", "$", "_SERVER", "[", "'argv'", "]", ")", ";", "$", "padding", "=", "count", "(", "$", "args", ")", ";", "foreach", "(", "$", "this", "->", "climate", "->", "arguments", "->", "toArray", "(", ")", "as", "$", "arg", ")", "{", "if", "(", "$", "arg", "===", "null", ")", "{", "--", "$", "padding", ";", "}", "}", "$", "argSize", "=", "count", "(", "$", "_SERVER", "[", "'argv'", "]", ")", "-", "$", "padding", "-", "1", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "argSize", ";", "$", "i", "++", ")", "{", "$", "args", "[", "'arg-'", ".", "$", "i", "]", "=", "[", "]", ";", "}", "$", "this", "->", "climate", "->", "arguments", "->", "add", "(", "$", "args", ")", ";", "$", "this", "->", "climate", "->", "arguments", "->", "parse", "(", "$", "_SERVER", "[", "'argv'", "]", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "return", "true", ";", "}" ]
Parse incoming arguments @return bool|void
[ "Parse", "incoming", "arguments" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Cli.php#L48-L88
akamai/AkamaiOPEN-edgegrid-php-client
src/Cli.php
Cli.executeCommand
protected function executeCommand() { static $methods = [ 'HEAD', 'GET', 'POST', 'PUT', 'DELETE' ]; \Akamai\Open\EdgeGrid\Client::setDebug(true); \Akamai\Open\EdgeGrid\Client::setVerbose(true); $args = $this->climate->arguments->all(); $client = new Client(); if ($this->climate->arguments->defined('auth-type')) { $auth = $this->climate->arguments->get('auth'); if ($this->climate->arguments->get('auth-type') === 'edgegrid' || (!$this->climate->arguments->defined('auth-type'))) { $section = 'default'; if ($this->climate->arguments->defined('auth')) { $section = (substr($auth, -1) === ':') ? substr($auth, 0, -1) : $auth; } $client = Client::createFromEdgeRcFile($section); } if (in_array($this->climate->arguments->get('auth-type'), ['basic', 'digest'])) { if (!$this->climate->arguments->defined('auth') || $this->climate->arguments->get('auth') === null) { $this->help(); return; } $auth = [ $auth, null, $this->climate->arguments->get('auth-type') ]; if (strpos(':', $auth[0]) !== false) { list($auth[0], $auth[1]) = explode(':', $auth[0]); } $client = new Client(['auth' => $auth]); } } $method = 'GET'; $options = []; $body = []; foreach ($args as $arg) { $value = $arg->value(); if (empty($value) || is_bool($value) || $arg->longPrefix()) { continue; } if (in_array(strtoupper($value), $methods)) { $method = $arg->value(); continue; } if (!isset($url) && preg_match('@^(http(s?)://|:).*$@', trim($value))) { $url = $value; if ($url{0} === ':') { $url = substr($url, 1); } continue; } $matches = []; if (preg_match('/^(?<key>.*?):=(?<file>@?)(?<value>.*?)$/', $value, $matches)) { if (!$value = $this->getArgValue($matches)) { return false; } $body[$matches['key']] = json_decode($value); continue; } if (preg_match('/^(?<header>.*?):(?<value>.*?)$/', $value, $matches) && !preg_match('@^http(s?)://@', $value)) { $options['headers'][$matches['header']] = $matches['value']; continue; } if (preg_match('/^(?<key>.*?)=(?<file>@?)(?<value>.*?)$/', $value, $matches)) { if (!$value = $this->getArgValue($matches)) { return false; } $body[$matches['key']] = $matches['value']; continue; } if (!isset($url)) { $url = $value; continue; } $this->help(); $this->climate->error('Unknown argument: ' . $value); return false; } $stdin = ''; $fp = fopen('php://stdin', 'rb'); if ($fp) { stream_set_blocking($fp, false); $stdin = fgets($fp); if (!empty(trim($stdin))) { while (!feof($fp)) { $stdin .= fgets($fp); } fclose($fp); } $stdin = rtrim($stdin); } if (!empty($stdin) && !empty($body)) { $this->help(); $this->climate->error( 'error: Request body (from stdin or a file) and request data (key=value) cannot be mixed.' ); return; } if (!empty($stdin)) { $body = $stdin; } if (count($body) && !$this->climate->arguments->defined('form')) { if (!isset($options['headers']['Content-Type'])) { $options['headers']['Content-Type'] = 'application/json'; } if (!isset($options['headers']['Accept'])) { $options['headers']['Accept'] = 'application/json'; } $options['body'] = (!is_string($body)) ? json_encode($body) : $body; } if (count($body) && $this->climate->arguments->defined('form')) { if (!isset($options['headers']['Content-Type'])) { $options['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'; } $options['body'] = (!is_string($body)) ? http_build_query($body, null, null, PHP_QUERY_RFC1738) : $body; } $options['allow_redirects'] = false; if ($this->climate->arguments->defined('follow')) { $options['allow_redirects'] = true; } return $client->request($method, $url, $options); }
php
protected function executeCommand() { static $methods = [ 'HEAD', 'GET', 'POST', 'PUT', 'DELETE' ]; \Akamai\Open\EdgeGrid\Client::setDebug(true); \Akamai\Open\EdgeGrid\Client::setVerbose(true); $args = $this->climate->arguments->all(); $client = new Client(); if ($this->climate->arguments->defined('auth-type')) { $auth = $this->climate->arguments->get('auth'); if ($this->climate->arguments->get('auth-type') === 'edgegrid' || (!$this->climate->arguments->defined('auth-type'))) { $section = 'default'; if ($this->climate->arguments->defined('auth')) { $section = (substr($auth, -1) === ':') ? substr($auth, 0, -1) : $auth; } $client = Client::createFromEdgeRcFile($section); } if (in_array($this->climate->arguments->get('auth-type'), ['basic', 'digest'])) { if (!$this->climate->arguments->defined('auth') || $this->climate->arguments->get('auth') === null) { $this->help(); return; } $auth = [ $auth, null, $this->climate->arguments->get('auth-type') ]; if (strpos(':', $auth[0]) !== false) { list($auth[0], $auth[1]) = explode(':', $auth[0]); } $client = new Client(['auth' => $auth]); } } $method = 'GET'; $options = []; $body = []; foreach ($args as $arg) { $value = $arg->value(); if (empty($value) || is_bool($value) || $arg->longPrefix()) { continue; } if (in_array(strtoupper($value), $methods)) { $method = $arg->value(); continue; } if (!isset($url) && preg_match('@^(http(s?)://|:).*$@', trim($value))) { $url = $value; if ($url{0} === ':') { $url = substr($url, 1); } continue; } $matches = []; if (preg_match('/^(?<key>.*?):=(?<file>@?)(?<value>.*?)$/', $value, $matches)) { if (!$value = $this->getArgValue($matches)) { return false; } $body[$matches['key']] = json_decode($value); continue; } if (preg_match('/^(?<header>.*?):(?<value>.*?)$/', $value, $matches) && !preg_match('@^http(s?)://@', $value)) { $options['headers'][$matches['header']] = $matches['value']; continue; } if (preg_match('/^(?<key>.*?)=(?<file>@?)(?<value>.*?)$/', $value, $matches)) { if (!$value = $this->getArgValue($matches)) { return false; } $body[$matches['key']] = $matches['value']; continue; } if (!isset($url)) { $url = $value; continue; } $this->help(); $this->climate->error('Unknown argument: ' . $value); return false; } $stdin = ''; $fp = fopen('php://stdin', 'rb'); if ($fp) { stream_set_blocking($fp, false); $stdin = fgets($fp); if (!empty(trim($stdin))) { while (!feof($fp)) { $stdin .= fgets($fp); } fclose($fp); } $stdin = rtrim($stdin); } if (!empty($stdin) && !empty($body)) { $this->help(); $this->climate->error( 'error: Request body (from stdin or a file) and request data (key=value) cannot be mixed.' ); return; } if (!empty($stdin)) { $body = $stdin; } if (count($body) && !$this->climate->arguments->defined('form')) { if (!isset($options['headers']['Content-Type'])) { $options['headers']['Content-Type'] = 'application/json'; } if (!isset($options['headers']['Accept'])) { $options['headers']['Accept'] = 'application/json'; } $options['body'] = (!is_string($body)) ? json_encode($body) : $body; } if (count($body) && $this->climate->arguments->defined('form')) { if (!isset($options['headers']['Content-Type'])) { $options['headers']['Content-Type'] = 'application/x-www-form-urlencoded; charset=utf-8'; } $options['body'] = (!is_string($body)) ? http_build_query($body, null, null, PHP_QUERY_RFC1738) : $body; } $options['allow_redirects'] = false; if ($this->climate->arguments->defined('follow')) { $options['allow_redirects'] = true; } return $client->request($method, $url, $options); }
[ "protected", "function", "executeCommand", "(", ")", "{", "static", "$", "methods", "=", "[", "'HEAD'", ",", "'GET'", ",", "'POST'", ",", "'PUT'", ",", "'DELETE'", "]", ";", "\\", "Akamai", "\\", "Open", "\\", "EdgeGrid", "\\", "Client", "::", "setDebug", "(", "true", ")", ";", "\\", "Akamai", "\\", "Open", "\\", "EdgeGrid", "\\", "Client", "::", "setVerbose", "(", "true", ")", ";", "$", "args", "=", "$", "this", "->", "climate", "->", "arguments", "->", "all", "(", ")", ";", "$", "client", "=", "new", "Client", "(", ")", ";", "if", "(", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'auth-type'", ")", ")", "{", "$", "auth", "=", "$", "this", "->", "climate", "->", "arguments", "->", "get", "(", "'auth'", ")", ";", "if", "(", "$", "this", "->", "climate", "->", "arguments", "->", "get", "(", "'auth-type'", ")", "===", "'edgegrid'", "||", "(", "!", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'auth-type'", ")", ")", ")", "{", "$", "section", "=", "'default'", ";", "if", "(", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'auth'", ")", ")", "{", "$", "section", "=", "(", "substr", "(", "$", "auth", ",", "-", "1", ")", "===", "':'", ")", "?", "substr", "(", "$", "auth", ",", "0", ",", "-", "1", ")", ":", "$", "auth", ";", "}", "$", "client", "=", "Client", "::", "createFromEdgeRcFile", "(", "$", "section", ")", ";", "}", "if", "(", "in_array", "(", "$", "this", "->", "climate", "->", "arguments", "->", "get", "(", "'auth-type'", ")", ",", "[", "'basic'", ",", "'digest'", "]", ")", ")", "{", "if", "(", "!", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'auth'", ")", "||", "$", "this", "->", "climate", "->", "arguments", "->", "get", "(", "'auth'", ")", "===", "null", ")", "{", "$", "this", "->", "help", "(", ")", ";", "return", ";", "}", "$", "auth", "=", "[", "$", "auth", ",", "null", ",", "$", "this", "->", "climate", "->", "arguments", "->", "get", "(", "'auth-type'", ")", "]", ";", "if", "(", "strpos", "(", "':'", ",", "$", "auth", "[", "0", "]", ")", "!==", "false", ")", "{", "list", "(", "$", "auth", "[", "0", "]", ",", "$", "auth", "[", "1", "]", ")", "=", "explode", "(", "':'", ",", "$", "auth", "[", "0", "]", ")", ";", "}", "$", "client", "=", "new", "Client", "(", "[", "'auth'", "=>", "$", "auth", "]", ")", ";", "}", "}", "$", "method", "=", "'GET'", ";", "$", "options", "=", "[", "]", ";", "$", "body", "=", "[", "]", ";", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "$", "value", "=", "$", "arg", "->", "value", "(", ")", ";", "if", "(", "empty", "(", "$", "value", ")", "||", "is_bool", "(", "$", "value", ")", "||", "$", "arg", "->", "longPrefix", "(", ")", ")", "{", "continue", ";", "}", "if", "(", "in_array", "(", "strtoupper", "(", "$", "value", ")", ",", "$", "methods", ")", ")", "{", "$", "method", "=", "$", "arg", "->", "value", "(", ")", ";", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "url", ")", "&&", "preg_match", "(", "'@^(http(s?)://|:).*$@'", ",", "trim", "(", "$", "value", ")", ")", ")", "{", "$", "url", "=", "$", "value", ";", "if", "(", "$", "url", "{", "0", "}", "===", "':'", ")", "{", "$", "url", "=", "substr", "(", "$", "url", ",", "1", ")", ";", "}", "continue", ";", "}", "$", "matches", "=", "[", "]", ";", "if", "(", "preg_match", "(", "'/^(?<key>.*?):=(?<file>@?)(?<value>.*?)$/'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "if", "(", "!", "$", "value", "=", "$", "this", "->", "getArgValue", "(", "$", "matches", ")", ")", "{", "return", "false", ";", "}", "$", "body", "[", "$", "matches", "[", "'key'", "]", "]", "=", "json_decode", "(", "$", "value", ")", ";", "continue", ";", "}", "if", "(", "preg_match", "(", "'/^(?<header>.*?):(?<value>.*?)$/'", ",", "$", "value", ",", "$", "matches", ")", "&&", "!", "preg_match", "(", "'@^http(s?)://@'", ",", "$", "value", ")", ")", "{", "$", "options", "[", "'headers'", "]", "[", "$", "matches", "[", "'header'", "]", "]", "=", "$", "matches", "[", "'value'", "]", ";", "continue", ";", "}", "if", "(", "preg_match", "(", "'/^(?<key>.*?)=(?<file>@?)(?<value>.*?)$/'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "if", "(", "!", "$", "value", "=", "$", "this", "->", "getArgValue", "(", "$", "matches", ")", ")", "{", "return", "false", ";", "}", "$", "body", "[", "$", "matches", "[", "'key'", "]", "]", "=", "$", "matches", "[", "'value'", "]", ";", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "url", ")", ")", "{", "$", "url", "=", "$", "value", ";", "continue", ";", "}", "$", "this", "->", "help", "(", ")", ";", "$", "this", "->", "climate", "->", "error", "(", "'Unknown argument: '", ".", "$", "value", ")", ";", "return", "false", ";", "}", "$", "stdin", "=", "''", ";", "$", "fp", "=", "fopen", "(", "'php://stdin'", ",", "'rb'", ")", ";", "if", "(", "$", "fp", ")", "{", "stream_set_blocking", "(", "$", "fp", ",", "false", ")", ";", "$", "stdin", "=", "fgets", "(", "$", "fp", ")", ";", "if", "(", "!", "empty", "(", "trim", "(", "$", "stdin", ")", ")", ")", "{", "while", "(", "!", "feof", "(", "$", "fp", ")", ")", "{", "$", "stdin", ".=", "fgets", "(", "$", "fp", ")", ";", "}", "fclose", "(", "$", "fp", ")", ";", "}", "$", "stdin", "=", "rtrim", "(", "$", "stdin", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "stdin", ")", "&&", "!", "empty", "(", "$", "body", ")", ")", "{", "$", "this", "->", "help", "(", ")", ";", "$", "this", "->", "climate", "->", "error", "(", "'error: Request body (from stdin or a file) and request data (key=value) cannot be mixed.'", ")", ";", "return", ";", "}", "if", "(", "!", "empty", "(", "$", "stdin", ")", ")", "{", "$", "body", "=", "$", "stdin", ";", "}", "if", "(", "count", "(", "$", "body", ")", "&&", "!", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'form'", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'headers'", "]", "[", "'Content-Type'", "]", ")", ")", "{", "$", "options", "[", "'headers'", "]", "[", "'Content-Type'", "]", "=", "'application/json'", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'headers'", "]", "[", "'Accept'", "]", ")", ")", "{", "$", "options", "[", "'headers'", "]", "[", "'Accept'", "]", "=", "'application/json'", ";", "}", "$", "options", "[", "'body'", "]", "=", "(", "!", "is_string", "(", "$", "body", ")", ")", "?", "json_encode", "(", "$", "body", ")", ":", "$", "body", ";", "}", "if", "(", "count", "(", "$", "body", ")", "&&", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'form'", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'headers'", "]", "[", "'Content-Type'", "]", ")", ")", "{", "$", "options", "[", "'headers'", "]", "[", "'Content-Type'", "]", "=", "'application/x-www-form-urlencoded; charset=utf-8'", ";", "}", "$", "options", "[", "'body'", "]", "=", "(", "!", "is_string", "(", "$", "body", ")", ")", "?", "http_build_query", "(", "$", "body", ",", "null", ",", "null", ",", "PHP_QUERY_RFC1738", ")", ":", "$", "body", ";", "}", "$", "options", "[", "'allow_redirects'", "]", "=", "false", ";", "if", "(", "$", "this", "->", "climate", "->", "arguments", "->", "defined", "(", "'follow'", ")", ")", "{", "$", "options", "[", "'allow_redirects'", "]", "=", "true", ";", "}", "return", "$", "client", "->", "request", "(", "$", "method", ",", "$", "url", ",", "$", "options", ")", ";", "}" ]
Execute the HTTP request @return mixed|\Psr\Http\Message\ResponseInterface
[ "Execute", "the", "HTTP", "request" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Cli.php#L95-L253
akamai/AkamaiOPEN-edgegrid-php-client
src/Cli.php
Cli.help
public function help() { $arguments = new \League\CLImate\Argument\Manager(); $arguments->description('Akamai {OPEN} Edgegrid Auth for PHP Client (v' .Client::VERSION. ')'); $arguments->add($this->getNamedArgs()); $arguments->usage($this->climate, $_SERVER['argv']); }
php
public function help() { $arguments = new \League\CLImate\Argument\Manager(); $arguments->description('Akamai {OPEN} Edgegrid Auth for PHP Client (v' .Client::VERSION. ')'); $arguments->add($this->getNamedArgs()); $arguments->usage($this->climate, $_SERVER['argv']); }
[ "public", "function", "help", "(", ")", "{", "$", "arguments", "=", "new", "\\", "League", "\\", "CLImate", "\\", "Argument", "\\", "Manager", "(", ")", ";", "$", "arguments", "->", "description", "(", "'Akamai {OPEN} Edgegrid Auth for PHP Client (v'", ".", "Client", "::", "VERSION", ".", "')'", ")", ";", "$", "arguments", "->", "add", "(", "$", "this", "->", "getNamedArgs", "(", ")", ")", ";", "$", "arguments", "->", "usage", "(", "$", "this", "->", "climate", ",", "$", "_SERVER", "[", "'argv'", "]", ")", ";", "}" ]
Display CLI help
[ "Display", "CLI", "help" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Cli.php#L258-L264
akamai/AkamaiOPEN-edgegrid-php-client
src/Cli.php
Cli.getArgValue
protected function getArgValue($matches) { $value = $matches['value']; if (!empty($matches['file'])) { if (!file_exists($matches['value']) || !is_readable($matches['value'])) { $this->climate->error('Unable to read input file: ' . $matches['value']); return false; } $value = file_get_contents($matches['value']); } return $value; }
php
protected function getArgValue($matches) { $value = $matches['value']; if (!empty($matches['file'])) { if (!file_exists($matches['value']) || !is_readable($matches['value'])) { $this->climate->error('Unable to read input file: ' . $matches['value']); return false; } $value = file_get_contents($matches['value']); } return $value; }
[ "protected", "function", "getArgValue", "(", "$", "matches", ")", "{", "$", "value", "=", "$", "matches", "[", "'value'", "]", ";", "if", "(", "!", "empty", "(", "$", "matches", "[", "'file'", "]", ")", ")", "{", "if", "(", "!", "file_exists", "(", "$", "matches", "[", "'value'", "]", ")", "||", "!", "is_readable", "(", "$", "matches", "[", "'value'", "]", ")", ")", "{", "$", "this", "->", "climate", "->", "error", "(", "'Unable to read input file: '", ".", "$", "matches", "[", "'value'", "]", ")", ";", "return", "false", ";", "}", "$", "value", "=", "file_get_contents", "(", "$", "matches", "[", "'value'", "]", ")", ";", "}", "return", "$", "value", ";", "}" ]
Get argument values @param $matches @return bool|string
[ "Get", "argument", "values" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Cli.php#L339-L351
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.requestAsync
public function requestAsync($method, $uri = null, array $options = []) { $options = $this->setRequestOptions($options); $query = parse_url($uri, PHP_URL_QUERY); if (!empty($query)) { $uri = substr($uri, 0, (strlen($query)+1) * -1); parse_str($query, $options['query']); } return parent::requestAsync($method, $uri, $options); }
php
public function requestAsync($method, $uri = null, array $options = []) { $options = $this->setRequestOptions($options); $query = parse_url($uri, PHP_URL_QUERY); if (!empty($query)) { $uri = substr($uri, 0, (strlen($query)+1) * -1); parse_str($query, $options['query']); } return parent::requestAsync($method, $uri, $options); }
[ "public", "function", "requestAsync", "(", "$", "method", ",", "$", "uri", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "this", "->", "setRequestOptions", "(", "$", "options", ")", ";", "$", "query", "=", "parse_url", "(", "$", "uri", ",", "PHP_URL_QUERY", ")", ";", "if", "(", "!", "empty", "(", "$", "query", ")", ")", "{", "$", "uri", "=", "substr", "(", "$", "uri", ",", "0", ",", "(", "strlen", "(", "$", "query", ")", "+", "1", ")", "*", "-", "1", ")", ";", "parse_str", "(", "$", "query", ",", "$", "options", "[", "'query'", "]", ")", ";", "}", "return", "parent", "::", "requestAsync", "(", "$", "method", ",", "$", "uri", ",", "$", "options", ")", ";", "}" ]
Make an Asynchronous request @param string $method @param string $uri @param array $options @return \GuzzleHttp\Promise\PromiseInterface @throws \GuzzleHttp\Exception\GuzzleException
[ "Make", "an", "Asynchronous", "request" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L126-L137
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.sendAsync
public function sendAsync(\Psr\Http\Message\RequestInterface $request, array $options = []) { $options = $this->setRequestOptions($options); return parent::sendAsync($request, $options); }
php
public function sendAsync(\Psr\Http\Message\RequestInterface $request, array $options = []) { $options = $this->setRequestOptions($options); return parent::sendAsync($request, $options); }
[ "public", "function", "sendAsync", "(", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "RequestInterface", "$", "request", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "$", "this", "->", "setRequestOptions", "(", "$", "options", ")", ";", "return", "parent", "::", "sendAsync", "(", "$", "request", ",", "$", "options", ")", ";", "}" ]
Send an Asynchronous HTTP request @param \Psr\Http\Message\RequestInterface $request The HTTP request @param array $options Request options @return \GuzzleHttp\Promise\PromiseInterface
[ "Send", "an", "Asynchronous", "HTTP", "request" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L147-L152
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setAuth
public function setAuth($client_token, $client_secret, $access_token) { $this->authentication->setAuth($client_token, $client_secret, $access_token); return $this; }
php
public function setAuth($client_token, $client_secret, $access_token) { $this->authentication->setAuth($client_token, $client_secret, $access_token); return $this; }
[ "public", "function", "setAuth", "(", "$", "client_token", ",", "$", "client_secret", ",", "$", "access_token", ")", "{", "$", "this", "->", "authentication", "->", "setAuth", "(", "$", "client_token", ",", "$", "client_secret", ",", "$", "access_token", ")", ";", "return", "$", "this", ";", "}" ]
Set Akamai {OPEN} Authentication Credentials @param string $client_token @param string $client_secret @param string $access_token @return $this
[ "Set", "Akamai", "{", "OPEN", "}", "Authentication", "Credentials" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L162-L167
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setHost
public function setHost($host) { if (substr($host, -1) === '/') { $host = substr($host, 0, -1); } $headers = $this->getConfig('headers'); $headers['Host'] = $host; $this->setConfigOption('headers', $headers); if (strpos('/', $host) === false) { $host = 'https://' . $host; } $this->setConfigOption('base_uri', $host); return $this; }
php
public function setHost($host) { if (substr($host, -1) === '/') { $host = substr($host, 0, -1); } $headers = $this->getConfig('headers'); $headers['Host'] = $host; $this->setConfigOption('headers', $headers); if (strpos('/', $host) === false) { $host = 'https://' . $host; } $this->setConfigOption('base_uri', $host); return $this; }
[ "public", "function", "setHost", "(", "$", "host", ")", "{", "if", "(", "substr", "(", "$", "host", ",", "-", "1", ")", "===", "'/'", ")", "{", "$", "host", "=", "substr", "(", "$", "host", ",", "0", ",", "-", "1", ")", ";", "}", "$", "headers", "=", "$", "this", "->", "getConfig", "(", "'headers'", ")", ";", "$", "headers", "[", "'Host'", "]", "=", "$", "host", ";", "$", "this", "->", "setConfigOption", "(", "'headers'", ",", "$", "headers", ")", ";", "if", "(", "strpos", "(", "'/'", ",", "$", "host", ")", "===", "false", ")", "{", "$", "host", "=", "'https://'", ".", "$", "host", ";", "}", "$", "this", "->", "setConfigOption", "(", "'base_uri'", ",", "$", "host", ")", ";", "return", "$", "this", ";", "}" ]
Set Request Host @param string $host @return $this
[ "Set", "Request", "Host" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L204-L220
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setLogger
public function setLogger( \Psr\Log\LoggerInterface $logger = null, $messageFormat = \GuzzleHttp\MessageFormatter::CLF ) { if ($logger === null) { $handler = new \Monolog\Handler\ErrorLogHandler(\Monolog\Handler\ErrorLogHandler::SAPI); $handler->setFormatter(new \Monolog\Formatter\LineFormatter('%message%')); $logger = new \Monolog\Logger('HTTP Log', [$handler]); } $formatter = new \GuzzleHttp\MessageFormatter($messageFormat); $handler = \GuzzleHttp\Middleware::log($logger, $formatter); $this->logger = $handler; $handlerStack = $this->getConfig('handler'); $this->setLogHandler($handlerStack, $handler); return $this; }
php
public function setLogger( \Psr\Log\LoggerInterface $logger = null, $messageFormat = \GuzzleHttp\MessageFormatter::CLF ) { if ($logger === null) { $handler = new \Monolog\Handler\ErrorLogHandler(\Monolog\Handler\ErrorLogHandler::SAPI); $handler->setFormatter(new \Monolog\Formatter\LineFormatter('%message%')); $logger = new \Monolog\Logger('HTTP Log', [$handler]); } $formatter = new \GuzzleHttp\MessageFormatter($messageFormat); $handler = \GuzzleHttp\Middleware::log($logger, $formatter); $this->logger = $handler; $handlerStack = $this->getConfig('handler'); $this->setLogHandler($handlerStack, $handler); return $this; }
[ "public", "function", "setLogger", "(", "\\", "Psr", "\\", "Log", "\\", "LoggerInterface", "$", "logger", "=", "null", ",", "$", "messageFormat", "=", "\\", "GuzzleHttp", "\\", "MessageFormatter", "::", "CLF", ")", "{", "if", "(", "$", "logger", "===", "null", ")", "{", "$", "handler", "=", "new", "\\", "Monolog", "\\", "Handler", "\\", "ErrorLogHandler", "(", "\\", "Monolog", "\\", "Handler", "\\", "ErrorLogHandler", "::", "SAPI", ")", ";", "$", "handler", "->", "setFormatter", "(", "new", "\\", "Monolog", "\\", "Formatter", "\\", "LineFormatter", "(", "'%message%'", ")", ")", ";", "$", "logger", "=", "new", "\\", "Monolog", "\\", "Logger", "(", "'HTTP Log'", ",", "[", "$", "handler", "]", ")", ";", "}", "$", "formatter", "=", "new", "\\", "GuzzleHttp", "\\", "MessageFormatter", "(", "$", "messageFormat", ")", ";", "$", "handler", "=", "\\", "GuzzleHttp", "\\", "Middleware", "::", "log", "(", "$", "logger", ",", "$", "formatter", ")", ";", "$", "this", "->", "logger", "=", "$", "handler", ";", "$", "handlerStack", "=", "$", "this", "->", "getConfig", "(", "'handler'", ")", ";", "$", "this", "->", "setLogHandler", "(", "$", "handlerStack", ",", "$", "handler", ")", ";", "return", "$", "this", ";", "}" ]
Set a PSR-3 compatible logger (or use monolog by default) @param \Psr\Log\LoggerInterface $logger @param string $messageFormat Message format @return $this
[ "Set", "a", "PSR", "-", "3", "compatible", "logger", "(", "or", "use", "monolog", "by", "default", ")" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L268-L287
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setSimpleLog
public function setSimpleLog($filename, $format = '{code}') { if ($this->logger && !($this->logger instanceof \Monolog\Logger)) { return false; } $handler = new \Monolog\Handler\StreamHandler($filename); $handler->setFormatter(new \Monolog\Formatter\LineFormatter('%message%')); $log = new \Monolog\Logger('HTTP Log', [$handler]); return $this->setLogger($log, $format); }
php
public function setSimpleLog($filename, $format = '{code}') { if ($this->logger && !($this->logger instanceof \Monolog\Logger)) { return false; } $handler = new \Monolog\Handler\StreamHandler($filename); $handler->setFormatter(new \Monolog\Formatter\LineFormatter('%message%')); $log = new \Monolog\Logger('HTTP Log', [$handler]); return $this->setLogger($log, $format); }
[ "public", "function", "setSimpleLog", "(", "$", "filename", ",", "$", "format", "=", "'{code}'", ")", "{", "if", "(", "$", "this", "->", "logger", "&&", "!", "(", "$", "this", "->", "logger", "instanceof", "\\", "Monolog", "\\", "Logger", ")", ")", "{", "return", "false", ";", "}", "$", "handler", "=", "new", "\\", "Monolog", "\\", "Handler", "\\", "StreamHandler", "(", "$", "filename", ")", ";", "$", "handler", "->", "setFormatter", "(", "new", "\\", "Monolog", "\\", "Formatter", "\\", "LineFormatter", "(", "'%message%'", ")", ")", ";", "$", "log", "=", "new", "\\", "Monolog", "\\", "Logger", "(", "'HTTP Log'", ",", "[", "$", "handler", "]", ")", ";", "return", "$", "this", "->", "setLogger", "(", "$", "log", ",", "$", "format", ")", ";", "}" ]
Add logger using a given filename/format @param string $filename @param string $format @return \Akamai\Open\EdgeGrid\Client|bool
[ "Add", "logger", "using", "a", "given", "filename", "/", "format" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L296-L307
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.createFromEdgeRcFile
public static function createFromEdgeRcFile($section = 'default', $path = null, array $config = []) { $auth = \Akamai\Open\EdgeGrid\Authentication::createFromEdgeRcFile($section, $path); if ($host = $auth->getHost()) { $config['base_uri'] = 'https://' . $host; } return new static($config, $auth); }
php
public static function createFromEdgeRcFile($section = 'default', $path = null, array $config = []) { $auth = \Akamai\Open\EdgeGrid\Authentication::createFromEdgeRcFile($section, $path); if ($host = $auth->getHost()) { $config['base_uri'] = 'https://' . $host; } return new static($config, $auth); }
[ "public", "static", "function", "createFromEdgeRcFile", "(", "$", "section", "=", "'default'", ",", "$", "path", "=", "null", ",", "array", "$", "config", "=", "[", "]", ")", "{", "$", "auth", "=", "\\", "Akamai", "\\", "Open", "\\", "EdgeGrid", "\\", "Authentication", "::", "createFromEdgeRcFile", "(", "$", "section", ",", "$", "path", ")", ";", "if", "(", "$", "host", "=", "$", "auth", "->", "getHost", "(", ")", ")", "{", "$", "config", "[", "'base_uri'", "]", "=", "'https://'", ".", "$", "host", ";", "}", "return", "new", "static", "(", "$", "config", ",", "$", "auth", ")", ";", "}" ]
Factory method to create a client using credentials from `.edgerc` Automatically checks your HOME directory, and the current working directory for credentials, if no path is supplied. @param string $section Credential section to use @param string $path Path to .edgerc credentials file @param array $config Options to pass to the constructor/guzzle @return \Akamai\Open\EdgeGrid\Client
[ "Factory", "method", "to", "create", "a", "client", "using", "credentials", "from", ".", "edgerc" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L350-L359
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.getDebugOption
protected function getDebugOption(array $config) { if (isset($config['debug'])) { return ($config['debug'] === true) ? fopen('php://stderr', 'ab') : $config['debug']; } if ($this->debugOverride && $this->debug) { return ($this->debug === true) ? fopen('php://stderr', 'ab') : $this->debug; } elseif (!$this->debugOverride && static::$staticDebug) { return (static::$staticDebug === true) ? fopen('php://stderr', 'ab') : static::$staticDebug; } return false; }
php
protected function getDebugOption(array $config) { if (isset($config['debug'])) { return ($config['debug'] === true) ? fopen('php://stderr', 'ab') : $config['debug']; } if ($this->debugOverride && $this->debug) { return ($this->debug === true) ? fopen('php://stderr', 'ab') : $this->debug; } elseif (!$this->debugOverride && static::$staticDebug) { return (static::$staticDebug === true) ? fopen('php://stderr', 'ab') : static::$staticDebug; } return false; }
[ "protected", "function", "getDebugOption", "(", "array", "$", "config", ")", "{", "if", "(", "isset", "(", "$", "config", "[", "'debug'", "]", ")", ")", "{", "return", "(", "$", "config", "[", "'debug'", "]", "===", "true", ")", "?", "fopen", "(", "'php://stderr'", ",", "'ab'", ")", ":", "$", "config", "[", "'debug'", "]", ";", "}", "if", "(", "$", "this", "->", "debugOverride", "&&", "$", "this", "->", "debug", ")", "{", "return", "(", "$", "this", "->", "debug", "===", "true", ")", "?", "fopen", "(", "'php://stderr'", ",", "'ab'", ")", ":", "$", "this", "->", "debug", ";", "}", "elseif", "(", "!", "$", "this", "->", "debugOverride", "&&", "static", "::", "$", "staticDebug", ")", "{", "return", "(", "static", "::", "$", "staticDebug", "===", "true", ")", "?", "fopen", "(", "'php://stderr'", ",", "'ab'", ")", ":", "static", "::", "$", "staticDebug", ";", "}", "return", "false", ";", "}" ]
Handle debug option @param array $config @return bool|resource
[ "Handle", "debug", "option" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L387-L400
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.isDebug
protected function isDebug() { if (($this->debugOverride && !$this->debug) || (!$this->debugOverride && !static::$staticDebug)) { return false; } if ($this->debugOverride && $this->debug) { return $this->debug; } return static::$staticDebug; }
php
protected function isDebug() { if (($this->debugOverride && !$this->debug) || (!$this->debugOverride && !static::$staticDebug)) { return false; } if ($this->debugOverride && $this->debug) { return $this->debug; } return static::$staticDebug; }
[ "protected", "function", "isDebug", "(", ")", "{", "if", "(", "(", "$", "this", "->", "debugOverride", "&&", "!", "$", "this", "->", "debug", ")", "||", "(", "!", "$", "this", "->", "debugOverride", "&&", "!", "static", "::", "$", "staticDebug", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "debugOverride", "&&", "$", "this", "->", "debug", ")", "{", "return", "$", "this", "->", "debug", ";", "}", "return", "static", "::", "$", "staticDebug", ";", "}" ]
Debugging status for the current request @return bool|resource
[ "Debugging", "status", "for", "the", "current", "request" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L407-L418
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.isVerbose
protected function isVerbose() { if (($this->verboseOverride && !$this->verbose) || (!$this->verboseOverride && !static::$staticVerbose)) { return false; } if ($this->verboseOverride && $this->verbose) { return $this->verbose; } return static::$staticVerbose; }
php
protected function isVerbose() { if (($this->verboseOverride && !$this->verbose) || (!$this->verboseOverride && !static::$staticVerbose)) { return false; } if ($this->verboseOverride && $this->verbose) { return $this->verbose; } return static::$staticVerbose; }
[ "protected", "function", "isVerbose", "(", ")", "{", "if", "(", "(", "$", "this", "->", "verboseOverride", "&&", "!", "$", "this", "->", "verbose", ")", "||", "(", "!", "$", "this", "->", "verboseOverride", "&&", "!", "static", "::", "$", "staticVerbose", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "verboseOverride", "&&", "$", "this", "->", "verbose", ")", "{", "return", "$", "this", "->", "verbose", ";", "}", "return", "static", "::", "$", "staticVerbose", ";", "}" ]
Verbose status for the current request @return array|bool|resource
[ "Verbose", "status", "for", "the", "current", "request" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L425-L436
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setAuthentication
protected function setAuthentication(array $config, Authentication $authentication = null) { $this->authentication = $authentication; if ($authentication === null) { $this->authentication = new Authentication(); } if (isset($config['timestamp'])) { $this->authentication->setTimestamp($config['timestamp']); } if (isset($config['nonce'])) { $this->authentication->setNonce($config['nonce']); } }
php
protected function setAuthentication(array $config, Authentication $authentication = null) { $this->authentication = $authentication; if ($authentication === null) { $this->authentication = new Authentication(); } if (isset($config['timestamp'])) { $this->authentication->setTimestamp($config['timestamp']); } if (isset($config['nonce'])) { $this->authentication->setNonce($config['nonce']); } }
[ "protected", "function", "setAuthentication", "(", "array", "$", "config", ",", "Authentication", "$", "authentication", "=", "null", ")", "{", "$", "this", "->", "authentication", "=", "$", "authentication", ";", "if", "(", "$", "authentication", "===", "null", ")", "{", "$", "this", "->", "authentication", "=", "new", "Authentication", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'timestamp'", "]", ")", ")", "{", "$", "this", "->", "authentication", "->", "setTimestamp", "(", "$", "config", "[", "'timestamp'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'nonce'", "]", ")", ")", "{", "$", "this", "->", "authentication", "->", "setNonce", "(", "$", "config", "[", "'nonce'", "]", ")", ";", "}", "}" ]
Set the Authentication instance @param array $config @param Authentication|null $authentication
[ "Set", "the", "Authentication", "instance" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L444-L458
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setAuthenticationHandler
protected function setAuthenticationHandler(array $config, Authentication $authentication = null) { $this->setAuthentication($config, $authentication); $authenticationHandler = new AuthenticationHandler(); $authenticationHandler->setSigner($this->authentication); if (!isset($config['handler'])) { $config['handler'] = \GuzzleHttp\HandlerStack::create(); } try { if (!($config['handler'] instanceof \GuzzleHttp\HandlerStack)) { $config['handler'] = \GuzzleHttp\HandlerStack::create($config['handler']); } $config['handler']->before('history', $authenticationHandler, 'authentication'); } catch (\InvalidArgumentException $e) { // history middleware not added yet $config['handler']->push($authenticationHandler, 'authentication'); } return $config; }
php
protected function setAuthenticationHandler(array $config, Authentication $authentication = null) { $this->setAuthentication($config, $authentication); $authenticationHandler = new AuthenticationHandler(); $authenticationHandler->setSigner($this->authentication); if (!isset($config['handler'])) { $config['handler'] = \GuzzleHttp\HandlerStack::create(); } try { if (!($config['handler'] instanceof \GuzzleHttp\HandlerStack)) { $config['handler'] = \GuzzleHttp\HandlerStack::create($config['handler']); } $config['handler']->before('history', $authenticationHandler, 'authentication'); } catch (\InvalidArgumentException $e) { // history middleware not added yet $config['handler']->push($authenticationHandler, 'authentication'); } return $config; }
[ "protected", "function", "setAuthenticationHandler", "(", "array", "$", "config", ",", "Authentication", "$", "authentication", "=", "null", ")", "{", "$", "this", "->", "setAuthentication", "(", "$", "config", ",", "$", "authentication", ")", ";", "$", "authenticationHandler", "=", "new", "AuthenticationHandler", "(", ")", ";", "$", "authenticationHandler", "->", "setSigner", "(", "$", "this", "->", "authentication", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'handler'", "]", ")", ")", "{", "$", "config", "[", "'handler'", "]", "=", "\\", "GuzzleHttp", "\\", "HandlerStack", "::", "create", "(", ")", ";", "}", "try", "{", "if", "(", "!", "(", "$", "config", "[", "'handler'", "]", "instanceof", "\\", "GuzzleHttp", "\\", "HandlerStack", ")", ")", "{", "$", "config", "[", "'handler'", "]", "=", "\\", "GuzzleHttp", "\\", "HandlerStack", "::", "create", "(", "$", "config", "[", "'handler'", "]", ")", ";", "}", "$", "config", "[", "'handler'", "]", "->", "before", "(", "'history'", ",", "$", "authenticationHandler", ",", "'authentication'", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "// history middleware not added yet", "$", "config", "[", "'handler'", "]", "->", "push", "(", "$", "authenticationHandler", ",", "'authentication'", ")", ";", "}", "return", "$", "config", ";", "}" ]
Set the Authentication Handler @param array $config @param Authentication|null $authentication @return array
[ "Set", "the", "Authentication", "Handler" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L467-L486
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setBasicOptions
protected function setBasicOptions(array $config) { if (!isset($config['timeout'])) { $config['timeout'] = static::DEFAULT_REQUEST_TIMEOUT; } if (isset($config['base_uri']) && strpos($config['base_uri'], 'http') === false) { $config['base_uri'] = 'https://' . $config['base_uri']; return $config; } return $config; }
php
protected function setBasicOptions(array $config) { if (!isset($config['timeout'])) { $config['timeout'] = static::DEFAULT_REQUEST_TIMEOUT; } if (isset($config['base_uri']) && strpos($config['base_uri'], 'http') === false) { $config['base_uri'] = 'https://' . $config['base_uri']; return $config; } return $config; }
[ "protected", "function", "setBasicOptions", "(", "array", "$", "config", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'timeout'", "]", ")", ")", "{", "$", "config", "[", "'timeout'", "]", "=", "static", "::", "DEFAULT_REQUEST_TIMEOUT", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'base_uri'", "]", ")", "&&", "strpos", "(", "$", "config", "[", "'base_uri'", "]", ",", "'http'", ")", "===", "false", ")", "{", "$", "config", "[", "'base_uri'", "]", "=", "'https://'", ".", "$", "config", "[", "'base_uri'", "]", ";", "return", "$", "config", ";", "}", "return", "$", "config", ";", "}" ]
Set timeout and base_uri options @param array $config @return mixed
[ "Set", "timeout", "and", "base_uri", "options" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L494-L505
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setConfigOption
protected function setConfigOption($what, $value) { $closure = function () use ($what, $value) { /* @var $this \GuzzleHttp\Client */ $this->config[$what] = $value; }; $closure = $closure->bindTo($this, \GuzzleHttp\Client::class); $closure(); }
php
protected function setConfigOption($what, $value) { $closure = function () use ($what, $value) { /* @var $this \GuzzleHttp\Client */ $this->config[$what] = $value; }; $closure = $closure->bindTo($this, \GuzzleHttp\Client::class); $closure(); }
[ "protected", "function", "setConfigOption", "(", "$", "what", ",", "$", "value", ")", "{", "$", "closure", "=", "function", "(", ")", "use", "(", "$", "what", ",", "$", "value", ")", "{", "/* @var $this \\GuzzleHttp\\Client */", "$", "this", "->", "config", "[", "$", "what", "]", "=", "$", "value", ";", "}", ";", "$", "closure", "=", "$", "closure", "->", "bindTo", "(", "$", "this", ",", "\\", "GuzzleHttp", "\\", "Client", "::", "class", ")", ";", "$", "closure", "(", ")", ";", "}" ]
Set values on the private \GuzzleHttp\Client->config This is a terrible hack, and illustrates why making anything private makes it difficult to extend, and impossible when there is no setter. @param string $what Config option to set @param mixed $value Value to set the option to @return void
[ "Set", "values", "on", "the", "private", "\\", "GuzzleHttp", "\\", "Client", "-", ">", "config" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L518-L527
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setDebugHandler
protected function setDebugHandler($options, $fp = null) { try { if (is_bool($fp)) { $fp = null; } $handler = $this->getConfig('handler'); // if we have a default handler, and we've already created a DebugHandler // we can bail out now (or we will add another one to the stack) if ($handler && $this->debugHandler) { return $options; } if (isset($options['handler'])) { $handler = $options['handler']; } if ($handler === null) { $handler = \GuzzleHttp\HandlerStack::create(); } if (!$this->debugHandler) { $this->debugHandler = new DebugHandler($fp); } $handler->after('allow_redirects', $this->debugHandler, 'debug'); } catch (\InvalidArgumentException $e) { $handler->push($this->debugHandler, 'debug'); } $options['handler'] = $handler; return $options; }
php
protected function setDebugHandler($options, $fp = null) { try { if (is_bool($fp)) { $fp = null; } $handler = $this->getConfig('handler'); // if we have a default handler, and we've already created a DebugHandler // we can bail out now (or we will add another one to the stack) if ($handler && $this->debugHandler) { return $options; } if (isset($options['handler'])) { $handler = $options['handler']; } if ($handler === null) { $handler = \GuzzleHttp\HandlerStack::create(); } if (!$this->debugHandler) { $this->debugHandler = new DebugHandler($fp); } $handler->after('allow_redirects', $this->debugHandler, 'debug'); } catch (\InvalidArgumentException $e) { $handler->push($this->debugHandler, 'debug'); } $options['handler'] = $handler; return $options; }
[ "protected", "function", "setDebugHandler", "(", "$", "options", ",", "$", "fp", "=", "null", ")", "{", "try", "{", "if", "(", "is_bool", "(", "$", "fp", ")", ")", "{", "$", "fp", "=", "null", ";", "}", "$", "handler", "=", "$", "this", "->", "getConfig", "(", "'handler'", ")", ";", "// if we have a default handler, and we've already created a DebugHandler", "// we can bail out now (or we will add another one to the stack)", "if", "(", "$", "handler", "&&", "$", "this", "->", "debugHandler", ")", "{", "return", "$", "options", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'handler'", "]", ")", ")", "{", "$", "handler", "=", "$", "options", "[", "'handler'", "]", ";", "}", "if", "(", "$", "handler", "===", "null", ")", "{", "$", "handler", "=", "\\", "GuzzleHttp", "\\", "HandlerStack", "::", "create", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "debugHandler", ")", "{", "$", "this", "->", "debugHandler", "=", "new", "DebugHandler", "(", "$", "fp", ")", ";", "}", "$", "handler", "->", "after", "(", "'allow_redirects'", ",", "$", "this", "->", "debugHandler", ",", "'debug'", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "$", "handler", "->", "push", "(", "$", "this", "->", "debugHandler", ",", "'debug'", ")", ";", "}", "$", "options", "[", "'handler'", "]", "=", "$", "handler", ";", "return", "$", "options", ";", "}" ]
Add the Debug handler to the HandlerStack @param array $options Guzzle Options @param bool|resource|null $fp Stream to write to @return array
[ "Add", "the", "Debug", "handler", "to", "the", "HandlerStack" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L536-L570
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setLogHandler
protected function setLogHandler(\GuzzleHttp\HandlerStack $handlerStack, callable $logHandler) { try { $handlerStack->after('history', $logHandler, 'logger'); } catch (\InvalidArgumentException $e) { try { $handlerStack->before('allow_redirects', $logHandler, 'logger'); } catch (\InvalidArgumentException $e) { $handlerStack->push($logHandler, 'logger'); } } return $this; }
php
protected function setLogHandler(\GuzzleHttp\HandlerStack $handlerStack, callable $logHandler) { try { $handlerStack->after('history', $logHandler, 'logger'); } catch (\InvalidArgumentException $e) { try { $handlerStack->before('allow_redirects', $logHandler, 'logger'); } catch (\InvalidArgumentException $e) { $handlerStack->push($logHandler, 'logger'); } } return $this; }
[ "protected", "function", "setLogHandler", "(", "\\", "GuzzleHttp", "\\", "HandlerStack", "$", "handlerStack", ",", "callable", "$", "logHandler", ")", "{", "try", "{", "$", "handlerStack", "->", "after", "(", "'history'", ",", "$", "logHandler", ",", "'logger'", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "try", "{", "$", "handlerStack", "->", "before", "(", "'allow_redirects'", ",", "$", "logHandler", ",", "'logger'", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "$", "handlerStack", "->", "push", "(", "$", "logHandler", ",", "'logger'", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Add the Log handler to the HandlerStack @param \GuzzleHttp\HandlerStack $handlerStack @param callable $logHandler @return $this
[ "Add", "the", "Log", "handler", "to", "the", "HandlerStack" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L579-L592
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setVerboseHandler
protected function setVerboseHandler($options, $fp = null) { try { if (is_bool($fp) || $fp === null) { $fp = ['outputStream' => null, 'errorStream' => null]; } elseif (!is_array($fp)) { $fp = ['outputStream' => $fp, 'errorStream' => $fp]; } $handler = $this->getConfig('handler'); // if we have a default handler, and we've already created a VerboseHandler // we can bail out now (or we will add another one to the stack) if ($handler && $this->verboseHandler) { return $options; } if (isset($options['handler'])) { $handler = $options['handler']; } if ($handler === null) { $handler = \GuzzleHttp\HandlerStack::create(); } if (!$this->verboseHandler) { $this->verboseHandler = new VerboseHandler(array_shift($fp), array_shift($fp)); } $handler->after('allow_redirects', $this->verboseHandler, 'verbose'); } catch (\InvalidArgumentException $e) { $handler->push($this->verboseHandler, 'verbose'); } $options['handler'] = $handler; return $options; }
php
protected function setVerboseHandler($options, $fp = null) { try { if (is_bool($fp) || $fp === null) { $fp = ['outputStream' => null, 'errorStream' => null]; } elseif (!is_array($fp)) { $fp = ['outputStream' => $fp, 'errorStream' => $fp]; } $handler = $this->getConfig('handler'); // if we have a default handler, and we've already created a VerboseHandler // we can bail out now (or we will add another one to the stack) if ($handler && $this->verboseHandler) { return $options; } if (isset($options['handler'])) { $handler = $options['handler']; } if ($handler === null) { $handler = \GuzzleHttp\HandlerStack::create(); } if (!$this->verboseHandler) { $this->verboseHandler = new VerboseHandler(array_shift($fp), array_shift($fp)); } $handler->after('allow_redirects', $this->verboseHandler, 'verbose'); } catch (\InvalidArgumentException $e) { $handler->push($this->verboseHandler, 'verbose'); } $options['handler'] = $handler; return $options; }
[ "protected", "function", "setVerboseHandler", "(", "$", "options", ",", "$", "fp", "=", "null", ")", "{", "try", "{", "if", "(", "is_bool", "(", "$", "fp", ")", "||", "$", "fp", "===", "null", ")", "{", "$", "fp", "=", "[", "'outputStream'", "=>", "null", ",", "'errorStream'", "=>", "null", "]", ";", "}", "elseif", "(", "!", "is_array", "(", "$", "fp", ")", ")", "{", "$", "fp", "=", "[", "'outputStream'", "=>", "$", "fp", ",", "'errorStream'", "=>", "$", "fp", "]", ";", "}", "$", "handler", "=", "$", "this", "->", "getConfig", "(", "'handler'", ")", ";", "// if we have a default handler, and we've already created a VerboseHandler", "// we can bail out now (or we will add another one to the stack)", "if", "(", "$", "handler", "&&", "$", "this", "->", "verboseHandler", ")", "{", "return", "$", "options", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'handler'", "]", ")", ")", "{", "$", "handler", "=", "$", "options", "[", "'handler'", "]", ";", "}", "if", "(", "$", "handler", "===", "null", ")", "{", "$", "handler", "=", "\\", "GuzzleHttp", "\\", "HandlerStack", "::", "create", "(", ")", ";", "}", "if", "(", "!", "$", "this", "->", "verboseHandler", ")", "{", "$", "this", "->", "verboseHandler", "=", "new", "VerboseHandler", "(", "array_shift", "(", "$", "fp", ")", ",", "array_shift", "(", "$", "fp", ")", ")", ";", "}", "$", "handler", "->", "after", "(", "'allow_redirects'", ",", "$", "this", "->", "verboseHandler", ",", "'verbose'", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "$", "handler", "->", "push", "(", "$", "this", "->", "verboseHandler", ",", "'verbose'", ")", ";", "}", "$", "options", "[", "'handler'", "]", "=", "$", "handler", ";", "return", "$", "options", ";", "}" ]
Add the Verbose handler to the HandlerStack @param array $options Guzzle Options @param bool|resource|array|null $fp Stream to write to @return array
[ "Add", "the", "Verbose", "handler", "to", "the", "HandlerStack" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L601-L637
akamai/AkamaiOPEN-edgegrid-php-client
src/Client.php
Client.setRequestOptions
protected function setRequestOptions(array $options) { if (isset($options['timestamp'])) { $this->authentication->setTimestamp($options['timestamp']); } elseif (!$this->getConfig('timestamp')) { $this->authentication->setTimestamp(); } if (isset($options['nonce'])) { $this->authentication->setNonce($options['nonce']); } if (isset($options['handler'])) { $options = $this->setAuthenticationHandler($options, $this->authentication); } if ($fp = $this->isVerbose()) { $options = $this->setVerboseHandler($options, $fp); } $options['debug'] = $this->getDebugOption($options); if ($fp = $this->isDebug()) { $options = $this->setDebugHandler($options, $fp); } if ($this->logger && isset($options['handler'])) { $this->setLogHandler($options['handler'], $this->logger); return $options; } return $options; }
php
protected function setRequestOptions(array $options) { if (isset($options['timestamp'])) { $this->authentication->setTimestamp($options['timestamp']); } elseif (!$this->getConfig('timestamp')) { $this->authentication->setTimestamp(); } if (isset($options['nonce'])) { $this->authentication->setNonce($options['nonce']); } if (isset($options['handler'])) { $options = $this->setAuthenticationHandler($options, $this->authentication); } if ($fp = $this->isVerbose()) { $options = $this->setVerboseHandler($options, $fp); } $options['debug'] = $this->getDebugOption($options); if ($fp = $this->isDebug()) { $options = $this->setDebugHandler($options, $fp); } if ($this->logger && isset($options['handler'])) { $this->setLogHandler($options['handler'], $this->logger); return $options; } return $options; }
[ "protected", "function", "setRequestOptions", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'timestamp'", "]", ")", ")", "{", "$", "this", "->", "authentication", "->", "setTimestamp", "(", "$", "options", "[", "'timestamp'", "]", ")", ";", "}", "elseif", "(", "!", "$", "this", "->", "getConfig", "(", "'timestamp'", ")", ")", "{", "$", "this", "->", "authentication", "->", "setTimestamp", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'nonce'", "]", ")", ")", "{", "$", "this", "->", "authentication", "->", "setNonce", "(", "$", "options", "[", "'nonce'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'handler'", "]", ")", ")", "{", "$", "options", "=", "$", "this", "->", "setAuthenticationHandler", "(", "$", "options", ",", "$", "this", "->", "authentication", ")", ";", "}", "if", "(", "$", "fp", "=", "$", "this", "->", "isVerbose", "(", ")", ")", "{", "$", "options", "=", "$", "this", "->", "setVerboseHandler", "(", "$", "options", ",", "$", "fp", ")", ";", "}", "$", "options", "[", "'debug'", "]", "=", "$", "this", "->", "getDebugOption", "(", "$", "options", ")", ";", "if", "(", "$", "fp", "=", "$", "this", "->", "isDebug", "(", ")", ")", "{", "$", "options", "=", "$", "this", "->", "setDebugHandler", "(", "$", "options", ",", "$", "fp", ")", ";", "}", "if", "(", "$", "this", "->", "logger", "&&", "isset", "(", "$", "options", "[", "'handler'", "]", ")", ")", "{", "$", "this", "->", "setLogHandler", "(", "$", "options", "[", "'handler'", "]", ",", "$", "this", "->", "logger", ")", ";", "return", "$", "options", ";", "}", "return", "$", "options", ";", "}" ]
Set request specific options @param array $options @return array
[ "Set", "request", "specific", "options" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Client.php#L645-L676
akamai/AkamaiOPEN-edgegrid-php-client
src/Handler/Authentication.php
Authentication.setSigner
public function setSigner(\Akamai\Open\EdgeGrid\Authentication $auth = null) { $this->signer = $auth; if ($this->signer === null) { $this->signer = new Signer(); } }
php
public function setSigner(\Akamai\Open\EdgeGrid\Authentication $auth = null) { $this->signer = $auth; if ($this->signer === null) { $this->signer = new Signer(); } }
[ "public", "function", "setSigner", "(", "\\", "Akamai", "\\", "Open", "\\", "EdgeGrid", "\\", "Authentication", "$", "auth", "=", "null", ")", "{", "$", "this", "->", "signer", "=", "$", "auth", ";", "if", "(", "$", "this", "->", "signer", "===", "null", ")", "{", "$", "this", "->", "signer", "=", "new", "Signer", "(", ")", ";", "}", "}" ]
Inject signer object @param Signer|null $auth
[ "Inject", "signer", "object" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Handler/Authentication.php#L50-L56
akamai/AkamaiOPEN-edgegrid-php-client
src/Handler/Authentication.php
Authentication.createFromEdgeRcFile
public static function createFromEdgeRcFile($section = 'default', $file = null) { $signer = Signer::createFromEdgeRcFile($section, $file); $auth = new static(); $auth->setSigner($signer); return $auth; }
php
public static function createFromEdgeRcFile($section = 'default', $file = null) { $signer = Signer::createFromEdgeRcFile($section, $file); $auth = new static(); $auth->setSigner($signer); return $auth; }
[ "public", "static", "function", "createFromEdgeRcFile", "(", "$", "section", "=", "'default'", ",", "$", "file", "=", "null", ")", "{", "$", "signer", "=", "Signer", "::", "createFromEdgeRcFile", "(", "$", "section", ",", "$", "file", ")", ";", "$", "auth", "=", "new", "static", "(", ")", ";", "$", "auth", "->", "setSigner", "(", "$", "signer", ")", ";", "return", "$", "auth", ";", "}" ]
Create Handler using an .edgerc file Automatically create a valid authentication handler using an .edgerc file @param string $section @param null $file @return static
[ "Create", "Handler", "using", "an", ".", "edgerc", "file" ]
train
https://github.com/akamai/AkamaiOPEN-edgegrid-php-client/blob/a368473f0f73fab96ffee03ee40d2f18694ff526/src/Handler/Authentication.php#L129-L136
edvinaskrucas/notification
src/Krucas/Notification/Collection.php
Collection.add
public function add(Message $message) { $this->queue->insert($message, is_null($message->getPosition()) ? null : -$message->getPosition()); $this->copyQueue(clone $this->queue); return $this; }
php
public function add(Message $message) { $this->queue->insert($message, is_null($message->getPosition()) ? null : -$message->getPosition()); $this->copyQueue(clone $this->queue); return $this; }
[ "public", "function", "add", "(", "Message", "$", "message", ")", "{", "$", "this", "->", "queue", "->", "insert", "(", "$", "message", ",", "is_null", "(", "$", "message", "->", "getPosition", "(", ")", ")", "?", "null", ":", "-", "$", "message", "->", "getPosition", "(", ")", ")", ";", "$", "this", "->", "copyQueue", "(", "clone", "$", "this", "->", "queue", ")", ";", "return", "$", "this", ";", "}" ]
Add message to collection. @param Message $message @return \Krucas\Notification\Collection
[ "Add", "message", "to", "collection", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Collection.php#L37-L44
edvinaskrucas/notification
src/Krucas/Notification/Collection.php
Collection.copyQueue
protected function copyQueue(\SplPriorityQueue $queue) { $this->items = []; foreach ($queue as $item) { $this->items[] = $item; } }
php
protected function copyQueue(\SplPriorityQueue $queue) { $this->items = []; foreach ($queue as $item) { $this->items[] = $item; } }
[ "protected", "function", "copyQueue", "(", "\\", "SplPriorityQueue", "$", "queue", ")", "{", "$", "this", "->", "items", "=", "[", "]", ";", "foreach", "(", "$", "queue", "as", "$", "item", ")", "{", "$", "this", "->", "items", "[", "]", "=", "$", "item", ";", "}", "}" ]
Copy queue items. @param \SplPriorityQueue $queue @return void
[ "Copy", "queue", "items", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Collection.php#L52-L59
edvinaskrucas/notification
src/Krucas/Notification/Collection.php
Collection.render
public function render() { $output = ''; foreach ($this->items as $message) { $output .= $message->render(); } return $output; }
php
public function render() { $output = ''; foreach ($this->items as $message) { $output .= $message->render(); } return $output; }
[ "public", "function", "render", "(", ")", "{", "$", "output", "=", "''", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "message", ")", "{", "$", "output", ".=", "$", "message", "->", "render", "(", ")", ";", "}", "return", "$", "output", ";", "}" ]
Get the evaluated contents of the object. @return string
[ "Get", "the", "evaluated", "contents", "of", "the", "object", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Collection.php#L66-L75
edvinaskrucas/notification
src/Krucas/Notification/Message.php
Message.render
public function render() { if (is_null($this->getMessage())) { return ''; } $message = htmlspecialchars($this->getMessage(), ENT_QUOTES, null, false); return str_replace([':message', ':type'], [$message, $this->getType()], $this->getFormat()); }
php
public function render() { if (is_null($this->getMessage())) { return ''; } $message = htmlspecialchars($this->getMessage(), ENT_QUOTES, null, false); return str_replace([':message', ':type'], [$message, $this->getType()], $this->getFormat()); }
[ "public", "function", "render", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "getMessage", "(", ")", ")", ")", "{", "return", "''", ";", "}", "$", "message", "=", "htmlspecialchars", "(", "$", "this", "->", "getMessage", "(", ")", ",", "ENT_QUOTES", ",", "null", ",", "false", ")", ";", "return", "str_replace", "(", "[", "':message'", ",", "':type'", "]", ",", "[", "$", "message", ",", "$", "this", "->", "getType", "(", ")", "]", ",", "$", "this", "->", "getFormat", "(", ")", ")", ";", "}" ]
Get the evaluated contents of the object. @return string
[ "Get", "the", "evaluated", "contents", "of", "the", "object", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Message.php#L255-L262
edvinaskrucas/notification
src/Krucas/Notification/Subscriber.php
Subscriber.onFlash
public function onFlash($eventName, array $data) { $this->validateEventData($data); list($notification, $notificationBag, $message) = $data; $key = implode('.', [$this->key, $notificationBag->getName()]); $this->session->push($key, $message); return true; }
php
public function onFlash($eventName, array $data) { $this->validateEventData($data); list($notification, $notificationBag, $message) = $data; $key = implode('.', [$this->key, $notificationBag->getName()]); $this->session->push($key, $message); return true; }
[ "public", "function", "onFlash", "(", "$", "eventName", ",", "array", "$", "data", ")", "{", "$", "this", "->", "validateEventData", "(", "$", "data", ")", ";", "list", "(", "$", "notification", ",", "$", "notificationBag", ",", "$", "message", ")", "=", "$", "data", ";", "$", "key", "=", "implode", "(", "'.'", ",", "[", "$", "this", "->", "key", ",", "$", "notificationBag", "->", "getName", "(", ")", "]", ")", ";", "$", "this", "->", "session", "->", "push", "(", "$", "key", ",", "$", "message", ")", ";", "return", "true", ";", "}" ]
Execute this event to flash messages. @param string $eventName @param array $data Event payload. Should be an array containing 3 elements: [ Notification, NotificationsBag, Message ] @return bool
[ "Execute", "this", "event", "to", "flash", "messages", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Subscriber.php#L61-L72
edvinaskrucas/notification
src/Krucas/Notification/Subscriber.php
Subscriber.validateEventData
private function validateEventData(array $data) { if ( ! array_key_exists(0, $data) || ! array_key_exists(1, $data) || ! array_key_exists(2, $data)) { throw new \InvalidArgumentException(sprintf( '%s expects 3 elements in data array, %s given.', sprintf('%s::onFlash', __CLASS__), count($data) )); } if ( ! $data[0] instanceof Notification || ! $data[1] instanceof NotificationsBag || ! $data[2] instanceof Message) { $expected = [Notification::class, NotificationsBag::class, Message::class]; $actual = array_map(function ($element) { return is_object($element) ? get_class($element) : '{' . gettype($element) . '}'; }, $data); throw new \InvalidArgumentException(sprintf( '%s expects a data array containing [%s], actually given [%s]', sprintf('%s::onFlash', __CLASS__), implode(', ', $expected), implode(', ', $actual) )); } }
php
private function validateEventData(array $data) { if ( ! array_key_exists(0, $data) || ! array_key_exists(1, $data) || ! array_key_exists(2, $data)) { throw new \InvalidArgumentException(sprintf( '%s expects 3 elements in data array, %s given.', sprintf('%s::onFlash', __CLASS__), count($data) )); } if ( ! $data[0] instanceof Notification || ! $data[1] instanceof NotificationsBag || ! $data[2] instanceof Message) { $expected = [Notification::class, NotificationsBag::class, Message::class]; $actual = array_map(function ($element) { return is_object($element) ? get_class($element) : '{' . gettype($element) . '}'; }, $data); throw new \InvalidArgumentException(sprintf( '%s expects a data array containing [%s], actually given [%s]', sprintf('%s::onFlash', __CLASS__), implode(', ', $expected), implode(', ', $actual) )); } }
[ "private", "function", "validateEventData", "(", "array", "$", "data", ")", "{", "if", "(", "!", "array_key_exists", "(", "0", ",", "$", "data", ")", "||", "!", "array_key_exists", "(", "1", ",", "$", "data", ")", "||", "!", "array_key_exists", "(", "2", ",", "$", "data", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s expects 3 elements in data array, %s given.'", ",", "sprintf", "(", "'%s::onFlash'", ",", "__CLASS__", ")", ",", "count", "(", "$", "data", ")", ")", ")", ";", "}", "if", "(", "!", "$", "data", "[", "0", "]", "instanceof", "Notification", "||", "!", "$", "data", "[", "1", "]", "instanceof", "NotificationsBag", "||", "!", "$", "data", "[", "2", "]", "instanceof", "Message", ")", "{", "$", "expected", "=", "[", "Notification", "::", "class", ",", "NotificationsBag", "::", "class", ",", "Message", "::", "class", "]", ";", "$", "actual", "=", "array_map", "(", "function", "(", "$", "element", ")", "{", "return", "is_object", "(", "$", "element", ")", "?", "get_class", "(", "$", "element", ")", ":", "'{'", ".", "gettype", "(", "$", "element", ")", ".", "'}'", ";", "}", ",", "$", "data", ")", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'%s expects a data array containing [%s], actually given [%s]'", ",", "sprintf", "(", "'%s::onFlash'", ",", "__CLASS__", ")", ",", "implode", "(", "', '", ",", "$", "expected", ")", ",", "implode", "(", "', '", ",", "$", "actual", ")", ")", ")", ";", "}", "}" ]
Validates that the correct event data has been passed to self::onFlash() Data array should have 3 elements with sequential keys: Notification, NotificationsBag and Message @param array $data @throws InvalidArgumentException If the event data is invalid.
[ "Validates", "that", "the", "correct", "event", "data", "has", "been", "passed", "to", "self", "::", "onFlash", "()" ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Subscriber.php#L93-L117
edvinaskrucas/notification
src/Krucas/Notification/NotificationServiceProvider.php
NotificationServiceProvider.boot
public function boot(Dispatcher $dispatcher) { $this->publishes(array( __DIR__ . '/../../config/notification.php' => config_path('notification.php'), ), 'config'); $dispatcher->subscribe('Krucas\Notification\Subscriber'); $this->app->afterResolving('blade.compiler', function ($bladeCompiler) { $bladeCompiler->directive('notification', function ($container = null) { if (strcasecmp('()', $container) === 0) { $container = null; } return "<?php echo app('notification')->container({$container})->show(); ?>"; }); }); }
php
public function boot(Dispatcher $dispatcher) { $this->publishes(array( __DIR__ . '/../../config/notification.php' => config_path('notification.php'), ), 'config'); $dispatcher->subscribe('Krucas\Notification\Subscriber'); $this->app->afterResolving('blade.compiler', function ($bladeCompiler) { $bladeCompiler->directive('notification', function ($container = null) { if (strcasecmp('()', $container) === 0) { $container = null; } return "<?php echo app('notification')->container({$container})->show(); ?>"; }); }); }
[ "public", "function", "boot", "(", "Dispatcher", "$", "dispatcher", ")", "{", "$", "this", "->", "publishes", "(", "array", "(", "__DIR__", ".", "'/../../config/notification.php'", "=>", "config_path", "(", "'notification.php'", ")", ",", ")", ",", "'config'", ")", ";", "$", "dispatcher", "->", "subscribe", "(", "'Krucas\\Notification\\Subscriber'", ")", ";", "$", "this", "->", "app", "->", "afterResolving", "(", "'blade.compiler'", ",", "function", "(", "$", "bladeCompiler", ")", "{", "$", "bladeCompiler", "->", "directive", "(", "'notification'", ",", "function", "(", "$", "container", "=", "null", ")", "{", "if", "(", "strcasecmp", "(", "'()'", ",", "$", "container", ")", "===", "0", ")", "{", "$", "container", "=", "null", ";", "}", "return", "\"<?php echo app('notification')->container({$container})->show(); ?>\"", ";", "}", ")", ";", "}", ")", ";", "}" ]
Bootstrap the application events. @param \Illuminate\Contracts\Events\Dispatcher $dispatcher @return void
[ "Bootstrap", "the", "application", "events", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationServiceProvider.php#L22-L39
edvinaskrucas/notification
src/Krucas/Notification/NotificationServiceProvider.php
NotificationServiceProvider.register
public function register() { $this->mergeConfigFrom(__DIR__ . '/../../config/notification.php', 'notification'); $this->app->singleton('notification', function ($app) { $config = $app['config']; $notification = new Notification( $config->get('notification.default_container'), $config->get('notification.default_types'), $config->get('notification.types'), $config->get('notification.default_format'), $config->get('notification.format'), $config->get('notification.default_formats'), $config->get('notification.formats') ); $notification->setEventDispatcher($app['events']); return $notification; }); $this->app->alias('notification', 'Krucas\Notification\Notification'); $this->app->singleton('Krucas\Notification\Subscriber', function ($app) { return new Subscriber($app['session.store'], $app['config']['notification.session_key']); }); $this->app->singleton('Krucas\Notification\Middleware\NotificationMiddleware', function ($app) { return new NotificationMiddleware( $app['session.store'], $app['notification'], $app['config']->get('notification.session_key') ); }); }
php
public function register() { $this->mergeConfigFrom(__DIR__ . '/../../config/notification.php', 'notification'); $this->app->singleton('notification', function ($app) { $config = $app['config']; $notification = new Notification( $config->get('notification.default_container'), $config->get('notification.default_types'), $config->get('notification.types'), $config->get('notification.default_format'), $config->get('notification.format'), $config->get('notification.default_formats'), $config->get('notification.formats') ); $notification->setEventDispatcher($app['events']); return $notification; }); $this->app->alias('notification', 'Krucas\Notification\Notification'); $this->app->singleton('Krucas\Notification\Subscriber', function ($app) { return new Subscriber($app['session.store'], $app['config']['notification.session_key']); }); $this->app->singleton('Krucas\Notification\Middleware\NotificationMiddleware', function ($app) { return new NotificationMiddleware( $app['session.store'], $app['notification'], $app['config']->get('notification.session_key') ); }); }
[ "public", "function", "register", "(", ")", "{", "$", "this", "->", "mergeConfigFrom", "(", "__DIR__", ".", "'/../../config/notification.php'", ",", "'notification'", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'notification'", ",", "function", "(", "$", "app", ")", "{", "$", "config", "=", "$", "app", "[", "'config'", "]", ";", "$", "notification", "=", "new", "Notification", "(", "$", "config", "->", "get", "(", "'notification.default_container'", ")", ",", "$", "config", "->", "get", "(", "'notification.default_types'", ")", ",", "$", "config", "->", "get", "(", "'notification.types'", ")", ",", "$", "config", "->", "get", "(", "'notification.default_format'", ")", ",", "$", "config", "->", "get", "(", "'notification.format'", ")", ",", "$", "config", "->", "get", "(", "'notification.default_formats'", ")", ",", "$", "config", "->", "get", "(", "'notification.formats'", ")", ")", ";", "$", "notification", "->", "setEventDispatcher", "(", "$", "app", "[", "'events'", "]", ")", ";", "return", "$", "notification", ";", "}", ")", ";", "$", "this", "->", "app", "->", "alias", "(", "'notification'", ",", "'Krucas\\Notification\\Notification'", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'Krucas\\Notification\\Subscriber'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Subscriber", "(", "$", "app", "[", "'session.store'", "]", ",", "$", "app", "[", "'config'", "]", "[", "'notification.session_key'", "]", ")", ";", "}", ")", ";", "$", "this", "->", "app", "->", "singleton", "(", "'Krucas\\Notification\\Middleware\\NotificationMiddleware'", ",", "function", "(", "$", "app", ")", "{", "return", "new", "NotificationMiddleware", "(", "$", "app", "[", "'session.store'", "]", ",", "$", "app", "[", "'notification'", "]", ",", "$", "app", "[", "'config'", "]", "->", "get", "(", "'notification.session_key'", ")", ")", ";", "}", ")", ";", "}" ]
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/NotificationServiceProvider.php#L46-L81
edvinaskrucas/notification
src/Krucas/Notification/Middleware/NotificationMiddleware.php
NotificationMiddleware.handle
public function handle($request, Closure $next) { $containers = $this->session->get($this->key, []); if (count($containers) > 0) { foreach ($containers as $name => $messages) { /** @var \Krucas\Notification\Message $message */ foreach ($messages as $message) { $this->notification->container($name)->add($message->getType(), $message, false); } } } $this->session->forget($this->key); return $next($request); }
php
public function handle($request, Closure $next) { $containers = $this->session->get($this->key, []); if (count($containers) > 0) { foreach ($containers as $name => $messages) { /** @var \Krucas\Notification\Message $message */ foreach ($messages as $message) { $this->notification->container($name)->add($message->getType(), $message, false); } } } $this->session->forget($this->key); return $next($request); }
[ "public", "function", "handle", "(", "$", "request", ",", "Closure", "$", "next", ")", "{", "$", "containers", "=", "$", "this", "->", "session", "->", "get", "(", "$", "this", "->", "key", ",", "[", "]", ")", ";", "if", "(", "count", "(", "$", "containers", ")", ">", "0", ")", "{", "foreach", "(", "$", "containers", "as", "$", "name", "=>", "$", "messages", ")", "{", "/** @var \\Krucas\\Notification\\Message $message */", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "$", "this", "->", "notification", "->", "container", "(", "$", "name", ")", "->", "add", "(", "$", "message", "->", "getType", "(", ")", ",", "$", "message", ",", "false", ")", ";", "}", "}", "}", "$", "this", "->", "session", "->", "forget", "(", "$", "this", "->", "key", ")", ";", "return", "$", "next", "(", "$", "request", ")", ";", "}" ]
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @return mixed
[ "Handle", "an", "incoming", "request", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Middleware/NotificationMiddleware.php#L43-L59
edvinaskrucas/notification
src/Krucas/Notification/Notification.php
Notification.getContainerTypes
public function getContainerTypes($container) { if (isset($this->types[$container])) { return $this->types[$container]; } return $this->defaultTypes; }
php
public function getContainerTypes($container) { if (isset($this->types[$container])) { return $this->types[$container]; } return $this->defaultTypes; }
[ "public", "function", "getContainerTypes", "(", "$", "container", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "types", "[", "$", "container", "]", ")", ")", "{", "return", "$", "this", "->", "types", "[", "$", "container", "]", ";", "}", "return", "$", "this", "->", "defaultTypes", ";", "}" ]
Return types for a container. @param $container @return array
[ "Return", "types", "for", "a", "container", "." ]
train
https://github.com/edvinaskrucas/notification/blob/f47205558171f5146fe6aa03da1c60ed2789f284/src/Krucas/Notification/Notification.php#L130-L137