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 |
|---|---|---|---|---|---|---|---|---|---|---|
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.getClonedNodes | protected function getClonedNodes()
{
$cloned_nodes = array();
foreach ($this->nodes as $node) {
$cloned_node = $node->cloneNode(true);
if ($cloned_node instanceof \DOMElement && $cloned_node->hasAttribute('dqn_tmp_id')) {
$cloned_node->removeAttribute('dqn_... | php | protected function getClonedNodes()
{
$cloned_nodes = array();
foreach ($this->nodes as $node) {
$cloned_node = $node->cloneNode(true);
if ($cloned_node instanceof \DOMElement && $cloned_node->hasAttribute('dqn_tmp_id')) {
$cloned_node->removeAttribute('dqn_... | [
"protected",
"function",
"getClonedNodes",
"(",
")",
"{",
"$",
"cloned_nodes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"cloned_node",
"=",
"$",
"node",
"->",
"cloneNode",
"(",
"true",
... | Return array with cloned nodes
@return \DOMNode[] | [
"Return",
"array",
"with",
"cloned",
"nodes"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L541-L556 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.xpathQuery | public function xpathQuery(string $expression, \DOMNode $context_node=null)
{
if ($this->dom_xpath) {
$node_list = $this->dom_xpath->query($expression, $context_node);
if ($node_list instanceof \DOMNodeList) {
return $node_list;
} elseif ($node_list === f... | php | public function xpathQuery(string $expression, \DOMNode $context_node=null)
{
if ($this->dom_xpath) {
$node_list = $this->dom_xpath->query($expression, $context_node);
if ($node_list instanceof \DOMNodeList) {
return $node_list;
} elseif ($node_list === f... | [
"public",
"function",
"xpathQuery",
"(",
"string",
"$",
"expression",
",",
"\\",
"DOMNode",
"$",
"context_node",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dom_xpath",
")",
"{",
"$",
"node_list",
"=",
"$",
"this",
"->",
"dom_xpath",
"->",
"q... | Perform query via xpath expression (using DOMXPath::query)
@param string $expression
@param \DOMNode|null $context_node
@return \DOMNodeList|false
@throws \Exception | [
"Perform",
"query",
"via",
"xpath",
"expression",
"(",
"using",
"DOMXPath",
"::",
"query",
")"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L651-L666 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.createDomXpath | private function createDomXpath()
{
$xpath = new \DOMXPath($this->document);
if ($this->xml_mode) { // register all name spaces
foreach ($xpath->query('namespace::*') as $node) {
if ($node->prefix !== 'xml') {
$xpath->registerNamespace($node->prefix, ... | php | private function createDomXpath()
{
$xpath = new \DOMXPath($this->document);
if ($this->xml_mode) { // register all name spaces
foreach ($xpath->query('namespace::*') as $node) {
if ($node->prefix !== 'xml') {
$xpath->registerNamespace($node->prefix, ... | [
"private",
"function",
"createDomXpath",
"(",
")",
"{",
"$",
"xpath",
"=",
"new",
"\\",
"DOMXPath",
"(",
"$",
"this",
"->",
"document",
")",
";",
"if",
"(",
"$",
"this",
"->",
"xml_mode",
")",
"{",
"// register all name spaces",
"foreach",
"(",
"$",
"xpa... | Create dom xpath instance
@return \DOMXPath | [
"Create",
"dom",
"xpath",
"instance"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L673-L686 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.getOuterHtml | public function getOuterHtml()
{
$outer_html = '';
if ($this->xml_mode && $this->xml_print_pi) {
$outer_html .= '<?xml version="'.$this->document->xmlVersion.'" encoding="'.$this->document->xmlEncoding.'"?>';
$outer_html .= "\n\n";
}
foreach ($this->nodes as... | php | public function getOuterHtml()
{
$outer_html = '';
if ($this->xml_mode && $this->xml_print_pi) {
$outer_html .= '<?xml version="'.$this->document->xmlVersion.'" encoding="'.$this->document->xmlEncoding.'"?>';
$outer_html .= "\n\n";
}
foreach ($this->nodes as... | [
"public",
"function",
"getOuterHtml",
"(",
")",
"{",
"$",
"outer_html",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"xml_mode",
"&&",
"$",
"this",
"->",
"xml_print_pi",
")",
"{",
"$",
"outer_html",
".=",
"'<?xml version=\"'",
".",
"$",
"this",
"->",
... | Return html of all nodes (HTML fragment describing all the elements, including their descendants)
@return string | [
"Return",
"html",
"of",
"all",
"nodes",
"(",
"HTML",
"fragment",
"describing",
"all",
"the",
"elements",
"including",
"their",
"descendants",
")"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L713-L735 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.getElementId | public static function getElementId(\DOMElement $node)
{
if ($node->hasAttribute('dqn_tmp_id')) {
return $node->getAttribute('dqn_tmp_id');
}
$node_id = md5(mt_rand());
$node->setAttribute('dqn_tmp_id', $node_id);
return $node_id;
} | php | public static function getElementId(\DOMElement $node)
{
if ($node->hasAttribute('dqn_tmp_id')) {
return $node->getAttribute('dqn_tmp_id');
}
$node_id = md5(mt_rand());
$node->setAttribute('dqn_tmp_id', $node_id);
return $node_id;
} | [
"public",
"static",
"function",
"getElementId",
"(",
"\\",
"DOMElement",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"hasAttribute",
"(",
"'dqn_tmp_id'",
")",
")",
"{",
"return",
"$",
"node",
"->",
"getAttribute",
"(",
"'dqn_tmp_id'",
")",
";",
... | Get id for node
@param \DOMElement $node
@return string $node_id | [
"Get",
"id",
"for",
"node"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L744-L753 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.handleHtmlResult | private function handleHtmlResult($html)
{
if ($this->preserve_no_newlines) {
$html = str_replace("\n", '', $html);
}
if (stripos($html, 'dqn_tmp_id=') !== false) {
$html = preg_replace('/ dqn_tmp_id="([a-z0-9]+)"/', '', $html);
}
return $html;
} | php | private function handleHtmlResult($html)
{
if ($this->preserve_no_newlines) {
$html = str_replace("\n", '', $html);
}
if (stripos($html, 'dqn_tmp_id=') !== false) {
$html = preg_replace('/ dqn_tmp_id="([a-z0-9]+)"/', '', $html);
}
return $html;
} | [
"private",
"function",
"handleHtmlResult",
"(",
"$",
"html",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"preserve_no_newlines",
")",
"{",
"$",
"html",
"=",
"str_replace",
"(",
"\"\\n\"",
",",
"''",
",",
"$",
"html",
")",
";",
"}",
"if",
"(",
"stripos",
... | Handle html when resulting html is requested
@param string $html
@return string | [
"Handle",
"html",
"when",
"resulting",
"html",
"is",
"requested"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L762-L772 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.getInnerHtml | public function getInnerHtml()
{
$html = '';
if ($content_node = $this->getFirstElmNode()) {
$document = $content_node->ownerDocument;
foreach ($content_node->childNodes as $node) {
if ($this->xml_mode) {
$html .= $document->saveXML($node)... | php | public function getInnerHtml()
{
$html = '';
if ($content_node = $this->getFirstElmNode()) {
$document = $content_node->ownerDocument;
foreach ($content_node->childNodes as $node) {
if ($this->xml_mode) {
$html .= $document->saveXML($node)... | [
"public",
"function",
"getInnerHtml",
"(",
")",
"{",
"$",
"html",
"=",
"''",
";",
"if",
"(",
"$",
"content_node",
"=",
"$",
"this",
"->",
"getFirstElmNode",
"(",
")",
")",
"{",
"$",
"document",
"=",
"$",
"content_node",
"->",
"ownerDocument",
";",
"for... | Get the HTML contents of the first element in the set of matched elements.
@return string | [
"Get",
"the",
"HTML",
"contents",
"of",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L779-L797 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.getIterator | public function getIterator()
{
$iteration_result = array();
if (\is_array($this->nodes)) {
foreach ($this->nodes as $node) {
$iteration_result[] = $this->createChildInstance($node);
}
}
return new \ArrayIterator($iteration_result);
} | php | public function getIterator()
{
$iteration_result = array();
if (\is_array($this->nodes)) {
foreach ($this->nodes as $node) {
$iteration_result[] = $this->createChildInstance($node);
}
}
return new \ArrayIterator($iteration_result);
} | [
"public",
"function",
"getIterator",
"(",
")",
"{",
"$",
"iteration_result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"nodes",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")... | IteratorAggregate (note: using Iterator conflicts with next method in jquery)
@return \ArrayIterator containing nodes as instances of DomQuery | [
"IteratorAggregate",
"(",
"note",
":",
"using",
"Iterator",
"conflicts",
"with",
"next",
"method",
"in",
"jquery",
")"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L814-L824 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQueryNodes.php | DomQueryNodes.offsetGet | public function offsetGet($key)
{
if (!\is_int($key)) {
throw new \BadMethodCallException('Attempting to access node list with non-integer');
}
if (isset($this->nodes[$key])) {
return $this->createChildInstance($this->nodes[$key]);
}
return $this->cr... | php | public function offsetGet($key)
{
if (!\is_int($key)) {
throw new \BadMethodCallException('Attempting to access node list with non-integer');
}
if (isset($this->nodes[$key])) {
return $this->createChildInstance($this->nodes[$key]);
}
return $this->cr... | [
"public",
"function",
"offsetGet",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"\\",
"is_int",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"BadMethodCallException",
"(",
"'Attempting to access node list with non-integer'",
")",
";",
"}",
"if",
"(",
... | ArrayAccess: get offset
@param mixed $key
@return static | [
"ArrayAccess",
":",
"get",
"offset"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQueryNodes.php#L845-L856 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.text | public function text($val=null)
{
if ($val !== null) { // set node value for all nodes
foreach ($this->nodes as $node) {
$node->nodeValue = $val;
}
return $this;
}
if ($node = $this->getFirstElmNode()) { // get value for first node
... | php | public function text($val=null)
{
if ($val !== null) { // set node value for all nodes
foreach ($this->nodes as $node) {
$node->nodeValue = $val;
}
return $this;
}
if ($node = $this->getFirstElmNode()) { // get value for first node
... | [
"public",
"function",
"text",
"(",
"$",
"val",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"val",
"!==",
"null",
")",
"{",
"// set node value for all nodes",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"node... | Get the combined text contents of each element in the set of matched elements, including their descendants,
or set the text contents of the matched elements.
@param string|null $val
@return $this|string|null | [
"Get",
"the",
"combined",
"text",
"contents",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"including",
"their",
"descendants",
"or",
"set",
"the",
"text",
"contents",
"of",
"the",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L27-L39 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.html | public function html($html_string=null)
{
if ($html_string !== null) { // set html for all nodes
foreach ($this as $node) {
$node->get(0)->nodeValue = '';
$node->append($html_string);
}
return $this;
}
// get html for first... | php | public function html($html_string=null)
{
if ($html_string !== null) { // set html for all nodes
foreach ($this as $node) {
$node->get(0)->nodeValue = '';
$node->append($html_string);
}
return $this;
}
// get html for first... | [
"public",
"function",
"html",
"(",
"$",
"html_string",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"html_string",
"!==",
"null",
")",
"{",
"// set html for all nodes",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
")",
"{",
"$",
"node",
"->",
"get",
"(",
... | Get the HTML contents of the first element in the set of matched elements
@param string|null $html_string
@return $this|string | [
"Get",
"the",
"HTML",
"contents",
"of",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L48-L60 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.attr | public function attr(string $name, $val=null)
{
if ($val !== null) { // set attribute for all nodes
foreach ($this->getElements() as $node) {
$node->setAttribute($name, $val);
}
return $this;
}
if ($node = $this->getFirstElmNode()) { // get... | php | public function attr(string $name, $val=null)
{
if ($val !== null) { // set attribute for all nodes
foreach ($this->getElements() as $node) {
$node->setAttribute($name, $val);
}
return $this;
}
if ($node = $this->getFirstElmNode()) { // get... | [
"public",
"function",
"attr",
"(",
"string",
"$",
"name",
",",
"$",
"val",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"val",
"!==",
"null",
")",
"{",
"// set attribute for all nodes",
"foreach",
"(",
"$",
"this",
"->",
"getElements",
"(",
")",
"as",
"$",
... | Get the value of an attribute for the first element in the set of matched elements
or set one or more attributes for every matched element.
@param string $name
@param string $val
@return $this|string|null | [
"Get",
"the",
"value",
"of",
"an",
"attribute",
"for",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"or",
"set",
"one",
"or",
"more",
"attributes",
"for",
"every",
"matched",
"element",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L71-L82 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.data | public function data(string $key=null, $val=null)
{
$doc_hash = spl_object_hash($this->document);
if ($val !== null) { // set data for all nodes
if (!isset(self::$node_data[$doc_hash])) {
self::$node_data[$doc_hash] = array();
}
foreach ($this->ge... | php | public function data(string $key=null, $val=null)
{
$doc_hash = spl_object_hash($this->document);
if ($val !== null) { // set data for all nodes
if (!isset(self::$node_data[$doc_hash])) {
self::$node_data[$doc_hash] = array();
}
foreach ($this->ge... | [
"public",
"function",
"data",
"(",
"string",
"$",
"key",
"=",
"null",
",",
"$",
"val",
"=",
"null",
")",
"{",
"$",
"doc_hash",
"=",
"spl_object_hash",
"(",
"$",
"this",
"->",
"document",
")",
";",
"if",
"(",
"$",
"val",
"!==",
"null",
")",
"{",
"... | Store arbitrary data associated with the matched elements or return the value at
the named data store for the first element in the set of matched elements.
@param string $key
@param $val
@return $this|string|object | [
"Store",
"arbitrary",
"data",
"associated",
"with",
"the",
"matched",
"elements",
"or",
"return",
"the",
"value",
"at",
"the",
"named",
"data",
"store",
"for",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L93-L133 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.removeData | public function removeData($name=null)
{
$remove_names = \is_array($name) ? $name : explode(' ', $name);
$doc_hash = spl_object_hash($this->document);
if (!isset(self::$node_data[$doc_hash])) {
return;
}
foreach ($this->getElements() as $node) {
if (... | php | public function removeData($name=null)
{
$remove_names = \is_array($name) ? $name : explode(' ', $name);
$doc_hash = spl_object_hash($this->document);
if (!isset(self::$node_data[$doc_hash])) {
return;
}
foreach ($this->getElements() as $node) {
if (... | [
"public",
"function",
"removeData",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"remove_names",
"=",
"\\",
"is_array",
"(",
"$",
"name",
")",
"?",
"$",
"name",
":",
"explode",
"(",
"' '",
",",
"$",
"name",
")",
";",
"$",
"doc_hash",
"=",
"spl_obj... | Remove a previously-stored piece of data.
@param string|string[] $name
@return void | [
"Remove",
"a",
"previously",
"-",
"stored",
"piece",
"of",
"data",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L142-L170 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.css | public function css(string $name, $val=null)
{
if ($val !== null) { // set css for all nodes
foreach ($this->getElements() as $node) {
$style = self::parseStyle($node->getAttribute('style'));
$style[$name] = $val;
$node->setAttribute('style', self:... | php | public function css(string $name, $val=null)
{
if ($val !== null) { // set css for all nodes
foreach ($this->getElements() as $node) {
$style = self::parseStyle($node->getAttribute('style'));
$style[$name] = $val;
$node->setAttribute('style', self:... | [
"public",
"function",
"css",
"(",
"string",
"$",
"name",
",",
"$",
"val",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"val",
"!==",
"null",
")",
"{",
"// set css for all nodes",
"foreach",
"(",
"$",
"this",
"->",
"getElements",
"(",
")",
"as",
"$",
"node"... | Get the value of a computed style property for the first element in the set of matched elements
or set one or more CSS properties for every matched element.
@param string $name
@param string $val
@return $this|string | [
"Get",
"the",
"value",
"of",
"a",
"computed",
"style",
"property",
"for",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"or",
"set",
"one",
"or",
"more",
"CSS",
"properties",
"for",
"every",
"matched",
"element",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L220-L236 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.removeAttr | public function removeAttr($name)
{
$remove_names = \is_array($name) ? $name : explode(' ', $name);
foreach ($this->getElements() as $node) {
foreach ($remove_names as $remove_name) {
$node->removeAttribute($remove_name);
}
}
return $this;
... | php | public function removeAttr($name)
{
$remove_names = \is_array($name) ? $name : explode(' ', $name);
foreach ($this->getElements() as $node) {
foreach ($remove_names as $remove_name) {
$node->removeAttribute($remove_name);
}
}
return $this;
... | [
"public",
"function",
"removeAttr",
"(",
"$",
"name",
")",
"{",
"$",
"remove_names",
"=",
"\\",
"is_array",
"(",
"$",
"name",
")",
"?",
"$",
"name",
":",
"explode",
"(",
"' '",
",",
"$",
"name",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getElem... | Remove an attribute from each element in the set of matched elements.
Name can be a space-separated list of attributes.
@param string|string[] $name
@return $this | [
"Remove",
"an",
"attribute",
"from",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
".",
"Name",
"can",
"be",
"a",
"space",
"-",
"separated",
"list",
"of",
"attributes",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L246-L257 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.addClass | public function addClass($class_name)
{
$add_names = \is_array($class_name) ? $class_name : explode(' ', $class_name);
foreach ($this->getElements() as $node) {
$node_classes = array();
if ($node_class_attr = $node->getAttribute('class')) {
$node_classes = ex... | php | public function addClass($class_name)
{
$add_names = \is_array($class_name) ? $class_name : explode(' ', $class_name);
foreach ($this->getElements() as $node) {
$node_classes = array();
if ($node_class_attr = $node->getAttribute('class')) {
$node_classes = ex... | [
"public",
"function",
"addClass",
"(",
"$",
"class_name",
")",
"{",
"$",
"add_names",
"=",
"\\",
"is_array",
"(",
"$",
"class_name",
")",
"?",
"$",
"class_name",
":",
"explode",
"(",
"' '",
",",
"$",
"class_name",
")",
";",
"foreach",
"(",
"$",
"this",... | Adds the specified class(es) to each element in the set of matched elements.
@param string|string[] $class_name class name(s)
@return $this | [
"Adds",
"the",
"specified",
"class",
"(",
"es",
")",
"to",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L266-L286 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.hasClass | public function hasClass($class_name)
{
foreach ($this->nodes as $node) {
if ($node instanceof \DOMElement && $node_class_attr = $node->getAttribute('class')) {
$node_classes = explode(' ', $node_class_attr);
if (\in_array($class_name, $node_classes, true)) {
... | php | public function hasClass($class_name)
{
foreach ($this->nodes as $node) {
if ($node instanceof \DOMElement && $node_class_attr = $node->getAttribute('class')) {
$node_classes = explode(' ', $node_class_attr);
if (\in_array($class_name, $node_classes, true)) {
... | [
"public",
"function",
"hasClass",
"(",
"$",
"class_name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"\\",
"DOMElement",
"&&",
"$",
"node_class_attr",
"=",
"$",
"node",
"->",... | Determine whether any of the matched elements are assigned the given class.
@param string $class_name
@return boolean | [
"Determine",
"whether",
"any",
"of",
"the",
"matched",
"elements",
"are",
"assigned",
"the",
"given",
"class",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L295-L307 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.removeClass | public function removeClass($class_name='')
{
$remove_names = \is_array($class_name) ? $class_name : explode(' ', $class_name);
foreach ($this->nodes as $node) {
if ($node instanceof \DOMElement && $node->hasAttribute('class')) {
$node_classes = preg_split('#\s+#s', $nod... | php | public function removeClass($class_name='')
{
$remove_names = \is_array($class_name) ? $class_name : explode(' ', $class_name);
foreach ($this->nodes as $node) {
if ($node instanceof \DOMElement && $node->hasAttribute('class')) {
$node_classes = preg_split('#\s+#s', $nod... | [
"public",
"function",
"removeClass",
"(",
"$",
"class_name",
"=",
"''",
")",
"{",
"$",
"remove_names",
"=",
"\\",
"is_array",
"(",
"$",
"class_name",
")",
"?",
"$",
"class_name",
":",
"explode",
"(",
"' '",
",",
"$",
"class_name",
")",
";",
"foreach",
... | Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
@param string|string[] $class_name
@return $this | [
"Remove",
"a",
"single",
"class",
"multiple",
"classes",
"or",
"all",
"classes",
"from",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L316-L344 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.toggleClass | public function toggleClass($class_name='')
{
$toggle_names = \is_array($class_name) ? $class_name : explode(' ', $class_name);
foreach ($this as $node) {
foreach ($toggle_names as $toggle_class) {
if (!$node->hasClass($toggle_class)) {
$node->addClas... | php | public function toggleClass($class_name='')
{
$toggle_names = \is_array($class_name) ? $class_name : explode(' ', $class_name);
foreach ($this as $node) {
foreach ($toggle_names as $toggle_class) {
if (!$node->hasClass($toggle_class)) {
$node->addClas... | [
"public",
"function",
"toggleClass",
"(",
"$",
"class_name",
"=",
"''",
")",
"{",
"$",
"toggle_names",
"=",
"\\",
"is_array",
"(",
"$",
"class_name",
")",
"?",
"$",
"class_name",
":",
"explode",
"(",
"' '",
",",
"$",
"class_name",
")",
";",
"foreach",
... | Remove a single class, multiple classes, or all classes from each element in the set of matched elements.
@param string|string[] $class_name
@return $this | [
"Remove",
"a",
"single",
"class",
"multiple",
"classes",
"or",
"all",
"classes",
"from",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L353-L368 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.prop | public function prop(string $name, $val=null)
{
if ($val !== null) { // set attribute for all nodes
foreach ($this->nodes as $node) {
$node->$name = $val;
}
return $this;
}
// get property value for first element
if ($name === 'out... | php | public function prop(string $name, $val=null)
{
if ($val !== null) { // set attribute for all nodes
foreach ($this->nodes as $node) {
$node->$name = $val;
}
return $this;
}
// get property value for first element
if ($name === 'out... | [
"public",
"function",
"prop",
"(",
"string",
"$",
"name",
",",
"$",
"val",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"val",
"!==",
"null",
")",
"{",
"// set attribute for all nodes",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{... | Get the value of a property for the first element in the set of matched elements
or set one or more properties for every matched element.
@param string $name
@param string $val
@return $this|mixed|null | [
"Get",
"the",
"value",
"of",
"a",
"property",
"for",
"the",
"first",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"or",
"set",
"one",
"or",
"more",
"properties",
"for",
"every",
"matched",
"element",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L379-L397 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.children | public function children($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
if (isset($this->root_instance) || $this->getXpathQuery()) {
foreach ($this->nodes as $node) {
if ($node->hasChildNod... | php | public function children($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
if (isset($this->root_instance) || $this->getXpathQuery()) {
foreach ($this->nodes as $node) {
if ($node->hasChildNod... | [
"public",
"function",
"children",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"this",
"->",
"length"... | Get the children of each element in the set of matched elements, optionally filtered by a selector.
@param string|self|callable|\DOMNodeList|\DOMNode|false|null $selector expression that filters the set of matched elements
@return self | [
"Get",
"the",
"children",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"optionally",
"filtered",
"by",
"a",
"selector",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L416-L446 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.siblings | public function siblings($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
if ($node->parentNode) {
foreach ($node->parentNode->childNodes as $sibling) {
... | php | public function siblings($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
if ($node->parentNode) {
foreach ($node->parentNode->childNodes as $sibling) {
... | [
"public",
"function",
"siblings",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"this",
"->",
"length"... | Get the siblings of each element in the set of matched elements, optionally filtered by a selector.
@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that filters the set of matched elements
@return self | [
"Get",
"the",
"siblings",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"optionally",
"filtered",
"by",
"a",
"selector",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L455-L476 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.parent | public function parent($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
if ($node->parentNode) {
$result->addDomNode($node->parentNode);
}
... | php | public function parent($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
if ($node->parentNode) {
$result->addDomNode($node->parentNode);
}
... | [
"public",
"function",
"parent",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"this",
"->",
"length",
... | Get the parent of each element in the current set of matched elements, optionally filtered by a selector
@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that filters the set of matched elements
@return self | [
"Get",
"the",
"parent",
"of",
"each",
"element",
"in",
"the",
"current",
"set",
"of",
"matched",
"elements",
"optionally",
"filtered",
"by",
"a",
"selector"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L485-L502 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.closest | public function closest($selector)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
$current = $node;
while ($current instanceof \DOMElement) {
if (self::cr... | php | public function closest($selector)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
$current = $node;
while ($current instanceof \DOMElement) {
if (self::cr... | [
"public",
"function",
"closest",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"this",
"->",
"length",
">",
"0",
... | For each element in the set, get the first element that matches the selector
by testing the element itself and traversing up through its ancestors in the DOM tree.
@param string|self|callable|\DOMNodeList|\DOMNode $selector selector expression to match elements against
@return self | [
"For",
"each",
"element",
"in",
"the",
"set",
"get",
"the",
"first",
"element",
"that",
"matches",
"the",
"selector",
"by",
"testing",
"the",
"element",
"itself",
"and",
"traversing",
"up",
"through",
"its",
"ancestors",
"in",
"the",
"DOM",
"tree",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L512-L531 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.not | public function not($selector)
{
$result = $this->createChildInstance();
if ($this->length > 0) {
if (\is_callable($selector)) {
foreach ($this->nodes as $index => $node) {
if (!$selector($node, $index)) {
$result->addDomNode($... | php | public function not($selector)
{
$result = $this->createChildInstance();
if ($this->length > 0) {
if (\is_callable($selector)) {
foreach ($this->nodes as $index => $node) {
if (!$selector($node, $index)) {
$result->addDomNode($... | [
"public",
"function",
"not",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"length",
">",
"0",
")",
"{",
"if",
"(",
"\\",
"is_callable",
"(",
"$",
"selecto... | Remove elements from the set of matched elements.
@param string|self|callable|\DOMNodeList|\DOMNode $selector
@return self | [
"Remove",
"elements",
"from",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L540-L574 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.add | public function add($selector, $context=null)
{
$result = $this->createChildInstance();
$result->nodes = $this->nodes;
$selection = $this->getTargetResult($selector, $context);
foreach ($selection as $selection_node) {
if (!$result->is($selection_node)) {
... | php | public function add($selector, $context=null)
{
$result = $this->createChildInstance();
$result->nodes = $this->nodes;
$selection = $this->getTargetResult($selector, $context);
foreach ($selection as $selection_node) {
if (!$result->is($selection_node)) {
... | [
"public",
"function",
"add",
"(",
"$",
"selector",
",",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"$",
"result",
"->",
"nodes",
"=",
"$",
"this",
"->",
"nodes",
";",
"$",
"se... | Reduce the set of matched elements to those that match the selector
@param string|self|callable|\DOMNodeList|\DOMNode $selector
@param string|self|\DOMNodeList|\DOMNode|\DOMDocument $context
@return self | [
"Reduce",
"the",
"set",
"of",
"matched",
"elements",
"to",
"those",
"that",
"match",
"the",
"selector"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L584-L604 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.filter | public function filter($selector)
{
$result = $this->createChildInstance();
if ($this->length > 0) {
if (\is_callable($selector)) {
foreach ($this->nodes as $index => $node) {
if ($selector($node, $index)) {
$result->addDomNode... | php | public function filter($selector)
{
$result = $this->createChildInstance();
if ($this->length > 0) {
if (\is_callable($selector)) {
foreach ($this->nodes as $index => $node) {
if ($selector($node, $index)) {
$result->addDomNode... | [
"public",
"function",
"filter",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"length",
">",
"0",
")",
"{",
"if",
"(",
"\\",
"is_callable",
"(",
"$",
"sele... | Reduce the set of matched elements to those that match the selector
@param string|self|callable|\DOMNodeList|\DOMNode $selector
@return self | [
"Reduce",
"the",
"set",
"of",
"matched",
"elements",
"to",
"those",
"that",
"match",
"the",
"selector"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L613-L639 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.index | public function index($selector=null)
{
if ($selector === null) {
if ($node = $this->getFirstElmNode()) {
$position = 0;
while ($node && ($node = $node->previousSibling)) {
if ($node instanceof \DOMElement) {
$position++... | php | public function index($selector=null)
{
if ($selector === null) {
if ($node = $this->getFirstElmNode()) {
$position = 0;
while ($node && ($node = $node->previousSibling)) {
if ($node instanceof \DOMElement) {
$position++... | [
"public",
"function",
"index",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"selector",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"node",
"=",
"$",
"this",
"->",
"getFirstElmNode",
"(",
")",
")",
"{",
"$",
"position",
"=",
"0",
";"... | Get the position of the first element within the DOM, relative to its sibling elements.
Or get the position of the first node in the result that matches the selector.
@param string|self|callable|\DOMNodeList|\DOMNode $selector
@return int $position | [
"Get",
"the",
"position",
"of",
"the",
"first",
"element",
"within",
"the",
"DOM",
"relative",
"to",
"its",
"sibling",
"elements",
".",
"Or",
"get",
"the",
"position",
"of",
"the",
"first",
"node",
"in",
"the",
"result",
"that",
"matches",
"the",
"selector... | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L659-L682 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.is | public function is($selector)
{
if ($this->length > 0) {
if (\is_callable($selector)) {
foreach ($this->nodes as $index => $node) {
if ($selector($node, $index)) {
return true;
}
}
} else ... | php | public function is($selector)
{
if ($this->length > 0) {
if (\is_callable($selector)) {
foreach ($this->nodes as $index => $node) {
if ($selector($node, $index)) {
return true;
}
}
} else ... | [
"public",
"function",
"is",
"(",
"$",
"selector",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"length",
">",
"0",
")",
"{",
"if",
"(",
"\\",
"is_callable",
"(",
"$",
"selector",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
... | Check if any node matches the selector
@param string|self|callable|\DOMNodeList|\DOMNode $selector
@return boolean | [
"Check",
"if",
"any",
"node",
"matches",
"the",
"selector"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L691-L714 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.has | public function has($selector)
{
$result = $this->createChildInstance();
if ($this->length > 0) {
foreach ($this as $node) {
if ($node->find($selector)->length > 0) {
$result->addDomNode($node->get(0));
}
}
}
... | php | public function has($selector)
{
$result = $this->createChildInstance();
if ($this->length > 0) {
foreach ($this as $node) {
if ($node->find($selector)->length > 0) {
$result->addDomNode($node->get(0));
}
}
}
... | [
"public",
"function",
"has",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"length",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"node",
... | Reduce the set of matched elements to those that have a descendant that matches the selector
@param string|self|callable|\DOMNodeList|\DOMNode $selector
@return self | [
"Reduce",
"the",
"set",
"of",
"matched",
"elements",
"to",
"those",
"that",
"have",
"a",
"descendant",
"that",
"matches",
"the",
"selector"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L723-L736 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.slice | public function slice($offset=0, $length=null)
{
$result = $this->createChildInstance();
$result->nodes = \array_slice($this->nodes, $offset, $length);
$result->length = \count($result->nodes);
return $result;
} | php | public function slice($offset=0, $length=null)
{
$result = $this->createChildInstance();
$result->nodes = \array_slice($this->nodes, $offset, $length);
$result->length = \count($result->nodes);
return $result;
} | [
"public",
"function",
"slice",
"(",
"$",
"offset",
"=",
"0",
",",
"$",
"length",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"$",
"result",
"->",
"nodes",
"=",
"\\",
"array_slice",
"(",
"$",
"... | Reduce the set of matched elements to a subset specified by the offset and length (php like)
@param integer $offset
@param integer $length
@return self | [
"Reduce",
"the",
"set",
"of",
"matched",
"elements",
"to",
"a",
"subset",
"specified",
"by",
"the",
"offset",
"and",
"length",
"(",
"php",
"like",
")"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L746-L752 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.first | public function first($selector=null)
{
$result = $this[0];
if ($selector) {
$result = $result->filter($selector);
}
return $result;
} | php | public function first($selector=null)
{
$result = $this[0];
if ($selector) {
$result = $result->filter($selector);
}
return $result;
} | [
"public",
"function",
"first",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"->",
"filter",
"(",
"$",
"selector",
")",
... | Returns DomQuery with first node
@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that filters the set of matched elements
@return self | [
"Returns",
"DomQuery",
"with",
"first",
"node"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L773-L780 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.last | public function last($selector=null)
{
$result = $this[$this->length-1];
if ($selector) {
$result = $result->filter($selector);
}
return $result;
} | php | public function last($selector=null)
{
$result = $this[$this->length-1];
if ($selector) {
$result = $result->filter($selector);
}
return $result;
} | [
"public",
"function",
"last",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"[",
"$",
"this",
"->",
"length",
"-",
"1",
"]",
";",
"if",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"->",
"fi... | Returns DomQuery with last node
@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that filters the set of matched elements
@return self | [
"Returns",
"DomQuery",
"with",
"last",
"node"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L789-L796 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.next | public function next($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
if ($next = self::getNextElement($node)) {
$result->addDomNode($next);
... | php | public function next($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) {
if ($next = self::getNextElement($node)) {
$result->addDomNode($next);
... | [
"public",
"function",
"next",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"this",
"->",
"length",
... | Returns DomQuery with immediately following sibling of all nodes
@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that filters the set of matched elements
@return self | [
"Returns",
"DomQuery",
"with",
"immediately",
"following",
"sibling",
"of",
"all",
"nodes"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L805-L822 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.prev | public function prev($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) { // get all previous sibling of all nodes
if ($prev = self::getPreviousElement($node)) {
... | php | public function prev($selector=null)
{
$result = $this->createChildInstance();
if (isset($this->document) && $this->length > 0) {
foreach ($this->nodes as $node) { // get all previous sibling of all nodes
if ($prev = self::getPreviousElement($node)) {
... | [
"public",
"function",
"prev",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"createChildInstance",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"document",
")",
"&&",
"$",
"this",
"->",
"length",
... | Returns DomQuery with immediately preceding sibling of all nodes
@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that filters the set of matched elements
@return self | [
"Returns",
"DomQuery",
"with",
"immediately",
"preceding",
"sibling",
"of",
"all",
"nodes"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L859-L876 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.remove | public function remove($selector=null)
{
$result = $this;
if ($selector) {
$result = $result->filter($selector);
}
foreach ($result->nodes as $node) {
if ($node->parentNode) {
$node->parentNode->removeChild($node);
}
}
... | php | public function remove($selector=null)
{
$result = $this;
if ($selector) {
$result = $result->filter($selector);
}
foreach ($result->nodes as $node) {
if ($node->parentNode) {
$node->parentNode->removeChild($node);
}
}
... | [
"public",
"function",
"remove",
"(",
"$",
"selector",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
";",
"if",
"(",
"$",
"selector",
")",
"{",
"$",
"result",
"=",
"$",
"result",
"->",
"filter",
"(",
"$",
"selector",
")",
";",
"}",
"fore... | Remove the set of matched elements
@param string|self|callable|\DOMNodeList|\DOMNode|null $selector expression that
filters the set of matched elements to be removed
@return self | [
"Remove",
"the",
"set",
"of",
"matched",
"elements"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L914-L930 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.importNodes | private function importNodes($content, callable $import_function)
{
if (\is_array($content)) {
foreach ($content as $item) {
$this->importNodes($item, $import_function);
}
} else {
if (\is_string($content) && strpos($content, "\n") !== false) {
... | php | private function importNodes($content, callable $import_function)
{
if (\is_array($content)) {
foreach ($content as $item) {
$this->importNodes($item, $import_function);
}
} else {
if (\is_string($content) && strpos($content, "\n") !== false) {
... | [
"private",
"function",
"importNodes",
"(",
"$",
"content",
",",
"callable",
"$",
"import_function",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"content",
")",
")",
"{",
"foreach",
"(",
"$",
"content",
"as",
"$",
"item",
")",
"{",
"$",
"this",
"... | Import nodes and insert or append them via callback function
@param string|self|array $content
@param callable $import_function
@return void | [
"Import",
"nodes",
"and",
"insert",
"or",
"append",
"them",
"via",
"callback",
"function"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L940-L969 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.getTargetResult | private function getTargetResult($target, $context=null)
{
if ($context===null && \is_string($target) && strpos($target, '<') === false) {
$context = $this->document;
}
return $context === null ? self::create($target) : self::create($target, $context);
} | php | private function getTargetResult($target, $context=null)
{
if ($context===null && \is_string($target) && strpos($target, '<') === false) {
$context = $this->document;
}
return $context === null ? self::create($target) : self::create($target, $context);
} | [
"private",
"function",
"getTargetResult",
"(",
"$",
"target",
",",
"$",
"context",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"context",
"===",
"null",
"&&",
"\\",
"is_string",
"(",
"$",
"target",
")",
"&&",
"strpos",
"(",
"$",
"target",
",",
"'<'",
")",... | Get target result using selector or instance of self
@param string|self $target
@param string|self|\DOMNodeList|\DOMNode|\DOMDocument $context
@return self | [
"Get",
"target",
"result",
"using",
"selector",
"or",
"instance",
"of",
"self"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L979-L986 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.append | public function append()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
$node->appendChild($imported_node);
});
return $this;
} | php | public function append()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
$node->appendChild($imported_node);
});
return $this;
} | [
"public",
"function",
"append",
"(",
")",
"{",
"$",
"this",
"->",
"importNodes",
"(",
"\\",
"func_get_args",
"(",
")",
",",
"function",
"(",
"$",
"node",
",",
"$",
"imported_node",
")",
"{",
"$",
"node",
"->",
"appendChild",
"(",
"$",
"imported_node",
... | Insert content to the end of each element in the set of matched elements.
@param string|self $content,...
@return $this | [
"Insert",
"content",
"to",
"the",
"end",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L995-L1002 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.appendTo | public function appendTo($target)
{
$target_result = $this->getTargetResult($target);
$target_result->append($this);
$this->remove();
return $target_result;
} | php | public function appendTo($target)
{
$target_result = $this->getTargetResult($target);
$target_result->append($this);
$this->remove();
return $target_result;
} | [
"public",
"function",
"appendTo",
"(",
"$",
"target",
")",
"{",
"$",
"target_result",
"=",
"$",
"this",
"->",
"getTargetResult",
"(",
"$",
"target",
")",
";",
"$",
"target_result",
"->",
"append",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"remove"... | Insert every element in the set of matched elements to the end of the target.
@param string|self $target
@return self | [
"Insert",
"every",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"to",
"the",
"end",
"of",
"the",
"target",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1011-L1019 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.prepend | public function prepend()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
$node->insertBefore($imported_node, $node->childNodes->item(0));
});
return $this;
} | php | public function prepend()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
$node->insertBefore($imported_node, $node->childNodes->item(0));
});
return $this;
} | [
"public",
"function",
"prepend",
"(",
")",
"{",
"$",
"this",
"->",
"importNodes",
"(",
"\\",
"func_get_args",
"(",
")",
",",
"function",
"(",
"$",
"node",
",",
"$",
"imported_node",
")",
"{",
"$",
"node",
"->",
"insertBefore",
"(",
"$",
"imported_node",
... | Insert content to the beginning of each element in the set of matched elements
@param string|self $content,...
@return $this | [
"Insert",
"content",
"to",
"the",
"beginning",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1028-L1035 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.prependTo | public function prependTo($target)
{
$target_result = $this->getTargetResult($target);
$target_result->prepend($this);
$this->remove();
return $target_result;
} | php | public function prependTo($target)
{
$target_result = $this->getTargetResult($target);
$target_result->prepend($this);
$this->remove();
return $target_result;
} | [
"public",
"function",
"prependTo",
"(",
"$",
"target",
")",
"{",
"$",
"target_result",
"=",
"$",
"this",
"->",
"getTargetResult",
"(",
"$",
"target",
")",
";",
"$",
"target_result",
"->",
"prepend",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"remov... | Insert every element in the set of matched elements to the beginning of the target.
@param string|self $target
@return self | [
"Insert",
"every",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"to",
"the",
"beginning",
"of",
"the",
"target",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1044-L1052 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.before | public function before()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
if ($node->parentNode instanceof \DOMDocument) {
throw new \Exception('Can not set before root element '.$node->tagName.' of document');
}
$node->parentNode... | php | public function before()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
if ($node->parentNode instanceof \DOMDocument) {
throw new \Exception('Can not set before root element '.$node->tagName.' of document');
}
$node->parentNode... | [
"public",
"function",
"before",
"(",
")",
"{",
"$",
"this",
"->",
"importNodes",
"(",
"\\",
"func_get_args",
"(",
")",
",",
"function",
"(",
"$",
"node",
",",
"$",
"imported_node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"parentNode",
"instanceof",
"\\... | Insert content before each element in the set of matched elements.
@param string|self $content,...
@return $this | [
"Insert",
"content",
"before",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1061-L1072 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.after | public function after()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
if ($node->nextSibling) {
$node->parentNode->insertBefore($imported_node, $node->nextSibling);
} else { // node is last, so there is no next sibling to insert before
... | php | public function after()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
if ($node->nextSibling) {
$node->parentNode->insertBefore($imported_node, $node->nextSibling);
} else { // node is last, so there is no next sibling to insert before
... | [
"public",
"function",
"after",
"(",
")",
"{",
"$",
"this",
"->",
"importNodes",
"(",
"\\",
"func_get_args",
"(",
")",
",",
"function",
"(",
"$",
"node",
",",
"$",
"imported_node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"nextSibling",
")",
"{",
"$",
... | Insert content after each element in the set of matched elements.
@param string|self $content,...
@return $this | [
"Insert",
"content",
"after",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1081-L1092 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.replaceWith | public function replaceWith()
{
$removed_nodes = new self();
$this->importNodes(\func_get_args(), function ($node, $imported_node) use (&$removed_nodes) {
if ($node->nextSibling) {
$node->parentNode->insertBefore($imported_node, $node->nextSibling);
} else { ... | php | public function replaceWith()
{
$removed_nodes = new self();
$this->importNodes(\func_get_args(), function ($node, $imported_node) use (&$removed_nodes) {
if ($node->nextSibling) {
$node->parentNode->insertBefore($imported_node, $node->nextSibling);
} else { ... | [
"public",
"function",
"replaceWith",
"(",
")",
"{",
"$",
"removed_nodes",
"=",
"new",
"self",
"(",
")",
";",
"$",
"this",
"->",
"importNodes",
"(",
"\\",
"func_get_args",
"(",
")",
",",
"function",
"(",
"$",
"node",
",",
"$",
"imported_node",
")",
"use... | Replace each element in the set of matched elements with the provided
new content and return the set of elements that was removed.
@param string|self $new_content,...
@return self | [
"Replace",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements",
"with",
"the",
"provided",
"new",
"content",
"and",
"return",
"the",
"set",
"of",
"elements",
"that",
"was",
"removed",
"."
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1102-L1123 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.wrap | public function wrap()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
if ($node->parentNode instanceof \DOMDocument) {
throw new \Exception('Can not wrap inside root element '.$node->tagName.' of document');
}
// replace node wi... | php | public function wrap()
{
$this->importNodes(\func_get_args(), function ($node, $imported_node) {
if ($node->parentNode instanceof \DOMDocument) {
throw new \Exception('Can not wrap inside root element '.$node->tagName.' of document');
}
// replace node wi... | [
"public",
"function",
"wrap",
"(",
")",
"{",
"$",
"this",
"->",
"importNodes",
"(",
"\\",
"func_get_args",
"(",
")",
",",
"function",
"(",
"$",
"node",
",",
"$",
"imported_node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"parentNode",
"instanceof",
"\\",... | Wrap an HTML structure around each element in the set of matched elements
@param string|self $content,...
@return $this | [
"Wrap",
"an",
"HTML",
"structure",
"around",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1132-L1150 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.wrapAll | public function wrapAll()
{
$wrapper_node = null; // node given as wrapper
$wrap_target_node = null; // node that wil be parent of content to be wrapped
$this->importNodes(\func_get_args(), function ($node, $imported_node) use (&$wrapper_node, &$wrap_target_node) {
if ($node->pa... | php | public function wrapAll()
{
$wrapper_node = null; // node given as wrapper
$wrap_target_node = null; // node that wil be parent of content to be wrapped
$this->importNodes(\func_get_args(), function ($node, $imported_node) use (&$wrapper_node, &$wrap_target_node) {
if ($node->pa... | [
"public",
"function",
"wrapAll",
"(",
")",
"{",
"$",
"wrapper_node",
"=",
"null",
";",
"// node given as wrapper",
"$",
"wrap_target_node",
"=",
"null",
";",
"// node that wil be parent of content to be wrapped",
"$",
"this",
"->",
"importNodes",
"(",
"\\",
"func_get_... | Wrap an HTML structure around all elements in the set of matched elements
@param string|self $content,...
@return $this | [
"Wrap",
"an",
"HTML",
"structure",
"around",
"all",
"elements",
"in",
"the",
"set",
"of",
"matched",
"elements"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1159-L1187 |
Rct567/DomQuery | src/Rct567/DomQuery/DomQuery.php | DomQuery.wrapInner | public function wrapInner()
{
foreach ($this->nodes as $node) {
self::create($node->childNodes)->wrapAll(\func_get_args());
}
return $this;
} | php | public function wrapInner()
{
foreach ($this->nodes as $node) {
self::create($node->childNodes)->wrapAll(\func_get_args());
}
return $this;
} | [
"public",
"function",
"wrapInner",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"self",
"::",
"create",
"(",
"$",
"node",
"->",
"childNodes",
")",
"->",
"wrapAll",
"(",
"\\",
"func_get_args",
"(",
")",
")",
... | Wrap an HTML structure around the content of each element in the set of matched elements
@param string|self $content,...
@return $this | [
"Wrap",
"an",
"HTML",
"structure",
"around",
"the",
"content",
"of",
"each",
"element",
"in",
"the",
"set",
"of",
"matched",
"elements"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/DomQuery.php#L1196-L1203 |
Rct567/DomQuery | src/Rct567/DomQuery/CssToXpath.php | CssToXpath.transform | public static function transform(string $path)
{
if (isset(self::$xpath_cache[$path])) {
return self::$xpath_cache[$path];
}
$tmp_path = self::replaceCharInsideEnclosure($path, ',');
if (strpos($tmp_path, ',') !== false) {
$paths = explode(',', $tmp_path);
... | php | public static function transform(string $path)
{
if (isset(self::$xpath_cache[$path])) {
return self::$xpath_cache[$path];
}
$tmp_path = self::replaceCharInsideEnclosure($path, ',');
if (strpos($tmp_path, ',') !== false) {
$paths = explode(',', $tmp_path);
... | [
"public",
"static",
"function",
"transform",
"(",
"string",
"$",
"path",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"xpath_cache",
"[",
"$",
"path",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"xpath_cache",
"[",
"$",
"path",
"]",
"... | Transform CSS selector expression to XPath
@param string $path css selector expression
@return string xpath expression | [
"Transform",
"CSS",
"selector",
"expression",
"to",
"XPath"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/CssToXpath.php#L25-L74 |
Rct567/DomQuery | src/Rct567/DomQuery/CssToXpath.php | CssToXpath.replaceCharInsideEnclosure | private static function replaceCharInsideEnclosure($str, $search_char, $enclosure_open='(', $enclosure_close=')')
{
if ($str === '' || strpos($str, $search_char) === false || strpos($str, $enclosure_open) === false) {
return $str;
}
for ($i = 0, $str_length = \strlen($str); $i <... | php | private static function replaceCharInsideEnclosure($str, $search_char, $enclosure_open='(', $enclosure_close=')')
{
if ($str === '' || strpos($str, $search_char) === false || strpos($str, $enclosure_open) === false) {
return $str;
}
for ($i = 0, $str_length = \strlen($str); $i <... | [
"private",
"static",
"function",
"replaceCharInsideEnclosure",
"(",
"$",
"str",
",",
"$",
"search_char",
",",
"$",
"enclosure_open",
"=",
"'('",
",",
"$",
"enclosure_close",
"=",
"')'",
")",
"{",
"if",
"(",
"$",
"str",
"===",
"''",
"||",
"strpos",
"(",
"... | Replace char with null bytes inside (optionally specified) enclosure
@param string $str
@param string $search_char
@param string $enclosure_open
@param string $enclosure_close
@return string $str | [
"Replace",
"char",
"with",
"null",
"bytes",
"inside",
"(",
"optionally",
"specified",
")",
"enclosure"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/CssToXpath.php#L86-L103 |
Rct567/DomQuery | src/Rct567/DomQuery/CssToXpath.php | CssToXpath.getSegmentFromToken | private static function getSegmentFromToken($token, $key, array $tokens)
{
$relation_tokens = array('>', '~', '+');
if (\in_array($token, $relation_tokens, true)) { // not a segment
return false;
}
$segment = (object) array(
'selector' => '',
're... | php | private static function getSegmentFromToken($token, $key, array $tokens)
{
$relation_tokens = array('>', '~', '+');
if (\in_array($token, $relation_tokens, true)) { // not a segment
return false;
}
$segment = (object) array(
'selector' => '',
're... | [
"private",
"static",
"function",
"getSegmentFromToken",
"(",
"$",
"token",
",",
"$",
"key",
",",
"array",
"$",
"tokens",
")",
"{",
"$",
"relation_tokens",
"=",
"array",
"(",
"'>'",
",",
"'~'",
",",
"'+'",
")",
";",
"if",
"(",
"\\",
"in_array",
"(",
"... | Get segment data from token (css selector delimited by space and commas)
@param string $token
@param integer $key
@param string[] $tokens
@return object|false $segment | [
"Get",
"segment",
"data",
"from",
"token",
"(",
"css",
"selector",
"delimited",
"by",
"space",
"and",
"commas",
")"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/CssToXpath.php#L114-L196 |
Rct567/DomQuery | src/Rct567/DomQuery/CssToXpath.php | CssToXpath.transformCssSegments | private static function transformCssSegments(array $segments)
{
$new_path_tokens = array();
foreach ($segments as $num => $segment) {
if ($segment->relation_token === '>') {
$new_path_tokens[] = '/';
} elseif ($segment->relation_token === '~' || $segment->rel... | php | private static function transformCssSegments(array $segments)
{
$new_path_tokens = array();
foreach ($segments as $num => $segment) {
if ($segment->relation_token === '>') {
$new_path_tokens[] = '/';
} elseif ($segment->relation_token === '~' || $segment->rel... | [
"private",
"static",
"function",
"transformCssSegments",
"(",
"array",
"$",
"segments",
")",
"{",
"$",
"new_path_tokens",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"segments",
"as",
"$",
"num",
"=>",
"$",
"segment",
")",
"{",
"if",
"(",
"$",
"s... | Transform css segments to xpath
@param object[] $segments
@return string[] $new_path_tokens | [
"Transform",
"css",
"segments",
"to",
"xpath"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/CssToXpath.php#L205-L239 |
Rct567/DomQuery | src/Rct567/DomQuery/CssToXpath.php | CssToXpath.transformCssPseudoSelector | private static function transformCssPseudoSelector($expression, array &$new_path_tokens)
{
if (preg_match('|not\((.+)\)|i', $expression, $matches)) {
$parts = explode(',', $matches[1]);
foreach ($parts as &$part) {
$part = trim($part);
$part = 'self::'... | php | private static function transformCssPseudoSelector($expression, array &$new_path_tokens)
{
if (preg_match('|not\((.+)\)|i', $expression, $matches)) {
$parts = explode(',', $matches[1]);
foreach ($parts as &$part) {
$part = trim($part);
$part = 'self::'... | [
"private",
"static",
"function",
"transformCssPseudoSelector",
"(",
"$",
"expression",
",",
"array",
"&",
"$",
"new_path_tokens",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'|not\\((.+)\\)|i'",
",",
"$",
"expression",
",",
"$",
"matches",
")",
")",
"{",
"$",
"... | Transform 'css pseudo selector' expression to xpath expression
@param string $expression
@param string[] $new_path_tokens
@return string transformed expression (xpath)
@throws \Exception | [
"Transform",
"css",
"pseudo",
"selector",
"expression",
"to",
"xpath",
"expression"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/CssToXpath.php#L250-L296 |
Rct567/DomQuery | src/Rct567/DomQuery/CssToXpath.php | CssToXpath.transformAttrSelector | private static function transformAttrSelector($expression)
{
if (preg_match('|@?([a-z0-9_]+)(([\!\*\^\$\~\|]{0,1})=)[\'"]([^\'"]+)[\'"]|i', $expression, $matches)) {
if ($matches[3] === '') { // arbitrary attribute strict value equality
return '[@' . strtolower($matches[1]) . "='... | php | private static function transformAttrSelector($expression)
{
if (preg_match('|@?([a-z0-9_]+)(([\!\*\^\$\~\|]{0,1})=)[\'"]([^\'"]+)[\'"]|i', $expression, $matches)) {
if ($matches[3] === '') { // arbitrary attribute strict value equality
return '[@' . strtolower($matches[1]) . "='... | [
"private",
"static",
"function",
"transformAttrSelector",
"(",
"$",
"expression",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'|@?([a-z0-9_]+)(([\\!\\*\\^\\$\\~\\|]{0,1})=)[\\'\"]([^\\'\"]+)[\\'\"]|i'",
",",
"$",
"expression",
",",
"$",
"matches",
")",
")",
"{",
"if",
"(... | Transform 'css attribute selector' expression to xpath expression
@param string $expression
@return string transformed expression (xpath) | [
"Transform",
"css",
"attribute",
"selector",
"expression",
"to",
"xpath",
"expression"
] | train | https://github.com/Rct567/DomQuery/blob/40ff02b4337e704c5816a6ecae11182dd705f136/src/Rct567/DomQuery/CssToXpath.php#L305-L333 |
laravel/spark-installer | src/Installation/RunSparkInstall.php | RunSparkInstall.install | public function install()
{
$process = new Process($this->command(), $this->command->path);
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
$process->setTty(true);
}
$process->run(function ($type, $line) {
$this->com... | php | public function install()
{
$process = new Process($this->command(), $this->command->path);
if ('\\' !== DIRECTORY_SEPARATOR && file_exists('/dev/tty') && is_readable('/dev/tty')) {
$process->setTty(true);
}
$process->run(function ($type, $line) {
$this->com... | [
"public",
"function",
"install",
"(",
")",
"{",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"this",
"->",
"command",
"(",
")",
",",
"$",
"this",
"->",
"command",
"->",
"path",
")",
";",
"if",
"(",
"'\\\\'",
"!==",
"DIRECTORY_SEPARATOR",
"&&",
"f... | Run the installation helper.
@return void | [
"Run",
"the",
"installation",
"helper",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/RunSparkInstall.php#L28-L39 |
laravel/spark-installer | src/Installation/RunSparkInstall.php | RunSparkInstall.command | protected function command()
{
$command = 'php artisan spark:install --force';
if ($this->command->input->getOption('braintree')) {
$command .= ' --braintree';
}
if ($this->command->input->getOption('team-billing')) {
$command .= ' --team-billing';
}... | php | protected function command()
{
$command = 'php artisan spark:install --force';
if ($this->command->input->getOption('braintree')) {
$command .= ' --braintree';
}
if ($this->command->input->getOption('team-billing')) {
$command .= ' --team-billing';
}... | [
"protected",
"function",
"command",
"(",
")",
"{",
"$",
"command",
"=",
"'php artisan spark:install --force'",
";",
"if",
"(",
"$",
"this",
"->",
"command",
"->",
"input",
"->",
"getOption",
"(",
"'braintree'",
")",
")",
"{",
"$",
"command",
".=",
"' --brain... | Get the proper Spark installation command.
@return string | [
"Get",
"the",
"proper",
"Spark",
"installation",
"command",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/RunSparkInstall.php#L46-L59 |
laravel/spark-installer | src/NewCommand.php | NewCommand.execute | public function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = new SymfonyStyle($input, $output);
$this->path = getcwd().'/'.$input->getArgument('name');
$installers = [
Installation\CreateLaravelProject::class,
... | php | public function execute(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = new SymfonyStyle($input, $output);
$this->path = getcwd().'/'.$input->getArgument('name');
$installers = [
Installation\CreateLaravelProject::class,
... | [
"public",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"input",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"output",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
... | Execute the command.
@param InputInterface $input
@param OutputInterface $output
@return void | [
"Execute",
"the",
"command",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/NewCommand.php#L57-L79 |
laravel/spark-installer | src/Installation/DownloadSpark.php | DownloadSpark.install | public function install()
{
$this->extractZip($this->downloadZip());
rename($this->sparkPath(), $this->command->path.'/spark');
(new Filesystem)->deleteDirectory(
$this->command->path.'/spark-new'
);
} | php | public function install()
{
$this->extractZip($this->downloadZip());
rename($this->sparkPath(), $this->command->path.'/spark');
(new Filesystem)->deleteDirectory(
$this->command->path.'/spark-new'
);
} | [
"public",
"function",
"install",
"(",
")",
"{",
"$",
"this",
"->",
"extractZip",
"(",
"$",
"this",
"->",
"downloadZip",
"(",
")",
")",
";",
"rename",
"(",
"$",
"this",
"->",
"sparkPath",
"(",
")",
",",
"$",
"this",
"->",
"command",
"->",
"path",
".... | Run the installation helper.
@return void | [
"Run",
"the",
"installation",
"helper",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/DownloadSpark.php#L36-L45 |
laravel/spark-installer | src/Installation/DownloadSpark.php | DownloadSpark.downloadZip | protected function downloadZip()
{
$this->command->output->writeln(
'<info>Downloading Spark...</info>'
);
file_put_contents(
$zipPath = $this->command->path.'/spark-archive.zip', $this->zipResponse()
);
return $zipPath;
} | php | protected function downloadZip()
{
$this->command->output->writeln(
'<info>Downloading Spark...</info>'
);
file_put_contents(
$zipPath = $this->command->path.'/spark-archive.zip', $this->zipResponse()
);
return $zipPath;
} | [
"protected",
"function",
"downloadZip",
"(",
")",
"{",
"$",
"this",
"->",
"command",
"->",
"output",
"->",
"writeln",
"(",
"'<info>Downloading Spark...</info>'",
")",
";",
"file_put_contents",
"(",
"$",
"zipPath",
"=",
"$",
"this",
"->",
"command",
"->",
"path... | Download the latest Spark release.
@return void | [
"Download",
"the",
"latest",
"Spark",
"release",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/DownloadSpark.php#L52-L63 |
laravel/spark-installer | src/Installation/DownloadSpark.php | DownloadSpark.zipResponse | protected function zipResponse()
{
$release = $this->latestSparkRelease();
try {
return (string) (new HttpClient)->get(
$this->sparkUrl.'/api/releases/'.$release.'/download?api_token='.$this->readToken(),
[
'headers' => [
... | php | protected function zipResponse()
{
$release = $this->latestSparkRelease();
try {
return (string) (new HttpClient)->get(
$this->sparkUrl.'/api/releases/'.$release.'/download?api_token='.$this->readToken(),
[
'headers' => [
... | [
"protected",
"function",
"zipResponse",
"(",
")",
"{",
"$",
"release",
"=",
"$",
"this",
"->",
"latestSparkRelease",
"(",
")",
";",
"try",
"{",
"return",
"(",
"string",
")",
"(",
"new",
"HttpClient",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"sparkUrl"... | Get the raw Zip response for a Spark download.
@return string | [
"Get",
"the",
"raw",
"Zip",
"response",
"for",
"a",
"Spark",
"download",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/DownloadSpark.php#L70-L91 |
laravel/spark-installer | src/Installation/DownloadSpark.php | DownloadSpark.extractZip | protected function extractZip($zipPath)
{
$archive = new ZipArchive;
$archive->open($zipPath);
$archive->extractTo($this->command->path.'/spark-new');
$archive->close();
@unlink($zipPath);
} | php | protected function extractZip($zipPath)
{
$archive = new ZipArchive;
$archive->open($zipPath);
$archive->extractTo($this->command->path.'/spark-new');
$archive->close();
@unlink($zipPath);
} | [
"protected",
"function",
"extractZip",
"(",
"$",
"zipPath",
")",
"{",
"$",
"archive",
"=",
"new",
"ZipArchive",
";",
"$",
"archive",
"->",
"open",
"(",
"$",
"zipPath",
")",
";",
"$",
"archive",
"->",
"extractTo",
"(",
"$",
"this",
"->",
"command",
"->"... | Extract the Spark Zip archive.
@param string $zipPath
@return void | [
"Extract",
"the",
"Spark",
"Zip",
"archive",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/DownloadSpark.php#L99-L110 |
laravel/spark-installer | src/Installation/DownloadSpark.php | DownloadSpark.sparkPath | protected function sparkPath()
{
return $this->command->path.'/spark-new/'.basename(
(new Filesystem)->directories($this->command->path.'/spark-new')[0]
);
} | php | protected function sparkPath()
{
return $this->command->path.'/spark-new/'.basename(
(new Filesystem)->directories($this->command->path.'/spark-new')[0]
);
} | [
"protected",
"function",
"sparkPath",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"command",
"->",
"path",
".",
"'/spark-new/'",
".",
"basename",
"(",
"(",
"new",
"Filesystem",
")",
"->",
"directories",
"(",
"$",
"this",
"->",
"command",
"->",
"path",
".... | Get the release directory.
@return string | [
"Get",
"the",
"release",
"directory",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/DownloadSpark.php#L117-L122 |
laravel/spark-installer | src/InteractsWithSparkConfiguration.php | InteractsWithSparkConfiguration.homePath | protected function homePath()
{
if (! empty($_SERVER['HOME'])) {
return $_SERVER['HOME'];
} elseif (! empty($_SERVER['HOMEDRIVE']) && ! empty($_SERVER['HOMEPATH'])) {
return $_SERVER['HOMEDRIVE'].$_SERVER['HOMEPATH'];
} else {
throw new Exception('Cannot d... | php | protected function homePath()
{
if (! empty($_SERVER['HOME'])) {
return $_SERVER['HOME'];
} elseif (! empty($_SERVER['HOMEDRIVE']) && ! empty($_SERVER['HOMEPATH'])) {
return $_SERVER['HOMEDRIVE'].$_SERVER['HOMEPATH'];
} else {
throw new Exception('Cannot d... | [
"protected",
"function",
"homePath",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HOME'",
"]",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"'HOME'",
"]",
";",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'... | Get the User's home path.
@return string
@throws Exception | [
"Get",
"the",
"User",
"s",
"home",
"path",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/InteractsWithSparkConfiguration.php#L65-L74 |
laravel/spark-installer | src/RegisterCommand.php | RegisterCommand.execute | public function execute(InputInterface $input, OutputInterface $output)
{
if (! $this->valid($input->getArgument('token'))) {
return $this->tokenIsInvalid($output);
}
if (! $this->configExists()) {
mkdir($this->homePath().'/.spark');
}
$this->storeTo... | php | public function execute(InputInterface $input, OutputInterface $output)
{
if (! $this->valid($input->getArgument('token'))) {
return $this->tokenIsInvalid($output);
}
if (! $this->configExists()) {
mkdir($this->homePath().'/.spark');
}
$this->storeTo... | [
"public",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'token'",
")",
")",
")",
"{",
"return",
"$"... | Execute the command.
@param InputInterface $input
@param OutputInterface $output
@return void | [
"Execute",
"the",
"command",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/RegisterCommand.php#L37-L50 |
laravel/spark-installer | src/RegisterCommand.php | RegisterCommand.valid | protected function valid($token)
{
try {
(new HttpClient)->get(
$this->sparkUrl.'/api/token/'.$token.'/validate',
['verify' => __DIR__.'/cacert.pem']
);
return true;
} catch (Exception $e) {
var_dump($e->getMessage());
... | php | protected function valid($token)
{
try {
(new HttpClient)->get(
$this->sparkUrl.'/api/token/'.$token.'/validate',
['verify' => __DIR__.'/cacert.pem']
);
return true;
} catch (Exception $e) {
var_dump($e->getMessage());
... | [
"protected",
"function",
"valid",
"(",
"$",
"token",
")",
"{",
"try",
"{",
"(",
"new",
"HttpClient",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"sparkUrl",
".",
"'/api/token/'",
".",
"$",
"token",
".",
"'/validate'",
",",
"[",
"'verify'",
"=>",
"__DIR__... | Determine if the given token is valid.
@param string $token
@return bool | [
"Determine",
"if",
"the",
"given",
"token",
"is",
"valid",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/RegisterCommand.php#L58-L72 |
laravel/spark-installer | src/Installation/UpdateComposerFile.php | UpdateComposerFile.install | public function install()
{
$composer = $this->getComposerConfiguration();
// Next we will add the Spark and Cashier dependencies to the Composer array as
// well as add the Spark "repository" to the configuration so Composer knows
// where Spark is located. Spark will get installed... | php | public function install()
{
$composer = $this->getComposerConfiguration();
// Next we will add the Spark and Cashier dependencies to the Composer array as
// well as add the Spark "repository" to the configuration so Composer knows
// where Spark is located. Spark will get installed... | [
"public",
"function",
"install",
"(",
")",
"{",
"$",
"composer",
"=",
"$",
"this",
"->",
"getComposerConfiguration",
"(",
")",
";",
"// Next we will add the Spark and Cashier dependencies to the Composer array as",
"// well as add the Spark \"repository\" to the configuration so Co... | Run the installation helper.
@return void | [
"Run",
"the",
"installation",
"helper",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/UpdateComposerFile.php#L30-L44 |
laravel/spark-installer | src/Installation/UpdateComposerFile.php | UpdateComposerFile.writeComposerFile | protected function writeComposerFile($composer)
{
file_put_contents(
$this->command->path.'/composer.json',
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
);
} | php | protected function writeComposerFile($composer)
{
file_put_contents(
$this->command->path.'/composer.json',
json_encode($composer, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)
);
} | [
"protected",
"function",
"writeComposerFile",
"(",
"$",
"composer",
")",
"{",
"file_put_contents",
"(",
"$",
"this",
"->",
"command",
"->",
"path",
".",
"'/composer.json'",
",",
"json_encode",
"(",
"$",
"composer",
",",
"JSON_PRETTY_PRINT",
"|",
"JSON_UNESCAPED_SL... | Write the given Composer configuration back to disk.
@param array $composer
@return void | [
"Write",
"the",
"given",
"Composer",
"configuration",
"back",
"to",
"disk",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/UpdateComposerFile.php#L110-L116 |
laravel/spark-installer | src/Installation/AddCoreProviderToConfiguration.php | AddCoreProviderToConfiguration.install | public function install()
{
$path = $this->command->path.'/config/app.php';
$contents = file_get_contents($path);
$contents = str_replace(
' App\\Providers\\AppServiceProvider::class,',
" Laravel\Spark\Providers\SparkServiceProvider::class,\n Ap... | php | public function install()
{
$path = $this->command->path.'/config/app.php';
$contents = file_get_contents($path);
$contents = str_replace(
' App\\Providers\\AppServiceProvider::class,',
" Laravel\Spark\Providers\SparkServiceProvider::class,\n Ap... | [
"public",
"function",
"install",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"command",
"->",
"path",
".",
"'/config/app.php'",
";",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"$",
"contents",
"=",
"str_replace",
"(",
... | Run the installation helper.
@return void | [
"Run",
"the",
"installation",
"helper",
"."
] | train | https://github.com/laravel/spark-installer/blob/2aa18947b9d8cdcf83aaaa273bc7b76426404507/src/Installation/AddCoreProviderToConfiguration.php#L27-L40 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.set_user_agent | private function set_user_agent() {
if (!empty($this->config['user_agent']))
return;
$ssl = ($this->config['curl_ssl_verifyhost'] && $this->config['curl_ssl_verifypeer'] && $this->config['use_ssl']) ? '+' : '-';
$ua = 'tmhOAuth ' . self::VERSION . $ssl . 'SSL - //github.com/themattharris/tmhOAuth';
... | php | private function set_user_agent() {
if (!empty($this->config['user_agent']))
return;
$ssl = ($this->config['curl_ssl_verifyhost'] && $this->config['curl_ssl_verifypeer'] && $this->config['use_ssl']) ? '+' : '-';
$ua = 'tmhOAuth ' . self::VERSION . $ssl . 'SSL - //github.com/themattharris/tmhOAuth';
... | [
"private",
"function",
"set_user_agent",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'user_agent'",
"]",
")",
")",
"return",
";",
"$",
"ssl",
"=",
"(",
"$",
"this",
"->",
"config",
"[",
"'curl_ssl_verifyhost'",
"]",
... | Sets the useragent for PHP to use
If '$this->config['user_agent']' already has a value it is used instead of one
being generated.
@return void value is stored to the config array class variable | [
"Sets",
"the",
"useragent",
"for",
"PHP",
"to",
"use",
"If",
"$this",
"-",
">",
"config",
"[",
"user_agent",
"]",
"already",
"has",
"a",
"value",
"it",
"is",
"used",
"instead",
"of",
"one",
"being",
"generated",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L119-L126 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.nonce | private function nonce($length=12, $include_time=true) {
if ($this->config['force_nonce'] === false) {
$prefix = $include_time ? microtime() : '';
return md5(substr($prefix . uniqid(), 0, $length));
} else {
return $this->config['force_nonce'];
}
} | php | private function nonce($length=12, $include_time=true) {
if ($this->config['force_nonce'] === false) {
$prefix = $include_time ? microtime() : '';
return md5(substr($prefix . uniqid(), 0, $length));
} else {
return $this->config['force_nonce'];
}
} | [
"private",
"function",
"nonce",
"(",
"$",
"length",
"=",
"12",
",",
"$",
"include_time",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'force_nonce'",
"]",
"===",
"false",
")",
"{",
"$",
"prefix",
"=",
"$",
"include_time",
"?",... | Generates a random OAuth nonce.
If 'force_nonce' is false a nonce will be generated, otherwise the value of '$this->config['force_nonce']' will be used.
@param string $length how many characters the nonce should be before MD5 hashing. default 12
@param string $include_time whether to include time at the beginning of t... | [
"Generates",
"a",
"random",
"OAuth",
"nonce",
".",
"If",
"force_nonce",
"is",
"false",
"a",
"nonce",
"will",
"be",
"generated",
"otherwise",
"the",
"value",
"of",
"$this",
"-",
">",
"config",
"[",
"force_nonce",
"]",
"will",
"be",
"used",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L136-L143 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.timestamp | private function timestamp() {
if ($this->config['force_timestamp'] === false) {
$time = time();
} else {
$time = $this->config['force_timestamp'];
}
return (string) $time;
} | php | private function timestamp() {
if ($this->config['force_timestamp'] === false) {
$time = time();
} else {
$time = $this->config['force_timestamp'];
}
return (string) $time;
} | [
"private",
"function",
"timestamp",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'force_timestamp'",
"]",
"===",
"false",
")",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"}",
"else",
"{",
"$",
"time",
"=",
"$",
"this",
"->",
"c... | Generates a timestamp.
If 'force_timestamp' is false a timestamp will be generated, otherwise the value of '$this->config['force_timestamp']' will be used.
@return $time as a string | [
"Generates",
"a",
"timestamp",
".",
"If",
"force_timestamp",
"is",
"false",
"a",
"timestamp",
"will",
"be",
"generated",
"otherwise",
"the",
"value",
"of",
"$this",
"-",
">",
"config",
"[",
"force_timestamp",
"]",
"will",
"be",
"used",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L151-L158 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.safe_encode | private function safe_encode($data) {
if (is_array($data)) {
return array_map(array($this, 'safe_encode'), $data);
} else if (is_scalar($data)) {
return str_ireplace(
array('+', '%7E'),
array(' ', '~'),
rawurlencode($data)
);
} else {
return '';
}
} | php | private function safe_encode($data) {
if (is_array($data)) {
return array_map(array($this, 'safe_encode'), $data);
} else if (is_scalar($data)) {
return str_ireplace(
array('+', '%7E'),
array(' ', '~'),
rawurlencode($data)
);
} else {
return '';
}
} | [
"private",
"function",
"safe_encode",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'safe_encode'",
")",
",",
"$",
"data",
")",
";",
"}",
"else",
"if... | Encodes the string or array passed in a way compatible with OAuth.
If an array is passed each array value will will be encoded.
@param mixed $data the scalar or array to encode
@return $data encoded in a way compatible with OAuth | [
"Encodes",
"the",
"string",
"or",
"array",
"passed",
"in",
"a",
"way",
"compatible",
"with",
"OAuth",
".",
"If",
"an",
"array",
"is",
"passed",
"each",
"array",
"value",
"will",
"will",
"be",
"encoded",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L167-L179 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.safe_decode | private function safe_decode($data) {
if (is_array($data)) {
return array_map(array($this, 'safe_decode'), $data);
} else if (is_scalar($data)) {
return rawurldecode($data);
} else {
return '';
}
} | php | private function safe_decode($data) {
if (is_array($data)) {
return array_map(array($this, 'safe_decode'), $data);
} else if (is_scalar($data)) {
return rawurldecode($data);
} else {
return '';
}
} | [
"private",
"function",
"safe_decode",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"array_map",
"(",
"array",
"(",
"$",
"this",
",",
"'safe_decode'",
")",
",",
"$",
"data",
")",
";",
"}",
"else",
"if... | Decodes the string or array from it's URL encoded form
If an array is passed each array value will will be decoded.
@param mixed $data the scalar or array to decode
@return string $data decoded from the URL encoded form | [
"Decodes",
"the",
"string",
"or",
"array",
"from",
"it",
"s",
"URL",
"encoded",
"form",
"If",
"an",
"array",
"is",
"passed",
"each",
"array",
"value",
"will",
"will",
"be",
"decoded",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L188-L196 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.prepare_oauth1_params | private function prepare_oauth1_params() {
$defaults = array(
'oauth_nonce' => $this->nonce(),
'oauth_timestamp' => $this->timestamp(),
'oauth_version' => $this->config['oauth_version'],
'oauth_consumer_key' => $this->config['consumer_key'],
'oauth_signat... | php | private function prepare_oauth1_params() {
$defaults = array(
'oauth_nonce' => $this->nonce(),
'oauth_timestamp' => $this->timestamp(),
'oauth_version' => $this->config['oauth_version'],
'oauth_consumer_key' => $this->config['consumer_key'],
'oauth_signat... | [
"private",
"function",
"prepare_oauth1_params",
"(",
")",
"{",
"$",
"defaults",
"=",
"array",
"(",
"'oauth_nonce'",
"=>",
"$",
"this",
"->",
"nonce",
"(",
")",
",",
"'oauth_timestamp'",
"=>",
"$",
"this",
"->",
"timestamp",
"(",
")",
",",
"'oauth_version'",
... | Prepares OAuth1 signing parameters.
@return void all required OAuth parameters, safely encoded, are stored to the class variable '$this->request_settings['oauth1_params']' | [
"Prepares",
"OAuth1",
"signing",
"parameters",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L203-L222 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.prepare_url | private function prepare_url() {
$parts = parse_url($this->request_settings['url']);
$port = isset($parts['port']) ? $parts['port'] : false;
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = isset($parts['path']) ? $parts['path'] : false;
$port or $port = ($scheme == 'https') ?... | php | private function prepare_url() {
$parts = parse_url($this->request_settings['url']);
$port = isset($parts['port']) ? $parts['port'] : false;
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = isset($parts['path']) ? $parts['path'] : false;
$port or $port = ($scheme == 'https') ?... | [
"private",
"function",
"prepare_url",
"(",
")",
"{",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"this",
"->",
"request_settings",
"[",
"'url'",
"]",
")",
";",
"$",
"port",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'port'",
"]",
")",
"?",
"$",
"parts",
... | Prepares the URL for use in the base string by ripping it apart and
reconstructing it.
Ref: 3.4.1.2
@return void value is stored to the class array variable '$this->request_settings['url']' | [
"Prepares",
"the",
"URL",
"for",
"use",
"in",
"the",
"base",
"string",
"by",
"ripping",
"it",
"apart",
"and",
"reconstructing",
"it",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L276-L294 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.multipart_escape | private function multipart_escape($value) {
if (!$this->request_settings['multipart'] || strpos($value, '@') !== 0)
return $value;
// see if the parameter is a file.
// we split on the semi-colon as it's the delimiter used on media uploads
// for fields with semi-colons this will return the origi... | php | private function multipart_escape($value) {
if (!$this->request_settings['multipart'] || strpos($value, '@') !== 0)
return $value;
// see if the parameter is a file.
// we split on the semi-colon as it's the delimiter used on media uploads
// for fields with semi-colons this will return the origi... | [
"private",
"function",
"multipart_escape",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"request_settings",
"[",
"'multipart'",
"]",
"||",
"strpos",
"(",
"$",
"value",
",",
"'@'",
")",
"!==",
"0",
")",
"return",
"$",
"value",
";",
... | If the request uses multipart, and the parameter isn't a file path, prepend a space
otherwise return the original value. we chose a space here as twitter whitespace trims from
the beginning of the tweet. we don't use \0 here because it's the character for string
termination.
@param the parameter value
@return string t... | [
"If",
"the",
"request",
"uses",
"multipart",
"and",
"the",
"parameter",
"isn",
"t",
"a",
"file",
"path",
"prepend",
"a",
"space",
"otherwise",
"return",
"the",
"original",
"value",
".",
"we",
"chose",
"a",
"space",
"here",
"as",
"twitter",
"whitespace",
"t... | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L305-L317 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.prepare_params | private function prepare_params() {
$doing_oauth1 = false;
$this->request_settings['prepared_params'] = array();
$prepared = &$this->request_settings['prepared_params'];
$prepared_pairs = array();
$prepared_pairs_with_oauth = array();
if (isset($this->request_settings['oauth1_params'])) {
... | php | private function prepare_params() {
$doing_oauth1 = false;
$this->request_settings['prepared_params'] = array();
$prepared = &$this->request_settings['prepared_params'];
$prepared_pairs = array();
$prepared_pairs_with_oauth = array();
if (isset($this->request_settings['oauth1_params'])) {
... | [
"private",
"function",
"prepare_params",
"(",
")",
"{",
"$",
"doing_oauth1",
"=",
"false",
";",
"$",
"this",
"->",
"request_settings",
"[",
"'prepared_params'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"prepared",
"=",
"&",
"$",
"this",
"->",
"request_settin... | Prepares all parameters for the base string and request.
Multipart parameters are ignored as they are not defined in the specification,
all other types of parameter are encoded for compatibility with OAuth.
@param array $params the parameters for the request
@return void prepared values are stored in the class array v... | [
"Prepares",
"all",
"parameters",
"for",
"the",
"base",
"string",
"and",
"request",
".",
"Multipart",
"parameters",
"are",
"ignored",
"as",
"they",
"are",
"not",
"defined",
"in",
"the",
"specification",
"all",
"other",
"types",
"of",
"parameter",
"are",
"encode... | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L328-L409 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.prepare_signing_key | private function prepare_signing_key() {
$left = $this->safe_encode($this->config['consumer_secret']);
$right = $this->safe_encode($this->secret());
$this->request_settings['signing_key'] = $left . '&' . $right;
} | php | private function prepare_signing_key() {
$left = $this->safe_encode($this->config['consumer_secret']);
$right = $this->safe_encode($this->secret());
$this->request_settings['signing_key'] = $left . '&' . $right;
} | [
"private",
"function",
"prepare_signing_key",
"(",
")",
"{",
"$",
"left",
"=",
"$",
"this",
"->",
"safe_encode",
"(",
"$",
"this",
"->",
"config",
"[",
"'consumer_secret'",
"]",
")",
";",
"$",
"right",
"=",
"$",
"this",
"->",
"safe_encode",
"(",
"$",
"... | Prepares the OAuth signing key
@return void prepared signing key is stored in the class variable 'signing_key' | [
"Prepares",
"the",
"OAuth",
"signing",
"key"
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L416-L420 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.prepare_base_string | private function prepare_base_string() {
$url = $this->request_settings['url'];
# if the host header is set we need to rewrite the basestring to use
# that, instead of the request host. otherwise the signature won't match
# on the server side
if (!empty($this->request_settings['headers']['Host'])) ... | php | private function prepare_base_string() {
$url = $this->request_settings['url'];
# if the host header is set we need to rewrite the basestring to use
# that, instead of the request host. otherwise the signature won't match
# on the server side
if (!empty($this->request_settings['headers']['Host'])) ... | [
"private",
"function",
"prepare_base_string",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"request_settings",
"[",
"'url'",
"]",
";",
"# if the host header is set we need to rewrite the basestring to use",
"# that, instead of the request host. otherwise the signature won't... | Prepare the base string.
Ref: Spec: 9.1.3 ("Concatenate Request Elements")
@return void prepared base string is stored in the class variable 'base_string' | [
"Prepare",
"the",
"base",
"string",
".",
"Ref",
":",
"Spec",
":",
"9",
".",
"1",
".",
"3",
"(",
"Concatenate",
"Request",
"Elements",
")"
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L428-L448 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.prepare_oauth_signature | private function prepare_oauth_signature() {
$this->request_settings['oauth1_params']['oauth_signature'] = $this->safe_encode(
base64_encode(
hash_hmac(
'sha1', $this->request_settings['basestring'], $this->request_settings['signing_key'], true
)));
} | php | private function prepare_oauth_signature() {
$this->request_settings['oauth1_params']['oauth_signature'] = $this->safe_encode(
base64_encode(
hash_hmac(
'sha1', $this->request_settings['basestring'], $this->request_settings['signing_key'], true
)));
} | [
"private",
"function",
"prepare_oauth_signature",
"(",
")",
"{",
"$",
"this",
"->",
"request_settings",
"[",
"'oauth1_params'",
"]",
"[",
"'oauth_signature'",
"]",
"=",
"$",
"this",
"->",
"safe_encode",
"(",
"base64_encode",
"(",
"hash_hmac",
"(",
"'sha1'",
",",... | Signs the OAuth 1 request
@return void oauth_signature is added to the parameters in the class array variable '$this->request_settings' | [
"Signs",
"the",
"OAuth",
"1",
"request"
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L455-L461 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.prepare_auth_header | private function prepare_auth_header() {
if (!$this->config['as_header'])
return;
// oauth1
if (isset($this->request_settings['oauth1_params'])) {
// sort again as oauth_signature was added post param preparation
uksort($this->request_settings['oauth1_params'], 'strcmp');
$encoded_q... | php | private function prepare_auth_header() {
if (!$this->config['as_header'])
return;
// oauth1
if (isset($this->request_settings['oauth1_params'])) {
// sort again as oauth_signature was added post param preparation
uksort($this->request_settings['oauth1_params'], 'strcmp');
$encoded_q... | [
"private",
"function",
"prepare_auth_header",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"config",
"[",
"'as_header'",
"]",
")",
"return",
";",
"// oauth1",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"request_settings",
"[",
"'oauth1_params'",
"]",... | Prepares the Authorization header
@return void prepared authorization header is stored in the class variable headers['Authorization'] | [
"Prepares",
"the",
"Authorization",
"header"
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L468-L487 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.bearer_token_credentials | public function bearer_token_credentials() {
$credentials = implode(':', array(
$this->safe_encode($this->config['consumer_key']),
$this->safe_encode($this->config['consumer_secret'])
));
return base64_encode($credentials);
} | php | public function bearer_token_credentials() {
$credentials = implode(':', array(
$this->safe_encode($this->config['consumer_key']),
$this->safe_encode($this->config['consumer_secret'])
));
return base64_encode($credentials);
} | [
"public",
"function",
"bearer_token_credentials",
"(",
")",
"{",
"$",
"credentials",
"=",
"implode",
"(",
"':'",
",",
"array",
"(",
"$",
"this",
"->",
"safe_encode",
"(",
"$",
"this",
"->",
"config",
"[",
"'consumer_key'",
"]",
")",
",",
"$",
"this",
"->... | Create the bearer token for OAuth2 requests from the consumer_key and consumer_secret.
@return string the bearer token | [
"Create",
"the",
"bearer",
"token",
"for",
"OAuth2",
"requests",
"from",
"the",
"consumer_key",
"and",
"consumer_secret",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L494-L500 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.request | public function request($method, $url, $params=array(), $useauth=true, $multipart=false, $headers=array()) {
$options = array(
'method' => $method,
'url' => $url,
'params' => $params,
'with_user' => true,
'multipart' => $multipart,
'headers' => $headers
);
$... | php | public function request($method, $url, $params=array(), $useauth=true, $multipart=false, $headers=array()) {
$options = array(
'method' => $method,
'url' => $url,
'params' => $params,
'with_user' => true,
'multipart' => $multipart,
'headers' => $headers
);
$... | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"useauth",
"=",
"true",
",",
"$",
"multipart",
"=",
"false",
",",
"$",
"headers",
"=",
"array",
"(",
")",
")",
"{",
"$",
... | Make an HTTP request using this library. This method doesn't return anything.
Instead the response should be inspected directly.
@param string $method the HTTP method being used. e.g. POST, GET, HEAD etc
@param string $url the request URL without query string parameters
@param array $params the request parameters as a... | [
"Make",
"an",
"HTTP",
"request",
"using",
"this",
"library",
".",
"This",
"method",
"doesn",
"t",
"return",
"anything",
".",
"Instead",
"the",
"response",
"should",
"be",
"inspected",
"directly",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L514-L530 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.oauth1_request | private function oauth1_request() {
$this->prepare_oauth1_params();
$this->prepare_method();
$this->prepare_url();
$this->prepare_params();
$this->prepare_base_string();
$this->prepare_signing_key();
$this->prepare_oauth_signature();
$this->prepare_auth_header();
return $this->curlit... | php | private function oauth1_request() {
$this->prepare_oauth1_params();
$this->prepare_method();
$this->prepare_url();
$this->prepare_params();
$this->prepare_base_string();
$this->prepare_signing_key();
$this->prepare_oauth_signature();
$this->prepare_auth_header();
return $this->curlit... | [
"private",
"function",
"oauth1_request",
"(",
")",
"{",
"$",
"this",
"->",
"prepare_oauth1_params",
"(",
")",
";",
"$",
"this",
"->",
"prepare_method",
"(",
")",
";",
"$",
"this",
"->",
"prepare_url",
"(",
")",
";",
"$",
"this",
"->",
"prepare_params",
"... | Signs the request and adds the OAuth signature. This runs all the request
parameter preparation methods.
@param string $method the HTTP method being used. e.g. POST, GET, HEAD etc
@param string $url the request URL without query string parameters
@param array $params the request parameters as an array of key=value pai... | [
"Signs",
"the",
"request",
"and",
"adds",
"the",
"OAuth",
"signature",
".",
"This",
"runs",
"all",
"the",
"request",
"parameter",
"preparation",
"methods",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L577-L587 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.streaming_request | public function streaming_request($method, $url, $params=array(), $callback='') {
if ( ! empty($callback) ) {
if ( ! is_callable($callback) ) {
return false;
}
$this->config['streaming_callback'] = $callback;
}
$this->metrics['start'] = time();
$this->metrics['interval... | php | public function streaming_request($method, $url, $params=array(), $callback='') {
if ( ! empty($callback) ) {
if ( ! is_callable($callback) ) {
return false;
}
$this->config['streaming_callback'] = $callback;
}
$this->metrics['start'] = time();
$this->metrics['interval... | [
"public",
"function",
"streaming_request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"callback",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"callback",
")",
")",
"{",
"if",
"(",
"!",
... | Make a long poll HTTP request using this library. This method is
different to the other request methods as it isn't supposed to disconnect
Using this method expects a callback which will receive the streaming
responses.
@param string $method the HTTP method being used. e.g. POST, GET, HEAD etc
@param string $url the ... | [
"Make",
"a",
"long",
"poll",
"HTTP",
"request",
"using",
"this",
"library",
".",
"This",
"method",
"is",
"different",
"to",
"the",
"other",
"request",
"methods",
"as",
"it",
"isn",
"t",
"supposed",
"to",
"disconnect"
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L613-L628 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.update_metrics | private function update_metrics() {
$now = time();
if (($this->metrics['interval_start'] + $this->config['streaming_metrics_interval']) > $now)
return null;
$this->metrics['mps'] = round( ($this->metrics['messages'] - $this->metrics['last_messages']) / $this->config['streaming_metrics_interval'], 2);... | php | private function update_metrics() {
$now = time();
if (($this->metrics['interval_start'] + $this->config['streaming_metrics_interval']) > $now)
return null;
$this->metrics['mps'] = round( ($this->metrics['messages'] - $this->metrics['last_messages']) / $this->config['streaming_metrics_interval'], 2);... | [
"private",
"function",
"update_metrics",
"(",
")",
"{",
"$",
"now",
"=",
"time",
"(",
")",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"metrics",
"[",
"'interval_start'",
"]",
"+",
"$",
"this",
"->",
"config",
"[",
"'streaming_metrics_interval'",
"]",
")",
... | Handles the updating of the current Streaming API metrics.
@return array the metrics for the streaming api connection | [
"Handles",
"the",
"updating",
"of",
"the",
"current",
"Streaming",
"API",
"metrics",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L635-L647 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.url | public function url($request, $extension='json') {
// remove multi-slashes
$request = preg_replace('$([^:])//+$', '$1/', $request);
if (stripos($request, 'http') === 0 || stripos($request, '//') === 0) {
return $request;
}
$extension = strlen($extension) > 0 ? ".$extension" : '';
$proto ... | php | public function url($request, $extension='json') {
// remove multi-slashes
$request = preg_replace('$([^:])//+$', '$1/', $request);
if (stripos($request, 'http') === 0 || stripos($request, '//') === 0) {
return $request;
}
$extension = strlen($extension) > 0 ? ".$extension" : '';
$proto ... | [
"public",
"function",
"url",
"(",
"$",
"request",
",",
"$",
"extension",
"=",
"'json'",
")",
"{",
"// remove multi-slashes",
"$",
"request",
"=",
"preg_replace",
"(",
"'$([^:])//+$'",
",",
"'$1/'",
",",
"$",
"request",
")",
";",
"if",
"(",
"stripos",
"(",
... | Utility function to create the request URL in the requested format.
If a fully-qualified URI is provided, it will be returned.
Any multi-slashes (except for the protocol) will be replaced with a single slash.
@param string $request the API method without extension
@param string $extension the format of the response. ... | [
"Utility",
"function",
"to",
"create",
"the",
"request",
"URL",
"in",
"the",
"requested",
"format",
".",
"If",
"a",
"fully",
"-",
"qualified",
"URI",
"is",
"provided",
"it",
"will",
"be",
"returned",
".",
"Any",
"multi",
"-",
"slashes",
"(",
"except",
"f... | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L659-L682 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.curlHeader | private function curlHeader($ch, $header) {
$this->response['raw'] .= $header;
list($key, $value) = array_pad(explode(':', $header, 2), 2, null);
$key = trim($key);
$value = trim($value);
if ( ! isset($this->response['headers'][$key])) {
$this->response['headers'][$key] = $value;
} else... | php | private function curlHeader($ch, $header) {
$this->response['raw'] .= $header;
list($key, $value) = array_pad(explode(':', $header, 2), 2, null);
$key = trim($key);
$value = trim($value);
if ( ! isset($this->response['headers'][$key])) {
$this->response['headers'][$key] = $value;
} else... | [
"private",
"function",
"curlHeader",
"(",
"$",
"ch",
",",
"$",
"header",
")",
"{",
"$",
"this",
"->",
"response",
"[",
"'raw'",
"]",
".=",
"$",
"header",
";",
"list",
"(",
"$",
"key",
",",
"$",
"value",
")",
"=",
"array_pad",
"(",
"explode",
"(",
... | Utility function to parse the returned curl headers and store them in the
class array variable.
@param object $ch curl handle
@param string $header the response headers
@return string the length of the header | [
"Utility",
"function",
"to",
"parse",
"the",
"returned",
"curl",
"headers",
"and",
"store",
"them",
"in",
"the",
"class",
"array",
"variable",
"."
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L703-L721 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.curlWrite | private function curlWrite($ch, $data) {
$l = strlen($data);
if (strpos($data, $this->config['streaming_eol']) === false) {
$this->buffer .= $data;
return $l;
}
$buffered = explode($this->config['streaming_eol'], $data);
$content = $this->buffer . $buffered[0];
$this->metrics['mess... | php | private function curlWrite($ch, $data) {
$l = strlen($data);
if (strpos($data, $this->config['streaming_eol']) === false) {
$this->buffer .= $data;
return $l;
}
$buffered = explode($this->config['streaming_eol'], $data);
$content = $this->buffer . $buffered[0];
$this->metrics['mess... | [
"private",
"function",
"curlWrite",
"(",
"$",
"ch",
",",
"$",
"data",
")",
"{",
"$",
"l",
"=",
"strlen",
"(",
"$",
"data",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"data",
",",
"$",
"this",
"->",
"config",
"[",
"'streaming_eol'",
"]",
")",
"===",... | Utility function to parse the returned curl buffer and store them until
an EOL is found. The buffer for curl is an undefined size so we need
to collect the content until an EOL is found.
This function calls the previously defined streaming callback method.
@param object $ch curl handle
@param string $data the current... | [
"Utility",
"function",
"to",
"parse",
"the",
"returned",
"curl",
"buffer",
"and",
"store",
"them",
"until",
"an",
"EOL",
"is",
"found",
".",
"The",
"buffer",
"for",
"curl",
"is",
"an",
"undefined",
"size",
"so",
"we",
"need",
"to",
"collect",
"the",
"con... | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L734-L762 |
themattharris/tmhOAuth | tmhOAuth.php | tmhOAuth.curlit | private function curlit() {
$this->response = array(
'raw' => ''
);
// configure curl
$c = curl_init();
if ($this->request_settings['method'] == 'GET' && isset($this->request_settings['querystring'])) {
$this->request_settings['url'] = $this->request_settings['url'] . '?' . $this->requ... | php | private function curlit() {
$this->response = array(
'raw' => ''
);
// configure curl
$c = curl_init();
if ($this->request_settings['method'] == 'GET' && isset($this->request_settings['querystring'])) {
$this->request_settings['url'] = $this->request_settings['url'] . '?' . $this->requ... | [
"private",
"function",
"curlit",
"(",
")",
"{",
"$",
"this",
"->",
"response",
"=",
"array",
"(",
"'raw'",
"=>",
"''",
")",
";",
"// configure curl",
"$",
"c",
"=",
"curl_init",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"request_settings",
"[",
"'... | Makes a curl request. Takes no parameters as all should have been prepared
by the request method
the response data is stored in the class variable 'response'
@return int the http response code for the request. 0 is returned if a connection could not be made | [
"Makes",
"a",
"curl",
"request",
".",
"Takes",
"no",
"parameters",
"as",
"all",
"should",
"have",
"been",
"prepared",
"by",
"the",
"request",
"method"
] | train | https://github.com/themattharris/tmhOAuth/blob/455552d6c57549632644b6c9ac9204766be2b5ee/tmhOAuth.php#L772-L861 |
troydavisson/PHRETS | src/Models/Metadata/Base.php | Base.offsetExists | public function offsetExists($offset)
{
foreach (array_merge($this->getXmlElements(), $this->getXmlAttributes()) as $attr) {
if (strtolower($attr) == strtolower($offset)) {
return true;
}
}
return false;
} | php | public function offsetExists($offset)
{
foreach (array_merge($this->getXmlElements(), $this->getXmlAttributes()) as $attr) {
if (strtolower($attr) == strtolower($offset)) {
return true;
}
}
return false;
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"foreach",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getXmlElements",
"(",
")",
",",
"$",
"this",
"->",
"getXmlAttributes",
"(",
")",
")",
"as",
"$",
"attr",
")",
"{",
"if",
"(",
... | (PHP 5 >= 5.0.0)<br/>
Whether a offset exists
@link http://php.net/manual/en/arrayaccess.offsetexists.php
@param mixed $offset <p>
An offset to check for.
</p>
@return boolean true on success or false on failure.
</p>
<p>
The return value will be casted to boolean if non-boolean was returned. | [
"(",
"PHP",
"5",
">",
";",
"=",
"5",
".",
"0",
".",
"0",
")",
"<br",
"/",
">",
"Whether",
"a",
"offset",
"exists"
] | train | https://github.com/troydavisson/PHRETS/blob/8eb9c43dfea54760383e0fcba4f55468568f9fc2/src/Models/Metadata/Base.php#L87-L95 |
troydavisson/PHRETS | src/Models/Metadata/Base.php | Base.offsetGet | public function offsetGet($offset)
{
foreach (array_merge($this->getXmlElements(), $this->getXmlAttributes()) as $attr) {
if (strtolower($attr) == strtolower($offset)) {
return \array_get($this->values, $attr);
}
}
return null;
} | php | public function offsetGet($offset)
{
foreach (array_merge($this->getXmlElements(), $this->getXmlAttributes()) as $attr) {
if (strtolower($attr) == strtolower($offset)) {
return \array_get($this->values, $attr);
}
}
return null;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"offset",
")",
"{",
"foreach",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"getXmlElements",
"(",
")",
",",
"$",
"this",
"->",
"getXmlAttributes",
"(",
")",
")",
"as",
"$",
"attr",
")",
"{",
"if",
"(",
"st... | (PHP 5 >= 5.0.0)<br/>
Offset to retrieve
@link http://php.net/manual/en/arrayaccess.offsetget.php
@param mixed $offset <p>
The offset to retrieve.
</p>
@return mixed Can return all value types. | [
"(",
"PHP",
"5",
">",
";",
"=",
"5",
".",
"0",
".",
"0",
")",
"<br",
"/",
">",
"Offset",
"to",
"retrieve"
] | train | https://github.com/troydavisson/PHRETS/blob/8eb9c43dfea54760383e0fcba4f55468568f9fc2/src/Models/Metadata/Base.php#L106-L114 |
troydavisson/PHRETS | src/Models/Search/Results.php | Results.keyResultsBy | public function keyResultsBy($field)
{
$results = clone $this->results;
$this->results = new Collection;
foreach ($results as $r) {
$this->addRecord($r, $field);
}
} | php | public function keyResultsBy($field)
{
$results = clone $this->results;
$this->results = new Collection;
foreach ($results as $r) {
$this->addRecord($r, $field);
}
} | [
"public",
"function",
"keyResultsBy",
"(",
"$",
"field",
")",
"{",
"$",
"results",
"=",
"clone",
"$",
"this",
"->",
"results",
";",
"$",
"this",
"->",
"results",
"=",
"new",
"Collection",
";",
"foreach",
"(",
"$",
"results",
"as",
"$",
"r",
")",
"{",... | Set which field's value will be used to key the records by
@param $field | [
"Set",
"which",
"field",
"s",
"value",
"will",
"be",
"used",
"to",
"key",
"the",
"records",
"by"
] | train | https://github.com/troydavisson/PHRETS/blob/8eb9c43dfea54760383e0fcba4f55468568f9fc2/src/Models/Search/Results.php#L75-L82 |
troydavisson/PHRETS | src/Models/Search/Results.php | Results.lists | public function lists($field)
{
$l = [];
foreach ($this->results as $r) {
$v = $r->get($field);
if ($v and !$r->isRestricted($field)) {
$l[] = $v;
}
}
return $l;
} | php | public function lists($field)
{
$l = [];
foreach ($this->results as $r) {
$v = $r->get($field);
if ($v and !$r->isRestricted($field)) {
$l[] = $v;
}
}
return $l;
} | [
"public",
"function",
"lists",
"(",
"$",
"field",
")",
"{",
"$",
"l",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"results",
"as",
"$",
"r",
")",
"{",
"$",
"v",
"=",
"$",
"r",
"->",
"get",
"(",
"$",
"field",
")",
";",
"if",
"(",
... | Returns an array containing the values from the given field
@param $field
@return array | [
"Returns",
"an",
"array",
"containing",
"the",
"values",
"from",
"the",
"given",
"field"
] | train | https://github.com/troydavisson/PHRETS/blob/8eb9c43dfea54760383e0fcba4f55468568f9fc2/src/Models/Search/Results.php#L344-L354 |
troydavisson/PHRETS | src/Models/Search/Results.php | Results.toCSV | public function toCSV()
{
// create a temporary file so we can write the CSV out
$writer = Writer::createFromFileObject(new SplTempFileObject);
// add the header line
$writer->insertOne($this->getHeaders());
// go through each record
foreach ($this->results as $r) {... | php | public function toCSV()
{
// create a temporary file so we can write the CSV out
$writer = Writer::createFromFileObject(new SplTempFileObject);
// add the header line
$writer->insertOne($this->getHeaders());
// go through each record
foreach ($this->results as $r) {... | [
"public",
"function",
"toCSV",
"(",
")",
"{",
"// create a temporary file so we can write the CSV out",
"$",
"writer",
"=",
"Writer",
"::",
"createFromFileObject",
"(",
"new",
"SplTempFileObject",
")",
";",
"// add the header line",
"$",
"writer",
"->",
"insertOne",
"("... | Return results as a large prepared CSV string
@return string | [
"Return",
"results",
"as",
"a",
"large",
"prepared",
"CSV",
"string"
] | train | https://github.com/troydavisson/PHRETS/blob/8eb9c43dfea54760383e0fcba4f55468568f9fc2/src/Models/Search/Results.php#L361-L382 |
troydavisson/PHRETS | src/Models/Search/Results.php | Results.toArray | public function toArray()
{
$result = [];
foreach ($this->results as $r) {
$result[] = $r->toArray();
}
return $result;
} | php | public function toArray()
{
$result = [];
foreach ($this->results as $r) {
$result[] = $r->toArray();
}
return $result;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"results",
"as",
"$",
"r",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"r",
"->",
"toArray",
"(",
")",
";",
"}",
"return",
... | Return results as a simple array
@return array | [
"Return",
"results",
"as",
"a",
"simple",
"array"
] | train | https://github.com/troydavisson/PHRETS/blob/8eb9c43dfea54760383e0fcba4f55468568f9fc2/src/Models/Search/Results.php#L399-L406 |
jhedstrom/drupalextension | src/Drupal/DrupalExtension/Context/ConfigContext.php | ConfigContext.cleanConfig | public function cleanConfig()
{
// Revert config that was changed.
foreach ($this->config as $name => $key_value) {
foreach ($key_value as $key => $value) {
$this->getDriver()->configSet($name, $key, $value);
}
}
$this->config = array();
} | php | public function cleanConfig()
{
// Revert config that was changed.
foreach ($this->config as $name => $key_value) {
foreach ($key_value as $key => $value) {
$this->getDriver()->configSet($name, $key, $value);
}
}
$this->config = array();
} | [
"public",
"function",
"cleanConfig",
"(",
")",
"{",
"// Revert config that was changed.",
"foreach",
"(",
"$",
"this",
"->",
"config",
"as",
"$",
"name",
"=>",
"$",
"key_value",
")",
"{",
"foreach",
"(",
"$",
"key_value",
"as",
"$",
"key",
"=>",
"$",
"valu... | Revert any changed config.
@AfterScenario | [
"Revert",
"any",
"changed",
"config",
"."
] | train | https://github.com/jhedstrom/drupalextension/blob/d117c1a23b83c0e88b6224ed5d1d3458ce255b5a/src/Drupal/DrupalExtension/Context/ConfigContext.php#L39-L48 |
jhedstrom/drupalextension | src/Drupal/DrupalExtension/Context/ConfigContext.php | ConfigContext.setComplexConfig | public function setComplexConfig($name, $key, TableNode $config_table)
{
$value = array();
foreach ($config_table->getHash() as $row) {
// Allow json values for extra complexity.
if (json_decode($row['value'])) {
$row['value'] = json_decode($row['value'], true... | php | public function setComplexConfig($name, $key, TableNode $config_table)
{
$value = array();
foreach ($config_table->getHash() as $row) {
// Allow json values for extra complexity.
if (json_decode($row['value'])) {
$row['value'] = json_decode($row['value'], true... | [
"public",
"function",
"setComplexConfig",
"(",
"$",
"name",
",",
"$",
"key",
",",
"TableNode",
"$",
"config_table",
")",
"{",
"$",
"value",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"config_table",
"->",
"getHash",
"(",
")",
"as",
"$",
"row",
... | Sets complex configuration.
@param string $name
The name of the configuration object.
@param string $key
Identifier to store value in configuration.
@param TableNode $config_table
The table listing configuration keys and values.
@Given I set the configuration item :name with key :key with values:
Provide configurati... | [
"Sets",
"complex",
"configuration",
"."
] | train | https://github.com/jhedstrom/drupalextension/blob/d117c1a23b83c0e88b6224ed5d1d3458ce255b5a/src/Drupal/DrupalExtension/Context/ConfigContext.php#L83-L94 |
jhedstrom/drupalextension | src/Drupal/DrupalExtension/Context/ConfigContext.php | ConfigContext.setConfig | public function setConfig($name, $key, $value)
{
$backup = $this->getDriver()->configGet($name, $key);
$this->getDriver()->configSet($name, $key, $value);
if (!array_key_exists($name, $this->config)) {
$this->config[$name][$key] = $backup;
return;
}
i... | php | public function setConfig($name, $key, $value)
{
$backup = $this->getDriver()->configGet($name, $key);
$this->getDriver()->configSet($name, $key, $value);
if (!array_key_exists($name, $this->config)) {
$this->config[$name][$key] = $backup;
return;
}
i... | [
"public",
"function",
"setConfig",
"(",
"$",
"name",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"backup",
"=",
"$",
"this",
"->",
"getDriver",
"(",
")",
"->",
"configGet",
"(",
"$",
"name",
",",
"$",
"key",
")",
";",
"$",
"this",
"->",
... | Sets a value in a configuration object.
@param string $name
The name of the configuration object.
@param string $key
Identifier to store value in configuration.
@param mixed $value
Value to associate with identifier. | [
"Sets",
"a",
"value",
"in",
"a",
"configuration",
"object",
"."
] | train | https://github.com/jhedstrom/drupalextension/blob/d117c1a23b83c0e88b6224ed5d1d3458ce255b5a/src/Drupal/DrupalExtension/Context/ConfigContext.php#L106-L118 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.