id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37,300 | CeusMedia/Common | src/XML/Element.php | XML_Element.addChildCData | public function addChildCData( $name, $text, $nsPrefix = NULL, $nsURI = NULL )
{
$child = $this->addChild( $name, NULL, $nsPrefix, $nsURI );
$child->addCData( $text );
return $child;
} | php | public function addChildCData( $name, $text, $nsPrefix = NULL, $nsURI = NULL )
{
$child = $this->addChild( $name, NULL, $nsPrefix, $nsURI );
$child->addCData( $text );
return $child;
} | [
"public",
"function",
"addChildCData",
"(",
"$",
"name",
",",
"$",
"text",
",",
"$",
"nsPrefix",
"=",
"NULL",
",",
"$",
"nsURI",
"=",
"NULL",
")",
"{",
"$",
"child",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"name",
",",
"NULL",
",",
"$",
"nsPrefix",
",",
"$",
"nsURI",
")",
";",
"$",
"child",
"->",
"addCData",
"(",
"$",
"text",
")",
";",
"return",
"$",
"child",
";",
"}"
] | Create a child element with CDATA value
@param string $name The name of the child element to add.
@param string $cdata_text The CDATA value of the child element.
@param string $nsPrefix Namespace prefix of child element
@param string $nsURI Namespace URI of child element
@return XML_Element
@reprecated use addChild instead | [
"Create",
"a",
"child",
"element",
"with",
"CDATA",
"value"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L127-L132 |
37,301 | CeusMedia/Common | src/XML/Element.php | XML_Element.countChildren | public function countChildren( $nsPrefix = NULL )
{
$i = 0;
foreach( $this->children( $nsPrefix, TRUE ) as $node )
$i++;
return $i;
} | php | public function countChildren( $nsPrefix = NULL )
{
$i = 0;
foreach( $this->children( $nsPrefix, TRUE ) as $node )
$i++;
return $i;
} | [
"public",
"function",
"countChildren",
"(",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
"as",
"$",
"node",
")",
"$",
"i",
"++",
";",
"return",
"$",
"i",
";",
"}"
] | Returns count of children.
@access public
@return int | [
"Returns",
"count",
"of",
"children",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L162-L168 |
37,302 | CeusMedia/Common | src/XML/Element.php | XML_Element.getAttribute | public function getAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
if( !isset( $data[$name] ) )
throw new RuntimeException( 'Attribute "'.( $nsPrefix ? $nsPrefix.':'.$name : $name ).'" is not set' );
return (string) $data[$name];
} | php | public function getAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
if( !isset( $data[$name] ) )
throw new RuntimeException( 'Attribute "'.( $nsPrefix ? $nsPrefix.':'.$name : $name ).'" is not set' );
return (string) $data[$name];
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"data",
"=",
"$",
"nsPrefix",
"?",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
":",
"$",
"this",
"->",
"attributes",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"name",
"]",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Attribute \"'",
".",
"(",
"$",
"nsPrefix",
"?",
"$",
"nsPrefix",
".",
"':'",
".",
"$",
"name",
":",
"$",
"name",
")",
".",
"'\" is not set'",
")",
";",
"return",
"(",
"string",
")",
"$",
"data",
"[",
"$",
"name",
"]",
";",
"}"
] | Returns the value of an attribute by it's name.
@access public
@param string $name Name of attribute
@param string $nsPrefix Namespace prefix of attribute
@return bool
@throws RuntimeException if attribute is not set | [
"Returns",
"the",
"value",
"of",
"an",
"attribute",
"by",
"it",
"s",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L178-L184 |
37,303 | CeusMedia/Common | src/XML/Element.php | XML_Element.getAttributeNames | public function getAttributeNames( $nsPrefix = NULL )
{
$list = array();
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $name => $value )
$list[] = $name;
return $list;
} | php | public function getAttributeNames( $nsPrefix = NULL )
{
$list = array();
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $name => $value )
$list[] = $name;
return $list;
} | [
"public",
"function",
"getAttributeNames",
"(",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"data",
"=",
"$",
"nsPrefix",
"?",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
":",
"$",
"this",
"->",
"attributes",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"name",
";",
"return",
"$",
"list",
";",
"}"
] | Returns List of attribute names.
@access public
@param string $nsPrefix Namespace prefix of attribute
@return array | [
"Returns",
"List",
"of",
"attribute",
"names",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L192-L199 |
37,304 | CeusMedia/Common | src/XML/Element.php | XML_Element.getAttributes | public function getAttributes( $nsPrefix = NULL )
{
$list = array();
foreach( $this->attributes( $nsPrefix, TRUE ) as $name => $value )
$list[$name] = (string) $value;
return $list;
} | php | public function getAttributes( $nsPrefix = NULL )
{
$list = array();
foreach( $this->attributes( $nsPrefix, TRUE ) as $name => $value )
$list[$name] = (string) $value;
return $list;
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"$",
"list",
"[",
"$",
"name",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"return",
"$",
"list",
";",
"}"
] | Returns map of attributes.
@access public
@param string $nsPrefix Namespace prefix of attributes
@return array | [
"Returns",
"map",
"of",
"attributes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L207-L213 |
37,305 | CeusMedia/Common | src/XML/Element.php | XML_Element.hasAttribute | public function hasAttribute( $name, $nsPrefix = NULL )
{
$names = $this->getAttributeNames( $nsPrefix );
return in_array( $name, $names );
} | php | public function hasAttribute( $name, $nsPrefix = NULL )
{
$names = $this->getAttributeNames( $nsPrefix );
return in_array( $name, $names );
} | [
"public",
"function",
"hasAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"names",
"=",
"$",
"this",
"->",
"getAttributeNames",
"(",
"$",
"nsPrefix",
")",
";",
"return",
"in_array",
"(",
"$",
"name",
",",
"$",
"names",
")",
";",
"}"
] | Indicates whether an attribute is existing by it's name.
@access public
@param string $name Name of attribute
@param string $nsPrefix Namespace prefix of attribute
@return bool | [
"Indicates",
"whether",
"an",
"attribute",
"is",
"existing",
"by",
"it",
"s",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L232-L236 |
37,306 | CeusMedia/Common | src/XML/Element.php | XML_Element.removeAttribute | public function removeAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $key => $attributeNode )
{
if( $key == $name )
{
unset( $data[$key] );
return TRUE;
}
}
return FALSE;
} | php | public function removeAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $key => $attributeNode )
{
if( $key == $name )
{
unset( $data[$key] );
return TRUE;
}
}
return FALSE;
} | [
"public",
"function",
"removeAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"data",
"=",
"$",
"nsPrefix",
"?",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
":",
"$",
"this",
"->",
"attributes",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"attributeNode",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"$",
"name",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"return",
"TRUE",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | Removes an attribute by it's name.
@access public
@param string $name Name of attribute
@param string $nsPrefix Namespace prefix of attribute
@return boolean | [
"Removes",
"an",
"attribute",
"by",
"it",
"s",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L245-L257 |
37,307 | CeusMedia/Common | src/XML/Element.php | XML_Element.setAttribute | public function setAttribute( $name, $value, $nsPrefix = NULL, $nsURI = NULL )
{
if( $value !== NULL )
{
if( !$this->hasAttribute( $name, $nsPrefix ) )
return $this->addAttribute( $name, $value, $nsPrefix, $nsURI );
$this->removeAttribute( $name, $nsPrefix );
$this->addAttribute( $name, $value, $nsPrefix, $nsURI );
}
else if( $this->hasAttribute( $name, $nsPrefix ) )
{
$this->removeAttribute( $name, $nsPrefix );
}
} | php | public function setAttribute( $name, $value, $nsPrefix = NULL, $nsURI = NULL )
{
if( $value !== NULL )
{
if( !$this->hasAttribute( $name, $nsPrefix ) )
return $this->addAttribute( $name, $value, $nsPrefix, $nsURI );
$this->removeAttribute( $name, $nsPrefix );
$this->addAttribute( $name, $value, $nsPrefix, $nsURI );
}
else if( $this->hasAttribute( $name, $nsPrefix ) )
{
$this->removeAttribute( $name, $nsPrefix );
}
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"nsPrefix",
"=",
"NULL",
",",
"$",
"nsURI",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
")",
")",
"return",
"$",
"this",
"->",
"addAttribute",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"nsPrefix",
",",
"$",
"nsURI",
")",
";",
"$",
"this",
"->",
"removeAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
")",
";",
"$",
"this",
"->",
"addAttribute",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"nsPrefix",
",",
"$",
"nsURI",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"hasAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
")",
")",
"{",
"$",
"this",
"->",
"removeAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
")",
";",
"}",
"}"
] | Sets an attribute from by it's name.
Adds attribute if not existing.
Removes attribute if value is NULL.
@access public
@param string $name Name of attribute
@param string $value Value of attribute, NULL means removal
@param string $nsPrefix Namespace prefix of attribute
@param string $nsURI Namespace URI of attribute
@return void | [
"Sets",
"an",
"attribute",
"from",
"by",
"it",
"s",
"name",
".",
"Adds",
"attribute",
"if",
"not",
"existing",
".",
"Removes",
"attribute",
"if",
"value",
"is",
"NULL",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L293-L306 |
37,308 | CeusMedia/Common | src/XML/Element.php | XML_Element.setValue | public function setValue( $value, $cdata = FALSE )
{
if( !is_string( $value ) && $value !== NULL )
throw new InvalidArgumentException( 'Value must be a string or NULL' );
$value = preg_replace( "/(.*)<!\[CDATA\[(.*)\]\]>(.*)/iU", "\\1\\2\\3", $value );
if( $cdata || preg_match( '/&|</', $value ) ) // string is known or detected to be CDATA
{
$dom = dom_import_simplexml( $this ); // import node in DOM
$cdata = $dom->ownerDocument->createCDATASection( $value ); // create a new CDATA section
$dom->nodeValue = ""; // clear node content
$dom->appendChild( $cdata ); // add CDATA section
}
else // normal node content
{
dom_import_simplexml( $this )->nodeValue = $value; // set node content
}
} | php | public function setValue( $value, $cdata = FALSE )
{
if( !is_string( $value ) && $value !== NULL )
throw new InvalidArgumentException( 'Value must be a string or NULL' );
$value = preg_replace( "/(.*)<!\[CDATA\[(.*)\]\]>(.*)/iU", "\\1\\2\\3", $value );
if( $cdata || preg_match( '/&|</', $value ) ) // string is known or detected to be CDATA
{
$dom = dom_import_simplexml( $this ); // import node in DOM
$cdata = $dom->ownerDocument->createCDATASection( $value ); // create a new CDATA section
$dom->nodeValue = ""; // clear node content
$dom->appendChild( $cdata ); // add CDATA section
}
else // normal node content
{
dom_import_simplexml( $this )->nodeValue = $value; // set node content
}
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
",",
"$",
"cdata",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"!==",
"NULL",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Value must be a string or NULL'",
")",
";",
"$",
"value",
"=",
"preg_replace",
"(",
"\"/(.*)<!\\[CDATA\\[(.*)\\]\\]>(.*)/iU\"",
",",
"\"\\\\1\\\\2\\\\3\"",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"cdata",
"||",
"preg_match",
"(",
"'/&|</'",
",",
"$",
"value",
")",
")",
"// string is known or detected to be CDATA",
"{",
"$",
"dom",
"=",
"dom_import_simplexml",
"(",
"$",
"this",
")",
";",
"// import node in DOM",
"$",
"cdata",
"=",
"$",
"dom",
"->",
"ownerDocument",
"->",
"createCDATASection",
"(",
"$",
"value",
")",
";",
"// create a new CDATA section",
"$",
"dom",
"->",
"nodeValue",
"=",
"\"\"",
";",
"// clear node content",
"$",
"dom",
"->",
"appendChild",
"(",
"$",
"cdata",
")",
";",
"// add CDATA section",
"}",
"else",
"// normal node content",
"{",
"dom_import_simplexml",
"(",
"$",
"this",
")",
"->",
"nodeValue",
"=",
"$",
"value",
";",
"// set node content",
"}",
"}"
] | Returns Text Value.
@access public
@return string | [
"Returns",
"Text",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L313-L330 |
37,309 | CeusMedia/Common | src/FS/File/CSV/Iterator.php | FS_File_CSV_Iterator.next | public function next()
{
if( is_resource( $this->filePointer ) )
{
if( !feof( $this->filePointer ) )
{
$data = fgetcsv(
$this->filePointer,
self::$maxRowSize,
$this->delimiter,
$this->enclosure
);
//A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error.
if( count( $data ) == 1 && ( !isset( $data[0] ) || trim( $data[0] ) == '') )
return $this->next();
if( $data )
{
$this->currentElement = $data;
$this->rowCounter++;
return TRUE;
}
}
}
return FALSE;
} | php | public function next()
{
if( is_resource( $this->filePointer ) )
{
if( !feof( $this->filePointer ) )
{
$data = fgetcsv(
$this->filePointer,
self::$maxRowSize,
$this->delimiter,
$this->enclosure
);
//A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error.
if( count( $data ) == 1 && ( !isset( $data[0] ) || trim( $data[0] ) == '') )
return $this->next();
if( $data )
{
$this->currentElement = $data;
$this->rowCounter++;
return TRUE;
}
}
}
return FALSE;
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"filePointer",
")",
")",
"{",
"if",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"filePointer",
")",
")",
"{",
"$",
"data",
"=",
"fgetcsv",
"(",
"$",
"this",
"->",
"filePointer",
",",
"self",
"::",
"$",
"maxRowSize",
",",
"$",
"this",
"->",
"delimiter",
",",
"$",
"this",
"->",
"enclosure",
")",
";",
"//A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error. ",
"if",
"(",
"count",
"(",
"$",
"data",
")",
"==",
"1",
"&&",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"||",
"trim",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"==",
"''",
")",
")",
"return",
"$",
"this",
"->",
"next",
"(",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"currentElement",
"=",
"$",
"data",
";",
"$",
"this",
"->",
"rowCounter",
"++",
";",
"return",
"TRUE",
";",
"}",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | Indicates whether the end of file is not reached.
@access public
@return boolean FALSE on EOF reached, TRUE otherwise | [
"Indicates",
"whether",
"the",
"end",
"of",
"file",
"is",
"not",
"reached",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Iterator.php#L76-L100 |
37,310 | CeusMedia/Common | src/FS/File/CSV/Iterator.php | FS_File_CSV_Iterator.valid | public function valid()
{
if( $this->next() )
return TRUE;
if( is_resource( $this->filePointer ) )
fclose( $this->filePointer );
return FALSE;
} | php | public function valid()
{
if( $this->next() )
return TRUE;
if( is_resource( $this->filePointer ) )
fclose( $this->filePointer );
return FALSE;
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"next",
"(",
")",
")",
"return",
"TRUE",
";",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"filePointer",
")",
")",
"fclose",
"(",
"$",
"this",
"->",
"filePointer",
")",
";",
"return",
"FALSE",
";",
"}"
] | Indicates whether the next row is a valid row.
@access public
@return boolean | [
"Indicates",
"whether",
"the",
"next",
"row",
"is",
"a",
"valid",
"row",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Iterator.php#L118-L125 |
37,311 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.getUrl | public function getUrl( $email ){
$hash = md5( strtolower( trim( $email ) ) );
$query = array(
's' => $this->size,
'd' => $this->default,
'r' => $this->rate,
);
return $this->url.$hash.'?'.http_build_query( $query, NULL, '&' );
} | php | public function getUrl( $email ){
$hash = md5( strtolower( trim( $email ) ) );
$query = array(
's' => $this->size,
'd' => $this->default,
'r' => $this->rate,
);
return $this->url.$hash.'?'.http_build_query( $query, NULL, '&' );
} | [
"public",
"function",
"getUrl",
"(",
"$",
"email",
")",
"{",
"$",
"hash",
"=",
"md5",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"email",
")",
")",
")",
";",
"$",
"query",
"=",
"array",
"(",
"'s'",
"=>",
"$",
"this",
"->",
"size",
",",
"'d'",
"=>",
"$",
"this",
"->",
"default",
",",
"'r'",
"=>",
"$",
"this",
"->",
"rate",
",",
")",
";",
"return",
"$",
"this",
"->",
"url",
".",
"$",
"hash",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"query",
",",
"NULL",
",",
"'&'",
")",
";",
"}"
] | Returns URL of Gravatar image.
@access public
@param string $email Email address to get Gravatar image for
@return string Gravatar URL | [
"Returns",
"URL",
"of",
"Gravatar",
"image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L96-L104 |
37,312 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.renderImage | public function renderImage( $email, $attributes = array() ){
$attributes['src'] = $this->getUrl( $email );
$attributes['width'] = $this->size;
$attributes['height'] = $this->size;
return UI_HTML_Tag::create( 'img', NULL, $attributes );
} | php | public function renderImage( $email, $attributes = array() ){
$attributes['src'] = $this->getUrl( $email );
$attributes['width'] = $this->size;
$attributes['height'] = $this->size;
return UI_HTML_Tag::create( 'img', NULL, $attributes );
} | [
"public",
"function",
"renderImage",
"(",
"$",
"email",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attributes",
"[",
"'src'",
"]",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"$",
"email",
")",
";",
"$",
"attributes",
"[",
"'width'",
"]",
"=",
"$",
"this",
"->",
"size",
";",
"$",
"attributes",
"[",
"'height'",
"]",
"=",
"$",
"this",
"->",
"size",
";",
"return",
"UI_HTML_Tag",
"::",
"create",
"(",
"'img'",
",",
"NULL",
",",
"$",
"attributes",
")",
";",
"}"
] | Returns rendered image HTML code.
@access public
@param string $email Email address to get Gravatar image for
@param array $attributes Additional HTML tag attributes
@return string Image HTML code | [
"Returns",
"rendered",
"image",
"HTML",
"code",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L130-L135 |
37,313 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.setSize | public function setSize( $size ){
if( !is_integer( $size ) )
throw new InvalidArgumentException( 'Size must be an integer' );
if( $size < 1 )
throw new OutOfBoundsException( 'Size must be atleast 1 pixel' );
if( $size > 512 )
throw new OutOfBoundsException( 'Size must be atmost 512 pixels' );
$this->size = $size;
} | php | public function setSize( $size ){
if( !is_integer( $size ) )
throw new InvalidArgumentException( 'Size must be an integer' );
if( $size < 1 )
throw new OutOfBoundsException( 'Size must be atleast 1 pixel' );
if( $size > 512 )
throw new OutOfBoundsException( 'Size must be atmost 512 pixels' );
$this->size = $size;
} | [
"public",
"function",
"setSize",
"(",
"$",
"size",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"size",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Size must be an integer'",
")",
";",
"if",
"(",
"$",
"size",
"<",
"1",
")",
"throw",
"new",
"OutOfBoundsException",
"(",
"'Size must be atleast 1 pixel'",
")",
";",
"if",
"(",
"$",
"size",
">",
"512",
")",
"throw",
"new",
"OutOfBoundsException",
"(",
"'Size must be atmost 512 pixels'",
")",
";",
"$",
"this",
"->",
"size",
"=",
"$",
"size",
";",
"}"
] | Sets size of image to get from Gravatar.
@access public
@param integer $size Size of image (within 1 and 512) in pixels
@return void | [
"Sets",
"size",
"of",
"image",
"to",
"get",
"from",
"Gravatar",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L167-L175 |
37,314 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.removeImage | public function removeImage( $email, $password, $imageId, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$data = array( 'password' => $password, 'userimage' => $imageId );
$response = $this->callXmlRpc( $email, 'deleteUserImage', $data );
return $response[0];
} | php | public function removeImage( $email, $password, $imageId, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$data = array( 'password' => $password, 'userimage' => $imageId );
$response = $this->callXmlRpc( $email, 'deleteUserImage', $data );
return $response[0];
} | [
"public",
"function",
"removeImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"imageId",
",",
"$",
"rating",
"=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'password'",
"=>",
"$",
"password",
",",
"'userimage'",
"=>",
"$",
"imageId",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"callXmlRpc",
"(",
"$",
"email",
",",
"'deleteUserImage'",
",",
"$",
"data",
")",
";",
"return",
"$",
"response",
"[",
"0",
"]",
";",
"}"
] | ...
Implements XML RPC method 'grav.deleteUserImage'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"deleteUserImage",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L182-L187 |
37,315 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.saveImage | public function saveImage( $email, $password, $imageDataBase64, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveData', array(
'password' => $password,
'data' => $imageDataBase64,
'rating' => $rating
) );
return $response[0];
} | php | public function saveImage( $email, $password, $imageDataBase64, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveData', array(
'password' => $password,
'data' => $imageDataBase64,
'rating' => $rating
) );
return $response[0];
} | [
"public",
"function",
"saveImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"imageDataBase64",
",",
"$",
"rating",
"=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"callXmlRpc",
"(",
"$",
"email",
",",
"'saveData'",
",",
"array",
"(",
"'password'",
"=>",
"$",
"password",
",",
"'data'",
"=>",
"$",
"imageDataBase64",
",",
"'rating'",
"=>",
"$",
"rating",
")",
")",
";",
"return",
"$",
"response",
"[",
"0",
"]",
";",
"}"
] | ...
Implements XML RPC method 'grav.saveData'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"saveData",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L194-L202 |
37,316 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.saveImageFromUrl | public function saveImageFromUrl( $email, $password, $imageUrl, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveUrl', array(
'password' => $password,
'url' => $imageUrl,
'rating' => $rating
) );
return $response[0];
} | php | public function saveImageFromUrl( $email, $password, $imageUrl, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveUrl', array(
'password' => $password,
'url' => $imageUrl,
'rating' => $rating
) );
return $response[0];
} | [
"public",
"function",
"saveImageFromUrl",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"imageUrl",
",",
"$",
"rating",
"=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"callXmlRpc",
"(",
"$",
"email",
",",
"'saveUrl'",
",",
"array",
"(",
"'password'",
"=>",
"$",
"password",
",",
"'url'",
"=>",
"$",
"imageUrl",
",",
"'rating'",
"=>",
"$",
"rating",
")",
")",
";",
"return",
"$",
"response",
"[",
"0",
"]",
";",
"}"
] | ...
Implements XML RPC method 'grav.saveUrl'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"saveUrl",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L209-L217 |
37,317 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.setAddressImage | public function setAddressImage( $email, $password, $address, $imageId ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'useUserimage', array(
'password' => $password,
'addresses' => array( $address ),
'userimage' => $imageId
) );
return $response[0];
} | php | public function setAddressImage( $email, $password, $address, $imageId ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'useUserimage', array(
'password' => $password,
'addresses' => array( $address ),
'userimage' => $imageId
) );
return $response[0];
} | [
"public",
"function",
"setAddressImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"address",
",",
"$",
"imageId",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"callXmlRpc",
"(",
"$",
"email",
",",
"'useUserimage'",
",",
"array",
"(",
"'password'",
"=>",
"$",
"password",
",",
"'addresses'",
"=>",
"array",
"(",
"$",
"address",
")",
",",
"'userimage'",
"=>",
"$",
"imageId",
")",
")",
";",
"return",
"$",
"response",
"[",
"0",
"]",
";",
"}"
] | ...
Implements XML RPC method 'grav.useUserimage'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"useUserimage",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L224-L232 |
37,318 | CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.unsetAddressImage | public function unsetAddressImage( $email, $password, $address ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'removeImage', array(
'password' => $password,
'addresses' => array( $address ),
) );
return $response[0];
} | php | public function unsetAddressImage( $email, $password, $address ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'removeImage', array(
'password' => $password,
'addresses' => array( $address ),
) );
return $response[0];
} | [
"public",
"function",
"unsetAddressImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"address",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"callXmlRpc",
"(",
"$",
"email",
",",
"'removeImage'",
",",
"array",
"(",
"'password'",
"=>",
"$",
"password",
",",
"'addresses'",
"=>",
"array",
"(",
"$",
"address",
")",
",",
")",
")",
";",
"return",
"$",
"response",
"[",
"0",
"]",
";",
"}"
] | ...
Implements XML RPC method 'grav.removeImage'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"removeImage",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L239-L246 |
37,319 | meritoo/common-library | src/Traits/Collection/MainTrait.php | MainTrait.remove | public function remove($element)
{
if ($this->count() > 0) {
foreach ($this->elements as $index => $existing) {
if ($element === $existing) {
unset($this->elements[$index]);
break;
}
}
}
return $this;
} | php | public function remove($element)
{
if ($this->count() > 0) {
foreach ($this->elements as $index => $existing) {
if ($element === $existing) {
unset($this->elements[$index]);
break;
}
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"index",
"=>",
"$",
"existing",
")",
"{",
"if",
"(",
"$",
"element",
"===",
"$",
"existing",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"index",
"]",
")",
";",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] | Removes given element
@param mixed $element The element to remove
@return $this | [
"Removes",
"given",
"element"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Traits/Collection/MainTrait.php#L91-L104 |
37,320 | meritoo/common-library | src/Traits/Collection/MainTrait.php | MainTrait.has | public function has($element)
{
$index = Arrays::getIndexOf($this->elements, $element);
return null !== $index && false !== $index;
} | php | public function has($element)
{
$index = Arrays::getIndexOf($this->elements, $element);
return null !== $index && false !== $index;
} | [
"public",
"function",
"has",
"(",
"$",
"element",
")",
"{",
"$",
"index",
"=",
"Arrays",
"::",
"getIndexOf",
"(",
"$",
"this",
"->",
"elements",
",",
"$",
"element",
")",
";",
"return",
"null",
"!==",
"$",
"index",
"&&",
"false",
"!==",
"$",
"index",
";",
"}"
] | Returns information if the collection has given element, iow. if given element exists in the collection
@param mixed $element The element to verify
@return bool | [
"Returns",
"information",
"if",
"the",
"collection",
"has",
"given",
"element",
"iow",
".",
"if",
"given",
"element",
"exists",
"in",
"the",
"collection"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Traits/Collection/MainTrait.php#L144-L149 |
37,321 | meritoo/common-library | src/Traits/Collection/MainTrait.php | MainTrait.getByIndex | public function getByIndex($index)
{
if (isset($this->elements[$index])) {
return $this->elements[$index];
}
return null;
} | php | public function getByIndex($index)
{
if (isset($this->elements[$index])) {
return $this->elements[$index];
}
return null;
} | [
"public",
"function",
"getByIndex",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"elements",
"[",
"$",
"index",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Returns element with given index
@param mixed $index Index / key of the element
@return null|mixed | [
"Returns",
"element",
"with",
"given",
"index"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Traits/Collection/MainTrait.php#L199-L206 |
37,322 | railken/amethyst-invoice | src/Models/InvoiceItem.php | InvoiceItem.calculatePriceTaxable | public function calculatePriceTaxable()
{
$money = new Money(round($this->price, 2, PHP_ROUND_HALF_UP) * 100, new Currency($this->invoice->currency));
return $money;
} | php | public function calculatePriceTaxable()
{
$money = new Money(round($this->price, 2, PHP_ROUND_HALF_UP) * 100, new Currency($this->invoice->currency));
return $money;
} | [
"public",
"function",
"calculatePriceTaxable",
"(",
")",
"{",
"$",
"money",
"=",
"new",
"Money",
"(",
"round",
"(",
"$",
"this",
"->",
"price",
",",
"2",
",",
"PHP_ROUND_HALF_UP",
")",
"*",
"100",
",",
"new",
"Currency",
"(",
"$",
"this",
"->",
"invoice",
"->",
"currency",
")",
")",
";",
"return",
"$",
"money",
";",
"}"
] | Calculate the price taxable.
@return Money | [
"Calculate",
"the",
"price",
"taxable",
"."
] | 605cf27aaa82aea7328d5e5ae5f69b1e7e86120e | https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Models/InvoiceItem.php#L116-L121 |
37,323 | CeusMedia/Common | src/Alg/Math/Prime.php | Alg_Math_Prime.getPrimeFactors | public static function getPrimeFactors( $number, $list = array() )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$edge = floor( sqrt( $number ) );
$primes = self::getPrimes( $edge );
if( self::isPrime( $number ) )
{
$list[] = $number;
}
else if( count( $primes ) )
{
rsort( $primes );
foreach( $primes as $prime )
{
if( $number % $prime == 0 )
{
$tmp = $list;
$tmp[] = $prime;
$rest = $number / $prime;
$result = self::getPrimeFactors( $rest, $tmp );
if( count( $result ) )
{
sort( $result );
return $result;
}
}
}
}
return $list;
} | php | public static function getPrimeFactors( $number, $list = array() )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$edge = floor( sqrt( $number ) );
$primes = self::getPrimes( $edge );
if( self::isPrime( $number ) )
{
$list[] = $number;
}
else if( count( $primes ) )
{
rsort( $primes );
foreach( $primes as $prime )
{
if( $number % $prime == 0 )
{
$tmp = $list;
$tmp[] = $prime;
$rest = $number / $prime;
$result = self::getPrimeFactors( $rest, $tmp );
if( count( $result ) )
{
sort( $result );
return $result;
}
}
}
}
return $list;
} | [
"public",
"static",
"function",
"getPrimeFactors",
"(",
"$",
"number",
",",
"$",
"list",
"=",
"array",
"(",
")",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Please use %s (%s) instead'",
",",
"'public library \"CeusMedia/Math\"'",
",",
"'https://packagist.org/packages/ceus-media/math'",
")",
")",
";",
"$",
"edge",
"=",
"floor",
"(",
"sqrt",
"(",
"$",
"number",
")",
")",
";",
"$",
"primes",
"=",
"self",
"::",
"getPrimes",
"(",
"$",
"edge",
")",
";",
"if",
"(",
"self",
"::",
"isPrime",
"(",
"$",
"number",
")",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"number",
";",
"}",
"else",
"if",
"(",
"count",
"(",
"$",
"primes",
")",
")",
"{",
"rsort",
"(",
"$",
"primes",
")",
";",
"foreach",
"(",
"$",
"primes",
"as",
"$",
"prime",
")",
"{",
"if",
"(",
"$",
"number",
"%",
"$",
"prime",
"==",
"0",
")",
"{",
"$",
"tmp",
"=",
"$",
"list",
";",
"$",
"tmp",
"[",
"]",
"=",
"$",
"prime",
";",
"$",
"rest",
"=",
"$",
"number",
"/",
"$",
"prime",
";",
"$",
"result",
"=",
"self",
"::",
"getPrimeFactors",
"(",
"$",
"rest",
",",
"$",
"tmp",
")",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
")",
"{",
"sort",
"(",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"list",
";",
"}"
] | Returns a List of Prime Factors if given Number is dividable with Prime Numbers.
@access public
@static
@param int $number
@param array $list
@return array | [
"Returns",
"a",
"List",
"of",
"Prime",
"Factors",
"if",
"given",
"Number",
"is",
"dividable",
"with",
"Prime",
"Numbers",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Prime.php#L51-L87 |
37,324 | CeusMedia/Common | src/Alg/Math/Prime.php | Alg_Math_Prime.getPrimes | public static function getPrimes( $max )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$primes = $numbers = array();
for( $i=2; $i<=$max; $i++ )
$numbers[$i] = true;
$edge = floor( sqrt( $max ) );
for( $i=2; $i<=$edge; $i++ )
if( $numbers[$i] )
foreach( $numbers as $key => $prime )
if( $key > $i )
if( $prime )
if( $key % $i == 0 )
$numbers[$key] = false;
foreach( $numbers as $key => $prime )
if( $prime )
$primes[] = $key;
return $primes;
} | php | public static function getPrimes( $max )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$primes = $numbers = array();
for( $i=2; $i<=$max; $i++ )
$numbers[$i] = true;
$edge = floor( sqrt( $max ) );
for( $i=2; $i<=$edge; $i++ )
if( $numbers[$i] )
foreach( $numbers as $key => $prime )
if( $key > $i )
if( $prime )
if( $key % $i == 0 )
$numbers[$key] = false;
foreach( $numbers as $key => $prime )
if( $prime )
$primes[] = $key;
return $primes;
} | [
"public",
"static",
"function",
"getPrimes",
"(",
"$",
"max",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Please use %s (%s) instead'",
",",
"'public library \"CeusMedia/Math\"'",
",",
"'https://packagist.org/packages/ceus-media/math'",
")",
")",
";",
"$",
"primes",
"=",
"$",
"numbers",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"2",
";",
"$",
"i",
"<=",
"$",
"max",
";",
"$",
"i",
"++",
")",
"$",
"numbers",
"[",
"$",
"i",
"]",
"=",
"true",
";",
"$",
"edge",
"=",
"floor",
"(",
"sqrt",
"(",
"$",
"max",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"2",
";",
"$",
"i",
"<=",
"$",
"edge",
";",
"$",
"i",
"++",
")",
"if",
"(",
"$",
"numbers",
"[",
"$",
"i",
"]",
")",
"foreach",
"(",
"$",
"numbers",
"as",
"$",
"key",
"=>",
"$",
"prime",
")",
"if",
"(",
"$",
"key",
">",
"$",
"i",
")",
"if",
"(",
"$",
"prime",
")",
"if",
"(",
"$",
"key",
"%",
"$",
"i",
"==",
"0",
")",
"$",
"numbers",
"[",
"$",
"key",
"]",
"=",
"false",
";",
"foreach",
"(",
"$",
"numbers",
"as",
"$",
"key",
"=>",
"$",
"prime",
")",
"if",
"(",
"$",
"prime",
")",
"$",
"primes",
"[",
"]",
"=",
"$",
"key",
";",
"return",
"$",
"primes",
";",
"}"
] | Returns all Primes from 2 to a given Number
@access public
@static
@param int $max Greatest Number to get Primes for
@return array | [
"Returns",
"all",
"Primes",
"from",
"2",
"to",
"a",
"given",
"Number"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Prime.php#L96-L123 |
37,325 | CeusMedia/Common | src/Alg/Math/Prime.php | Alg_Math_Prime.isPrime | public static function isPrime( $number )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( $number < 2 )
return false;
$edge = floor( sqrt( $number ) );
for( $i=2; $i<=$edge; $i++ )
if( $number % $i == 0 )
return false;
return true;
} | php | public static function isPrime( $number )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( $number < 2 )
return false;
$edge = floor( sqrt( $number ) );
for( $i=2; $i<=$edge; $i++ )
if( $number % $i == 0 )
return false;
return true;
} | [
"public",
"static",
"function",
"isPrime",
"(",
"$",
"number",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Please use %s (%s) instead'",
",",
"'public library \"CeusMedia/Math\"'",
",",
"'https://packagist.org/packages/ceus-media/math'",
")",
")",
";",
"if",
"(",
"$",
"number",
"<",
"2",
")",
"return",
"false",
";",
"$",
"edge",
"=",
"floor",
"(",
"sqrt",
"(",
"$",
"number",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"2",
";",
"$",
"i",
"<=",
"$",
"edge",
";",
"$",
"i",
"++",
")",
"if",
"(",
"$",
"number",
"%",
"$",
"i",
"==",
"0",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Indicates whether a given Number is a Prime Number.
@access public
@static
@param int $number Number to be checked
@return bool | [
"Indicates",
"whether",
"a",
"given",
"Number",
"is",
"a",
"Prime",
"Number",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Prime.php#L132-L149 |
37,326 | Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.handle | public function handle(Request $request)
{
$response = new Response();
$response = $this->executePassiveActions($request, $response);
$response = $this->executeAction($request, $response);
if ($response->isClientError() || $response->isServerError()) {
return $this->handleError($request, $response);
}
return $response;
} | php | public function handle(Request $request)
{
$response = new Response();
$response = $this->executePassiveActions($request, $response);
$response = $this->executeAction($request, $response);
if ($response->isClientError() || $response->isServerError()) {
return $this->handleError($request, $response);
}
return $response;
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"executePassiveActions",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"executeAction",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"if",
"(",
"$",
"response",
"->",
"isClientError",
"(",
")",
"||",
"$",
"response",
"->",
"isServerError",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handleError",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Handles request and returns response to the client
@param Request $request
@return mixed|Response
@throws \Exception | [
"Handles",
"request",
"and",
"returns",
"response",
"to",
"the",
"client"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L59-L70 |
37,327 | Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.executePassiveActions | private function executePassiveActions(Request $request, Response $response): Response
{
foreach ($this->getRouter()->getConfiguration()->getPassiveActions() as $action => $whitelist) {
$activeAction = $this->getRouter()->getActionAlias($request);
if (!in_array($activeAction, $whitelist) && !in_array('all', $whitelist)) {
continue;
}
if (in_array('-' . $activeAction, $whitelist) && in_array('all', $whitelist)) {
continue;
}
$route = $this->getRouter()->getAliasedRoute($action, [], Router::PASSIVE_ACTION);
if (!method_exists($route->getController(), $route->getAction())) {
throw new ActionNotFoundException($action . ' passive action is present in registry, but can\'t be found or is improperly configured.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
$response = $controller->{$route->getAction()}(...$route->getActionParams());
}
return $response;
} | php | private function executePassiveActions(Request $request, Response $response): Response
{
foreach ($this->getRouter()->getConfiguration()->getPassiveActions() as $action => $whitelist) {
$activeAction = $this->getRouter()->getActionAlias($request);
if (!in_array($activeAction, $whitelist) && !in_array('all', $whitelist)) {
continue;
}
if (in_array('-' . $activeAction, $whitelist) && in_array('all', $whitelist)) {
continue;
}
$route = $this->getRouter()->getAliasedRoute($action, [], Router::PASSIVE_ACTION);
if (!method_exists($route->getController(), $route->getAction())) {
throw new ActionNotFoundException($action . ' passive action is present in registry, but can\'t be found or is improperly configured.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
$response = $controller->{$route->getAction()}(...$route->getActionParams());
}
return $response;
} | [
"private",
"function",
"executePassiveActions",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
":",
"Response",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getPassiveActions",
"(",
")",
"as",
"$",
"action",
"=>",
"$",
"whitelist",
")",
"{",
"$",
"activeAction",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getActionAlias",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"activeAction",
",",
"$",
"whitelist",
")",
"&&",
"!",
"in_array",
"(",
"'all'",
",",
"$",
"whitelist",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"in_array",
"(",
"'-'",
".",
"$",
"activeAction",
",",
"$",
"whitelist",
")",
"&&",
"in_array",
"(",
"'all'",
",",
"$",
"whitelist",
")",
")",
"{",
"continue",
";",
"}",
"$",
"route",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getAliasedRoute",
"(",
"$",
"action",
",",
"[",
"]",
",",
"Router",
"::",
"PASSIVE_ACTION",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"route",
"->",
"getController",
"(",
")",
",",
"$",
"route",
"->",
"getAction",
"(",
")",
")",
")",
"{",
"throw",
"new",
"ActionNotFoundException",
"(",
"$",
"action",
".",
"' passive action is present in registry, but can\\'t be found or is improperly configured.'",
")",
";",
"}",
"$",
"controllerName",
"=",
"$",
"route",
"->",
"getController",
"(",
")",
";",
"$",
"controller",
"=",
"new",
"$",
"controllerName",
"(",
"$",
"this",
"->",
"drivers",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"$",
"response",
"=",
"$",
"controller",
"->",
"{",
"$",
"route",
"->",
"getAction",
"(",
")",
"}",
"(",
"...",
"$",
"route",
"->",
"getActionParams",
"(",
")",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Executes passive actions existing in registry
@param Request $request
@param Response $response
@return Response
@throws ActionNotFoundException if passive action can't be found
@throws \Exception | [
"Executes",
"passive",
"actions",
"existing",
"in",
"registry"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L81-L106 |
37,328 | Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.executeAction | private function executeAction(Request $request, Response $response)
{
$route = $this->getRouter()->getRoute($request);
if (!method_exists($route->getController(), $route->getAction())) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent($this->getRouter()->getConfiguration()->getNotFoundMsg() ?? 'Not found.')
->setStatusCode(Response::HTTP_NOT_FOUND);
}
throw new ActionNotFoundException($route->getAction() . ' for ' . $route->getController() . ' not found.');
}
$errorController = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (1 === preg_match('(Partial|Passive)', $route->getAction()) || $errorController === $route->getController()) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent('Forbidden.')
->setStatusCode(Response::HTTP_FORBIDDEN);
}
throw new ActionForbiddenException('Partial, passive and error actions cannot be requested by user.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$route->getAction()}(...$route->getActionParams());
} | php | private function executeAction(Request $request, Response $response)
{
$route = $this->getRouter()->getRoute($request);
if (!method_exists($route->getController(), $route->getAction())) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent($this->getRouter()->getConfiguration()->getNotFoundMsg() ?? 'Not found.')
->setStatusCode(Response::HTTP_NOT_FOUND);
}
throw new ActionNotFoundException($route->getAction() . ' for ' . $route->getController() . ' not found.');
}
$errorController = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (1 === preg_match('(Partial|Passive)', $route->getAction()) || $errorController === $route->getController()) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent('Forbidden.')
->setStatusCode(Response::HTTP_FORBIDDEN);
}
throw new ActionForbiddenException('Partial, passive and error actions cannot be requested by user.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$route->getAction()}(...$route->getActionParams());
} | [
"private",
"function",
"executeAction",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getRoute",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"route",
"->",
"getController",
"(",
")",
",",
"$",
"route",
"->",
"getAction",
"(",
")",
")",
")",
"{",
"if",
"(",
"'prod'",
"===",
"$",
"this",
"->",
"configuration",
"[",
"'framework'",
"]",
"[",
"'env'",
"]",
")",
"{",
"return",
"$",
"response",
"->",
"setContent",
"(",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getNotFoundMsg",
"(",
")",
"??",
"'Not found.'",
")",
"->",
"setStatusCode",
"(",
"Response",
"::",
"HTTP_NOT_FOUND",
")",
";",
"}",
"throw",
"new",
"ActionNotFoundException",
"(",
"$",
"route",
"->",
"getAction",
"(",
")",
".",
"' for '",
".",
"$",
"route",
"->",
"getController",
"(",
")",
".",
"' not found.'",
")",
";",
"}",
"$",
"errorController",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getControllerNamespace",
"(",
")",
".",
"'ErrorController'",
";",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"'(Partial|Passive)'",
",",
"$",
"route",
"->",
"getAction",
"(",
")",
")",
"||",
"$",
"errorController",
"===",
"$",
"route",
"->",
"getController",
"(",
")",
")",
"{",
"if",
"(",
"'prod'",
"===",
"$",
"this",
"->",
"configuration",
"[",
"'framework'",
"]",
"[",
"'env'",
"]",
")",
"{",
"return",
"$",
"response",
"->",
"setContent",
"(",
"'Forbidden.'",
")",
"->",
"setStatusCode",
"(",
"Response",
"::",
"HTTP_FORBIDDEN",
")",
";",
"}",
"throw",
"new",
"ActionForbiddenException",
"(",
"'Partial, passive and error actions cannot be requested by user.'",
")",
";",
"}",
"$",
"controllerName",
"=",
"$",
"route",
"->",
"getController",
"(",
")",
";",
"$",
"controller",
"=",
"new",
"$",
"controllerName",
"(",
"$",
"this",
"->",
"drivers",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"return",
"$",
"controller",
"->",
"{",
"$",
"route",
"->",
"getAction",
"(",
")",
"}",
"(",
"...",
"$",
"route",
"->",
"getActionParams",
"(",
")",
")",
";",
"}"
] | Executes active action
@param Request $request
@param Response $response Response returned by passive actions execution
@return mixed|Response
@throws ActionNotFoundException if requested action can't be found in dev mode
@throws ActionForbiddenException if requested action is partial, passive or belongs to ErrorController in dev mode | [
"Executes",
"active",
"action"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L117-L147 |
37,329 | Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.handleError | private function handleError(Request $request, Response $response)
{
$controllerName = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (!class_exists($controllerName)) {
return $response;
}
$actionName = 'code' . $response->getStatusCode() . 'Action';
if (!method_exists($controllerName, $actionName)) {
$actionName = 'defaultAction';
}
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$actionName}();
} | php | private function handleError(Request $request, Response $response)
{
$controllerName = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (!class_exists($controllerName)) {
return $response;
}
$actionName = 'code' . $response->getStatusCode() . 'Action';
if (!method_exists($controllerName, $actionName)) {
$actionName = 'defaultAction';
}
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$actionName}();
} | [
"private",
"function",
"handleError",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"controllerName",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getControllerNamespace",
"(",
")",
".",
"'ErrorController'",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"controllerName",
")",
")",
"{",
"return",
"$",
"response",
";",
"}",
"$",
"actionName",
"=",
"'code'",
".",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
".",
"'Action'",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"controllerName",
",",
"$",
"actionName",
")",
")",
"{",
"$",
"actionName",
"=",
"'defaultAction'",
";",
"}",
"$",
"controller",
"=",
"new",
"$",
"controllerName",
"(",
"$",
"this",
"->",
"drivers",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"return",
"$",
"controller",
"->",
"{",
"$",
"actionName",
"}",
"(",
")",
";",
"}"
] | Handles HTTP errors, that may occur on action execution stage
@param Request $request
@param Response $response Response returned by action execution
@return mixed|Response | [
"Handles",
"HTTP",
"errors",
"that",
"may",
"occur",
"on",
"action",
"execution",
"stage"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L156-L173 |
37,330 | smasty/Neevo | src/Neevo/Connection.php | Connection.connect | public function connect(){
if($this->connected !== false)
return;
$this->driver->connect($this->config);
$this->connected = true;
$this->notifyObservers(ObserverInterface::CONNECT);
} | php | public function connect(){
if($this->connected !== false)
return;
$this->driver->connect($this->config);
$this->connected = true;
$this->notifyObservers(ObserverInterface::CONNECT);
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connected",
"!==",
"false",
")",
"return",
";",
"$",
"this",
"->",
"driver",
"->",
"connect",
"(",
"$",
"this",
"->",
"config",
")",
";",
"$",
"this",
"->",
"connected",
"=",
"true",
";",
"$",
"this",
"->",
"notifyObservers",
"(",
"ObserverInterface",
"::",
"CONNECT",
")",
";",
"}"
] | Opens database connection. | [
"Opens",
"database",
"connection",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Connection.php#L146-L153 |
37,331 | smasty/Neevo | src/Neevo/Connection.php | Connection.alias | public static function alias(&$config, $key, $alias){
if(!isset($config[$alias]))
return;
$tmp = & $config;
foreach(explode('.', $key) as $key){
$tmp = & $tmp[$key];
}
if(!isset($tmp))
$tmp = $config[$alias];
} | php | public static function alias(&$config, $key, $alias){
if(!isset($config[$alias]))
return;
$tmp = & $config;
foreach(explode('.', $key) as $key){
$tmp = & $tmp[$key];
}
if(!isset($tmp))
$tmp = $config[$alias];
} | [
"public",
"static",
"function",
"alias",
"(",
"&",
"$",
"config",
",",
"$",
"key",
",",
"$",
"alias",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"alias",
"]",
")",
")",
"return",
";",
"$",
"tmp",
"=",
"&",
"$",
"config",
";",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
"as",
"$",
"key",
")",
"{",
"$",
"tmp",
"=",
"&",
"$",
"tmp",
"[",
"$",
"key",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"tmp",
")",
")",
"$",
"tmp",
"=",
"$",
"config",
"[",
"$",
"alias",
"]",
";",
"}"
] | Creates an alias for configuration value.
@param array $config Passed by reference
@param string $key
@param string $alias Alias of $key | [
"Creates",
"an",
"alias",
"for",
"configuration",
"value",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Connection.php#L282-L291 |
37,332 | smasty/Neevo | src/Neevo/Connection.php | Connection.setDriver | protected function setDriver($driver){
if(strcasecmp($driver, 'sqlite') === 0) // Backward compatibility
$driver = 'SQLite2';
$class = "Neevo\\Drivers\\{$driver}Driver";
if(!class_exists($class)){
$file = __DIR__ . '/Drivers/' . strtolower($driver) . '.php';
if(!file_exists($file))
throw new DriverException("$driver driver file ($file) does not exist.");
if(is_readable($file))
include_once $file;
else
throw new DriverException("$driver driver file ($file) is not readable.");
}
if(!$this->isDriver($class))
throw new DriverException("Class '$class' is not a valid Neevo driver class.");
$this->driver = new $class;
// Set statement parser
if($this->isParser($class))
$this->parser = $class;
} | php | protected function setDriver($driver){
if(strcasecmp($driver, 'sqlite') === 0) // Backward compatibility
$driver = 'SQLite2';
$class = "Neevo\\Drivers\\{$driver}Driver";
if(!class_exists($class)){
$file = __DIR__ . '/Drivers/' . strtolower($driver) . '.php';
if(!file_exists($file))
throw new DriverException("$driver driver file ($file) does not exist.");
if(is_readable($file))
include_once $file;
else
throw new DriverException("$driver driver file ($file) is not readable.");
}
if(!$this->isDriver($class))
throw new DriverException("Class '$class' is not a valid Neevo driver class.");
$this->driver = new $class;
// Set statement parser
if($this->isParser($class))
$this->parser = $class;
} | [
"protected",
"function",
"setDriver",
"(",
"$",
"driver",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"driver",
",",
"'sqlite'",
")",
"===",
"0",
")",
"// Backward compatibility",
"$",
"driver",
"=",
"'SQLite2'",
";",
"$",
"class",
"=",
"\"Neevo\\\\Drivers\\\\{$driver}Driver\"",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"file",
"=",
"__DIR__",
".",
"'/Drivers/'",
".",
"strtolower",
"(",
"$",
"driver",
")",
".",
"'.php'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"file",
")",
")",
"throw",
"new",
"DriverException",
"(",
"\"$driver driver file ($file) does not exist.\"",
")",
";",
"if",
"(",
"is_readable",
"(",
"$",
"file",
")",
")",
"include_once",
"$",
"file",
";",
"else",
"throw",
"new",
"DriverException",
"(",
"\"$driver driver file ($file) is not readable.\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isDriver",
"(",
"$",
"class",
")",
")",
"throw",
"new",
"DriverException",
"(",
"\"Class '$class' is not a valid Neevo driver class.\"",
")",
";",
"$",
"this",
"->",
"driver",
"=",
"new",
"$",
"class",
";",
"// Set statement parser",
"if",
"(",
"$",
"this",
"->",
"isParser",
"(",
"$",
"class",
")",
")",
"$",
"this",
"->",
"parser",
"=",
"$",
"class",
";",
"}"
] | Sets the driver and statement parser.
@param string $driver
@throws DriverException | [
"Sets",
"the",
"driver",
"and",
"statement",
"parser",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Connection.php#L299-L322 |
37,333 | CeusMedia/Common | src/Alg/Validation/LanguageValidator.php | Alg_Validation_LanguageValidator.getLanguage | public function getLanguage( $language )
{
$pattern = '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i';
if( !$language )
return $this->default;
$accepted = preg_split( '/,\s*/', $language );
$curr_lang = $this->default;
$curr_qual = 0;
foreach( $accepted as $accept)
{
if( !preg_match ( $pattern, $accept, $matches) )
continue;
$lang_code = explode ( '-', $matches[1] );
$lang_quality = isset( $matches[2] ) ? (float)$matches[2] : 1.0;
while (count ($lang_code))
{
if( in_array( strtolower( join( '-', $lang_code ) ), $this->allowed ) )
{
if( $lang_quality > $curr_qual )
{
$curr_lang = strtolower( join( '-', $lang_code ) );
$curr_qual = $lang_quality;
break;
}
}
array_pop ($lang_code);
}
}
return $curr_lang;
} | php | public function getLanguage( $language )
{
$pattern = '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i';
if( !$language )
return $this->default;
$accepted = preg_split( '/,\s*/', $language );
$curr_lang = $this->default;
$curr_qual = 0;
foreach( $accepted as $accept)
{
if( !preg_match ( $pattern, $accept, $matches) )
continue;
$lang_code = explode ( '-', $matches[1] );
$lang_quality = isset( $matches[2] ) ? (float)$matches[2] : 1.0;
while (count ($lang_code))
{
if( in_array( strtolower( join( '-', $lang_code ) ), $this->allowed ) )
{
if( $lang_quality > $curr_qual )
{
$curr_lang = strtolower( join( '-', $lang_code ) );
$curr_qual = $lang_quality;
break;
}
}
array_pop ($lang_code);
}
}
return $curr_lang;
} | [
"public",
"function",
"getLanguage",
"(",
"$",
"language",
")",
"{",
"$",
"pattern",
"=",
"'/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/i'",
";",
"if",
"(",
"!",
"$",
"language",
")",
"return",
"$",
"this",
"->",
"default",
";",
"$",
"accepted",
"=",
"preg_split",
"(",
"'/,\\s*/'",
",",
"$",
"language",
")",
";",
"$",
"curr_lang",
"=",
"$",
"this",
"->",
"default",
";",
"$",
"curr_qual",
"=",
"0",
";",
"foreach",
"(",
"$",
"accepted",
"as",
"$",
"accept",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"accept",
",",
"$",
"matches",
")",
")",
"continue",
";",
"$",
"lang_code",
"=",
"explode",
"(",
"'-'",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"lang_quality",
"=",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"(",
"float",
")",
"$",
"matches",
"[",
"2",
"]",
":",
"1.0",
";",
"while",
"(",
"count",
"(",
"$",
"lang_code",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"join",
"(",
"'-'",
",",
"$",
"lang_code",
")",
")",
",",
"$",
"this",
"->",
"allowed",
")",
")",
"{",
"if",
"(",
"$",
"lang_quality",
">",
"$",
"curr_qual",
")",
"{",
"$",
"curr_lang",
"=",
"strtolower",
"(",
"join",
"(",
"'-'",
",",
"$",
"lang_code",
")",
")",
";",
"$",
"curr_qual",
"=",
"$",
"lang_quality",
";",
"break",
";",
"}",
"}",
"array_pop",
"(",
"$",
"lang_code",
")",
";",
"}",
"}",
"return",
"$",
"curr_lang",
";",
"}"
] | Returns prefered allowed and accepted Language.
@access public
@param string $language Language to prove
@return string | [
"Returns",
"prefered",
"allowed",
"and",
"accepted",
"Language",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/LanguageValidator.php#L77-L106 |
37,334 | CeusMedia/Common | src/Alg/Validation/LanguageValidator.php | Alg_Validation_LanguageValidator.validate | public static function validate( $language, $allowed, $default = NULL )
{
$validator = new Alg_Validation_LanguageValidator( $allowed, $default );
$language = $validator->getLanguage( $language );
return $language;
} | php | public static function validate( $language, $allowed, $default = NULL )
{
$validator = new Alg_Validation_LanguageValidator( $allowed, $default );
$language = $validator->getLanguage( $language );
return $language;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"language",
",",
"$",
"allowed",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"$",
"validator",
"=",
"new",
"Alg_Validation_LanguageValidator",
"(",
"$",
"allowed",
",",
"$",
"default",
")",
";",
"$",
"language",
"=",
"$",
"validator",
"->",
"getLanguage",
"(",
"$",
"language",
")",
";",
"return",
"$",
"language",
";",
"}"
] | Validates Language statically and returns valid Language.
@access public
@static
@param string $language Language to validate
@param array $allowed List of allowed Languages
@param string $default Default Language
@return string | [
"Validates",
"Language",
"statically",
"and",
"returns",
"valid",
"Language",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/LanguageValidator.php#L117-L122 |
37,335 | CeusMedia/Common | src/Alg/Math/Algebra/Vector/ScalarProduct.php | Alg_Math_Algebra_Vector_ScalarProduct.produce | public function produce( $vector1, $vector2 )
{
$sum = 0;
if( $vector1->getDimension() != $vector2->getDimension() )
throw new Exception( 'Dimensions of Vectors are not compatible.' );
for( $i=0; $i<$vector1->getDimension(); $i++)
$sum += $vector1->getValueFromIndex( $i ) * $vector2->getValueFromIndex( $i );
return $sum;
} | php | public function produce( $vector1, $vector2 )
{
$sum = 0;
if( $vector1->getDimension() != $vector2->getDimension() )
throw new Exception( 'Dimensions of Vectors are not compatible.' );
for( $i=0; $i<$vector1->getDimension(); $i++)
$sum += $vector1->getValueFromIndex( $i ) * $vector2->getValueFromIndex( $i );
return $sum;
} | [
"public",
"function",
"produce",
"(",
"$",
"vector1",
",",
"$",
"vector2",
")",
"{",
"$",
"sum",
"=",
"0",
";",
"if",
"(",
"$",
"vector1",
"->",
"getDimension",
"(",
")",
"!=",
"$",
"vector2",
"->",
"getDimension",
"(",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Dimensions of Vectors are not compatible.'",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"vector1",
"->",
"getDimension",
"(",
")",
";",
"$",
"i",
"++",
")",
"$",
"sum",
"+=",
"$",
"vector1",
"->",
"getValueFromIndex",
"(",
"$",
"i",
")",
"*",
"$",
"vector2",
"->",
"getValueFromIndex",
"(",
"$",
"i",
")",
";",
"return",
"$",
"sum",
";",
"}"
] | Returns Scalar Product of two Vectors
@access public
@param Alg_Math_Algebra_Vector $vector1 Vector 1
@param Alg_Math_Algebra_Vector $vector2 Vector 2
@return mixed | [
"Returns",
"Scalar",
"Product",
"of",
"two",
"Vectors"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/Vector/ScalarProduct.php#L58-L67 |
37,336 | rollun-com/rollun-logger | src/Logger/src/Formatter/FluentdFormatter.php | FluentdFormatter.format | public function format($event)
{
$event = $this->reachUpFirstNestedLevel($event);
$event = $this->clearEmptyArrayInEvent($event);
return json_encode($event);
} | php | public function format($event)
{
$event = $this->reachUpFirstNestedLevel($event);
$event = $this->clearEmptyArrayInEvent($event);
return json_encode($event);
} | [
"public",
"function",
"format",
"(",
"$",
"event",
")",
"{",
"$",
"event",
"=",
"$",
"this",
"->",
"reachUpFirstNestedLevel",
"(",
"$",
"event",
")",
";",
"$",
"event",
"=",
"$",
"this",
"->",
"clearEmptyArrayInEvent",
"(",
"$",
"event",
")",
";",
"return",
"json_encode",
"(",
"$",
"event",
")",
";",
"}"
] | Formats data into a single line to be written by the writer.
@param array $event event data
@return string|array Either a formatted line to write to the log, or the
updated event information to provide to the writer. | [
"Formats",
"data",
"into",
"a",
"single",
"line",
"to",
"be",
"written",
"by",
"the",
"writer",
"."
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Formatter/FluentdFormatter.php#L25-L30 |
37,337 | rollun-com/rollun-logger | src/Logger/src/Formatter/FluentdFormatter.php | FluentdFormatter.clearEmptyArrayInEvent | private function clearEmptyArrayInEvent(array $event) {
$repackEvent = [];
foreach ($event as $key => $value) {
if(is_array($value) && count($value) > 0) {
$repackEvent[$key] = $this->clearEmptyArrayInEvent($value);
}else if(!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | php | private function clearEmptyArrayInEvent(array $event) {
$repackEvent = [];
foreach ($event as $key => $value) {
if(is_array($value) && count($value) > 0) {
$repackEvent[$key] = $this->clearEmptyArrayInEvent($value);
}else if(!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | [
"private",
"function",
"clearEmptyArrayInEvent",
"(",
"array",
"$",
"event",
")",
"{",
"$",
"repackEvent",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"event",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"count",
"(",
"$",
"value",
")",
">",
"0",
")",
"{",
"$",
"repackEvent",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"clearEmptyArrayInEvent",
"(",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"repackEvent",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"repackEvent",
";",
"}"
] | Clear empty array in event
@param array $event
@return array | [
"Clear",
"empty",
"array",
"in",
"event"
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Formatter/FluentdFormatter.php#L36-L46 |
37,338 | rollun-com/rollun-logger | src/Logger/src/Formatter/FluentdFormatter.php | FluentdFormatter.reachUpFirstNestedLevel | private function reachUpFirstNestedLevel(array $event)
{
$repackEvent = [];
foreach ($event as $key => $value) {
if (is_array($value)) {
foreach ($value as $nestedKey => $nestedValue) {
$repackEvent["$key.$nestedKey"] = $nestedValue;
}
} else if (!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | php | private function reachUpFirstNestedLevel(array $event)
{
$repackEvent = [];
foreach ($event as $key => $value) {
if (is_array($value)) {
foreach ($value as $nestedKey => $nestedValue) {
$repackEvent["$key.$nestedKey"] = $nestedValue;
}
} else if (!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | [
"private",
"function",
"reachUpFirstNestedLevel",
"(",
"array",
"$",
"event",
")",
"{",
"$",
"repackEvent",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"event",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"nestedKey",
"=>",
"$",
"nestedValue",
")",
"{",
"$",
"repackEvent",
"[",
"\"$key.$nestedKey\"",
"]",
"=",
"$",
"nestedValue",
";",
"}",
"}",
"else",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"repackEvent",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"repackEvent",
";",
"}"
] | reach up first nested arrays in event
@param array $event
@return array | [
"reach",
"up",
"first",
"nested",
"arrays",
"in",
"event"
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Formatter/FluentdFormatter.php#L53-L66 |
37,339 | CeusMedia/Common | src/FS/File/Permissions.php | FS_File_Permissions.getAsInteger | public function getAsInteger()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return octdec( substr( sprintf( '%o', $permissions ), -4 ) );
} | php | public function getAsInteger()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return octdec( substr( sprintf( '%o', $permissions ), -4 ) );
} | [
"public",
"function",
"getAsInteger",
"(",
")",
"{",
"$",
"permissions",
"=",
"@",
"fileperms",
"(",
"$",
"this",
"->",
"pathName",
")",
";",
"if",
"(",
"FALSE",
"===",
"$",
"permissions",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Could not get permissions of file \"'",
".",
"$",
"this",
"->",
"pathName",
".",
"'\"'",
")",
";",
"return",
"octdec",
"(",
"substr",
"(",
"sprintf",
"(",
"'%o'",
",",
"$",
"permissions",
")",
",",
"-",
"4",
")",
")",
";",
"}"
] | Returns permissions as integer value.
@access public
@return integer Integer value of permissions of current file
@throws RuntimeException if no valid file is set | [
"Returns",
"permissions",
"as",
"integer",
"value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Permissions.php#L63-L69 |
37,340 | CeusMedia/Common | src/FS/File/Permissions.php | FS_File_Permissions.getAsOctal | public function getAsOctal()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return substr( sprintf( '%o', $permissions ), -4 );
} | php | public function getAsOctal()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return substr( sprintf( '%o', $permissions ), -4 );
} | [
"public",
"function",
"getAsOctal",
"(",
")",
"{",
"$",
"permissions",
"=",
"@",
"fileperms",
"(",
"$",
"this",
"->",
"pathName",
")",
";",
"if",
"(",
"FALSE",
"===",
"$",
"permissions",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Could not get permissions of file \"'",
".",
"$",
"this",
"->",
"pathName",
".",
"'\"'",
")",
";",
"return",
"substr",
"(",
"sprintf",
"(",
"'%o'",
",",
"$",
"permissions",
")",
",",
"-",
"4",
")",
";",
"}"
] | Returns permissions as octal string value.
@access public
@return integer Octal string value of permissions of current file
@throws RuntimeException if no valid file is set | [
"Returns",
"permissions",
"as",
"octal",
"string",
"value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Permissions.php#L77-L83 |
37,341 | CeusMedia/Common | src/FS/File/Permissions.php | FS_File_Permissions.getAsString | public function getAsString()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return self::getStringFromOctal( $permissions );
} | php | public function getAsString()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return self::getStringFromOctal( $permissions );
} | [
"public",
"function",
"getAsString",
"(",
")",
"{",
"$",
"permissions",
"=",
"@",
"fileperms",
"(",
"$",
"this",
"->",
"pathName",
")",
";",
"if",
"(",
"FALSE",
"===",
"$",
"permissions",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Could not get permissions of file \"'",
".",
"$",
"this",
"->",
"pathName",
".",
"'\"'",
")",
";",
"return",
"self",
"::",
"getStringFromOctal",
"(",
"$",
"permissions",
")",
";",
"}"
] | Returns permissions as string value.
@access public
@return string String value of permissions of current file
@throws RuntimeException if no valid file is set | [
"Returns",
"permissions",
"as",
"string",
"value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Permissions.php#L91-L97 |
37,342 | ncou/Chiron | src/Chiron/Support/Http/Serializer.php | Serializer.responseToString | public static function responseToString(ResponseInterface $response): string
{
$reasonPhrase = $response->getReasonPhrase();
$headers = self::serializeHeaders($response->getHeaders());
$body = (string) $response->getBody();
$format = 'HTTP/%s %d%s%s%s';
if (! empty($headers)) {
$headers = self::EOL . $headers;
}
$headers .= self::EOL . self::EOL;
return sprintf(
$format,
$response->getProtocolVersion(),
$response->getStatusCode(),
($reasonPhrase ? ' ' . $reasonPhrase : ''),
$headers,
$body
);
} | php | public static function responseToString(ResponseInterface $response): string
{
$reasonPhrase = $response->getReasonPhrase();
$headers = self::serializeHeaders($response->getHeaders());
$body = (string) $response->getBody();
$format = 'HTTP/%s %d%s%s%s';
if (! empty($headers)) {
$headers = self::EOL . $headers;
}
$headers .= self::EOL . self::EOL;
return sprintf(
$format,
$response->getProtocolVersion(),
$response->getStatusCode(),
($reasonPhrase ? ' ' . $reasonPhrase : ''),
$headers,
$body
);
} | [
"public",
"static",
"function",
"responseToString",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"string",
"{",
"$",
"reasonPhrase",
"=",
"$",
"response",
"->",
"getReasonPhrase",
"(",
")",
";",
"$",
"headers",
"=",
"self",
"::",
"serializeHeaders",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
")",
";",
"$",
"body",
"=",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"$",
"format",
"=",
"'HTTP/%s %d%s%s%s'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"headers",
")",
")",
"{",
"$",
"headers",
"=",
"self",
"::",
"EOL",
".",
"$",
"headers",
";",
"}",
"$",
"headers",
".=",
"self",
"::",
"EOL",
".",
"self",
"::",
"EOL",
";",
"return",
"sprintf",
"(",
"$",
"format",
",",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
",",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
",",
"(",
"$",
"reasonPhrase",
"?",
"' '",
".",
"$",
"reasonPhrase",
":",
"''",
")",
",",
"$",
"headers",
",",
"$",
"body",
")",
";",
"}"
] | Create a string representation of a response.
@param ResponseInterface $response
@return string | [
"Create",
"a",
"string",
"representation",
"of",
"a",
"response",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Support/Http/Serializer.php#L36-L55 |
37,343 | CeusMedia/Common | src/FS/File/VCard/Parser.php | FS_File_VCard_Parser.parse | public static function parse( $string, $charsetIn = NULL, $charsetOut = NULL )
{
$vcard = new ADT_VCard;
return self::parseInto( $string, $vcard, $charsetIn, $charsetOut );
} | php | public static function parse( $string, $charsetIn = NULL, $charsetOut = NULL )
{
$vcard = new ADT_VCard;
return self::parseInto( $string, $vcard, $charsetIn, $charsetOut );
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"string",
",",
"$",
"charsetIn",
"=",
"NULL",
",",
"$",
"charsetOut",
"=",
"NULL",
")",
"{",
"$",
"vcard",
"=",
"new",
"ADT_VCard",
";",
"return",
"self",
"::",
"parseInto",
"(",
"$",
"string",
",",
"$",
"vcard",
",",
"$",
"charsetIn",
",",
"$",
"charsetOut",
")",
";",
"}"
] | Parses vCard String to new vCard Object and converts between Charsets.
@access public
@static
@param string $string VCard String
@param string $charsetIn Charset to convert from
@param string $charsetOut Charset to convert to
@return string | [
"Parses",
"vCard",
"String",
"to",
"new",
"vCard",
"Object",
"and",
"converts",
"between",
"Charsets",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Parser.php#L57-L61 |
37,344 | CeusMedia/Common | src/FS/File/VCard/Parser.php | FS_File_VCard_Parser.parseInto | public static function parseInto( $string, ADT_VCard $vcard, $charsetIn = NULL, $charsetOut = NULL )
{
if( !$string )
throw new InvalidArgumentException( 'String is empty ' );
if( $charsetIn && $charsetOut && function_exists( 'iconv' ) )
{
$string = Alg_Text_EncodingConverter::convert( $string, $charsetIn, $charsetOut );
}
$lines = explode( "\n", $string );
foreach( $lines as $line )
self::parseLine( $vcard, $line );
return $vcard;
} | php | public static function parseInto( $string, ADT_VCard $vcard, $charsetIn = NULL, $charsetOut = NULL )
{
if( !$string )
throw new InvalidArgumentException( 'String is empty ' );
if( $charsetIn && $charsetOut && function_exists( 'iconv' ) )
{
$string = Alg_Text_EncodingConverter::convert( $string, $charsetIn, $charsetOut );
}
$lines = explode( "\n", $string );
foreach( $lines as $line )
self::parseLine( $vcard, $line );
return $vcard;
} | [
"public",
"static",
"function",
"parseInto",
"(",
"$",
"string",
",",
"ADT_VCard",
"$",
"vcard",
",",
"$",
"charsetIn",
"=",
"NULL",
",",
"$",
"charsetOut",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"string",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'String is empty '",
")",
";",
"if",
"(",
"$",
"charsetIn",
"&&",
"$",
"charsetOut",
"&&",
"function_exists",
"(",
"'iconv'",
")",
")",
"{",
"$",
"string",
"=",
"Alg_Text_EncodingConverter",
"::",
"convert",
"(",
"$",
"string",
",",
"$",
"charsetIn",
",",
"$",
"charsetOut",
")",
";",
"}",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"string",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"self",
"::",
"parseLine",
"(",
"$",
"vcard",
",",
"$",
"line",
")",
";",
"return",
"$",
"vcard",
";",
"}"
] | Parses vCard String to an given vCard Object and converts between Charsets.
@access public
@static
@param string $string VCard String
@param ADT_VCard $vcard VCard Data Object
@param string $charsetIn Charset to convert from
@param string $charsetOut Charset to convert to
@return string | [
"Parses",
"vCard",
"String",
"to",
"an",
"given",
"vCard",
"Object",
"and",
"converts",
"between",
"Charsets",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Parser.php#L87-L100 |
37,345 | ethical-jobs/laravel-foundation | src/Http/Normalizr.php | Normalizr.injectData | public function injectData($data, $rawIncludedData)
{
$entityKey = key($data);
// Normalise entity
foreach ($data as $entity) {
if (isset($entity[0])) { // is a collection
foreach ($entity as $collectionItem) {
$this->insertEntity($entityKey, $collectionItem, $rawIncludedData);
}
} else { // is a single item
$this->insertEntity($entityKey, $entity, $rawIncludedData);
}
}
return $this->normalised;
} | php | public function injectData($data, $rawIncludedData)
{
$entityKey = key($data);
// Normalise entity
foreach ($data as $entity) {
if (isset($entity[0])) { // is a collection
foreach ($entity as $collectionItem) {
$this->insertEntity($entityKey, $collectionItem, $rawIncludedData);
}
} else { // is a single item
$this->insertEntity($entityKey, $entity, $rawIncludedData);
}
}
return $this->normalised;
} | [
"public",
"function",
"injectData",
"(",
"$",
"data",
",",
"$",
"rawIncludedData",
")",
"{",
"$",
"entityKey",
"=",
"key",
"(",
"$",
"data",
")",
";",
"// Normalise entity",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"entity",
"[",
"0",
"]",
")",
")",
"{",
"// is a collection",
"foreach",
"(",
"$",
"entity",
"as",
"$",
"collectionItem",
")",
"{",
"$",
"this",
"->",
"insertEntity",
"(",
"$",
"entityKey",
",",
"$",
"collectionItem",
",",
"$",
"rawIncludedData",
")",
";",
"}",
"}",
"else",
"{",
"// is a single item",
"$",
"this",
"->",
"insertEntity",
"(",
"$",
"entityKey",
",",
"$",
"entity",
",",
"$",
"rawIncludedData",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"normalised",
";",
"}"
] | Hook for the serializer to inject custom data based on the relationships of the resource.
@param array $data
@param array $rawIncludedData
@return array | [
"Hook",
"for",
"the",
"serializer",
"to",
"inject",
"custom",
"data",
"based",
"on",
"the",
"relationships",
"of",
"the",
"resource",
"."
] | 5f1d3bc45cf6fef149b583e2590fae76dd0df7c3 | https://github.com/ethical-jobs/laravel-foundation/blob/5f1d3bc45cf6fef149b583e2590fae76dd0df7c3/src/Http/Normalizr.php#L71-L87 |
37,346 | railken/amethyst-invoice | src/Providers/InvoiceServiceProvider.php | InvoiceServiceProvider.loadExtraRoutes | public function loadExtraRoutes()
{
$config = Config::get('amethyst.invoice.http.admin.invoice');
if (Arr::get($config, 'enabled')) {
Router::group('admin', Arr::get($config, 'router'), function ($router) use ($config) {
$controller = Arr::get($config, 'controller');
$router->post('/{id}/issue', ['as' => 'issue', 'uses' => $controller.'@issue']);
});
}
} | php | public function loadExtraRoutes()
{
$config = Config::get('amethyst.invoice.http.admin.invoice');
if (Arr::get($config, 'enabled')) {
Router::group('admin', Arr::get($config, 'router'), function ($router) use ($config) {
$controller = Arr::get($config, 'controller');
$router->post('/{id}/issue', ['as' => 'issue', 'uses' => $controller.'@issue']);
});
}
} | [
"public",
"function",
"loadExtraRoutes",
"(",
")",
"{",
"$",
"config",
"=",
"Config",
"::",
"get",
"(",
"'amethyst.invoice.http.admin.invoice'",
")",
";",
"if",
"(",
"Arr",
"::",
"get",
"(",
"$",
"config",
",",
"'enabled'",
")",
")",
"{",
"Router",
"::",
"group",
"(",
"'admin'",
",",
"Arr",
"::",
"get",
"(",
"$",
"config",
",",
"'router'",
")",
",",
"function",
"(",
"$",
"router",
")",
"use",
"(",
"$",
"config",
")",
"{",
"$",
"controller",
"=",
"Arr",
"::",
"get",
"(",
"$",
"config",
",",
"'controller'",
")",
";",
"$",
"router",
"->",
"post",
"(",
"'/{id}/issue'",
",",
"[",
"'as'",
"=>",
"'issue'",
",",
"'uses'",
"=>",
"$",
"controller",
".",
"'@issue'",
"]",
")",
";",
"}",
")",
";",
"}",
"}"
] | Load extra routes. | [
"Load",
"extra",
"routes",
"."
] | 605cf27aaa82aea7328d5e5ae5f69b1e7e86120e | https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Providers/InvoiceServiceProvider.php#L44-L54 |
37,347 | CeusMedia/Common | src/UI/Image/Watermark.php | UI_Image_Watermark.calculatePosition | protected function calculatePosition( $image )
{
switch( $this->positionH )
{
case 'left':
$posX = 0 + $this->marginX;
break;
case 'center':
$posX = ceil( $image->getWidth() / 2 - $this->stamp->getWidth() / 2 );
break;
case 'right':
$posX = $image->getWidth() - $this->stamp->getWidth() - $this->marginX;
break;
}
switch( $this->positionV )
{
case 'top':
$posY = 0 + $this->marginY;
break;
case 'middle':
$posY = ceil( $image->getHeight() / 2 - $this->stamp->getHeight() / 2 );
break;
case 'bottom':
$posY = $image->getHeight() - $this->stamp->getHeight() - $this->marginY;
break;
}
$position = array(
'x' => $posX,
'y' => $posY
);
return $position;
} | php | protected function calculatePosition( $image )
{
switch( $this->positionH )
{
case 'left':
$posX = 0 + $this->marginX;
break;
case 'center':
$posX = ceil( $image->getWidth() / 2 - $this->stamp->getWidth() / 2 );
break;
case 'right':
$posX = $image->getWidth() - $this->stamp->getWidth() - $this->marginX;
break;
}
switch( $this->positionV )
{
case 'top':
$posY = 0 + $this->marginY;
break;
case 'middle':
$posY = ceil( $image->getHeight() / 2 - $this->stamp->getHeight() / 2 );
break;
case 'bottom':
$posY = $image->getHeight() - $this->stamp->getHeight() - $this->marginY;
break;
}
$position = array(
'x' => $posX,
'y' => $posY
);
return $position;
} | [
"protected",
"function",
"calculatePosition",
"(",
"$",
"image",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"positionH",
")",
"{",
"case",
"'left'",
":",
"$",
"posX",
"=",
"0",
"+",
"$",
"this",
"->",
"marginX",
";",
"break",
";",
"case",
"'center'",
":",
"$",
"posX",
"=",
"ceil",
"(",
"$",
"image",
"->",
"getWidth",
"(",
")",
"/",
"2",
"-",
"$",
"this",
"->",
"stamp",
"->",
"getWidth",
"(",
")",
"/",
"2",
")",
";",
"break",
";",
"case",
"'right'",
":",
"$",
"posX",
"=",
"$",
"image",
"->",
"getWidth",
"(",
")",
"-",
"$",
"this",
"->",
"stamp",
"->",
"getWidth",
"(",
")",
"-",
"$",
"this",
"->",
"marginX",
";",
"break",
";",
"}",
"switch",
"(",
"$",
"this",
"->",
"positionV",
")",
"{",
"case",
"'top'",
":",
"$",
"posY",
"=",
"0",
"+",
"$",
"this",
"->",
"marginY",
";",
"break",
";",
"case",
"'middle'",
":",
"$",
"posY",
"=",
"ceil",
"(",
"$",
"image",
"->",
"getHeight",
"(",
")",
"/",
"2",
"-",
"$",
"this",
"->",
"stamp",
"->",
"getHeight",
"(",
")",
"/",
"2",
")",
";",
"break",
";",
"case",
"'bottom'",
":",
"$",
"posY",
"=",
"$",
"image",
"->",
"getHeight",
"(",
")",
"-",
"$",
"this",
"->",
"stamp",
"->",
"getHeight",
"(",
")",
"-",
"$",
"this",
"->",
"marginY",
";",
"break",
";",
"}",
"$",
"position",
"=",
"array",
"(",
"'x'",
"=>",
"$",
"posX",
",",
"'y'",
"=>",
"$",
"posY",
")",
";",
"return",
"$",
"position",
";",
"}"
] | Return Array with Coords of Stamp Image within a given Image.
@access protected
@param resource $img Image Resource
@return array | [
"Return",
"Array",
"with",
"Coords",
"of",
"Stamp",
"Image",
"within",
"a",
"given",
"Image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L84-L115 |
37,348 | CeusMedia/Common | src/UI/Image/Watermark.php | UI_Image_Watermark.markImage | public function markImage( $source, $target = NULL )
{
if( !$target )
$target = $source;
$creator = new UI_Image_Creator();
$creator->loadImage( $source );
$image = $creator->getResource();
$type = $creator->getType();
$position = $this->calculatePosition( $creator );
$stampHeight = $this->stamp->getHeight();
$stampWidth = $this->stamp->getWidth();
$stampResource = $this->stamp->getResource();
imagecopymerge( $image, $stampResource, $position['x'], $position['y'], 0, 0, $stampWidth, $stampHeight, $this->alpha );
$printer = new UI_Image_Printer( $image );
$printer->save( $target, $type );
} | php | public function markImage( $source, $target = NULL )
{
if( !$target )
$target = $source;
$creator = new UI_Image_Creator();
$creator->loadImage( $source );
$image = $creator->getResource();
$type = $creator->getType();
$position = $this->calculatePosition( $creator );
$stampHeight = $this->stamp->getHeight();
$stampWidth = $this->stamp->getWidth();
$stampResource = $this->stamp->getResource();
imagecopymerge( $image, $stampResource, $position['x'], $position['y'], 0, 0, $stampWidth, $stampHeight, $this->alpha );
$printer = new UI_Image_Printer( $image );
$printer->save( $target, $type );
} | [
"public",
"function",
"markImage",
"(",
"$",
"source",
",",
"$",
"target",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"target",
")",
"$",
"target",
"=",
"$",
"source",
";",
"$",
"creator",
"=",
"new",
"UI_Image_Creator",
"(",
")",
";",
"$",
"creator",
"->",
"loadImage",
"(",
"$",
"source",
")",
";",
"$",
"image",
"=",
"$",
"creator",
"->",
"getResource",
"(",
")",
";",
"$",
"type",
"=",
"$",
"creator",
"->",
"getType",
"(",
")",
";",
"$",
"position",
"=",
"$",
"this",
"->",
"calculatePosition",
"(",
"$",
"creator",
")",
";",
"$",
"stampHeight",
"=",
"$",
"this",
"->",
"stamp",
"->",
"getHeight",
"(",
")",
";",
"$",
"stampWidth",
"=",
"$",
"this",
"->",
"stamp",
"->",
"getWidth",
"(",
")",
";",
"$",
"stampResource",
"=",
"$",
"this",
"->",
"stamp",
"->",
"getResource",
"(",
")",
";",
"imagecopymerge",
"(",
"$",
"image",
",",
"$",
"stampResource",
",",
"$",
"position",
"[",
"'x'",
"]",
",",
"$",
"position",
"[",
"'y'",
"]",
",",
"0",
",",
"0",
",",
"$",
"stampWidth",
",",
"$",
"stampHeight",
",",
"$",
"this",
"->",
"alpha",
")",
";",
"$",
"printer",
"=",
"new",
"UI_Image_Printer",
"(",
"$",
"image",
")",
";",
"$",
"printer",
"->",
"save",
"(",
"$",
"target",
",",
"$",
"type",
")",
";",
"}"
] | Marks a Image with Stamp Image.
@access public
@param string $source File Name of Source Image
@param string $target Target Name of Target Image
@return bool | [
"Marks",
"a",
"Image",
"with",
"Stamp",
"Image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L124-L142 |
37,349 | CeusMedia/Common | src/UI/Image/Watermark.php | UI_Image_Watermark.setMargin | public function setMargin( $x, $y )
{
$this->marginX = abs( (int)$x );
$this->marginY = abs( (int)$y );
} | php | public function setMargin( $x, $y )
{
$this->marginX = abs( (int)$x );
$this->marginY = abs( (int)$y );
} | [
"public",
"function",
"setMargin",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"$",
"this",
"->",
"marginX",
"=",
"abs",
"(",
"(",
"int",
")",
"$",
"x",
")",
";",
"$",
"this",
"->",
"marginY",
"=",
"abs",
"(",
"(",
"int",
")",
"$",
"y",
")",
";",
"}"
] | Sets the Marig of Stamp Image.
@access public
@param int $x Horizontal Margin of Stamp Image
@param int $y Vertical Margin of Stamp Image
@return void | [
"Sets",
"the",
"Marig",
"of",
"Stamp",
"Image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L162-L166 |
37,350 | CeusMedia/Common | src/UI/Image/Watermark.php | UI_Image_Watermark.setPosition | public function setPosition( $horizontal, $vertical )
{
if( in_array( $horizontal, array( 'left', 'center', 'right' ) ) )
$this->positionH = $horizontal;
else
throw new InvalidArgumentException( 'Horizontal Position "'.$horizontal.'" must be on of (left, center, right).' );
if( in_array( $vertical, array( 'top', 'middle', 'bottom' ) ) )
$this->positionV = $vertical;
else
throw new InvalidArgumentException( 'Vertical Position "'.$horizontal.'" must be on of (top, middle, bottom).' );
} | php | public function setPosition( $horizontal, $vertical )
{
if( in_array( $horizontal, array( 'left', 'center', 'right' ) ) )
$this->positionH = $horizontal;
else
throw new InvalidArgumentException( 'Horizontal Position "'.$horizontal.'" must be on of (left, center, right).' );
if( in_array( $vertical, array( 'top', 'middle', 'bottom' ) ) )
$this->positionV = $vertical;
else
throw new InvalidArgumentException( 'Vertical Position "'.$horizontal.'" must be on of (top, middle, bottom).' );
} | [
"public",
"function",
"setPosition",
"(",
"$",
"horizontal",
",",
"$",
"vertical",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"horizontal",
",",
"array",
"(",
"'left'",
",",
"'center'",
",",
"'right'",
")",
")",
")",
"$",
"this",
"->",
"positionH",
"=",
"$",
"horizontal",
";",
"else",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Horizontal Position \"'",
".",
"$",
"horizontal",
".",
"'\" must be on of (left, center, right).'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"vertical",
",",
"array",
"(",
"'top'",
",",
"'middle'",
",",
"'bottom'",
")",
")",
")",
"$",
"this",
"->",
"positionV",
"=",
"$",
"vertical",
";",
"else",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Vertical Position \"'",
".",
"$",
"horizontal",
".",
"'\" must be on of (top, middle, bottom).'",
")",
";",
"}"
] | Sets the Position of Stamp Image.
@access public
@param string $horizontal Horizontal Position of Stamp Image (left,center,right)
@param string $vertical Vertical Position of Stamp Image (top,middle,bottom)
@return void | [
"Sets",
"the",
"Position",
"of",
"Stamp",
"Image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Watermark.php#L175-L185 |
37,351 | CeusMedia/Common | src/FS/File/VCard/Reader.php | FS_File_VCard_Reader.readFile | public function readFile( $fileName, $charsetIn = NULL, $charsetOut = NULL )
{
$text = FS_File_Reader::load( $fileName );
$parser = new FS_File_VCard_Parser;
return $parser->parse( $text, $charsetIn, $charsetOut );
} | php | public function readFile( $fileName, $charsetIn = NULL, $charsetOut = NULL )
{
$text = FS_File_Reader::load( $fileName );
$parser = new FS_File_VCard_Parser;
return $parser->parse( $text, $charsetIn, $charsetOut );
} | [
"public",
"function",
"readFile",
"(",
"$",
"fileName",
",",
"$",
"charsetIn",
"=",
"NULL",
",",
"$",
"charsetOut",
"=",
"NULL",
")",
"{",
"$",
"text",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"fileName",
")",
";",
"$",
"parser",
"=",
"new",
"FS_File_VCard_Parser",
";",
"return",
"$",
"parser",
"->",
"parse",
"(",
"$",
"text",
",",
"$",
"charsetIn",
",",
"$",
"charsetOut",
")",
";",
"}"
] | Reads and parses vCard File to vCard Object and converts between Charsets.
@access public
@static
@param string $vcard VCard String
@param string $charsetIn Charset to convert from
@param string $charsetOut Charset to convert to
@return string | [
"Reads",
"and",
"parses",
"vCard",
"File",
"to",
"vCard",
"Object",
"and",
"converts",
"between",
"Charsets",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Reader.php#L52-L57 |
37,352 | meritoo/common-library | src/Exception/ValueObject/Template/TemplateNotFoundException.php | TemplateNotFoundException.create | public static function create(string $index): TemplateNotFoundException
{
$template = 'Template with \'%s\' index was not found. Did you provide all required templates?';
$message = sprintf($template, $index);
return new static($message);
} | php | public static function create(string $index): TemplateNotFoundException
{
$template = 'Template with \'%s\' index was not found. Did you provide all required templates?';
$message = sprintf($template, $index);
return new static($message);
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"index",
")",
":",
"TemplateNotFoundException",
"{",
"$",
"template",
"=",
"'Template with \\'%s\\' index was not found. Did you provide all required templates?'",
";",
"$",
"message",
"=",
"sprintf",
"(",
"$",
"template",
",",
"$",
"index",
")",
";",
"return",
"new",
"static",
"(",
"$",
"message",
")",
";",
"}"
] | Creates the exception
@param string $index Index that should contain template, but it was not found
@return TemplateNotFoundException | [
"Creates",
"the",
"exception"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Exception/ValueObject/Template/TemplateNotFoundException.php#L29-L35 |
37,353 | CeusMedia/Common | src/Alg/Turing/Machine.php | Alg_Turing_Machine.cleanTape | private function cleanTape( &$tape )
{
while( substr( $tape, 0, 1 ) == $this->blank )
$tape = substr( $tape, 1 );
while( substr( $tape, -1 ) == $this->blank )
$tape = substr( $tape, 0, -1 );
} | php | private function cleanTape( &$tape )
{
while( substr( $tape, 0, 1 ) == $this->blank )
$tape = substr( $tape, 1 );
while( substr( $tape, -1 ) == $this->blank )
$tape = substr( $tape, 0, -1 );
} | [
"private",
"function",
"cleanTape",
"(",
"&",
"$",
"tape",
")",
"{",
"while",
"(",
"substr",
"(",
"$",
"tape",
",",
"0",
",",
"1",
")",
"==",
"$",
"this",
"->",
"blank",
")",
"$",
"tape",
"=",
"substr",
"(",
"$",
"tape",
",",
"1",
")",
";",
"while",
"(",
"substr",
"(",
"$",
"tape",
",",
"-",
"1",
")",
"==",
"$",
"this",
"->",
"blank",
")",
"$",
"tape",
"=",
"substr",
"(",
"$",
"tape",
",",
"0",
",",
"-",
"1",
")",
";",
"}"
] | Deletes not needed Blanks at start and end of the tape.
@access private
@param string $tape current tape to be cleaned up
@return string | [
"Deletes",
"not",
"needed",
"Blanks",
"at",
"start",
"and",
"end",
"of",
"the",
"tape",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L82-L88 |
37,354 | CeusMedia/Common | src/Alg/Turing/Machine.php | Alg_Turing_Machine.extendTape | private function extendTape( &$tape, $pointer )
{
if( $pointer < 0 )
$tape = $this->blank.$tape;
else if( $pointer >= strlen( $tape ) )
$tape .= $this->blank;
} | php | private function extendTape( &$tape, $pointer )
{
if( $pointer < 0 )
$tape = $this->blank.$tape;
else if( $pointer >= strlen( $tape ) )
$tape .= $this->blank;
} | [
"private",
"function",
"extendTape",
"(",
"&",
"$",
"tape",
",",
"$",
"pointer",
")",
"{",
"if",
"(",
"$",
"pointer",
"<",
"0",
")",
"$",
"tape",
"=",
"$",
"this",
"->",
"blank",
".",
"$",
"tape",
";",
"else",
"if",
"(",
"$",
"pointer",
">=",
"strlen",
"(",
"$",
"tape",
")",
")",
"$",
"tape",
".=",
"$",
"this",
"->",
"blank",
";",
"}"
] | Checks and extends the pseudo infinite tape.
@access private
@param string $tape current tape to be cleaned up
@param string $pointer current Position on tape
@return string | [
"Checks",
"and",
"extends",
"the",
"pseudo",
"infinite",
"tape",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L97-L103 |
37,355 | CeusMedia/Common | src/Alg/Turing/Machine.php | Alg_Turing_Machine.getCurrent | private function getCurrent( &$tape, $pointer )
{
if( $pointer < 0 || $pointer >= strlen( $tape ) )
{
$current = $this->blank;
$this->extendTape( $tape, $pointer );
}
else $current = substr( $tape, $pointer, 1 );
return $current;
} | php | private function getCurrent( &$tape, $pointer )
{
if( $pointer < 0 || $pointer >= strlen( $tape ) )
{
$current = $this->blank;
$this->extendTape( $tape, $pointer );
}
else $current = substr( $tape, $pointer, 1 );
return $current;
} | [
"private",
"function",
"getCurrent",
"(",
"&",
"$",
"tape",
",",
"$",
"pointer",
")",
"{",
"if",
"(",
"$",
"pointer",
"<",
"0",
"||",
"$",
"pointer",
">=",
"strlen",
"(",
"$",
"tape",
")",
")",
"{",
"$",
"current",
"=",
"$",
"this",
"->",
"blank",
";",
"$",
"this",
"->",
"extendTape",
"(",
"$",
"tape",
",",
"$",
"pointer",
")",
";",
"}",
"else",
"$",
"current",
"=",
"substr",
"(",
"$",
"tape",
",",
"$",
"pointer",
",",
"1",
")",
";",
"return",
"$",
"current",
";",
"}"
] | Returns current Sign.
@access private
@param string $tape current tape to be cleaned up
@param string $pointer current Position on tape
@return string | [
"Returns",
"current",
"Sign",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L112-L121 |
37,356 | CeusMedia/Common | src/Alg/Turing/Machine.php | Alg_Turing_Machine.run | public function run( $input )
{
$this->state = $this->start;
$this->pointer = 0;
$output = $input;
$this->wrapTape( $output );
while( !in_array( $this->state, $this->finals ) )
{
if( $_counter > 200 )
break;
$_counter++;
$_current = $this->getCurrent( $output, $this->pointer );
reset( $this->transition );
foreach( $this->transition as $trans )
{
if( $trans[0] == array( $this->state, $_current ) )
{
$value = $trans[1];
$state = $value[0];
$this->state = $state;
$write = $value[1];
$left = substr( $output, 0, $this->pointer );
$right = substr( $output, $this->pointer+1 );
$output = $left.$write.$right;
$direction = $value[2];
if( $direction == "l" )
$this->pointer--;
else if( $direction == "r" )
$this->pointer++;
$this->extendTape( $output, $this->pointer );
$this->wrapTape( $output );
break;
}
}
echo $this->showTape( $output );
}
$this->cleanTape( $output );
return $output;
} | php | public function run( $input )
{
$this->state = $this->start;
$this->pointer = 0;
$output = $input;
$this->wrapTape( $output );
while( !in_array( $this->state, $this->finals ) )
{
if( $_counter > 200 )
break;
$_counter++;
$_current = $this->getCurrent( $output, $this->pointer );
reset( $this->transition );
foreach( $this->transition as $trans )
{
if( $trans[0] == array( $this->state, $_current ) )
{
$value = $trans[1];
$state = $value[0];
$this->state = $state;
$write = $value[1];
$left = substr( $output, 0, $this->pointer );
$right = substr( $output, $this->pointer+1 );
$output = $left.$write.$right;
$direction = $value[2];
if( $direction == "l" )
$this->pointer--;
else if( $direction == "r" )
$this->pointer++;
$this->extendTape( $output, $this->pointer );
$this->wrapTape( $output );
break;
}
}
echo $this->showTape( $output );
}
$this->cleanTape( $output );
return $output;
} | [
"public",
"function",
"run",
"(",
"$",
"input",
")",
"{",
"$",
"this",
"->",
"state",
"=",
"$",
"this",
"->",
"start",
";",
"$",
"this",
"->",
"pointer",
"=",
"0",
";",
"$",
"output",
"=",
"$",
"input",
";",
"$",
"this",
"->",
"wrapTape",
"(",
"$",
"output",
")",
";",
"while",
"(",
"!",
"in_array",
"(",
"$",
"this",
"->",
"state",
",",
"$",
"this",
"->",
"finals",
")",
")",
"{",
"if",
"(",
"$",
"_counter",
">",
"200",
")",
"break",
";",
"$",
"_counter",
"++",
";",
"$",
"_current",
"=",
"$",
"this",
"->",
"getCurrent",
"(",
"$",
"output",
",",
"$",
"this",
"->",
"pointer",
")",
";",
"reset",
"(",
"$",
"this",
"->",
"transition",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"transition",
"as",
"$",
"trans",
")",
"{",
"if",
"(",
"$",
"trans",
"[",
"0",
"]",
"==",
"array",
"(",
"$",
"this",
"->",
"state",
",",
"$",
"_current",
")",
")",
"{",
"$",
"value",
"=",
"$",
"trans",
"[",
"1",
"]",
";",
"$",
"state",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"state",
"=",
"$",
"state",
";",
"$",
"write",
"=",
"$",
"value",
"[",
"1",
"]",
";",
"$",
"left",
"=",
"substr",
"(",
"$",
"output",
",",
"0",
",",
"$",
"this",
"->",
"pointer",
")",
";",
"$",
"right",
"=",
"substr",
"(",
"$",
"output",
",",
"$",
"this",
"->",
"pointer",
"+",
"1",
")",
";",
"$",
"output",
"=",
"$",
"left",
".",
"$",
"write",
".",
"$",
"right",
";",
"$",
"direction",
"=",
"$",
"value",
"[",
"2",
"]",
";",
"if",
"(",
"$",
"direction",
"==",
"\"l\"",
")",
"$",
"this",
"->",
"pointer",
"--",
";",
"else",
"if",
"(",
"$",
"direction",
"==",
"\"r\"",
")",
"$",
"this",
"->",
"pointer",
"++",
";",
"$",
"this",
"->",
"extendTape",
"(",
"$",
"output",
",",
"$",
"this",
"->",
"pointer",
")",
";",
"$",
"this",
"->",
"wrapTape",
"(",
"$",
"output",
")",
";",
"break",
";",
"}",
"}",
"echo",
"$",
"this",
"->",
"showTape",
"(",
"$",
"output",
")",
";",
"}",
"$",
"this",
"->",
"cleanTape",
"(",
"$",
"output",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Runs the Machine.
@access public
@param string $input Input to be worked
@return string | [
"Runs",
"the",
"Machine",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L129-L167 |
37,357 | CeusMedia/Common | src/Alg/Turing/Machine.php | Alg_Turing_Machine.showTape | public function showTape( $tape )
{
for( $i=0; $i<strlen( $tape ); $i++ )
{
$sign = substr( $tape, $i, 1 );
if( $i == $this->pointer )
$lines[] = "<td style='background: #FF7F7F'>".$sign."</td>";
else
$lines[] = "<td>".$sign."</td>";
}
// return "<code>(".$this->state.") ".implode( "", $lines)."</code><br>";
return "<tr><td>(".$this->state.")</td>".implode( "", $lines )."</tr>";
} | php | public function showTape( $tape )
{
for( $i=0; $i<strlen( $tape ); $i++ )
{
$sign = substr( $tape, $i, 1 );
if( $i == $this->pointer )
$lines[] = "<td style='background: #FF7F7F'>".$sign."</td>";
else
$lines[] = "<td>".$sign."</td>";
}
// return "<code>(".$this->state.") ".implode( "", $lines)."</code><br>";
return "<tr><td>(".$this->state.")</td>".implode( "", $lines )."</tr>";
} | [
"public",
"function",
"showTape",
"(",
"$",
"tape",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"tape",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"sign",
"=",
"substr",
"(",
"$",
"tape",
",",
"$",
"i",
",",
"1",
")",
";",
"if",
"(",
"$",
"i",
"==",
"$",
"this",
"->",
"pointer",
")",
"$",
"lines",
"[",
"]",
"=",
"\"<td style='background: #FF7F7F'>\"",
".",
"$",
"sign",
".",
"\"</td>\"",
";",
"else",
"$",
"lines",
"[",
"]",
"=",
"\"<td>\"",
".",
"$",
"sign",
".",
"\"</td>\"",
";",
"}",
"//\t\treturn \"<code>(\".$this->state.\") \".implode( \"\", $lines).\"</code><br>\";\r",
"return",
"\"<tr><td>(\"",
".",
"$",
"this",
"->",
"state",
".",
"\")</td>\"",
".",
"implode",
"(",
"\"\"",
",",
"$",
"lines",
")",
".",
"\"</tr>\"",
";",
"}"
] | Generates HTML Visualisation of current tape.
@access public
@param string $tape current tape
@return string | [
"Generates",
"HTML",
"Visualisation",
"of",
"current",
"tape",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L175-L187 |
37,358 | CeusMedia/Common | src/Alg/Turing/Machine.php | Alg_Turing_Machine.wrapTape | private function wrapTape( &$tape )
{
if( substr( $tape, 0, 1 ) != $this->blank )
$tape = $this->blank.$tape;
if( substr( $tape, -1 ) != $this->blank )
$tape = $tape.$this->blank;
} | php | private function wrapTape( &$tape )
{
if( substr( $tape, 0, 1 ) != $this->blank )
$tape = $this->blank.$tape;
if( substr( $tape, -1 ) != $this->blank )
$tape = $tape.$this->blank;
} | [
"private",
"function",
"wrapTape",
"(",
"&",
"$",
"tape",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"tape",
",",
"0",
",",
"1",
")",
"!=",
"$",
"this",
"->",
"blank",
")",
"$",
"tape",
"=",
"$",
"this",
"->",
"blank",
".",
"$",
"tape",
";",
"if",
"(",
"substr",
"(",
"$",
"tape",
",",
"-",
"1",
")",
"!=",
"$",
"this",
"->",
"blank",
")",
"$",
"tape",
"=",
"$",
"tape",
".",
"$",
"this",
"->",
"blank",
";",
"}"
] | Adds Blanks at start and end of the tape.
@access private
@param string $tape current tape to be cleaned up
@return string | [
"Adds",
"Blanks",
"at",
"start",
"and",
"end",
"of",
"the",
"tape",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Turing/Machine.php#L195-L201 |
37,359 | danielmaier42/Magento2-ConsoleUtility | Command/UtilityCommand.php | UtilityCommand.configure | protected function configure()
{
$this->configureCommand();
foreach ($this->interactiveQuestsion as $argumentName => $question) {
$this->addOption($this->escapeArgument($argumentName), null, InputOption::VALUE_OPTIONAL, $question->getQuestion());
}
} | php | protected function configure()
{
$this->configureCommand();
foreach ($this->interactiveQuestsion as $argumentName => $question) {
$this->addOption($this->escapeArgument($argumentName), null, InputOption::VALUE_OPTIONAL, $question->getQuestion());
}
} | [
"protected",
"function",
"configure",
"(",
")",
"{",
"$",
"this",
"->",
"configureCommand",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"interactiveQuestsion",
"as",
"$",
"argumentName",
"=>",
"$",
"question",
")",
"{",
"$",
"this",
"->",
"addOption",
"(",
"$",
"this",
"->",
"escapeArgument",
"(",
"$",
"argumentName",
")",
",",
"null",
",",
"InputOption",
"::",
"VALUE_OPTIONAL",
",",
"$",
"question",
"->",
"getQuestion",
"(",
")",
")",
";",
"}",
"}"
] | Force Abstract Implementation of Configure | [
"Force",
"Abstract",
"Implementation",
"of",
"Configure"
] | bed046766524bc046cb24251145831de1ed8d681 | https://github.com/danielmaier42/Magento2-ConsoleUtility/blob/bed046766524bc046cb24251145831de1ed8d681/Command/UtilityCommand.php#L99-L106 |
37,360 | spiral/models | src/Reflection/ReflectionEntity.php | ReflectionEntity.declaredMethods | public function declaredMethods(): array
{
$methods = [];
foreach ($this->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() != $this->getName()) {
continue;
}
$methods[] = $method;
}
return $methods;
} | php | public function declaredMethods(): array
{
$methods = [];
foreach ($this->getMethods() as $method) {
if ($method->getDeclaringClass()->getName() != $this->getName()) {
continue;
}
$methods[] = $method;
}
return $methods;
} | [
"public",
"function",
"declaredMethods",
"(",
")",
":",
"array",
"{",
"$",
"methods",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getMethods",
"(",
")",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"$",
"method",
"->",
"getDeclaringClass",
"(",
")",
"->",
"getName",
"(",
")",
"!=",
"$",
"this",
"->",
"getName",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"methods",
"[",
"]",
"=",
"$",
"method",
";",
"}",
"return",
"$",
"methods",
";",
"}"
] | Get methods declared in current class and exclude methods declared in parents.
@return \ReflectionMethod[] | [
"Get",
"methods",
"declared",
"in",
"current",
"class",
"and",
"exclude",
"methods",
"declared",
"in",
"parents",
"."
] | 7ad86808c938354dfc2aaaee824d72ee8a15b6fd | https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Reflection/ReflectionEntity.php#L120-L132 |
37,361 | spiral/models | src/Reflection/ReflectionEntity.php | ReflectionEntity.getMutators | public function getMutators(): array
{
$mutators = [
self::MUTATOR_GETTER => [],
self::MUTATOR_SETTER => [],
self::MUTATOR_ACCESSOR => [],
];
foreach ((array)$this->getProperty('getters', true) as $field => $filter) {
$mutators[self::MUTATOR_GETTER][$field] = $filter;
}
foreach ((array)$this->getProperty('setters', true) as $field => $filter) {
$mutators[self::MUTATOR_SETTER][$field] = $filter;
}
foreach ((array)$this->getProperty('accessors', true) as $field => $filter) {
$mutators[self::MUTATOR_ACCESSOR][$field] = $filter;
}
return $mutators;
} | php | public function getMutators(): array
{
$mutators = [
self::MUTATOR_GETTER => [],
self::MUTATOR_SETTER => [],
self::MUTATOR_ACCESSOR => [],
];
foreach ((array)$this->getProperty('getters', true) as $field => $filter) {
$mutators[self::MUTATOR_GETTER][$field] = $filter;
}
foreach ((array)$this->getProperty('setters', true) as $field => $filter) {
$mutators[self::MUTATOR_SETTER][$field] = $filter;
}
foreach ((array)$this->getProperty('accessors', true) as $field => $filter) {
$mutators[self::MUTATOR_ACCESSOR][$field] = $filter;
}
return $mutators;
} | [
"public",
"function",
"getMutators",
"(",
")",
":",
"array",
"{",
"$",
"mutators",
"=",
"[",
"self",
"::",
"MUTATOR_GETTER",
"=>",
"[",
"]",
",",
"self",
"::",
"MUTATOR_SETTER",
"=>",
"[",
"]",
",",
"self",
"::",
"MUTATOR_ACCESSOR",
"=>",
"[",
"]",
",",
"]",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"getProperty",
"(",
"'getters'",
",",
"true",
")",
"as",
"$",
"field",
"=>",
"$",
"filter",
")",
"{",
"$",
"mutators",
"[",
"self",
"::",
"MUTATOR_GETTER",
"]",
"[",
"$",
"field",
"]",
"=",
"$",
"filter",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"getProperty",
"(",
"'setters'",
",",
"true",
")",
"as",
"$",
"field",
"=>",
"$",
"filter",
")",
"{",
"$",
"mutators",
"[",
"self",
"::",
"MUTATOR_SETTER",
"]",
"[",
"$",
"field",
"]",
"=",
"$",
"filter",
";",
"}",
"foreach",
"(",
"(",
"array",
")",
"$",
"this",
"->",
"getProperty",
"(",
"'accessors'",
",",
"true",
")",
"as",
"$",
"field",
"=>",
"$",
"filter",
")",
"{",
"$",
"mutators",
"[",
"self",
"::",
"MUTATOR_ACCESSOR",
"]",
"[",
"$",
"field",
"]",
"=",
"$",
"filter",
";",
"}",
"return",
"$",
"mutators",
";",
"}"
] | Model mutators grouped by their type.
@return array | [
"Model",
"mutators",
"grouped",
"by",
"their",
"type",
"."
] | 7ad86808c938354dfc2aaaee824d72ee8a15b6fd | https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Reflection/ReflectionEntity.php#L150-L171 |
37,362 | spiral/models | src/Reflection/ReflectionEntity.php | ReflectionEntity.getProperty | public function getProperty(string $property, bool $merge = false)
{
if (isset($this->propertyCache[$property])) {
//Property merging and trait events are pretty slow
return $this->propertyCache[$property];
}
$properties = $this->reflection->getDefaultProperties();
$constants = $this->reflection->getConstants();
if (isset($properties[$property])) {
//Read from default value
$value = $properties[$property];
} elseif (isset($constants[strtoupper($property)])) {
//Read from a constant
$value = $constants[strtoupper($property)];
} else {
return null;
}
//Merge with parent value requested
if ($merge && is_array($value) && !empty($parent = $this->parentReflection())) {
$parentValue = $parent->getProperty($property, $merge);
if (is_array($parentValue)) {
//Class values prior to parent values
$value = array_merge($parentValue, $value);
}
}
if (!$this->reflection->isSubclassOf(SchematicEntity::class)) {
return $value;
}
//To let traits apply schema changes
return $this->propertyCache[$property] = call_user_func(
[$this->getName(), 'describeProperty'], $this, $property, $value
);
} | php | public function getProperty(string $property, bool $merge = false)
{
if (isset($this->propertyCache[$property])) {
//Property merging and trait events are pretty slow
return $this->propertyCache[$property];
}
$properties = $this->reflection->getDefaultProperties();
$constants = $this->reflection->getConstants();
if (isset($properties[$property])) {
//Read from default value
$value = $properties[$property];
} elseif (isset($constants[strtoupper($property)])) {
//Read from a constant
$value = $constants[strtoupper($property)];
} else {
return null;
}
//Merge with parent value requested
if ($merge && is_array($value) && !empty($parent = $this->parentReflection())) {
$parentValue = $parent->getProperty($property, $merge);
if (is_array($parentValue)) {
//Class values prior to parent values
$value = array_merge($parentValue, $value);
}
}
if (!$this->reflection->isSubclassOf(SchematicEntity::class)) {
return $value;
}
//To let traits apply schema changes
return $this->propertyCache[$property] = call_user_func(
[$this->getName(), 'describeProperty'], $this, $property, $value
);
} | [
"public",
"function",
"getProperty",
"(",
"string",
"$",
"property",
",",
"bool",
"$",
"merge",
"=",
"false",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"propertyCache",
"[",
"$",
"property",
"]",
")",
")",
"{",
"//Property merging and trait events are pretty slow",
"return",
"$",
"this",
"->",
"propertyCache",
"[",
"$",
"property",
"]",
";",
"}",
"$",
"properties",
"=",
"$",
"this",
"->",
"reflection",
"->",
"getDefaultProperties",
"(",
")",
";",
"$",
"constants",
"=",
"$",
"this",
"->",
"reflection",
"->",
"getConstants",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"properties",
"[",
"$",
"property",
"]",
")",
")",
"{",
"//Read from default value",
"$",
"value",
"=",
"$",
"properties",
"[",
"$",
"property",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"constants",
"[",
"strtoupper",
"(",
"$",
"property",
")",
"]",
")",
")",
"{",
"//Read from a constant",
"$",
"value",
"=",
"$",
"constants",
"[",
"strtoupper",
"(",
"$",
"property",
")",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"//Merge with parent value requested",
"if",
"(",
"$",
"merge",
"&&",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"empty",
"(",
"$",
"parent",
"=",
"$",
"this",
"->",
"parentReflection",
"(",
")",
")",
")",
"{",
"$",
"parentValue",
"=",
"$",
"parent",
"->",
"getProperty",
"(",
"$",
"property",
",",
"$",
"merge",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"parentValue",
")",
")",
"{",
"//Class values prior to parent values",
"$",
"value",
"=",
"array_merge",
"(",
"$",
"parentValue",
",",
"$",
"value",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"reflection",
"->",
"isSubclassOf",
"(",
"SchematicEntity",
"::",
"class",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"//To let traits apply schema changes",
"return",
"$",
"this",
"->",
"propertyCache",
"[",
"$",
"property",
"]",
"=",
"call_user_func",
"(",
"[",
"$",
"this",
"->",
"getName",
"(",
")",
",",
"'describeProperty'",
"]",
",",
"$",
"this",
",",
"$",
"property",
",",
"$",
"value",
")",
";",
"}"
] | Read default model property value, will read "protected" and "private" properties. Method
raises entity event "describe" to allow it traits modify needed values.
@param string $property Property name.
@param bool $merge If true value will be merged with all parent declarations.
@return mixed | [
"Read",
"default",
"model",
"property",
"value",
"will",
"read",
"protected",
"and",
"private",
"properties",
".",
"Method",
"raises",
"entity",
"event",
"describe",
"to",
"allow",
"it",
"traits",
"modify",
"needed",
"values",
"."
] | 7ad86808c938354dfc2aaaee824d72ee8a15b6fd | https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/Reflection/ReflectionEntity.php#L182-L220 |
37,363 | ncou/Chiron | src/Chiron/Routing/Dispatcher.php | Dispatcher.dispatchRequest | public function dispatchRequest(ServerRequestInterface $request): RouteResult
{
$httpMethod = $request->getMethod();
$uri = rawurldecode($request->getUri()->getPath()); //$uri = '/' . ltrim($request->getUri()->getPath(), '/');
$result = $this->dispatch($httpMethod, $uri);
return $result[0] !== self::FOUND
? $this->marshalFailedRoute($result)
: $this->marshalMatchedRoute($result);
} | php | public function dispatchRequest(ServerRequestInterface $request): RouteResult
{
$httpMethod = $request->getMethod();
$uri = rawurldecode($request->getUri()->getPath()); //$uri = '/' . ltrim($request->getUri()->getPath(), '/');
$result = $this->dispatch($httpMethod, $uri);
return $result[0] !== self::FOUND
? $this->marshalFailedRoute($result)
: $this->marshalMatchedRoute($result);
} | [
"public",
"function",
"dispatchRequest",
"(",
"ServerRequestInterface",
"$",
"request",
")",
":",
"RouteResult",
"{",
"$",
"httpMethod",
"=",
"$",
"request",
"->",
"getMethod",
"(",
")",
";",
"$",
"uri",
"=",
"rawurldecode",
"(",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
")",
";",
"//$uri = '/' . ltrim($request->getUri()->getPath(), '/');",
"$",
"result",
"=",
"$",
"this",
"->",
"dispatch",
"(",
"$",
"httpMethod",
",",
"$",
"uri",
")",
";",
"return",
"$",
"result",
"[",
"0",
"]",
"!==",
"self",
"::",
"FOUND",
"?",
"$",
"this",
"->",
"marshalFailedRoute",
"(",
"$",
"result",
")",
":",
"$",
"this",
"->",
"marshalMatchedRoute",
"(",
"$",
"result",
")",
";",
"}"
] | Dispatch the current route.
@see https://github.com/nikic/FastRoute/blob/master/src/Dispatcher.php
@param \Psr\Http\Message\ServerRequestInterface $request
@return \Psr\Http\Message\ResponseInterface | [
"Dispatch",
"the",
"current",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Dispatcher.php#L30-L40 |
37,364 | ncou/Chiron | src/Chiron/Routing/Dispatcher.php | Dispatcher.marshalFailedRoute | private function marshalFailedRoute(array $result): RouteResult
{
if ($result[0] === self::METHOD_NOT_ALLOWED) {
return RouteResult::fromRouteFailure($result[1]);
}
return RouteResult::fromRouteFailure(RouteResult::HTTP_METHOD_ANY);
} | php | private function marshalFailedRoute(array $result): RouteResult
{
if ($result[0] === self::METHOD_NOT_ALLOWED) {
return RouteResult::fromRouteFailure($result[1]);
}
return RouteResult::fromRouteFailure(RouteResult::HTTP_METHOD_ANY);
} | [
"private",
"function",
"marshalFailedRoute",
"(",
"array",
"$",
"result",
")",
":",
"RouteResult",
"{",
"if",
"(",
"$",
"result",
"[",
"0",
"]",
"===",
"self",
"::",
"METHOD_NOT_ALLOWED",
")",
"{",
"return",
"RouteResult",
"::",
"fromRouteFailure",
"(",
"$",
"result",
"[",
"1",
"]",
")",
";",
"}",
"return",
"RouteResult",
"::",
"fromRouteFailure",
"(",
"RouteResult",
"::",
"HTTP_METHOD_ANY",
")",
";",
"}"
] | Marshal a routing failure result.
If the failure was due to the HTTP method, passes the allowed HTTP
methods to the factory. | [
"Marshal",
"a",
"routing",
"failure",
"result",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Dispatcher.php#L48-L55 |
37,365 | CeusMedia/Common | src/FS/File/Writer.php | FS_File_Writer.create | public function create( $mode = NULL, $user = NULL, $group = NULL )
{
if( self::$minFreeDiskSpace && self::$minFreeDiskSpace > disk_free_space( getcwd() ) )
throw new RuntimeException( 'No space left' );
if( !@touch( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" could not been created' );
if( $mode )
$this->setPermissions( $mode );
if( $user )
$this->setOwner( $user );
if( $group )
$this->setGroup( $group );
} | php | public function create( $mode = NULL, $user = NULL, $group = NULL )
{
if( self::$minFreeDiskSpace && self::$minFreeDiskSpace > disk_free_space( getcwd() ) )
throw new RuntimeException( 'No space left' );
if( !@touch( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" could not been created' );
if( $mode )
$this->setPermissions( $mode );
if( $user )
$this->setOwner( $user );
if( $group )
$this->setGroup( $group );
} | [
"public",
"function",
"create",
"(",
"$",
"mode",
"=",
"NULL",
",",
"$",
"user",
"=",
"NULL",
",",
"$",
"group",
"=",
"NULL",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"minFreeDiskSpace",
"&&",
"self",
"::",
"$",
"minFreeDiskSpace",
">",
"disk_free_space",
"(",
"getcwd",
"(",
")",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No space left'",
")",
";",
"if",
"(",
"!",
"@",
"touch",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" could not been created'",
")",
";",
"if",
"(",
"$",
"mode",
")",
"$",
"this",
"->",
"setPermissions",
"(",
"$",
"mode",
")",
";",
"if",
"(",
"$",
"user",
")",
"$",
"this",
"->",
"setOwner",
"(",
"$",
"user",
")",
";",
"if",
"(",
"$",
"group",
")",
"$",
"this",
"->",
"setGroup",
"(",
"$",
"group",
")",
";",
"}"
] | Create a file and sets Rights, Owner and Group.
@access public
@param string $mode UNIX rights for chmod()
@param string $user User Name for chown()
@param string $group Group Name for chgrp()
@throws RuntimeException if no space is left on file system
@throws RuntimeException if file could not been created
@return void | [
"Create",
"a",
"file",
"and",
"sets",
"Rights",
"Owner",
"and",
"Group",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L91-L105 |
37,366 | CeusMedia/Common | src/FS/File/Writer.php | FS_File_Writer.save | public static function save( $fileName, $content, $mode = NULL, $user = NULL, $group = NULL )
{
$writer = new FS_File_Writer( $fileName, $mode, $user, $group );
return $writer->writeString( $content );
} | php | public static function save( $fileName, $content, $mode = NULL, $user = NULL, $group = NULL )
{
$writer = new FS_File_Writer( $fileName, $mode, $user, $group );
return $writer->writeString( $content );
} | [
"public",
"static",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"content",
",",
"$",
"mode",
"=",
"NULL",
",",
"$",
"user",
"=",
"NULL",
",",
"$",
"group",
"=",
"NULL",
")",
"{",
"$",
"writer",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"fileName",
",",
"$",
"mode",
",",
"$",
"user",
",",
"$",
"group",
")",
";",
"return",
"$",
"writer",
"->",
"writeString",
"(",
"$",
"content",
")",
";",
"}"
] | Saves Content into a File statically and returns Length.
@access public
@static
@param string $fileName URI of File
@param string $content Content to save in File
@param string $mode UNIX rights for chmod()
@param string $user User Name for chown()
@param string $group Group Name for chgrp()
@return integer Number of written bytes
@throws InvalidArgumentExcpetion if no string is given | [
"Saves",
"Content",
"into",
"a",
"File",
"statically",
"and",
"returns",
"Length",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L145-L149 |
37,367 | CeusMedia/Common | src/FS/File/Writer.php | FS_File_Writer.setGroup | public function setGroup( $groupName )
{
if( !$groupName )
throw new InvalidArgumentException( 'No Group Name given.' );
if( !file_exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
if( !$this->isWritable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' );
if( !@chGrp( $this->fileName, $groupName ) )
throw new RuntimeException( 'Only a superuser can change file group' );
} | php | public function setGroup( $groupName )
{
if( !$groupName )
throw new InvalidArgumentException( 'No Group Name given.' );
if( !file_exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
if( !$this->isWritable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' );
if( !@chGrp( $this->fileName, $groupName ) )
throw new RuntimeException( 'Only a superuser can change file group' );
} | [
"public",
"function",
"setGroup",
"(",
"$",
"groupName",
")",
"{",
"if",
"(",
"!",
"$",
"groupName",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No Group Name given.'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" is not existing'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isWritable",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" is not writable'",
")",
";",
"if",
"(",
"!",
"@",
"chGrp",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"groupName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Only a superuser can change file group'",
")",
";",
"}"
] | Sets Group of current File.
@access public
@param string $groupName OS Group Name of new File Owner
@return bool | [
"Sets",
"Group",
"of",
"current",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L173-L183 |
37,368 | CeusMedia/Common | src/FS/File/Writer.php | FS_File_Writer.setOwner | public function setOwner( $userName )
{
if( !$userName )
throw new InvalidArgumentException( 'No User Name given.' );
if( !file_exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
# if( !$this->isOwner() )
# throw new RuntimeException( 'File "'.$this->fileName.'" is not owned by current user' );
if( !$this->isWritable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' );
if( !@chOwn( $this->fileName, $userName ) )
throw new RuntimeException( 'Only a superuser can change file owner' );
} | php | public function setOwner( $userName )
{
if( !$userName )
throw new InvalidArgumentException( 'No User Name given.' );
if( !file_exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
# if( !$this->isOwner() )
# throw new RuntimeException( 'File "'.$this->fileName.'" is not owned by current user' );
if( !$this->isWritable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not writable' );
if( !@chOwn( $this->fileName, $userName ) )
throw new RuntimeException( 'Only a superuser can change file owner' );
} | [
"public",
"function",
"setOwner",
"(",
"$",
"userName",
")",
"{",
"if",
"(",
"!",
"$",
"userName",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No User Name given.'",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" is not existing'",
")",
";",
"#\t\tif( !$this->isOwner() )",
"#\t\t\tthrow new RuntimeException( 'File \"'.$this->fileName.'\" is not owned by current user' );",
"if",
"(",
"!",
"$",
"this",
"->",
"isWritable",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" is not writable'",
")",
";",
"if",
"(",
"!",
"@",
"chOwn",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"userName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Only a superuser can change file owner'",
")",
";",
"}"
] | Sets Owner of current File.
@access public
@param string $userName OS User Name of new File Owner
@return bool | [
"Sets",
"Owner",
"of",
"current",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L191-L203 |
37,369 | CeusMedia/Common | src/FS/File/Writer.php | FS_File_Writer.writeArray | public function writeArray( $array, $lineBreak = "\n" )
{
if( !is_array( $array ) )
throw new InvalidArgumentException( ucFirst( gettype( $string ) ).' given instead of array' );
$string = implode( $lineBreak, $array );
return $this->writeString( $string );
} | php | public function writeArray( $array, $lineBreak = "\n" )
{
if( !is_array( $array ) )
throw new InvalidArgumentException( ucFirst( gettype( $string ) ).' given instead of array' );
$string = implode( $lineBreak, $array );
return $this->writeString( $string );
} | [
"public",
"function",
"writeArray",
"(",
"$",
"array",
",",
"$",
"lineBreak",
"=",
"\"\\n\"",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"array",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"ucFirst",
"(",
"gettype",
"(",
"$",
"string",
")",
")",
".",
"' given instead of array'",
")",
";",
"$",
"string",
"=",
"implode",
"(",
"$",
"lineBreak",
",",
"$",
"array",
")",
";",
"return",
"$",
"this",
"->",
"writeString",
"(",
"$",
"string",
")",
";",
"}"
] | Writes an Array into the File and returns Length.
@access public
@param array $array List of String to write to File
@param string $lineBreak Line Break
@return integer Number of written bytes
@throws InvalidArgumentExcpetion if no array is given | [
"Writes",
"an",
"Array",
"into",
"the",
"File",
"and",
"returns",
"Length",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Writer.php#L225-L231 |
37,370 | CeusMedia/Common | src/ADT/JSON/Formater.php | ADT_JSON_Formater.format | public static function format( $json, $validateSource = FALSE )
{
$tab = " ";
$content = "";
$indentLevel = 0;
$inString = FALSE;
if( !is_string( $json ) )
$json = json_encode( $json );
if( $validateSource )
if( json_decode( $json ) === FALSE )
throw new InvalidArgumentException( 'JSON String is not valid.' );
$len = strlen( $json );
for( $c=0; $c<$len; $c++ )
{
$char = $json[$c];
switch( $char )
{
case '{':
case '[':
$content .= $char;
if( !$inString )
{
$content .= "\n".str_repeat( $tab, $indentLevel + 1 );
$indentLevel++;
}
break;
case '}':
case ']':
if( !$inString )
{
$indentLevel--;
$content .= "\n".str_repeat( $tab, $indentLevel );
}
$content .= $char;
break;
case ',':
$content .= $inString ? $char : ",\n" . str_repeat( $tab, $indentLevel );
break;
case ':':
$content .= $inString ? $char : ": ";
break;
case '"':
if( $c > 0 && $json[$c-1] != '\\' )
$inString = !$inString;
default:
$content .= $char;
break;
}
}
return $content;
} | php | public static function format( $json, $validateSource = FALSE )
{
$tab = " ";
$content = "";
$indentLevel = 0;
$inString = FALSE;
if( !is_string( $json ) )
$json = json_encode( $json );
if( $validateSource )
if( json_decode( $json ) === FALSE )
throw new InvalidArgumentException( 'JSON String is not valid.' );
$len = strlen( $json );
for( $c=0; $c<$len; $c++ )
{
$char = $json[$c];
switch( $char )
{
case '{':
case '[':
$content .= $char;
if( !$inString )
{
$content .= "\n".str_repeat( $tab, $indentLevel + 1 );
$indentLevel++;
}
break;
case '}':
case ']':
if( !$inString )
{
$indentLevel--;
$content .= "\n".str_repeat( $tab, $indentLevel );
}
$content .= $char;
break;
case ',':
$content .= $inString ? $char : ",\n" . str_repeat( $tab, $indentLevel );
break;
case ':':
$content .= $inString ? $char : ": ";
break;
case '"':
if( $c > 0 && $json[$c-1] != '\\' )
$inString = !$inString;
default:
$content .= $char;
break;
}
}
return $content;
} | [
"public",
"static",
"function",
"format",
"(",
"$",
"json",
",",
"$",
"validateSource",
"=",
"FALSE",
")",
"{",
"$",
"tab",
"=",
"\" \"",
";",
"$",
"content",
"=",
"\"\"",
";",
"$",
"indentLevel",
"=",
"0",
";",
"$",
"inString",
"=",
"FALSE",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"json",
")",
")",
"$",
"json",
"=",
"json_encode",
"(",
"$",
"json",
")",
";",
"if",
"(",
"$",
"validateSource",
")",
"if",
"(",
"json_decode",
"(",
"$",
"json",
")",
"===",
"FALSE",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'JSON String is not valid.'",
")",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"json",
")",
";",
"for",
"(",
"$",
"c",
"=",
"0",
";",
"$",
"c",
"<",
"$",
"len",
";",
"$",
"c",
"++",
")",
"{",
"$",
"char",
"=",
"$",
"json",
"[",
"$",
"c",
"]",
";",
"switch",
"(",
"$",
"char",
")",
"{",
"case",
"'{'",
":",
"case",
"'['",
":",
"$",
"content",
".=",
"$",
"char",
";",
"if",
"(",
"!",
"$",
"inString",
")",
"{",
"$",
"content",
".=",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"tab",
",",
"$",
"indentLevel",
"+",
"1",
")",
";",
"$",
"indentLevel",
"++",
";",
"}",
"break",
";",
"case",
"'}'",
":",
"case",
"']'",
":",
"if",
"(",
"!",
"$",
"inString",
")",
"{",
"$",
"indentLevel",
"--",
";",
"$",
"content",
".=",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"tab",
",",
"$",
"indentLevel",
")",
";",
"}",
"$",
"content",
".=",
"$",
"char",
";",
"break",
";",
"case",
"','",
":",
"$",
"content",
".=",
"$",
"inString",
"?",
"$",
"char",
":",
"\",\\n\"",
".",
"str_repeat",
"(",
"$",
"tab",
",",
"$",
"indentLevel",
")",
";",
"break",
";",
"case",
"':'",
":",
"$",
"content",
".=",
"$",
"inString",
"?",
"$",
"char",
":",
"\": \"",
";",
"break",
";",
"case",
"'\"'",
":",
"if",
"(",
"$",
"c",
">",
"0",
"&&",
"$",
"json",
"[",
"$",
"c",
"-",
"1",
"]",
"!=",
"'\\\\'",
")",
"$",
"inString",
"=",
"!",
"$",
"inString",
";",
"default",
":",
"$",
"content",
".=",
"$",
"char",
";",
"break",
";",
"}",
"}",
"return",
"$",
"content",
";",
"}"
] | Formats JSON String.
@access public
@static
@param string $json JSON String or Object to format
@return string | [
"Formats",
"JSON",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Formater.php#L52-L105 |
37,371 | CeusMedia/Common | src/ADT/List/SectionList.php | ADT_List_SectionList.addEntry | public function addEntry( $entry, $section )
{
if( isset( $this->list[$section] ) && is_array( $this->list[$section] ) && in_array( $entry, $this->list[$section] ) )
throw new InvalidArgumentException( 'Entry "'.$entry.'" is already in Section "'.$section.'".' );
$this->list[$section][] = $entry;
} | php | public function addEntry( $entry, $section )
{
if( isset( $this->list[$section] ) && is_array( $this->list[$section] ) && in_array( $entry, $this->list[$section] ) )
throw new InvalidArgumentException( 'Entry "'.$entry.'" is already in Section "'.$section.'".' );
$this->list[$section][] = $entry;
} | [
"public",
"function",
"addEntry",
"(",
"$",
"entry",
",",
"$",
"section",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
"&&",
"in_array",
"(",
"$",
"entry",
",",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Entry \"'",
".",
"$",
"entry",
".",
"'\" is already in Section \"'",
".",
"$",
"section",
".",
"'\".'",
")",
";",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
"[",
"]",
"=",
"$",
"entry",
";",
"}"
] | Adds an Entry to a Section of the List.
@access public
@param mixed $entry Entry to add
@param string $section Section to add in
@return void | [
"Adds",
"an",
"Entry",
"to",
"a",
"Section",
"of",
"the",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L52-L57 |
37,372 | CeusMedia/Common | src/ADT/List/SectionList.php | ADT_List_SectionList.getEntries | public function getEntries( $section )
{
if( !isset( $this->list[$section] ) )
throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' );
return array_values( $this->list[$section] );
} | php | public function getEntries( $section )
{
if( !isset( $this->list[$section] ) )
throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' );
return array_values( $this->list[$section] );
} | [
"public",
"function",
"getEntries",
"(",
"$",
"section",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid Section \"'",
".",
"$",
"section",
".",
"'\".'",
")",
";",
"return",
"array_values",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
";",
"}"
] | Returns a list of Entries of a Section in the List.
@access public
@param string $section Section to get Entries for
@return array | [
"Returns",
"a",
"list",
"of",
"Entries",
"of",
"a",
"Section",
"in",
"the",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L108-L113 |
37,373 | CeusMedia/Common | src/ADT/List/SectionList.php | ADT_List_SectionList.getEntry | public function getEntry( $index, $section )
{
if( !isset( $this->list[$section][$index] ) )
throw new InvalidArgumentException( 'No Entry with Index '.$index.' in Section "'.$section.'" found.' );
return $this->list[$section][$index];
} | php | public function getEntry( $index, $section )
{
if( !isset( $this->list[$section][$index] ) )
throw new InvalidArgumentException( 'No Entry with Index '.$index.' in Section "'.$section.'" found.' );
return $this->list[$section][$index];
} | [
"public",
"function",
"getEntry",
"(",
"$",
"index",
",",
"$",
"section",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
"[",
"$",
"index",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No Entry with Index '",
".",
"$",
"index",
".",
"' in Section \"'",
".",
"$",
"section",
".",
"'\" found.'",
")",
";",
"return",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
"[",
"$",
"index",
"]",
";",
"}"
] | Returns an entry in a section in the List.
@access public
@return mixed | [
"Returns",
"an",
"entry",
"in",
"a",
"section",
"in",
"the",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L120-L125 |
37,374 | CeusMedia/Common | src/ADT/List/SectionList.php | ADT_List_SectionList.getIndex | public function getIndex( $entry, $section = NULL )
{
if( !$section )
$section = $this->getSectionOfEntry( $entry );
if( !isset( $this->list[$section] ) )
throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' );
return array_search( $entry, $this->list[$section] );
} | php | public function getIndex( $entry, $section = NULL )
{
if( !$section )
$section = $this->getSectionOfEntry( $entry );
if( !isset( $this->list[$section] ) )
throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' );
return array_search( $entry, $this->list[$section] );
} | [
"public",
"function",
"getIndex",
"(",
"$",
"entry",
",",
"$",
"section",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"section",
")",
"$",
"section",
"=",
"$",
"this",
"->",
"getSectionOfEntry",
"(",
"$",
"entry",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid Section \"'",
".",
"$",
"section",
".",
"'\".'",
")",
";",
"return",
"array_search",
"(",
"$",
"entry",
",",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
";",
"}"
] | Return the Index of a given String in the List.
@access public
@param string $content Content String of Entry
@param string $section Section of Entry
@return int | [
"Return",
"the",
"Index",
"of",
"a",
"given",
"String",
"in",
"the",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L134-L141 |
37,375 | CeusMedia/Common | src/ADT/List/SectionList.php | ADT_List_SectionList.getSectionOfEntry | public function getSectionOfEntry( $entry )
{
foreach( $this->getSections() as $section )
if( in_array( $entry, $this->list[$section] ) )
return $section;
throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in any Section.' );
} | php | public function getSectionOfEntry( $entry )
{
foreach( $this->getSections() as $section )
if( in_array( $entry, $this->list[$section] ) )
return $section;
throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in any Section.' );
} | [
"public",
"function",
"getSectionOfEntry",
"(",
"$",
"entry",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getSections",
"(",
")",
"as",
"$",
"section",
")",
"if",
"(",
"in_array",
"(",
"$",
"entry",
",",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
")",
"return",
"$",
"section",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Entry \"'",
".",
"$",
"entry",
".",
"'\" not found in any Section.'",
")",
";",
"}"
] | Return the Sections of an entry if available.
@access public
@param string $entry Entry to get Section for
@return string | [
"Return",
"the",
"Sections",
"of",
"an",
"entry",
"if",
"available",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L159-L165 |
37,376 | CeusMedia/Common | src/ADT/List/SectionList.php | ADT_List_SectionList.removeEntry | public function removeEntry( $entry, $section = NULL )
{
if( !$section )
$section = $this->getSectionOfEntry( $entry );
$index = $this->getIndex( $entry, $section );
if( $index === FALSE )
throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in Section "'.$section.'".' );
unset( $this->list[$section][$index] );
} | php | public function removeEntry( $entry, $section = NULL )
{
if( !$section )
$section = $this->getSectionOfEntry( $entry );
$index = $this->getIndex( $entry, $section );
if( $index === FALSE )
throw new InvalidArgumentException( 'Entry "'.$entry.'" not found in Section "'.$section.'".' );
unset( $this->list[$section][$index] );
} | [
"public",
"function",
"removeEntry",
"(",
"$",
"entry",
",",
"$",
"section",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"section",
")",
"$",
"section",
"=",
"$",
"this",
"->",
"getSectionOfEntry",
"(",
"$",
"entry",
")",
";",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"entry",
",",
"$",
"section",
")",
";",
"if",
"(",
"$",
"index",
"===",
"FALSE",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Entry \"'",
".",
"$",
"entry",
".",
"'\" not found in Section \"'",
".",
"$",
"section",
".",
"'\".'",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
"[",
"$",
"index",
"]",
")",
";",
"}"
] | Removes an entry in a section in the List.
@access public
@param string $entry Entry to remove
@param string $section Section of Entry
@return void | [
"Removes",
"an",
"entry",
"in",
"a",
"section",
"in",
"the",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L184-L192 |
37,377 | CeusMedia/Common | src/ADT/List/SectionList.php | ADT_List_SectionList.removeSection | public function removeSection( $section )
{
if( !isset( $this->list[$section] ) )
throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' );
unset( $this->list[$section] );
} | php | public function removeSection( $section )
{
if( !isset( $this->list[$section] ) )
throw new InvalidArgumentException( 'Invalid Section "'.$section.'".' );
unset( $this->list[$section] );
} | [
"public",
"function",
"removeSection",
"(",
"$",
"section",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid Section \"'",
".",
"$",
"section",
".",
"'\".'",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"section",
"]",
")",
";",
"}"
] | Removes a section in the List.
@access public
@param string $section Section to remove
@return void | [
"Removes",
"a",
"section",
"in",
"the",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/SectionList.php#L200-L205 |
37,378 | 975L/EmailBundle | Entity/Email.php | Email.setDataFromArray | public function setDataFromArray(array $data)
{
foreach ($data as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
$this->$method($value);
}
}
} | php | public function setDataFromArray(array $data)
{
foreach ($data as $key => $value) {
$method = 'set' . ucfirst($key);
if (method_exists($this, $method)) {
$this->$method($value);
}
}
} | [
"public",
"function",
"setDataFromArray",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"method",
"=",
"'set'",
".",
"ucfirst",
"(",
"$",
"key",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"method",
")",
")",
"{",
"$",
"this",
"->",
"$",
"method",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | Hydrates entity from associative array | [
"Hydrates",
"entity",
"from",
"associative",
"array"
] | e674f4aa96b264c453d8a1ce18b749cbc97a1803 | https://github.com/975L/EmailBundle/blob/e674f4aa96b264c453d8a1ce18b749cbc97a1803/Entity/Email.php#L106-L114 |
37,379 | CeusMedia/Common | src/Net/IMAP/Box.php | Net_IMAP_Box.getBoxInfo | public function getBoxInfo( $folder = NULL )
{
$address = $this->connection->getAddress( $this->folder.$folder );
$info = imap_mailboxmsginfo( $this->connection->getStream() );
if( !$info )
throw new Exception( "imap_mailboxmsginfo() failed: ". imap_lasterror() );
return array(
"date" => $info->Date,
"driver" => $info->Driver,
"mailbox" => $info->Mailbox,
"messages" => $info->Nmsgs,
"recent" => $info->Recent,
"size" => $info->Size,
);
} | php | public function getBoxInfo( $folder = NULL )
{
$address = $this->connection->getAddress( $this->folder.$folder );
$info = imap_mailboxmsginfo( $this->connection->getStream() );
if( !$info )
throw new Exception( "imap_mailboxmsginfo() failed: ". imap_lasterror() );
return array(
"date" => $info->Date,
"driver" => $info->Driver,
"mailbox" => $info->Mailbox,
"messages" => $info->Nmsgs,
"recent" => $info->Recent,
"size" => $info->Size,
);
} | [
"public",
"function",
"getBoxInfo",
"(",
"$",
"folder",
"=",
"NULL",
")",
"{",
"$",
"address",
"=",
"$",
"this",
"->",
"connection",
"->",
"getAddress",
"(",
"$",
"this",
"->",
"folder",
".",
"$",
"folder",
")",
";",
"$",
"info",
"=",
"imap_mailboxmsginfo",
"(",
"$",
"this",
"->",
"connection",
"->",
"getStream",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"info",
")",
"throw",
"new",
"Exception",
"(",
"\"imap_mailboxmsginfo() failed: \"",
".",
"imap_lasterror",
"(",
")",
")",
";",
"return",
"array",
"(",
"\"date\"",
"=>",
"$",
"info",
"->",
"Date",
",",
"\"driver\"",
"=>",
"$",
"info",
"->",
"Driver",
",",
"\"mailbox\"",
"=>",
"$",
"info",
"->",
"Mailbox",
",",
"\"messages\"",
"=>",
"$",
"info",
"->",
"Nmsgs",
",",
"\"recent\"",
"=>",
"$",
"info",
"->",
"Recent",
",",
"\"size\"",
"=>",
"$",
"info",
"->",
"Size",
",",
")",
";",
"}"
] | Returns Information Array of Mail Box.
@access public
@param string $folder Folder within Mail Box
@return array | [
"Returns",
"Information",
"Array",
"of",
"Mail",
"Box",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Box.php#L65-L79 |
37,380 | CeusMedia/Common | src/Net/IMAP/Box.php | Net_IMAP_Box.getFolders | public function getFolders( $folder = "*" )
{
$list = array();
$address = $this->connection->getAddress();
$folders = imap_getmailboxes( $this->connection->getStream(), $address, "*" );
foreach( $folders as $folder )
$list[] = str_replace( $address, "", imap_utf7_decode( $folder->name ) );
return $list;
} | php | public function getFolders( $folder = "*" )
{
$list = array();
$address = $this->connection->getAddress();
$folders = imap_getmailboxes( $this->connection->getStream(), $address, "*" );
foreach( $folders as $folder )
$list[] = str_replace( $address, "", imap_utf7_decode( $folder->name ) );
return $list;
} | [
"public",
"function",
"getFolders",
"(",
"$",
"folder",
"=",
"\"*\"",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"address",
"=",
"$",
"this",
"->",
"connection",
"->",
"getAddress",
"(",
")",
";",
"$",
"folders",
"=",
"imap_getmailboxes",
"(",
"$",
"this",
"->",
"connection",
"->",
"getStream",
"(",
")",
",",
"$",
"address",
",",
"\"*\"",
")",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"$",
"list",
"[",
"]",
"=",
"str_replace",
"(",
"$",
"address",
",",
"\"\"",
",",
"imap_utf7_decode",
"(",
"$",
"folder",
"->",
"name",
")",
")",
";",
"return",
"$",
"list",
";",
"}"
] | Returns Array of Folders within Mail Box.
@access public
@param string $folder Folder to index
@return array | [
"Returns",
"Array",
"of",
"Folders",
"within",
"Mail",
"Box",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Box.php#L87-L95 |
37,381 | CeusMedia/Common | src/Net/IMAP/Box.php | Net_IMAP_Box.getStatusInfo | public function getStatusInfo( $folder = NULL )
{
$address = $this->connection->getAddress( $folder );
$info = imap_status( $this->connection->getStream(), $address, SA_ALL );
if( !$info )
throw new Exception( "imap_status() failed: ". imap_lasterror() );
return array(
"messages" => $info->messages,
"recent" => $info->recent,
"unseen" => $info->unseen,
);
} | php | public function getStatusInfo( $folder = NULL )
{
$address = $this->connection->getAddress( $folder );
$info = imap_status( $this->connection->getStream(), $address, SA_ALL );
if( !$info )
throw new Exception( "imap_status() failed: ". imap_lasterror() );
return array(
"messages" => $info->messages,
"recent" => $info->recent,
"unseen" => $info->unseen,
);
} | [
"public",
"function",
"getStatusInfo",
"(",
"$",
"folder",
"=",
"NULL",
")",
"{",
"$",
"address",
"=",
"$",
"this",
"->",
"connection",
"->",
"getAddress",
"(",
"$",
"folder",
")",
";",
"$",
"info",
"=",
"imap_status",
"(",
"$",
"this",
"->",
"connection",
"->",
"getStream",
"(",
")",
",",
"$",
"address",
",",
"SA_ALL",
")",
";",
"if",
"(",
"!",
"$",
"info",
")",
"throw",
"new",
"Exception",
"(",
"\"imap_status() failed: \"",
".",
"imap_lasterror",
"(",
")",
")",
";",
"return",
"array",
"(",
"\"messages\"",
"=>",
"$",
"info",
"->",
"messages",
",",
"\"recent\"",
"=>",
"$",
"info",
"->",
"recent",
",",
"\"unseen\"",
"=>",
"$",
"info",
"->",
"unseen",
",",
")",
";",
"}"
] | Returns Status Information of Mail Box.
@access public
@param string $folder Folder in Mail Box
@return array | [
"Returns",
"Status",
"Information",
"of",
"Mail",
"Box",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/IMAP/Box.php#L230-L241 |
37,382 | CeusMedia/Common | src/ADT/Constant.php | ADT_Constant.get | public static function get( $key )
{
$key = strtoupper( $key );
if( self::has( $key ) )
return constant( $key );
throw new InvalidArgumentException( 'Constant "'.$key.'" is not set' );
} | php | public static function get( $key )
{
$key = strtoupper( $key );
if( self::has( $key ) )
return constant( $key );
throw new InvalidArgumentException( 'Constant "'.$key.'" is not set' );
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"strtoupper",
"(",
"$",
"key",
")",
";",
"if",
"(",
"self",
"::",
"has",
"(",
"$",
"key",
")",
")",
"return",
"constant",
"(",
"$",
"key",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Constant \"'",
".",
"$",
"key",
".",
"'\" is not set'",
")",
";",
"}"
] | Returns the Value of a set Constant, throws Exception otherwise.
@access public
@static
@param string $key Name of Constant to return
@return mixed
@todo finish impl | [
"Returns",
"the",
"Value",
"of",
"a",
"set",
"Constant",
"throws",
"Exception",
"otherwise",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Constant.php#L52-L58 |
37,383 | CeusMedia/Common | src/ADT/Constant.php | ADT_Constant.getAll | public static function getAll( $prefix = NULL, $excludePrefix = NULL )
{
$prefix = strtoupper( $prefix );
$length = strlen( $prefix );
if( $length < 2 )
throw new InvalidArgumentException( 'Prefix "'.$prefix.'" is to short.' );
$map = get_defined_constants();
if( $prefix ){
foreach( $map as $key => $value )
{
if( $key[0] !== $prefix[0] )
unset( $map[$key] );
else if( $key[1] !== $prefix[1] )
unset( $map[$key] );
else if( substr( $key, 0, $length ) !== $prefix )
unset( $map[$key] );
# remark( $prefix." - ".$key." - ".(int)isset( $map[$key] ) );
}
}
if( $excludePrefix ){
if( substr( $excludePrefix, 0, $length ) !== $prefix )
$excludePrefix = $prefix.$excludePrefix;
foreach( $map as $key => $value ){
if( substr( $key, 0, strlen( $excludePrefix ) ) === $excludePrefix )
unset( $map[$key] );
}
}
return $map;
} | php | public static function getAll( $prefix = NULL, $excludePrefix = NULL )
{
$prefix = strtoupper( $prefix );
$length = strlen( $prefix );
if( $length < 2 )
throw new InvalidArgumentException( 'Prefix "'.$prefix.'" is to short.' );
$map = get_defined_constants();
if( $prefix ){
foreach( $map as $key => $value )
{
if( $key[0] !== $prefix[0] )
unset( $map[$key] );
else if( $key[1] !== $prefix[1] )
unset( $map[$key] );
else if( substr( $key, 0, $length ) !== $prefix )
unset( $map[$key] );
# remark( $prefix." - ".$key." - ".(int)isset( $map[$key] ) );
}
}
if( $excludePrefix ){
if( substr( $excludePrefix, 0, $length ) !== $prefix )
$excludePrefix = $prefix.$excludePrefix;
foreach( $map as $key => $value ){
if( substr( $key, 0, strlen( $excludePrefix ) ) === $excludePrefix )
unset( $map[$key] );
}
}
return $map;
} | [
"public",
"static",
"function",
"getAll",
"(",
"$",
"prefix",
"=",
"NULL",
",",
"$",
"excludePrefix",
"=",
"NULL",
")",
"{",
"$",
"prefix",
"=",
"strtoupper",
"(",
"$",
"prefix",
")",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"prefix",
")",
";",
"if",
"(",
"$",
"length",
"<",
"2",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Prefix \"'",
".",
"$",
"prefix",
".",
"'\" is to short.'",
")",
";",
"$",
"map",
"=",
"get_defined_constants",
"(",
")",
";",
"if",
"(",
"$",
"prefix",
")",
"{",
"foreach",
"(",
"$",
"map",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"[",
"0",
"]",
"!==",
"$",
"prefix",
"[",
"0",
"]",
")",
"unset",
"(",
"$",
"map",
"[",
"$",
"key",
"]",
")",
";",
"else",
"if",
"(",
"$",
"key",
"[",
"1",
"]",
"!==",
"$",
"prefix",
"[",
"1",
"]",
")",
"unset",
"(",
"$",
"map",
"[",
"$",
"key",
"]",
")",
";",
"else",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"$",
"length",
")",
"!==",
"$",
"prefix",
")",
"unset",
"(",
"$",
"map",
"[",
"$",
"key",
"]",
")",
";",
"#\t\t\t\tremark( $prefix.\" - \".$key.\" - \".(int)isset( $map[$key] ) );",
"}",
"}",
"if",
"(",
"$",
"excludePrefix",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"excludePrefix",
",",
"0",
",",
"$",
"length",
")",
"!==",
"$",
"prefix",
")",
"$",
"excludePrefix",
"=",
"$",
"prefix",
".",
"$",
"excludePrefix",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"key",
",",
"0",
",",
"strlen",
"(",
"$",
"excludePrefix",
")",
")",
"===",
"$",
"excludePrefix",
")",
"unset",
"(",
"$",
"map",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"$",
"map",
";",
"}"
] | Returns a Map of defined Constants.
@access public
@static
@return array | [
"Returns",
"a",
"Map",
"of",
"defined",
"Constants",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Constant.php#L66-L94 |
37,384 | CeusMedia/Common | src/ADT/Constant.php | ADT_Constant.set | public static function set( $key, $value, $strict = TRUE )
{
$key = strtoupper( $key );
if( defined( $key ) && $strict )
throw new RuntimeException( 'Constant "'.$key.'" is already defined.' );
return define( $key, $value );
} | php | public static function set( $key, $value, $strict = TRUE )
{
$key = strtoupper( $key );
if( defined( $key ) && $strict )
throw new RuntimeException( 'Constant "'.$key.'" is already defined.' );
return define( $key, $value );
} | [
"public",
"static",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"strict",
"=",
"TRUE",
")",
"{",
"$",
"key",
"=",
"strtoupper",
"(",
"$",
"key",
")",
";",
"if",
"(",
"defined",
"(",
"$",
"key",
")",
"&&",
"$",
"strict",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Constant \"'",
".",
"$",
"key",
".",
"'\" is already defined.'",
")",
";",
"return",
"define",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Sets a Constant.
@access public
@static
@param string $key Name of Constant to set
@param mixed $value Value of Constant to set
@param bool $strict Flag: set only if unset
@return bool
@throws RuntimeException if Constant has already been set | [
"Sets",
"a",
"Constant",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Constant.php#L136-L142 |
37,385 | CeusMedia/Common | src/FS/Folder/CodeLineCounter.php | FS_Folder_CodeLineCounter.readFolder | public function readFolder( $path, $extensions = array() )
{
$files = array();
$numberCodes = 0;
$numberDocs = 0;
$numberFiles = 0;
$numberLength = 0;
$numberLines = 0;
$numberStrips = 0;
$path = preg_replace( "@^(.+)/?$@", "\\1/", $path );
$st = new Alg_Time_Clock();
$lister = new FS_Folder_RecursiveLister( $path );
$lister->setExtensions( $extensions );
$list = $lister->getList();
foreach( $list as $entry )
{
$fileName = str_replace( "\\", "/", $entry->getFilename() );
$pathName = str_replace( "\\", "/", $entry->getPathname() );
if( substr( $fileName, 0, 1 ) == "_" )
continue;
if( preg_match( "@/_@", $pathName ) )
continue;
$countData = FS_File_CodeLineCounter::countLines( $pathName );
unset( $countData['linesCodes'] );
unset( $countData['linesDocs'] );
unset( $countData['linesStrips'] );
$numberLength += $countData['length'];
$numberLines += $countData['linesTotal'];
$numberFiles ++;
$numberStrips += $countData['numberStrips'];
$numberCodes += $countData['numberCodes'];
$numberDocs += $countData['numberDocs'];
$files[$pathName] = $countData;
}
$linesPerFile = $numberLines / $numberFiles;
$this->data = array(
'number' => array(
'files' => $numberFiles,
'lines' => $numberLines,
'codes' => $numberCodes,
'docs' => $numberDocs,
'strips' => $numberStrips,
'length' => $numberLength,
),
'ratio' => array(
'linesPerFile' => round( $linesPerFile, 0 ),
'codesPerFile' => round( $numberCodes / $numberFiles, 0 ),
'docsPerFile' => round( $numberDocs / $numberFiles, 0 ),
'stripsPerFile' => round( $numberStrips / $numberFiles, 0 ),
'codesPerFile%' => round( $numberCodes / $numberFiles / $linesPerFile * 100, 1 ),
'docsPerFile%' => round( $numberDocs / $numberFiles / $linesPerFile * 100, 1 ),
'stripsPerFile%' => round( $numberStrips / $numberFiles / $linesPerFile * 100, 1 ),
),
'files' => $files,
'seconds' => $st->stop( 6 ),
'path' => $path,
);
} | php | public function readFolder( $path, $extensions = array() )
{
$files = array();
$numberCodes = 0;
$numberDocs = 0;
$numberFiles = 0;
$numberLength = 0;
$numberLines = 0;
$numberStrips = 0;
$path = preg_replace( "@^(.+)/?$@", "\\1/", $path );
$st = new Alg_Time_Clock();
$lister = new FS_Folder_RecursiveLister( $path );
$lister->setExtensions( $extensions );
$list = $lister->getList();
foreach( $list as $entry )
{
$fileName = str_replace( "\\", "/", $entry->getFilename() );
$pathName = str_replace( "\\", "/", $entry->getPathname() );
if( substr( $fileName, 0, 1 ) == "_" )
continue;
if( preg_match( "@/_@", $pathName ) )
continue;
$countData = FS_File_CodeLineCounter::countLines( $pathName );
unset( $countData['linesCodes'] );
unset( $countData['linesDocs'] );
unset( $countData['linesStrips'] );
$numberLength += $countData['length'];
$numberLines += $countData['linesTotal'];
$numberFiles ++;
$numberStrips += $countData['numberStrips'];
$numberCodes += $countData['numberCodes'];
$numberDocs += $countData['numberDocs'];
$files[$pathName] = $countData;
}
$linesPerFile = $numberLines / $numberFiles;
$this->data = array(
'number' => array(
'files' => $numberFiles,
'lines' => $numberLines,
'codes' => $numberCodes,
'docs' => $numberDocs,
'strips' => $numberStrips,
'length' => $numberLength,
),
'ratio' => array(
'linesPerFile' => round( $linesPerFile, 0 ),
'codesPerFile' => round( $numberCodes / $numberFiles, 0 ),
'docsPerFile' => round( $numberDocs / $numberFiles, 0 ),
'stripsPerFile' => round( $numberStrips / $numberFiles, 0 ),
'codesPerFile%' => round( $numberCodes / $numberFiles / $linesPerFile * 100, 1 ),
'docsPerFile%' => round( $numberDocs / $numberFiles / $linesPerFile * 100, 1 ),
'stripsPerFile%' => round( $numberStrips / $numberFiles / $linesPerFile * 100, 1 ),
),
'files' => $files,
'seconds' => $st->stop( 6 ),
'path' => $path,
);
} | [
"public",
"function",
"readFolder",
"(",
"$",
"path",
",",
"$",
"extensions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"files",
"=",
"array",
"(",
")",
";",
"$",
"numberCodes",
"=",
"0",
";",
"$",
"numberDocs",
"=",
"0",
";",
"$",
"numberFiles",
"=",
"0",
";",
"$",
"numberLength",
"=",
"0",
";",
"$",
"numberLines",
"=",
"0",
";",
"$",
"numberStrips",
"=",
"0",
";",
"$",
"path",
"=",
"preg_replace",
"(",
"\"@^(.+)/?$@\"",
",",
"\"\\\\1/\"",
",",
"$",
"path",
")",
";",
"$",
"st",
"=",
"new",
"Alg_Time_Clock",
"(",
")",
";",
"$",
"lister",
"=",
"new",
"FS_Folder_RecursiveLister",
"(",
"$",
"path",
")",
";",
"$",
"lister",
"->",
"setExtensions",
"(",
"$",
"extensions",
")",
";",
"$",
"list",
"=",
"$",
"lister",
"->",
"getList",
"(",
")",
";",
"foreach",
"(",
"$",
"list",
"as",
"$",
"entry",
")",
"{",
"$",
"fileName",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
",",
"$",
"entry",
"->",
"getFilename",
"(",
")",
")",
";",
"$",
"pathName",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"",
",",
"$",
"entry",
"->",
"getPathname",
"(",
")",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"fileName",
",",
"0",
",",
"1",
")",
"==",
"\"_\"",
")",
"continue",
";",
"if",
"(",
"preg_match",
"(",
"\"@/_@\"",
",",
"$",
"pathName",
")",
")",
"continue",
";",
"$",
"countData",
"=",
"FS_File_CodeLineCounter",
"::",
"countLines",
"(",
"$",
"pathName",
")",
";",
"unset",
"(",
"$",
"countData",
"[",
"'linesCodes'",
"]",
")",
";",
"unset",
"(",
"$",
"countData",
"[",
"'linesDocs'",
"]",
")",
";",
"unset",
"(",
"$",
"countData",
"[",
"'linesStrips'",
"]",
")",
";",
"$",
"numberLength",
"+=",
"$",
"countData",
"[",
"'length'",
"]",
";",
"$",
"numberLines",
"+=",
"$",
"countData",
"[",
"'linesTotal'",
"]",
";",
"$",
"numberFiles",
"++",
";",
"$",
"numberStrips",
"+=",
"$",
"countData",
"[",
"'numberStrips'",
"]",
";",
"$",
"numberCodes",
"+=",
"$",
"countData",
"[",
"'numberCodes'",
"]",
";",
"$",
"numberDocs",
"+=",
"$",
"countData",
"[",
"'numberDocs'",
"]",
";",
"$",
"files",
"[",
"$",
"pathName",
"]",
"=",
"$",
"countData",
";",
"}",
"$",
"linesPerFile",
"=",
"$",
"numberLines",
"/",
"$",
"numberFiles",
";",
"$",
"this",
"->",
"data",
"=",
"array",
"(",
"'number'",
"=>",
"array",
"(",
"'files'",
"=>",
"$",
"numberFiles",
",",
"'lines'",
"=>",
"$",
"numberLines",
",",
"'codes'",
"=>",
"$",
"numberCodes",
",",
"'docs'",
"=>",
"$",
"numberDocs",
",",
"'strips'",
"=>",
"$",
"numberStrips",
",",
"'length'",
"=>",
"$",
"numberLength",
",",
")",
",",
"'ratio'",
"=>",
"array",
"(",
"'linesPerFile'",
"=>",
"round",
"(",
"$",
"linesPerFile",
",",
"0",
")",
",",
"'codesPerFile'",
"=>",
"round",
"(",
"$",
"numberCodes",
"/",
"$",
"numberFiles",
",",
"0",
")",
",",
"'docsPerFile'",
"=>",
"round",
"(",
"$",
"numberDocs",
"/",
"$",
"numberFiles",
",",
"0",
")",
",",
"'stripsPerFile'",
"=>",
"round",
"(",
"$",
"numberStrips",
"/",
"$",
"numberFiles",
",",
"0",
")",
",",
"'codesPerFile%'",
"=>",
"round",
"(",
"$",
"numberCodes",
"/",
"$",
"numberFiles",
"/",
"$",
"linesPerFile",
"*",
"100",
",",
"1",
")",
",",
"'docsPerFile%'",
"=>",
"round",
"(",
"$",
"numberDocs",
"/",
"$",
"numberFiles",
"/",
"$",
"linesPerFile",
"*",
"100",
",",
"1",
")",
",",
"'stripsPerFile%'",
"=>",
"round",
"(",
"$",
"numberStrips",
"/",
"$",
"numberFiles",
"/",
"$",
"linesPerFile",
"*",
"100",
",",
"1",
")",
",",
")",
",",
"'files'",
"=>",
"$",
"files",
",",
"'seconds'",
"=>",
"$",
"st",
"->",
"stop",
"(",
"6",
")",
",",
"'path'",
"=>",
"$",
"path",
",",
")",
";",
"}"
] | Counts Files, Folders, Lines of Code and other statistical Information.
@access public
@param string $path Folder to count within
@param array $extensions List of Code File Extensions
@return array | [
"Counts",
"Files",
"Folders",
"Lines",
"of",
"Code",
"and",
"other",
"statistical",
"Information",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/CodeLineCounter.php#L75-L139 |
37,386 | meritoo/common-library | src/Utilities/Locale.php | Locale.setLocale | public static function setLocale($category, $languageCode, $countryCode = '')
{
$category = (int)$category;
if (is_string($languageCode)) {
$languageCode = trim($languageCode);
}
$availableCategories = [
LC_ALL,
LC_COLLATE,
LC_CTYPE,
LC_MONETARY,
LC_NUMERIC,
LC_TIME,
LC_MESSAGES,
];
if (empty($languageCode) || !in_array($category, $availableCategories, true)) {
return false;
}
$localeLongForm = self::getLongForm($languageCode, $countryCode);
return setlocale($category, $localeLongForm);
} | php | public static function setLocale($category, $languageCode, $countryCode = '')
{
$category = (int)$category;
if (is_string($languageCode)) {
$languageCode = trim($languageCode);
}
$availableCategories = [
LC_ALL,
LC_COLLATE,
LC_CTYPE,
LC_MONETARY,
LC_NUMERIC,
LC_TIME,
LC_MESSAGES,
];
if (empty($languageCode) || !in_array($category, $availableCategories, true)) {
return false;
}
$localeLongForm = self::getLongForm($languageCode, $countryCode);
return setlocale($category, $localeLongForm);
} | [
"public",
"static",
"function",
"setLocale",
"(",
"$",
"category",
",",
"$",
"languageCode",
",",
"$",
"countryCode",
"=",
"''",
")",
"{",
"$",
"category",
"=",
"(",
"int",
")",
"$",
"category",
";",
"if",
"(",
"is_string",
"(",
"$",
"languageCode",
")",
")",
"{",
"$",
"languageCode",
"=",
"trim",
"(",
"$",
"languageCode",
")",
";",
"}",
"$",
"availableCategories",
"=",
"[",
"LC_ALL",
",",
"LC_COLLATE",
",",
"LC_CTYPE",
",",
"LC_MONETARY",
",",
"LC_NUMERIC",
",",
"LC_TIME",
",",
"LC_MESSAGES",
",",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"languageCode",
")",
"||",
"!",
"in_array",
"(",
"$",
"category",
",",
"$",
"availableCategories",
",",
"true",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"localeLongForm",
"=",
"self",
"::",
"getLongForm",
"(",
"$",
"languageCode",
",",
"$",
"countryCode",
")",
";",
"return",
"setlocale",
"(",
"$",
"category",
",",
"$",
"localeLongForm",
")",
";",
"}"
] | Sets locale for given category using given language and country code
@param int $category Named constant specifying the category of the functions affected by the locale
setting. It's the same constant as required by setlocale() function.
@param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
@param string $countryCode (optional) Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
@return false|string
Available categories (values of $category argument):
- LC_ALL for all of the below
- LC_COLLATE for string comparison, see strcoll()
- LC_CTYPE for character classification and conversion, for example strtoupper()
- LC_MONETARY for localeconv()
- LC_NUMERIC for decimal separator (See also localeconv())
- LC_TIME for date and time formatting with strftime()
- LC_MESSAGES for system responses (available if PHP was compiled with libintl) | [
"Sets",
"locale",
"for",
"given",
"category",
"using",
"given",
"language",
"and",
"country",
"code"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Locale.php#L37-L62 |
37,387 | meritoo/common-library | src/Utilities/Locale.php | Locale.getLongForm | public static function getLongForm($languageCode, $countryCode = '', $encoding = 'UTF-8')
{
if (is_string($languageCode)) {
$languageCode = trim($languageCode);
}
/*
* Language code not provided?
* Nothing to do
*/
if (empty($languageCode)) {
return '';
}
/*
* Country code not provided?
* Let's use language code
*/
if (empty($countryCode)) {
$countryCode = $languageCode;
}
if (!empty($encoding)) {
$encoding = sprintf('.%s', $encoding);
}
return sprintf('%s_%s%s', $languageCode, strtoupper($countryCode), $encoding);
} | php | public static function getLongForm($languageCode, $countryCode = '', $encoding = 'UTF-8')
{
if (is_string($languageCode)) {
$languageCode = trim($languageCode);
}
/*
* Language code not provided?
* Nothing to do
*/
if (empty($languageCode)) {
return '';
}
/*
* Country code not provided?
* Let's use language code
*/
if (empty($countryCode)) {
$countryCode = $languageCode;
}
if (!empty($encoding)) {
$encoding = sprintf('.%s', $encoding);
}
return sprintf('%s_%s%s', $languageCode, strtoupper($countryCode), $encoding);
} | [
"public",
"static",
"function",
"getLongForm",
"(",
"$",
"languageCode",
",",
"$",
"countryCode",
"=",
"''",
",",
"$",
"encoding",
"=",
"'UTF-8'",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"languageCode",
")",
")",
"{",
"$",
"languageCode",
"=",
"trim",
"(",
"$",
"languageCode",
")",
";",
"}",
"/*\n * Language code not provided?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"languageCode",
")",
")",
"{",
"return",
"''",
";",
"}",
"/*\n * Country code not provided?\n * Let's use language code\n */",
"if",
"(",
"empty",
"(",
"$",
"countryCode",
")",
")",
"{",
"$",
"countryCode",
"=",
"$",
"languageCode",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"encoding",
")",
")",
"{",
"$",
"encoding",
"=",
"sprintf",
"(",
"'.%s'",
",",
"$",
"encoding",
")",
";",
"}",
"return",
"sprintf",
"(",
"'%s_%s%s'",
",",
"$",
"languageCode",
",",
"strtoupper",
"(",
"$",
"countryCode",
")",
",",
"$",
"encoding",
")",
";",
"}"
] | Returns long form of the locale
@param string $languageCode Language code, in ISO 639-1 format. Short form of the locale, e.g. "fr".
@param string $countryCode (optional) Country code, in ISO 3166-1 alpha-2 format, e.g. "FR"
@param string $encoding (optional) Encoding of the final locale
@return string
Example:
- language code: fr
- country code: ''
- result: fr_FR | [
"Returns",
"long",
"form",
"of",
"the",
"locale"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Locale.php#L98-L125 |
37,388 | CeusMedia/Common | src/UI/HTML/ListItem.php | UI_HTML_ListItem.render | public function render()
{
$content = $this->renderInner( $this->content );
return UI_HTML_Tag::create( "li", $content, $this->getAttributes() );
} | php | public function render()
{
$content = $this->renderInner( $this->content );
return UI_HTML_Tag::create( "li", $content, $this->getAttributes() );
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"renderInner",
"(",
"$",
"this",
"->",
"content",
")",
";",
"return",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"li\"",
",",
"$",
"content",
",",
"$",
"this",
"->",
"getAttributes",
"(",
")",
")",
";",
"}"
] | Returns rendered List Item Element.
@access public
@return string | [
"Returns",
"rendered",
"List",
"Item",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/ListItem.php#L61-L65 |
37,389 | CeusMedia/Common | src/FS/File/PHP/Check/MethodVisibility.php | FS_File_PHP_Check_MethodVisibility.check | public function check()
{
$this->checked = TRUE;
$this->methods = array();
$matches = array();
$content = FS_File_Reader::load( $this->fileName );
if( preg_match( "@class @i", $content ) )
if( preg_match_all( "@\tfunction (& *)?([a-z][a-z0-9]+)@i", $content, $matches ) )
foreach( $matches[2] as $match )
$this->methods[] = $match;
return empty( $this->methods );
} | php | public function check()
{
$this->checked = TRUE;
$this->methods = array();
$matches = array();
$content = FS_File_Reader::load( $this->fileName );
if( preg_match( "@class @i", $content ) )
if( preg_match_all( "@\tfunction (& *)?([a-z][a-z0-9]+)@i", $content, $matches ) )
foreach( $matches[2] as $match )
$this->methods[] = $match;
return empty( $this->methods );
} | [
"public",
"function",
"check",
"(",
")",
"{",
"$",
"this",
"->",
"checked",
"=",
"TRUE",
";",
"$",
"this",
"->",
"methods",
"=",
"array",
"(",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"$",
"content",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"if",
"(",
"preg_match",
"(",
"\"@class @i\"",
",",
"$",
"content",
")",
")",
"if",
"(",
"preg_match_all",
"(",
"\"@\\tfunction (& *)?([a-z][a-z0-9]+)@i\"",
",",
"$",
"content",
",",
"$",
"matches",
")",
")",
"foreach",
"(",
"$",
"matches",
"[",
"2",
"]",
"as",
"$",
"match",
")",
"$",
"this",
"->",
"methods",
"[",
"]",
"=",
"$",
"match",
";",
"return",
"empty",
"(",
"$",
"this",
"->",
"methods",
")",
";",
"}"
] | Indicates whether all methods have a defined visibility.
@access public
@return bool | [
"Indicates",
"whether",
"all",
"methods",
"have",
"a",
"defined",
"visibility",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Check/MethodVisibility.php#L66-L77 |
37,390 | CeusMedia/Common | src/CLI/Shell.php | CLI_Shell.isImmediate | protected function isImmediate( $line )
{
$code = "";
$sq = $dq = false;
for( $i = 0; $i < strlen( $line ); $i++ )
{
$c = $line{$i};
if( $c == "'" )
$sq = !$sq;
else if( $c == '"')
$dq = !$dq;
else if( ( $sq ) ||( $dq ) )
{
if( $c == "\\" )
$i++;
}
else
$code .= $c;
}
$code = str_replace( $this->okeq, "", $code );
if( strcspn( $code, ";{=" ) != strlen( $code ) )
return false;
$kw = split( "[^A-Za-z0-9_]", $code );
foreach( $kw as $i )
if( in_array( $i, $this->skip ) )
return false;
return true;
} | php | protected function isImmediate( $line )
{
$code = "";
$sq = $dq = false;
for( $i = 0; $i < strlen( $line ); $i++ )
{
$c = $line{$i};
if( $c == "'" )
$sq = !$sq;
else if( $c == '"')
$dq = !$dq;
else if( ( $sq ) ||( $dq ) )
{
if( $c == "\\" )
$i++;
}
else
$code .= $c;
}
$code = str_replace( $this->okeq, "", $code );
if( strcspn( $code, ";{=" ) != strlen( $code ) )
return false;
$kw = split( "[^A-Za-z0-9_]", $code );
foreach( $kw as $i )
if( in_array( $i, $this->skip ) )
return false;
return true;
} | [
"protected",
"function",
"isImmediate",
"(",
"$",
"line",
")",
"{",
"$",
"code",
"=",
"\"\"",
";",
"$",
"sq",
"=",
"$",
"dq",
"=",
"false",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"line",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"c",
"=",
"$",
"line",
"{",
"$",
"i",
"}",
";",
"if",
"(",
"$",
"c",
"==",
"\"'\"",
")",
"$",
"sq",
"=",
"!",
"$",
"sq",
";",
"else",
"if",
"(",
"$",
"c",
"==",
"'\"'",
")",
"$",
"dq",
"=",
"!",
"$",
"dq",
";",
"else",
"if",
"(",
"(",
"$",
"sq",
")",
"||",
"(",
"$",
"dq",
")",
")",
"{",
"if",
"(",
"$",
"c",
"==",
"\"\\\\\"",
")",
"$",
"i",
"++",
";",
"}",
"else",
"$",
"code",
".=",
"$",
"c",
";",
"}",
"$",
"code",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"okeq",
",",
"\"\"",
",",
"$",
"code",
")",
";",
"if",
"(",
"strcspn",
"(",
"$",
"code",
",",
"\";{=\"",
")",
"!=",
"strlen",
"(",
"$",
"code",
")",
")",
"return",
"false",
";",
"$",
"kw",
"=",
"split",
"(",
"\"[^A-Za-z0-9_]\"",
",",
"$",
"code",
")",
";",
"foreach",
"(",
"$",
"kw",
"as",
"$",
"i",
")",
"if",
"(",
"in_array",
"(",
"$",
"i",
",",
"$",
"this",
"->",
"skip",
")",
")",
"return",
"false",
";",
"return",
"true",
";",
"}"
] | Indicates whether a line is immediate executable like equations.
@access protected
@return void | [
"Indicates",
"whether",
"a",
"line",
"is",
"immediate",
"executable",
"like",
"equations",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Shell.php#L104-L131 |
37,391 | CeusMedia/Common | src/CLI/Shell.php | CLI_Shell.run | protected function run()
{
fputs( STDOUT, ":> " );
while( $line = $this->readLine() )
{
$line = preg_replace( "/\n*|\r*/", "", $line );
$line = preg_replace( "/;$/", "", $line );
if( strlen( $line ) )
{
if( $this->isImmediate( $line ) )
$line = "return( ".$line." )";
ob_start();
$ret = eval( "unset(\$line); $line;" );
if( ob_get_length() == 0)
{
if( is_bool( $ret ) )
echo( $ret ? "true" : "false" );
else if( is_string( $ret ) )
echo "'" . addcslashes( $ret, "\0..\37\177..\377" ) . "'";
else if( !is_null( $ret ) )
print_r( $ret );
}
unset($ret);
$out = ob_get_contents();
ob_end_clean();
if( ( strlen( $out ) > 0) && ( substr( $out, -1 ) != "\n" ) )
$out .= "\n";
fputs( STDOUT, "=> ".$out );
unset( $out );
fputs( STDOUT, ":> " );
}
}
} | php | protected function run()
{
fputs( STDOUT, ":> " );
while( $line = $this->readLine() )
{
$line = preg_replace( "/\n*|\r*/", "", $line );
$line = preg_replace( "/;$/", "", $line );
if( strlen( $line ) )
{
if( $this->isImmediate( $line ) )
$line = "return( ".$line." )";
ob_start();
$ret = eval( "unset(\$line); $line;" );
if( ob_get_length() == 0)
{
if( is_bool( $ret ) )
echo( $ret ? "true" : "false" );
else if( is_string( $ret ) )
echo "'" . addcslashes( $ret, "\0..\37\177..\377" ) . "'";
else if( !is_null( $ret ) )
print_r( $ret );
}
unset($ret);
$out = ob_get_contents();
ob_end_clean();
if( ( strlen( $out ) > 0) && ( substr( $out, -1 ) != "\n" ) )
$out .= "\n";
fputs( STDOUT, "=> ".$out );
unset( $out );
fputs( STDOUT, ":> " );
}
}
} | [
"protected",
"function",
"run",
"(",
")",
"{",
"fputs",
"(",
"STDOUT",
",",
"\":> \"",
")",
";",
"while",
"(",
"$",
"line",
"=",
"$",
"this",
"->",
"readLine",
"(",
")",
")",
"{",
"$",
"line",
"=",
"preg_replace",
"(",
"\"/\\n*|\\r*/\"",
",",
"\"\"",
",",
"$",
"line",
")",
";",
"$",
"line",
"=",
"preg_replace",
"(",
"\"/;$/\"",
",",
"\"\"",
",",
"$",
"line",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"line",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isImmediate",
"(",
"$",
"line",
")",
")",
"$",
"line",
"=",
"\"return( \"",
".",
"$",
"line",
".",
"\" )\"",
";",
"ob_start",
"(",
")",
";",
"$",
"ret",
"=",
"eval",
"(",
"\"unset(\\$line); $line;\"",
")",
";",
"if",
"(",
"ob_get_length",
"(",
")",
"==",
"0",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"ret",
")",
")",
"echo",
"(",
"$",
"ret",
"?",
"\"true\"",
":",
"\"false\"",
")",
";",
"else",
"if",
"(",
"is_string",
"(",
"$",
"ret",
")",
")",
"echo",
"\"'\"",
".",
"addcslashes",
"(",
"$",
"ret",
",",
"\"\\0..\\37\\177..\\377\"",
")",
".",
"\"'\"",
";",
"else",
"if",
"(",
"!",
"is_null",
"(",
"$",
"ret",
")",
")",
"print_r",
"(",
"$",
"ret",
")",
";",
"}",
"unset",
"(",
"$",
"ret",
")",
";",
"$",
"out",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"if",
"(",
"(",
"strlen",
"(",
"$",
"out",
")",
">",
"0",
")",
"&&",
"(",
"substr",
"(",
"$",
"out",
",",
"-",
"1",
")",
"!=",
"\"\\n\"",
")",
")",
"$",
"out",
".=",
"\"\\n\"",
";",
"fputs",
"(",
"STDOUT",
",",
"\"=> \"",
".",
"$",
"out",
")",
";",
"unset",
"(",
"$",
"out",
")",
";",
"fputs",
"(",
"STDOUT",
",",
"\":> \"",
")",
";",
"}",
"}",
"}"
] | Reads input lines from console and prints out the answer.
@access protected
@return void | [
"Reads",
"input",
"lines",
"from",
"console",
"and",
"prints",
"out",
"the",
"answer",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Shell.php#L149-L181 |
37,392 | CeusMedia/Common | src/XML/DOM/PEAR/PackageReader.php | XML_DOM_PEAR_PackageReader.getPackageDataFromXmlFile | public function getPackageDataFromXmlFile( $fileName )
{
$package = array(
'name' => NULL,
'summary' => NULL,
'description' => NULL,
'maintainers' => array(),
'release' => array(),
'changes' => array(),
);
$xml = FS_File_Reader::load( $fileName );
$doc = new DOMDocument();
$doc->preserveWhiteSpace = FALSE;
$doc->validateOnParse = !TRUE;
$doc->loadXml( $xml );
foreach( $doc->childNodes as $node )
{
if( $node->nodeType == 1 )
{
$root = $node;
break;
}
}
if( !$root )
throw Exception( 'No root node found.' );
foreach( $root->childNodes as $node )
{
$nodeName = strToLower( $node->nodeName );
switch( $nodeName )
{
case 'maintainers':
foreach( $node->childNodes as $maintainer )
$package['maintainers'][] = $this->readMaintainer( $maintainer );
break;
case 'release':
$package['releases'][] = $this->readRelease( $node );
break;
case 'changelog':
foreach( $node->childNodes as $release )
$package['changes'][] = $this->readRelease( $release );
break;
default:
$package[$nodeName] = $this->getNodeValue( $node );
break;
}
}
return $package;
} | php | public function getPackageDataFromXmlFile( $fileName )
{
$package = array(
'name' => NULL,
'summary' => NULL,
'description' => NULL,
'maintainers' => array(),
'release' => array(),
'changes' => array(),
);
$xml = FS_File_Reader::load( $fileName );
$doc = new DOMDocument();
$doc->preserveWhiteSpace = FALSE;
$doc->validateOnParse = !TRUE;
$doc->loadXml( $xml );
foreach( $doc->childNodes as $node )
{
if( $node->nodeType == 1 )
{
$root = $node;
break;
}
}
if( !$root )
throw Exception( 'No root node found.' );
foreach( $root->childNodes as $node )
{
$nodeName = strToLower( $node->nodeName );
switch( $nodeName )
{
case 'maintainers':
foreach( $node->childNodes as $maintainer )
$package['maintainers'][] = $this->readMaintainer( $maintainer );
break;
case 'release':
$package['releases'][] = $this->readRelease( $node );
break;
case 'changelog':
foreach( $node->childNodes as $release )
$package['changes'][] = $this->readRelease( $release );
break;
default:
$package[$nodeName] = $this->getNodeValue( $node );
break;
}
}
return $package;
} | [
"public",
"function",
"getPackageDataFromXmlFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"package",
"=",
"array",
"(",
"'name'",
"=>",
"NULL",
",",
"'summary'",
"=>",
"NULL",
",",
"'description'",
"=>",
"NULL",
",",
"'maintainers'",
"=>",
"array",
"(",
")",
",",
"'release'",
"=>",
"array",
"(",
")",
",",
"'changes'",
"=>",
"array",
"(",
")",
",",
")",
";",
"$",
"xml",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"fileName",
")",
";",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"doc",
"->",
"preserveWhiteSpace",
"=",
"FALSE",
";",
"$",
"doc",
"->",
"validateOnParse",
"=",
"!",
"TRUE",
";",
"$",
"doc",
"->",
"loadXml",
"(",
"$",
"xml",
")",
";",
"foreach",
"(",
"$",
"doc",
"->",
"childNodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"nodeType",
"==",
"1",
")",
"{",
"$",
"root",
"=",
"$",
"node",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"root",
")",
"throw",
"Exception",
"(",
"'No root node found.'",
")",
";",
"foreach",
"(",
"$",
"root",
"->",
"childNodes",
"as",
"$",
"node",
")",
"{",
"$",
"nodeName",
"=",
"strToLower",
"(",
"$",
"node",
"->",
"nodeName",
")",
";",
"switch",
"(",
"$",
"nodeName",
")",
"{",
"case",
"'maintainers'",
":",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"maintainer",
")",
"$",
"package",
"[",
"'maintainers'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"readMaintainer",
"(",
"$",
"maintainer",
")",
";",
"break",
";",
"case",
"'release'",
":",
"$",
"package",
"[",
"'releases'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"readRelease",
"(",
"$",
"node",
")",
";",
"break",
";",
"case",
"'changelog'",
":",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"release",
")",
"$",
"package",
"[",
"'changes'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"readRelease",
"(",
"$",
"release",
")",
";",
"break",
";",
"default",
":",
"$",
"package",
"[",
"$",
"nodeName",
"]",
"=",
"$",
"this",
"->",
"getNodeValue",
"(",
"$",
"node",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"package",
";",
"}"
] | Reads Package XML File and returns found Information as Array.
@access public
@param string $fileName Name of Package XML File
@return array | [
"Reads",
"Package",
"XML",
"File",
"and",
"returns",
"found",
"Information",
"as",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L49-L98 |
37,393 | CeusMedia/Common | src/XML/DOM/PEAR/PackageReader.php | XML_DOM_PEAR_PackageReader.readMaintainer | private function readMaintainer( $domNode )
{
$maintainer = array();
foreach( $domNode->childNodes as $node )
$maintainer[$node->nodeName] = $this->getNodeValue( $node );
return $maintainer;
} | php | private function readMaintainer( $domNode )
{
$maintainer = array();
foreach( $domNode->childNodes as $node )
$maintainer[$node->nodeName] = $this->getNodeValue( $node );
return $maintainer;
} | [
"private",
"function",
"readMaintainer",
"(",
"$",
"domNode",
")",
"{",
"$",
"maintainer",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"domNode",
"->",
"childNodes",
"as",
"$",
"node",
")",
"$",
"maintainer",
"[",
"$",
"node",
"->",
"nodeName",
"]",
"=",
"$",
"this",
"->",
"getNodeValue",
"(",
"$",
"node",
")",
";",
"return",
"$",
"maintainer",
";",
"}"
] | Reads a Maintainer Block and returns an Array.
@access protected
@param DOMNode $domNode DOM Node of Maintainer Block
@return array | [
"Reads",
"a",
"Maintainer",
"Block",
"and",
"returns",
"an",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L106-L112 |
37,394 | CeusMedia/Common | src/XML/DOM/PEAR/PackageReader.php | XML_DOM_PEAR_PackageReader.readRelease | private function readRelease( $domNode )
{
$release = array();
foreach( $domNode->childNodes as $node )
{
$nodeName = $node->nodeName;
switch( $nodeName )
{
case 'deps':
foreach( $node->childNodes as $dep )
$release['dependencies'][] = $this->getNodeValue( $dep );
break;
case 'filelist':
foreach( $node->childNodes as $file )
$release['files'][] = $this->getNodeAttributes( $file );
break;
default:
$release[$nodeName] = $this->getNodeValue( $node );
break;
}
}
return $release;
} | php | private function readRelease( $domNode )
{
$release = array();
foreach( $domNode->childNodes as $node )
{
$nodeName = $node->nodeName;
switch( $nodeName )
{
case 'deps':
foreach( $node->childNodes as $dep )
$release['dependencies'][] = $this->getNodeValue( $dep );
break;
case 'filelist':
foreach( $node->childNodes as $file )
$release['files'][] = $this->getNodeAttributes( $file );
break;
default:
$release[$nodeName] = $this->getNodeValue( $node );
break;
}
}
return $release;
} | [
"private",
"function",
"readRelease",
"(",
"$",
"domNode",
")",
"{",
"$",
"release",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"domNode",
"->",
"childNodes",
"as",
"$",
"node",
")",
"{",
"$",
"nodeName",
"=",
"$",
"node",
"->",
"nodeName",
";",
"switch",
"(",
"$",
"nodeName",
")",
"{",
"case",
"'deps'",
":",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"dep",
")",
"$",
"release",
"[",
"'dependencies'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getNodeValue",
"(",
"$",
"dep",
")",
";",
"break",
";",
"case",
"'filelist'",
":",
"foreach",
"(",
"$",
"node",
"->",
"childNodes",
"as",
"$",
"file",
")",
"$",
"release",
"[",
"'files'",
"]",
"[",
"]",
"=",
"$",
"this",
"->",
"getNodeAttributes",
"(",
"$",
"file",
")",
";",
"break",
";",
"default",
":",
"$",
"release",
"[",
"$",
"nodeName",
"]",
"=",
"$",
"this",
"->",
"getNodeValue",
"(",
"$",
"node",
")",
";",
"break",
";",
"}",
"}",
"return",
"$",
"release",
";",
"}"
] | Reads a Release Block and returns an Array.
@access protected
@param DOMNode $domNode DOM Node of Release Block
@return array | [
"Reads",
"a",
"Release",
"Block",
"and",
"returns",
"an",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L120-L142 |
37,395 | CeusMedia/Common | src/XML/DOM/PEAR/PackageReader.php | XML_DOM_PEAR_PackageReader.getNodeAttributes | private function getNodeAttributes( $domNode )
{
$attributes = array();
foreach( $domNode->attributes as $attribute )
$attributes[$attribute->name] = $attribute->value;
return $attributes;
} | php | private function getNodeAttributes( $domNode )
{
$attributes = array();
foreach( $domNode->attributes as $attribute )
$attributes[$attribute->name] = $attribute->value;
return $attributes;
} | [
"private",
"function",
"getNodeAttributes",
"(",
"$",
"domNode",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"domNode",
"->",
"attributes",
"as",
"$",
"attribute",
")",
"$",
"attributes",
"[",
"$",
"attribute",
"->",
"name",
"]",
"=",
"$",
"attribute",
"->",
"value",
";",
"return",
"$",
"attributes",
";",
"}"
] | Returns all Attributes of a DOM Node as Array.
@access protected
@param DOMNode $domNode DOM Node with Attributes
@return array | [
"Returns",
"all",
"Attributes",
"of",
"a",
"DOM",
"Node",
"as",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L150-L156 |
37,396 | CeusMedia/Common | src/XML/DOM/PEAR/PackageReader.php | XML_DOM_PEAR_PackageReader.getNodeValue | private function getNodeValue( $domNode )
{
if( !( $domNode->nodeType == 1 && $domNode->childNodes->length > 0 ) )
return NULL;
return $domNode->childNodes->item(0)->nodeValue;
} | php | private function getNodeValue( $domNode )
{
if( !( $domNode->nodeType == 1 && $domNode->childNodes->length > 0 ) )
return NULL;
return $domNode->childNodes->item(0)->nodeValue;
} | [
"private",
"function",
"getNodeValue",
"(",
"$",
"domNode",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"domNode",
"->",
"nodeType",
"==",
"1",
"&&",
"$",
"domNode",
"->",
"childNodes",
"->",
"length",
">",
"0",
")",
")",
"return",
"NULL",
";",
"return",
"$",
"domNode",
"->",
"childNodes",
"->",
"item",
"(",
"0",
")",
"->",
"nodeValue",
";",
"}"
] | Returns the Text Value of a DOM Node.
@access protected
@param DOMNode $domNode DOM Node with Attributes
@return string | [
"Returns",
"the",
"Text",
"Value",
"of",
"a",
"DOM",
"Node",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/PEAR/PackageReader.php#L164-L169 |
37,397 | CeusMedia/Common | src/XML/DOM/Builder.php | XML_DOM_Builder.build | static public function build( XML_DOM_Node $tree, $encoding = "utf-8", $namespaces = array() )
{
$document = new DOMDocument( "1.0", $encoding );
$document->formatOutput = TRUE;
$root = $document->createElement( $tree->getNodename() );
foreach( $namespaces as $prefix => $namespace )
$root->setAttribute( "xmlns:".$prefix, $namespace );
$root = $document->appendChild( $root );
self::buildRecursive( $document, $root, $tree, $encoding );
return $document->saveXML();
} | php | static public function build( XML_DOM_Node $tree, $encoding = "utf-8", $namespaces = array() )
{
$document = new DOMDocument( "1.0", $encoding );
$document->formatOutput = TRUE;
$root = $document->createElement( $tree->getNodename() );
foreach( $namespaces as $prefix => $namespace )
$root->setAttribute( "xmlns:".$prefix, $namespace );
$root = $document->appendChild( $root );
self::buildRecursive( $document, $root, $tree, $encoding );
return $document->saveXML();
} | [
"static",
"public",
"function",
"build",
"(",
"XML_DOM_Node",
"$",
"tree",
",",
"$",
"encoding",
"=",
"\"utf-8\"",
",",
"$",
"namespaces",
"=",
"array",
"(",
")",
")",
"{",
"$",
"document",
"=",
"new",
"DOMDocument",
"(",
"\"1.0\"",
",",
"$",
"encoding",
")",
";",
"$",
"document",
"->",
"formatOutput",
"=",
"TRUE",
";",
"$",
"root",
"=",
"$",
"document",
"->",
"createElement",
"(",
"$",
"tree",
"->",
"getNodename",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"prefix",
"=>",
"$",
"namespace",
")",
"$",
"root",
"->",
"setAttribute",
"(",
"\"xmlns:\"",
".",
"$",
"prefix",
",",
"$",
"namespace",
")",
";",
"$",
"root",
"=",
"$",
"document",
"->",
"appendChild",
"(",
"$",
"root",
")",
";",
"self",
"::",
"buildRecursive",
"(",
"$",
"document",
",",
"$",
"root",
",",
"$",
"tree",
",",
"$",
"encoding",
")",
";",
"return",
"$",
"document",
"->",
"saveXML",
"(",
")",
";",
"}"
] | Builds XML and returns XML as string.
@static
@access public
@param XML_DOM_Node $tree XML Tree
@param string $encoding Encoding Character Set (utf-8 etc.)
@return string Rendered tree as XML string | [
"Builds",
"XML",
"and",
"returns",
"XML",
"as",
"string",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Builder.php#L48-L58 |
37,398 | CeusMedia/Common | src/XML/DOM/Builder.php | XML_DOM_Builder.buildRecursive | static protected function buildRecursive( DOMDocument $document, DOMElement $root, XML_DOM_Node $tree, $encoding )
{
foreach( $tree->getAttributes() as $key => $value )
{
$root->setAttribute( $key, $value );
}
if( $tree->hasChildren() )
{
$children = $tree->getChildren();
foreach( $children as $child )
{
$element = $document->createElement( $child->getNodename() );
self::buildRecursive( $document, $element, $child, $encoding );
$element = $root->appendChild( $element );
}
}
else if( $tree->hasContent() )
{
$text = (string) $tree->getContent();
$text = $document->createTextNode( $text );
$text = $root->appendChild( $text );
}
} | php | static protected function buildRecursive( DOMDocument $document, DOMElement $root, XML_DOM_Node $tree, $encoding )
{
foreach( $tree->getAttributes() as $key => $value )
{
$root->setAttribute( $key, $value );
}
if( $tree->hasChildren() )
{
$children = $tree->getChildren();
foreach( $children as $child )
{
$element = $document->createElement( $child->getNodename() );
self::buildRecursive( $document, $element, $child, $encoding );
$element = $root->appendChild( $element );
}
}
else if( $tree->hasContent() )
{
$text = (string) $tree->getContent();
$text = $document->createTextNode( $text );
$text = $root->appendChild( $text );
}
} | [
"static",
"protected",
"function",
"buildRecursive",
"(",
"DOMDocument",
"$",
"document",
",",
"DOMElement",
"$",
"root",
",",
"XML_DOM_Node",
"$",
"tree",
",",
"$",
"encoding",
")",
"{",
"foreach",
"(",
"$",
"tree",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"root",
"->",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"tree",
"->",
"hasChildren",
"(",
")",
")",
"{",
"$",
"children",
"=",
"$",
"tree",
"->",
"getChildren",
"(",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"element",
"=",
"$",
"document",
"->",
"createElement",
"(",
"$",
"child",
"->",
"getNodename",
"(",
")",
")",
";",
"self",
"::",
"buildRecursive",
"(",
"$",
"document",
",",
"$",
"element",
",",
"$",
"child",
",",
"$",
"encoding",
")",
";",
"$",
"element",
"=",
"$",
"root",
"->",
"appendChild",
"(",
"$",
"element",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"tree",
"->",
"hasContent",
"(",
")",
")",
"{",
"$",
"text",
"=",
"(",
"string",
")",
"$",
"tree",
"->",
"getContent",
"(",
")",
";",
"$",
"text",
"=",
"$",
"document",
"->",
"createTextNode",
"(",
"$",
"text",
")",
";",
"$",
"text",
"=",
"$",
"root",
"->",
"appendChild",
"(",
"$",
"text",
")",
";",
"}",
"}"
] | Writes XML Tree to XML File recursive.
@static
@access protected
@param DOMElement $document DOM Document
@param DOMElement $root DOM Element
@param XML_DOM_Node $tree Parent XML Node
@param string $encoding Encoding Character Set (utf-8 etc.)
@return void | [
"Writes",
"XML",
"Tree",
"to",
"XML",
"File",
"recursive",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/Builder.php#L70-L92 |
37,399 | CeusMedia/Common | src/UI/HTML/AHAH/Link.php | UI_HTML_AHAH_Link.render | public static function render( $url, $label, $targetId, $class = NULL )
{
$attributes = array(
'href' => "#".$targetId,
'class' => $class,
'onclick' => "ahah('".$url."','".$targetId."');",
);
return UI_HTML_Tag::create( 'a', $label, $attributes );
} | php | public static function render( $url, $label, $targetId, $class = NULL )
{
$attributes = array(
'href' => "#".$targetId,
'class' => $class,
'onclick' => "ahah('".$url."','".$targetId."');",
);
return UI_HTML_Tag::create( 'a', $label, $attributes );
} | [
"public",
"static",
"function",
"render",
"(",
"$",
"url",
",",
"$",
"label",
",",
"$",
"targetId",
",",
"$",
"class",
"=",
"NULL",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
"'href'",
"=>",
"\"#\"",
".",
"$",
"targetId",
",",
"'class'",
"=>",
"$",
"class",
",",
"'onclick'",
"=>",
"\"ahah('\"",
".",
"$",
"url",
".",
"\"','\"",
".",
"$",
"targetId",
".",
"\"');\"",
",",
")",
";",
"return",
"UI_HTML_Tag",
"::",
"create",
"(",
"'a'",
",",
"$",
"label",
",",
"$",
"attributes",
")",
";",
"}"
] | Returns rendered Link Element.
@access public
@param string $url URL of Page to load
@param string $label Link Label
@param string $targetId ID of Fragment in Page
@param string $class Class Attribute
@return string | [
"Returns",
"rendered",
"Link",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/AHAH/Link.php#L49-L57 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.