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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36,500 | CeusMedia/Common | src/Net/Site/Crawler.php | Net_Site_Crawler.getHTML | protected function getHTML( $url )
{
$this->reader->setUrl( $url );
try
{
$content = $this->reader->read( array(
'CURLOPT_FOLLOWLOCATION' => TRUE,
'CURLOPT_COOKIEJAR' => 'cookies.txt',
'CURLOPT_COOKIEFILE' => 'cookies.txt'
) );
$contentType = $this->reader->getInfo( 'content_type' );
return $contentType === 'text/html' ? $content : '';
}
catch( RuntimeException $e )
{
$this->errors[$url] = $e->getMessage();
throw $e;
}
} | php | protected function getHTML( $url )
{
$this->reader->setUrl( $url );
try
{
$content = $this->reader->read( array(
'CURLOPT_FOLLOWLOCATION' => TRUE,
'CURLOPT_COOKIEJAR' => 'cookies.txt',
'CURLOPT_COOKIEFILE' => 'cookies.txt'
) );
$contentType = $this->reader->getInfo( 'content_type' );
return $contentType === 'text/html' ? $content : '';
}
catch( RuntimeException $e )
{
$this->errors[$url] = $e->getMessage();
throw $e;
}
} | [
"protected",
"function",
"getHTML",
"(",
"$",
"url",
")",
"{",
"$",
"this",
"->",
"reader",
"->",
"setUrl",
"(",
"$",
"url",
")",
";",
"try",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"reader",
"->",
"read",
"(",
"array",
"(",
"'CURLOPT_FOLLOWLOCATION'",
"=>",
"TRUE",
",",
"'CURLOPT_COOKIEJAR'",
"=>",
"'cookies.txt'",
",",
"'CURLOPT_COOKIEFILE'",
"=>",
"'cookies.txt'",
")",
")",
";",
"$",
"contentType",
"=",
"$",
"this",
"->",
"reader",
"->",
"getInfo",
"(",
"'content_type'",
")",
";",
"return",
"$",
"contentType",
"===",
"'text/html'",
"?",
"$",
"content",
":",
"''",
";",
"}",
"catch",
"(",
"RuntimeException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"errors",
"[",
"$",
"url",
"]",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
] | Reads HTML Page and returns Content or logs Errors and throws Exception.
@access public
@param string $url URL to get Content for
@return string | [
"Reads",
"HTML",
"Page",
"and",
"returns",
"Content",
"or",
"logs",
"Errors",
"and",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/Crawler.php#L255-L273 |
36,501 | CeusMedia/Common | src/Net/Site/Crawler.php | Net_Site_Crawler.getLinksFromDocument | protected function getLinksFromDocument( $document, $onlyWithLabel = FALSE )
{
$baseUrl = $this->getBaseUrl( $document );
$links = array();
$nodes = $document->getElementsByTagName( "a" );
foreach( $nodes as $node )
{
$ref = $node->getAttribute( 'href' );
$ref = trim( preg_replace( "@^\./@", "", $ref ) );
if( strlen( $ref ) ){
$base = $document->getElementsByTagName( "base" );
// remark( $ref );
if( preg_match( "@^(#|mailto:|javascript:)@", $ref ) )
continue;
if( $base->length && preg_match( "@^\.\./@", $ref ) )
continue;
if( preg_match( "@^\.?/@", $ref ) )
$ref = $baseUrl.$ref;
else if( preg_match( "@^\./@", $ref ) )
$ref = preg_replace( "@^\./@", "", $ref );
if( !preg_match( "@^https?://@", $ref ) )
$ref = $baseUrl.$ref;
$label = trim( strip_tags( $node->nodeValue ) );
if( $node->hasAttribute( 'title' ) )
$label = trim( strip_tags( $node->getAttribute( 'title' ) ) );
if( $onlyWithLabel && !strlen( $label ) )
continue;
$links[$ref] = $label;
}
}
return $links;
} | php | protected function getLinksFromDocument( $document, $onlyWithLabel = FALSE )
{
$baseUrl = $this->getBaseUrl( $document );
$links = array();
$nodes = $document->getElementsByTagName( "a" );
foreach( $nodes as $node )
{
$ref = $node->getAttribute( 'href' );
$ref = trim( preg_replace( "@^\./@", "", $ref ) );
if( strlen( $ref ) ){
$base = $document->getElementsByTagName( "base" );
// remark( $ref );
if( preg_match( "@^(#|mailto:|javascript:)@", $ref ) )
continue;
if( $base->length && preg_match( "@^\.\./@", $ref ) )
continue;
if( preg_match( "@^\.?/@", $ref ) )
$ref = $baseUrl.$ref;
else if( preg_match( "@^\./@", $ref ) )
$ref = preg_replace( "@^\./@", "", $ref );
if( !preg_match( "@^https?://@", $ref ) )
$ref = $baseUrl.$ref;
$label = trim( strip_tags( $node->nodeValue ) );
if( $node->hasAttribute( 'title' ) )
$label = trim( strip_tags( $node->getAttribute( 'title' ) ) );
if( $onlyWithLabel && !strlen( $label ) )
continue;
$links[$ref] = $label;
}
}
return $links;
} | [
"protected",
"function",
"getLinksFromDocument",
"(",
"$",
"document",
",",
"$",
"onlyWithLabel",
"=",
"FALSE",
")",
"{",
"$",
"baseUrl",
"=",
"$",
"this",
"->",
"getBaseUrl",
"(",
"$",
"document",
")",
";",
"$",
"links",
"=",
"array",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"document",
"->",
"getElementsByTagName",
"(",
"\"a\"",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"ref",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"'href'",
")",
";",
"$",
"ref",
"=",
"trim",
"(",
"preg_replace",
"(",
"\"@^\\./@\"",
",",
"\"\"",
",",
"$",
"ref",
")",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"ref",
")",
")",
"{",
"$",
"base",
"=",
"$",
"document",
"->",
"getElementsByTagName",
"(",
"\"base\"",
")",
";",
"//\t\t\tremark( $ref );\r",
"if",
"(",
"preg_match",
"(",
"\"@^(#|mailto:|javascript:)@\"",
",",
"$",
"ref",
")",
")",
"continue",
";",
"if",
"(",
"$",
"base",
"->",
"length",
"&&",
"preg_match",
"(",
"\"@^\\.\\./@\"",
",",
"$",
"ref",
")",
")",
"continue",
";",
"if",
"(",
"preg_match",
"(",
"\"@^\\.?/@\"",
",",
"$",
"ref",
")",
")",
"$",
"ref",
"=",
"$",
"baseUrl",
".",
"$",
"ref",
";",
"else",
"if",
"(",
"preg_match",
"(",
"\"@^\\./@\"",
",",
"$",
"ref",
")",
")",
"$",
"ref",
"=",
"preg_replace",
"(",
"\"@^\\./@\"",
",",
"\"\"",
",",
"$",
"ref",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"@^https?://@\"",
",",
"$",
"ref",
")",
")",
"$",
"ref",
"=",
"$",
"baseUrl",
".",
"$",
"ref",
";",
"$",
"label",
"=",
"trim",
"(",
"strip_tags",
"(",
"$",
"node",
"->",
"nodeValue",
")",
")",
";",
"if",
"(",
"$",
"node",
"->",
"hasAttribute",
"(",
"'title'",
")",
")",
"$",
"label",
"=",
"trim",
"(",
"strip_tags",
"(",
"$",
"node",
"->",
"getAttribute",
"(",
"'title'",
")",
")",
")",
";",
"if",
"(",
"$",
"onlyWithLabel",
"&&",
"!",
"strlen",
"(",
"$",
"label",
")",
")",
"continue",
";",
"$",
"links",
"[",
"$",
"ref",
"]",
"=",
"$",
"label",
";",
"}",
"}",
"return",
"$",
"links",
";",
"}"
] | Parses a HTML Document and returns extracted Link URLs.
@access protected
@param DOMDocument $document DOM Document of HTML Content
@param boolean $onlyWithLabel Flag: note only links with label
@return array | [
"Parses",
"a",
"HTML",
"Document",
"and",
"returns",
"extracted",
"Link",
"URLs",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/Crawler.php#L294-L325 |
36,502 | CeusMedia/Common | src/Alg/Math/Analysis/Sequence.php | Alg_Math_Analysis_Sequence.isConvergent | public function isConvergent()
{
for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++)
{
$diff = abs ($this->getValue ($i+1) - $this->getValue ($i));
if (!$old_diff) $old_diff = $diff;
else
{
if ($diff >= $old_diff)
return false;
}
}
return true;
} | php | public function isConvergent()
{
for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++)
{
$diff = abs ($this->getValue ($i+1) - $this->getValue ($i));
if (!$old_diff) $old_diff = $diff;
else
{
if ($diff >= $old_diff)
return false;
}
}
return true;
} | [
"public",
"function",
"isConvergent",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"interval",
"->",
"getStart",
"(",
")",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"interval",
"->",
"getEnd",
"(",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"diff",
"=",
"abs",
"(",
"$",
"this",
"->",
"getValue",
"(",
"$",
"i",
"+",
"1",
")",
"-",
"$",
"this",
"->",
"getValue",
"(",
"$",
"i",
")",
")",
";",
"if",
"(",
"!",
"$",
"old_diff",
")",
"$",
"old_diff",
"=",
"$",
"diff",
";",
"else",
"{",
"if",
"(",
"$",
"diff",
">=",
"$",
"old_diff",
")",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Indicates whether this Sequence is convergent.
@access public
@return bool | [
"Indicates",
"whether",
"this",
"Sequence",
"is",
"convergent",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Sequence.php#L92-L105 |
36,503 | CeusMedia/Common | src/Alg/Math/Analysis/Sequence.php | Alg_Math_Analysis_Sequence.toArray | public function toArray()
{
$array = array ();
for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++)
{
$value = $this->getValue ($i);
$array [$i] = $value;
}
return $array;
} | php | public function toArray()
{
$array = array ();
for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++)
{
$value = $this->getValue ($i);
$array [$i] = $value;
}
return $array;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"array",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"interval",
"->",
"getStart",
"(",
")",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"interval",
"->",
"getEnd",
"(",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"i",
")",
";",
"$",
"array",
"[",
"$",
"i",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"array",
";",
"}"
] | Returns Sequence as Array.
@access public
@return array | [
"Returns",
"Sequence",
"as",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Sequence.php#L122-L131 |
36,504 | CeusMedia/Common | src/XML/DOM/ObjectDeserializer.php | XML_DOM_ObjectDeserializer.deserialize | public static function deserialize( $xml, $strict = TRUE )
{
$parser = new XML_DOM_Parser();
$tree = $parser->parse( $xml );
$class = $tree->getAttribute( 'class' );
if( !class_exists( $class ) )
throw new Exception( 'Class "'.$class.'" has not been loaded, yet.' );
$object = new $class();
self::deserializeVarsRec( $tree->getChildren(), $object );
return $object;
} | php | public static function deserialize( $xml, $strict = TRUE )
{
$parser = new XML_DOM_Parser();
$tree = $parser->parse( $xml );
$class = $tree->getAttribute( 'class' );
if( !class_exists( $class ) )
throw new Exception( 'Class "'.$class.'" has not been loaded, yet.' );
$object = new $class();
self::deserializeVarsRec( $tree->getChildren(), $object );
return $object;
} | [
"public",
"static",
"function",
"deserialize",
"(",
"$",
"xml",
",",
"$",
"strict",
"=",
"TRUE",
")",
"{",
"$",
"parser",
"=",
"new",
"XML_DOM_Parser",
"(",
")",
";",
"$",
"tree",
"=",
"$",
"parser",
"->",
"parse",
"(",
"$",
"xml",
")",
";",
"$",
"class",
"=",
"$",
"tree",
"->",
"getAttribute",
"(",
"'class'",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Class \"'",
".",
"$",
"class",
".",
"'\" has not been loaded, yet.'",
")",
";",
"$",
"object",
"=",
"new",
"$",
"class",
"(",
")",
";",
"self",
"::",
"deserializeVarsRec",
"(",
"$",
"tree",
"->",
"getChildren",
"(",
")",
",",
"$",
"object",
")",
";",
"return",
"$",
"object",
";",
"}"
] | Builds Object from XML of a serialized Object.
@access public
@param string $xml XML String of a serialized Object
@return mixed | [
"Builds",
"Object",
"from",
"XML",
"of",
"a",
"serialized",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectDeserializer.php#L50-L60 |
36,505 | CeusMedia/Common | src/XML/DOM/ObjectDeserializer.php | XML_DOM_ObjectDeserializer.deserializeVarsRec | protected static function deserializeVarsRec( $children, &$element )
{
foreach( $children as $child )
{
$name = $child->getAttribute( 'name' );
$vartype = $child->getNodeName();
if( is_object( $element ) )
{
if( !isset( $element->$name ) )
$element->$name = NULL;
$pointer =& $element->$name;
}
else
{
if( !isset( $element->$name ) )
$element[$name] = NULL;
$pointer =& $element[$name];
}
switch( $vartype )
{
case 'boolean':
$pointer = (bool) $child->getContent();
break;
case 'string':
$pointer = utf8_decode( $child->getContent() );
break;
case 'integer':
$pointer = (int) $child->getContent();
break;
case 'double':
$pointer = (double) $child->getContent();
break;
case 'array':
$pointer = array();
self::deserializeVarsRec( $child->getChildren(), $pointer );
break;
case 'object':
$class = $child->getAttribute( 'class' );
$pointer = new $class();
self::deserializeVarsRec( $child->getChildren(), $pointer );
break;
default:
$pointer = NULL;
break;
}
}
} | php | protected static function deserializeVarsRec( $children, &$element )
{
foreach( $children as $child )
{
$name = $child->getAttribute( 'name' );
$vartype = $child->getNodeName();
if( is_object( $element ) )
{
if( !isset( $element->$name ) )
$element->$name = NULL;
$pointer =& $element->$name;
}
else
{
if( !isset( $element->$name ) )
$element[$name] = NULL;
$pointer =& $element[$name];
}
switch( $vartype )
{
case 'boolean':
$pointer = (bool) $child->getContent();
break;
case 'string':
$pointer = utf8_decode( $child->getContent() );
break;
case 'integer':
$pointer = (int) $child->getContent();
break;
case 'double':
$pointer = (double) $child->getContent();
break;
case 'array':
$pointer = array();
self::deserializeVarsRec( $child->getChildren(), $pointer );
break;
case 'object':
$class = $child->getAttribute( 'class' );
$pointer = new $class();
self::deserializeVarsRec( $child->getChildren(), $pointer );
break;
default:
$pointer = NULL;
break;
}
}
} | [
"protected",
"static",
"function",
"deserializeVarsRec",
"(",
"$",
"children",
",",
"&",
"$",
"element",
")",
"{",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"name",
"=",
"$",
"child",
"->",
"getAttribute",
"(",
"'name'",
")",
";",
"$",
"vartype",
"=",
"$",
"child",
"->",
"getNodeName",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"element",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"element",
"->",
"$",
"name",
")",
")",
"$",
"element",
"->",
"$",
"name",
"=",
"NULL",
";",
"$",
"pointer",
"=",
"&",
"$",
"element",
"->",
"$",
"name",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"element",
"->",
"$",
"name",
")",
")",
"$",
"element",
"[",
"$",
"name",
"]",
"=",
"NULL",
";",
"$",
"pointer",
"=",
"&",
"$",
"element",
"[",
"$",
"name",
"]",
";",
"}",
"switch",
"(",
"$",
"vartype",
")",
"{",
"case",
"'boolean'",
":",
"$",
"pointer",
"=",
"(",
"bool",
")",
"$",
"child",
"->",
"getContent",
"(",
")",
";",
"break",
";",
"case",
"'string'",
":",
"$",
"pointer",
"=",
"utf8_decode",
"(",
"$",
"child",
"->",
"getContent",
"(",
")",
")",
";",
"break",
";",
"case",
"'integer'",
":",
"$",
"pointer",
"=",
"(",
"int",
")",
"$",
"child",
"->",
"getContent",
"(",
")",
";",
"break",
";",
"case",
"'double'",
":",
"$",
"pointer",
"=",
"(",
"double",
")",
"$",
"child",
"->",
"getContent",
"(",
")",
";",
"break",
";",
"case",
"'array'",
":",
"$",
"pointer",
"=",
"array",
"(",
")",
";",
"self",
"::",
"deserializeVarsRec",
"(",
"$",
"child",
"->",
"getChildren",
"(",
")",
",",
"$",
"pointer",
")",
";",
"break",
";",
"case",
"'object'",
":",
"$",
"class",
"=",
"$",
"child",
"->",
"getAttribute",
"(",
"'class'",
")",
";",
"$",
"pointer",
"=",
"new",
"$",
"class",
"(",
")",
";",
"self",
"::",
"deserializeVarsRec",
"(",
"$",
"child",
"->",
"getChildren",
"(",
")",
",",
"$",
"pointer",
")",
";",
"break",
";",
"default",
":",
"$",
"pointer",
"=",
"NULL",
";",
"break",
";",
"}",
"}",
"}"
] | Adds nested Vars to an Element by their Type while supporting nested Arrays.
@access protected
@param array $children Array of Vars to add
@param mixed $element current Position in Object
@return string | [
"Adds",
"nested",
"Vars",
"to",
"an",
"Element",
"by",
"their",
"Type",
"while",
"supporting",
"nested",
"Arrays",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectDeserializer.php#L69-L116 |
36,506 | CeusMedia/Common | src/XML/DOM/FileEditor.php | XML_DOM_FileEditor.addNode | public function addNode( $nodePath, $name, $content = "", $attributes = array() )
{
$branch = $this->getNode( $nodePath );
$node = new XML_DOM_Node( $name, $content, $attributes );
$branch->addChild( $node );
return (bool) $this->write();
} | php | public function addNode( $nodePath, $name, $content = "", $attributes = array() )
{
$branch = $this->getNode( $nodePath );
$node = new XML_DOM_Node( $name, $content, $attributes );
$branch->addChild( $node );
return (bool) $this->write();
} | [
"public",
"function",
"addNode",
"(",
"$",
"nodePath",
",",
"$",
"name",
",",
"$",
"content",
"=",
"\"\"",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"branch",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"nodePath",
")",
";",
"$",
"node",
"=",
"new",
"XML_DOM_Node",
"(",
"$",
"name",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"$",
"branch",
"->",
"addChild",
"(",
"$",
"node",
")",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}"
] | Adds a new Node Attribute to an existing Node.
@access public
@param string $nodePath Path to existring Node in XML Tree
@param string $name Name of new Node
@param string $content Cotnent of new Node
@param array $attributes Array of Attribute of new Content
@return bool | [
"Adds",
"a",
"new",
"Node",
"Attribute",
"to",
"an",
"existing",
"Node",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L71-L77 |
36,507 | CeusMedia/Common | src/XML/DOM/FileEditor.php | XML_DOM_FileEditor.editNodeAttribute | public function editNodeAttribute( $nodePath, $key, $value )
{
$node = $this->getNode( $nodePath );
if( $node->setAttribute( $key, $value ) )
return (bool) $this->write();
return FALSE;
} | php | public function editNodeAttribute( $nodePath, $key, $value )
{
$node = $this->getNode( $nodePath );
if( $node->setAttribute( $key, $value ) )
return (bool) $this->write();
return FALSE;
} | [
"public",
"function",
"editNodeAttribute",
"(",
"$",
"nodePath",
",",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"nodePath",
")",
";",
"if",
"(",
"$",
"node",
"->",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
")",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"write",
"(",
")",
";",
"return",
"FALSE",
";",
"}"
] | Modifies a Node Attribute by its Path and Attribute Key.
@access public
@param string $nodePath Path to Node in XML Tree
@param string $key Attribute Key
@return bool | [
"Modifies",
"a",
"Node",
"Attribute",
"by",
"its",
"Path",
"and",
"Attribute",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L86-L92 |
36,508 | CeusMedia/Common | src/XML/DOM/FileEditor.php | XML_DOM_FileEditor.editNodeContent | public function editNodeContent( $nodePath, $content )
{
$node = $this->getNode( $nodePath );
if( $node->setContent( $content ) )
return (bool) $this->write();
return FALSE;
} | php | public function editNodeContent( $nodePath, $content )
{
$node = $this->getNode( $nodePath );
if( $node->setContent( $content ) )
return (bool) $this->write();
return FALSE;
} | [
"public",
"function",
"editNodeContent",
"(",
"$",
"nodePath",
",",
"$",
"content",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"nodePath",
")",
";",
"if",
"(",
"$",
"node",
"->",
"setContent",
"(",
"$",
"content",
")",
")",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"write",
"(",
")",
";",
"return",
"FALSE",
";",
"}"
] | Modifies a Node Content by its Path.
@access public
@param string $nodePath Path to Node in XML Tree
@param string $content Content to set to Node
@return bool | [
"Modifies",
"a",
"Node",
"Content",
"by",
"its",
"Path",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L101-L107 |
36,509 | CeusMedia/Common | src/XML/DOM/FileEditor.php | XML_DOM_FileEditor.getNode | protected function getNode( $nodePath )
{
$pathNodes = explode( "/", $nodePath );
$xmlNode =& $this->xmlTree;
while( $pathNodes )
{
$pathNode = trim( array_shift( $pathNodes ) );
$matches = array();
if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $pathNode, $matches ) )
{
$pathNode = $matches[1][0];
$itemNumber = $matches[2][0];
$nodes = $xmlNode->getChildren( $pathNode );
if( !isset( $nodes[$itemNumber] ) )
throw new InvalidArgumentException( 'Node not existing.' );
$xmlNode =& $nodes[$itemNumber];
continue;
}
$xmlNode =& $xmlNode->getChild( $pathNode );
continue;
}
return $xmlNode;
} | php | protected function getNode( $nodePath )
{
$pathNodes = explode( "/", $nodePath );
$xmlNode =& $this->xmlTree;
while( $pathNodes )
{
$pathNode = trim( array_shift( $pathNodes ) );
$matches = array();
if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $pathNode, $matches ) )
{
$pathNode = $matches[1][0];
$itemNumber = $matches[2][0];
$nodes = $xmlNode->getChildren( $pathNode );
if( !isset( $nodes[$itemNumber] ) )
throw new InvalidArgumentException( 'Node not existing.' );
$xmlNode =& $nodes[$itemNumber];
continue;
}
$xmlNode =& $xmlNode->getChild( $pathNode );
continue;
}
return $xmlNode;
} | [
"protected",
"function",
"getNode",
"(",
"$",
"nodePath",
")",
"{",
"$",
"pathNodes",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"nodePath",
")",
";",
"$",
"xmlNode",
"=",
"&",
"$",
"this",
"->",
"xmlTree",
";",
"while",
"(",
"$",
"pathNodes",
")",
"{",
"$",
"pathNode",
"=",
"trim",
"(",
"array_shift",
"(",
"$",
"pathNodes",
")",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"\"@^(.*)\\[([0-9]+)\\]$@\"",
",",
"$",
"pathNode",
",",
"$",
"matches",
")",
")",
"{",
"$",
"pathNode",
"=",
"$",
"matches",
"[",
"1",
"]",
"[",
"0",
"]",
";",
"$",
"itemNumber",
"=",
"$",
"matches",
"[",
"2",
"]",
"[",
"0",
"]",
";",
"$",
"nodes",
"=",
"$",
"xmlNode",
"->",
"getChildren",
"(",
"$",
"pathNode",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"nodes",
"[",
"$",
"itemNumber",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Node not existing.'",
")",
";",
"$",
"xmlNode",
"=",
"&",
"$",
"nodes",
"[",
"$",
"itemNumber",
"]",
";",
"continue",
";",
"}",
"$",
"xmlNode",
"=",
"&",
"$",
"xmlNode",
"->",
"getChild",
"(",
"$",
"pathNode",
")",
";",
"continue",
";",
"}",
"return",
"$",
"xmlNode",
";",
"}"
] | Returns Node Object for a Node Path.
@access public
@param string $nodePath Path to Node in XML Tree
@return bool | [
"Returns",
"Node",
"Object",
"for",
"a",
"Node",
"Path",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L115-L137 |
36,510 | CeusMedia/Common | src/XML/DOM/FileEditor.php | XML_DOM_FileEditor.removeNode | public function removeNode( $nodePath )
{
$pathNodes = explode( "/", $nodePath );
$nodeName = array_pop( $pathNodes );
$nodePath = implode( "/", $pathNodes );
$nodeNumber = 0;
$branch = $this->getNode( $nodePath );
if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $nodeName, $matches ) )
{
$nodeName = $matches[1][0];
$nodeNumber = $matches[2][0];
}
$nodes =& $branch->getChildren();
$index = -1;
for( $i=0; $i<count( $nodes ); $i++ )
{
if( !$nodeName || $nodes[$i]->getNodeName() == $nodeName )
{
$index++;
if( $index != $nodeNumber )
continue;
unset( $nodes[$i] );
return (bool) $this->write();
}
}
throw new InvalidArgumentException( 'Node not found.' );
} | php | public function removeNode( $nodePath )
{
$pathNodes = explode( "/", $nodePath );
$nodeName = array_pop( $pathNodes );
$nodePath = implode( "/", $pathNodes );
$nodeNumber = 0;
$branch = $this->getNode( $nodePath );
if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $nodeName, $matches ) )
{
$nodeName = $matches[1][0];
$nodeNumber = $matches[2][0];
}
$nodes =& $branch->getChildren();
$index = -1;
for( $i=0; $i<count( $nodes ); $i++ )
{
if( !$nodeName || $nodes[$i]->getNodeName() == $nodeName )
{
$index++;
if( $index != $nodeNumber )
continue;
unset( $nodes[$i] );
return (bool) $this->write();
}
}
throw new InvalidArgumentException( 'Node not found.' );
} | [
"public",
"function",
"removeNode",
"(",
"$",
"nodePath",
")",
"{",
"$",
"pathNodes",
"=",
"explode",
"(",
"\"/\"",
",",
"$",
"nodePath",
")",
";",
"$",
"nodeName",
"=",
"array_pop",
"(",
"$",
"pathNodes",
")",
";",
"$",
"nodePath",
"=",
"implode",
"(",
"\"/\"",
",",
"$",
"pathNodes",
")",
";",
"$",
"nodeNumber",
"=",
"0",
";",
"$",
"branch",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"nodePath",
")",
";",
"if",
"(",
"preg_match_all",
"(",
"\"@^(.*)\\[([0-9]+)\\]$@\"",
",",
"$",
"nodeName",
",",
"$",
"matches",
")",
")",
"{",
"$",
"nodeName",
"=",
"$",
"matches",
"[",
"1",
"]",
"[",
"0",
"]",
";",
"$",
"nodeNumber",
"=",
"$",
"matches",
"[",
"2",
"]",
"[",
"0",
"]",
";",
"}",
"$",
"nodes",
"=",
"&",
"$",
"branch",
"->",
"getChildren",
"(",
")",
";",
"$",
"index",
"=",
"-",
"1",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"nodes",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"$",
"nodeName",
"||",
"$",
"nodes",
"[",
"$",
"i",
"]",
"->",
"getNodeName",
"(",
")",
"==",
"$",
"nodeName",
")",
"{",
"$",
"index",
"++",
";",
"if",
"(",
"$",
"index",
"!=",
"$",
"nodeNumber",
")",
"continue",
";",
"unset",
"(",
"$",
"nodes",
"[",
"$",
"i",
"]",
")",
";",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Node not found.'",
")",
";",
"}"
] | Removes a Node by its Path.
@access public
@param string $nodePath Path to Node in XML Tree
@return bool | [
"Removes",
"a",
"Node",
"by",
"its",
"Path",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L145-L171 |
36,511 | CeusMedia/Common | src/XML/DOM/FileEditor.php | XML_DOM_FileEditor.removeNodeAttribute | public function removeNodeAttribute( $nodePath, $key )
{
$node = $this->getNode( $nodePath );
if( $node->removeAttribute( $key ) )
return (bool) $this->write();
return FALSE;
} | php | public function removeNodeAttribute( $nodePath, $key )
{
$node = $this->getNode( $nodePath );
if( $node->removeAttribute( $key ) )
return (bool) $this->write();
return FALSE;
} | [
"public",
"function",
"removeNodeAttribute",
"(",
"$",
"nodePath",
",",
"$",
"key",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"getNode",
"(",
"$",
"nodePath",
")",
";",
"if",
"(",
"$",
"node",
"->",
"removeAttribute",
"(",
"$",
"key",
")",
")",
"return",
"(",
"bool",
")",
"$",
"this",
"->",
"write",
"(",
")",
";",
"return",
"FALSE",
";",
"}"
] | Removes a Node Attribute by its Path and Attribute Key.
@access public
@param string $nodePath Path to Node in XML Tree
@param string $key Attribute Key
@return bool | [
"Removes",
"a",
"Node",
"Attribute",
"by",
"its",
"Path",
"and",
"Attribute",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L180-L186 |
36,512 | fxpio/fxp-resource-bundle | DependencyInjection/Compiler/DomainPass.php | DomainPass.getResolveTargets | private function getResolveTargets(ContainerBuilder $container)
{
if (null === $this->resolveTargets) {
$this->resolveTargets = [];
if ($container->hasDefinition('doctrine.orm.listeners.resolve_target_entity')) {
$def = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity');
foreach ($def->getMethodCalls() as $call) {
if ('addResolveTargetEntity' === $call[0]) {
$this->resolveTargets[$call[1][0]] = $call[1][1];
}
}
}
}
return $this->resolveTargets;
} | php | private function getResolveTargets(ContainerBuilder $container)
{
if (null === $this->resolveTargets) {
$this->resolveTargets = [];
if ($container->hasDefinition('doctrine.orm.listeners.resolve_target_entity')) {
$def = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity');
foreach ($def->getMethodCalls() as $call) {
if ('addResolveTargetEntity' === $call[0]) {
$this->resolveTargets[$call[1][0]] = $call[1][1];
}
}
}
}
return $this->resolveTargets;
} | [
"private",
"function",
"getResolveTargets",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"resolveTargets",
")",
"{",
"$",
"this",
"->",
"resolveTargets",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"container",
"->",
"hasDefinition",
"(",
"'doctrine.orm.listeners.resolve_target_entity'",
")",
")",
"{",
"$",
"def",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"'doctrine.orm.listeners.resolve_target_entity'",
")",
";",
"foreach",
"(",
"$",
"def",
"->",
"getMethodCalls",
"(",
")",
"as",
"$",
"call",
")",
"{",
"if",
"(",
"'addResolveTargetEntity'",
"===",
"$",
"call",
"[",
"0",
"]",
")",
"{",
"$",
"this",
"->",
"resolveTargets",
"[",
"$",
"call",
"[",
"1",
"]",
"[",
"0",
"]",
"]",
"=",
"$",
"call",
"[",
"1",
"]",
"[",
"1",
"]",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"resolveTargets",
";",
"}"
] | Get the resolve target classes.
@param ContainerBuilder $container The container
@return array | [
"Get",
"the",
"resolve",
"target",
"classes",
"."
] | a6549ad2013fe751f20c0619382d0589d0d549d7 | https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/DomainPass.php#L49-L66 |
36,513 | spiral/pagination | src/Paginator.php | Paginator.setCount | private function setCount(int $count): self
{
$this->count = max($count, 0);
if ($this->count > 0) {
$this->countPages = (int)ceil($this->count / $this->limit);
} else {
$this->countPages = 1;
}
return $this;
} | php | private function setCount(int $count): self
{
$this->count = max($count, 0);
if ($this->count > 0) {
$this->countPages = (int)ceil($this->count / $this->limit);
} else {
$this->countPages = 1;
}
return $this;
} | [
"private",
"function",
"setCount",
"(",
"int",
"$",
"count",
")",
":",
"self",
"{",
"$",
"this",
"->",
"count",
"=",
"max",
"(",
"$",
"count",
",",
"0",
")",
";",
"if",
"(",
"$",
"this",
"->",
"count",
">",
"0",
")",
"{",
"$",
"this",
"->",
"countPages",
"=",
"(",
"int",
")",
"ceil",
"(",
"$",
"this",
"->",
"count",
"/",
"$",
"this",
"->",
"limit",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"countPages",
"=",
"1",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Non-Immutable version of withCount.
@param int $count
@return self|$this | [
"Non",
"-",
"Immutable",
"version",
"of",
"withCount",
"."
] | c2ccf0c3c38fc6cdb2e547685008898dc5804e6f | https://github.com/spiral/pagination/blob/c2ccf0c3c38fc6cdb2e547685008898dc5804e6f/src/Paginator.php#L206-L216 |
36,514 | railken/amethyst-invoice | src/InvoiceNumber/IncrementalWithYearInvoice.php | IncrementalWithYearInvoice.calculateNextFreeNumber | public function calculateNextFreeNumber()
{
$year = (new \DateTime())->format('Y');
/** @var \Railken\Amethyst\Models\InvoiceModel */
$result = $this->getManager()
->getRepository()
->newQuery()
->where('number', 'like', '%/'.$year)
->orderBy(DB::raw("CAST(REPLACE(number, '/{$year}', '') AS DECIMAL(10,2))"), 'desc')
->first();
$number = $result ? intval(str_replace("/{$year}", '', $result->number)) + 1 : 1;
return $number.'/'.$year;
} | php | public function calculateNextFreeNumber()
{
$year = (new \DateTime())->format('Y');
/** @var \Railken\Amethyst\Models\InvoiceModel */
$result = $this->getManager()
->getRepository()
->newQuery()
->where('number', 'like', '%/'.$year)
->orderBy(DB::raw("CAST(REPLACE(number, '/{$year}', '') AS DECIMAL(10,2))"), 'desc')
->first();
$number = $result ? intval(str_replace("/{$year}", '', $result->number)) + 1 : 1;
return $number.'/'.$year;
} | [
"public",
"function",
"calculateNextFreeNumber",
"(",
")",
"{",
"$",
"year",
"=",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"format",
"(",
"'Y'",
")",
";",
"/** @var \\Railken\\Amethyst\\Models\\InvoiceModel */",
"$",
"result",
"=",
"$",
"this",
"->",
"getManager",
"(",
")",
"->",
"getRepository",
"(",
")",
"->",
"newQuery",
"(",
")",
"->",
"where",
"(",
"'number'",
",",
"'like'",
",",
"'%/'",
".",
"$",
"year",
")",
"->",
"orderBy",
"(",
"DB",
"::",
"raw",
"(",
"\"CAST(REPLACE(number, '/{$year}', '') AS DECIMAL(10,2))\"",
")",
",",
"'desc'",
")",
"->",
"first",
"(",
")",
";",
"$",
"number",
"=",
"$",
"result",
"?",
"intval",
"(",
"str_replace",
"(",
"\"/{$year}\"",
",",
"''",
",",
"$",
"result",
"->",
"number",
")",
")",
"+",
"1",
":",
"1",
";",
"return",
"$",
"number",
".",
"'/'",
".",
"$",
"year",
";",
"}"
] | Calculate next free number.
@return string | [
"Calculate",
"next",
"free",
"number",
"."
] | 605cf27aaa82aea7328d5e5ae5f69b1e7e86120e | https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/InvoiceNumber/IncrementalWithYearInvoice.php#L51-L66 |
36,515 | CeusMedia/Common | src/Alg/Math/Average.php | Alg_Math_Average.arithmetic | public static function arithmetic( $values, $accuracy = NULL )
{
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'
) );
$sum = 0;
foreach( $values as $value )
$sum += $value;
$result = $sum / count( $values );
if( $accuracy >= 0 )
$result = round( $result, $accuracy );
return $result;
} | php | public static function arithmetic( $values, $accuracy = NULL )
{
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'
) );
$sum = 0;
foreach( $values as $value )
$sum += $value;
$result = $sum / count( $values );
if( $accuracy >= 0 )
$result = round( $result, $accuracy );
return $result;
} | [
"public",
"static",
"function",
"arithmetic",
"(",
"$",
"values",
",",
"$",
"accuracy",
"=",
"NULL",
")",
"{",
"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'",
")",
")",
";",
"$",
"sum",
"=",
"0",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"$",
"sum",
"+=",
"$",
"value",
";",
"$",
"result",
"=",
"$",
"sum",
"/",
"count",
"(",
"$",
"values",
")",
";",
"if",
"(",
"$",
"accuracy",
">=",
"0",
")",
"$",
"result",
"=",
"round",
"(",
"$",
"result",
",",
"$",
"accuracy",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Calculates artithmetic Average.
@access public
@static
@param array $values Array of Values.
@param int $accuracy Accuracy of Result
@return float | [
"Calculates",
"artithmetic",
"Average",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Average.php#L51-L68 |
36,516 | CeusMedia/Common | src/Alg/Math/Average.php | Alg_Math_Average.geometric | public static function geometric( $values, $accuracy = NULL )
{
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'
) );
$product = 1;
foreach( $values as $value )
$product *= $value;
$result = pow( $product, 1 / count( $values ) );
if( $accuracy >= 0 )
$result = round( $result, $accuracy );
return $result;
} | php | public static function geometric( $values, $accuracy = NULL )
{
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'
) );
$product = 1;
foreach( $values as $value )
$product *= $value;
$result = pow( $product, 1 / count( $values ) );
if( $accuracy >= 0 )
$result = round( $result, $accuracy );
return $result;
} | [
"public",
"static",
"function",
"geometric",
"(",
"$",
"values",
",",
"$",
"accuracy",
"=",
"NULL",
")",
"{",
"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'",
")",
")",
";",
"$",
"product",
"=",
"1",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"$",
"product",
"*=",
"$",
"value",
";",
"$",
"result",
"=",
"pow",
"(",
"$",
"product",
",",
"1",
"/",
"count",
"(",
"$",
"values",
")",
")",
";",
"if",
"(",
"$",
"accuracy",
">=",
"0",
")",
"$",
"result",
"=",
"round",
"(",
"$",
"result",
",",
"$",
"accuracy",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Calculates geometric Average.
@access public
@static
@param array $values Array of Values
@param int $accuracy Accuracy of Result
@return float | [
"Calculates",
"geometric",
"Average",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Average.php#L78-L95 |
36,517 | rollun-com/rollun-logger | src/Logger/src/Processor/LifeCycleTokenInjector.php | LifeCycleTokenInjector.process | public function process(array $event)
{
if (!isset($event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) {
$event[LifeCycleToken::KEY_LIFECYCLE_TOKEN] = $this->token->toString();
} elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN])
&& ($this->token->toString() !== $event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) {
$event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN] = $this->token->toString();
}
if ($this->token->hasParentToken()) {
if (!isset($event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN])) {
$event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken()
->toString();
} elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN])
&& $this->token->getParentToken()
->toString() !== $event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN]) {
$event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken()
->toString();
}
}
return $event;
} | php | public function process(array $event)
{
if (!isset($event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) {
$event[LifeCycleToken::KEY_LIFECYCLE_TOKEN] = $this->token->toString();
} elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN])
&& ($this->token->toString() !== $event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) {
$event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN] = $this->token->toString();
}
if ($this->token->hasParentToken()) {
if (!isset($event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN])) {
$event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken()
->toString();
} elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN])
&& $this->token->getParentToken()
->toString() !== $event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN]) {
$event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken()
->toString();
}
}
return $event;
} | [
"public",
"function",
"process",
"(",
"array",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"event",
"[",
"LifeCycleToken",
"::",
"KEY_LIFECYCLE_TOKEN",
"]",
")",
")",
"{",
"$",
"event",
"[",
"LifeCycleToken",
"::",
"KEY_LIFECYCLE_TOKEN",
"]",
"=",
"$",
"this",
"->",
"token",
"->",
"toString",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"event",
"[",
"'context'",
"]",
"[",
"LifeCycleToken",
"::",
"KEY_ORIGINAL_LIFECYCLE_TOKEN",
"]",
")",
"&&",
"(",
"$",
"this",
"->",
"token",
"->",
"toString",
"(",
")",
"!==",
"$",
"event",
"[",
"LifeCycleToken",
"::",
"KEY_LIFECYCLE_TOKEN",
"]",
")",
")",
"{",
"$",
"event",
"[",
"'context'",
"]",
"[",
"LifeCycleToken",
"::",
"KEY_ORIGINAL_LIFECYCLE_TOKEN",
"]",
"=",
"$",
"this",
"->",
"token",
"->",
"toString",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"token",
"->",
"hasParentToken",
"(",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"event",
"[",
"LifeCycleToken",
"::",
"KEY_PARENT_LIFECYCLE_TOKEN",
"]",
")",
")",
"{",
"$",
"event",
"[",
"LifeCycleToken",
"::",
"KEY_PARENT_LIFECYCLE_TOKEN",
"]",
"=",
"$",
"this",
"->",
"token",
"->",
"getParentToken",
"(",
")",
"->",
"toString",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"isset",
"(",
"$",
"event",
"[",
"'context'",
"]",
"[",
"LifeCycleToken",
"::",
"KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN",
"]",
")",
"&&",
"$",
"this",
"->",
"token",
"->",
"getParentToken",
"(",
")",
"->",
"toString",
"(",
")",
"!==",
"$",
"event",
"[",
"LifeCycleToken",
"::",
"KEY_PARENT_LIFECYCLE_TOKEN",
"]",
")",
"{",
"$",
"event",
"[",
"'context'",
"]",
"[",
"LifeCycleToken",
"::",
"KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN",
"]",
"=",
"$",
"this",
"->",
"token",
"->",
"getParentToken",
"(",
")",
"->",
"toString",
"(",
")",
";",
"}",
"}",
"return",
"$",
"event",
";",
"}"
] | Processes a log message before it is given to the writers
@param array $event
@return array | [
"Processes",
"a",
"log",
"message",
"before",
"it",
"is",
"given",
"to",
"the",
"writers"
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Processor/LifeCycleTokenInjector.php#L34-L55 |
36,518 | CeusMedia/Common | src/FS/File/Arc/TarGzip.php | FS_File_Arc_TarGzip.open | public function open( $fileName )
{
if( !file_exists( $fileName ) ) // If the tar file doesn't exist...
throw new Exception( "TGZ file '".$fileName."' is not existing." );
$this->fileName = $fileName;
$this->readGzipTar( $fileName );
} | php | public function open( $fileName )
{
if( !file_exists( $fileName ) ) // If the tar file doesn't exist...
throw new Exception( "TGZ file '".$fileName."' is not existing." );
$this->fileName = $fileName;
$this->readGzipTar( $fileName );
} | [
"public",
"function",
"open",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"// If the tar file doesn't exist...\r",
"throw",
"new",
"Exception",
"(",
"\"TGZ file '\"",
".",
"$",
"fileName",
".",
"\"' is not existing.\"",
")",
";",
"$",
"this",
"->",
"fileName",
"=",
"$",
"fileName",
";",
"$",
"this",
"->",
"readGzipTar",
"(",
"$",
"fileName",
")",
";",
"}"
] | Opens an existing Tar Gzip File and loads contents.
@access public
@param string $fileName Name of Tar Gzip Archive to open
@return bool | [
"Opens",
"an",
"existing",
"Tar",
"Gzip",
"File",
"and",
"loads",
"contents",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/TarGzip.php#L60-L66 |
36,519 | CeusMedia/Common | src/FS/File/Arc/TarGzip.php | FS_File_Arc_TarGzip.readGzipTar | private function readGzipTar( $fileName )
{
$f = new FS_File_Arc_Gzip( $fileName );
$this->content = $f->readString();
$this->parseTar(); // Parse the TAR file
return true;
} | php | private function readGzipTar( $fileName )
{
$f = new FS_File_Arc_Gzip( $fileName );
$this->content = $f->readString();
$this->parseTar(); // Parse the TAR file
return true;
} | [
"private",
"function",
"readGzipTar",
"(",
"$",
"fileName",
")",
"{",
"$",
"f",
"=",
"new",
"FS_File_Arc_Gzip",
"(",
"$",
"fileName",
")",
";",
"$",
"this",
"->",
"content",
"=",
"$",
"f",
"->",
"readString",
"(",
")",
";",
"$",
"this",
"->",
"parseTar",
"(",
")",
";",
"// Parse the TAR file\r",
"return",
"true",
";",
"}"
] | Reads an existing Tar Gzip File.
@access private
@param string $fileName Name of Tar Gzip Archive to read
@return bool | [
"Reads",
"an",
"existing",
"Tar",
"Gzip",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/TarGzip.php#L74-L80 |
36,520 | CeusMedia/Common | src/FS/File/Arc/TarGzip.php | FS_File_Arc_TarGzip.save | public function save( $fileName = false )
{
if( !$fileName )
{
if( !$this->fileName )
throw new Exception( "No TGZ file name for saving given." );
$fileName = $this->fileName;
}
$this->generateTar(); // Encode processed files into TAR file format
$f = new FS_File_Arc_Gzip( $fileName );
$f->writeString( $this->content);
return true;
} | php | public function save( $fileName = false )
{
if( !$fileName )
{
if( !$this->fileName )
throw new Exception( "No TGZ file name for saving given." );
$fileName = $this->fileName;
}
$this->generateTar(); // Encode processed files into TAR file format
$f = new FS_File_Arc_Gzip( $fileName );
$f->writeString( $this->content);
return true;
} | [
"public",
"function",
"save",
"(",
"$",
"fileName",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"fileName",
")",
"throw",
"new",
"Exception",
"(",
"\"No TGZ file name for saving given.\"",
")",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"fileName",
";",
"}",
"$",
"this",
"->",
"generateTar",
"(",
")",
";",
"// Encode processed files into TAR file format\r",
"$",
"f",
"=",
"new",
"FS_File_Arc_Gzip",
"(",
"$",
"fileName",
")",
";",
"$",
"f",
"->",
"writeString",
"(",
"$",
"this",
"->",
"content",
")",
";",
"return",
"true",
";",
"}"
] | Write down the currently loaded Tar Gzip Archive.
@access public
@param string $fileName Name of Tar Gzip Archive to save
@return bool | [
"Write",
"down",
"the",
"currently",
"loaded",
"Tar",
"Gzip",
"Archive",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/TarGzip.php#L88-L100 |
36,521 | CeusMedia/Common | src/Net/Mail.php | Net_Mail.getBody | public function getBody()
{
$number = count( $this->parts );
if( !$number )
return '';
$innerBoundary = $this->mimeBoundary.'-1';
$contents = array( 'This is a multi-part message in MIME format.');
$contents[] = '--'.$this->mimeBoundary;
$contents[] = 'Content-Type: multipart/alternative;';
$contents[] = ' boundary="'.$innerBoundary.'"'.Net_Mail::$delimiter;
foreach( $this->parts as $part )
if( $part instanceof Net_Mail_Body )
$contents[] = '--'.$innerBoundary.Net_Mail::$delimiter.$part->render();
$contents[] = '--'.$innerBoundary.'--'.Net_Mail::$delimiter;
foreach( $this->parts as $part )
if( $part instanceof Net_Mail_Attachment )
$contents[] = '--'.$this->mimeBoundary.Net_Mail::$delimiter.$part->render();
$contents[] = '--'.$this->mimeBoundary.'--'.Net_Mail::$delimiter;
return join( Net_Mail::$delimiter, $contents );
} | php | public function getBody()
{
$number = count( $this->parts );
if( !$number )
return '';
$innerBoundary = $this->mimeBoundary.'-1';
$contents = array( 'This is a multi-part message in MIME format.');
$contents[] = '--'.$this->mimeBoundary;
$contents[] = 'Content-Type: multipart/alternative;';
$contents[] = ' boundary="'.$innerBoundary.'"'.Net_Mail::$delimiter;
foreach( $this->parts as $part )
if( $part instanceof Net_Mail_Body )
$contents[] = '--'.$innerBoundary.Net_Mail::$delimiter.$part->render();
$contents[] = '--'.$innerBoundary.'--'.Net_Mail::$delimiter;
foreach( $this->parts as $part )
if( $part instanceof Net_Mail_Attachment )
$contents[] = '--'.$this->mimeBoundary.Net_Mail::$delimiter.$part->render();
$contents[] = '--'.$this->mimeBoundary.'--'.Net_Mail::$delimiter;
return join( Net_Mail::$delimiter, $contents );
} | [
"public",
"function",
"getBody",
"(",
")",
"{",
"$",
"number",
"=",
"count",
"(",
"$",
"this",
"->",
"parts",
")",
";",
"if",
"(",
"!",
"$",
"number",
")",
"return",
"''",
";",
"$",
"innerBoundary",
"=",
"$",
"this",
"->",
"mimeBoundary",
".",
"'-1'",
";",
"$",
"contents",
"=",
"array",
"(",
"'This is a multi-part message in MIME format.'",
")",
";",
"$",
"contents",
"[",
"]",
"=",
"'--'",
".",
"$",
"this",
"->",
"mimeBoundary",
";",
"$",
"contents",
"[",
"]",
"=",
"'Content-Type: multipart/alternative;'",
";",
"$",
"contents",
"[",
"]",
"=",
"' boundary=\"'",
".",
"$",
"innerBoundary",
".",
"'\"'",
".",
"Net_Mail",
"::",
"$",
"delimiter",
";",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"as",
"$",
"part",
")",
"if",
"(",
"$",
"part",
"instanceof",
"Net_Mail_Body",
")",
"$",
"contents",
"[",
"]",
"=",
"'--'",
".",
"$",
"innerBoundary",
".",
"Net_Mail",
"::",
"$",
"delimiter",
".",
"$",
"part",
"->",
"render",
"(",
")",
";",
"$",
"contents",
"[",
"]",
"=",
"'--'",
".",
"$",
"innerBoundary",
".",
"'--'",
".",
"Net_Mail",
"::",
"$",
"delimiter",
";",
"foreach",
"(",
"$",
"this",
"->",
"parts",
"as",
"$",
"part",
")",
"if",
"(",
"$",
"part",
"instanceof",
"Net_Mail_Attachment",
")",
"$",
"contents",
"[",
"]",
"=",
"'--'",
".",
"$",
"this",
"->",
"mimeBoundary",
".",
"Net_Mail",
"::",
"$",
"delimiter",
".",
"$",
"part",
"->",
"render",
"(",
")",
";",
"$",
"contents",
"[",
"]",
"=",
"'--'",
".",
"$",
"this",
"->",
"mimeBoundary",
".",
"'--'",
".",
"Net_Mail",
"::",
"$",
"delimiter",
";",
"return",
"join",
"(",
"Net_Mail",
"::",
"$",
"delimiter",
",",
"$",
"contents",
")",
";",
"}"
] | Returns Mail Body.
@access public
@return string | [
"Returns",
"Mail",
"Body",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail.php#L110-L132 |
36,522 | ncou/Chiron | src/Chiron/Routing/Router.php | Router.processGroups | private function processGroups(): void
{
// Call the $group by reference because in the case : group of group the size of the array is modified because a new group is added in the group() function.
foreach ($this->groups as $key => &$group) {
unset($this->groups[$key]);
$group();
//array_pop($this->groups);
}
} | php | private function processGroups(): void
{
// Call the $group by reference because in the case : group of group the size of the array is modified because a new group is added in the group() function.
foreach ($this->groups as $key => &$group) {
unset($this->groups[$key]);
$group();
//array_pop($this->groups);
}
} | [
"private",
"function",
"processGroups",
"(",
")",
":",
"void",
"{",
"// Call the $group by reference because in the case : group of group the size of the array is modified because a new group is added in the group() function.",
"foreach",
"(",
"$",
"this",
"->",
"groups",
"as",
"$",
"key",
"=>",
"&",
"$",
"group",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"groups",
"[",
"$",
"key",
"]",
")",
";",
"$",
"group",
"(",
")",
";",
"//array_pop($this->groups);",
"}",
"}"
] | Process all groups. | [
"Process",
"all",
"groups",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L271-L279 |
36,523 | ncou/Chiron | src/Chiron/Routing/Router.php | Router.replaceAssertPatterns | private function replaceAssertPatterns(array $requirements, string $path): string
{
$patternAssert = [];
foreach ($requirements as $attribute => $pattern) {
// it will replace {attribute_name} to {attribute_name:$pattern}, work event if there is alreay a patter {attribute_name:pattern_to_remove} to {attribute_name:$pattern}
// the second regex group (starting with the char ':') will be discarded.
$patternAssert['/{(' . $attribute . ')(\:.*)?}/'] = '{$1:' . $pattern . '}';
//$patternAssert['/{(' . $attribute . ')}/'] = '{$1:' . $pattern . '}'; // TODO : réfléchir si on utilise cette regex, dans ce cas seulement les propriétés qui n'ont pas déjà un pattern de défini (c'est à dire une partie avec ':pattern')
}
return preg_replace(array_keys($patternAssert), array_values($patternAssert), $path);
} | php | private function replaceAssertPatterns(array $requirements, string $path): string
{
$patternAssert = [];
foreach ($requirements as $attribute => $pattern) {
// it will replace {attribute_name} to {attribute_name:$pattern}, work event if there is alreay a patter {attribute_name:pattern_to_remove} to {attribute_name:$pattern}
// the second regex group (starting with the char ':') will be discarded.
$patternAssert['/{(' . $attribute . ')(\:.*)?}/'] = '{$1:' . $pattern . '}';
//$patternAssert['/{(' . $attribute . ')}/'] = '{$1:' . $pattern . '}'; // TODO : réfléchir si on utilise cette regex, dans ce cas seulement les propriétés qui n'ont pas déjà un pattern de défini (c'est à dire une partie avec ':pattern')
}
return preg_replace(array_keys($patternAssert), array_values($patternAssert), $path);
} | [
"private",
"function",
"replaceAssertPatterns",
"(",
"array",
"$",
"requirements",
",",
"string",
"$",
"path",
")",
":",
"string",
"{",
"$",
"patternAssert",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"requirements",
"as",
"$",
"attribute",
"=>",
"$",
"pattern",
")",
"{",
"// it will replace {attribute_name} to {attribute_name:$pattern}, work event if there is alreay a patter {attribute_name:pattern_to_remove} to {attribute_name:$pattern}",
"// the second regex group (starting with the char ':') will be discarded.",
"$",
"patternAssert",
"[",
"'/{('",
".",
"$",
"attribute",
".",
"')(\\:.*)?}/'",
"]",
"=",
"'{$1:'",
".",
"$",
"pattern",
".",
"'}'",
";",
"//$patternAssert['/{(' . $attribute . ')}/'] = '{$1:' . $pattern . '}'; // TODO : réfléchir si on utilise cette regex, dans ce cas seulement les propriétés qui n'ont pas déjà un pattern de défini (c'est à dire une partie avec ':pattern')",
"}",
"return",
"preg_replace",
"(",
"array_keys",
"(",
"$",
"patternAssert",
")",
",",
"array_values",
"(",
"$",
"patternAssert",
")",
",",
"$",
"path",
")",
";",
"}"
] | Add or replace the requirement pattern inside the route path.
@param array $requirements
@param string $path
@return string | [
"Add",
"or",
"replace",
"the",
"requirement",
"pattern",
"inside",
"the",
"route",
"path",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L289-L300 |
36,524 | ncou/Chiron | src/Chiron/Routing/Router.php | Router.replaceWordPatterns | private function replaceWordPatterns(string $path): string
{
return preg_replace(array_keys($this->patternMatchers), array_values($this->patternMatchers), $path);
} | php | private function replaceWordPatterns(string $path): string
{
return preg_replace(array_keys($this->patternMatchers), array_values($this->patternMatchers), $path);
} | [
"private",
"function",
"replaceWordPatterns",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"return",
"preg_replace",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"patternMatchers",
")",
",",
"array_values",
"(",
"$",
"this",
"->",
"patternMatchers",
")",
",",
"$",
"path",
")",
";",
"}"
] | Replace word patterns with regex in route path.
@param string $path
@return string | [
"Replace",
"word",
"patterns",
"with",
"regex",
"in",
"route",
"path",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L309-L312 |
36,525 | ncou/Chiron | src/Chiron/Routing/Router.php | Router.addRoute | private function addRoute(array $httpMethod, string $routePath, string $routeId): void
{
$routeDatas = $this->parser->parse($routePath);
foreach ($httpMethod as $method) {
foreach ($routeDatas as $routeData) {
$this->generator->addRoute($method, $routeData, $routeId);
}
}
} | php | private function addRoute(array $httpMethod, string $routePath, string $routeId): void
{
$routeDatas = $this->parser->parse($routePath);
foreach ($httpMethod as $method) {
foreach ($routeDatas as $routeData) {
$this->generator->addRoute($method, $routeData, $routeId);
}
}
} | [
"private",
"function",
"addRoute",
"(",
"array",
"$",
"httpMethod",
",",
"string",
"$",
"routePath",
",",
"string",
"$",
"routeId",
")",
":",
"void",
"{",
"$",
"routeDatas",
"=",
"$",
"this",
"->",
"parser",
"->",
"parse",
"(",
"$",
"routePath",
")",
";",
"foreach",
"(",
"$",
"httpMethod",
"as",
"$",
"method",
")",
"{",
"foreach",
"(",
"$",
"routeDatas",
"as",
"$",
"routeData",
")",
"{",
"$",
"this",
"->",
"generator",
"->",
"addRoute",
"(",
"$",
"method",
",",
"$",
"routeData",
",",
"$",
"routeId",
")",
";",
"}",
"}",
"}"
] | Adds a route to the collection.
The syntax used in the $route string depends on the used route parser.
@param string[] $httpMethod
@param string $routePath
@param string $routeId | [
"Adds",
"a",
"route",
"to",
"the",
"collection",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L323-L331 |
36,526 | ncou/Chiron | src/Chiron/Routing/Router.php | Router.getNamedRoute | public function getNamedRoute(string $name): Route
{
foreach ($this->getRoutes() as $route) {
if ($route->getName() === $name) {
return $route;
}
}
throw new InvalidArgumentException('Named route does not exist for name: ' . $name);
} | php | public function getNamedRoute(string $name): Route
{
foreach ($this->getRoutes() as $route) {
if ($route->getName() === $name) {
return $route;
}
}
throw new InvalidArgumentException('Named route does not exist for name: ' . $name);
} | [
"public",
"function",
"getNamedRoute",
"(",
"string",
"$",
"name",
")",
":",
"Route",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"route",
"->",
"getName",
"(",
")",
"===",
"$",
"name",
")",
"{",
"return",
"$",
"route",
";",
"}",
"}",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Named route does not exist for name: '",
".",
"$",
"name",
")",
";",
"}"
] | Get a named route.
@param string $name Route name
@throws \InvalidArgumentException If named route does not exist
@return \Chiron\Routing\Route | [
"Get",
"a",
"named",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L354-L363 |
36,527 | ncou/Chiron | src/Chiron/Routing/Router.php | Router.removeNamedRoute | public function removeNamedRoute(string $name)
{
$route = $this->getNamedRoute($name);
// no exception, route exists, now remove by id
unset($this->routes[$route->getIdentifier()]);
} | php | public function removeNamedRoute(string $name)
{
$route = $this->getNamedRoute($name);
// no exception, route exists, now remove by id
unset($this->routes[$route->getIdentifier()]);
} | [
"public",
"function",
"removeNamedRoute",
"(",
"string",
"$",
"name",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"getNamedRoute",
"(",
"$",
"name",
")",
";",
"// no exception, route exists, now remove by id",
"unset",
"(",
"$",
"this",
"->",
"routes",
"[",
"$",
"route",
"->",
"getIdentifier",
"(",
")",
"]",
")",
";",
"}"
] | Remove named route.
@param string $name Route name
@throws \InvalidArgumentException If named route does not exist | [
"Remove",
"named",
"route",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L372-L377 |
36,528 | ncou/Chiron | src/Chiron/Routing/Router.php | Router.pathFor | public function pathFor(string $name, array $data = [], array $queryParams = []): string
{
$url = $this->relativePathFor($name, $data, $queryParams);
if ($this->basePath) {
$url = $this->basePath . $url;
}
return $url;
} | php | public function pathFor(string $name, array $data = [], array $queryParams = []): string
{
$url = $this->relativePathFor($name, $data, $queryParams);
if ($this->basePath) {
$url = $this->basePath . $url;
}
return $url;
} | [
"public",
"function",
"pathFor",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"relativePathFor",
"(",
"$",
"name",
",",
"$",
"data",
",",
"$",
"queryParams",
")",
";",
"if",
"(",
"$",
"this",
"->",
"basePath",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"basePath",
".",
"$",
"url",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Build the path for a named route including the base path.
@param string $name Route name
@param array $data Named argument replacement data
@param array $queryParams Optional query string parameters
@throws InvalidArgumentException If named route does not exist
@throws InvalidArgumentException If required data not provided
@return string | [
"Build",
"the",
"path",
"for",
"a",
"named",
"route",
"including",
"the",
"base",
"path",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L391-L400 |
36,529 | CeusMedia/Common | src/FS/Folder/MethodSortCheck.php | FS_Folder_MethodSortCheck.checkOrder | public function checkOrder()
{
$this->count = 0;
$this->found = 0;
$this->files = array();
$extensions = implode( "|", $this->extensions );
$pattern = "@^[A-Z].*\.(".$extensions.")$@";
$filter = new FS_File_RecursiveRegexFilter( $this->path, $pattern );
foreach( $filter as $entry )
{
if( preg_match( "@^(_|\.)@", $entry->getFilename() ) )
continue;
$this->count++;
$check = new FS_File_PHP_MethodSortCheck( $entry->getPathname() );
if( $check->compare() )
continue;
$this->found++;
$list1 = $check->getOriginalList();
$list2 = $check->getSortedList();
do{
$line1 = array_shift( $list1 );
$line2 = array_shift( $list2 );
if( $line1 != $line2 )
break;
}
while( count( $list1 ) && count( $list2 ) );
$fileName = substr( $entry->getPathname(), strlen( $this->path ) + 1 );
$this->files[$entry->getPathname()] = array(
'fileName' => $fileName,
'pathName' => $entry->getPathname(),
'original' => $line1,
'sorted' => $line2,
);
}
return !$this->found;
} | php | public function checkOrder()
{
$this->count = 0;
$this->found = 0;
$this->files = array();
$extensions = implode( "|", $this->extensions );
$pattern = "@^[A-Z].*\.(".$extensions.")$@";
$filter = new FS_File_RecursiveRegexFilter( $this->path, $pattern );
foreach( $filter as $entry )
{
if( preg_match( "@^(_|\.)@", $entry->getFilename() ) )
continue;
$this->count++;
$check = new FS_File_PHP_MethodSortCheck( $entry->getPathname() );
if( $check->compare() )
continue;
$this->found++;
$list1 = $check->getOriginalList();
$list2 = $check->getSortedList();
do{
$line1 = array_shift( $list1 );
$line2 = array_shift( $list2 );
if( $line1 != $line2 )
break;
}
while( count( $list1 ) && count( $list2 ) );
$fileName = substr( $entry->getPathname(), strlen( $this->path ) + 1 );
$this->files[$entry->getPathname()] = array(
'fileName' => $fileName,
'pathName' => $entry->getPathname(),
'original' => $line1,
'sorted' => $line2,
);
}
return !$this->found;
} | [
"public",
"function",
"checkOrder",
"(",
")",
"{",
"$",
"this",
"->",
"count",
"=",
"0",
";",
"$",
"this",
"->",
"found",
"=",
"0",
";",
"$",
"this",
"->",
"files",
"=",
"array",
"(",
")",
";",
"$",
"extensions",
"=",
"implode",
"(",
"\"|\"",
",",
"$",
"this",
"->",
"extensions",
")",
";",
"$",
"pattern",
"=",
"\"@^[A-Z].*\\.(\"",
".",
"$",
"extensions",
".",
"\")$@\"",
";",
"$",
"filter",
"=",
"new",
"FS_File_RecursiveRegexFilter",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"pattern",
")",
";",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"@^(_|\\.)@\"",
",",
"$",
"entry",
"->",
"getFilename",
"(",
")",
")",
")",
"continue",
";",
"$",
"this",
"->",
"count",
"++",
";",
"$",
"check",
"=",
"new",
"FS_File_PHP_MethodSortCheck",
"(",
"$",
"entry",
"->",
"getPathname",
"(",
")",
")",
";",
"if",
"(",
"$",
"check",
"->",
"compare",
"(",
")",
")",
"continue",
";",
"$",
"this",
"->",
"found",
"++",
";",
"$",
"list1",
"=",
"$",
"check",
"->",
"getOriginalList",
"(",
")",
";",
"$",
"list2",
"=",
"$",
"check",
"->",
"getSortedList",
"(",
")",
";",
"do",
"{",
"$",
"line1",
"=",
"array_shift",
"(",
"$",
"list1",
")",
";",
"$",
"line2",
"=",
"array_shift",
"(",
"$",
"list2",
")",
";",
"if",
"(",
"$",
"line1",
"!=",
"$",
"line2",
")",
"break",
";",
"}",
"while",
"(",
"count",
"(",
"$",
"list1",
")",
"&&",
"count",
"(",
"$",
"list2",
")",
")",
";",
"$",
"fileName",
"=",
"substr",
"(",
"$",
"entry",
"->",
"getPathname",
"(",
")",
",",
"strlen",
"(",
"$",
"this",
"->",
"path",
")",
"+",
"1",
")",
";",
"$",
"this",
"->",
"files",
"[",
"$",
"entry",
"->",
"getPathname",
"(",
")",
"]",
"=",
"array",
"(",
"'fileName'",
"=>",
"$",
"fileName",
",",
"'pathName'",
"=>",
"$",
"entry",
"->",
"getPathname",
"(",
")",
",",
"'original'",
"=>",
"$",
"line1",
",",
"'sorted'",
"=>",
"$",
"line2",
",",
")",
";",
"}",
"return",
"!",
"$",
"this",
"->",
"found",
";",
"}"
] | Indicates whether all Methods in all Files are ordered correctly.
@access public
@return bool | [
"Indicates",
"whether",
"all",
"Methods",
"in",
"all",
"Files",
"are",
"ordered",
"correctly",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/MethodSortCheck.php#L66-L101 |
36,530 | CeusMedia/Common | src/FS/Folder/MethodSortCheck.php | FS_Folder_MethodSortCheck.getPercentage | public function getPercentage( $accuracy = 0 )
{
if( !$this->count )
return 0;
return round( $this->found / $this->count * 100, $accuracy );
} | php | public function getPercentage( $accuracy = 0 )
{
if( !$this->count )
return 0;
return round( $this->found / $this->count * 100, $accuracy );
} | [
"public",
"function",
"getPercentage",
"(",
"$",
"accuracy",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"count",
")",
"return",
"0",
";",
"return",
"round",
"(",
"$",
"this",
"->",
"found",
"/",
"$",
"this",
"->",
"count",
"*",
"100",
",",
"$",
"accuracy",
")",
";",
"}"
] | Returns Percentage Value of Ratio between Number of found and scanned Files.
@access public
@param int $accuracy Number of Digits after Dot
@return float | [
"Returns",
"Percentage",
"Value",
"of",
"Ratio",
"between",
"Number",
"of",
"found",
"and",
"scanned",
"Files",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/MethodSortCheck.php#L139-L144 |
36,531 | CeusMedia/Common | src/UI/HTML/Exception/View.php | UI_HTML_Exception_View.getMeaningOfSQLSTATE | protected static function getMeaningOfSQLSTATE( $SQLSTATE )
{
$class1 = substr( $SQLSTATE, 0, 2 );
$class2 = substr( $SQLSTATE, 2, 3 );
$root = XML_ElementReader::readFile( dirname( __FILE__ ).'/SQLSTATE.xml' );
$query = 'class[@id="'.$class1.'"]/subclass[@id="000"]';
$result = $root->xpath( $query );
$class = array_pop( $result );
if( $class ){
$query = 'class[@id="'.$class1.'"]/subclass[@id="'.$class2.'"]';
$result = $root->xpath( $query );
$subclass = array_pop( $result );
if( $subclass )
return $class->getAttribute( 'meaning' ).' - '.$subclass->getAttribute( 'meaning' );
return $class->getAttribute( 'meaning' );
}
return '';
} | php | protected static function getMeaningOfSQLSTATE( $SQLSTATE )
{
$class1 = substr( $SQLSTATE, 0, 2 );
$class2 = substr( $SQLSTATE, 2, 3 );
$root = XML_ElementReader::readFile( dirname( __FILE__ ).'/SQLSTATE.xml' );
$query = 'class[@id="'.$class1.'"]/subclass[@id="000"]';
$result = $root->xpath( $query );
$class = array_pop( $result );
if( $class ){
$query = 'class[@id="'.$class1.'"]/subclass[@id="'.$class2.'"]';
$result = $root->xpath( $query );
$subclass = array_pop( $result );
if( $subclass )
return $class->getAttribute( 'meaning' ).' - '.$subclass->getAttribute( 'meaning' );
return $class->getAttribute( 'meaning' );
}
return '';
} | [
"protected",
"static",
"function",
"getMeaningOfSQLSTATE",
"(",
"$",
"SQLSTATE",
")",
"{",
"$",
"class1",
"=",
"substr",
"(",
"$",
"SQLSTATE",
",",
"0",
",",
"2",
")",
";",
"$",
"class2",
"=",
"substr",
"(",
"$",
"SQLSTATE",
",",
"2",
",",
"3",
")",
";",
"$",
"root",
"=",
"XML_ElementReader",
"::",
"readFile",
"(",
"dirname",
"(",
"__FILE__",
")",
".",
"'/SQLSTATE.xml'",
")",
";",
"$",
"query",
"=",
"'class[@id=\"'",
".",
"$",
"class1",
".",
"'\"]/subclass[@id=\"000\"]'",
";",
"$",
"result",
"=",
"$",
"root",
"->",
"xpath",
"(",
"$",
"query",
")",
";",
"$",
"class",
"=",
"array_pop",
"(",
"$",
"result",
")",
";",
"if",
"(",
"$",
"class",
")",
"{",
"$",
"query",
"=",
"'class[@id=\"'",
".",
"$",
"class1",
".",
"'\"]/subclass[@id=\"'",
".",
"$",
"class2",
".",
"'\"]'",
";",
"$",
"result",
"=",
"$",
"root",
"->",
"xpath",
"(",
"$",
"query",
")",
";",
"$",
"subclass",
"=",
"array_pop",
"(",
"$",
"result",
")",
";",
"if",
"(",
"$",
"subclass",
")",
"return",
"$",
"class",
"->",
"getAttribute",
"(",
"'meaning'",
")",
".",
"' - '",
".",
"$",
"subclass",
"->",
"getAttribute",
"(",
"'meaning'",
")",
";",
"return",
"$",
"class",
"->",
"getAttribute",
"(",
"'meaning'",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Resolves SQLSTATE Code and returns its Meaning.
@access protected
@static
@return string
@see http://developer.mimer.com/documentation/html_92/Mimer_SQL_Mobile_DocSet/App_Return_Codes2.html
@see http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqls.doc/sqls520.htm | [
"Resolves",
"SQLSTATE",
"Code",
"and",
"returns",
"its",
"Meaning",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Exception/View.php#L62-L80 |
36,532 | CeusMedia/Common | src/FS/File/CSV/Reader.php | FS_File_CSV_Reader.getColumnHeaders | public function getColumnHeaders()
{
if( !$this->withHeaders )
throw new RuntimeException( 'Column headers not enabled' );
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
if( !$iterator->valid() )
throw new RuntimeException( 'Invalid CSV file' );
return $iterator->current();
} | php | public function getColumnHeaders()
{
if( !$this->withHeaders )
throw new RuntimeException( 'Column headers not enabled' );
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
if( !$iterator->valid() )
throw new RuntimeException( 'Invalid CSV file' );
return $iterator->current();
} | [
"public",
"function",
"getColumnHeaders",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"withHeaders",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Column headers not enabled'",
")",
";",
"$",
"iterator",
"=",
"new",
"FS_File_CSV_Iterator",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"this",
"->",
"delimiter",
")",
";",
"if",
"(",
"!",
"$",
"iterator",
"->",
"valid",
"(",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Invalid CSV file'",
")",
";",
"return",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"}"
] | Returns columns headers if used.
@access public
@return array | [
"Returns",
"columns",
"headers",
"if",
"used",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L74-L82 |
36,533 | CeusMedia/Common | src/FS/File/CSV/Reader.php | FS_File_CSV_Reader.getRowCount | public function getRowCount()
{
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
$counter = 0;
while( $iterator->next() )
$counter++;
if( $counter && $this->withHeaders )
$counter--;
return $counter;
} | php | public function getRowCount()
{
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
$counter = 0;
while( $iterator->next() )
$counter++;
if( $counter && $this->withHeaders )
$counter--;
return $counter;
} | [
"public",
"function",
"getRowCount",
"(",
")",
"{",
"$",
"iterator",
"=",
"new",
"FS_File_CSV_Iterator",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"this",
"->",
"delimiter",
")",
";",
"$",
"counter",
"=",
"0",
";",
"while",
"(",
"$",
"iterator",
"->",
"next",
"(",
")",
")",
"$",
"counter",
"++",
";",
"if",
"(",
"$",
"counter",
"&&",
"$",
"this",
"->",
"withHeaders",
")",
"$",
"counter",
"--",
";",
"return",
"$",
"counter",
";",
"}"
] | Returns the count of data rows.
@access public
@return int | [
"Returns",
"the",
"count",
"of",
"data",
"rows",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L109-L118 |
36,534 | CeusMedia/Common | src/FS/File/CSV/Reader.php | FS_File_CSV_Reader.toArray | public function toArray()
{
$data = array();
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
while( $iterator->next() )
$data[] = $iterator->current();
if( $this->withHeaders )
array_shift( $data );
return $data;
} | php | public function toArray()
{
$data = array();
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
while( $iterator->next() )
$data[] = $iterator->current();
if( $this->withHeaders )
array_shift( $data );
return $data;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"iterator",
"=",
"new",
"FS_File_CSV_Iterator",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"this",
"->",
"delimiter",
")",
";",
"while",
"(",
"$",
"iterator",
"->",
"next",
"(",
")",
")",
"$",
"data",
"[",
"]",
"=",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"withHeaders",
")",
"array_shift",
"(",
"$",
"data",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Reads data an returns an array.
@access public
@return array | [
"Reads",
"data",
"an",
"returns",
"an",
"array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L147-L156 |
36,535 | CeusMedia/Common | src/FS/File/CSV/Reader.php | FS_File_CSV_Reader.toAssocArray | public function toAssocArray( $headerMap = array() )
{
$data = array();
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
$keys = $this->getColumnHeaders( $headerMap );
$line = 0;
if( $this->withHeaders )
{
$iterator->next();
$line++;
}
while( $iterator->valid() )
{
$line++;
$values = $iterator->current();
if( count( $keys ) != count( $values ) )
throw new RuntimeException( 'Invalid line '.$line.' in file "'.$this->fileName.'"' );
$data[] = array_combine( $keys, $values );
}
return $data;
} | php | public function toAssocArray( $headerMap = array() )
{
$data = array();
$iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter );
$keys = $this->getColumnHeaders( $headerMap );
$line = 0;
if( $this->withHeaders )
{
$iterator->next();
$line++;
}
while( $iterator->valid() )
{
$line++;
$values = $iterator->current();
if( count( $keys ) != count( $values ) )
throw new RuntimeException( 'Invalid line '.$line.' in file "'.$this->fileName.'"' );
$data[] = array_combine( $keys, $values );
}
return $data;
} | [
"public",
"function",
"toAssocArray",
"(",
"$",
"headerMap",
"=",
"array",
"(",
")",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"iterator",
"=",
"new",
"FS_File_CSV_Iterator",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"this",
"->",
"delimiter",
")",
";",
"$",
"keys",
"=",
"$",
"this",
"->",
"getColumnHeaders",
"(",
"$",
"headerMap",
")",
";",
"$",
"line",
"=",
"0",
";",
"if",
"(",
"$",
"this",
"->",
"withHeaders",
")",
"{",
"$",
"iterator",
"->",
"next",
"(",
")",
";",
"$",
"line",
"++",
";",
"}",
"while",
"(",
"$",
"iterator",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"line",
"++",
";",
"$",
"values",
"=",
"$",
"iterator",
"->",
"current",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
"!=",
"count",
"(",
"$",
"values",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Invalid line '",
".",
"$",
"line",
".",
"' in file \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\"'",
")",
";",
"$",
"data",
"[",
"]",
"=",
"array_combine",
"(",
"$",
"keys",
",",
"$",
"values",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Reads data and returns an associative array if column headers are used.
@access public
@return array | [
"Reads",
"data",
"and",
"returns",
"an",
"associative",
"array",
"if",
"column",
"headers",
"are",
"used",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L163-L183 |
36,536 | meritoo/common-library | src/Utilities/Bootstrap4CssSelector.php | Bootstrap4CssSelector.getFieldErrorSelector | public static function getFieldErrorSelector($formName, $fieldId)
{
$labelSelector = CssSelector::getLabelSelector($formName, $fieldId);
if (empty($labelSelector)) {
return '';
}
$errorContainerSelector = static::getFieldErrorContainerSelector();
return sprintf('%s %s', $labelSelector, $errorContainerSelector);
} | php | public static function getFieldErrorSelector($formName, $fieldId)
{
$labelSelector = CssSelector::getLabelSelector($formName, $fieldId);
if (empty($labelSelector)) {
return '';
}
$errorContainerSelector = static::getFieldErrorContainerSelector();
return sprintf('%s %s', $labelSelector, $errorContainerSelector);
} | [
"public",
"static",
"function",
"getFieldErrorSelector",
"(",
"$",
"formName",
",",
"$",
"fieldId",
")",
"{",
"$",
"labelSelector",
"=",
"CssSelector",
"::",
"getLabelSelector",
"(",
"$",
"formName",
",",
"$",
"fieldId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"labelSelector",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"errorContainerSelector",
"=",
"static",
"::",
"getFieldErrorContainerSelector",
"(",
")",
";",
"return",
"sprintf",
"(",
"'%s %s'",
",",
"$",
"labelSelector",
",",
"$",
"errorContainerSelector",
")",
";",
"}"
] | Returns selector of field's validation error
@param string $formName Name of form (value of the "name" attribute)
@param string $fieldId ID of field (value of the "id" attribute)
@return string | [
"Returns",
"selector",
"of",
"field",
"s",
"validation",
"error"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Bootstrap4CssSelector.php#L36-L47 |
36,537 | meritoo/common-library | src/Utilities/Bootstrap4CssSelector.php | Bootstrap4CssSelector.getRadioButtonErrorSelector | public static function getRadioButtonErrorSelector($formName, $fieldSetIndex)
{
$fieldSetSelector = CssSelector::getFieldSetByIndexSelector($formName, $fieldSetIndex);
if (empty($fieldSetSelector)) {
return '';
}
$errorContainerSelector = static::getFieldErrorContainerSelector();
return sprintf('%s legend.col-form-label %s', $fieldSetSelector, $errorContainerSelector);
} | php | public static function getRadioButtonErrorSelector($formName, $fieldSetIndex)
{
$fieldSetSelector = CssSelector::getFieldSetByIndexSelector($formName, $fieldSetIndex);
if (empty($fieldSetSelector)) {
return '';
}
$errorContainerSelector = static::getFieldErrorContainerSelector();
return sprintf('%s legend.col-form-label %s', $fieldSetSelector, $errorContainerSelector);
} | [
"public",
"static",
"function",
"getRadioButtonErrorSelector",
"(",
"$",
"formName",
",",
"$",
"fieldSetIndex",
")",
"{",
"$",
"fieldSetSelector",
"=",
"CssSelector",
"::",
"getFieldSetByIndexSelector",
"(",
"$",
"formName",
",",
"$",
"fieldSetIndex",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fieldSetSelector",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"errorContainerSelector",
"=",
"static",
"::",
"getFieldErrorContainerSelector",
"(",
")",
";",
"return",
"sprintf",
"(",
"'%s legend.col-form-label %s'",
",",
"$",
"fieldSetSelector",
",",
"$",
"errorContainerSelector",
")",
";",
"}"
] | Returns selector of radio-button's validation error
@param string $formName Name of form (value of the "name" attribute)
@param int $fieldSetIndex Index/Position of the field-set
@return string | [
"Returns",
"selector",
"of",
"radio",
"-",
"button",
"s",
"validation",
"error"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Bootstrap4CssSelector.php#L56-L67 |
36,538 | meritoo/common-library | src/Utilities/Bootstrap4CssSelector.php | Bootstrap4CssSelector.getFieldGroupSelector | public static function getFieldGroupSelector($formName)
{
$formSelector = CssSelector::getFormByNameSelector($formName);
if (empty($formSelector)) {
return '';
}
return sprintf('%s .form-group', $formSelector);
} | php | public static function getFieldGroupSelector($formName)
{
$formSelector = CssSelector::getFormByNameSelector($formName);
if (empty($formSelector)) {
return '';
}
return sprintf('%s .form-group', $formSelector);
} | [
"public",
"static",
"function",
"getFieldGroupSelector",
"(",
"$",
"formName",
")",
"{",
"$",
"formSelector",
"=",
"CssSelector",
"::",
"getFormByNameSelector",
"(",
"$",
"formName",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"formSelector",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"sprintf",
"(",
"'%s .form-group'",
",",
"$",
"formSelector",
")",
";",
"}"
] | Returns selector of field's group
@param string $formName Name of form (value of the "name" attribute)
@return string | [
"Returns",
"selector",
"of",
"field",
"s",
"group"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Bootstrap4CssSelector.php#L75-L84 |
36,539 | CeusMedia/Common | src/Alg/Search/Binary.php | Alg_Search_Binary.search | public function search( $list, $search, $pos = 0 )
{
$size = sizeof( $list );
if( $size == 1 )
{
if( $list[0] == $search )
return $list[0];
else
return -1;
}
else
{
$this->counter++;
$mid = floor( $size / 2 );
if( $search < $list[$mid] )
{
$list = array_slice( $list, 0, $mid );
return $this->search( $list, $search, $pos );
}
else
{
$list = array_slice( $list, $mid );
return $this->search( $list, $search, $pos );
}
}
} | php | public function search( $list, $search, $pos = 0 )
{
$size = sizeof( $list );
if( $size == 1 )
{
if( $list[0] == $search )
return $list[0];
else
return -1;
}
else
{
$this->counter++;
$mid = floor( $size / 2 );
if( $search < $list[$mid] )
{
$list = array_slice( $list, 0, $mid );
return $this->search( $list, $search, $pos );
}
else
{
$list = array_slice( $list, $mid );
return $this->search( $list, $search, $pos );
}
}
} | [
"public",
"function",
"search",
"(",
"$",
"list",
",",
"$",
"search",
",",
"$",
"pos",
"=",
"0",
")",
"{",
"$",
"size",
"=",
"sizeof",
"(",
"$",
"list",
")",
";",
"if",
"(",
"$",
"size",
"==",
"1",
")",
"{",
"if",
"(",
"$",
"list",
"[",
"0",
"]",
"==",
"$",
"search",
")",
"return",
"$",
"list",
"[",
"0",
"]",
";",
"else",
"return",
"-",
"1",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"counter",
"++",
";",
"$",
"mid",
"=",
"floor",
"(",
"$",
"size",
"/",
"2",
")",
";",
"if",
"(",
"$",
"search",
"<",
"$",
"list",
"[",
"$",
"mid",
"]",
")",
"{",
"$",
"list",
"=",
"array_slice",
"(",
"$",
"list",
",",
"0",
",",
"$",
"mid",
")",
";",
"return",
"$",
"this",
"->",
"search",
"(",
"$",
"list",
",",
"$",
"search",
",",
"$",
"pos",
")",
";",
"}",
"else",
"{",
"$",
"list",
"=",
"array_slice",
"(",
"$",
"list",
",",
"$",
"mid",
")",
";",
"return",
"$",
"this",
"->",
"search",
"(",
"$",
"list",
",",
"$",
"search",
",",
"$",
"pos",
")",
";",
"}",
"}",
"}"
] | Searches in List and returns position if found, else 0.
@access public
@param array $list List to search in
@param mixed $search Element to search
@param int $pos Position (initial = 0)
@return int | [
"Searches",
"in",
"List",
"and",
"returns",
"position",
"if",
"found",
"else",
"0",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Search/Binary.php#L51-L76 |
36,540 | CeusMedia/Common | src/Net/CURL.php | Net_CURL.exec | public function exec( $breakOnError = FALSE, $parseHeaders = TRUE )
{
$url = $this->getOption( CURLOPT_URL );
if( empty( $url ) )
throw new RuntimeException( 'No URL set.' );
if( !preg_match( "@[a-z]+://[a-z0-9]+.+@i", $url ) )
throw new InvalidArgumentException( 'URL "'.$url.'" has no valid protocol' );
$result = curl_exec( $this->handle );
$this->info = curl_getinfo( $this->handle );
$this->info['errno'] = curl_errno( $this->handle );
$this->info['error'] = curl_error( $this->handle );
if( $breakOnError && $this->info['errno'] )
throw new RuntimeException( $this->info['error'], $this->info['errno'] );
if( $this->getOption( CURLOPT_HEADER ) && $parseHeaders )
{
# $result = preg_replace( "@^HTTP/1\.1 100 Continue\r\n\r\n@", "", $result ); // Hack: remove "100 Continue"
$header = mb_substr( $result, 0, $this->info['header_size'] );
$result = mb_substr( $result, $this->info['header_size'] );
$this->parseHeaderSection( $header ); // parse Header Block
}
return $result;
} | php | public function exec( $breakOnError = FALSE, $parseHeaders = TRUE )
{
$url = $this->getOption( CURLOPT_URL );
if( empty( $url ) )
throw new RuntimeException( 'No URL set.' );
if( !preg_match( "@[a-z]+://[a-z0-9]+.+@i", $url ) )
throw new InvalidArgumentException( 'URL "'.$url.'" has no valid protocol' );
$result = curl_exec( $this->handle );
$this->info = curl_getinfo( $this->handle );
$this->info['errno'] = curl_errno( $this->handle );
$this->info['error'] = curl_error( $this->handle );
if( $breakOnError && $this->info['errno'] )
throw new RuntimeException( $this->info['error'], $this->info['errno'] );
if( $this->getOption( CURLOPT_HEADER ) && $parseHeaders )
{
# $result = preg_replace( "@^HTTP/1\.1 100 Continue\r\n\r\n@", "", $result ); // Hack: remove "100 Continue"
$header = mb_substr( $result, 0, $this->info['header_size'] );
$result = mb_substr( $result, $this->info['header_size'] );
$this->parseHeaderSection( $header ); // parse Header Block
}
return $result;
} | [
"public",
"function",
"exec",
"(",
"$",
"breakOnError",
"=",
"FALSE",
",",
"$",
"parseHeaders",
"=",
"TRUE",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getOption",
"(",
"CURLOPT_URL",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No URL set.'",
")",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"@[a-z]+://[a-z0-9]+.+@i\"",
",",
"$",
"url",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'URL \"'",
".",
"$",
"url",
".",
"'\" has no valid protocol'",
")",
";",
"$",
"result",
"=",
"curl_exec",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"$",
"this",
"->",
"info",
"=",
"curl_getinfo",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"$",
"this",
"->",
"info",
"[",
"'errno'",
"]",
"=",
"curl_errno",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"$",
"this",
"->",
"info",
"[",
"'error'",
"]",
"=",
"curl_error",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"if",
"(",
"$",
"breakOnError",
"&&",
"$",
"this",
"->",
"info",
"[",
"'errno'",
"]",
")",
"throw",
"new",
"RuntimeException",
"(",
"$",
"this",
"->",
"info",
"[",
"'error'",
"]",
",",
"$",
"this",
"->",
"info",
"[",
"'errno'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"CURLOPT_HEADER",
")",
"&&",
"$",
"parseHeaders",
")",
"{",
"#\t\t\t$result\t= preg_replace( \"@^HTTP/1\\.1 100 Continue\\r\\n\\r\\n@\", \"\", $result );\t\t\t\t// Hack: remove \"100 Continue\"",
"$",
"header",
"=",
"mb_substr",
"(",
"$",
"result",
",",
"0",
",",
"$",
"this",
"->",
"info",
"[",
"'header_size'",
"]",
")",
";",
"$",
"result",
"=",
"mb_substr",
"(",
"$",
"result",
",",
"$",
"this",
"->",
"info",
"[",
"'header_size'",
"]",
")",
";",
"$",
"this",
"->",
"parseHeaderSection",
"(",
"$",
"header",
")",
";",
"// parse Header Block",
"}",
"return",
"$",
"result",
";",
"}"
] | Execute the cURL request and return the result.
@access public
@param bool $breakOnError Flag: throw an Exception if a Error has occured
@return string
@link http://www.php.net/curl_exec
@link http://www.php.net/curl_getinfo
@link http://www.php.net/curl_errno
@link http://www.php.net/curl_error | [
"Execute",
"the",
"cURL",
"request",
"and",
"return",
"the",
"result",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L159-L182 |
36,541 | CeusMedia/Common | src/Net/CURL.php | Net_CURL.getHeader | public function getHeader( $key = NULL )
{
if( empty( $key ) )
return $this->header;
else
{
$key = strtoupper( $key );
if( isset( $this->caseless[$key] ) )
return $this->header[$this->caseless[$key]];
else
return NULL;
}
} | php | public function getHeader( $key = NULL )
{
if( empty( $key ) )
return $this->header;
else
{
$key = strtoupper( $key );
if( isset( $this->caseless[$key] ) )
return $this->header[$this->caseless[$key]];
else
return NULL;
}
} | [
"public",
"function",
"getHeader",
"(",
"$",
"key",
"=",
"NULL",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"return",
"$",
"this",
"->",
"header",
";",
"else",
"{",
"$",
"key",
"=",
"strtoupper",
"(",
"$",
"key",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"caseless",
"[",
"$",
"key",
"]",
")",
")",
"return",
"$",
"this",
"->",
"header",
"[",
"$",
"this",
"->",
"caseless",
"[",
"$",
"key",
"]",
"]",
";",
"else",
"return",
"NULL",
";",
"}",
"}"
] | Returns the parsed HTTP header.
@access public
@param string $key Key name of Header Information
@return mixed | [
"Returns",
"the",
"parsed",
"HTTP",
"header",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L190-L202 |
36,542 | CeusMedia/Common | src/Net/CURL.php | Net_CURL.getInfo | public function getInfo( $key = NULL )
{
if( !$this->info )
throw new RuntimeException( "No Request has been sent, yet." );
if( empty( $key ) )
return $this->info;
else if( isset( $this->info[$key] ) )
return $this->info[$key];
else
return NULL;
} | php | public function getInfo( $key = NULL )
{
if( !$this->info )
throw new RuntimeException( "No Request has been sent, yet." );
if( empty( $key ) )
return $this->info;
else if( isset( $this->info[$key] ) )
return $this->info[$key];
else
return NULL;
} | [
"public",
"function",
"getInfo",
"(",
"$",
"key",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"info",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"No Request has been sent, yet.\"",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"return",
"$",
"this",
"->",
"info",
";",
"else",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"$",
"key",
"]",
")",
")",
"return",
"$",
"this",
"->",
"info",
"[",
"$",
"key",
"]",
";",
"else",
"return",
"NULL",
";",
"}"
] | Return the information of the last cURL request.
@access public
@param string $key Key name of Information
@return mixed | [
"Return",
"the",
"information",
"of",
"the",
"last",
"cURL",
"request",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L227-L237 |
36,543 | CeusMedia/Common | src/Net/CURL.php | Net_CURL.hasError | public function hasError()
{
if( isset( $this->info['error'] ) )
return ( empty( $this->info['error'] ) ? NULL : $this->info['error'] );
else
return NULL;
} | php | public function hasError()
{
if( isset( $this->info['error'] ) )
return ( empty( $this->info['error'] ) ? NULL : $this->info['error'] );
else
return NULL;
} | [
"public",
"function",
"hasError",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"info",
"[",
"'error'",
"]",
")",
")",
"return",
"(",
"empty",
"(",
"$",
"this",
"->",
"info",
"[",
"'error'",
"]",
")",
"?",
"NULL",
":",
"$",
"this",
"->",
"info",
"[",
"'error'",
"]",
")",
";",
"else",
"return",
"NULL",
";",
"}"
] | Did the last cURL exec operation have an error?
@access public
@return mixed | [
"Did",
"the",
"last",
"cURL",
"exec",
"operation",
"have",
"an",
"error?"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L244-L250 |
36,544 | CeusMedia/Common | src/Net/CURL.php | Net_CURL.parseHeaderSection | protected function parseHeaderSection( $section )
{
$this->header = NULL;
$this->caseless = array();
$headers = preg_split( "/(\r\n)+/", $section );
foreach( $headers as $header )
{
if( !( trim( $header ) && !preg_match( '/^HTTP/', $header ) ) )
continue;
$pair = preg_split( "/\s*:\s*/", $header, 2 );
$caselessTag = strtoupper( $pair[0] );
if( !isset( $this->caseless[$caselessTag] ) )
$this->caseless[$caselessTag] = $pair[0];
$this->header[$this->caseless[$caselessTag]][] = $pair[1];
}
} | php | protected function parseHeaderSection( $section )
{
$this->header = NULL;
$this->caseless = array();
$headers = preg_split( "/(\r\n)+/", $section );
foreach( $headers as $header )
{
if( !( trim( $header ) && !preg_match( '/^HTTP/', $header ) ) )
continue;
$pair = preg_split( "/\s*:\s*/", $header, 2 );
$caselessTag = strtoupper( $pair[0] );
if( !isset( $this->caseless[$caselessTag] ) )
$this->caseless[$caselessTag] = $pair[0];
$this->header[$this->caseless[$caselessTag]][] = $pair[1];
}
} | [
"protected",
"function",
"parseHeaderSection",
"(",
"$",
"section",
")",
"{",
"$",
"this",
"->",
"header",
"=",
"NULL",
";",
"$",
"this",
"->",
"caseless",
"=",
"array",
"(",
")",
";",
"$",
"headers",
"=",
"preg_split",
"(",
"\"/(\\r\\n)+/\"",
",",
"$",
"section",
")",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"!",
"(",
"trim",
"(",
"$",
"header",
")",
"&&",
"!",
"preg_match",
"(",
"'/^HTTP/'",
",",
"$",
"header",
")",
")",
")",
"continue",
";",
"$",
"pair",
"=",
"preg_split",
"(",
"\"/\\s*:\\s*/\"",
",",
"$",
"header",
",",
"2",
")",
";",
"$",
"caselessTag",
"=",
"strtoupper",
"(",
"$",
"pair",
"[",
"0",
"]",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"caseless",
"[",
"$",
"caselessTag",
"]",
")",
")",
"$",
"this",
"->",
"caseless",
"[",
"$",
"caselessTag",
"]",
"=",
"$",
"pair",
"[",
"0",
"]",
";",
"$",
"this",
"->",
"header",
"[",
"$",
"this",
"->",
"caseless",
"[",
"$",
"caselessTag",
"]",
"]",
"[",
"]",
"=",
"$",
"pair",
"[",
"1",
"]",
";",
"}",
"}"
] | Parse an HTTP header section.
As a side effect it stores the parsed header in the
header instance variable. The header is stored as
an associative array and the case of the headers
as provided by the server is preserved and all
repeated headers (pragma, set-cookie, etc) are grouped
with the first spelling for that header
that is seen.
All headers are stored as if they COULD be repeated, so
the headers are really stored as an array of arrays.
@access protected
@param string $section Section of HTTP headers
@return void | [
"Parse",
"an",
"HTTP",
"header",
"section",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L274-L289 |
36,545 | CeusMedia/Common | src/Net/CURL.php | Net_CURL.setOption | public function setOption( $option, $value )
{
if( is_string( $option ) && $option )
{
if( defined( $option ) )
$option = constant( $option );
else
throw new InvalidArgumentException( 'Invalid CURL option constant "'.$option.'"' );
}
// if( !curl_setopt( $this->handle, $option, $value ) )
// throw new InvalidArgumentException( "Option could not been set." );
curl_setopt( $this->handle, $option, $value );
$this->options[$option] = $value;
} | php | public function setOption( $option, $value )
{
if( is_string( $option ) && $option )
{
if( defined( $option ) )
$option = constant( $option );
else
throw new InvalidArgumentException( 'Invalid CURL option constant "'.$option.'"' );
}
// if( !curl_setopt( $this->handle, $option, $value ) )
// throw new InvalidArgumentException( "Option could not been set." );
curl_setopt( $this->handle, $option, $value );
$this->options[$option] = $value;
} | [
"public",
"function",
"setOption",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"option",
")",
"&&",
"$",
"option",
")",
"{",
"if",
"(",
"defined",
"(",
"$",
"option",
")",
")",
"$",
"option",
"=",
"constant",
"(",
"$",
"option",
")",
";",
"else",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid CURL option constant \"'",
".",
"$",
"option",
".",
"'\"'",
")",
";",
"}",
"//\t\tif( !curl_setopt( $this->handle, $option, $value ) )",
"//\t\t\tthrow new InvalidArgumentException( \"Option could not been set.\" );",
"curl_setopt",
"(",
"$",
"this",
"->",
"handle",
",",
"$",
"option",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"options",
"[",
"$",
"option",
"]",
"=",
"$",
"value",
";",
"}"
] | Set a cURL option.
@access public
@param mixed $option One of the valid CURLOPT defines.
@param mixed $value the value of the cURL option.
@return void
@link http://www.php.net/curl_setopt
@link http://www.php.net/manual/en/function.curl-setopt.php | [
"Set",
"a",
"cURL",
"option",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/CURL.php#L301-L314 |
36,546 | CeusMedia/Common | src/UI/HTML/MonthCalendar.php | UI_HTML_MonthCalendar.buildCalendar | public function buildCalendar( $cell_class = NULL, $heading_span = NULL )
{
$time = mktime( 0, 0, 0, $this->getOption( 'show_month'), 1, $this->getOption( 'show_year' ) );
$offset = date( 'w', $time )-1;
if( $offset < 0 )
$offset += 7;
$days = date( "t", $time );
$weeks = ceil( ( $days + $offset ) / 7 );
$d = 1;
$lines = array();
for( $w=0; $w<$weeks; $w++ )
{
$cells = array();
for( $i=0; $i<7; $i++ )
{
if( $offset )
{
$cells[] = $this->buildCell( 0, $cell_class );
$offset --;
}
else if( $d > $days )
$cells[] = $this->buildCell( 0, $cell_class );
else
{
$cells[] = $this->buildCell( $d, $cell_class );
$d++;
}
$line = implode( "", $cells );
}
$lines[] = UI_HTML_Tag::create( "div", $line, array( 'class' => 'day-week' ) );
}
$lines = implode( "\n\t ", $lines );
$days = UI_HTML_Tag::create( "div", $lines, array( 'class' => "days" ) );
$heading = $this->buildHeading( $heading_span );
$weekdays = $this->buildWeekDays();
$code = $this->getCode( $heading, $weekdays, $days );
return $code;
} | php | public function buildCalendar( $cell_class = NULL, $heading_span = NULL )
{
$time = mktime( 0, 0, 0, $this->getOption( 'show_month'), 1, $this->getOption( 'show_year' ) );
$offset = date( 'w', $time )-1;
if( $offset < 0 )
$offset += 7;
$days = date( "t", $time );
$weeks = ceil( ( $days + $offset ) / 7 );
$d = 1;
$lines = array();
for( $w=0; $w<$weeks; $w++ )
{
$cells = array();
for( $i=0; $i<7; $i++ )
{
if( $offset )
{
$cells[] = $this->buildCell( 0, $cell_class );
$offset --;
}
else if( $d > $days )
$cells[] = $this->buildCell( 0, $cell_class );
else
{
$cells[] = $this->buildCell( $d, $cell_class );
$d++;
}
$line = implode( "", $cells );
}
$lines[] = UI_HTML_Tag::create( "div", $line, array( 'class' => 'day-week' ) );
}
$lines = implode( "\n\t ", $lines );
$days = UI_HTML_Tag::create( "div", $lines, array( 'class' => "days" ) );
$heading = $this->buildHeading( $heading_span );
$weekdays = $this->buildWeekDays();
$code = $this->getCode( $heading, $weekdays, $days );
return $code;
} | [
"public",
"function",
"buildCalendar",
"(",
"$",
"cell_class",
"=",
"NULL",
",",
"$",
"heading_span",
"=",
"NULL",
")",
"{",
"$",
"time",
"=",
"mktime",
"(",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"getOption",
"(",
"'show_month'",
")",
",",
"1",
",",
"$",
"this",
"->",
"getOption",
"(",
"'show_year'",
")",
")",
";",
"$",
"offset",
"=",
"date",
"(",
"'w'",
",",
"$",
"time",
")",
"-",
"1",
";",
"if",
"(",
"$",
"offset",
"<",
"0",
")",
"$",
"offset",
"+=",
"7",
";",
"$",
"days",
"=",
"date",
"(",
"\"t\"",
",",
"$",
"time",
")",
";",
"$",
"weeks",
"=",
"ceil",
"(",
"(",
"$",
"days",
"+",
"$",
"offset",
")",
"/",
"7",
")",
";",
"$",
"d",
"=",
"1",
";",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"w",
"=",
"0",
";",
"$",
"w",
"<",
"$",
"weeks",
";",
"$",
"w",
"++",
")",
"{",
"$",
"cells",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"7",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"cells",
"[",
"]",
"=",
"$",
"this",
"->",
"buildCell",
"(",
"0",
",",
"$",
"cell_class",
")",
";",
"$",
"offset",
"--",
";",
"}",
"else",
"if",
"(",
"$",
"d",
">",
"$",
"days",
")",
"$",
"cells",
"[",
"]",
"=",
"$",
"this",
"->",
"buildCell",
"(",
"0",
",",
"$",
"cell_class",
")",
";",
"else",
"{",
"$",
"cells",
"[",
"]",
"=",
"$",
"this",
"->",
"buildCell",
"(",
"$",
"d",
",",
"$",
"cell_class",
")",
";",
"$",
"d",
"++",
";",
"}",
"$",
"line",
"=",
"implode",
"(",
"\"\"",
",",
"$",
"cells",
")",
";",
"}",
"$",
"lines",
"[",
"]",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"line",
",",
"array",
"(",
"'class'",
"=>",
"'day-week'",
")",
")",
";",
"}",
"$",
"lines",
"=",
"implode",
"(",
"\"\\n\\t \"",
",",
"$",
"lines",
")",
";",
"$",
"days",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"lines",
",",
"array",
"(",
"'class'",
"=>",
"\"days\"",
")",
")",
";",
"$",
"heading",
"=",
"$",
"this",
"->",
"buildHeading",
"(",
"$",
"heading_span",
")",
";",
"$",
"weekdays",
"=",
"$",
"this",
"->",
"buildWeekDays",
"(",
")",
";",
"$",
"code",
"=",
"$",
"this",
"->",
"getCode",
"(",
"$",
"heading",
",",
"$",
"weekdays",
",",
"$",
"days",
")",
";",
"return",
"$",
"code",
";",
"}"
] | Builds Output of Month Calendar.
@access public
@param string $cell_class CSS Class of Cell
@param bool $heading_span Flag: Span Heading over whole Table
@return string | [
"Builds",
"Output",
"of",
"Month",
"Calendar",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L102-L139 |
36,547 | CeusMedia/Common | src/UI/HTML/MonthCalendar.php | UI_HTML_MonthCalendar.buildCell | protected function buildCell( $day, $class = "")
{
$classes = array( 'day' );
if( $this->getOption( 'current_year' ) == $this->getOption( 'show_year' ) &&
$this->getOption( 'current_month' ) == $this->getOption( 'show_month' ) &&
$this->getOption( 'current_day' ) == $day )
$classes[] = 'current';
if( $class )
$classes[] = $class;
if( $day )
{
$content = $this->modifyDay( $day );
$day = $content['day'];
if( isset( $content['class'] ) && $content['class'] )
$classes[] = $content['class'];
}
else
$day = " ";
$code = UI_HTML_Tag::create( "div", $day, array( 'class' => implode( " ", $classes ) ) );
return $code;
} | php | protected function buildCell( $day, $class = "")
{
$classes = array( 'day' );
if( $this->getOption( 'current_year' ) == $this->getOption( 'show_year' ) &&
$this->getOption( 'current_month' ) == $this->getOption( 'show_month' ) &&
$this->getOption( 'current_day' ) == $day )
$classes[] = 'current';
if( $class )
$classes[] = $class;
if( $day )
{
$content = $this->modifyDay( $day );
$day = $content['day'];
if( isset( $content['class'] ) && $content['class'] )
$classes[] = $content['class'];
}
else
$day = " ";
$code = UI_HTML_Tag::create( "div", $day, array( 'class' => implode( " ", $classes ) ) );
return $code;
} | [
"protected",
"function",
"buildCell",
"(",
"$",
"day",
",",
"$",
"class",
"=",
"\"\"",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
"'day'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'current_year'",
")",
"==",
"$",
"this",
"->",
"getOption",
"(",
"'show_year'",
")",
"&&",
"$",
"this",
"->",
"getOption",
"(",
"'current_month'",
")",
"==",
"$",
"this",
"->",
"getOption",
"(",
"'show_month'",
")",
"&&",
"$",
"this",
"->",
"getOption",
"(",
"'current_day'",
")",
"==",
"$",
"day",
")",
"$",
"classes",
"[",
"]",
"=",
"'current'",
";",
"if",
"(",
"$",
"class",
")",
"$",
"classes",
"[",
"]",
"=",
"$",
"class",
";",
"if",
"(",
"$",
"day",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"modifyDay",
"(",
"$",
"day",
")",
";",
"$",
"day",
"=",
"$",
"content",
"[",
"'day'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"content",
"[",
"'class'",
"]",
")",
"&&",
"$",
"content",
"[",
"'class'",
"]",
")",
"$",
"classes",
"[",
"]",
"=",
"$",
"content",
"[",
"'class'",
"]",
";",
"}",
"else",
"$",
"day",
"=",
"\" \"",
";",
"$",
"code",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"day",
",",
"array",
"(",
"'class'",
"=>",
"implode",
"(",
"\" \"",
",",
"$",
"classes",
")",
")",
")",
";",
"return",
"$",
"code",
";",
"}"
] | Builds Table Cell for one Day.
@access protected
@param int $day Number of Day
@param string $class Class of Cell
@return string | [
"Builds",
"Table",
"Cell",
"for",
"one",
"Day",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L148-L168 |
36,548 | CeusMedia/Common | src/UI/HTML/MonthCalendar.php | UI_HTML_MonthCalendar.buildHeading | protected function buildHeading( $span = NULL )
{
$month = (int) $this->getOption( 'show_month' );
$year = (int) $this->getOption( 'show_year' );
$prev_month = $month - 1;
$next_month = $month + 1;
$prev_year = $next_year = $year;
$month = $this->months[$month - 1];
if( $prev_month < 1 )
{
$prev_month = 12;
$prev_year--;
}
else if( $next_month > 12 )
{
$next_month = 1;
$next_year++;
}
$colspan = "";
if( $span )
$colspan = " colspan='5'";
$url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$prev_year."&".$this->getOption( 'carrier_month' )."=".$prev_month;
$prev = UI_HTML_Elements::Link( $url, "<" );
$url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$next_year."&".$this->getOption( 'carrier_month' )."=".$next_month;
$next = UI_HTML_Elements::Link( $url, ">" );
$left = UI_HTML_Tag::create( "div", $prev, array( 'class' => "go-left" ) );
$right = UI_HTML_Tag::create( "div", $next, array( 'class' => "go-right" ) );
$label = UI_HTML_Tag::create( "div", htmlspecialchars( $month ).' '.$year, array( 'class' => "label" ) );
$code = UI_HTML_Tag::create( "div", $left.$label.$right, array( 'class' => 'month' ) );
return $code;
} | php | protected function buildHeading( $span = NULL )
{
$month = (int) $this->getOption( 'show_month' );
$year = (int) $this->getOption( 'show_year' );
$prev_month = $month - 1;
$next_month = $month + 1;
$prev_year = $next_year = $year;
$month = $this->months[$month - 1];
if( $prev_month < 1 )
{
$prev_month = 12;
$prev_year--;
}
else if( $next_month > 12 )
{
$next_month = 1;
$next_year++;
}
$colspan = "";
if( $span )
$colspan = " colspan='5'";
$url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$prev_year."&".$this->getOption( 'carrier_month' )."=".$prev_month;
$prev = UI_HTML_Elements::Link( $url, "<" );
$url = $this->getOption( 'url' )."&".$this->getOption( 'carrier_year' )."=".$next_year."&".$this->getOption( 'carrier_month' )."=".$next_month;
$next = UI_HTML_Elements::Link( $url, ">" );
$left = UI_HTML_Tag::create( "div", $prev, array( 'class' => "go-left" ) );
$right = UI_HTML_Tag::create( "div", $next, array( 'class' => "go-right" ) );
$label = UI_HTML_Tag::create( "div", htmlspecialchars( $month ).' '.$year, array( 'class' => "label" ) );
$code = UI_HTML_Tag::create( "div", $left.$label.$right, array( 'class' => 'month' ) );
return $code;
} | [
"protected",
"function",
"buildHeading",
"(",
"$",
"span",
"=",
"NULL",
")",
"{",
"$",
"month",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"getOption",
"(",
"'show_month'",
")",
";",
"$",
"year",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"getOption",
"(",
"'show_year'",
")",
";",
"$",
"prev_month",
"=",
"$",
"month",
"-",
"1",
";",
"$",
"next_month",
"=",
"$",
"month",
"+",
"1",
";",
"$",
"prev_year",
"=",
"$",
"next_year",
"=",
"$",
"year",
";",
"$",
"month",
"=",
"$",
"this",
"->",
"months",
"[",
"$",
"month",
"-",
"1",
"]",
";",
"if",
"(",
"$",
"prev_month",
"<",
"1",
")",
"{",
"$",
"prev_month",
"=",
"12",
";",
"$",
"prev_year",
"--",
";",
"}",
"else",
"if",
"(",
"$",
"next_month",
">",
"12",
")",
"{",
"$",
"next_month",
"=",
"1",
";",
"$",
"next_year",
"++",
";",
"}",
"$",
"colspan",
"=",
"\"\"",
";",
"if",
"(",
"$",
"span",
")",
"$",
"colspan",
"=",
"\" colspan='5'\"",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'url'",
")",
".",
"\"&\"",
".",
"$",
"this",
"->",
"getOption",
"(",
"'carrier_year'",
")",
".",
"\"=\"",
".",
"$",
"prev_year",
".",
"\"&\"",
".",
"$",
"this",
"->",
"getOption",
"(",
"'carrier_month'",
")",
".",
"\"=\"",
".",
"$",
"prev_month",
";",
"$",
"prev",
"=",
"UI_HTML_Elements",
"::",
"Link",
"(",
"$",
"url",
",",
"\"<\"",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'url'",
")",
".",
"\"&\"",
".",
"$",
"this",
"->",
"getOption",
"(",
"'carrier_year'",
")",
".",
"\"=\"",
".",
"$",
"next_year",
".",
"\"&\"",
".",
"$",
"this",
"->",
"getOption",
"(",
"'carrier_month'",
")",
".",
"\"=\"",
".",
"$",
"next_month",
";",
"$",
"next",
"=",
"UI_HTML_Elements",
"::",
"Link",
"(",
"$",
"url",
",",
"\">\"",
")",
";",
"$",
"left",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"prev",
",",
"array",
"(",
"'class'",
"=>",
"\"go-left\"",
")",
")",
";",
"$",
"right",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"next",
",",
"array",
"(",
"'class'",
"=>",
"\"go-right\"",
")",
")",
";",
"$",
"label",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"htmlspecialchars",
"(",
"$",
"month",
")",
".",
"' '",
".",
"$",
"year",
",",
"array",
"(",
"'class'",
"=>",
"\"label\"",
")",
")",
";",
"$",
"code",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"left",
".",
"$",
"label",
".",
"$",
"right",
",",
"array",
"(",
"'class'",
"=>",
"'month'",
")",
")",
";",
"return",
"$",
"code",
";",
"}"
] | Builds Table Heading with Month, Year and Links for Selection.
@access protected
@param int $day Number of Day
@param string $class Class of Cell
@return string | [
"Builds",
"Table",
"Heading",
"with",
"Month",
"Year",
"and",
"Links",
"for",
"Selection",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L177-L209 |
36,549 | CeusMedia/Common | src/UI/HTML/MonthCalendar.php | UI_HTML_MonthCalendar.buildWeekDays | protected function buildWeekDays()
{
foreach( $this->days as $day )
$days[] = UI_HTML_Tag::create( "div", $day, array( 'class' => "weekday" ) );
$days = implode( "", $days );
$code = UI_HTML_Tag::create( "div", $days, array( 'class' => "weekdays" ) );
return $code;
} | php | protected function buildWeekDays()
{
foreach( $this->days as $day )
$days[] = UI_HTML_Tag::create( "div", $day, array( 'class' => "weekday" ) );
$days = implode( "", $days );
$code = UI_HTML_Tag::create( "div", $days, array( 'class' => "weekdays" ) );
return $code;
} | [
"protected",
"function",
"buildWeekDays",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"days",
"as",
"$",
"day",
")",
"$",
"days",
"[",
"]",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"day",
",",
"array",
"(",
"'class'",
"=>",
"\"weekday\"",
")",
")",
";",
"$",
"days",
"=",
"implode",
"(",
"\"\"",
",",
"$",
"days",
")",
";",
"$",
"code",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"div\"",
",",
"$",
"days",
",",
"array",
"(",
"'class'",
"=>",
"\"weekdays\"",
")",
")",
";",
"return",
"$",
"code",
";",
"}"
] | Builds Table Row with Week Days.
@access protected
@return string | [
"Builds",
"Table",
"Row",
"with",
"Week",
"Days",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L216-L223 |
36,550 | CeusMedia/Common | src/UI/HTML/MonthCalendar.php | UI_HTML_MonthCalendar.getCode | protected function getCode( $heading, $weekdays, $weeks )
{
if( $template = $this->getOption( 'template' ) )
{
$options = $this->getOptions();
require( $template );
}
else
{
$clearFix = UI_HTML_Tag::create( 'div', "", array( 'style' => 'clear: both' ) );
$content = UI_HTML_Tag::create( 'div', $heading.$weekdays.$weeks.$clearFix, array( 'class' => 'calendar' ) );
}
return $content;
} | php | protected function getCode( $heading, $weekdays, $weeks )
{
if( $template = $this->getOption( 'template' ) )
{
$options = $this->getOptions();
require( $template );
}
else
{
$clearFix = UI_HTML_Tag::create( 'div', "", array( 'style' => 'clear: both' ) );
$content = UI_HTML_Tag::create( 'div', $heading.$weekdays.$weeks.$clearFix, array( 'class' => 'calendar' ) );
}
return $content;
} | [
"protected",
"function",
"getCode",
"(",
"$",
"heading",
",",
"$",
"weekdays",
",",
"$",
"weeks",
")",
"{",
"if",
"(",
"$",
"template",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'template'",
")",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
";",
"require",
"(",
"$",
"template",
")",
";",
"}",
"else",
"{",
"$",
"clearFix",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'div'",
",",
"\"\"",
",",
"array",
"(",
"'style'",
"=>",
"'clear: both'",
")",
")",
";",
"$",
"content",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'div'",
",",
"$",
"heading",
".",
"$",
"weekdays",
".",
"$",
"weeks",
".",
"$",
"clearFix",
",",
"array",
"(",
"'class'",
"=>",
"'calendar'",
")",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] | Builds Output Code by loading a Template or with built-in Template.
@access protected
@param string $heading Table Row of Heading
@param string $weekdays Table Row of Weekdays
@param string $weeks Table Rows of Weeks
@return string | [
"Builds",
"Output",
"Code",
"by",
"loading",
"a",
"Template",
"or",
"with",
"built",
"-",
"in",
"Template",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/MonthCalendar.php#L233-L246 |
36,551 | CeusMedia/Common | src/FS/Folder/Lister.php | FS_Folder_Lister.setExtensions | public function setExtensions( $extensions = array() )
{
if( !is_array( $extensions ) )
throw new InvalidArgumentException( 'Extensions must be given as Array.' );
$pattern = "";
if( count( $extensions ) )
{
$extensions = implode( "|", array_values( $extensions ) );
$pattern = '@\.'.$extensions.'$@i';
}
$this->pattern = $pattern;
} | php | public function setExtensions( $extensions = array() )
{
if( !is_array( $extensions ) )
throw new InvalidArgumentException( 'Extensions must be given as Array.' );
$pattern = "";
if( count( $extensions ) )
{
$extensions = implode( "|", array_values( $extensions ) );
$pattern = '@\.'.$extensions.'$@i';
}
$this->pattern = $pattern;
} | [
"public",
"function",
"setExtensions",
"(",
"$",
"extensions",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"extensions",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Extensions must be given as Array.'",
")",
";",
"$",
"pattern",
"=",
"\"\"",
";",
"if",
"(",
"count",
"(",
"$",
"extensions",
")",
")",
"{",
"$",
"extensions",
"=",
"implode",
"(",
"\"|\"",
",",
"array_values",
"(",
"$",
"extensions",
")",
")",
";",
"$",
"pattern",
"=",
"'@\\.'",
".",
"$",
"extensions",
".",
"'$@i'",
";",
"}",
"$",
"this",
"->",
"pattern",
"=",
"$",
"pattern",
";",
"}"
] | Sets Filter for Extensions.
Caution! Method overwrites Pattern if already set.
Caution! Flag 'showFiles' needs to be set to TRUE.
@access public
@param array $extensions List of allowed File Extensions.
@return void | [
"Sets",
"Filter",
"for",
"Extensions",
".",
"Caution!",
"Method",
"overwrites",
"Pattern",
"if",
"already",
"set",
".",
"Caution!",
"Flag",
"showFiles",
"needs",
"to",
"be",
"set",
"to",
"TRUE",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Lister.php#L160-L172 |
36,552 | CeusMedia/Common | src/Net/HTTP/Request.php | Net_HTTP_Request.getUrl | public function getUrl( $absolute = TRUE ){
$url = new ADT_URL( getEnv( 'REQUEST_URI' ) );
if( $absolute ){
$url->setScheme( getEnv( 'REQUEST_SCHEME' ) );
$url->setHost( getEnv( 'HTTP_HOST' ) );
}
return $url;
} | php | public function getUrl( $absolute = TRUE ){
$url = new ADT_URL( getEnv( 'REQUEST_URI' ) );
if( $absolute ){
$url->setScheme( getEnv( 'REQUEST_SCHEME' ) );
$url->setHost( getEnv( 'HTTP_HOST' ) );
}
return $url;
} | [
"public",
"function",
"getUrl",
"(",
"$",
"absolute",
"=",
"TRUE",
")",
"{",
"$",
"url",
"=",
"new",
"ADT_URL",
"(",
"getEnv",
"(",
"'REQUEST_URI'",
")",
")",
";",
"if",
"(",
"$",
"absolute",
")",
"{",
"$",
"url",
"->",
"setScheme",
"(",
"getEnv",
"(",
"'REQUEST_SCHEME'",
")",
")",
";",
"$",
"url",
"->",
"setHost",
"(",
"getEnv",
"(",
"'HTTP_HOST'",
")",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Get requested URL, relative of absolute.
@access public
@param boolean $absolute Flag: return absolute URL
@return ADT_URL | [
"Get",
"requested",
"URL",
"relative",
"of",
"absolute",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request.php#L276-L283 |
36,553 | CeusMedia/Common | src/Net/HTTP/Request.php | Net_HTTP_Request.isMethod | public function isMethod( $method )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.4.7' )
->setExceptionVersion( '0.9' )
->message( 'Please use $request->getMethod()->is( $method ) instead' );
return $this->method->is( $method );
} | php | public function isMethod( $method )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.4.7' )
->setExceptionVersion( '0.9' )
->message( 'Please use $request->getMethod()->is( $method ) instead' );
return $this->method->is( $method );
} | [
"public",
"function",
"isMethod",
"(",
"$",
"method",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.4.7'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"'Please use $request->getMethod()->is( $method ) instead'",
")",
";",
"return",
"$",
"this",
"->",
"method",
"->",
"is",
"(",
"$",
"method",
")",
";",
"}"
] | Indicate whether a specific request method is used.
Method parameter is not case sensitive.
@access public
@param string $method Request method to check against
@return boolean
@deprecated use request->getMethod()->is( $method ) instead | [
"Indicate",
"whether",
"a",
"specific",
"request",
"method",
"is",
"used",
".",
"Method",
"parameter",
"is",
"not",
"case",
"sensitive",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request.php#L311-L318 |
36,554 | railken/amethyst-invoice | src/Managers/InvoiceManager.php | InvoiceManager.issue | public function issue(Invoice $invoice)
{
$result = $this->update($invoice, [
'issued_at' => new \DateTime(),
'expires_at' => (new \DateTime())->modify('+1 month'),
'number' => $this->getNumberManager()->calculateNextFreeNumber(),
]);
$result->ok() && event(new Events\InvoiceIssued($invoice));
return $result;
} | php | public function issue(Invoice $invoice)
{
$result = $this->update($invoice, [
'issued_at' => new \DateTime(),
'expires_at' => (new \DateTime())->modify('+1 month'),
'number' => $this->getNumberManager()->calculateNextFreeNumber(),
]);
$result->ok() && event(new Events\InvoiceIssued($invoice));
return $result;
} | [
"public",
"function",
"issue",
"(",
"Invoice",
"$",
"invoice",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"update",
"(",
"$",
"invoice",
",",
"[",
"'issued_at'",
"=>",
"new",
"\\",
"DateTime",
"(",
")",
",",
"'expires_at'",
"=>",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"modify",
"(",
"'+1 month'",
")",
",",
"'number'",
"=>",
"$",
"this",
"->",
"getNumberManager",
"(",
")",
"->",
"calculateNextFreeNumber",
"(",
")",
",",
"]",
")",
";",
"$",
"result",
"->",
"ok",
"(",
")",
"&&",
"event",
"(",
"new",
"Events",
"\\",
"InvoiceIssued",
"(",
"$",
"invoice",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Issue an invoice.
@param Invoice $invoice
@return \Railken\Lem\Result | [
"Issue",
"an",
"invoice",
"."
] | 605cf27aaa82aea7328d5e5ae5f69b1e7e86120e | https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Managers/InvoiceManager.php#L34-L45 |
36,555 | nails/module-cron | cron/controllers/CronRouter.php | CronRouter.index | public function index()
{
// Command line only
$oInput = Factory::service('Input');
if (Environment::is(Environment::ENV_PROD) && !$oInput::isCli()) {
header($oInput->server('SERVER_PROTOCOL') . ' 401 Unauthorized');
echo '<h1>' . lang('unauthorised') . '</h1>';
exit(401);
}
// --------------------------------------------------------------------------
/**
* Look for a controller, app version first then the module's cron controllers directory
*/
$aControllerPaths = [
NAILS_APP_PATH . 'application/modules/cron/controllers/',
];
$nailsModules = Components::modules();
foreach ($nailsModules as $oModule) {
if ($oModule->moduleName === $this->sModuleName) {
$aControllerPaths[] = $oModule->path . 'cron/controllers/';
break;
}
}
// Look for a valid controller
$sControllerName = ucfirst($this->sClassName) . '.php';
$bDidfindController = false;
foreach ($aControllerPaths as $sPath) {
$sControllerPath = $sPath . $sControllerName;
if (is_file($sControllerPath)) {
$bDidfindController = true;
break;
}
}
if (!empty($bDidfindController)) {
// Load the file and try and execute the method
require_once $sControllerPath;
$this->sModuleName = 'Nails\\Cron\\' . ucfirst($this->sModuleName) . '\\' . ucfirst($this->sClassName);
if (class_exists($this->sModuleName)) {
// New instance of the controller
$oInstance = new $this->sModuleName($this);
if (is_callable([$oInstance, $this->sMethod])) {
// Begin timing
$this->writeLog('Starting job');
if (!empty($this->aParams)) {
$this->writeLog('Passed parameters');
$this->writeLog(print_r($this->aParams, true));
}
$iStart = microtime(true) * 10000;
call_user_func_array([$oInstance, $this->sMethod], $this->aParams);
$iEnd = microtime(true) * 10000;
$iDuration = ($iEnd - $iStart) / 10000;
$this->writeLog('Finished job');
$this->writeLog('Job took ' . number_format($iDuration, 5) . ' seconds');
} else {
$this->writeLog('Cannot call method "' . $this->sMethod . '"');
}
} else {
$this->writeLog(
'"' . $this->sModuleName . '" is incorrectly configured; could not find class ' . $this->sModuleName . ' at path ' . $sControllerPath
);
}
} else {
$this->writeLog(
'"' . $this->sModuleName . '/' . $this->sClassName . '/' . $this->sMethod . '" is not a valid route.'
);
}
} | php | public function index()
{
// Command line only
$oInput = Factory::service('Input');
if (Environment::is(Environment::ENV_PROD) && !$oInput::isCli()) {
header($oInput->server('SERVER_PROTOCOL') . ' 401 Unauthorized');
echo '<h1>' . lang('unauthorised') . '</h1>';
exit(401);
}
// --------------------------------------------------------------------------
/**
* Look for a controller, app version first then the module's cron controllers directory
*/
$aControllerPaths = [
NAILS_APP_PATH . 'application/modules/cron/controllers/',
];
$nailsModules = Components::modules();
foreach ($nailsModules as $oModule) {
if ($oModule->moduleName === $this->sModuleName) {
$aControllerPaths[] = $oModule->path . 'cron/controllers/';
break;
}
}
// Look for a valid controller
$sControllerName = ucfirst($this->sClassName) . '.php';
$bDidfindController = false;
foreach ($aControllerPaths as $sPath) {
$sControllerPath = $sPath . $sControllerName;
if (is_file($sControllerPath)) {
$bDidfindController = true;
break;
}
}
if (!empty($bDidfindController)) {
// Load the file and try and execute the method
require_once $sControllerPath;
$this->sModuleName = 'Nails\\Cron\\' . ucfirst($this->sModuleName) . '\\' . ucfirst($this->sClassName);
if (class_exists($this->sModuleName)) {
// New instance of the controller
$oInstance = new $this->sModuleName($this);
if (is_callable([$oInstance, $this->sMethod])) {
// Begin timing
$this->writeLog('Starting job');
if (!empty($this->aParams)) {
$this->writeLog('Passed parameters');
$this->writeLog(print_r($this->aParams, true));
}
$iStart = microtime(true) * 10000;
call_user_func_array([$oInstance, $this->sMethod], $this->aParams);
$iEnd = microtime(true) * 10000;
$iDuration = ($iEnd - $iStart) / 10000;
$this->writeLog('Finished job');
$this->writeLog('Job took ' . number_format($iDuration, 5) . ' seconds');
} else {
$this->writeLog('Cannot call method "' . $this->sMethod . '"');
}
} else {
$this->writeLog(
'"' . $this->sModuleName . '" is incorrectly configured; could not find class ' . $this->sModuleName . ' at path ' . $sControllerPath
);
}
} else {
$this->writeLog(
'"' . $this->sModuleName . '/' . $this->sClassName . '/' . $this->sMethod . '" is not a valid route.'
);
}
} | [
"public",
"function",
"index",
"(",
")",
"{",
"// Command line only",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"if",
"(",
"Environment",
"::",
"is",
"(",
"Environment",
"::",
"ENV_PROD",
")",
"&&",
"!",
"$",
"oInput",
"::",
"isCli",
"(",
")",
")",
"{",
"header",
"(",
"$",
"oInput",
"->",
"server",
"(",
"'SERVER_PROTOCOL'",
")",
".",
"' 401 Unauthorized'",
")",
";",
"echo",
"'<h1>'",
".",
"lang",
"(",
"'unauthorised'",
")",
".",
"'</h1>'",
";",
"exit",
"(",
"401",
")",
";",
"}",
"// --------------------------------------------------------------------------",
"/**\n * Look for a controller, app version first then the module's cron controllers directory\n */",
"$",
"aControllerPaths",
"=",
"[",
"NAILS_APP_PATH",
".",
"'application/modules/cron/controllers/'",
",",
"]",
";",
"$",
"nailsModules",
"=",
"Components",
"::",
"modules",
"(",
")",
";",
"foreach",
"(",
"$",
"nailsModules",
"as",
"$",
"oModule",
")",
"{",
"if",
"(",
"$",
"oModule",
"->",
"moduleName",
"===",
"$",
"this",
"->",
"sModuleName",
")",
"{",
"$",
"aControllerPaths",
"[",
"]",
"=",
"$",
"oModule",
"->",
"path",
".",
"'cron/controllers/'",
";",
"break",
";",
"}",
"}",
"// Look for a valid controller",
"$",
"sControllerName",
"=",
"ucfirst",
"(",
"$",
"this",
"->",
"sClassName",
")",
".",
"'.php'",
";",
"$",
"bDidfindController",
"=",
"false",
";",
"foreach",
"(",
"$",
"aControllerPaths",
"as",
"$",
"sPath",
")",
"{",
"$",
"sControllerPath",
"=",
"$",
"sPath",
".",
"$",
"sControllerName",
";",
"if",
"(",
"is_file",
"(",
"$",
"sControllerPath",
")",
")",
"{",
"$",
"bDidfindController",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"bDidfindController",
")",
")",
"{",
"// Load the file and try and execute the method",
"require_once",
"$",
"sControllerPath",
";",
"$",
"this",
"->",
"sModuleName",
"=",
"'Nails\\\\Cron\\\\'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"sModuleName",
")",
".",
"'\\\\'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"sClassName",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"this",
"->",
"sModuleName",
")",
")",
"{",
"// New instance of the controller",
"$",
"oInstance",
"=",
"new",
"$",
"this",
"->",
"sModuleName",
"(",
"$",
"this",
")",
";",
"if",
"(",
"is_callable",
"(",
"[",
"$",
"oInstance",
",",
"$",
"this",
"->",
"sMethod",
"]",
")",
")",
"{",
"// Begin timing",
"$",
"this",
"->",
"writeLog",
"(",
"'Starting job'",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"aParams",
")",
")",
"{",
"$",
"this",
"->",
"writeLog",
"(",
"'Passed parameters'",
")",
";",
"$",
"this",
"->",
"writeLog",
"(",
"print_r",
"(",
"$",
"this",
"->",
"aParams",
",",
"true",
")",
")",
";",
"}",
"$",
"iStart",
"=",
"microtime",
"(",
"true",
")",
"*",
"10000",
";",
"call_user_func_array",
"(",
"[",
"$",
"oInstance",
",",
"$",
"this",
"->",
"sMethod",
"]",
",",
"$",
"this",
"->",
"aParams",
")",
";",
"$",
"iEnd",
"=",
"microtime",
"(",
"true",
")",
"*",
"10000",
";",
"$",
"iDuration",
"=",
"(",
"$",
"iEnd",
"-",
"$",
"iStart",
")",
"/",
"10000",
";",
"$",
"this",
"->",
"writeLog",
"(",
"'Finished job'",
")",
";",
"$",
"this",
"->",
"writeLog",
"(",
"'Job took '",
".",
"number_format",
"(",
"$",
"iDuration",
",",
"5",
")",
".",
"' seconds'",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"writeLog",
"(",
"'Cannot call method \"'",
".",
"$",
"this",
"->",
"sMethod",
".",
"'\"'",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"writeLog",
"(",
"'\"'",
".",
"$",
"this",
"->",
"sModuleName",
".",
"'\" is incorrectly configured; could not find class '",
".",
"$",
"this",
"->",
"sModuleName",
".",
"' at path '",
".",
"$",
"sControllerPath",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"writeLog",
"(",
"'\"'",
".",
"$",
"this",
"->",
"sModuleName",
".",
"'/'",
".",
"$",
"this",
"->",
"sClassName",
".",
"'/'",
".",
"$",
"this",
"->",
"sMethod",
".",
"'\" is not a valid route.'",
")",
";",
"}",
"}"
] | Route the call to the correct place
@return Void | [
"Route",
"the",
"call",
"to",
"the",
"correct",
"place"
] | caa4560356517a57ee2ba3ce669b5f4cb7e50c34 | https://github.com/nails/module-cron/blob/caa4560356517a57ee2ba3ce669b5f4cb7e50c34/cron/controllers/CronRouter.php#L81-L174 |
36,556 | nails/module-cron | cron/controllers/CronRouter.php | CronRouter.writeLog | public function writeLog($sLine)
{
$this->oLogger->line(' [' . $this->sModuleName . '->' . $this->sMethod . '] ' . $sLine);
} | php | public function writeLog($sLine)
{
$this->oLogger->line(' [' . $this->sModuleName . '->' . $this->sMethod . '] ' . $sLine);
} | [
"public",
"function",
"writeLog",
"(",
"$",
"sLine",
")",
"{",
"$",
"this",
"->",
"oLogger",
"->",
"line",
"(",
"' ['",
".",
"$",
"this",
"->",
"sModuleName",
".",
"'->'",
".",
"$",
"this",
"->",
"sMethod",
".",
"'] '",
".",
"$",
"sLine",
")",
";",
"}"
] | Write a line to the cron log
@param string $sLine The line to write | [
"Write",
"a",
"line",
"to",
"the",
"cron",
"log"
] | caa4560356517a57ee2ba3ce669b5f4cb7e50c34 | https://github.com/nails/module-cron/blob/caa4560356517a57ee2ba3ce669b5f4cb7e50c34/cron/controllers/CronRouter.php#L183-L186 |
36,557 | CeusMedia/Common | src/FS/File/Block/Writer.php | FS_File_Block_Writer.writeBlocks | public function writeBlocks( $blocks )
{
foreach( $blocks as $name => $content )
{
$list[] = str_replace( "{#name#}", $name, $this->patternSection );
$list[] = $content;
$list[] = "";
}
$file = new FS_File_Writer( $this->fileName );
return $file->writeArray( $list );
} | php | public function writeBlocks( $blocks )
{
foreach( $blocks as $name => $content )
{
$list[] = str_replace( "{#name#}", $name, $this->patternSection );
$list[] = $content;
$list[] = "";
}
$file = new FS_File_Writer( $this->fileName );
return $file->writeArray( $list );
} | [
"public",
"function",
"writeBlocks",
"(",
"$",
"blocks",
")",
"{",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"name",
"=>",
"$",
"content",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"str_replace",
"(",
"\"{#name#}\"",
",",
"$",
"name",
",",
"$",
"this",
"->",
"patternSection",
")",
";",
"$",
"list",
"[",
"]",
"=",
"$",
"content",
";",
"$",
"list",
"[",
"]",
"=",
"\"\"",
";",
"}",
"$",
"file",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"$",
"file",
"->",
"writeArray",
"(",
"$",
"list",
")",
";",
"}"
] | Writes Blocks to Block File.
@access public
@param array $blocks Associative Array with Block Names and Contents
@return int | [
"Writes",
"Blocks",
"to",
"Block",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Block/Writer.php#L63-L73 |
36,558 | CeusMedia/Common | src/Net/Site/MapBuilder.php | Net_Site_MapBuilder.build | public static function build( $urls )
{
$set = new XML_DOM_Node( "urlset" );
$set->setAttribute( 'xmlns', "http://www.google.com/schemas/sitemap/0.84" );
foreach( $urls as $url )
{
$node = new XML_DOM_Node( "url" );
$child = new XML_DOM_Node( "loc", $url );
$node->addChild( $child );
$set->addChild( $node );
}
$xb = new XML_DOM_Builder();
return $xb->build( $set );
} | php | public static function build( $urls )
{
$set = new XML_DOM_Node( "urlset" );
$set->setAttribute( 'xmlns', "http://www.google.com/schemas/sitemap/0.84" );
foreach( $urls as $url )
{
$node = new XML_DOM_Node( "url" );
$child = new XML_DOM_Node( "loc", $url );
$node->addChild( $child );
$set->addChild( $node );
}
$xb = new XML_DOM_Builder();
return $xb->build( $set );
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"urls",
")",
"{",
"$",
"set",
"=",
"new",
"XML_DOM_Node",
"(",
"\"urlset\"",
")",
";",
"$",
"set",
"->",
"setAttribute",
"(",
"'xmlns'",
",",
"\"http://www.google.com/schemas/sitemap/0.84\"",
")",
";",
"foreach",
"(",
"$",
"urls",
"as",
"$",
"url",
")",
"{",
"$",
"node",
"=",
"new",
"XML_DOM_Node",
"(",
"\"url\"",
")",
";",
"$",
"child",
"=",
"new",
"XML_DOM_Node",
"(",
"\"loc\"",
",",
"$",
"url",
")",
";",
"$",
"node",
"->",
"addChild",
"(",
"$",
"child",
")",
";",
"$",
"set",
"->",
"addChild",
"(",
"$",
"node",
")",
";",
"}",
"$",
"xb",
"=",
"new",
"XML_DOM_Builder",
"(",
")",
";",
"return",
"$",
"xb",
"->",
"build",
"(",
"$",
"set",
")",
";",
"}"
] | Builds Sitemap XML for List of URLs.
@access public
@static
@param array $urls List of URLs
@return string | [
"Builds",
"Sitemap",
"XML",
"for",
"List",
"of",
"URLs",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/MapBuilder.php#L51-L64 |
36,559 | CeusMedia/Common | src/UI/Image/ThumbnailCreator.php | UI_Image_ThumbnailCreator.thumbize | public function thumbize( $width, $height )
{
if( !count( $this->size ) )
throw new RuntimeException( 'No Source Image set.' );
$thumb = imagecreatetruecolor( $width, $height );
if( function_exists( 'imageantialias' ) )
imageantialias( $thumb, TRUE );
switch( $this->size[2] )
{
case 1: //GIF
$source = imagecreatefromgif( $this->source );
imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
imagegif( $thumb, $this->target );
break;
case 2: //JPEG
$source = imagecreatefromjpeg( $this->source );
imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
imagejpeg( $thumb, $this->target, $this->quality );
break;
case 3: //PNG
$source = imagecreatefrompng( $this->source );
imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
imagepng( $thumb, $this->target );
break;
default:
throw new Exception( 'Image Type is no supported.' );
}
return true;
} | php | public function thumbize( $width, $height )
{
if( !count( $this->size ) )
throw new RuntimeException( 'No Source Image set.' );
$thumb = imagecreatetruecolor( $width, $height );
if( function_exists( 'imageantialias' ) )
imageantialias( $thumb, TRUE );
switch( $this->size[2] )
{
case 1: //GIF
$source = imagecreatefromgif( $this->source );
imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
imagegif( $thumb, $this->target );
break;
case 2: //JPEG
$source = imagecreatefromjpeg( $this->source );
imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
imagejpeg( $thumb, $this->target, $this->quality );
break;
case 3: //PNG
$source = imagecreatefrompng( $this->source );
imagecopyresampled( $thumb, $source, 0, 0, 0, 0, $width, $height, $this->size[0], $this->size[1] );
imagepng( $thumb, $this->target );
break;
default:
throw new Exception( 'Image Type is no supported.' );
}
return true;
} | [
"public",
"function",
"thumbize",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"size",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No Source Image set.'",
")",
";",
"$",
"thumb",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"if",
"(",
"function_exists",
"(",
"'imageantialias'",
")",
")",
"imageantialias",
"(",
"$",
"thumb",
",",
"TRUE",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"size",
"[",
"2",
"]",
")",
"{",
"case",
"1",
":",
"//GIF\r",
"$",
"source",
"=",
"imagecreatefromgif",
"(",
"$",
"this",
"->",
"source",
")",
";",
"imagecopyresampled",
"(",
"$",
"thumb",
",",
"$",
"source",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"this",
"->",
"size",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"size",
"[",
"1",
"]",
")",
";",
"imagegif",
"(",
"$",
"thumb",
",",
"$",
"this",
"->",
"target",
")",
";",
"break",
";",
"case",
"2",
":",
"//JPEG\r",
"$",
"source",
"=",
"imagecreatefromjpeg",
"(",
"$",
"this",
"->",
"source",
")",
";",
"imagecopyresampled",
"(",
"$",
"thumb",
",",
"$",
"source",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"this",
"->",
"size",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"size",
"[",
"1",
"]",
")",
";",
"imagejpeg",
"(",
"$",
"thumb",
",",
"$",
"this",
"->",
"target",
",",
"$",
"this",
"->",
"quality",
")",
";",
"break",
";",
"case",
"3",
":",
"//PNG\r",
"$",
"source",
"=",
"imagecreatefrompng",
"(",
"$",
"this",
"->",
"source",
")",
";",
"imagecopyresampled",
"(",
"$",
"thumb",
",",
"$",
"source",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"this",
"->",
"size",
"[",
"0",
"]",
",",
"$",
"this",
"->",
"size",
"[",
"1",
"]",
")",
";",
"imagepng",
"(",
"$",
"thumb",
",",
"$",
"this",
"->",
"target",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"'Image Type is no supported.'",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Resizes Image to a given Size.
@access public
@param int $width Width of Target Image
@param int $height Height of Target Image
@return bool | [
"Resizes",
"Image",
"to",
"a",
"given",
"Size",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/ThumbnailCreator.php#L112-L142 |
36,560 | CeusMedia/Common | src/UI/Image/ThumbnailCreator.php | UI_Image_ThumbnailCreator.thumbizeByLimit | public function thumbizeByLimit( $width, $height )
{
if( !count( $this->size ) )
throw new RuntimeException( 'No Source Image set.' );
$ratio_s = $this->size[0] / $this->size[1];
$ratio_t = $width / $height;
if( ( $ratio_s / $ratio_t ) > 1 )
$height = ceil( $width / $ratio_s );
else
$width = ceil( $height * $ratio_s );
return $this->thumbize( $width, $height );
} | php | public function thumbizeByLimit( $width, $height )
{
if( !count( $this->size ) )
throw new RuntimeException( 'No Source Image set.' );
$ratio_s = $this->size[0] / $this->size[1];
$ratio_t = $width / $height;
if( ( $ratio_s / $ratio_t ) > 1 )
$height = ceil( $width / $ratio_s );
else
$width = ceil( $height * $ratio_s );
return $this->thumbize( $width, $height );
} | [
"public",
"function",
"thumbizeByLimit",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"if",
"(",
"!",
"count",
"(",
"$",
"this",
"->",
"size",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No Source Image set.'",
")",
";",
"$",
"ratio_s",
"=",
"$",
"this",
"->",
"size",
"[",
"0",
"]",
"/",
"$",
"this",
"->",
"size",
"[",
"1",
"]",
";",
"$",
"ratio_t",
"=",
"$",
"width",
"/",
"$",
"height",
";",
"if",
"(",
"(",
"$",
"ratio_s",
"/",
"$",
"ratio_t",
")",
">",
"1",
")",
"$",
"height",
"=",
"ceil",
"(",
"$",
"width",
"/",
"$",
"ratio_s",
")",
";",
"else",
"$",
"width",
"=",
"ceil",
"(",
"$",
"height",
"*",
"$",
"ratio_s",
")",
";",
"return",
"$",
"this",
"->",
"thumbize",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"}"
] | Resizes Image within a given Limit.
@access public
@param int $width Largest Width of Target Image
@param int $height Largest Height of Target Image
@return bool | [
"Resizes",
"Image",
"within",
"a",
"given",
"Limit",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/ThumbnailCreator.php#L151-L163 |
36,561 | CeusMedia/Common | src/Alg/Math/NaturalNumbers.php | Alg_Math_NaturalNumbers.gcd | public function gcd( $m, $n )
{
if( $n != 0 )
return NaturalNumbers::gcd( $n, $m % $n );
else
return $m;
} | php | public function gcd( $m, $n )
{
if( $n != 0 )
return NaturalNumbers::gcd( $n, $m % $n );
else
return $m;
} | [
"public",
"function",
"gcd",
"(",
"$",
"m",
",",
"$",
"n",
")",
"{",
"if",
"(",
"$",
"n",
"!=",
"0",
")",
"return",
"NaturalNumbers",
"::",
"gcd",
"(",
"$",
"n",
",",
"$",
"m",
"%",
"$",
"n",
")",
";",
"else",
"return",
"$",
"m",
";",
"}"
] | Calcalates greatest common Divisor of m and n.
@access public
@param int m Natural Number m
@param int n Natural Number n
@return int | [
"Calcalates",
"greatest",
"common",
"Divisor",
"of",
"m",
"and",
"n",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/NaturalNumbers.php#L92-L98 |
36,562 | CeusMedia/Common | src/Alg/Math/NaturalNumbers.php | Alg_Math_NaturalNumbers.gcdm | public function gcdm( $args )
{
if( count( $args ) )
{
$min = $this->min( $args );
for( $i=$min; $i>0; $i-- )
{
$a = true;
foreach( $args as $arg )
if( $arg % $i != 0 )
$a = false;
if( $a )
return $i;
}
}
return false;
} | php | public function gcdm( $args )
{
if( count( $args ) )
{
$min = $this->min( $args );
for( $i=$min; $i>0; $i-- )
{
$a = true;
foreach( $args as $arg )
if( $arg % $i != 0 )
$a = false;
if( $a )
return $i;
}
}
return false;
} | [
"public",
"function",
"gcdm",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"$",
"min",
"=",
"$",
"this",
"->",
"min",
"(",
"$",
"args",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"min",
";",
"$",
"i",
">",
"0",
";",
"$",
"i",
"--",
")",
"{",
"$",
"a",
"=",
"true",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"if",
"(",
"$",
"arg",
"%",
"$",
"i",
"!=",
"0",
")",
"$",
"a",
"=",
"false",
";",
"if",
"(",
"$",
"a",
")",
"return",
"$",
"i",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Calculates greatest common Divisor of at least two Numbers.
@todo Test
@todo Code Documentation | [
"Calculates",
"greatest",
"common",
"Divisor",
"of",
"at",
"least",
"two",
"Numbers",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/NaturalNumbers.php#L105-L121 |
36,563 | CeusMedia/Common | src/Alg/Math/NaturalNumbers.php | Alg_Math_NaturalNumbers.lcmm | public function lcmm( $args )
{
if( count( $args ) )
{
$gcd = $this->gcdm( $args );
$m = 1;
foreach( $args as $arg )
$m *= $arg;
$r = $m / $gcd;
return $r;
}
return false;
} | php | public function lcmm( $args )
{
if( count( $args ) )
{
$gcd = $this->gcdm( $args );
$m = 1;
foreach( $args as $arg )
$m *= $arg;
$r = $m / $gcd;
return $r;
}
return false;
} | [
"public",
"function",
"lcmm",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"args",
")",
")",
"{",
"$",
"gcd",
"=",
"$",
"this",
"->",
"gcdm",
"(",
"$",
"args",
")",
";",
"$",
"m",
"=",
"1",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"$",
"m",
"*=",
"$",
"arg",
";",
"$",
"r",
"=",
"$",
"m",
"/",
"$",
"gcd",
";",
"return",
"$",
"r",
";",
"}",
"return",
"false",
";",
"}"
] | Calculates least common Multiple of at least 2 Numbers.
@todo Test
@todo Code Documentation | [
"Calculates",
"least",
"common",
"Multiple",
"of",
"at",
"least",
"2",
"Numbers",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/NaturalNumbers.php#L192-L204 |
36,564 | CeusMedia/Common | src/Alg/Math/Analysis/Interpolation/Lagrange.php | Alg_Math_Analysis_Interpolation_Lagrange.buildExpressions | public function buildExpressions()
{
$this->expressions = array();
$values = array_keys( $this->data );
for( $i=0; $i<count( $values ); $i++ )
{
$this->expressions[$i] = "";
for( $k=0; $k<count( $values ) ;$k++ )
{
if( $k == $i )
continue;
$expression = "(x-".$values[$k].")/(".$values[$i]."-".$values[$k].")";
if( strlen( $this->expressions[$i] ) )
$this->expressions[$i] .= "*".$expression;
else
$this->expressions[$i] = $expression;
}
}
} | php | public function buildExpressions()
{
$this->expressions = array();
$values = array_keys( $this->data );
for( $i=0; $i<count( $values ); $i++ )
{
$this->expressions[$i] = "";
for( $k=0; $k<count( $values ) ;$k++ )
{
if( $k == $i )
continue;
$expression = "(x-".$values[$k].")/(".$values[$i]."-".$values[$k].")";
if( strlen( $this->expressions[$i] ) )
$this->expressions[$i] .= "*".$expression;
else
$this->expressions[$i] = $expression;
}
}
} | [
"public",
"function",
"buildExpressions",
"(",
")",
"{",
"$",
"this",
"->",
"expressions",
"=",
"array",
"(",
")",
";",
"$",
"values",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"data",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"values",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"expressions",
"[",
"$",
"i",
"]",
"=",
"\"\"",
";",
"for",
"(",
"$",
"k",
"=",
"0",
";",
"$",
"k",
"<",
"count",
"(",
"$",
"values",
")",
";",
"$",
"k",
"++",
")",
"{",
"if",
"(",
"$",
"k",
"==",
"$",
"i",
")",
"continue",
";",
"$",
"expression",
"=",
"\"(x-\"",
".",
"$",
"values",
"[",
"$",
"k",
"]",
".",
"\")/(\"",
".",
"$",
"values",
"[",
"$",
"i",
"]",
".",
"\"-\"",
".",
"$",
"values",
"[",
"$",
"k",
"]",
".",
"\")\"",
";",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"expressions",
"[",
"$",
"i",
"]",
")",
")",
"$",
"this",
"->",
"expressions",
"[",
"$",
"i",
"]",
".=",
"\"*\"",
".",
"$",
"expression",
";",
"else",
"$",
"this",
"->",
"expressions",
"[",
"$",
"i",
"]",
"=",
"$",
"expression",
";",
"}",
"}",
"}"
] | Build Expressions for Interpolation.
@access public
@return void | [
"Build",
"Expressions",
"for",
"Interpolation",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Interpolation/Lagrange.php#L64-L82 |
36,565 | Assasz/yggdrasil | src/Yggdrasil/Utils/Entity/EntityGenerator.php | EntityGenerator.generateClass | private function generateClass(): EntityGenerator
{
$this->entityFile = (new PhpFile())
->addComment('This file is auto-generated.');
$this->entityClass = $this->entityFile
->addNamespace($this->entityData['namespace'])
->addClass($this->entityData['class'])
->addComment($this->entityData['class'] . ' entity' . PHP_EOL)
->addComment('@package ' . $this->entityData['namespace']);
return $this;
} | php | private function generateClass(): EntityGenerator
{
$this->entityFile = (new PhpFile())
->addComment('This file is auto-generated.');
$this->entityClass = $this->entityFile
->addNamespace($this->entityData['namespace'])
->addClass($this->entityData['class'])
->addComment($this->entityData['class'] . ' entity' . PHP_EOL)
->addComment('@package ' . $this->entityData['namespace']);
return $this;
} | [
"private",
"function",
"generateClass",
"(",
")",
":",
"EntityGenerator",
"{",
"$",
"this",
"->",
"entityFile",
"=",
"(",
"new",
"PhpFile",
"(",
")",
")",
"->",
"addComment",
"(",
"'This file is auto-generated.'",
")",
";",
"$",
"this",
"->",
"entityClass",
"=",
"$",
"this",
"->",
"entityFile",
"->",
"addNamespace",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'namespace'",
"]",
")",
"->",
"addClass",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'class'",
"]",
")",
"->",
"addComment",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'class'",
"]",
".",
"' entity'",
".",
"PHP_EOL",
")",
"->",
"addComment",
"(",
"'@package '",
".",
"$",
"this",
"->",
"entityData",
"[",
"'namespace'",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Generates entity class
@return EntityGenerator | [
"Generates",
"entity",
"class"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L67-L79 |
36,566 | Assasz/yggdrasil | src/Yggdrasil/Utils/Entity/EntityGenerator.php | EntityGenerator.generateProperties | private function generateProperties(): EntityGenerator
{
$this->entityClass
->addProperty('id')
->setVisibility('private')
->addComment($this->entityData['class'] . ' ID' . PHP_EOL)
->addComment('@var int $id');
foreach ($this->entityData['properties'] as $name => $type) {
if ('datetime' === $type) {
$type = '\DateTime';
}
$this->entityClass
->addProperty($name)
->setVisibility('private')
->addComment($this->entityData['class'] . ' ' . $name . PHP_EOL)
->addComment('@var ' . $type . ' $' . $name);
}
return $this;
} | php | private function generateProperties(): EntityGenerator
{
$this->entityClass
->addProperty('id')
->setVisibility('private')
->addComment($this->entityData['class'] . ' ID' . PHP_EOL)
->addComment('@var int $id');
foreach ($this->entityData['properties'] as $name => $type) {
if ('datetime' === $type) {
$type = '\DateTime';
}
$this->entityClass
->addProperty($name)
->setVisibility('private')
->addComment($this->entityData['class'] . ' ' . $name . PHP_EOL)
->addComment('@var ' . $type . ' $' . $name);
}
return $this;
} | [
"private",
"function",
"generateProperties",
"(",
")",
":",
"EntityGenerator",
"{",
"$",
"this",
"->",
"entityClass",
"->",
"addProperty",
"(",
"'id'",
")",
"->",
"setVisibility",
"(",
"'private'",
")",
"->",
"addComment",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'class'",
"]",
".",
"' ID'",
".",
"PHP_EOL",
")",
"->",
"addComment",
"(",
"'@var int $id'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'properties'",
"]",
"as",
"$",
"name",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"'datetime'",
"===",
"$",
"type",
")",
"{",
"$",
"type",
"=",
"'\\DateTime'",
";",
"}",
"$",
"this",
"->",
"entityClass",
"->",
"addProperty",
"(",
"$",
"name",
")",
"->",
"setVisibility",
"(",
"'private'",
")",
"->",
"addComment",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'class'",
"]",
".",
"' '",
".",
"$",
"name",
".",
"PHP_EOL",
")",
"->",
"addComment",
"(",
"'@var '",
".",
"$",
"type",
".",
"' $'",
".",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Generates entity properties
@return EntityGenerator | [
"Generates",
"entity",
"properties"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L86-L107 |
36,567 | Assasz/yggdrasil | src/Yggdrasil/Utils/Entity/EntityGenerator.php | EntityGenerator.generateMethods | private function generateMethods(): EntityGenerator
{
$this->entityClass
->addMethod('getId')
->setVisibility('public')
->addComment('Returns ' . strtolower($this->entityData['class']) . ' ID' . PHP_EOL)
->addComment('@return int')
->addBody('return $this->id;')
->setReturnType('int');
foreach ($this->entityData['properties'] as $name => $type) {
$this
->generateGetter($name, $type)
->generateSetter($name, $type);
}
return $this;
} | php | private function generateMethods(): EntityGenerator
{
$this->entityClass
->addMethod('getId')
->setVisibility('public')
->addComment('Returns ' . strtolower($this->entityData['class']) . ' ID' . PHP_EOL)
->addComment('@return int')
->addBody('return $this->id;')
->setReturnType('int');
foreach ($this->entityData['properties'] as $name => $type) {
$this
->generateGetter($name, $type)
->generateSetter($name, $type);
}
return $this;
} | [
"private",
"function",
"generateMethods",
"(",
")",
":",
"EntityGenerator",
"{",
"$",
"this",
"->",
"entityClass",
"->",
"addMethod",
"(",
"'getId'",
")",
"->",
"setVisibility",
"(",
"'public'",
")",
"->",
"addComment",
"(",
"'Returns '",
".",
"strtolower",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'class'",
"]",
")",
".",
"' ID'",
".",
"PHP_EOL",
")",
"->",
"addComment",
"(",
"'@return int'",
")",
"->",
"addBody",
"(",
"'return $this->id;'",
")",
"->",
"setReturnType",
"(",
"'int'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"entityData",
"[",
"'properties'",
"]",
"as",
"$",
"name",
"=>",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"generateGetter",
"(",
"$",
"name",
",",
"$",
"type",
")",
"->",
"generateSetter",
"(",
"$",
"name",
",",
"$",
"type",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Generates entity methods
@return EntityGenerator | [
"Generates",
"entity",
"methods"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L114-L131 |
36,568 | Assasz/yggdrasil | src/Yggdrasil/Utils/Entity/EntityGenerator.php | EntityGenerator.saveFile | private function saveFile(): void
{
$sourceCode = Helpers::tabsToSpaces((string) $this->entityFile);
$entityPath = dirname(__DIR__, 7) . '/src/' . $this->entityData['namespace'] . '/';
$handle = fopen($entityPath . $this->entityData['class'] . '.php', 'w');
fwrite($handle, $sourceCode);
fclose($handle);
} | php | private function saveFile(): void
{
$sourceCode = Helpers::tabsToSpaces((string) $this->entityFile);
$entityPath = dirname(__DIR__, 7) . '/src/' . $this->entityData['namespace'] . '/';
$handle = fopen($entityPath . $this->entityData['class'] . '.php', 'w');
fwrite($handle, $sourceCode);
fclose($handle);
} | [
"private",
"function",
"saveFile",
"(",
")",
":",
"void",
"{",
"$",
"sourceCode",
"=",
"Helpers",
"::",
"tabsToSpaces",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"entityFile",
")",
";",
"$",
"entityPath",
"=",
"dirname",
"(",
"__DIR__",
",",
"7",
")",
".",
"'/src/'",
".",
"$",
"this",
"->",
"entityData",
"[",
"'namespace'",
"]",
".",
"'/'",
";",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"entityPath",
".",
"$",
"this",
"->",
"entityData",
"[",
"'class'",
"]",
".",
"'.php'",
",",
"'w'",
")",
";",
"fwrite",
"(",
"$",
"handle",
",",
"$",
"sourceCode",
")",
";",
"fclose",
"(",
"$",
"handle",
")",
";",
"}"
] | Saves entity file in given path | [
"Saves",
"entity",
"file",
"in",
"given",
"path"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityGenerator.php#L190-L198 |
36,569 | FriendsOfSilverStripe/backendmessages | src/MessageBoxField.php | MessageBoxField.FieldHolder | public function FieldHolder($properties = array())
{
$content = $this->content;
if ($content instanceof ViewableData) {
if ($properties) {
$content = $content->customise($properties);
}
$content = $content->forTemplate();
}
if($this->config()->allow_html === true) {
return '<div class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</div>';
} else {
return '<p class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</p>';
}
} | php | public function FieldHolder($properties = array())
{
$content = $this->content;
if ($content instanceof ViewableData) {
if ($properties) {
$content = $content->customise($properties);
}
$content = $content->forTemplate();
}
if($this->config()->allow_html === true) {
return '<div class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</div>';
} else {
return '<p class="'.$this->classes.'"" name="'.$this->getName().'">'.$content.'</p>';
}
} | [
"public",
"function",
"FieldHolder",
"(",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"content",
";",
"if",
"(",
"$",
"content",
"instanceof",
"ViewableData",
")",
"{",
"if",
"(",
"$",
"properties",
")",
"{",
"$",
"content",
"=",
"$",
"content",
"->",
"customise",
"(",
"$",
"properties",
")",
";",
"}",
"$",
"content",
"=",
"$",
"content",
"->",
"forTemplate",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"config",
"(",
")",
"->",
"allow_html",
"===",
"true",
")",
"{",
"return",
"'<div class=\"'",
".",
"$",
"this",
"->",
"classes",
".",
"'\"\" name=\"'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'\">'",
".",
"$",
"content",
".",
"'</div>'",
";",
"}",
"else",
"{",
"return",
"'<p class=\"'",
".",
"$",
"this",
"->",
"classes",
".",
"'\"\" name=\"'",
".",
"$",
"this",
"->",
"getName",
"(",
")",
".",
"'\">'",
".",
"$",
"content",
".",
"'</p>'",
";",
"}",
"}"
] | adjusts the return to include the required classes.
@param array $properties
@return string | [
"adjusts",
"the",
"return",
"to",
"include",
"the",
"required",
"classes",
"."
] | 6733fd84162fb2b722dcc31ece01f5b36f2f84a4 | https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/MessageBoxField.php#L52-L69 |
36,570 | CeusMedia/Common | src/ADT/JSON/Builder.php | ADT_JSON_Builder.escape | private static function escape( $string )
{
$replace = array(
'\\' => '\\\\',
'"' => '\"',
'/' => '\/',
"\b" => '\b',
"\f" => '\f',
"\n" => '\n',
"\r" => '\r',
"\t" => '\t',
"\u" => '\u'
);
$string = str_replace( array_keys( $replace ), array_values( $replace ), $string );
return $string;
} | php | private static function escape( $string )
{
$replace = array(
'\\' => '\\\\',
'"' => '\"',
'/' => '\/',
"\b" => '\b',
"\f" => '\f',
"\n" => '\n',
"\r" => '\r',
"\t" => '\t',
"\u" => '\u'
);
$string = str_replace( array_keys( $replace ), array_values( $replace ), $string );
return $string;
} | [
"private",
"static",
"function",
"escape",
"(",
"$",
"string",
")",
"{",
"$",
"replace",
"=",
"array",
"(",
"'\\\\'",
"=>",
"'\\\\\\\\'",
",",
"'\"'",
"=>",
"'\\\"'",
",",
"'/'",
"=>",
"'\\/'",
",",
"\"\\b\"",
"=>",
"'\\b'",
",",
"\"\\f\"",
"=>",
"'\\f'",
",",
"\"\\n\"",
"=>",
"'\\n'",
",",
"\"\\r\"",
"=>",
"'\\r'",
",",
"\"\\t\"",
"=>",
"'\\t'",
",",
"\"\\u\"",
"=>",
"'\\u'",
")",
";",
"$",
"string",
"=",
"str_replace",
"(",
"array_keys",
"(",
"$",
"replace",
")",
",",
"array_values",
"(",
"$",
"replace",
")",
",",
"$",
"string",
")",
";",
"return",
"$",
"string",
";",
"}"
] | Escpapes Control Sings in String.
@access private
@static
@param string $string String to be escaped
@return string | [
"Escpapes",
"Control",
"Sings",
"in",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L61-L76 |
36,571 | CeusMedia/Common | src/ADT/JSON/Builder.php | ADT_JSON_Builder.get | public function get( $key, $value, $parent = NULL )
{
$type = self::getType( $key, $value );
switch( $type )
{
case 'object':
$value = '{'.self::loop( $value, $type ).'}';
break;
case 'array':
$value = '['.self::loop( $value, $type ).']';
break;
case 'number':
$value = $value;
break;
case 'string':
$value = '"'.self::escape( $value ).'"';
break;
case 'boolean':
$value = $value ? 'true' : 'false';
break;
case 'null':
$value = 'null';
break;
}
if( !is_null( $key ) && $parent != 'array' )
$value = '"'.$key.'":'.$value;
return $value;
} | php | public function get( $key, $value, $parent = NULL )
{
$type = self::getType( $key, $value );
switch( $type )
{
case 'object':
$value = '{'.self::loop( $value, $type ).'}';
break;
case 'array':
$value = '['.self::loop( $value, $type ).']';
break;
case 'number':
$value = $value;
break;
case 'string':
$value = '"'.self::escape( $value ).'"';
break;
case 'boolean':
$value = $value ? 'true' : 'false';
break;
case 'null':
$value = 'null';
break;
}
if( !is_null( $key ) && $parent != 'array' )
$value = '"'.$key.'":'.$value;
return $value;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"parent",
"=",
"NULL",
")",
"{",
"$",
"type",
"=",
"self",
"::",
"getType",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'object'",
":",
"$",
"value",
"=",
"'{'",
".",
"self",
"::",
"loop",
"(",
"$",
"value",
",",
"$",
"type",
")",
".",
"'}'",
";",
"break",
";",
"case",
"'array'",
":",
"$",
"value",
"=",
"'['",
".",
"self",
"::",
"loop",
"(",
"$",
"value",
",",
"$",
"type",
")",
".",
"']'",
";",
"break",
";",
"case",
"'number'",
":",
"$",
"value",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'string'",
":",
"$",
"value",
"=",
"'\"'",
".",
"self",
"::",
"escape",
"(",
"$",
"value",
")",
".",
"'\"'",
";",
"break",
";",
"case",
"'boolean'",
":",
"$",
"value",
"=",
"$",
"value",
"?",
"'true'",
":",
"'false'",
";",
"break",
";",
"case",
"'null'",
":",
"$",
"value",
"=",
"'null'",
";",
"break",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
"&&",
"$",
"parent",
"!=",
"'array'",
")",
"$",
"value",
"=",
"'\"'",
".",
"$",
"key",
".",
"'\":'",
".",
"$",
"value",
";",
"return",
"$",
"value",
";",
"}"
] | Returns a representative String for a Data Pair.
@access public
@param string $key Key of Pair
@param mixed $value Value of Pair
@param string $parent Parent of Pair
@return string | [
"Returns",
"a",
"representative",
"String",
"for",
"a",
"Data",
"Pair",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L86-L113 |
36,572 | CeusMedia/Common | src/ADT/JSON/Builder.php | ADT_JSON_Builder.getType | private static function getType( $key, $value )
{
if( is_object( $value ))
$type = 'object';
elseif( is_array( $value ) )
$type = self::isAssoc( $value ) ? 'object' : 'array';
elseif( is_int( $value ) || is_float( $value ) || is_double( $value ) )
$type = 'number';
elseif( is_string( $value ) )
$type = 'string';
elseif( is_bool( $value ) )
$type = 'boolean';
elseif( is_null( $value ) )
$type = 'null';
else
throw new InvalidArgumentException( 'Variable "'.$key.'" is not a supported Type.' );
return $type;
} | php | private static function getType( $key, $value )
{
if( is_object( $value ))
$type = 'object';
elseif( is_array( $value ) )
$type = self::isAssoc( $value ) ? 'object' : 'array';
elseif( is_int( $value ) || is_float( $value ) || is_double( $value ) )
$type = 'number';
elseif( is_string( $value ) )
$type = 'string';
elseif( is_bool( $value ) )
$type = 'boolean';
elseif( is_null( $value ) )
$type = 'null';
else
throw new InvalidArgumentException( 'Variable "'.$key.'" is not a supported Type.' );
return $type;
} | [
"private",
"static",
"function",
"getType",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"$",
"type",
"=",
"'object'",
";",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"$",
"type",
"=",
"self",
"::",
"isAssoc",
"(",
"$",
"value",
")",
"?",
"'object'",
":",
"'array'",
";",
"elseif",
"(",
"is_int",
"(",
"$",
"value",
")",
"||",
"is_float",
"(",
"$",
"value",
")",
"||",
"is_double",
"(",
"$",
"value",
")",
")",
"$",
"type",
"=",
"'number'",
";",
"elseif",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"$",
"type",
"=",
"'string'",
";",
"elseif",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"$",
"type",
"=",
"'boolean'",
";",
"elseif",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"$",
"type",
"=",
"'null'",
";",
"else",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Variable \"'",
".",
"$",
"key",
".",
"'\" is not a supported Type.'",
")",
";",
"return",
"$",
"type",
";",
"}"
] | Returns Data Type of Pair Value.
@access private
@static
@param string $key Key of Pair
@param mixed $value Value of Pair
@return string | [
"Returns",
"Data",
"Type",
"of",
"Pair",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L124-L141 |
36,573 | CeusMedia/Common | src/ADT/JSON/Builder.php | ADT_JSON_Builder.loop | private static function loop( $array, $type )
{
$output = NULL;
foreach( $array as $key => $value )
$output .= self::get( $key, $value, $type ).',';
$output = trim( $output, ',' );
return $output;
} | php | private static function loop( $array, $type )
{
$output = NULL;
foreach( $array as $key => $value )
$output .= self::get( $key, $value, $type ).',';
$output = trim( $output, ',' );
return $output;
} | [
"private",
"static",
"function",
"loop",
"(",
"$",
"array",
",",
"$",
"type",
")",
"{",
"$",
"output",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"output",
".=",
"self",
"::",
"get",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"type",
")",
".",
"','",
";",
"$",
"output",
"=",
"trim",
"(",
"$",
"output",
",",
"','",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Loops through Data Array and returns a representative String.
@access private
@static
@param array $array Array to be looped
@param string $type Data Type
@return string | [
"Loops",
"through",
"Data",
"Array",
"and",
"returns",
"a",
"representative",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/JSON/Builder.php#L164-L171 |
36,574 | php-toolkit/cli-utils | src/Terminal.php | Terminal.build | public static function build($format, $type = 'm'): string
{
$format = null === $format ? '' : implode(';', (array)$format);
return "\033[" . implode(';', (array)$format) . $type;
} | php | public static function build($format, $type = 'm'): string
{
$format = null === $format ? '' : implode(';', (array)$format);
return "\033[" . implode(';', (array)$format) . $type;
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"format",
",",
"$",
"type",
"=",
"'m'",
")",
":",
"string",
"{",
"$",
"format",
"=",
"null",
"===",
"$",
"format",
"?",
"''",
":",
"implode",
"(",
"';'",
",",
"(",
"array",
")",
"$",
"format",
")",
";",
"return",
"\"\\033[\"",
".",
"implode",
"(",
"';'",
",",
"(",
"array",
")",
"$",
"format",
")",
".",
"$",
"type",
";",
"}"
] | build ansi code string
```
Terminal::build(null, 'u'); // "\033[s" Saves the current cursor position
Terminal::build(0); // "\033[0m" Build end char, Resets any ANSI format
```
@param mixed $format
@param string $type
@return string | [
"build",
"ansi",
"code",
"string"
] | bc60e7744db8f5452a1421770c00e315d00e3153 | https://github.com/php-toolkit/cli-utils/blob/bc60e7744db8f5452a1421770c00e315d00e3153/src/Terminal.php#L143-L148 |
36,575 | Assasz/yggdrasil | src/Yggdrasil/Utils/Entity/EntityNormalizer.php | EntityNormalizer.normalize | public static function normalize(array $entities, int $depth = 1): array
{
if ($depth < 0) {
return null;
}
$depth = $depth - 1;
$data = [];
$i = 0;
foreach ($entities as $entity) {
$methods[$i] = get_class_methods($entity);
foreach ($methods[$i] as $method) {
if (
(strpos($method, 'get') === false || strpos($method, 'get') !== 0) &&
(strpos($method, 'is') === false || strpos($method, 'is') !== 0)
) {
continue;
}
$propertyName = lcfirst(substr($method, (strpos($method, 'is') === 0) ? 2 : 3));
$value = $entity->{$method}();
if (is_object($value)) {
($value instanceof \DateTime) ?
$value = $value->format('Y-m-d H:i:s') :
$value = self::normalize([$value], $depth);
}
$data[$i][$propertyName] = $value;
}
$i++;
}
return $data;
} | php | public static function normalize(array $entities, int $depth = 1): array
{
if ($depth < 0) {
return null;
}
$depth = $depth - 1;
$data = [];
$i = 0;
foreach ($entities as $entity) {
$methods[$i] = get_class_methods($entity);
foreach ($methods[$i] as $method) {
if (
(strpos($method, 'get') === false || strpos($method, 'get') !== 0) &&
(strpos($method, 'is') === false || strpos($method, 'is') !== 0)
) {
continue;
}
$propertyName = lcfirst(substr($method, (strpos($method, 'is') === 0) ? 2 : 3));
$value = $entity->{$method}();
if (is_object($value)) {
($value instanceof \DateTime) ?
$value = $value->format('Y-m-d H:i:s') :
$value = self::normalize([$value], $depth);
}
$data[$i][$propertyName] = $value;
}
$i++;
}
return $data;
} | [
"public",
"static",
"function",
"normalize",
"(",
"array",
"$",
"entities",
",",
"int",
"$",
"depth",
"=",
"1",
")",
":",
"array",
"{",
"if",
"(",
"$",
"depth",
"<",
"0",
")",
"{",
"return",
"null",
";",
"}",
"$",
"depth",
"=",
"$",
"depth",
"-",
"1",
";",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"methods",
"[",
"$",
"i",
"]",
"=",
"get_class_methods",
"(",
"$",
"entity",
")",
";",
"foreach",
"(",
"$",
"methods",
"[",
"$",
"i",
"]",
"as",
"$",
"method",
")",
"{",
"if",
"(",
"(",
"strpos",
"(",
"$",
"method",
",",
"'get'",
")",
"===",
"false",
"||",
"strpos",
"(",
"$",
"method",
",",
"'get'",
")",
"!==",
"0",
")",
"&&",
"(",
"strpos",
"(",
"$",
"method",
",",
"'is'",
")",
"===",
"false",
"||",
"strpos",
"(",
"$",
"method",
",",
"'is'",
")",
"!==",
"0",
")",
")",
"{",
"continue",
";",
"}",
"$",
"propertyName",
"=",
"lcfirst",
"(",
"substr",
"(",
"$",
"method",
",",
"(",
"strpos",
"(",
"$",
"method",
",",
"'is'",
")",
"===",
"0",
")",
"?",
"2",
":",
"3",
")",
")",
";",
"$",
"value",
"=",
"$",
"entity",
"->",
"{",
"$",
"method",
"}",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"(",
"$",
"value",
"instanceof",
"\\",
"DateTime",
")",
"?",
"$",
"value",
"=",
"$",
"value",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
":",
"$",
"value",
"=",
"self",
"::",
"normalize",
"(",
"[",
"$",
"value",
"]",
",",
"$",
"depth",
")",
";",
"}",
"$",
"data",
"[",
"$",
"i",
"]",
"[",
"$",
"propertyName",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"i",
"++",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Normalizes passed entities
Works with DTOs with implemented getters as well
@param array $entities Array of entities to normalize
@param int $depth Entity association depth to be pursued by normalization
@return array | [
"Normalizes",
"passed",
"entities",
"Works",
"with",
"DTOs",
"with",
"implemented",
"getters",
"as",
"well"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Entity/EntityNormalizer.php#L21-L59 |
36,576 | CeusMedia/Common | src/FS/File/Log/ShortReader.php | FS_File_Log_ShortReader.read | public function read()
{
if( $fcont = @file( $this->uri ) )
{
$this->data = array();
foreach( $fcont as $line )
$this->data[] = explode( "|", trim( $line ) );
$this->open = true;
return true;
}
return false;
} | php | public function read()
{
if( $fcont = @file( $this->uri ) )
{
$this->data = array();
foreach( $fcont as $line )
$this->data[] = explode( "|", trim( $line ) );
$this->open = true;
return true;
}
return false;
} | [
"public",
"function",
"read",
"(",
")",
"{",
"if",
"(",
"$",
"fcont",
"=",
"@",
"file",
"(",
"$",
"this",
"->",
"uri",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fcont",
"as",
"$",
"line",
")",
"$",
"this",
"->",
"data",
"[",
"]",
"=",
"explode",
"(",
"\"|\"",
",",
"trim",
"(",
"$",
"line",
")",
")",
";",
"$",
"this",
"->",
"open",
"=",
"true",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Reads Log File.
@access public
@return bool | [
"Reads",
"Log",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/ShortReader.php#L100-L111 |
36,577 | CeusMedia/Common | src/Alg/Math/RomanNumbers.php | Alg_Math_RomanNumbers.convertFromRoman | public static function convertFromRoman( $roman )
{
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'
) );
$_r = str_replace( array_keys( $this->roman ), "", $roman ); // prove roman number by clearing all valid numbers
if( strlen( $_r ) ) // some numbers are invalid
throw new InvalidArgumentException( "Roman '".$roman."' is invalid." );
$integer = 0; // initiating integer
$keys = array_keys( $this->shorts );
$values = array_values( $this->shorts );
$roman = str_replace( $values, $keys, $roman ); // resolve shortcuts
foreach( $this->roman as $key => $value ) // all roman number starting with biggest
{
$count = substr_count( $roman, $key ); // amount of roman numbers of current value
$integer += $count * $value; // increase integer by amount * current value
$roman = str_replace( $key, "", $roman ); // remove current roman numbers
}
return $integer;
} | php | public static function convertFromRoman( $roman )
{
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'
) );
$_r = str_replace( array_keys( $this->roman ), "", $roman ); // prove roman number by clearing all valid numbers
if( strlen( $_r ) ) // some numbers are invalid
throw new InvalidArgumentException( "Roman '".$roman."' is invalid." );
$integer = 0; // initiating integer
$keys = array_keys( $this->shorts );
$values = array_values( $this->shorts );
$roman = str_replace( $values, $keys, $roman ); // resolve shortcuts
foreach( $this->roman as $key => $value ) // all roman number starting with biggest
{
$count = substr_count( $roman, $key ); // amount of roman numbers of current value
$integer += $count * $value; // increase integer by amount * current value
$roman = str_replace( $key, "", $roman ); // remove current roman numbers
}
return $integer;
} | [
"public",
"static",
"function",
"convertFromRoman",
"(",
"$",
"roman",
")",
"{",
"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'",
")",
")",
";",
"$",
"_r",
"=",
"str_replace",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"roman",
")",
",",
"\"\"",
",",
"$",
"roman",
")",
";",
"// prove roman number by clearing all valid numbers\r",
"if",
"(",
"strlen",
"(",
"$",
"_r",
")",
")",
"// some numbers are invalid\r",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Roman '\"",
".",
"$",
"roman",
".",
"\"' is invalid.\"",
")",
";",
"$",
"integer",
"=",
"0",
";",
"// initiating integer\r",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"shorts",
")",
";",
"$",
"values",
"=",
"array_values",
"(",
"$",
"this",
"->",
"shorts",
")",
";",
"$",
"roman",
"=",
"str_replace",
"(",
"$",
"values",
",",
"$",
"keys",
",",
"$",
"roman",
")",
";",
"// resolve shortcuts\r",
"foreach",
"(",
"$",
"this",
"->",
"roman",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"// all roman number starting with biggest\r",
"{",
"$",
"count",
"=",
"substr_count",
"(",
"$",
"roman",
",",
"$",
"key",
")",
";",
"// amount of roman numbers of current value\r",
"$",
"integer",
"+=",
"$",
"count",
"*",
"$",
"value",
";",
"// increase integer by amount * current value\r",
"$",
"roman",
"=",
"str_replace",
"(",
"$",
"key",
",",
"\"\"",
",",
"$",
"roman",
")",
";",
"// remove current roman numbers\r",
"}",
"return",
"$",
"integer",
";",
"}"
] | Converts and returns a roman number as arabian number.
@access
@static
@param string $roman Roman number
@return integer | [
"Converts",
"and",
"returns",
"a",
"roman",
"number",
"as",
"arabian",
"number",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/RomanNumbers.php#L75-L99 |
36,578 | CeusMedia/Common | src/Alg/Math/RomanNumbers.php | Alg_Math_RomanNumbers.convertToRoman | public static function convertToRoman( $integer )
{
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'
) );
arsort( self::$roman );
$roman = ""; // initiating roman number
if( is_numeric( $integer ) && $integer == round( $integer, 0 ) ) // prove integer by cutting floats
{
while( $integer > 0 )
{
foreach( self::$roman as $key => $value ) // all roman number starting with biggest
{
if( $integer >= $value ) // current roman number is in integer
{
$roman .= $key; // append roman number
$integer -= $value; // decrease integer by current value
break;
}
}
}
$keys = array_keys( self::$shorts );
$values = array_values( self::$shorts );
$roman = str_replace( $keys, $values, $roman ); // realize shortcuts
return $roman;
}
else
throw new InvalidArgumentException( "Integer '".$integer."' is invalid." );
} | php | public static function convertToRoman( $integer )
{
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'
) );
arsort( self::$roman );
$roman = ""; // initiating roman number
if( is_numeric( $integer ) && $integer == round( $integer, 0 ) ) // prove integer by cutting floats
{
while( $integer > 0 )
{
foreach( self::$roman as $key => $value ) // all roman number starting with biggest
{
if( $integer >= $value ) // current roman number is in integer
{
$roman .= $key; // append roman number
$integer -= $value; // decrease integer by current value
break;
}
}
}
$keys = array_keys( self::$shorts );
$values = array_values( self::$shorts );
$roman = str_replace( $keys, $values, $roman ); // realize shortcuts
return $roman;
}
else
throw new InvalidArgumentException( "Integer '".$integer."' is invalid." );
} | [
"public",
"static",
"function",
"convertToRoman",
"(",
"$",
"integer",
")",
"{",
"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'",
")",
")",
";",
"arsort",
"(",
"self",
"::",
"$",
"roman",
")",
";",
"$",
"roman",
"=",
"\"\"",
";",
"// initiating roman number\r",
"if",
"(",
"is_numeric",
"(",
"$",
"integer",
")",
"&&",
"$",
"integer",
"==",
"round",
"(",
"$",
"integer",
",",
"0",
")",
")",
"// prove integer by cutting floats\r",
"{",
"while",
"(",
"$",
"integer",
">",
"0",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"roman",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"// all roman number starting with biggest\r",
"{",
"if",
"(",
"$",
"integer",
">=",
"$",
"value",
")",
"// current roman number is in integer\r",
"{",
"$",
"roman",
".=",
"$",
"key",
";",
"// append roman number\r",
"$",
"integer",
"-=",
"$",
"value",
";",
"// decrease integer by current value\r",
"break",
";",
"}",
"}",
"}",
"$",
"keys",
"=",
"array_keys",
"(",
"self",
"::",
"$",
"shorts",
")",
";",
"$",
"values",
"=",
"array_values",
"(",
"self",
"::",
"$",
"shorts",
")",
";",
"$",
"roman",
"=",
"str_replace",
"(",
"$",
"keys",
",",
"$",
"values",
",",
"$",
"roman",
")",
";",
"// realize shortcuts\r",
"return",
"$",
"roman",
";",
"}",
"else",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Integer '\"",
".",
"$",
"integer",
".",
"\"' is invalid.\"",
")",
";",
"}"
] | Converts and returns an arabian number as roman number.
@access public
@static
@param int $integer Arabian number
@return string | [
"Converts",
"and",
"returns",
"an",
"arabian",
"number",
"as",
"roman",
"number",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/RomanNumbers.php#L108-L141 |
36,579 | CeusMedia/Common | src/FS/File/Log/Writer.php | FS_File_Log_Writer.note | public function note( $line, $format = "datetime" )
{
$converter = new Alg_Time_Converter();
$time = $format ? " [".$converter->convertToHuman( time(), $format )."]" : "";
$message = time().$time." ".$line."\n";
return error_log( $message, 3, $this->uri );
} | php | public function note( $line, $format = "datetime" )
{
$converter = new Alg_Time_Converter();
$time = $format ? " [".$converter->convertToHuman( time(), $format )."]" : "";
$message = time().$time." ".$line."\n";
return error_log( $message, 3, $this->uri );
} | [
"public",
"function",
"note",
"(",
"$",
"line",
",",
"$",
"format",
"=",
"\"datetime\"",
")",
"{",
"$",
"converter",
"=",
"new",
"Alg_Time_Converter",
"(",
")",
";",
"$",
"time",
"=",
"$",
"format",
"?",
"\" [\"",
".",
"$",
"converter",
"->",
"convertToHuman",
"(",
"time",
"(",
")",
",",
"$",
"format",
")",
".",
"\"]\"",
":",
"\"\"",
";",
"$",
"message",
"=",
"time",
"(",
")",
".",
"$",
"time",
".",
"\" \"",
".",
"$",
"line",
".",
"\"\\n\"",
";",
"return",
"error_log",
"(",
"$",
"message",
",",
"3",
",",
"$",
"this",
"->",
"uri",
")",
";",
"}"
] | Adds an Note to Log File.
@access public
@param string $line Entry to add to Log File
@return bool | [
"Adds",
"an",
"Note",
"to",
"Log",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/Writer.php#L63-L69 |
36,580 | CeusMedia/Common | src/FS/Folder/RecursiveLister.php | FS_Folder_RecursiveLister.getFileList | public static function getFileList( $path, $pattern = NULL )
{
$index = new FS_Folder_RecursiveLister( $path );
$index->setPattern( $pattern );
$index->showFiles( TRUE );
$index->showFolders( FALSE );
return $index->getList();
} | php | public static function getFileList( $path, $pattern = NULL )
{
$index = new FS_Folder_RecursiveLister( $path );
$index->setPattern( $pattern );
$index->showFiles( TRUE );
$index->showFolders( FALSE );
return $index->getList();
} | [
"public",
"static",
"function",
"getFileList",
"(",
"$",
"path",
",",
"$",
"pattern",
"=",
"NULL",
")",
"{",
"$",
"index",
"=",
"new",
"FS_Folder_RecursiveLister",
"(",
"$",
"path",
")",
";",
"$",
"index",
"->",
"setPattern",
"(",
"$",
"pattern",
")",
";",
"$",
"index",
"->",
"showFiles",
"(",
"TRUE",
")",
";",
"$",
"index",
"->",
"showFolders",
"(",
"FALSE",
")",
";",
"return",
"$",
"index",
"->",
"getList",
"(",
")",
";",
"}"
] | Returns List of Files statically.
@access public
@static
@param string $path Path to Folder
@param string $pattern RegEx Pattern to match with File Name
@return FilterIterator | [
"Returns",
"List",
"of",
"Files",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/RecursiveLister.php#L84-L91 |
36,581 | CeusMedia/Common | src/FS/Folder/RecursiveLister.php | FS_Folder_RecursiveLister.getFolderList | public static function getFolderList( $path, $pattern = NULL, $stripDotEntries = TRUE )
{
$index = new FS_Folder_RecursiveLister( $path );
$index->setPattern( $pattern );
$index->showFiles( FALSE );
$index->showFolders( TRUE );
$index->stripDotEntries( $stripDotEntries );
return $index->getList();
} | php | public static function getFolderList( $path, $pattern = NULL, $stripDotEntries = TRUE )
{
$index = new FS_Folder_RecursiveLister( $path );
$index->setPattern( $pattern );
$index->showFiles( FALSE );
$index->showFolders( TRUE );
$index->stripDotEntries( $stripDotEntries );
return $index->getList();
} | [
"public",
"static",
"function",
"getFolderList",
"(",
"$",
"path",
",",
"$",
"pattern",
"=",
"NULL",
",",
"$",
"stripDotEntries",
"=",
"TRUE",
")",
"{",
"$",
"index",
"=",
"new",
"FS_Folder_RecursiveLister",
"(",
"$",
"path",
")",
";",
"$",
"index",
"->",
"setPattern",
"(",
"$",
"pattern",
")",
";",
"$",
"index",
"->",
"showFiles",
"(",
"FALSE",
")",
";",
"$",
"index",
"->",
"showFolders",
"(",
"TRUE",
")",
";",
"$",
"index",
"->",
"stripDotEntries",
"(",
"$",
"stripDotEntries",
")",
";",
"return",
"$",
"index",
"->",
"getList",
"(",
")",
";",
"}"
] | Returns List of Folders statically.
@access public
@static
@param string $path Path to Folder
@param string $pattern RegEx Pattern to match with Folder Name
@param bool $stripDotEntries Flag: strip Files and Folders starting with a Dot
@return FilterIterator | [
"Returns",
"List",
"of",
"Folders",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/RecursiveLister.php#L102-L110 |
36,582 | CeusMedia/Common | src/FS/Folder/RecursiveLister.php | FS_Folder_RecursiveLister.getMixedList | public static function getMixedList( $path, $pattern = NULL, $stripDotEntries = TRUE )
{
$index = new FS_Folder_RecursiveLister( $path );
$index->setPattern( $pattern );
$index->showFiles( TRUE );
$index->showFolders( TRUE );
$index->stripDotEntries( $stripDotEntries );
return $index->getList();
} | php | public static function getMixedList( $path, $pattern = NULL, $stripDotEntries = TRUE )
{
$index = new FS_Folder_RecursiveLister( $path );
$index->setPattern( $pattern );
$index->showFiles( TRUE );
$index->showFolders( TRUE );
$index->stripDotEntries( $stripDotEntries );
return $index->getList();
} | [
"public",
"static",
"function",
"getMixedList",
"(",
"$",
"path",
",",
"$",
"pattern",
"=",
"NULL",
",",
"$",
"stripDotEntries",
"=",
"TRUE",
")",
"{",
"$",
"index",
"=",
"new",
"FS_Folder_RecursiveLister",
"(",
"$",
"path",
")",
";",
"$",
"index",
"->",
"setPattern",
"(",
"$",
"pattern",
")",
";",
"$",
"index",
"->",
"showFiles",
"(",
"TRUE",
")",
";",
"$",
"index",
"->",
"showFolders",
"(",
"TRUE",
")",
";",
"$",
"index",
"->",
"stripDotEntries",
"(",
"$",
"stripDotEntries",
")",
";",
"return",
"$",
"index",
"->",
"getList",
"(",
")",
";",
"}"
] | Returns List of Folders and Files statically.
@access public
@static
@param string $path Path to Folder
@param string $pattern RegEx Pattern to match with Entry Name
@param bool $stripDotEntries Flag: strip Files and Folders starting with a Dot
@return FilterIterator | [
"Returns",
"List",
"of",
"Folders",
"and",
"Files",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/RecursiveLister.php#L121-L129 |
36,583 | CeusMedia/Common | src/FS/File/List/Editor.php | FS_File_List_Editor.edit | public function edit( $oldItem, $newItem )
{
$index = $this->getIndex( $oldItem );
$this->list[$index] = $newItem;
return $this->write();
} | php | public function edit( $oldItem, $newItem )
{
$index = $this->getIndex( $oldItem );
$this->list[$index] = $newItem;
return $this->write();
} | [
"public",
"function",
"edit",
"(",
"$",
"oldItem",
",",
"$",
"newItem",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
"$",
"oldItem",
")",
";",
"$",
"this",
"->",
"list",
"[",
"$",
"index",
"]",
"=",
"$",
"newItem",
";",
"return",
"$",
"this",
"->",
"write",
"(",
")",
";",
"}"
] | Edits an existing Item of current List.
@access public
@param int $oldItem Item to replace
@param int $newItem Item to set instead
@return bool | [
"Edits",
"an",
"existing",
"Item",
"of",
"current",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Editor.php#L80-L85 |
36,584 | smasty/Neevo | src/Neevo/Drivers/pdo.php | PDODriver.randomizeOrder | public function randomizeOrder(BaseStatement $statement){
switch($this->driverName){
case 'mysql':
case 'pgsql':
$random = 'RAND()';
case 'sqlite':
case 'sqlite2':
$random = 'RANDOM()';
case 'odbc':
$random = 'Rnd(id)';
case 'oci':
$random = 'dbms_random.value';
case 'mssql':
$random = 'NEWID()';
}
$statement->order($random);
} | php | public function randomizeOrder(BaseStatement $statement){
switch($this->driverName){
case 'mysql':
case 'pgsql':
$random = 'RAND()';
case 'sqlite':
case 'sqlite2':
$random = 'RANDOM()';
case 'odbc':
$random = 'Rnd(id)';
case 'oci':
$random = 'dbms_random.value';
case 'mssql':
$random = 'NEWID()';
}
$statement->order($random);
} | [
"public",
"function",
"randomizeOrder",
"(",
"BaseStatement",
"$",
"statement",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"driverName",
")",
"{",
"case",
"'mysql'",
":",
"case",
"'pgsql'",
":",
"$",
"random",
"=",
"'RAND()'",
";",
"case",
"'sqlite'",
":",
"case",
"'sqlite2'",
":",
"$",
"random",
"=",
"'RANDOM()'",
";",
"case",
"'odbc'",
":",
"$",
"random",
"=",
"'Rnd(id)'",
";",
"case",
"'oci'",
":",
"$",
"random",
"=",
"'dbms_random.value'",
";",
"case",
"'mssql'",
":",
"$",
"random",
"=",
"'NEWID()'",
";",
"}",
"$",
"statement",
"->",
"order",
"(",
"$",
"random",
")",
";",
"}"
] | Randomizes result order.
@param BaseStatement $statement | [
"Randomizes",
"result",
"order",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Drivers/pdo.php#L222-L242 |
36,585 | CeusMedia/Common | src/XML/FeedIdentifier.php | XML_FeedIdentifier.identifyFromUrl | public function identifyFromUrl( $url, $timeout = 5 )
{
Net_CURL::setTimeOut( $timeout );
$xml = Net_Reader::readUrl( $url );
return $this->identify( $xml );
} | php | public function identifyFromUrl( $url, $timeout = 5 )
{
Net_CURL::setTimeOut( $timeout );
$xml = Net_Reader::readUrl( $url );
return $this->identify( $xml );
} | [
"public",
"function",
"identifyFromUrl",
"(",
"$",
"url",
",",
"$",
"timeout",
"=",
"5",
")",
"{",
"Net_CURL",
"::",
"setTimeOut",
"(",
"$",
"timeout",
")",
";",
"$",
"xml",
"=",
"Net_Reader",
"::",
"readUrl",
"(",
"$",
"url",
")",
";",
"return",
"$",
"this",
"->",
"identify",
"(",
"$",
"xml",
")",
";",
"}"
] | Identifies Feed from an URL.
@access public
@param string $url URL of Feed
@param int $timeout Timeout in seconds
@return string | [
"Identifies",
"Feed",
"from",
"an",
"URL",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/FeedIdentifier.php#L157-L162 |
36,586 | kdambekalns/faker | Classes/Internet.php | Internet.userName | public static function userName($name = null)
{
if ($name === null) {
if (rand(1, 10) > 5) {
$name = Name::firstName() . ' ' . Name::lastName();
} else {
$name = Name::firstName();
}
}
$glue = array('.', '_');
shuffle($glue);
$nameParts = explode(' ', $name);
shuffle($nameParts);
$userName = implode($glue[0], $nameParts);
return strtolower($userName);
} | php | public static function userName($name = null)
{
if ($name === null) {
if (rand(1, 10) > 5) {
$name = Name::firstName() . ' ' . Name::lastName();
} else {
$name = Name::firstName();
}
}
$glue = array('.', '_');
shuffle($glue);
$nameParts = explode(' ', $name);
shuffle($nameParts);
$userName = implode($glue[0], $nameParts);
return strtolower($userName);
} | [
"public",
"static",
"function",
"userName",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"null",
")",
"{",
"if",
"(",
"rand",
"(",
"1",
",",
"10",
")",
">",
"5",
")",
"{",
"$",
"name",
"=",
"Name",
"::",
"firstName",
"(",
")",
".",
"' '",
".",
"Name",
"::",
"lastName",
"(",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"Name",
"::",
"firstName",
"(",
")",
";",
"}",
"}",
"$",
"glue",
"=",
"array",
"(",
"'.'",
",",
"'_'",
")",
";",
"shuffle",
"(",
"$",
"glue",
")",
";",
"$",
"nameParts",
"=",
"explode",
"(",
"' '",
",",
"$",
"name",
")",
";",
"shuffle",
"(",
"$",
"nameParts",
")",
";",
"$",
"userName",
"=",
"implode",
"(",
"$",
"glue",
"[",
"0",
"]",
",",
"$",
"nameParts",
")",
";",
"return",
"strtolower",
"(",
"$",
"userName",
")",
";",
"}"
] | Return a fake username.
@param string $name
@return string | [
"Return",
"a",
"fake",
"username",
"."
] | 9cb516a59a1e1407956c354611434673e318ee7c | https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Internet.php#L57-L74 |
36,587 | kdambekalns/faker | Classes/Internet.php | Internet.domainWord | protected static function domainWord()
{
$words = explode(' ', Company::name());
shuffle($words);
return strtolower(preg_replace('/\W/', '', current($words)));
} | php | protected static function domainWord()
{
$words = explode(' ', Company::name());
shuffle($words);
return strtolower(preg_replace('/\W/', '', current($words)));
} | [
"protected",
"static",
"function",
"domainWord",
"(",
")",
"{",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"Company",
"::",
"name",
"(",
")",
")",
";",
"shuffle",
"(",
"$",
"words",
")",
";",
"return",
"strtolower",
"(",
"preg_replace",
"(",
"'/\\W/'",
",",
"''",
",",
"current",
"(",
"$",
"words",
")",
")",
")",
";",
"}"
] | Return a fake domain name part.
@return string | [
"Return",
"a",
"fake",
"domain",
"name",
"part",
"."
] | 9cb516a59a1e1407956c354611434673e318ee7c | https://github.com/kdambekalns/faker/blob/9cb516a59a1e1407956c354611434673e318ee7c/Classes/Internet.php#L91-L97 |
36,588 | spiral/models | src/SchematicEntity.php | SchematicEntity.describeProperty | public static function describeProperty(ReflectionEntity $reflection, string $property, $value)
{
static::initialize(true);
/**
* Clarifying property value using traits or other listeners.
*
* @var ReflectionEvent $event
*/
$event = static::getEventDispatcher()->dispatch(
ReflectionEvent::EVENT,
new ReflectionEvent($reflection, $property, $value)
);
return $event->getValue();
} | php | public static function describeProperty(ReflectionEntity $reflection, string $property, $value)
{
static::initialize(true);
/**
* Clarifying property value using traits or other listeners.
*
* @var ReflectionEvent $event
*/
$event = static::getEventDispatcher()->dispatch(
ReflectionEvent::EVENT,
new ReflectionEvent($reflection, $property, $value)
);
return $event->getValue();
} | [
"public",
"static",
"function",
"describeProperty",
"(",
"ReflectionEntity",
"$",
"reflection",
",",
"string",
"$",
"property",
",",
"$",
"value",
")",
"{",
"static",
"::",
"initialize",
"(",
"true",
")",
";",
"/**\n * Clarifying property value using traits or other listeners.\n *\n * @var ReflectionEvent $event\n */",
"$",
"event",
"=",
"static",
"::",
"getEventDispatcher",
"(",
")",
"->",
"dispatch",
"(",
"ReflectionEvent",
"::",
"EVENT",
",",
"new",
"ReflectionEvent",
"(",
"$",
"reflection",
",",
"$",
"property",
",",
"$",
"value",
")",
")",
";",
"return",
"$",
"event",
"->",
"getValue",
"(",
")",
";",
"}"
] | Method used while entity static analysis to describe model related property using even
dispatcher and associated model traits.
@param ReflectionEntity $reflection
@param string $property
@param mixed $value
@return mixed Returns filtered value.
@event describe(DescribeEvent) | [
"Method",
"used",
"while",
"entity",
"static",
"analysis",
"to",
"describe",
"model",
"related",
"property",
"using",
"even",
"dispatcher",
"and",
"associated",
"model",
"traits",
"."
] | 7ad86808c938354dfc2aaaee824d72ee8a15b6fd | https://github.com/spiral/models/blob/7ad86808c938354dfc2aaaee824d72ee8a15b6fd/src/SchematicEntity.php#L87-L102 |
36,589 | CeusMedia/Common | src/Alg/Math/Analysis/Interpolation/RegulaFalsi.php | Alg_Math_Analysis_Interpolation_RegulaFalsi.setInterval | public function setInterval( $start, $end )
{
if( $start * $end > 0 )
throw new InvalidArgumentException( 'Interval needs to start below 0.' );
$this->interval = new Alg_Math_CompactInterval( $start, $end );
} | php | public function setInterval( $start, $end )
{
if( $start * $end > 0 )
throw new InvalidArgumentException( 'Interval needs to start below 0.' );
$this->interval = new Alg_Math_CompactInterval( $start, $end );
} | [
"public",
"function",
"setInterval",
"(",
"$",
"start",
",",
"$",
"end",
")",
"{",
"if",
"(",
"$",
"start",
"*",
"$",
"end",
">",
"0",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Interval needs to start below 0.'",
")",
";",
"$",
"this",
"->",
"interval",
"=",
"new",
"Alg_Math_CompactInterval",
"(",
"$",
"start",
",",
"$",
"end",
")",
";",
"}"
] | Sets Interval data to start at.
@access public
@param int $start Start of Interval
@param int $end End of Interval
@return void | [
"Sets",
"Interval",
"data",
"to",
"start",
"at",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Interpolation/RegulaFalsi.php#L112-L117 |
36,590 | CeusMedia/Common | src/ADT/List/Dictionary.php | ADT_List_Dictionary.cast | public function cast( $value, $key )
{
if( strtolower( gettype( $value ) ) === "resource" )
throw new InvalidArgumentException( 'Cannot cast resource' );
if( !$this->has( $key ) )
throw new OutOfRangeException( 'Invalid key "'.$key.'"' );
$key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive
$valueType = strtolower( gettype( $value ) );
$pairType = strtolower( gettype( $this->get( $key ) ) );
$abstracts = array( 'array', 'object' );
if( in_array( $valueType, $abstracts ) !== in_array( $pairType, $abstracts ) )
throw new UnexpectedValueException( 'Cannot cast '.$valueType.' to '.$pairType );
settype( $value, $pairType );
return $value;
} | php | public function cast( $value, $key )
{
if( strtolower( gettype( $value ) ) === "resource" )
throw new InvalidArgumentException( 'Cannot cast resource' );
if( !$this->has( $key ) )
throw new OutOfRangeException( 'Invalid key "'.$key.'"' );
$key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive
$valueType = strtolower( gettype( $value ) );
$pairType = strtolower( gettype( $this->get( $key ) ) );
$abstracts = array( 'array', 'object' );
if( in_array( $valueType, $abstracts ) !== in_array( $pairType, $abstracts ) )
throw new UnexpectedValueException( 'Cannot cast '.$valueType.' to '.$pairType );
settype( $value, $pairType );
return $value;
} | [
"public",
"function",
"cast",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"if",
"(",
"strtolower",
"(",
"gettype",
"(",
"$",
"value",
")",
")",
"===",
"\"resource\"",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Cannot cast resource'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"throw",
"new",
"OutOfRangeException",
"(",
"'Invalid key \"'",
".",
"$",
"key",
".",
"'\"'",
")",
";",
"$",
"key",
"=",
"!",
"$",
"this",
"->",
"caseSensitive",
"?",
"strtolower",
"(",
"$",
"key",
")",
":",
"$",
"key",
";",
"// lowercase key if dictionary is not case sensitive\r",
"$",
"valueType",
"=",
"strtolower",
"(",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"$",
"pairType",
"=",
"strtolower",
"(",
"gettype",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
")",
")",
";",
"$",
"abstracts",
"=",
"array",
"(",
"'array'",
",",
"'object'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"valueType",
",",
"$",
"abstracts",
")",
"!==",
"in_array",
"(",
"$",
"pairType",
",",
"$",
"abstracts",
")",
")",
"throw",
"new",
"UnexpectedValueException",
"(",
"'Cannot cast '",
".",
"$",
"valueType",
".",
"' to '",
".",
"$",
"pairType",
")",
";",
"settype",
"(",
"$",
"value",
",",
"$",
"pairType",
")",
";",
"return",
"$",
"value",
";",
"}"
] | Casts a Value by the Type of the current Value by its Key.
@access public
@param string $value Value to cast
@param string $key Key in Dictionary
@return mixed
@throws InvalidArgumentException if value is a resource
@throws OutOfRangeException if key is not existing
@throws UnexpectedValueException if cast is not possible (like between string and array and vise versa) | [
"Casts",
"a",
"Value",
"by",
"the",
"Type",
"of",
"the",
"current",
"Value",
"by",
"its",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L80-L96 |
36,591 | CeusMedia/Common | src/ADT/List/Dictionary.php | ADT_List_Dictionary.get | public function get( $key, $default = NULL )
{
if( $this->has( $key ) )
return $this->pairs[( !$this->caseSensitive ? strtolower( $key ) : $key )];
return $default;
} | php | public function get( $key, $default = NULL )
{
if( $this->has( $key ) )
return $this->pairs[( !$this->caseSensitive ? strtolower( $key ) : $key )];
return $default;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"return",
"$",
"this",
"->",
"pairs",
"[",
"(",
"!",
"$",
"this",
"->",
"caseSensitive",
"?",
"strtolower",
"(",
"$",
"key",
")",
":",
"$",
"key",
")",
"]",
";",
"return",
"$",
"default",
";",
"}"
] | Return a Value of Dictionary by its Key.
@access public
@param string $key Key in Dictionary
@param mixed $default Value to return if key is not set
@return mixed | [
"Return",
"a",
"Value",
"of",
"Dictionary",
"by",
"its",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L145-L150 |
36,592 | CeusMedia/Common | src/ADT/List/Dictionary.php | ADT_List_Dictionary.getKeyOf | public function getKeyOf( $value )
{
$key = array_search( $value, $this->pairs, TRUE );
return $key === FALSE ? NULL : $key;
} | php | public function getKeyOf( $value )
{
$key = array_search( $value, $this->pairs, TRUE );
return $key === FALSE ? NULL : $key;
} | [
"public",
"function",
"getKeyOf",
"(",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"pairs",
",",
"TRUE",
")",
";",
"return",
"$",
"key",
"===",
"FALSE",
"?",
"NULL",
":",
"$",
"key",
";",
"}"
] | Returns corresponding Key of a Value if Value is in Dictionary, otherwise NULL.
@access public
@param string $value Value to get Key of
@return mixed|NULL Key of value if found, otherwise NULL | [
"Returns",
"corresponding",
"Key",
"of",
"a",
"Value",
"if",
"Value",
"is",
"in",
"Dictionary",
"otherwise",
"NULL",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L200-L204 |
36,593 | CeusMedia/Common | src/ADT/List/Dictionary.php | ADT_List_Dictionary.has | public function has( $key )
{
$key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive
return array_key_exists( $key, $this->pairs );
} | php | public function has( $key )
{
$key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive
return array_key_exists( $key, $this->pairs );
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"key",
"=",
"!",
"$",
"this",
"->",
"caseSensitive",
"?",
"strtolower",
"(",
"$",
"key",
")",
":",
"$",
"key",
";",
"// lowercase key if dictionary is not case sensitive\r",
"return",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"pairs",
")",
";",
"}"
] | Indicates whether a Key is existing.
@access public
@param string $key Key in Dictionary
@return boolean | [
"Indicates",
"whether",
"a",
"Key",
"is",
"existing",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L212-L216 |
36,594 | CeusMedia/Common | src/ADT/List/Dictionary.php | ADT_List_Dictionary.remove | public function remove( $key )
{
if( !$this->has( $key ) ) // pair key is not existing
return FALSE; // indicate miss
$key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive
$index = array_search( $key, array_keys( $this->pairs ) ); // index of pair to be removed
if( $index >= $this->position ) // iterator position is beyond pair
$this->position--; // decrease iterator position since pair is removed
unset( $this->pairs[$key] ); // remove pair by its key
return TRUE; // indicate hit
} | php | public function remove( $key )
{
if( !$this->has( $key ) ) // pair key is not existing
return FALSE; // indicate miss
$key = !$this->caseSensitive ? strtolower( $key ) : $key; // lowercase key if dictionary is not case sensitive
$index = array_search( $key, array_keys( $this->pairs ) ); // index of pair to be removed
if( $index >= $this->position ) // iterator position is beyond pair
$this->position--; // decrease iterator position since pair is removed
unset( $this->pairs[$key] ); // remove pair by its key
return TRUE; // indicate hit
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"// pair key is not existing\r",
"return",
"FALSE",
";",
"// indicate miss\r",
"$",
"key",
"=",
"!",
"$",
"this",
"->",
"caseSensitive",
"?",
"strtolower",
"(",
"$",
"key",
")",
":",
"$",
"key",
";",
"// lowercase key if dictionary is not case sensitive\r",
"$",
"index",
"=",
"array_search",
"(",
"$",
"key",
",",
"array_keys",
"(",
"$",
"this",
"->",
"pairs",
")",
")",
";",
"// index of pair to be removed\r",
"if",
"(",
"$",
"index",
">=",
"$",
"this",
"->",
"position",
")",
"// iterator position is beyond pair\r",
"$",
"this",
"->",
"position",
"--",
";",
"// decrease iterator position since pair is removed\r",
"unset",
"(",
"$",
"this",
"->",
"pairs",
"[",
"$",
"key",
"]",
")",
";",
"// remove pair by its key\r",
"return",
"TRUE",
";",
"// indicate hit\r",
"}"
] | Removes a Value from Dictionary by its Key.
@access public
@param string $key Key in Dictionary
@return boolean | [
"Removes",
"a",
"Value",
"from",
"Dictionary",
"by",
"its",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/List/Dictionary.php#L290-L300 |
36,595 | meritoo/common-library | src/Utilities/QueryBuilderUtility.php | QueryBuilderUtility.getRootAlias | public static function getRootAlias(QueryBuilder $queryBuilder)
{
$aliases = $queryBuilder->getRootAliases();
/*
* No aliases?
* Nothing to do
*/
if (empty($aliases)) {
return null;
}
return Arrays::getFirstElement($aliases);
} | php | public static function getRootAlias(QueryBuilder $queryBuilder)
{
$aliases = $queryBuilder->getRootAliases();
/*
* No aliases?
* Nothing to do
*/
if (empty($aliases)) {
return null;
}
return Arrays::getFirstElement($aliases);
} | [
"public",
"static",
"function",
"getRootAlias",
"(",
"QueryBuilder",
"$",
"queryBuilder",
")",
"{",
"$",
"aliases",
"=",
"$",
"queryBuilder",
"->",
"getRootAliases",
"(",
")",
";",
"/*\n * No aliases?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"aliases",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"Arrays",
"::",
"getFirstElement",
"(",
"$",
"aliases",
")",
";",
"}"
] | Returns root alias of given query builder.
If null is returned, alias was not found.
@param QueryBuilder $queryBuilder The query builder to retrieve root alias
@return null|string | [
"Returns",
"root",
"alias",
"of",
"given",
"query",
"builder",
".",
"If",
"null",
"is",
"returned",
"alias",
"was",
"not",
"found",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L32-L45 |
36,596 | meritoo/common-library | src/Utilities/QueryBuilderUtility.php | QueryBuilderUtility.getJoinedPropertyAlias | public static function getJoinedPropertyAlias(QueryBuilder $queryBuilder, $property)
{
$joins = $queryBuilder->getDQLPart('join');
/*
* No joins?
* Nothing to do
*/
if (empty($joins)) {
return null;
}
$patternTemplate = '/^.+\.%s$/'; // e.g. "SomeThing.PropertyName"
$pattern = sprintf($patternTemplate, $property);
foreach ($joins as $joinExpressions) {
/** @var Join $expression */
foreach ($joinExpressions as $expression) {
$joinedProperty = $expression->getJoin();
if (preg_match($pattern, $joinedProperty)) {
return $expression->getAlias();
}
}
}
return null;
} | php | public static function getJoinedPropertyAlias(QueryBuilder $queryBuilder, $property)
{
$joins = $queryBuilder->getDQLPart('join');
/*
* No joins?
* Nothing to do
*/
if (empty($joins)) {
return null;
}
$patternTemplate = '/^.+\.%s$/'; // e.g. "SomeThing.PropertyName"
$pattern = sprintf($patternTemplate, $property);
foreach ($joins as $joinExpressions) {
/** @var Join $expression */
foreach ($joinExpressions as $expression) {
$joinedProperty = $expression->getJoin();
if (preg_match($pattern, $joinedProperty)) {
return $expression->getAlias();
}
}
}
return null;
} | [
"public",
"static",
"function",
"getJoinedPropertyAlias",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"$",
"property",
")",
"{",
"$",
"joins",
"=",
"$",
"queryBuilder",
"->",
"getDQLPart",
"(",
"'join'",
")",
";",
"/*\n * No joins?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"joins",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"patternTemplate",
"=",
"'/^.+\\.%s$/'",
";",
"// e.g. \"SomeThing.PropertyName\"",
"$",
"pattern",
"=",
"sprintf",
"(",
"$",
"patternTemplate",
",",
"$",
"property",
")",
";",
"foreach",
"(",
"$",
"joins",
"as",
"$",
"joinExpressions",
")",
"{",
"/** @var Join $expression */",
"foreach",
"(",
"$",
"joinExpressions",
"as",
"$",
"expression",
")",
"{",
"$",
"joinedProperty",
"=",
"$",
"expression",
"->",
"getJoin",
"(",
")",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"joinedProperty",
")",
")",
"{",
"return",
"$",
"expression",
"->",
"getAlias",
"(",
")",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns alias of given property joined in given query builder
If there are no joins or the join does not exist, null is returned.
It's also information if given property is already joined in given query builder.
@param QueryBuilder $queryBuilder The query builder to verify
@param string $property Name of property that maybe is joined
@return null|string | [
"Returns",
"alias",
"of",
"given",
"property",
"joined",
"in",
"given",
"query",
"builder"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L57-L84 |
36,597 | meritoo/common-library | src/Utilities/QueryBuilderUtility.php | QueryBuilderUtility.setCriteria | public static function setCriteria(QueryBuilder $queryBuilder, array $criteria = [], $alias = null)
{
/*
* No criteria used in WHERE clause?
* Nothing to do
*/
if (empty($criteria)) {
return $queryBuilder;
}
/*
* No alias provided?
* Let's use root alias
*/
if (null === $alias || '' === $alias) {
$alias = self::getRootAlias($queryBuilder);
}
foreach ($criteria as $column => $value) {
$compareOperator = '=';
if (is_array($value) && !empty($value)) {
if (2 === count($value)) {
$compareOperator = $value[1];
}
$value = $value[0];
}
$predicate = sprintf('%s.%s %s :%s', $alias, $column, $compareOperator, $column);
if (null === $value) {
$predicate = $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $column));
unset($criteria[$column]);
} else {
$queryBuilder->setParameter($column, $value);
}
$queryBuilder = $queryBuilder->andWhere($predicate);
}
return $queryBuilder;
} | php | public static function setCriteria(QueryBuilder $queryBuilder, array $criteria = [], $alias = null)
{
/*
* No criteria used in WHERE clause?
* Nothing to do
*/
if (empty($criteria)) {
return $queryBuilder;
}
/*
* No alias provided?
* Let's use root alias
*/
if (null === $alias || '' === $alias) {
$alias = self::getRootAlias($queryBuilder);
}
foreach ($criteria as $column => $value) {
$compareOperator = '=';
if (is_array($value) && !empty($value)) {
if (2 === count($value)) {
$compareOperator = $value[1];
}
$value = $value[0];
}
$predicate = sprintf('%s.%s %s :%s', $alias, $column, $compareOperator, $column);
if (null === $value) {
$predicate = $queryBuilder->expr()->isNull(sprintf('%s.%s', $alias, $column));
unset($criteria[$column]);
} else {
$queryBuilder->setParameter($column, $value);
}
$queryBuilder = $queryBuilder->andWhere($predicate);
}
return $queryBuilder;
} | [
"public",
"static",
"function",
"setCriteria",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"array",
"$",
"criteria",
"=",
"[",
"]",
",",
"$",
"alias",
"=",
"null",
")",
"{",
"/*\n * No criteria used in WHERE clause?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"criteria",
")",
")",
"{",
"return",
"$",
"queryBuilder",
";",
"}",
"/*\n * No alias provided?\n * Let's use root alias\n */",
"if",
"(",
"null",
"===",
"$",
"alias",
"||",
"''",
"===",
"$",
"alias",
")",
"{",
"$",
"alias",
"=",
"self",
"::",
"getRootAlias",
"(",
"$",
"queryBuilder",
")",
";",
"}",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"$",
"compareOperator",
"=",
"'='",
";",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"&&",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"2",
"===",
"count",
"(",
"$",
"value",
")",
")",
"{",
"$",
"compareOperator",
"=",
"$",
"value",
"[",
"1",
"]",
";",
"}",
"$",
"value",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"}",
"$",
"predicate",
"=",
"sprintf",
"(",
"'%s.%s %s :%s'",
",",
"$",
"alias",
",",
"$",
"column",
",",
"$",
"compareOperator",
",",
"$",
"column",
")",
";",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"$",
"predicate",
"=",
"$",
"queryBuilder",
"->",
"expr",
"(",
")",
"->",
"isNull",
"(",
"sprintf",
"(",
"'%s.%s'",
",",
"$",
"alias",
",",
"$",
"column",
")",
")",
";",
"unset",
"(",
"$",
"criteria",
"[",
"$",
"column",
"]",
")",
";",
"}",
"else",
"{",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"$",
"column",
",",
"$",
"value",
")",
";",
"}",
"$",
"queryBuilder",
"=",
"$",
"queryBuilder",
"->",
"andWhere",
"(",
"$",
"predicate",
")",
";",
"}",
"return",
"$",
"queryBuilder",
";",
"}"
] | Sets the WHERE criteria in given query builder
@param QueryBuilder $queryBuilder The query builder
@param array $criteria (optional) The criteria used in WHERE clause. It may simple array with pairs
key-value or an array of arrays where second element of sub-array is the
comparison operator. Example below.
@param null|string $alias (optional) Alias used in the query
@return QueryBuilder
Example of the $criteria argument:
[
'created_at' => [
'2012-11-17 20:00',
'<'
],
'title' => [
'%test%',
'like'
],
'position' => 5,
] | [
"Sets",
"the",
"WHERE",
"criteria",
"in",
"given",
"query",
"builder"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L109-L151 |
36,598 | meritoo/common-library | src/Utilities/QueryBuilderUtility.php | QueryBuilderUtility.deleteEntities | public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true)
{
/*
* No entities provided?
* Nothing to do
*/
if (empty($entities)) {
return false;
}
foreach ($entities as $entity) {
$entityManager->remove($entity);
}
// The deleted objects should be flushed?
if ($flushDeleted) {
$entityManager->flush();
}
return true;
} | php | public static function deleteEntities(EntityManager $entityManager, $entities, $flushDeleted = true)
{
/*
* No entities provided?
* Nothing to do
*/
if (empty($entities)) {
return false;
}
foreach ($entities as $entity) {
$entityManager->remove($entity);
}
// The deleted objects should be flushed?
if ($flushDeleted) {
$entityManager->flush();
}
return true;
} | [
"public",
"static",
"function",
"deleteEntities",
"(",
"EntityManager",
"$",
"entityManager",
",",
"$",
"entities",
",",
"$",
"flushDeleted",
"=",
"true",
")",
"{",
"/*\n * No entities provided?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"entities",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"entities",
"as",
"$",
"entity",
")",
"{",
"$",
"entityManager",
"->",
"remove",
"(",
"$",
"entity",
")",
";",
"}",
"// The deleted objects should be flushed?",
"if",
"(",
"$",
"flushDeleted",
")",
"{",
"$",
"entityManager",
"->",
"flush",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Deletes given entities
@param EntityManager $entityManager The entity manager
@param array|ArrayCollection $entities The entities to delete
@param bool $flushDeleted (optional) If is set to true, flushes the deleted objects (default
behaviour). Otherwise - not.
@return bool | [
"Deletes",
"given",
"entities"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L162-L182 |
36,599 | meritoo/common-library | src/Utilities/QueryBuilderUtility.php | QueryBuilderUtility.addParameters | public static function addParameters(QueryBuilder $queryBuilder, $parameters)
{
/*
* No parameters?
* Nothing to do
*/
if (empty($parameters)) {
return $queryBuilder;
}
foreach ($parameters as $key => $parameter) {
$name = $key;
$value = $parameter;
if ($parameter instanceof Parameter) {
$name = $parameter->getName();
$value = $parameter->getValue();
}
$queryBuilder->setParameter($name, $value);
}
return $queryBuilder;
} | php | public static function addParameters(QueryBuilder $queryBuilder, $parameters)
{
/*
* No parameters?
* Nothing to do
*/
if (empty($parameters)) {
return $queryBuilder;
}
foreach ($parameters as $key => $parameter) {
$name = $key;
$value = $parameter;
if ($parameter instanceof Parameter) {
$name = $parameter->getName();
$value = $parameter->getValue();
}
$queryBuilder->setParameter($name, $value);
}
return $queryBuilder;
} | [
"public",
"static",
"function",
"addParameters",
"(",
"QueryBuilder",
"$",
"queryBuilder",
",",
"$",
"parameters",
")",
"{",
"/*\n * No parameters?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"parameters",
")",
")",
"{",
"return",
"$",
"queryBuilder",
";",
"}",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"parameter",
")",
"{",
"$",
"name",
"=",
"$",
"key",
";",
"$",
"value",
"=",
"$",
"parameter",
";",
"if",
"(",
"$",
"parameter",
"instanceof",
"Parameter",
")",
"{",
"$",
"name",
"=",
"$",
"parameter",
"->",
"getName",
"(",
")",
";",
"$",
"value",
"=",
"$",
"parameter",
"->",
"getValue",
"(",
")",
";",
"}",
"$",
"queryBuilder",
"->",
"setParameter",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"queryBuilder",
";",
"}"
] | Adds given parameters to given query builder.
Attention. Existing parameters will be overridden.
@param QueryBuilder $queryBuilder The query builder
@param array|ArrayCollection $parameters Parameters to add. Collection of Doctrine\ORM\Query\Parameter
instances or an array with key-value pairs.
@return QueryBuilder | [
"Adds",
"given",
"parameters",
"to",
"given",
"query",
"builder",
".",
"Attention",
".",
"Existing",
"parameters",
"will",
"be",
"overridden",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/QueryBuilderUtility.php#L193-L216 |
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.