repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.setDocType | public function setDocType( $doctype )
{
$doctypes = array_keys( $this->doctypes );
$key = str_replace( array( ' ', '-' ), '_', trim( $doctype ) );
$key = preg_replace( "/[^A-Z0-9_]/", '', strtoupper( $key ) );
if( !strlen( trim( $key ) ) )
throw new InvalidArgumentException( 'No doctype given' );
if( !array_key_exists( $key, $this->doctypes ) )
throw new OutOfRangeException( 'Doctype "'.$doctype.'" (understood as '.$key.') is invalid' );
$this->doctype = $key;
} | php | public function setDocType( $doctype )
{
$doctypes = array_keys( $this->doctypes );
$key = str_replace( array( ' ', '-' ), '_', trim( $doctype ) );
$key = preg_replace( "/[^A-Z0-9_]/", '', strtoupper( $key ) );
if( !strlen( trim( $key ) ) )
throw new InvalidArgumentException( 'No doctype given' );
if( !array_key_exists( $key, $this->doctypes ) )
throw new OutOfRangeException( 'Doctype "'.$doctype.'" (understood as '.$key.') is invalid' );
$this->doctype = $key;
} | [
"public",
"function",
"setDocType",
"(",
"$",
"doctype",
")",
"{",
"$",
"doctypes",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"doctypes",
")",
";",
"$",
"key",
"=",
"str_replace",
"(",
"array",
"(",
"' '",
",",
"'-'",
")",
",",
"'_'",
",",
"trim",
... | Sets document type of page.
@access public
@param string $doctype Document type to set
@return void
@see http://www.w3.org/QA/2002/04/valid-dtd-list.html | [
"Sets",
"document",
"type",
"of",
"page",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L359-L369 | train |
CeusMedia/Common | src/UI/HTML/PageFrame.php | UI_HTML_PageFrame.setTitle | public function setTitle( $title, $mode = 'set', $separator = ' | ' )
{
if( $mode == 'append' || $mode === 1 )
$title = $this->title.$separator.$title;
else if( $mode == 'prepend' || $mode === -1 )
$title = $title.$separator.$this->title;
$this->title = $title;
} | php | public function setTitle( $title, $mode = 'set', $separator = ' | ' )
{
if( $mode == 'append' || $mode === 1 )
$title = $this->title.$separator.$title;
else if( $mode == 'prepend' || $mode === -1 )
$title = $title.$separator.$this->title;
$this->title = $title;
} | [
"public",
"function",
"setTitle",
"(",
"$",
"title",
",",
"$",
"mode",
"=",
"'set'",
",",
"$",
"separator",
"=",
"' | '",
")",
"{",
"if",
"(",
"$",
"mode",
"==",
"'append'",
"||",
"$",
"mode",
"===",
"1",
")",
"$",
"title",
"=",
"$",
"this",
"->"... | Sets Page Title, visible in Browser Title Bar.
@access public
@param string $title Page Title
@return void | [
"Sets",
"Page",
"Title",
"visible",
"in",
"Browser",
"Title",
"Bar",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/PageFrame.php#L397-L404 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Controller/HttpManagerTrait.php | HttpManagerTrait.json | protected function json(array $data = [], string $status = Response::HTTP_OK): JsonResponse
{
$headers = $this->getResponse()->headers->all();
$serializedData = [];
foreach ($data as $key => $item) {
if (is_array($item) && is_object($item[0])) {
$serializedData[$key] = EntityNormalizer::normalize($item);
unset($data[$key]);
}
if (is_object($item)) {
$serializedData[$key] = EntityNormalizer::normalize([$item])[0];
unset($data[$key]);
}
}
$serializedData = array_merge($serializedData, $data);
return new JsonResponse($serializedData, $status, $headers);
} | php | protected function json(array $data = [], string $status = Response::HTTP_OK): JsonResponse
{
$headers = $this->getResponse()->headers->all();
$serializedData = [];
foreach ($data as $key => $item) {
if (is_array($item) && is_object($item[0])) {
$serializedData[$key] = EntityNormalizer::normalize($item);
unset($data[$key]);
}
if (is_object($item)) {
$serializedData[$key] = EntityNormalizer::normalize([$item])[0];
unset($data[$key]);
}
}
$serializedData = array_merge($serializedData, $data);
return new JsonResponse($serializedData, $status, $headers);
} | [
"protected",
"function",
"json",
"(",
"array",
"$",
"data",
"=",
"[",
"]",
",",
"string",
"$",
"status",
"=",
"Response",
"::",
"HTTP_OK",
")",
":",
"JsonResponse",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"getResponse",
"(",
")",
"->",
"headers",
... | Returns JSON encoded response
@param array $data Data supposed to be returned
@param string $status Response status code
@return JsonResponse | [
"Returns",
"JSON",
"encoded",
"response"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/HttpManagerTrait.php#L128-L151 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Controller/HttpManagerTrait.php | HttpManagerTrait.configureCorsIfEnabled | protected function configureCorsIfEnabled(): void
{
$reflection = new \ReflectionClass($this);
$reader = new AnnotationReader();
$annotation = $reader->getClassAnnotation($reflection, CORS::class);
if (empty($annotation)) {
return;
}
$corsConfig = [
'Access-Control-Allow-Origin' => $annotation->origins ?? '*',
'Access-Control-Allow-Methods' => $annotation->methods ?? 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers' => $annotation->headers ?? '*',
'Access-Control-Allow-Credentials' => $annotation->credentials ?? true,
'Access-Control-Allow-Max-Age' => $annotation->maxAge ?? 3600
];
foreach ($corsConfig as $key => $value) {
$this->getResponse()->headers->set($key, $value);
}
} | php | protected function configureCorsIfEnabled(): void
{
$reflection = new \ReflectionClass($this);
$reader = new AnnotationReader();
$annotation = $reader->getClassAnnotation($reflection, CORS::class);
if (empty($annotation)) {
return;
}
$corsConfig = [
'Access-Control-Allow-Origin' => $annotation->origins ?? '*',
'Access-Control-Allow-Methods' => $annotation->methods ?? 'GET, POST, PUT, DELETE, OPTIONS',
'Access-Control-Allow-Headers' => $annotation->headers ?? '*',
'Access-Control-Allow-Credentials' => $annotation->credentials ?? true,
'Access-Control-Allow-Max-Age' => $annotation->maxAge ?? 3600
];
foreach ($corsConfig as $key => $value) {
$this->getResponse()->headers->set($key, $value);
}
} | [
"protected",
"function",
"configureCorsIfEnabled",
"(",
")",
":",
"void",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
";",
"$",
"reader",
"=",
"new",
"AnnotationReader",
"(",
")",
";",
"$",
"annotation",
"=",
"$",
... | Configures CORS in controller if is enabled by annotation
@throws \Doctrine\Common\Annotations\AnnotationException
@throws \ReflectionException | [
"Configures",
"CORS",
"in",
"controller",
"if",
"is",
"enabled",
"by",
"annotation"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/HttpManagerTrait.php#L169-L191 | train |
CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.addEdge | public function addEdge( $sourceNode, $targetNode, $value = NULL )
{
if( $this->isEdge( $sourceNode, $targetNode ) )
{
$edge = $this->getEdge( $sourceNode, $targetNode );
if( $value == $edge->getEdgeValue( $sourceNode, $targetNode ) )
throw new InvalidArgumentException( 'Edge is already set.' );
else
$this->removeEdge( $sourceNode, $targetNode );
}
$newEdge = new ADT_Graph_Edge( $sourceNode, $targetNode, $value );
$this->edges[] = $newEdge;
return $newEdge;
} | php | public function addEdge( $sourceNode, $targetNode, $value = NULL )
{
if( $this->isEdge( $sourceNode, $targetNode ) )
{
$edge = $this->getEdge( $sourceNode, $targetNode );
if( $value == $edge->getEdgeValue( $sourceNode, $targetNode ) )
throw new InvalidArgumentException( 'Edge is already set.' );
else
$this->removeEdge( $sourceNode, $targetNode );
}
$newEdge = new ADT_Graph_Edge( $sourceNode, $targetNode, $value );
$this->edges[] = $newEdge;
return $newEdge;
} | [
"public",
"function",
"addEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
")",
"{",
"$",
"edge",
"=",
"$",... | Adds a new Edge and returns reference of this Edge.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@param int $value Value of this Edge
@return ADT_Graph_Node | [
"Adds",
"a",
"new",
"Edge",
"and",
"returns",
"reference",
"of",
"this",
"Edge",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L53-L66 | train |
CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.getEdge | public function getEdge( $sourceNode, $targetNode )
{
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
return $this->edges[$index];
} | php | public function getEdge( $sourceNode, $targetNode )
{
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
return $this->edges[$index];
} | [
"public",
"function",
"getEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getEdgeIndex",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
";",
"return",
"$",
"this",
"->",
"edges",
"[",
"$",
... | Returns an Edge existing in this EdgeSet.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return int | [
"Returns",
"an",
"Edge",
"existing",
"in",
"this",
"EdgeSet",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L85-L89 | train |
CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.getEdgeIndex | private function getEdgeIndex( $sourceNode, $targetNode )
{
for( $i=0; $i<sizeof( $this->edges ); $i++ )
{
$edge = $this->edges[$i];
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return $i;
}
return -1;
} | php | private function getEdgeIndex( $sourceNode, $targetNode )
{
for( $i=0; $i<sizeof( $this->edges ); $i++ )
{
$edge = $this->edges[$i];
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return $i;
}
return -1;
} | [
"private",
"function",
"getEdgeIndex",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"sizeof",
"(",
"$",
"this",
"->",
"edges",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"edge",
"="... | Returns Index of an Edge in this EdgeSet.
@access private
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return int | [
"Returns",
"Index",
"of",
"an",
"Edge",
"in",
"this",
"EdgeSet",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L98-L109 | train |
CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.isEdge | public function isEdge( $sourceNode, $targetNode )
{
foreach( $this->edges as $edge )
{
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return TRUE;
}
return FALSE;
} | php | public function isEdge( $sourceNode, $targetNode )
{
foreach( $this->edges as $edge )
{
$isSource = $edge->getSourceNode() == $sourceNode;
$isTarget = $edge->getTargetNode() == $targetNode;
if( $isSource && $isTarget )
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"isEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"edges",
"as",
"$",
"edge",
")",
"{",
"$",
"isSource",
"=",
"$",
"edge",
"->",
"getSourceNode",
"(",
")",
"==",
"$",
"sourceN... | Indicates whether an Edge is existing in this EdgeSet.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return bool | [
"Indicates",
"whether",
"an",
"Edge",
"is",
"existing",
"in",
"this",
"EdgeSet",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L128-L138 | train |
CeusMedia/Common | src/ADT/Graph/EdgeSet.php | ADT_Graph_EdgeSet.removeEdge | public function removeEdge( $sourceNode, $targetNode )
{
if( !$this->isEdge( $sourceNode, $targetNode ) )
throw new Exception( 'Edge is not existing.' );
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
unset( $this->edges[$index] );
sort( $this->edges );
} | php | public function removeEdge( $sourceNode, $targetNode )
{
if( !$this->isEdge( $sourceNode, $targetNode ) )
throw new Exception( 'Edge is not existing.' );
$index = $this->getEdgeIndex( $sourceNode, $targetNode );
unset( $this->edges[$index] );
sort( $this->edges );
} | [
"public",
"function",
"removeEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEdge",
"(",
"$",
"sourceNode",
",",
"$",
"targetNode",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Edge is not existing.'"... | Removing an Edge.
@access public
@param ADT_Graph_Node $sourceNode Source Node of this Edge
@param ADT_Graph_Node $targetNode Target Node of this Edge
@return void | [
"Removing",
"an",
"Edge",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/EdgeSet.php#L147-L154 | train |
grape-fluid/grape-fluid | src/Security/User.php | User.isAllowed | public function isAllowed($resource = Nette\Security\IAuthorizator::ALL, $privilege = Nette\Security\IAuthorizator::ALL)
{
$defaultNamespace = null;
if (strpos($resource, ":") !== false) {
$exploded = explode(":", $resource);
if (count($exploded) == 2) {
list($namespace, $resource) = $exploded;
$defaultNamespace = $this->namespacesRepository->getDefaultNamespace();
$this->namespacesRepository->setCurrentNamespace($namespace);
}
}
foreach ($this->getRoles() as $role) {
if ($this->getAuthorizator()->isAllowed($role, $resource, $privilege)) {
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return true;
}
}
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return false;
} | php | public function isAllowed($resource = Nette\Security\IAuthorizator::ALL, $privilege = Nette\Security\IAuthorizator::ALL)
{
$defaultNamespace = null;
if (strpos($resource, ":") !== false) {
$exploded = explode(":", $resource);
if (count($exploded) == 2) {
list($namespace, $resource) = $exploded;
$defaultNamespace = $this->namespacesRepository->getDefaultNamespace();
$this->namespacesRepository->setCurrentNamespace($namespace);
}
}
foreach ($this->getRoles() as $role) {
if ($this->getAuthorizator()->isAllowed($role, $resource, $privilege)) {
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return true;
}
}
$this->namespacesRepository->setCurrentNamespace($defaultNamespace);
return false;
} | [
"public",
"function",
"isAllowed",
"(",
"$",
"resource",
"=",
"Nette",
"\\",
"Security",
"\\",
"IAuthorizator",
"::",
"ALL",
",",
"$",
"privilege",
"=",
"Nette",
"\\",
"Security",
"\\",
"IAuthorizator",
"::",
"ALL",
")",
"{",
"$",
"defaultNamespace",
"=",
... | Ma uzivatel pristup k zadanemu zdroji?
@param string $resource - Jmeno zdroje
@param $privilege - Pouze pro zachování kompatibility s Nette\Security\User
@return bool | [
"Ma",
"uzivatel",
"pristup",
"k",
"zadanemu",
"zdroji?"
] | 3696150cced6f419469071c33acaf39a6e29ecab | https://github.com/grape-fluid/grape-fluid/blob/3696150cced6f419469071c33acaf39a6e29ecab/src/Security/User.php#L19-L41 | train |
CeusMedia/Common | src/Net/HTTP/Header/Parser.php | Net_HTTP_Header_Parser.parse | static public function parse( $string )
{
$section = new Net_HTTP_Header_Section();
$lines = explode( PHP_EOL, trim( $string ) );
foreach( $lines as $line )
{
if( preg_match( '@^HTTP/@', $line ) )
continue;
if( strlen( trim( $line ) ) )
$section->addField( Net_HTTP_Header_Field_Parser::parse( $line ) );
}
return $section;
} | php | static public function parse( $string )
{
$section = new Net_HTTP_Header_Section();
$lines = explode( PHP_EOL, trim( $string ) );
foreach( $lines as $line )
{
if( preg_match( '@^HTTP/@', $line ) )
continue;
if( strlen( trim( $line ) ) )
$section->addField( Net_HTTP_Header_Field_Parser::parse( $line ) );
}
return $section;
} | [
"static",
"public",
"function",
"parse",
"(",
"$",
"string",
")",
"{",
"$",
"section",
"=",
"new",
"Net_HTTP_Header_Section",
"(",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"PHP_EOL",
",",
"trim",
"(",
"$",
"string",
")",
")",
";",
"foreach",
"(",
... | Parses block of HTTP headers and returns list of HTTP header field objects.
@static
@access public
@param $string HTTP headers encoded as string
@return Net_HTTP_Header_Section | [
"Parses",
"block",
"of",
"HTTP",
"headers",
"and",
"returns",
"list",
"of",
"HTTP",
"header",
"field",
"objects",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Parser.php#L49-L61 | train |
CeusMedia/Common | src/UI/Image/Captcha.php | UI_Image_Captcha.generate | public function generate( $fileName ){
$word = $this->generateWord();
$this->generateImage( $word, $fileName );
return $word;
} | php | public function generate( $fileName ){
$word = $this->generateWord();
$this->generateImage( $word, $fileName );
return $word;
} | [
"public",
"function",
"generate",
"(",
"$",
"fileName",
")",
"{",
"$",
"word",
"=",
"$",
"this",
"->",
"generateWord",
"(",
")",
";",
"$",
"this",
"->",
"generateImage",
"(",
"$",
"word",
",",
"$",
"fileName",
")",
";",
"return",
"$",
"word",
";",
... | Generates CAPTCHA image file and returns generated and used CAPTCHA word.
@access public
@param string $fileName Name of CAPTCHA image file to create
@return string CAPTCHA word rendered in image file | [
"Generates",
"CAPTCHA",
"image",
"file",
"and",
"returns",
"generated",
"and",
"used",
"CAPTCHA",
"word",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Captcha.php#L77-L81 | train |
CeusMedia/Common | src/UI/Image/Captcha.php | UI_Image_Captcha.generateImage | public function generateImage( $word, $fileName = NULL )
{
if( !$this->font )
throw new RuntimeException( 'No font defined' );
if( !( is_array( $this->textColor ) && count( $this->textColor ) == 3 ) )
throw new InvalidArgumentException( 'Text Color must be an Array of 3 decimal Values.' );
if( !( is_array( $this->background ) && count( $this->background ) == 3 ) )
throw new InvalidArgumentException( 'Background Color must be an Array of 3 decimal Values.' );
$image = imagecreate( $this->width, $this->height );
$backColor = imagecolorallocate( $image, $this->background[0], $this->background[1], $this->background[2] );
$frontColor = imagecolorallocate( $image, $this->textColor[0], $this->textColor[1], $this->textColor[2] );
for( $i=0; $i<strlen( $word ); $i++ )
{
// -- ANGLE -- //
$angle = 0;
if( $this->angle )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$angle = round( $rand * $this->angle, 0 ); // calculate rounded Angle
}
// -- POSITION X -- //
$offset = 0;
if( $this->offsetX )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetX, 0 ); // calculate rounded Offset
}
$posX = $i * 20 + $offset + 10;
// -- POSITION Y -- //
$offset = 0;
if( $this->offsetY )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetY, 0 ); // calculate rounded Offset
}
$posY = $offset + round( $this->height / 2, 0 ) + 5;
$char = $word[$i];
imagettftext( $image, $this->fontSize, $angle, $posX, $posY, $frontColor, $this->font, $char );
}
ob_start();
imagejpeg( $image, NULL, $this->quality );
if( $fileName )
return FS_File_Writer::save( $fileName, ob_get_clean() );
return ob_get_clean();
} | php | public function generateImage( $word, $fileName = NULL )
{
if( !$this->font )
throw new RuntimeException( 'No font defined' );
if( !( is_array( $this->textColor ) && count( $this->textColor ) == 3 ) )
throw new InvalidArgumentException( 'Text Color must be an Array of 3 decimal Values.' );
if( !( is_array( $this->background ) && count( $this->background ) == 3 ) )
throw new InvalidArgumentException( 'Background Color must be an Array of 3 decimal Values.' );
$image = imagecreate( $this->width, $this->height );
$backColor = imagecolorallocate( $image, $this->background[0], $this->background[1], $this->background[2] );
$frontColor = imagecolorallocate( $image, $this->textColor[0], $this->textColor[1], $this->textColor[2] );
for( $i=0; $i<strlen( $word ); $i++ )
{
// -- ANGLE -- //
$angle = 0;
if( $this->angle )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$angle = round( $rand * $this->angle, 0 ); // calculate rounded Angle
}
// -- POSITION X -- //
$offset = 0;
if( $this->offsetX )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetX, 0 ); // calculate rounded Offset
}
$posX = $i * 20 + $offset + 10;
// -- POSITION Y -- //
$offset = 0;
if( $this->offsetY )
{
$rand = 2 * rand() / getrandmax() - 1; // randomize Float between -1 and 1
$offset = round( $rand * $this->offsetY, 0 ); // calculate rounded Offset
}
$posY = $offset + round( $this->height / 2, 0 ) + 5;
$char = $word[$i];
imagettftext( $image, $this->fontSize, $angle, $posX, $posY, $frontColor, $this->font, $char );
}
ob_start();
imagejpeg( $image, NULL, $this->quality );
if( $fileName )
return FS_File_Writer::save( $fileName, ob_get_clean() );
return ob_get_clean();
} | [
"public",
"function",
"generateImage",
"(",
"$",
"word",
",",
"$",
"fileName",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"font",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No font defined'",
")",
";",
"if",
"(",
"!",
"(",
"is_array... | Generates Captcha Image for Captcha Word.
Saves image if file name is set.
Otherwise returns binary content of image.
@access public
@param string $word Captcha Word
@param string $fileName File Name to write Captcha Image to
@return int | [
"Generates",
"Captcha",
"Image",
"for",
"Captcha",
"Word",
".",
"Saves",
"image",
"if",
"file",
"name",
"is",
"set",
".",
"Otherwise",
"returns",
"binary",
"content",
"of",
"image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Captcha.php#L92-L141 | train |
CeusMedia/Common | src/UI/Image/Captcha.php | UI_Image_Captcha.generateWord | public function generateWord()
{
$rand = new Alg_Randomizer();
$rand->digits = "2345678";
$rand->larges = "ABCDEFGHIKLMNPQRSTUVWXYZ";
$rand->smalls = "abcdefghiklmnpqrstuvwxyz";
$rand->useSmalls = $this->useSmalls;
$rand->useLarges = $this->useLarges;
$rand->useDigits = $this->useDigits;
$rand->useSigns = FALSE;
$rand->unique = $this->unique;
return $rand->get( $this->length );
} | php | public function generateWord()
{
$rand = new Alg_Randomizer();
$rand->digits = "2345678";
$rand->larges = "ABCDEFGHIKLMNPQRSTUVWXYZ";
$rand->smalls = "abcdefghiklmnpqrstuvwxyz";
$rand->useSmalls = $this->useSmalls;
$rand->useLarges = $this->useLarges;
$rand->useDigits = $this->useDigits;
$rand->useSigns = FALSE;
$rand->unique = $this->unique;
return $rand->get( $this->length );
} | [
"public",
"function",
"generateWord",
"(",
")",
"{",
"$",
"rand",
"=",
"new",
"Alg_Randomizer",
"(",
")",
";",
"$",
"rand",
"->",
"digits",
"=",
"\"2345678\"",
";",
"$",
"rand",
"->",
"larges",
"=",
"\"ABCDEFGHIKLMNPQRSTUVWXYZ\"",
";",
"$",
"rand",
"->",
... | Generates CAPTCHA Word.
@access public
@return string | [
"Generates",
"CAPTCHA",
"Word",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Captcha.php#L148-L160 | train |
meritoo/common-library | src/Utilities/Date.php | Date.getCurrentDayOfWeek | public static function getCurrentDayOfWeek()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeek($year, $month, $day);
} | php | public static function getCurrentDayOfWeek()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeek($year, $month, $day);
} | [
"public",
"static",
"function",
"getCurrentDayOfWeek",
"(",
")",
"{",
"$",
"now",
"=",
"new",
"DateTime",
"(",
")",
";",
"$",
"year",
"=",
"$",
"now",
"->",
"format",
"(",
"'Y'",
")",
";",
"$",
"month",
"=",
"$",
"now",
"->",
"format",
"(",
"'m'",
... | Returns current day of week
@return int | [
"Returns",
"current",
"day",
"of",
"week"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L232-L241 | train |
meritoo/common-library | src/Utilities/Date.php | Date.getCurrentDayOfWeekName | public static function getCurrentDayOfWeekName()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeekName($year, $month, $day);
} | php | public static function getCurrentDayOfWeekName()
{
$now = new DateTime();
$year = $now->format('Y');
$month = $now->format('m');
$day = $now->format('d');
return self::getDayOfWeekName($year, $month, $day);
} | [
"public",
"static",
"function",
"getCurrentDayOfWeekName",
"(",
")",
"{",
"$",
"now",
"=",
"new",
"DateTime",
"(",
")",
";",
"$",
"year",
"=",
"$",
"now",
"->",
"format",
"(",
"'Y'",
")",
";",
"$",
"month",
"=",
"$",
"now",
"->",
"format",
"(",
"'m... | Returns based on locale name of current weekday
@return string | [
"Returns",
"based",
"on",
"locale",
"name",
"of",
"current",
"weekday"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L296-L305 | train |
meritoo/common-library | src/Utilities/Date.php | Date.getDayOfWeekName | public static function getDayOfWeekName($year, $month, $day)
{
$hour = 0;
$minute = 0;
$second = 0;
$time = mktime($hour, $minute, $second, $month, $day, $year);
$name = strftime('%A', $time);
$encoding = mb_detect_encoding($name);
if (false === $encoding) {
$name = mb_convert_encoding($name, 'UTF-8', 'ISO-8859-2');
}
return $name;
} | php | public static function getDayOfWeekName($year, $month, $day)
{
$hour = 0;
$minute = 0;
$second = 0;
$time = mktime($hour, $minute, $second, $month, $day, $year);
$name = strftime('%A', $time);
$encoding = mb_detect_encoding($name);
if (false === $encoding) {
$name = mb_convert_encoding($name, 'UTF-8', 'ISO-8859-2');
}
return $name;
} | [
"public",
"static",
"function",
"getDayOfWeekName",
"(",
"$",
"year",
",",
"$",
"month",
",",
"$",
"day",
")",
"{",
"$",
"hour",
"=",
"0",
";",
"$",
"minute",
"=",
"0",
";",
"$",
"second",
"=",
"0",
";",
"$",
"time",
"=",
"mktime",
"(",
"$",
"h... | Returns name of weekday based on locale
@param int $year The year value
@param int $month The month value
@param int $day The day value
@return string | [
"Returns",
"name",
"of",
"weekday",
"based",
"on",
"locale"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L315-L331 | train |
meritoo/common-library | src/Utilities/Date.php | Date.getDateDifference | public static function getDateDifference($dateStart, $dateEnd, $differenceUnit = null)
{
$validDateStart = self::isValidDate($dateStart, true);
$validDateEnd = self::isValidDate($dateEnd, true);
/*
* The start or end date is unknown?
* or
* The start or end date is not valid date?
*
* Nothing to do
*/
if (empty($dateStart) || empty($dateEnd) || !$validDateStart || !$validDateEnd) {
return null;
}
$start = self::getDateTime($dateStart, true);
$end = self::getDateTime($dateEnd, true);
$difference = [];
$dateDiff = $end->getTimestamp() - $start->getTimestamp();
$daysInSeconds = 0;
$hoursInSeconds = 0;
$hourSeconds = 60 * 60;
$daySeconds = $hourSeconds * 24;
/*
* These units are related, because while calculating difference in the lowest unit, difference in the
* highest unit is required, e.g. while calculating hours I have to know difference in days
*/
$relatedUnits = [
self::DATE_DIFFERENCE_UNIT_DAYS,
self::DATE_DIFFERENCE_UNIT_HOURS,
self::DATE_DIFFERENCE_UNIT_MINUTES,
];
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in years should be returned only?
if (self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
return $diff->y;
}
$difference[self::DATE_DIFFERENCE_UNIT_YEARS] = $diff->y;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in months should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
return $diff->m;
}
$difference[self::DATE_DIFFERENCE_UNIT_MONTHS] = $diff->m;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$days = (int)floor($dateDiff / $daySeconds);
// Difference between dates in days should be returned only?
if (self::DATE_DIFFERENCE_UNIT_DAYS === $differenceUnit) {
return $days;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_DAYS] = $days;
}
// Calculation for later usage
$daysInSeconds = $days * $daySeconds;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$hours = (int)floor(($dateDiff - $daysInSeconds) / $hourSeconds);
// Difference between dates in hours should be returned only?
if (self::DATE_DIFFERENCE_UNIT_HOURS === $differenceUnit) {
return $hours;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_HOURS] = $hours;
}
// Calculation for later usage
$hoursInSeconds = $hours * $hourSeconds;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
$minutes = (int)floor(($dateDiff - $daysInSeconds - $hoursInSeconds) / 60);
// Difference between dates in minutes should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
return $minutes;
}
$difference[self::DATE_DIFFERENCE_UNIT_MINUTES] = $minutes;
}
return $difference;
} | php | public static function getDateDifference($dateStart, $dateEnd, $differenceUnit = null)
{
$validDateStart = self::isValidDate($dateStart, true);
$validDateEnd = self::isValidDate($dateEnd, true);
/*
* The start or end date is unknown?
* or
* The start or end date is not valid date?
*
* Nothing to do
*/
if (empty($dateStart) || empty($dateEnd) || !$validDateStart || !$validDateEnd) {
return null;
}
$start = self::getDateTime($dateStart, true);
$end = self::getDateTime($dateEnd, true);
$difference = [];
$dateDiff = $end->getTimestamp() - $start->getTimestamp();
$daysInSeconds = 0;
$hoursInSeconds = 0;
$hourSeconds = 60 * 60;
$daySeconds = $hourSeconds * 24;
/*
* These units are related, because while calculating difference in the lowest unit, difference in the
* highest unit is required, e.g. while calculating hours I have to know difference in days
*/
$relatedUnits = [
self::DATE_DIFFERENCE_UNIT_DAYS,
self::DATE_DIFFERENCE_UNIT_HOURS,
self::DATE_DIFFERENCE_UNIT_MINUTES,
];
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in years should be returned only?
if (self::DATE_DIFFERENCE_UNIT_YEARS === $differenceUnit) {
return $diff->y;
}
$difference[self::DATE_DIFFERENCE_UNIT_YEARS] = $diff->y;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
$diff = $end->diff($start);
// Difference between dates in months should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MONTHS === $differenceUnit) {
return $diff->m;
}
$difference[self::DATE_DIFFERENCE_UNIT_MONTHS] = $diff->m;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$days = (int)floor($dateDiff / $daySeconds);
// Difference between dates in days should be returned only?
if (self::DATE_DIFFERENCE_UNIT_DAYS === $differenceUnit) {
return $days;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_DAYS] = $days;
}
// Calculation for later usage
$daysInSeconds = $days * $daySeconds;
}
if (null === $differenceUnit || in_array($differenceUnit, $relatedUnits, true)) {
$hours = (int)floor(($dateDiff - $daysInSeconds) / $hourSeconds);
// Difference between dates in hours should be returned only?
if (self::DATE_DIFFERENCE_UNIT_HOURS === $differenceUnit) {
return $hours;
}
// All units should be returned?
if (null === $differenceUnit) {
$difference[self::DATE_DIFFERENCE_UNIT_HOURS] = $hours;
}
// Calculation for later usage
$hoursInSeconds = $hours * $hourSeconds;
}
if (null === $differenceUnit || self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
$minutes = (int)floor(($dateDiff - $daysInSeconds - $hoursInSeconds) / 60);
// Difference between dates in minutes should be returned only?
if (self::DATE_DIFFERENCE_UNIT_MINUTES === $differenceUnit) {
return $minutes;
}
$difference[self::DATE_DIFFERENCE_UNIT_MINUTES] = $minutes;
}
return $difference;
} | [
"public",
"static",
"function",
"getDateDifference",
"(",
"$",
"dateStart",
",",
"$",
"dateEnd",
",",
"$",
"differenceUnit",
"=",
"null",
")",
"{",
"$",
"validDateStart",
"=",
"self",
"::",
"isValidDate",
"(",
"$",
"dateStart",
",",
"true",
")",
";",
"$",
... | Returns difference between given dates.
The difference is calculated in units based on the 3rd argument or all available unit of date difference
(defined as DATE_DIFFERENCE_UNIT_* constants of this class).
The difference is also whole / complete value for given unit instead of relative value as may be received by
DateTime::diff() method, e.g.:
- 2 days, 50 hours
instead of
- 2 days, 2 hours
If the unit of date difference is null, all units are returned in array (units are keys of the array).
Otherwise - one, integer value is returned.
@param DateTime|string $dateStart The start date
@param DateTime|string $dateEnd The end date
@param string $differenceUnit (optional) Unit of date difference. One of this class
DATE_DIFFERENCE_UNIT_* constants. If is set to null all units are
returned in the array.
@return array|int | [
"Returns",
"difference",
"between",
"given",
"dates",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L355-L461 | train |
meritoo/common-library | src/Utilities/Date.php | Date.getRandomDate | public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
{
if (null === $startDate) {
$startDate = new DateTime();
}
$start = (int)$start;
$end = (int)$end;
/*
* Incorrect end of random partition?
* Use start as the end of random partition
*/
if ($end < $start) {
$end = $start;
}
$randomDate = clone $startDate;
$randomInterval = new DateInterval(sprintf($intervalTemplate, mt_rand($start, $end)));
return $randomDate->add($randomInterval);
} | php | public static function getRandomDate(DateTime $startDate = null, $start = 1, $end = 100, $intervalTemplate = 'P%sD')
{
if (null === $startDate) {
$startDate = new DateTime();
}
$start = (int)$start;
$end = (int)$end;
/*
* Incorrect end of random partition?
* Use start as the end of random partition
*/
if ($end < $start) {
$end = $start;
}
$randomDate = clone $startDate;
$randomInterval = new DateInterval(sprintf($intervalTemplate, mt_rand($start, $end)));
return $randomDate->add($randomInterval);
} | [
"public",
"static",
"function",
"getRandomDate",
"(",
"DateTime",
"$",
"startDate",
"=",
"null",
",",
"$",
"start",
"=",
"1",
",",
"$",
"end",
"=",
"100",
",",
"$",
"intervalTemplate",
"=",
"'P%sD'",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"startDate"... | Returns random date based on given start date
@param DateTime $startDate (optional) Beginning of the random date. If not provided, current date will
be used (default behaviour).
@param int $start (optional) Start of random partition. If not provided, 1 will be used
(default behaviour).
@param int $end (optional) End of random partition. If not provided, 100 will be used
(default behaviour).
@param string $intervalTemplate (optional) Template used to build date interval. The placeholder is replaced
with next, iterated value. If not provided, "P%sD" will be used (default
behaviour).
@throws Exception
@return DateTime | [
"Returns",
"random",
"date",
"based",
"on",
"given",
"start",
"date"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L525-L546 | train |
meritoo/common-library | src/Utilities/Date.php | Date.getDateTime | public static function getDateTime($value, $allowCompoundFormats = false, $dateFormat = 'Y-m-d')
{
/*
* Empty value?
* Nothing to do :)
*/
if (empty($value)) {
return false;
}
/*
* Instance of DateTime class?
* Nothing to do :)
*/
if ($value instanceof DateTime) {
return $value;
}
try {
try {
/*
* Pass the value to the constructor. Maybe it's one of the allowed relative formats.
* Examples: "now", "last day of next month"
*/
$date = new DateTime($value);
/*
* Instance of the DateTime class was created.
* Let's verify if given value is really proper date.
*/
$dateFromFormat = DateTime::createFromFormat($dateFormat, $value);
if (false === $dateFromFormat) {
/*
* Nothing to do more, because:
* a) instance of the DateTime was created
* and
* b) if createFromFormat() method failed, given value is one of the allowed relative formats
* ("now", "last day of next month")
* and...
*/
if ($allowCompoundFormats) {
/*
* ...and
* c) it's not an integer, e.g. not 10 or 100 or 1000
*/
if (!is_numeric($value)) {
return $date;
}
} else {
$specialFormats = [
'now',
];
/*
* ...and
* c) it's special compound format that contains characters that each may be used by
* DateTime::format() method and it raises problem while trying to verify the value at the end
* of this method:
*
* (new DateTime())->format($value);
*
* So, I have to refuse those special compound formats if they are not explicitly declared as
* compound (2nd argument of this method, set to false by default)
*/
if (in_array($value, $specialFormats, true)) {
return false;
}
}
} /*
* Verify instance of the DateTime created by constructor and by createFromFormat() method.
* After formatting, these dates should be the same.
*/
else {
if ($dateFromFormat->format($dateFormat) === $value) {
return $date;
}
}
} catch (\Exception $exception) {
if (!$allowCompoundFormats) {
return false;
}
}
/*
* Does the value is a string that may be used to format date?
* Example: "Y-m-d"
*/
$dateString = (new DateTime())->format($value);
if ($dateString !== (string)$value) {
return new DateTime($dateString);
}
} catch (\Exception $exception) {
}
return false;
} | php | public static function getDateTime($value, $allowCompoundFormats = false, $dateFormat = 'Y-m-d')
{
/*
* Empty value?
* Nothing to do :)
*/
if (empty($value)) {
return false;
}
/*
* Instance of DateTime class?
* Nothing to do :)
*/
if ($value instanceof DateTime) {
return $value;
}
try {
try {
/*
* Pass the value to the constructor. Maybe it's one of the allowed relative formats.
* Examples: "now", "last day of next month"
*/
$date = new DateTime($value);
/*
* Instance of the DateTime class was created.
* Let's verify if given value is really proper date.
*/
$dateFromFormat = DateTime::createFromFormat($dateFormat, $value);
if (false === $dateFromFormat) {
/*
* Nothing to do more, because:
* a) instance of the DateTime was created
* and
* b) if createFromFormat() method failed, given value is one of the allowed relative formats
* ("now", "last day of next month")
* and...
*/
if ($allowCompoundFormats) {
/*
* ...and
* c) it's not an integer, e.g. not 10 or 100 or 1000
*/
if (!is_numeric($value)) {
return $date;
}
} else {
$specialFormats = [
'now',
];
/*
* ...and
* c) it's special compound format that contains characters that each may be used by
* DateTime::format() method and it raises problem while trying to verify the value at the end
* of this method:
*
* (new DateTime())->format($value);
*
* So, I have to refuse those special compound formats if they are not explicitly declared as
* compound (2nd argument of this method, set to false by default)
*/
if (in_array($value, $specialFormats, true)) {
return false;
}
}
} /*
* Verify instance of the DateTime created by constructor and by createFromFormat() method.
* After formatting, these dates should be the same.
*/
else {
if ($dateFromFormat->format($dateFormat) === $value) {
return $date;
}
}
} catch (\Exception $exception) {
if (!$allowCompoundFormats) {
return false;
}
}
/*
* Does the value is a string that may be used to format date?
* Example: "Y-m-d"
*/
$dateString = (new DateTime())->format($value);
if ($dateString !== (string)$value) {
return new DateTime($dateString);
}
} catch (\Exception $exception) {
}
return false;
} | [
"public",
"static",
"function",
"getDateTime",
"(",
"$",
"value",
",",
"$",
"allowCompoundFormats",
"=",
"false",
",",
"$",
"dateFormat",
"=",
"'Y-m-d'",
")",
"{",
"/*\n * Empty value?\n * Nothing to do :)\n */",
"if",
"(",
"empty",
"(",
"$",
... | Returns the DateTime object for given value.
If the DateTime object cannot be created, false is returned.
@param mixed $value The value which maybe is a date
@param bool $allowCompoundFormats (optional) If is set to true, the compound formats used to create an
instance of DateTime class are allowed (e.g. "now", "last day of next
month", "yyyy"). Otherwise - not and every incorrect value is refused
(default behaviour).
@param string $dateFormat (optional) Format of date used to verify if given value is actually a date.
It should be format matched to the given value, e.g. "Y-m-d H:i" for
"2015-01-01 10:00" value. Default: "Y-m-d".
@return bool|DateTime | [
"Returns",
"the",
"DateTime",
"object",
"for",
"given",
"value",
".",
"If",
"the",
"DateTime",
"object",
"cannot",
"be",
"created",
"false",
"is",
"returned",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L562-L659 | train |
meritoo/common-library | src/Utilities/Date.php | Date.isValidDateFormat | public static function isValidDateFormat($format)
{
if (empty($format) || !is_string($format)) {
return false;
}
$formatted = (new DateTime())->format($format);
// Formatted date it's the format who is validated?
// The format is invalid
if ($formatted === $format) {
return false;
}
// Validate the format used to create the datetime
$fromFormat = DateTime::createFromFormat($format, $formatted);
// It's instance of DateTime?
// The format is valid
if ($fromFormat instanceof DateTime) {
return true;
}
return $fromFormat instanceof DateTime;
} | php | public static function isValidDateFormat($format)
{
if (empty($format) || !is_string($format)) {
return false;
}
$formatted = (new DateTime())->format($format);
// Formatted date it's the format who is validated?
// The format is invalid
if ($formatted === $format) {
return false;
}
// Validate the format used to create the datetime
$fromFormat = DateTime::createFromFormat($format, $formatted);
// It's instance of DateTime?
// The format is valid
if ($fromFormat instanceof DateTime) {
return true;
}
return $fromFormat instanceof DateTime;
} | [
"public",
"static",
"function",
"isValidDateFormat",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"format",
")",
"||",
"!",
"is_string",
"(",
"$",
"format",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"formatted",
"=",
"(",
"new",... | Returns information if given format of date is valid
@param string $format The validated format of date
@return bool | [
"Returns",
"information",
"if",
"given",
"format",
"of",
"date",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Date.php#L681-L705 | train |
CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.equals | public function equals( $fileName )
{
$toCompare = FS_File_Reader::load( $fileName );
$thisFile = FS_File_Reader::load( $this->fileName );
return( $thisFile == $toCompare );
} | php | public function equals( $fileName )
{
$toCompare = FS_File_Reader::load( $fileName );
$thisFile = FS_File_Reader::load( $this->fileName );
return( $thisFile == $toCompare );
} | [
"public",
"function",
"equals",
"(",
"$",
"fileName",
")",
"{",
"$",
"toCompare",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"fileName",
")",
";",
"$",
"thisFile",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"... | Indicates whether current File is equal to another File.
@access public
@param string $fileName Name of File to compare with
@return bool | [
"Indicates",
"whether",
"current",
"File",
"is",
"equal",
"to",
"another",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L68-L73 | train |
CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.exists | public function exists()
{
$exists = file_exists( $this->fileName );
$isFile = is_file( $this->fileName );
return $exists && $isFile;
} | php | public function exists()
{
$exists = file_exists( $this->fileName );
$isFile = is_file( $this->fileName );
return $exists && $isFile;
} | [
"public",
"function",
"exists",
"(",
")",
"{",
"$",
"exists",
"=",
"file_exists",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"isFile",
"=",
"is_file",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"$",
"exists",
"&&",
"$",
"isFile",... | Indicates whether current URI is an existing File.
@access public
@return bool | [
"Indicates",
"whether",
"current",
"URI",
"is",
"an",
"existing",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L80-L85 | train |
CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.getPath | public function getPath()
{
$realpath = realpath( $this->fileName );
$path = dirname( $realpath );
$path = str_replace( "\\", "/", $path );
$path .= "/";
return $path;
} | php | public function getPath()
{
$realpath = realpath( $this->fileName );
$path = dirname( $realpath );
$path = str_replace( "\\", "/", $path );
$path .= "/";
return $path;
} | [
"public",
"function",
"getPath",
"(",
")",
"{",
"$",
"realpath",
"=",
"realpath",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"$",
"path",
"=",
"dirname",
"(",
"$",
"realpath",
")",
";",
"$",
"path",
"=",
"str_replace",
"(",
"\"\\\\\"",
",",
"\"/\"... | Returns canonical Path to the current File.
@access public
@return string | [
"Returns",
"canonical",
"Path",
"to",
"the",
"current",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L206-L213 | train |
CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.getSize | public function getSize( $precision = NULL )
{
$size = filesize( $this->fileName );
if( $precision )
{
$size = Alg_UnitFormater::formatBytes( $size, $precision );
}
return $size;
} | php | public function getSize( $precision = NULL )
{
$size = filesize( $this->fileName );
if( $precision )
{
$size = Alg_UnitFormater::formatBytes( $size, $precision );
}
return $size;
} | [
"public",
"function",
"getSize",
"(",
"$",
"precision",
"=",
"NULL",
")",
"{",
"$",
"size",
"=",
"filesize",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"if",
"(",
"$",
"precision",
")",
"{",
"$",
"size",
"=",
"Alg_UnitFormater",
"::",
"formatBytes",... | Returns Size of current File.
@access public
@param int $precision Precision of rounded Size (only if unit is set)
@return int | [
"Returns",
"Size",
"of",
"current",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L231-L239 | train |
CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.isOwner | public function isOwner( $user = NULL )
{
$user = $user ? $user : get_current_user();
if( !function_exists( 'posix_getpwuid' ) )
return TRUE;
$uid = fileowner( $this->fileName );
if( !$uid )
return TRUE;
$owner = posix_getpwuid( $uid );
if( !$owner )
return TRUE;
print_m( $owner );
return $user == $owner['name'];
} | php | public function isOwner( $user = NULL )
{
$user = $user ? $user : get_current_user();
if( !function_exists( 'posix_getpwuid' ) )
return TRUE;
$uid = fileowner( $this->fileName );
if( !$uid )
return TRUE;
$owner = posix_getpwuid( $uid );
if( !$owner )
return TRUE;
print_m( $owner );
return $user == $owner['name'];
} | [
"public",
"function",
"isOwner",
"(",
"$",
"user",
"=",
"NULL",
")",
"{",
"$",
"user",
"=",
"$",
"user",
"?",
"$",
"user",
":",
"get_current_user",
"(",
")",
";",
"if",
"(",
"!",
"function_exists",
"(",
"'posix_getpwuid'",
")",
")",
"return",
"TRUE",
... | Indicates whether a given user is owner of current file.
On Windows this method always returns TRUE.
@access public
@param string $user Name of user to check ownership for, current user by default
@return boolean | [
"Indicates",
"whether",
"a",
"given",
"user",
"is",
"owner",
"of",
"current",
"file",
".",
"On",
"Windows",
"this",
"method",
"always",
"returns",
"TRUE",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L248-L261 | train |
CeusMedia/Common | src/FS/File/Reader.php | FS_File_Reader.readString | public function readString()
{
if( !$this->exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
if( !$this->isReadable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not readable' );
return file_get_contents( $this->fileName );
} | php | public function readString()
{
if( !$this->exists( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not existing' );
if( !$this->isReadable( $this->fileName ) )
throw new RuntimeException( 'File "'.$this->fileName.'" is not readable' );
return file_get_contents( $this->fileName );
} | [
"public",
"function",
"readString",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"this",
"->",
"fileName",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" is not exist... | Reads file and returns it as string.
@access public
@return string
@throws RuntimeException if File is not existing
@throws RuntimeException if File is not readable | [
"Reads",
"file",
"and",
"returns",
"it",
"as",
"string",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Reader.php#L317-L324 | train |
generationtux/marketo-rest-api-client | src/Api/LeadApi.php | LeadApi.show | public function show($email)
{
$url = $this->client->url . '/rest/v1/leads.json';
$queryParams = [
'filterType' => 'email',
'filterValues' => $email
];
$response = parent::get($url, $queryParams);
if ($response->success) {
if (count($response->result) > 0) {
return $response->result[0];
} else {
throw new LeadDoesNotExistException('Lead does not exist with email ' . $email);
}
} else {
throw new MarketoApiException('Error retrieving lead: ' . $response->errors[0]->message);
}
} | php | public function show($email)
{
$url = $this->client->url . '/rest/v1/leads.json';
$queryParams = [
'filterType' => 'email',
'filterValues' => $email
];
$response = parent::get($url, $queryParams);
if ($response->success) {
if (count($response->result) > 0) {
return $response->result[0];
} else {
throw new LeadDoesNotExistException('Lead does not exist with email ' . $email);
}
} else {
throw new MarketoApiException('Error retrieving lead: ' . $response->errors[0]->message);
}
} | [
"public",
"function",
"show",
"(",
"$",
"email",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"client",
"->",
"url",
".",
"'/rest/v1/leads.json'",
";",
"$",
"queryParams",
"=",
"[",
"'filterType'",
"=>",
"'email'",
",",
"'filterValues'",
"=>",
"$",
"ema... | Get a lead by email address
@param string $email
@return \stdClass
@throws LeadDoesNotExistException
@throws MarketoApiException | [
"Get",
"a",
"lead",
"by",
"email",
"address"
] | a227574f6569ca2c95c2343dd963d7f9d3885afe | https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/LeadApi.php#L44-L61 | train |
CeusMedia/Common | src/FS/File/Gantt/MeetingReader.php | FS_File_Gantt_MeetingReader.calculateEndDate | protected static function calculateEndDate( $startDate, $durationDays )
{
$time = strtotime( $startDate ) + $durationDays * 24 * 60 * 60;
$time = date( "Y-m-d", $time );
return $time;
} | php | protected static function calculateEndDate( $startDate, $durationDays )
{
$time = strtotime( $startDate ) + $durationDays * 24 * 60 * 60;
$time = date( "Y-m-d", $time );
return $time;
} | [
"protected",
"static",
"function",
"calculateEndDate",
"(",
"$",
"startDate",
",",
"$",
"durationDays",
")",
"{",
"$",
"time",
"=",
"strtotime",
"(",
"$",
"startDate",
")",
"+",
"$",
"durationDays",
"*",
"24",
"*",
"60",
"*",
"60",
";",
"$",
"time",
"=... | Calculates End Date from Start Date and Duration in Days.
@access protected
@static
@param string $startDate Start Date
@param int $durationDays Duration in Days
@return string $endDate | [
"Calculates",
"End",
"Date",
"from",
"Start",
"Date",
"and",
"Duration",
"in",
"Days",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/MeetingReader.php#L63-L68 | train |
CeusMedia/Common | src/FS/File/Gantt/MeetingReader.php | FS_File_Gantt_MeetingReader.getProjectData | public function getProjectData()
{
$data = $this->readProjectDates();
$meetings = $this->readMeetingDates();
$data['meetings'] = $meetings;
return $data;
} | php | public function getProjectData()
{
$data = $this->readProjectDates();
$meetings = $this->readMeetingDates();
$data['meetings'] = $meetings;
return $data;
} | [
"public",
"function",
"getProjectData",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"readProjectDates",
"(",
")",
";",
"$",
"meetings",
"=",
"$",
"this",
"->",
"readMeetingDates",
"(",
")",
";",
"$",
"data",
"[",
"'meetings'",
"]",
"=",
"$",
... | Returns extracted Project and Meeting Dates.
@access public
@return array | [
"Returns",
"extracted",
"Project",
"and",
"Meeting",
"Dates",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/MeetingReader.php#L75-L81 | train |
CeusMedia/Common | src/ADT/Graph/DirectedAcyclicWeighted.php | ADT_Graph_DirectedAcyclicWeighted.removeEdge | public function removeEdge( $source, $target )
{
$value = $this->getEdgeValue( $source, $target );
$this->edgeSet->removeEdge( $source, $target );
if( !$this->isCoherent() )
$this->edgeSet->addEdge( $source, $target, $value );
} | php | public function removeEdge( $source, $target )
{
$value = $this->getEdgeValue( $source, $target );
$this->edgeSet->removeEdge( $source, $target );
if( !$this->isCoherent() )
$this->edgeSet->addEdge( $source, $target, $value );
} | [
"public",
"function",
"removeEdge",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getEdgeValue",
"(",
"$",
"source",
",",
"$",
"target",
")",
";",
"$",
"this",
"->",
"edgeSet",
"->",
"removeEdge",
"(",
"$",
... | Removes an Edge.
@access public
@param Node $source Source Node of this Edge
@param Node $target Target Node of this Edge
@return void | [
"Removes",
"an",
"Edge",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/DirectedAcyclicWeighted.php#L67-L73 | train |
meritoo/common-library | src/Utilities/GeneratorUtility.php | GeneratorUtility.getGeneratorElements | public static function getGeneratorElements(Generator $generator)
{
$elements = [];
for (; $generator->valid(); $generator->next()) {
$elements[] = $generator->current();
}
return $elements;
} | php | public static function getGeneratorElements(Generator $generator)
{
$elements = [];
for (; $generator->valid(); $generator->next()) {
$elements[] = $generator->current();
}
return $elements;
} | [
"public",
"static",
"function",
"getGeneratorElements",
"(",
"Generator",
"$",
"generator",
")",
"{",
"$",
"elements",
"=",
"[",
"]",
";",
"for",
"(",
";",
"$",
"generator",
"->",
"valid",
"(",
")",
";",
"$",
"generator",
"->",
"next",
"(",
")",
")",
... | Returns elements of generator
@param Generator $generator The generator who elements should be returned
@return array | [
"Returns",
"elements",
"of",
"generator"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/GeneratorUtility.php#L27-L36 | train |
CeusMedia/Common | src/UI/HTML/OrderedList.php | UI_HTML_OrderedList.addItems | public function addItems( $items )
{
if( $items instanceof UI_HTML_Buffer )
$this->addItem( $items->render() );
else
foreach( $items as $item )
$this->addItem( $item );
} | php | public function addItems( $items )
{
if( $items instanceof UI_HTML_Buffer )
$this->addItem( $items->render() );
else
foreach( $items as $item )
$this->addItem( $item );
} | [
"public",
"function",
"addItems",
"(",
"$",
"items",
")",
"{",
"if",
"(",
"$",
"items",
"instanceof",
"UI_HTML_Buffer",
")",
"$",
"this",
"->",
"addItem",
"(",
"$",
"items",
"->",
"render",
"(",
")",
")",
";",
"else",
"foreach",
"(",
"$",
"items",
"a... | Adds an Item.
@access public
@param array $items List of List Item Elements or Strings
@return void | [
"Adds",
"an",
"Item",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/OrderedList.php#L74-L81 | train |
CeusMedia/Common | src/UI/HTML/OrderedList.php | UI_HTML_OrderedList.render | public function render()
{
$list = array();
foreach( $this->listItems as $item )
$list[] = $this->renderInner( $item );
return UI_HTML_Tag::create( "ol", join( $list ), $this->getAttributes() );
} | php | public function render()
{
$list = array();
foreach( $this->listItems as $item )
$list[] = $this->renderInner( $item );
return UI_HTML_Tag::create( "ol", join( $list ), $this->getAttributes() );
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"listItems",
"as",
"$",
"item",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"this",
"->",
"renderInner",
"(",
"$",
"item",
")",
... | Returns rendered List Element.
@access public
@return string | [
"Returns",
"rendered",
"List",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/OrderedList.php#L88-L94 | train |
CeusMedia/Common | src/UI/Image/Filter.php | UI_Image_Filter.colorize | public function colorize( $red, $green, $blue, $alpha = 0 )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_COLORIZE, $red, $green, $blue, $alpha );
} | php | public function colorize( $red, $green, $blue, $alpha = 0 )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_COLORIZE, $red, $green, $blue, $alpha );
} | [
"public",
"function",
"colorize",
"(",
"$",
"red",
",",
"$",
"green",
",",
"$",
"blue",
",",
"$",
"alpha",
"=",
"0",
")",
"{",
"return",
"imagefilter",
"(",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
",",
"IMG_FILTER_COLORIZE",
",",
"... | Adds or subtracts colors.
@access public
@param integer $red Red component, value between -255 and 255
@param integer $red Green component, value between -255 and 255
@param integer $red Blue component, value between -255 and 255
@param integer $alpha Alpha channel, value between 0 (opacue) and 127 (transparent)
@return boolean | [
"Adds",
"or",
"subtracts",
"colors",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Filter.php#L91-L94 | train |
CeusMedia/Common | src/UI/Image/Filter.php | UI_Image_Filter.pixelate | public function pixelate( $size, $effect = FALSE )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_PIXELATE, $size, $effect );
} | php | public function pixelate( $size, $effect = FALSE )
{
return imagefilter( $this->image->getResource(), IMG_FILTER_PIXELATE, $size, $effect );
} | [
"public",
"function",
"pixelate",
"(",
"$",
"size",
",",
"$",
"effect",
"=",
"FALSE",
")",
"{",
"return",
"imagefilter",
"(",
"$",
"this",
"->",
"image",
"->",
"getResource",
"(",
")",
",",
"IMG_FILTER_PIXELATE",
",",
"$",
"size",
",",
"$",
"effect",
"... | Applies pixelation effect to the image.
@access public
@param integer $size Block size in pixels
@param boolean $effect Flag: activate advanced pixelation effect
@return boolean | [
"Applies",
"pixelation",
"effect",
"to",
"the",
"image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Filter.php#L160-L163 | train |
graze/monolog-extensions | src/Graze/Monolog/Event.php | Event.publish | public function publish()
{
if (empty($this->handlers)) {
return false;
}
foreach ($this->handlers as $handler) {
$handler->handle($this->eventData);
}
return true;
} | php | public function publish()
{
if (empty($this->handlers)) {
return false;
}
foreach ($this->handlers as $handler) {
$handler->handle($this->eventData);
}
return true;
} | [
"public",
"function",
"publish",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"handlers",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"handler",
")",
"{",
"$",
"handler",
"->",... | triggers all the event handlers set for this event
@return bool true if at least one handler set | [
"triggers",
"all",
"the",
"event",
"handlers",
"set",
"for",
"this",
"event"
] | 91cc36ec690cdeba1c25c2f2c7c832b2974f5db1 | https://github.com/graze/monolog-extensions/blob/91cc36ec690cdeba1c25c2f2c7c832b2974f5db1/src/Graze/Monolog/Event.php#L89-L99 | train |
graze/monolog-extensions | src/Graze/Monolog/Event.php | Event.getNow | private function getNow()
{
$timezone = new DateTimeZone(date_default_timezone_get() ?: 'UTC');
return DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)))->setTimezone($timezone);
} | php | private function getNow()
{
$timezone = new DateTimeZone(date_default_timezone_get() ?: 'UTC');
return DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)))->setTimezone($timezone);
} | [
"private",
"function",
"getNow",
"(",
")",
"{",
"$",
"timezone",
"=",
"new",
"DateTimeZone",
"(",
"date_default_timezone_get",
"(",
")",
"?",
":",
"'UTC'",
")",
";",
"return",
"DateTime",
"::",
"createFromFormat",
"(",
"'U.u'",
",",
"sprintf",
"(",
"'%.6F'",... | returns a datetime object representing the current instant with microseconds
@return \DateTime | [
"returns",
"a",
"datetime",
"object",
"representing",
"the",
"current",
"instant",
"with",
"microseconds"
] | 91cc36ec690cdeba1c25c2f2c7c832b2974f5db1 | https://github.com/graze/monolog-extensions/blob/91cc36ec690cdeba1c25c2f2c7c832b2974f5db1/src/Graze/Monolog/Event.php#L106-L111 | train |
CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.addAttributes | public function addAttributes( $attributes = array() )
{
foreach( $attributes as $key => $value )
{
if( $key == 'class' )
{
if( is_string( $value ) )
$value = explode( " ", $value );
if( !is_array( $value ) && !( $value instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $value as $class )
$this->addClass( $class );
continue;
}
else
$this->attributes[$key] = $value;
}
} | php | public function addAttributes( $attributes = array() )
{
foreach( $attributes as $key => $value )
{
if( $key == 'class' )
{
if( is_string( $value ) )
$value = explode( " ", $value );
if( !is_array( $value ) && !( $value instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $value as $class )
$this->addClass( $class );
continue;
}
else
$this->attributes[$key] = $value;
}
} | [
"public",
"function",
"addAttributes",
"(",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"==",
"'class'",
")",
"{",
"if",
"(",
"is_str... | Adds Attributes of Element.
@access public
@param string $attributes Map of Element Attributes
@return void | [
"Adds",
"Attributes",
"of",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L53-L70 | train |
CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.getAttributes | public function getAttributes()
{
$attributes = $this->attributes;
$attributes['class'] = NULL;
if( !empty( $this->attributes['class'] ) )
$attributes['class'] = implode( " ", $this->attributes['class'] );
return $attributes;
} | php | public function getAttributes()
{
$attributes = $this->attributes;
$attributes['class'] = NULL;
if( !empty( $this->attributes['class'] ) )
$attributes['class'] = implode( " ", $this->attributes['class'] );
return $attributes;
} | [
"public",
"function",
"getAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"attributes",
";",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"NULL",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'class'",... | Returns set Element Attributes.
@access public
@return array | [
"Returns",
"set",
"Element",
"Attributes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L88-L95 | train |
CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.setAttributes | public function setAttributes( $attributes = array() )
{
if( !empty( $attributes['class'] ) && is_string( $attributes['class'] ) )
$attributes['class'] = explode( ' ', $attributes['class'] );
$this->addAttributes( $attributes );
} | php | public function setAttributes( $attributes = array() )
{
if( !empty( $attributes['class'] ) && is_string( $attributes['class'] ) )
$attributes['class'] = explode( ' ', $attributes['class'] );
$this->addAttributes( $attributes );
} | [
"public",
"function",
"setAttributes",
"(",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
")",
"$",... | Sets Attributes of Element.
@access public
@param string $attributes Map of Element Attributes
@return void | [
"Sets",
"Attributes",
"of",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L115-L120 | train |
CeusMedia/Common | src/UI/HTML/Abstract.php | UI_HTML_Abstract.setClasses | public function setClasses( $classes )
{
$this->attributes['class'] = array();
if( is_string( $classes ) )
$classes = explode( " ", $classes );
if( !is_array( $classes ) && !( $classes instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $classes as $class )
$this->addClass( $class );
} | php | public function setClasses( $classes )
{
$this->attributes['class'] = array();
if( is_string( $classes ) )
$classes = explode( " ", $classes );
if( !is_array( $classes ) && !( $classes instanceof ArrayIterator ) )
throw new InvalidArgumentException( 'Class attribute must be string, array or iterator' );
foreach( $classes as $class )
$this->addClass( $class );
} | [
"public",
"function",
"setClasses",
"(",
"$",
"classes",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"classes",
")",
")",
"$",
"classes",
"=",
"explode",
"(",
"\" \"",... | Sets Content of Element.
@access public
@param string $content Content of Element
@return void | [
"Sets",
"Content",
"of",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Abstract.php#L128-L137 | train |
CeusMedia/Common | src/XML/RSS/Writer.php | XML_RSS_Writer.save | public static function save( $fileName, $channelData, $itemList, $encoding = "utf-8" )
{
$builder = new XML_RSS_Builder();
$builder->setChannelData( $channelData );
$builder->setItemList( $itemList );
$xml = $builder->build( $encoding = "utf-8" );
return FS_File_Writer::save( $fileName, $xml );
} | php | public static function save( $fileName, $channelData, $itemList, $encoding = "utf-8" )
{
$builder = new XML_RSS_Builder();
$builder->setChannelData( $channelData );
$builder->setItemList( $itemList );
$xml = $builder->build( $encoding = "utf-8" );
return FS_File_Writer::save( $fileName, $xml );
} | [
"public",
"static",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"channelData",
",",
"$",
"itemList",
",",
"$",
"encoding",
"=",
"\"utf-8\"",
")",
"{",
"$",
"builder",
"=",
"new",
"XML_RSS_Builder",
"(",
")",
";",
"$",
"builder",
"->",
"setChannel... | Writes RSS to a File statically and returns Number of written Bytes.
@access public
@static
@param string $fileName File Name of XML RSS File
@param array $array Array of Channel Information Pairs
@param array $array List of Item
@param string $encoding Encoding Type
@return int | [
"Writes",
"RSS",
"to",
"a",
"File",
"statically",
"and",
"returns",
"Number",
"of",
"written",
"Bytes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Writer.php#L108-L115 | train |
CeusMedia/Common | src/XML/RSS/Writer.php | XML_RSS_Writer.write | public function write( $fileName, $encoding = "utf-8" )
{
return $this->save( $fileName, $this->channelData, $this->itemList, $encoding );
} | php | public function write( $fileName, $encoding = "utf-8" )
{
return $this->save( $fileName, $this->channelData, $this->itemList, $encoding );
} | [
"public",
"function",
"write",
"(",
"$",
"fileName",
",",
"$",
"encoding",
"=",
"\"utf-8\"",
")",
"{",
"return",
"$",
"this",
"->",
"save",
"(",
"$",
"fileName",
",",
"$",
"this",
"->",
"channelData",
",",
"$",
"this",
"->",
"itemList",
",",
"$",
"en... | Writes RSS to a File and returns Number of written Bytes.
@access public
@param string $fileName File Name of XML RSS File
@param string $encoding Encoding Type
@return int | [
"Writes",
"RSS",
"to",
"a",
"File",
"and",
"returns",
"Number",
"of",
"written",
"Bytes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RSS/Writer.php#L124-L127 | train |
celtic34fr/zf-graphic-object-templating-twig | view/twigstemplates/Entity/Menus.php | Menus.setTarget | public function setTarget($target = self::ODMENUTARGET_SELF)
{
$targets = $this->getTargetConstants();
$target = (string) $target;
if (!in_array($target, $targets)) { $target = self::ODMENUTARGET_SELF; }
$this->target = $target;
return $this;
} | php | public function setTarget($target = self::ODMENUTARGET_SELF)
{
$targets = $this->getTargetConstants();
$target = (string) $target;
if (!in_array($target, $targets)) { $target = self::ODMENUTARGET_SELF; }
$this->target = $target;
return $this;
} | [
"public",
"function",
"setTarget",
"(",
"$",
"target",
"=",
"self",
"::",
"ODMENUTARGET_SELF",
")",
"{",
"$",
"targets",
"=",
"$",
"this",
"->",
"getTargetConstants",
"(",
")",
";",
"$",
"target",
"=",
"(",
"string",
")",
"$",
"target",
";",
"if",
"(",... | Set target.
@param string $ord
@return Menus | [
"Set",
"target",
"."
] | 7a354eff05d678dc225df5e778d5bc3500982768 | https://github.com/celtic34fr/zf-graphic-object-templating-twig/blob/7a354eff05d678dc225df5e778d5bc3500982768/view/twigstemplates/Entity/Menus.php#L266-L275 | train |
CeusMedia/Common | src/Net/HTTP/Header/Field.php | Net_HTTP_Header_Field.getValue | public function getValue( $qualified = FALSE )
{
if( $qualified )
return $this->decodeQualifiedValues ( $this->value );
return $this->value;
} | php | public function getValue( $qualified = FALSE )
{
if( $qualified )
return $this->decodeQualifiedValues ( $this->value );
return $this->value;
} | [
"public",
"function",
"getValue",
"(",
"$",
"qualified",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"qualified",
")",
"return",
"$",
"this",
"->",
"decodeQualifiedValues",
"(",
"$",
"this",
"->",
"value",
")",
";",
"return",
"$",
"this",
"->",
"value",
";... | Returns set Header Value.
@access public
@return string|array Header Value or Array of qualified Values | [
"Returns",
"set",
"Header",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Field.php#L89-L94 | train |
CeusMedia/Common | src/Net/HTTP/Header/Field.php | Net_HTTP_Header_Field.toString | public function toString()
{
if( function_exists( 'mb_convert_case' ) )
$name = mb_convert_case( $this->name, MB_CASE_TITLE );
else
$name = str_replace( " ", "-", ucwords( str_replace( "-", " ", $this->name ) ) );
return $name.": ".$this->value;
} | php | public function toString()
{
if( function_exists( 'mb_convert_case' ) )
$name = mb_convert_case( $this->name, MB_CASE_TITLE );
else
$name = str_replace( " ", "-", ucwords( str_replace( "-", " ", $this->name ) ) );
return $name.": ".$this->value;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'mb_convert_case'",
")",
")",
"$",
"name",
"=",
"mb_convert_case",
"(",
"$",
"this",
"->",
"name",
",",
"MB_CASE_TITLE",
")",
";",
"else",
"$",
"name",
"=",
"str_replace",... | Returns a representative string of Header.
@access public
@return string | [
"Returns",
"a",
"representative",
"string",
"of",
"Header",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Field.php#L113-L120 | train |
CeusMedia/Common | src/Alg/Math/Algebra/GaussElimination.php | Alg_Math_Algebra_GaussElimination.eliminate | public function eliminate( $matrix )
{
$lines = $matrix->getRowNumber();
for( $i=0; $i<$lines-1; $i++ )
{
$r = $this->findPivotRow( $matrix, $i, $i );
if( $i != $r )
$matrix->swapRows( $r, $i );
for( $j=$i+1; $j<$lines; $j++ )
{
$f = $matrix->getValue( $j, $i ) / $matrix->getValue( $i, $i );
for( $k=$i; $k<$matrix->getColumnNumber(); $k++ )
{
$value = $matrix->getValue( $j, $k ) - $f * $matrix->getValue( $i, $k );
$matrix->setValue( $j, $k, $value );
}
}
}
return $matrix;
} | php | public function eliminate( $matrix )
{
$lines = $matrix->getRowNumber();
for( $i=0; $i<$lines-1; $i++ )
{
$r = $this->findPivotRow( $matrix, $i, $i );
if( $i != $r )
$matrix->swapRows( $r, $i );
for( $j=$i+1; $j<$lines; $j++ )
{
$f = $matrix->getValue( $j, $i ) / $matrix->getValue( $i, $i );
for( $k=$i; $k<$matrix->getColumnNumber(); $k++ )
{
$value = $matrix->getValue( $j, $k ) - $f * $matrix->getValue( $i, $k );
$matrix->setValue( $j, $k, $value );
}
}
}
return $matrix;
} | [
"public",
"function",
"eliminate",
"(",
"$",
"matrix",
")",
"{",
"$",
"lines",
"=",
"$",
"matrix",
"->",
"getRowNumber",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"lines",
"-",
"1",
";",
"$",
"i",
"++",
")",
"{",... | Eliminates Matrix using Gauss Algorithm.
@access public
@param Alg_Math_Algebra_Matrix $matrix Matrix to eliminate
@return Alg_Math_Algebra_Matrix | [
"Eliminates",
"Matrix",
"using",
"Gauss",
"Algorithm",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/GaussElimination.php#L71-L90 | train |
CeusMedia/Common | src/Alg/Math/Algebra/GaussElimination.php | Alg_Math_Algebra_GaussElimination.findPivotRow | protected function findPivotRow( $matrix, $column, $row = 0 )
{
$r = $row;
$a = abs( $matrix->getValue( $row, $column ) );
for( $i=$row+1; $i<$matrix->getRowNumber(); $i++ )
{
if( abs( $matrix->getValue( $i, $column ) ) > $a )
{
$a = abs( $matrix->getValue( $i, $column ) );
$r = $i;
}
}
return $r;
} | php | protected function findPivotRow( $matrix, $column, $row = 0 )
{
$r = $row;
$a = abs( $matrix->getValue( $row, $column ) );
for( $i=$row+1; $i<$matrix->getRowNumber(); $i++ )
{
if( abs( $matrix->getValue( $i, $column ) ) > $a )
{
$a = abs( $matrix->getValue( $i, $column ) );
$r = $i;
}
}
return $r;
} | [
"protected",
"function",
"findPivotRow",
"(",
"$",
"matrix",
",",
"$",
"column",
",",
"$",
"row",
"=",
"0",
")",
"{",
"$",
"r",
"=",
"$",
"row",
";",
"$",
"a",
"=",
"abs",
"(",
"$",
"matrix",
"->",
"getValue",
"(",
"$",
"row",
",",
"$",
"column... | Returns the advices Privot Row within a Matrix.
@access protected
@param Alg_Math_Algebra_Matrix $matrix Matrix to eliminate
@param int $column current Column
@param int $row Row to start Search
@return int | [
"Returns",
"the",
"advices",
"Privot",
"Row",
"within",
"a",
"Matrix",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/GaussElimination.php#L100-L113 | train |
CeusMedia/Common | src/Alg/Math/Algebra/GaussElimination.php | Alg_Math_Algebra_GaussElimination.resolve | public function resolve( $matrix )
{
$lines = $matrix->getRowNumber();
$solution = array();
for( $i=$lines-1; $i>=0; $i-- )
{
for( $j=$lines-1; $j>=0; $j-- )
{
if( isset( $solution[$j] ) )
{
$var = $solution[$j];
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 ) - $var * $matrix->getValue( $i, $j );
$matrix->setValue( $i, $matrix->getColumnNumber()-1, $value );
}
else
{
$factor = $matrix->getValue( $i, $j );
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 );
$var = $value / $factor;
$solution[$j] = $var;
$solution[$j] = round( $var, $this->accuracy );
break;
}
}
}
ksort( $solution );
$solution = new Alg_Math_Algebra_Vector( array_values( $solution ) );
return $solution;
} | php | public function resolve( $matrix )
{
$lines = $matrix->getRowNumber();
$solution = array();
for( $i=$lines-1; $i>=0; $i-- )
{
for( $j=$lines-1; $j>=0; $j-- )
{
if( isset( $solution[$j] ) )
{
$var = $solution[$j];
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 ) - $var * $matrix->getValue( $i, $j );
$matrix->setValue( $i, $matrix->getColumnNumber()-1, $value );
}
else
{
$factor = $matrix->getValue( $i, $j );
$value = $matrix->getValue( $i, $matrix->getColumnNumber()-1 );
$var = $value / $factor;
$solution[$j] = $var;
$solution[$j] = round( $var, $this->accuracy );
break;
}
}
}
ksort( $solution );
$solution = new Alg_Math_Algebra_Vector( array_values( $solution ) );
return $solution;
} | [
"public",
"function",
"resolve",
"(",
"$",
"matrix",
")",
"{",
"$",
"lines",
"=",
"$",
"matrix",
"->",
"getRowNumber",
"(",
")",
";",
"$",
"solution",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"lines",
"-",
"1",
";",
"$",
"i"... | Resolves eliminated Matrix and return Solution Vector.
@access public
@param Alg_Math_Algebra_Matrix $matrix Matrix to eliminate
@return Alg_Math_Algebra_Vector | [
"Resolves",
"eliminated",
"Matrix",
"and",
"return",
"Solution",
"Vector",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/GaussElimination.php#L121-L149 | train |
CeusMedia/Common | src/Net/HTTP/Response/Sender.php | Net_HTTP_Response_Sender.sendResponse | public static function sendResponse( Net_HTTP_Response $response, $compression = NULL, $sendLengthHeader = TRUE, $exit = TRUE )
{
$sender = new Net_HTTP_Response_Sender( $response );
return $sender->send( $compression, $sendLengthHeader, $exit );
} | php | public static function sendResponse( Net_HTTP_Response $response, $compression = NULL, $sendLengthHeader = TRUE, $exit = TRUE )
{
$sender = new Net_HTTP_Response_Sender( $response );
return $sender->send( $compression, $sendLengthHeader, $exit );
} | [
"public",
"static",
"function",
"sendResponse",
"(",
"Net_HTTP_Response",
"$",
"response",
",",
"$",
"compression",
"=",
"NULL",
",",
"$",
"sendLengthHeader",
"=",
"TRUE",
",",
"$",
"exit",
"=",
"TRUE",
")",
"{",
"$",
"sender",
"=",
"new",
"Net_HTTP_Response... | Send Response statically.
@access public
@param Net_HTTP_Response $response Response Object
@param string $compression Type of compression (gzip|deflate)
@param boolean $sendLengthHeader Send Content-Length Header
@return integer Number of sent Bytes | [
"Send",
"Response",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response/Sender.php#L99-L103 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Controller/SessionManagerTrait.php | SessionManagerTrait.startUserSession | protected function startUserSession(object $user): Session
{
$session = new Session();
$session->set('is_granted', true);
$session->set('user', $user);
return $session;
} | php | protected function startUserSession(object $user): Session
{
$session = new Session();
$session->set('is_granted', true);
$session->set('user', $user);
return $session;
} | [
"protected",
"function",
"startUserSession",
"(",
"object",
"$",
"user",
")",
":",
"Session",
"{",
"$",
"session",
"=",
"new",
"Session",
"(",
")",
";",
"$",
"session",
"->",
"set",
"(",
"'is_granted'",
",",
"true",
")",
";",
"$",
"session",
"->",
"set... | Starts user session and returns session instance
@param object $user Authenticated user instance
@return Session | [
"Starts",
"user",
"session",
"and",
"returns",
"session",
"instance"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/SessionManagerTrait.php#L23-L31 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Controller/SessionManagerTrait.php | SessionManagerTrait.addFlash | protected function addFlash(string $type, $message): void
{
(new Session())->getFlashBag()->set($type, $message);
} | php | protected function addFlash(string $type, $message): void
{
(new Session())->getFlashBag()->set($type, $message);
} | [
"protected",
"function",
"addFlash",
"(",
"string",
"$",
"type",
",",
"$",
"message",
")",
":",
"void",
"{",
"(",
"new",
"Session",
"(",
")",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"set",
"(",
"$",
"type",
",",
"$",
"message",
")",
";",
"}"
] | Adds flash to session flash bag
@param string $type Type of flash bag
@param string|array $message Message of flash | [
"Adds",
"flash",
"to",
"session",
"flash",
"bag"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Controller/SessionManagerTrait.php#L59-L62 | train |
CeusMedia/Common | src/FS/File/VCard/Builder.php | FS_File_VCard_Builder.build | public static function build( ADT_VCard $card, $charsetIn = NULL, $charsetOut = NULL )
{
$lines = array();
if( $fields = $card->getNameFields() ) // NAME FIELDS
$lines[] = self::renderLine( "n", $fields );
foreach( $card->getAddresses() as $address ) // ADDRESSES
$lines[] = self::renderLine( "adr", $address, $address['types'] );
if( $name = $card->getFormatedName() ) // FORMATED NAME
$lines[] = self::renderLine( "fn", $name );
if( $nicknames = $card->getNicknames() ) // NICKNAMES
$lines[] = self::renderLine( "nickname", $nicknames, NULL, TRUE, "," );
if( $fields = $card->getOrganisationFields() ) // ORGANISATION
$lines[] = self::renderLine( "org", $fields, NULL, TRUE );
if( $title = $card->getTitle() ) // TITLE
$lines[] = self::renderLine( "title", $title );
if( $role = $card->getRole() ) // ROLE
$lines[] = self::renderLine( "role", $role );
foreach( $card->getEmails() as $address => $types ) // EMAIL ADDRESSES
$lines[] = self::renderLine( "email", $address, $types );
foreach( $card->getUrls() as $url => $types ) // URLS
$lines[] = self::renderLine( "url", $url, $types, FALSE );
foreach( $card->getPhones() as $number => $types ) // PHONES
$lines[] = self::renderLine( "tel", $number, $types );
foreach( $card->getGeoTags() as $geo ) // GEO TAGS
$lines[] = self::renderLine( "geo", $geo, $geo['types'] );
if( self::$prodId )
array_unshift( $lines, "PRODID:".self::$prodId );
if( self::$version )
array_unshift( $lines, "VERSION:".self::$version );
array_unshift( $lines, "BEGIN:VCARD" );
array_push( $lines, "END:VCARD" );
$lines = implode( "\n", $lines );
if( $charsetIn && $charsetOut )
{
$lines = Alg_Text_EncodingConverter::convert( $lines, $charsetIn, $charsetOut );
}
return $lines;
} | php | public static function build( ADT_VCard $card, $charsetIn = NULL, $charsetOut = NULL )
{
$lines = array();
if( $fields = $card->getNameFields() ) // NAME FIELDS
$lines[] = self::renderLine( "n", $fields );
foreach( $card->getAddresses() as $address ) // ADDRESSES
$lines[] = self::renderLine( "adr", $address, $address['types'] );
if( $name = $card->getFormatedName() ) // FORMATED NAME
$lines[] = self::renderLine( "fn", $name );
if( $nicknames = $card->getNicknames() ) // NICKNAMES
$lines[] = self::renderLine( "nickname", $nicknames, NULL, TRUE, "," );
if( $fields = $card->getOrganisationFields() ) // ORGANISATION
$lines[] = self::renderLine( "org", $fields, NULL, TRUE );
if( $title = $card->getTitle() ) // TITLE
$lines[] = self::renderLine( "title", $title );
if( $role = $card->getRole() ) // ROLE
$lines[] = self::renderLine( "role", $role );
foreach( $card->getEmails() as $address => $types ) // EMAIL ADDRESSES
$lines[] = self::renderLine( "email", $address, $types );
foreach( $card->getUrls() as $url => $types ) // URLS
$lines[] = self::renderLine( "url", $url, $types, FALSE );
foreach( $card->getPhones() as $number => $types ) // PHONES
$lines[] = self::renderLine( "tel", $number, $types );
foreach( $card->getGeoTags() as $geo ) // GEO TAGS
$lines[] = self::renderLine( "geo", $geo, $geo['types'] );
if( self::$prodId )
array_unshift( $lines, "PRODID:".self::$prodId );
if( self::$version )
array_unshift( $lines, "VERSION:".self::$version );
array_unshift( $lines, "BEGIN:VCARD" );
array_push( $lines, "END:VCARD" );
$lines = implode( "\n", $lines );
if( $charsetIn && $charsetOut )
{
$lines = Alg_Text_EncodingConverter::convert( $lines, $charsetIn, $charsetOut );
}
return $lines;
} | [
"public",
"static",
"function",
"build",
"(",
"ADT_VCard",
"$",
"card",
",",
"$",
"charsetIn",
"=",
"NULL",
",",
"$",
"charsetOut",
"=",
"NULL",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"fields",
"=",
"$",
"card",
"->",
... | Builds vCard String from vCard Object and converts between Charsets.
@access public
@static
@param ADT_VCard $card VCard Data Object
@param string $charsetIn Charset to convert from
@param string $charsetOut Charset to convert to
@return string | [
"Builds",
"vCard",
"String",
"from",
"vCard",
"Object",
"and",
"converts",
"between",
"Charsets",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/VCard/Builder.php#L60-L109 | train |
CeusMedia/Common | src/Net/AtomServerTime.php | Net_AtomServerTime.readSyncFile | protected function readSyncFile()
{
if( !file_exists( $this->syncFile ) )
$this->synchronize();
$ir = new FS_File_INI_Reader ($this->syncFile, false);
$data = $ir->getProperties (true);
$this->syncTime = $data['time'];
$this->syncDiff = $data['diff'];
} | php | protected function readSyncFile()
{
if( !file_exists( $this->syncFile ) )
$this->synchronize();
$ir = new FS_File_INI_Reader ($this->syncFile, false);
$data = $ir->getProperties (true);
$this->syncTime = $data['time'];
$this->syncDiff = $data['diff'];
} | [
"protected",
"function",
"readSyncFile",
"(",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"this",
"->",
"syncFile",
")",
")",
"$",
"this",
"->",
"synchronize",
"(",
")",
";",
"$",
"ir",
"=",
"new",
"FS_File_INI_Reader",
"(",
"$",
"this",
"->",
... | Reads File with synchronized atom time difference.
@access protected
@return void | [
"Reads",
"File",
"with",
"synchronized",
"atom",
"time",
"difference",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/AtomServerTime.php#L74-L82 | train |
CeusMedia/Common | src/Net/AtomServerTime.php | Net_AtomServerTime.synchronize | protected function synchronize()
{
if( file_exists( $this->syncFile ) )
{
$time = filemtime( $this->syncFile );
if( ( time() - $time ) < $this->refreshTime )
{
$this->syncTime = $time;
$this->syncDiff = FS_File_Reader::load( $this->syncFile );
return;
}
}
$this->syncTime = time();
$this->syncDiff = $this->syncTime - Net_AtomTime::getTimestamp();
FS_File_Writer::save( $this->syncFile, $this->syncDiff );
touch( $this->syncFile );
} | php | protected function synchronize()
{
if( file_exists( $this->syncFile ) )
{
$time = filemtime( $this->syncFile );
if( ( time() - $time ) < $this->refreshTime )
{
$this->syncTime = $time;
$this->syncDiff = FS_File_Reader::load( $this->syncFile );
return;
}
}
$this->syncTime = time();
$this->syncDiff = $this->syncTime - Net_AtomTime::getTimestamp();
FS_File_Writer::save( $this->syncFile, $this->syncDiff );
touch( $this->syncFile );
} | [
"protected",
"function",
"synchronize",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"syncFile",
")",
")",
"{",
"$",
"time",
"=",
"filemtime",
"(",
"$",
"this",
"->",
"syncFile",
")",
";",
"if",
"(",
"(",
"time",
"(",
")",
"-",
... | Synchronizes server time with atom time by saving time difference.
@access protected
@return void | [
"Synchronizes",
"server",
"time",
"with",
"atom",
"time",
"by",
"saving",
"time",
"difference",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/AtomServerTime.php#L89-L105 | train |
CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.buildGraph | protected static function buildGraph( $config, $data )
{
$graph = new Graph( $config['width'], $config['height'], 'auto' );
$graph->setScale( self::getConfigValue( $config, 'scale' ) );
$graph->img->SetAntiAliasing( self::getConfigValue( $config, 'image.antialias', FALSE ) );
UI_Image_Graph_Components::setTitle( $graph, $config );
UI_Image_Graph_Components::setSubTitle( $graph, $config );
UI_Image_Graph_Components::setLegend( $graph, self::getSubConfig( $config, "legend." ) );
UI_Image_Graph_Components::setFrame( $graph, $config );
UI_Image_Graph_Components::setShadow( $graph, $config );
UI_Image_Graph_Components::setAxis( $graph->xaxis, self::getSubConfig( $config, 'x.axis.' ), $data );
UI_Image_Graph_Components::setAxis( $graph->yaxis, self::getSubConfig( $config, 'y1.axis.' ), $data );
self::setUpMargin( $graph, $config );
self::setUpGrid( $graph, $config, $data );
self::setUpPlots( $graph, $config, $data );
return $graph;
} | php | protected static function buildGraph( $config, $data )
{
$graph = new Graph( $config['width'], $config['height'], 'auto' );
$graph->setScale( self::getConfigValue( $config, 'scale' ) );
$graph->img->SetAntiAliasing( self::getConfigValue( $config, 'image.antialias', FALSE ) );
UI_Image_Graph_Components::setTitle( $graph, $config );
UI_Image_Graph_Components::setSubTitle( $graph, $config );
UI_Image_Graph_Components::setLegend( $graph, self::getSubConfig( $config, "legend." ) );
UI_Image_Graph_Components::setFrame( $graph, $config );
UI_Image_Graph_Components::setShadow( $graph, $config );
UI_Image_Graph_Components::setAxis( $graph->xaxis, self::getSubConfig( $config, 'x.axis.' ), $data );
UI_Image_Graph_Components::setAxis( $graph->yaxis, self::getSubConfig( $config, 'y1.axis.' ), $data );
self::setUpMargin( $graph, $config );
self::setUpGrid( $graph, $config, $data );
self::setUpPlots( $graph, $config, $data );
return $graph;
} | [
"protected",
"static",
"function",
"buildGraph",
"(",
"$",
"config",
",",
"$",
"data",
")",
"{",
"$",
"graph",
"=",
"new",
"Graph",
"(",
"$",
"config",
"[",
"'width'",
"]",
",",
"$",
"config",
"[",
"'height'",
"]",
",",
"'auto'",
")",
";",
"$",
"gr... | Builds and returns the Graph Object.
@access protected
@static
@param array $config Configuration Data
@param array $data Graph Data
@return Graph | [
"Builds",
"and",
"returns",
"the",
"Graph",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L51-L69 | train |
CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.buildImage | public static function buildImage( $config, $data )
{
$graph = self::buildGraph( $config, $data );
$graph->stroke();
} | php | public static function buildImage( $config, $data )
{
$graph = self::buildGraph( $config, $data );
$graph->stroke();
} | [
"public",
"static",
"function",
"buildImage",
"(",
"$",
"config",
",",
"$",
"data",
")",
"{",
"$",
"graph",
"=",
"self",
"::",
"buildGraph",
"(",
"$",
"config",
",",
"$",
"data",
")",
";",
"$",
"graph",
"->",
"stroke",
"(",
")",
";",
"}"
] | Builds and prints Graph Image.
@access public
@static
@param array $config Configuration Data
@param array $data Graph Data
@return void | [
"Builds",
"and",
"prints",
"Graph",
"Image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L79-L83 | train |
CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.createPlot | protected static function createPlot( $config, $data, $prefix )
{
$plotClass = $config[$prefix.'type'];
$plotClass = 'UI_Image_Graph_'.$plotClass;
$plotObject = new $plotClass;
$plotConf = self::getSubConfig( $config, $prefix );
return $plotObject->buildPlot( $plotConf, $data );
} | php | protected static function createPlot( $config, $data, $prefix )
{
$plotClass = $config[$prefix.'type'];
$plotClass = 'UI_Image_Graph_'.$plotClass;
$plotObject = new $plotClass;
$plotConf = self::getSubConfig( $config, $prefix );
return $plotObject->buildPlot( $plotConf, $data );
} | [
"protected",
"static",
"function",
"createPlot",
"(",
"$",
"config",
",",
"$",
"data",
",",
"$",
"prefix",
")",
"{",
"$",
"plotClass",
"=",
"$",
"config",
"[",
"$",
"prefix",
".",
"'type'",
"]",
";",
"$",
"plotClass",
"=",
"'UI_Image_Graph_'",
".",
"$"... | Creates a Plot working like a Plot Factory.
@access protected
@static
@param array $config Configuration Data
@param array $data Graph Data
@param string $prefix Configuration Prefix, must end with a Point
@return mixed | [
"Creates",
"a",
"Plot",
"working",
"like",
"a",
"Plot",
"Factory",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L94-L101 | train |
CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.saveImage | public static function saveImage( $fileName, $config, $data, $invertOrder = FALSE )
{
$graph = self::buildGraph( $config, $data, $invertOrder );
$graph->stroke( $fileName );
} | php | public static function saveImage( $fileName, $config, $data, $invertOrder = FALSE )
{
$graph = self::buildGraph( $config, $data, $invertOrder );
$graph->stroke( $fileName );
} | [
"public",
"static",
"function",
"saveImage",
"(",
"$",
"fileName",
",",
"$",
"config",
",",
"$",
"data",
",",
"$",
"invertOrder",
"=",
"FALSE",
")",
"{",
"$",
"graph",
"=",
"self",
"::",
"buildGraph",
"(",
"$",
"config",
",",
"$",
"data",
",",
"$",
... | Builds and saves Graph Image to an Image File.
@access public
@static
@param array $config Configuration Data
@param array $data Graph Data
@return void | [
"Builds",
"and",
"saves",
"Graph",
"Image",
"to",
"an",
"Image",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L138-L142 | train |
CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.setUpGrid | protected static function setUpGrid( $graph, $config, $data )
{
$gridDepth = self::getConfigValue( $config, "grid.depth", DEPTH_BACK );
$graph->setGridDepth( $gridDepth );
UI_Image_Graph_Components::setGrid( $graph->xgrid, self::getSubConfig( $config, 'x.grid.' ), $data );
UI_Image_Graph_Components::setGrid( $graph->ygrid, self::getSubConfig( $config, 'y.grid.' ), $data );
} | php | protected static function setUpGrid( $graph, $config, $data )
{
$gridDepth = self::getConfigValue( $config, "grid.depth", DEPTH_BACK );
$graph->setGridDepth( $gridDepth );
UI_Image_Graph_Components::setGrid( $graph->xgrid, self::getSubConfig( $config, 'x.grid.' ), $data );
UI_Image_Graph_Components::setGrid( $graph->ygrid, self::getSubConfig( $config, 'y.grid.' ), $data );
} | [
"protected",
"static",
"function",
"setUpGrid",
"(",
"$",
"graph",
",",
"$",
"config",
",",
"$",
"data",
")",
"{",
"$",
"gridDepth",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"\"grid.depth\"",
",",
"DEPTH_BACK",
")",
";",
"$",
"graph"... | Adds a Grid to Graph.
@access protected
@static
@param Graph $graph Graph Object to work on
@param array $config Configuration Data
@param array $data Graph Data
@return void | [
"Adds",
"a",
"Grid",
"to",
"Graph",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L153-L159 | train |
CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.setUpMargin | protected static function setUpMargin( $graph, $config )
{
$marginLeft = self::getConfigValue( $config, 'margin.left', 0 );
$marginRight = self::getConfigValue( $config, 'margin.right', 0 );
$marginTop = self::getConfigValue( $config, 'margin.top', 0 );
$marginBottom = self::getConfigValue( $config, 'margin.bottom', 0 );
$marginColor = self::getConfigValue( $config, 'margin.color' );
$graph->setMargin( $marginLeft, $marginRight, $marginTop, $marginBottom );
if( $marginColor )
$graph->setMarginColor( $marginColor );
} | php | protected static function setUpMargin( $graph, $config )
{
$marginLeft = self::getConfigValue( $config, 'margin.left', 0 );
$marginRight = self::getConfigValue( $config, 'margin.right', 0 );
$marginTop = self::getConfigValue( $config, 'margin.top', 0 );
$marginBottom = self::getConfigValue( $config, 'margin.bottom', 0 );
$marginColor = self::getConfigValue( $config, 'margin.color' );
$graph->setMargin( $marginLeft, $marginRight, $marginTop, $marginBottom );
if( $marginColor )
$graph->setMarginColor( $marginColor );
} | [
"protected",
"static",
"function",
"setUpMargin",
"(",
"$",
"graph",
",",
"$",
"config",
")",
"{",
"$",
"marginLeft",
"=",
"self",
"::",
"getConfigValue",
"(",
"$",
"config",
",",
"'margin.left'",
",",
"0",
")",
";",
"$",
"marginRight",
"=",
"self",
"::"... | Adds Margin to Graph.
@access protected
@static
@param Graph $graph Graph Object to work on
@param array $config Configuration Data
@return void | [
"Adds",
"Margin",
"to",
"Graph",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L169-L179 | train |
CeusMedia/Common | src/UI/Image/Graph/Builder.php | UI_Image_Graph_Builder.setUpPlots | protected static function setUpPlots( $graph, $config, $data )
{
// -- CREATE PLOTS -- //
$plots = array(
'y2' => array(),
'y1' => array(),
);
$nr = 1;
while( 1 )
{
$prefix = 'y1.'.$nr++.'.';
if( !isset( $config[$prefix.'type'] ) )
break;
if( $plot = self::createPlot( $config, $data, $prefix ) )
array_unshift( $plots['y1'], $plot );
}
$scaleY2 = self::getConfigValue( $config, "y2.scale" );
if( $scaleY2 )
{
$graph->setY2Scale( $scaleY2 );
UI_Image_Graph_Components::setAxis( $graph->y2axis, self::getSubConfig( $config, 'y2.axis.' ), $data );
$nr = 1;
while( 1 )
{
$prefix = 'y2.'.$nr++.'.';
if( !isset( $config[$prefix.'type'] ) )
break;
if( $plot = self::createPlot( $config, $prefix ) )
array_unshift( $plots['y2'], $plot );
}
}
foreach( $plots as $axis => $axisPlots )
foreach( $axisPlots as $plot )
( $axis == 'y2' ) ? $graph->addY2( $plot ) : $graph->add( $plot );
} | php | protected static function setUpPlots( $graph, $config, $data )
{
// -- CREATE PLOTS -- //
$plots = array(
'y2' => array(),
'y1' => array(),
);
$nr = 1;
while( 1 )
{
$prefix = 'y1.'.$nr++.'.';
if( !isset( $config[$prefix.'type'] ) )
break;
if( $plot = self::createPlot( $config, $data, $prefix ) )
array_unshift( $plots['y1'], $plot );
}
$scaleY2 = self::getConfigValue( $config, "y2.scale" );
if( $scaleY2 )
{
$graph->setY2Scale( $scaleY2 );
UI_Image_Graph_Components::setAxis( $graph->y2axis, self::getSubConfig( $config, 'y2.axis.' ), $data );
$nr = 1;
while( 1 )
{
$prefix = 'y2.'.$nr++.'.';
if( !isset( $config[$prefix.'type'] ) )
break;
if( $plot = self::createPlot( $config, $prefix ) )
array_unshift( $plots['y2'], $plot );
}
}
foreach( $plots as $axis => $axisPlots )
foreach( $axisPlots as $plot )
( $axis == 'y2' ) ? $graph->addY2( $plot ) : $graph->add( $plot );
} | [
"protected",
"static",
"function",
"setUpPlots",
"(",
"$",
"graph",
",",
"$",
"config",
",",
"$",
"data",
")",
"{",
"// -- CREATE PLOTS -- //",
"$",
"plots",
"=",
"array",
"(",
"'y2'",
"=>",
"array",
"(",
")",
",",
"'y1'",
"=>",
"array",
"(",
")",
... | Adds Plots to Graph.
@access protected
@static
@param Graph $graph Graph Object to work on
@param array $config Configuration Data
@param array $data Graph Data
@return void | [
"Adds",
"Plots",
"to",
"Graph",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Builder.php#L190-L225 | train |
CeusMedia/Common | src/Net/HTTP/PageRank.php | Net_HTTP_PageRank.calculateChecksum | private static function calculateChecksum( $url )
{
$length = sizeof( $url );
$a = $b = 0x9E3779B9;
$c = GOOGLE_MAGIC;
$k = 0;
$len = $length;
while( $len >= 12 )
{
$a += ( $url[$k+0] + ( $url[$k+1] <<8 ) + ( $url[$k+2] << 16 ) + ( $url[$k+3] << 24 ) );
$b += ( $url[$k+4] + ( $url[$k+5] <<8 ) + ( $url[$k+6] << 16 ) + ( $url[$k+7] << 24 ) );
$c += ( $url[$k+8] + ( $url[$k+9] <<8 ) + ( $url[$k+10] << 16 )+ ( $url[$k+11] << 24 ) );
$mix = self::mix( $a, $b, $c);
$a = $mix[0];
$b = $mix[1];
$c = $mix[2];
$k += 12;
$len -= 12;
}
$c += $length;
switch( $len )
{
case 11: $c +=( $url[$k+10] << 24 );
case 10: $c +=( $url[$k+9] << 16 );
case 9 : $c +=( $url[$k+8] << 8 );
/* the first byte of c is reserved for the length */
case 8 : $b +=( $url[$k+7] << 24 );
case 7 : $b +=( $url[$k+6] << 16 );
case 6 : $b +=( $url[$k+5] << 8 );
case 5 : $b +=( $url[$k+4]);
case 4 : $a +=( $url[$k+3] << 24 );
case 3 : $a +=( $url[$k+2] << 16 );
case 2 : $a +=( $url[$k+1] << 8 );
case 1 : $a +=( $url[$k+0] );
}
$mix = self::mix( $a, $b, $c );
return $mix[2];
} | php | private static function calculateChecksum( $url )
{
$length = sizeof( $url );
$a = $b = 0x9E3779B9;
$c = GOOGLE_MAGIC;
$k = 0;
$len = $length;
while( $len >= 12 )
{
$a += ( $url[$k+0] + ( $url[$k+1] <<8 ) + ( $url[$k+2] << 16 ) + ( $url[$k+3] << 24 ) );
$b += ( $url[$k+4] + ( $url[$k+5] <<8 ) + ( $url[$k+6] << 16 ) + ( $url[$k+7] << 24 ) );
$c += ( $url[$k+8] + ( $url[$k+9] <<8 ) + ( $url[$k+10] << 16 )+ ( $url[$k+11] << 24 ) );
$mix = self::mix( $a, $b, $c);
$a = $mix[0];
$b = $mix[1];
$c = $mix[2];
$k += 12;
$len -= 12;
}
$c += $length;
switch( $len )
{
case 11: $c +=( $url[$k+10] << 24 );
case 10: $c +=( $url[$k+9] << 16 );
case 9 : $c +=( $url[$k+8] << 8 );
/* the first byte of c is reserved for the length */
case 8 : $b +=( $url[$k+7] << 24 );
case 7 : $b +=( $url[$k+6] << 16 );
case 6 : $b +=( $url[$k+5] << 8 );
case 5 : $b +=( $url[$k+4]);
case 4 : $a +=( $url[$k+3] << 24 );
case 3 : $a +=( $url[$k+2] << 16 );
case 2 : $a +=( $url[$k+1] << 8 );
case 1 : $a +=( $url[$k+0] );
}
$mix = self::mix( $a, $b, $c );
return $mix[2];
} | [
"private",
"static",
"function",
"calculateChecksum",
"(",
"$",
"url",
")",
"{",
"$",
"length",
"=",
"sizeof",
"(",
"$",
"url",
")",
";",
"$",
"a",
"=",
"$",
"b",
"=",
"0x9E3779B9",
";",
"$",
"c",
"=",
"GOOGLE_MAGIC",
";",
"$",
"k",
"=",
"0",
";"... | Calculates Checksum of URL for Google Request
@access private
@static
@param array $url URL as numeric Array
@return string | [
"Calculates",
"Checksum",
"of",
"URL",
"for",
"Google",
"Request"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PageRank.php#L53-L90 | train |
CeusMedia/Common | src/Net/HTTP/PageRank.php | Net_HTTP_PageRank.get | public static function get( $url )
{
$checksum = "6".self::calculateChecksum( self::strord( "info:".$url ) );
$googleUrl = "www.google.com/search?client=navclient-auto&ch=".$checksum."&features=Rank&q=info:".$url;
$curl = new Net_CURL( $googleUrl );
$response = $curl->exec();
$position = strpos( $response, "Rank_" );
if( $position === FALSE )
throw new Exception( 'Response does not contain Rank.' );
$pagerank = substr( $response, $position + 9 );
return (int) $pagerank;
} | php | public static function get( $url )
{
$checksum = "6".self::calculateChecksum( self::strord( "info:".$url ) );
$googleUrl = "www.google.com/search?client=navclient-auto&ch=".$checksum."&features=Rank&q=info:".$url;
$curl = new Net_CURL( $googleUrl );
$response = $curl->exec();
$position = strpos( $response, "Rank_" );
if( $position === FALSE )
throw new Exception( 'Response does not contain Rank.' );
$pagerank = substr( $response, $position + 9 );
return (int) $pagerank;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"url",
")",
"{",
"$",
"checksum",
"=",
"\"6\"",
".",
"self",
"::",
"calculateChecksum",
"(",
"self",
"::",
"strord",
"(",
"\"info:\"",
".",
"$",
"url",
")",
")",
";",
"$",
"googleUrl",
"=",
"\"www.google... | Returns Google PageRank.
@access public
@static
@param string $url URL to check (e.G. www.domain.com)
@return int | [
"Returns",
"Google",
"PageRank",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PageRank.php#L99-L110 | train |
CeusMedia/Common | src/Net/HTTP/PageRank.php | Net_HTTP_PageRank.strord | private static function strord( $string )
{
for( $i=0; $i<strlen( $string ); $i++ )
{
$result[$i] = ord( $string{$i} );
}
return $result;
} | php | private static function strord( $string )
{
for( $i=0; $i<strlen( $string ); $i++ )
{
$result[$i] = ord( $string{$i} );
}
return $result;
} | [
"private",
"static",
"function",
"strord",
"(",
"$",
"string",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"strlen",
"(",
"$",
"string",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"result",
"[",
"$",
"i",
"]",
"=",
"ord",
"(... | Converts a String into an Array of Integers containing the numeric Values of the Characters.
@access private
@static
@param string $string String to convert
@return array | [
"Converts",
"a",
"String",
"into",
"an",
"Array",
"of",
"Integers",
"containing",
"the",
"numeric",
"Values",
"of",
"the",
"Characters",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PageRank.php#L133-L140 | train |
AOEpeople/Aoe_ExtendedFilter | app/code/community/Aoe/ExtendedFilter/Model/Core.php | Aoe_ExtendedFilter_Model_Core._amplifyModifiers | protected function _amplifyModifiers($value, $modifiers)
{
/** @var $helper Aoe_ExtendedFilter_Helper_Data */
$helper = Mage::helper('Aoe_ExtendedFilter');
foreach (explode('|', $modifiers) as $part) {
if (empty($part)) {
continue;
}
$params = explode(':', $part);
$modifier = array_shift($params);
$callback = $helper->getModifier($modifier);
// Legacy modifiers
if (!is_callable($callback) && isset($this->_modifiers[$modifier])) {
$callback = $this->_modifiers[$modifier];
if (!$callback) {
$callback = $modifier;
}
}
if (is_callable($callback)) {
array_unshift($params, $value);
$value = call_user_func_array($callback, $params);
}
}
return $value;
} | php | protected function _amplifyModifiers($value, $modifiers)
{
/** @var $helper Aoe_ExtendedFilter_Helper_Data */
$helper = Mage::helper('Aoe_ExtendedFilter');
foreach (explode('|', $modifiers) as $part) {
if (empty($part)) {
continue;
}
$params = explode(':', $part);
$modifier = array_shift($params);
$callback = $helper->getModifier($modifier);
// Legacy modifiers
if (!is_callable($callback) && isset($this->_modifiers[$modifier])) {
$callback = $this->_modifiers[$modifier];
if (!$callback) {
$callback = $modifier;
}
}
if (is_callable($callback)) {
array_unshift($params, $value);
$value = call_user_func_array($callback, $params);
}
}
return $value;
} | [
"protected",
"function",
"_amplifyModifiers",
"(",
"$",
"value",
",",
"$",
"modifiers",
")",
"{",
"/** @var $helper Aoe_ExtendedFilter_Helper_Data */",
"$",
"helper",
"=",
"Mage",
"::",
"helper",
"(",
"'Aoe_ExtendedFilter'",
")",
";",
"foreach",
"(",
"explode",
"(",... | Apply modifiers one by one, with specified params
Modifier syntax: modifier1[:param1:param2:...][|modifier2:...]
@param string $value
@param string $modifiers
@return string | [
"Apply",
"modifiers",
"one",
"by",
"one",
"with",
"specified",
"params"
] | 46c95b8167472c7a1ead51d2e92336e2a58fea13 | https://github.com/AOEpeople/Aoe_ExtendedFilter/blob/46c95b8167472c7a1ead51d2e92336e2a58fea13/app/code/community/Aoe/ExtendedFilter/Model/Core.php#L84-L111 | train |
CeusMedia/Common | src/Alg/Math/FormulaSum.php | Alg_Math_FormulaSum.calculate | public function calculate()
{
$sum = 0;
$arguments = func_get_args();
for( $i=$this->interval->getStart(); $i<=$this->interval->getEnd(); $i++ )
{
$params = array( $i );
foreach( $arguments as $argument )
$params[] = $argument;
$value = call_user_func_array( array( &$this->formula, 'getValue' ), $params );
$sum += $value;
}
return $sum;
} | php | public function calculate()
{
$sum = 0;
$arguments = func_get_args();
for( $i=$this->interval->getStart(); $i<=$this->interval->getEnd(); $i++ )
{
$params = array( $i );
foreach( $arguments as $argument )
$params[] = $argument;
$value = call_user_func_array( array( &$this->formula, 'getValue' ), $params );
$sum += $value;
}
return $sum;
} | [
"public",
"function",
"calculate",
"(",
")",
"{",
"$",
"sum",
"=",
"0",
";",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"this",
"->",
"interval",
"->",
"getStart",
"(",
")",
";",
"$",
"i",
"<=",
"$",
... | Calculates Sum of given Formula within given compact Interval and Parameters.
@access public
@return mixed | [
"Calculates",
"Sum",
"of",
"given",
"Formula",
"within",
"given",
"compact",
"Interval",
"and",
"Parameters",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/FormulaSum.php#L77-L90 | train |
CeusMedia/Common | src/DB/PDO/TableWriter.php | DB_PDO_TableWriter.delete | public function delete(){
$this->validateFocus();
$conditions = $this->getConditionQuery( array() );
$query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions;
# $has = $this->get( FALSE );
# if( !$has )
# throw new \InvalidArgumentException( 'Focused Indices are not existing.' );
return $this->dbc->exec( $query );
} | php | public function delete(){
$this->validateFocus();
$conditions = $this->getConditionQuery( array() );
$query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions;
# $has = $this->get( FALSE );
# if( !$has )
# throw new \InvalidArgumentException( 'Focused Indices are not existing.' );
return $this->dbc->exec( $query );
} | [
"public",
"function",
"delete",
"(",
")",
"{",
"$",
"this",
"->",
"validateFocus",
"(",
")",
";",
"$",
"conditions",
"=",
"$",
"this",
"->",
"getConditionQuery",
"(",
"array",
"(",
")",
")",
";",
"$",
"query",
"=",
"'DELETE FROM '",
".",
"$",
"this",
... | Deletes focused Rows in this Table and returns number of affected Rows.
@access public
@return int | [
"Deletes",
"focused",
"Rows",
"in",
"this",
"Table",
"and",
"returns",
"number",
"of",
"affected",
"Rows",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L46-L54 | train |
CeusMedia/Common | src/DB/PDO/TableWriter.php | DB_PDO_TableWriter.deleteByConditions | public function deleteByConditions( $where = array() ){
$conditions = $this->getConditionQuery( $where, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions
$query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions;
$result = $this->dbc->exec( $query );
$this->defocus();
return $result;
} | php | public function deleteByConditions( $where = array() ){
$conditions = $this->getConditionQuery( $where, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions
$query = 'DELETE FROM '.$this->getTableName().' WHERE '.$conditions;
$result = $this->dbc->exec( $query );
$this->defocus();
return $result;
} | [
"public",
"function",
"deleteByConditions",
"(",
"$",
"where",
"=",
"array",
"(",
")",
")",
"{",
"$",
"conditions",
"=",
"$",
"this",
"->",
"getConditionQuery",
"(",
"$",
"where",
",",
"FALSE",
",",
"FALSE",
",",
"FALSE",
")",
";",
"// render WHERE condit... | Deletes data by given conditions.
@access public
@param array $where associative Array of Condition Strings
@return bool | [
"Deletes",
"data",
"by",
"given",
"conditions",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L62-L68 | train |
CeusMedia/Common | src/DB/PDO/TableWriter.php | DB_PDO_TableWriter.insert | public function insert( $data = array(), $stripTags = TRUE ){
$columns = array();
$values = array();
foreach( $this->columns as $column ){ // iterate Columns
if( !isset( $data[$column] ) ) // no Data given for Column
continue;
$value = $data[$column];
if( $stripTags )
$value = strip_tags( $value );
$columns[$column] = $column;
$values[$column] = $this->secureValue( $value );
}
if( $this->isFocused() ){ // add focused indices to data
foreach( $this->focusedIndices as $index => $value ){ // iterate focused indices
if( isset( $columns[$index] ) ) // Column is already set
continue;
if( $index == $this->primaryKey ) // skip primary key
continue;
$columns[$index] = $index; // add key
$values[$index] = $this->secureValue( $value ); // add value
}
}
$columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names
$values = implode( ', ', array_values( $values ) );
$query = 'INSERT INTO '.$this->getTableName().' ('.$columns.') VALUES ('.$values.')';
$this->dbc->exec( $query );
return $this->dbc->lastInsertId();
} | php | public function insert( $data = array(), $stripTags = TRUE ){
$columns = array();
$values = array();
foreach( $this->columns as $column ){ // iterate Columns
if( !isset( $data[$column] ) ) // no Data given for Column
continue;
$value = $data[$column];
if( $stripTags )
$value = strip_tags( $value );
$columns[$column] = $column;
$values[$column] = $this->secureValue( $value );
}
if( $this->isFocused() ){ // add focused indices to data
foreach( $this->focusedIndices as $index => $value ){ // iterate focused indices
if( isset( $columns[$index] ) ) // Column is already set
continue;
if( $index == $this->primaryKey ) // skip primary key
continue;
$columns[$index] = $index; // add key
$values[$index] = $this->secureValue( $value ); // add value
}
}
$columns = $this->getColumnEnumeration( $columns ); // get enumeration of masked column names
$values = implode( ', ', array_values( $values ) );
$query = 'INSERT INTO '.$this->getTableName().' ('.$columns.') VALUES ('.$values.')';
$this->dbc->exec( $query );
return $this->dbc->lastInsertId();
} | [
"public",
"function",
"insert",
"(",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"stripTags",
"=",
"TRUE",
")",
"{",
"$",
"columns",
"=",
"array",
"(",
")",
";",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
... | Inserts data into this table and returns ID.
@access public
@param array $data associative array of data to store
@param bool $stripTags Flag: strip HTML Tags from values
@return int ID of inserted row | [
"Inserts",
"data",
"into",
"this",
"table",
"and",
"returns",
"ID",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L77-L104 | train |
CeusMedia/Common | src/DB/PDO/TableWriter.php | DB_PDO_TableWriter.updateByConditions | public function updateByConditions( $data = array(), $conditions = array(), $stripTags = FALSE ){
if( !( is_array( $data ) && $data ) )
throw new \InvalidArgumentException( 'Data for update must be an array and have atleast 1 pair' );
if( !( is_array( $conditions ) && $conditions ) )
throw new \InvalidArgumentException( 'Conditions for update must be an array and have atleast 1 pair' );
$updates = array();
$conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions
foreach( $this->columns as $column ){
if( isset( $data[$column] ) ){
if( $stripTags )
$data[$column] = strip_tags( $data[$column] );
if( $data[$column] == 'on' )
$data[$column] = 1;
$data[$column] = $this->secureValue( $data[$column] );
$updates[] = '`'.$column.'`='.$data[$column];
}
}
if( sizeof( $updates ) ){
$updates = implode( ', ', $updates );
$query = 'UPDATE '.$this->getTableName().' SET '.$updates.' WHERE '.$conditions;
$result = $this->dbc->exec( $query );
return $result;
}
} | php | public function updateByConditions( $data = array(), $conditions = array(), $stripTags = FALSE ){
if( !( is_array( $data ) && $data ) )
throw new \InvalidArgumentException( 'Data for update must be an array and have atleast 1 pair' );
if( !( is_array( $conditions ) && $conditions ) )
throw new \InvalidArgumentException( 'Conditions for update must be an array and have atleast 1 pair' );
$updates = array();
$conditions = $this->getConditionQuery( $conditions, FALSE, FALSE, FALSE ); // render WHERE conditions, uncursored, without functions
foreach( $this->columns as $column ){
if( isset( $data[$column] ) ){
if( $stripTags )
$data[$column] = strip_tags( $data[$column] );
if( $data[$column] == 'on' )
$data[$column] = 1;
$data[$column] = $this->secureValue( $data[$column] );
$updates[] = '`'.$column.'`='.$data[$column];
}
}
if( sizeof( $updates ) ){
$updates = implode( ', ', $updates );
$query = 'UPDATE '.$this->getTableName().' SET '.$updates.' WHERE '.$conditions;
$result = $this->dbc->exec( $query );
return $result;
}
} | [
"public",
"function",
"updateByConditions",
"(",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"conditions",
"=",
"array",
"(",
")",
",",
"$",
"stripTags",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"(",
"is_array",
"(",
"$",
"data",
")",
"&&",
"$",
... | Updates data in table where conditions are given for.
@access public
@param array $data Array of data to store
@param array $conditions Array of condition pairs
@param bool $stripTags Flag: strip HTML tags from values
@return bool | [
"Updates",
"data",
"in",
"table",
"where",
"conditions",
"are",
"given",
"for",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/TableWriter.php#L146-L170 | train |
CeusMedia/Common | src/UI/HTML/Tree/VariableDump.php | UI_HTML_Tree_VariableDump.buildTree | public static function buildTree( $mixed, $key = NULL, $closed = FALSE, $level = 0 )
{
if( $level === 0 )
self::$count = 0;
$type = gettype( $mixed );
$children = array();
$keyLabel = ( $key !== NULL ) ? htmlentities( $key, ENT_QUOTES, 'UTF-8' )." -> " : "";
$event = NULL;
self::$count++;
switch( $type )
{
case 'array':
self::$count--;
foreach( $mixed as $childKey => $childValue )
$children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 );
if( $key === NULL )
$keyLabel = self::$noteOpen."Array".self::$noteClose;
$mixed = "";
$event = '$(this).parent().toggleClass(\'closed\'); return false;';
break;
case 'object':
self::$count--;
$vars = get_object_vars( $mixed );
foreach( $vars as $childKey => $childValue )
$children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 );
$keyLabel = self::$noteOpen.get_class( $mixed ).self::$noteClose;
$mixed = "";
$event = '$(this).parent().toggleClass(\'closed\'); return false;';
break;
case 'bool':
$mixed = self::$noteOpen.( $mixed ? "TRUE" : "FALSE" ).self::$noteClose;
break;
case 'NULL':
if( $mixed === NULL )
$mixed = self::$noteOpen."NULL".self::$noteClose;
break;
case 'unknown type':
throw new RuntimeException( 'Unknown type' );
default:
if( preg_match( "/pass(w(or)?d)?/", $key ) )
$mixed = str_repeat( '*', 8 );
break;
}
$children = $children ? "\n".UI_HTML_Elements::unorderedList( $children, $level + 2 ) : "";
$pair = $keyLabel.htmlentities( $mixed, ENT_QUOTES, 'UTF-8' );
$label = UI_HTML_Tag::create( 'span', $pair, array( 'onclick' => $event ) );
$classes = array( $type );
if( $closed )
$classes[] = "closed";
return UI_HTML_Elements::ListItem( $label.$children, $level + 1, array( 'class' => implode( " ", $classes ) ) );
} | php | public static function buildTree( $mixed, $key = NULL, $closed = FALSE, $level = 0 )
{
if( $level === 0 )
self::$count = 0;
$type = gettype( $mixed );
$children = array();
$keyLabel = ( $key !== NULL ) ? htmlentities( $key, ENT_QUOTES, 'UTF-8' )." -> " : "";
$event = NULL;
self::$count++;
switch( $type )
{
case 'array':
self::$count--;
foreach( $mixed as $childKey => $childValue )
$children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 );
if( $key === NULL )
$keyLabel = self::$noteOpen."Array".self::$noteClose;
$mixed = "";
$event = '$(this).parent().toggleClass(\'closed\'); return false;';
break;
case 'object':
self::$count--;
$vars = get_object_vars( $mixed );
foreach( $vars as $childKey => $childValue )
$children[] = self::buildTree( $childValue, $childKey, $closed, $level + 1 );
$keyLabel = self::$noteOpen.get_class( $mixed ).self::$noteClose;
$mixed = "";
$event = '$(this).parent().toggleClass(\'closed\'); return false;';
break;
case 'bool':
$mixed = self::$noteOpen.( $mixed ? "TRUE" : "FALSE" ).self::$noteClose;
break;
case 'NULL':
if( $mixed === NULL )
$mixed = self::$noteOpen."NULL".self::$noteClose;
break;
case 'unknown type':
throw new RuntimeException( 'Unknown type' );
default:
if( preg_match( "/pass(w(or)?d)?/", $key ) )
$mixed = str_repeat( '*', 8 );
break;
}
$children = $children ? "\n".UI_HTML_Elements::unorderedList( $children, $level + 2 ) : "";
$pair = $keyLabel.htmlentities( $mixed, ENT_QUOTES, 'UTF-8' );
$label = UI_HTML_Tag::create( 'span', $pair, array( 'onclick' => $event ) );
$classes = array( $type );
if( $closed )
$classes[] = "closed";
return UI_HTML_Elements::ListItem( $label.$children, $level + 1, array( 'class' => implode( " ", $classes ) ) );
} | [
"public",
"static",
"function",
"buildTree",
"(",
"$",
"mixed",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"closed",
"=",
"FALSE",
",",
"$",
"level",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"level",
"===",
"0",
")",
"self",
"::",
"$",
"count",
"=",
"0... | Builds and returns a Tree Display of a Variable, recursively.
@access public
@static
@param mixed $mixed Variable of every Type to build Tree for
@param string $key Variable Name
@param string $closed Flag: start with closed Nodes
@param int $level Depth Level
@return void | [
"Builds",
"and",
"returns",
"a",
"Tree",
"Display",
"of",
"a",
"Variable",
"recursively",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tree/VariableDump.php#L57-L107 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.add | public function add( $elements, $overwrite = FALSE )
{
if( !is_array( $elements ) )
return 0;
$number = 0;
foreach( $elements as $key => $value )
{
if( !( is_string( $key ) || is_int( $key ) || is_float( $key ) ) )
throw new InvalidArgumentException( 'Invalid key type "'.gettype( $key ).'"' );
if( !strlen( trim( $key ) ) )
throw new InvalidArgumentException( 'Key cannot be empty' );
$isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary;
$isPrimitive = is_string( $value ) || is_int( $value ) || is_float( $value ) || is_bool( $value );
$isTemplate = $value instanceof $this->className;
if( is_null( $value ) )
continue;
else if( is_array( $value ) || $isListObject )
$number += $this->addArrayRecursive( $key, $value, array(), $overwrite );
else if( $isPrimitive || $isTemplate )
{
// if( $overwrite == TRUE )
// $this->elements[$key] = array();
// $this->elements[$key][] = $value;
$this->elements[$key] = $value;
$number ++;
}
else if( is_object( $value ) )
$this->addObject( $key, $value, array(), $overwrite );
else
throw new InvalidArgumentException( 'Unsupported type '.gettype( $value ).' for "'.$key.'"' );
}
return $number;
} | php | public function add( $elements, $overwrite = FALSE )
{
if( !is_array( $elements ) )
return 0;
$number = 0;
foreach( $elements as $key => $value )
{
if( !( is_string( $key ) || is_int( $key ) || is_float( $key ) ) )
throw new InvalidArgumentException( 'Invalid key type "'.gettype( $key ).'"' );
if( !strlen( trim( $key ) ) )
throw new InvalidArgumentException( 'Key cannot be empty' );
$isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary;
$isPrimitive = is_string( $value ) || is_int( $value ) || is_float( $value ) || is_bool( $value );
$isTemplate = $value instanceof $this->className;
if( is_null( $value ) )
continue;
else if( is_array( $value ) || $isListObject )
$number += $this->addArrayRecursive( $key, $value, array(), $overwrite );
else if( $isPrimitive || $isTemplate )
{
// if( $overwrite == TRUE )
// $this->elements[$key] = array();
// $this->elements[$key][] = $value;
$this->elements[$key] = $value;
$number ++;
}
else if( is_object( $value ) )
$this->addObject( $key, $value, array(), $overwrite );
else
throw new InvalidArgumentException( 'Unsupported type '.gettype( $value ).' for "'.$key.'"' );
}
return $number;
} | [
"public",
"function",
"add",
"(",
"$",
"elements",
",",
"$",
"overwrite",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"elements",
")",
")",
"return",
"0",
";",
"$",
"number",
"=",
"0",
";",
"foreach",
"(",
"$",
"elements",
"as",
... | Adds an associative array with labels and elements to the template and returns number of added elements.
@param array Array where the <b>key</b> can be a string, integer or
float and is the <b>label</b>. The <b>value</b> can be a
string, integer, float or a template object and represents
the element to add.
@param boolean if TRUE an a tag is already used, it will overwrite it
@return integer | [
"Adds",
"an",
"associative",
"array",
"with",
"labels",
"and",
"elements",
"to",
"the",
"template",
"and",
"returns",
"number",
"of",
"added",
"elements",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L109-L142 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.addArrayRecursive | public function addArrayRecursive( $name, $data, $steps = array(), $overwrite = FALSE )
{
$number = 0;
$steps[] = $name;
foreach( $data as $key => $value )
{
$isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary;
if( is_array( $value ) || $isListObject )
{
$number += $this->addArrayRecursive( $key, $value, $steps );
}
else
{
$key = implode( ".", $steps ).".".$key;
$this->addElement( $key, $value );
$number ++;
}
}
return $number;
} | php | public function addArrayRecursive( $name, $data, $steps = array(), $overwrite = FALSE )
{
$number = 0;
$steps[] = $name;
foreach( $data as $key => $value )
{
$isListObject = $value instanceof ArrayObject || $value instanceof ADT_List_Dictionary;
if( is_array( $value ) || $isListObject )
{
$number += $this->addArrayRecursive( $key, $value, $steps );
}
else
{
$key = implode( ".", $steps ).".".$key;
$this->addElement( $key, $value );
$number ++;
}
}
return $number;
} | [
"public",
"function",
"addArrayRecursive",
"(",
"$",
"name",
",",
"$",
"data",
",",
"$",
"steps",
"=",
"array",
"(",
")",
",",
"$",
"overwrite",
"=",
"FALSE",
")",
"{",
"$",
"number",
"=",
"0",
";",
"$",
"steps",
"[",
"]",
"=",
"$",
"name",
";",
... | Adds an array recursive and returns number of added elements.
@access public
@param string $name Key of array
@param mixed $data Values of array
@param array $steps Steps within recursion
@param bool $overwrite Flag: overwrite existing tag
@return int | [
"Adds",
"an",
"array",
"recursive",
"and",
"returns",
"number",
"of",
"added",
"elements",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L153-L172 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.addElement | public function addElement( $tag, $element, $overwrite = FALSE )
{
$this->add( array( $tag => $element ), $overwrite );
} | php | public function addElement( $tag, $element, $overwrite = FALSE )
{
$this->add( array( $tag => $element ), $overwrite );
} | [
"public",
"function",
"addElement",
"(",
"$",
"tag",
",",
"$",
"element",
",",
"$",
"overwrite",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"array",
"(",
"$",
"tag",
"=>",
"$",
"element",
")",
",",
"$",
"overwrite",
")",
";",
"}"
] | Adds one Element.
@param string $tag Tag name
@param string|integer|float|UI_Template
@param boolean if set to TRUE, it will overwrite an existing element with the same label
@return void | [
"Adds",
"one",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L181-L184 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.addTemplate | public function addTemplate( $tag, $fileName, $element = NULL, $overwrite = FALSE )
{
$this->addElement( $tag, new self( $fileName, $element ), $overwrite );
} | php | public function addTemplate( $tag, $fileName, $element = NULL, $overwrite = FALSE )
{
$this->addElement( $tag, new self( $fileName, $element ), $overwrite );
} | [
"public",
"function",
"addTemplate",
"(",
"$",
"tag",
",",
"$",
"fileName",
",",
"$",
"element",
"=",
"NULL",
",",
"$",
"overwrite",
"=",
"FALSE",
")",
"{",
"$",
"this",
"->",
"addElement",
"(",
"$",
"tag",
",",
"new",
"self",
"(",
"$",
"fileName",
... | Adds another Template.
@param string tagname
@param string template file
@param array array containing elements {@link add()}
@param boolean if set to TRUE, it will overwrite an existing element with the same label
@return void | [
"Adds",
"another",
"Template",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L216-L219 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.create | public function create()
{
$out = $this->template; // local copy of set template
$out = $this->loadNestedTemplates( $out ); // search for nested templates and load them
foreach( $this->plugins as $plugin )
if( $plugin->type == 'pre' )
$out = $plugin->work( $out );
$out = preg_replace( '/<%--.*--%>/sU', '', $out ); // remove template engine style comments
if( self::$removeComments ) // HTML comments should be removed
$out = preg_replace( '/<!--.+-->/sU', '', $out ); // find and remove all HTML comments
if( self::$removeOptional ) // optional parts should be removed
$out = preg_replace( '/<%\?--.+--%>/sU', '', $out ); // find and remove optional parts
else // otherwise
$out = preg_replace( '/<%\?--(.+)--%>/sU', '\\1', $out ); // find, remove markup but keep content
foreach( $this->elements as $label => $element ) // iterate over all registered element containers
{
$tmp = ''; //
if( is_object( $element ) ) // element is an object
{
if( !( $element instanceof $this->className ) ) // object is not an template of this template engine
continue; // skip this one
$element = $element->create(); // render template before concat
}
$tmp .= $element;
$out = preg_replace( '/<%(\?)?' . preg_quote( $label, '/' ) . '%>/', $tmp, $out ); // find placeholder and set in content
}
$out = preg_replace( '/<%\?.*%>/U', '', $out ); // remove left over optional placeholders
# $out = preg_replace( '/\n\s+\n/', "\n", $out ); // remove double line breaks
foreach( $this->plugins as $plugin )
if( $plugin->type == 'post' )
$out = $plugin->work( $out );
$tags = array(); // create container for left over placeholders
if( preg_match_all( '/<%.*%>/U', $out, $tags ) === 0 ) // no more placeholders left over
return $out; // return final result
$tags = array_shift( $tags ); //
foreach( $tags as $key => $value )
$tags[$key] = preg_replace( '@(<%\??)|%>@', "", $value );
if( $this->fileName )
throw new Exception_Template( Exception_Template::FILE_LABELS_MISSING, $this->fileName, $tags );
throw new Exception_Template( Exception_Template::LABELS_MISSING, NULL, $tags );
} | php | public function create()
{
$out = $this->template; // local copy of set template
$out = $this->loadNestedTemplates( $out ); // search for nested templates and load them
foreach( $this->plugins as $plugin )
if( $plugin->type == 'pre' )
$out = $plugin->work( $out );
$out = preg_replace( '/<%--.*--%>/sU', '', $out ); // remove template engine style comments
if( self::$removeComments ) // HTML comments should be removed
$out = preg_replace( '/<!--.+-->/sU', '', $out ); // find and remove all HTML comments
if( self::$removeOptional ) // optional parts should be removed
$out = preg_replace( '/<%\?--.+--%>/sU', '', $out ); // find and remove optional parts
else // otherwise
$out = preg_replace( '/<%\?--(.+)--%>/sU', '\\1', $out ); // find, remove markup but keep content
foreach( $this->elements as $label => $element ) // iterate over all registered element containers
{
$tmp = ''; //
if( is_object( $element ) ) // element is an object
{
if( !( $element instanceof $this->className ) ) // object is not an template of this template engine
continue; // skip this one
$element = $element->create(); // render template before concat
}
$tmp .= $element;
$out = preg_replace( '/<%(\?)?' . preg_quote( $label, '/' ) . '%>/', $tmp, $out ); // find placeholder and set in content
}
$out = preg_replace( '/<%\?.*%>/U', '', $out ); // remove left over optional placeholders
# $out = preg_replace( '/\n\s+\n/', "\n", $out ); // remove double line breaks
foreach( $this->plugins as $plugin )
if( $plugin->type == 'post' )
$out = $plugin->work( $out );
$tags = array(); // create container for left over placeholders
if( preg_match_all( '/<%.*%>/U', $out, $tags ) === 0 ) // no more placeholders left over
return $out; // return final result
$tags = array_shift( $tags ); //
foreach( $tags as $key => $value )
$tags[$key] = preg_replace( '@(<%\??)|%>@', "", $value );
if( $this->fileName )
throw new Exception_Template( Exception_Template::FILE_LABELS_MISSING, $this->fileName, $tags );
throw new Exception_Template( Exception_Template::LABELS_MISSING, NULL, $tags );
} | [
"public",
"function",
"create",
"(",
")",
"{",
"$",
"out",
"=",
"$",
"this",
"->",
"template",
";",
"// local copy of set template",
"$",
"out",
"=",
"$",
"this",
"->",
"loadNestedTemplates",
"(",
"$",
"out",
")",
";",
"// search for nested templates and load ... | Creates an output string from the templatefile where all labels will be replaced with apropriate elements.
If a non optional label wasn't specified, the method will throw a Template Exception
@access public
@return string | [
"Creates",
"an",
"output",
"string",
"from",
"the",
"templatefile",
"where",
"all",
"labels",
"will",
"be",
"replaced",
"with",
"apropriate",
"elements",
".",
"If",
"a",
"non",
"optional",
"label",
"wasn",
"t",
"specified",
"the",
"method",
"will",
"throw",
... | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L227-L273 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.getElementsFromComment | public function getElementsFromComment( $comment, $unique = TRUE )
{
$content = $this->getTaggedComment( $comment );
if( !isset( $content ) )
return NULL;
$list = array();
$content = explode( "\n", $content );
foreach( $content as $row )
{
if( preg_match( '/\s*@(\S+)?\s+(.*)/', $row, $out ) )
{
if( $unique )
$list[$out[1]] = $out[2];
else
$list[$out[1]][] = $out[2];
}
}
return $list;
} | php | public function getElementsFromComment( $comment, $unique = TRUE )
{
$content = $this->getTaggedComment( $comment );
if( !isset( $content ) )
return NULL;
$list = array();
$content = explode( "\n", $content );
foreach( $content as $row )
{
if( preg_match( '/\s*@(\S+)?\s+(.*)/', $row, $out ) )
{
if( $unique )
$list[$out[1]] = $out[2];
else
$list[$out[1]][] = $out[2];
}
}
return $list;
} | [
"public",
"function",
"getElementsFromComment",
"(",
"$",
"comment",
",",
"$",
"unique",
"=",
"TRUE",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"getTaggedComment",
"(",
"$",
"comment",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"content",
")"... | Returns all marked elements from a comment.
@param string $comment Comment Tag
@param boolean $unique Flag: unique Keys only
@return array containing Elements or empty | [
"Returns",
"all",
"marked",
"elements",
"from",
"a",
"comment",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L291-L310 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.getLabels | public function getLabels( $type = 0, $xml = TRUE )
{
$content = preg_replace( '/<%\??--.*--%>/sU', '', $this->template );
switch( $type )
{
case 2:
preg_match_all( '/<%(\?.*)%>/U', $content, $tags );
break;
case 1:
preg_match_all( '/<%([^-?].*)%>/U', $content, $tags );
break;
default:
preg_match_all( '/<%([^-].*)%>/U', $content, $tags );
}
return $xml ? $tags[0] : $tags[1];
} | php | public function getLabels( $type = 0, $xml = TRUE )
{
$content = preg_replace( '/<%\??--.*--%>/sU', '', $this->template );
switch( $type )
{
case 2:
preg_match_all( '/<%(\?.*)%>/U', $content, $tags );
break;
case 1:
preg_match_all( '/<%([^-?].*)%>/U', $content, $tags );
break;
default:
preg_match_all( '/<%([^-].*)%>/U', $content, $tags );
}
return $xml ? $tags[0] : $tags[1];
} | [
"public",
"function",
"getLabels",
"(",
"$",
"type",
"=",
"0",
",",
"$",
"xml",
"=",
"TRUE",
")",
"{",
"$",
"content",
"=",
"preg_replace",
"(",
"'/<%\\??--.*--%>/sU'",
",",
"''",
",",
"$",
"this",
"->",
"template",
")",
";",
"switch",
"(",
"$",
"typ... | Returns all defined labels.
@param int $type Label Type: 0=all, 1=mandatory, 2=optional
@param boolean $xml Flag: with or without delimiter
@return array Array of Labels | [
"Returns",
"all",
"defined",
"labels",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L318-L333 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.getTaggedComment | public function getTaggedComment( $tag, $xml = TRUE )
{
if( preg_match( '/<%--'.$tag.'(.*)--%>/sU', $this->template, $tag ) )
return $xml ? $tag[0] : $tag[1];
return NULL;
} | php | public function getTaggedComment( $tag, $xml = TRUE )
{
if( preg_match( '/<%--'.$tag.'(.*)--%>/sU', $this->template, $tag ) )
return $xml ? $tag[0] : $tag[1];
return NULL;
} | [
"public",
"function",
"getTaggedComment",
"(",
"$",
"tag",
",",
"$",
"xml",
"=",
"TRUE",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/<%--'",
".",
"$",
"tag",
".",
"'(.*)--%>/sU'",
",",
"$",
"this",
"->",
"template",
",",
"$",
"tag",
")",
")",
"return"... | Returns a tagged comment.
@param string $tag Comment Tag
@param boolean $xml Flag: with or without Delimiter
@return string Comment or NULL
@todo quote specialchars in tagname | [
"Returns",
"a",
"tagged",
"comment",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L342-L347 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.renderString | public static function renderString( $string, $elements = array() )
{
$template = new self();
$template->template = $string;
$template->add( $elements );
return $template->create();
} | php | public static function renderString( $string, $elements = array() )
{
$template = new self();
$template->template = $string;
$template->add( $elements );
return $template->create();
} | [
"public",
"static",
"function",
"renderString",
"(",
"$",
"string",
",",
"$",
"elements",
"=",
"array",
"(",
")",
")",
"{",
"$",
"template",
"=",
"new",
"self",
"(",
")",
";",
"$",
"template",
"->",
"template",
"=",
"$",
"string",
";",
"$",
"template... | Renders a Template String with given Elements statically.
@access public
@static
@param string $string Template String
@param array $elements Map of Elements for Template String
@return string | [
"Renders",
"a",
"Template",
"String",
"with",
"given",
"Elements",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L402-L408 | train |
CeusMedia/Common | src/UI/Template.php | UI_Template.setTemplate | public function setTemplate( $fileName )
{
if( empty( $fileName ) )
return FALSE;
if( !file_exists( $fileName ) )
throw new Exception_Template( Exception_Template::FILE_NOT_FOUND, $fileName );
$this->fileName = $fileName;
$this->template = file_get_contents( $fileName );
return TRUE;
} | php | public function setTemplate( $fileName )
{
if( empty( $fileName ) )
return FALSE;
if( !file_exists( $fileName ) )
throw new Exception_Template( Exception_Template::FILE_NOT_FOUND, $fileName );
$this->fileName = $fileName;
$this->template = file_get_contents( $fileName );
return TRUE;
} | [
"public",
"function",
"setTemplate",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"fileName",
")",
")",
"return",
"FALSE",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"throw",
"new",
"Exception_Template",
"(",
"... | Loads a new template file if it exists. Otherwise it will throw an Exception.
@param string $fileName File Name of Template
@return boolean | [
"Loads",
"a",
"new",
"template",
"file",
"if",
"it",
"exists",
".",
"Otherwise",
"it",
"will",
"throw",
"an",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Template.php#L415-L426 | train |
FriendsOfSilverStripe/backendmessages | src/Message.php | Message.warning | public static function warning($message = null, $name = null)
{
return self::generic($message, WarningMessage::$CSSClass, $name);
} | php | public static function warning($message = null, $name = null)
{
return self::generic($message, WarningMessage::$CSSClass, $name);
} | [
"public",
"static",
"function",
"warning",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"generic",
"(",
"$",
"message",
",",
"WarningMessage",
"::",
"$",
"CSSClass",
",",
"$",
"name",
")",
";",
"}... | Creates a warning message.
@param string $message
@param string $name (optional)
@return MessageBoxField | [
"Creates",
"a",
"warning",
"message",
"."
] | 6733fd84162fb2b722dcc31ece01f5b36f2f84a4 | https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/Message.php#L69-L72 | train |
FriendsOfSilverStripe/backendmessages | src/Message.php | Message.success | public static function success($message = null, $name = null)
{
return self::generic($message, SuccessMessage::$CSSClass, $name);
} | php | public static function success($message = null, $name = null)
{
return self::generic($message, SuccessMessage::$CSSClass, $name);
} | [
"public",
"static",
"function",
"success",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"generic",
"(",
"$",
"message",
",",
"SuccessMessage",
"::",
"$",
"CSSClass",
",",
"$",
"name",
")",
";",
"}... | Creates a success message.
@param string $message
@param string $name (optional)
@return MessageBoxField | [
"Creates",
"a",
"success",
"message",
"."
] | 6733fd84162fb2b722dcc31ece01f5b36f2f84a4 | https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/Message.php#L82-L85 | train |
FriendsOfSilverStripe/backendmessages | src/Message.php | Message.notice | public static function notice($message = null, $name = null)
{
return self::generic($message, NoticeMessage::$CSSClass, $name);
} | php | public static function notice($message = null, $name = null)
{
return self::generic($message, NoticeMessage::$CSSClass, $name);
} | [
"public",
"static",
"function",
"notice",
"(",
"$",
"message",
"=",
"null",
",",
"$",
"name",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"generic",
"(",
"$",
"message",
",",
"NoticeMessage",
"::",
"$",
"CSSClass",
",",
"$",
"name",
")",
";",
"}"
... | Creates a notice message.
@param string $message
@param string $name (optional)
@return MessageBoxField | [
"Creates",
"a",
"notice",
"message",
"."
] | 6733fd84162fb2b722dcc31ece01f5b36f2f84a4 | https://github.com/FriendsOfSilverStripe/backendmessages/blob/6733fd84162fb2b722dcc31ece01f5b36f2f84a4/src/Message.php#L95-L98 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Configuration/AbstractConfiguration.php | AbstractConfiguration.loadDrivers | public function loadDrivers(): DriverCollection
{
$drivers = new DriverCollection($this);
foreach ($this->drivers as $name => $driver) {
$drivers->add($name, $driver);
}
return $drivers;
} | php | public function loadDrivers(): DriverCollection
{
$drivers = new DriverCollection($this);
foreach ($this->drivers as $name => $driver) {
$drivers->add($name, $driver);
}
return $drivers;
} | [
"public",
"function",
"loadDrivers",
"(",
")",
":",
"DriverCollection",
"{",
"$",
"drivers",
"=",
"new",
"DriverCollection",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"drivers",
"as",
"$",
"name",
"=>",
"$",
"driver",
")",
"{",
"$"... | Returns collection of registered application drivers
@return DriverCollection | [
"Returns",
"collection",
"of",
"registered",
"application",
"drivers"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L49-L58 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Configuration/AbstractConfiguration.php | AbstractConfiguration.loadDriver | public function loadDriver(string $key): DriverInterface
{
if (!$this->hasDriver($key)) {
throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.');
}
return $this->drivers[$key]::install($this);
} | php | public function loadDriver(string $key): DriverInterface
{
if (!$this->hasDriver($key)) {
throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.');
}
return $this->drivers[$key]::install($this);
} | [
"public",
"function",
"loadDriver",
"(",
"string",
"$",
"key",
")",
":",
"DriverInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasDriver",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"DriverNotFoundException",
"(",
"'Driver you are looking for doesn\... | Returns configured instance of given driver
@param string $key Name of driver
@return DriverInterface
@throws DriverNotFoundException if given driver doesn't exist | [
"Returns",
"configured",
"instance",
"of",
"given",
"driver"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L67-L74 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Configuration/AbstractConfiguration.php | AbstractConfiguration.isConfigured | public function isConfigured(array $keys, string $section): bool
{
if (!array_key_exists($section, $this->configuration)) {
return false;
}
return !array_diff_key(array_flip($keys), $this->configuration[$section]);
} | php | public function isConfigured(array $keys, string $section): bool
{
if (!array_key_exists($section, $this->configuration)) {
return false;
}
return !array_diff_key(array_flip($keys), $this->configuration[$section]);
} | [
"public",
"function",
"isConfigured",
"(",
"array",
"$",
"keys",
",",
"string",
"$",
"section",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"section",
",",
"$",
"this",
"->",
"configuration",
")",
")",
"{",
"return",
"false",
"... | Checks if given parameters exist in configuration
@param array $keys Set of parameters keys to check
@param string $section Name of configuration file section, in which given parameters should exist
@return bool | [
"Checks",
"if",
"given",
"parameters",
"exist",
"in",
"configuration"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L104-L111 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Configuration/AbstractConfiguration.php | AbstractConfiguration.parseConfiguration | private function parseConfiguration(): void
{
$configFilePath = dirname(__DIR__, 7) . '/src/' . $this->getConfigPath() . '/config.ini';
if (!file_exists($configFilePath)) {
throw new ConfigurationNotFoundException('Configuration file in ' . $configFilePath . ' not found.');
}
$this->configuration = parse_ini_file($configFilePath, true);
if (!$this->isConfigured(['root_namespace', 'env'], 'framework')) {
throw new MissingConfigurationException(['root_namespace', 'env'], 'framework');
}
} | php | private function parseConfiguration(): void
{
$configFilePath = dirname(__DIR__, 7) . '/src/' . $this->getConfigPath() . '/config.ini';
if (!file_exists($configFilePath)) {
throw new ConfigurationNotFoundException('Configuration file in ' . $configFilePath . ' not found.');
}
$this->configuration = parse_ini_file($configFilePath, true);
if (!$this->isConfigured(['root_namespace', 'env'], 'framework')) {
throw new MissingConfigurationException(['root_namespace', 'env'], 'framework');
}
} | [
"private",
"function",
"parseConfiguration",
"(",
")",
":",
"void",
"{",
"$",
"configFilePath",
"=",
"dirname",
"(",
"__DIR__",
",",
"7",
")",
".",
"'/src/'",
".",
"$",
"this",
"->",
"getConfigPath",
"(",
")",
".",
"'/config.ini'",
";",
"if",
"(",
"!",
... | Parses config.ini file into configuration array
@throws ConfigurationNotFoundException if config.ini file doesn't exist in specified path
@throws MissingConfigurationException if root_namespace or env is not configured | [
"Parses",
"config",
".",
"ini",
"file",
"into",
"configuration",
"array"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Configuration/AbstractConfiguration.php#L119-L132 | train |
CeusMedia/Common | src/Alg/Object/EventHandler.php | Alg_Object_EventHandler.handleEvent | public function handleEvent( $eventName )
{
$counter = 0;
if( !array_key_exists( $eventName, $this->callbacks ) )
return $counter;
foreach( $this->callbacks[$eventName] as $callback )
{
extract( $callback );
$factory = new Alg_Object_MethodFactory; // build a new Method Factory
$factory->callObjectMethod( $object, $methodName, $methodParameters );
$counter++; // increase Callback Counter
$this->counter++; // increase total Callback Counter
}
return $counter;
} | php | public function handleEvent( $eventName )
{
$counter = 0;
if( !array_key_exists( $eventName, $this->callbacks ) )
return $counter;
foreach( $this->callbacks[$eventName] as $callback )
{
extract( $callback );
$factory = new Alg_Object_MethodFactory; // build a new Method Factory
$factory->callObjectMethod( $object, $methodName, $methodParameters );
$counter++; // increase Callback Counter
$this->counter++; // increase total Callback Counter
}
return $counter;
} | [
"public",
"function",
"handleEvent",
"(",
"$",
"eventName",
")",
"{",
"$",
"counter",
"=",
"0",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"eventName",
",",
"$",
"this",
"->",
"callbacks",
")",
")",
"return",
"$",
"counter",
";",
"foreach",
"("... | Trigger all registered Callbacks for an Event.
@access public
@public string $eventName Name of Event to trigger
@return int Number of handled Callbacks | [
"Trigger",
"all",
"registered",
"Callbacks",
"for",
"an",
"Event",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Object/EventHandler.php#L119-L133 | train |
CeusMedia/Common | src/FS/File/PHP/Encoder.php | FS_File_PHP_Encoder.decode | public function decode( $php )
{
$code = substr( $php, strlen( $this->outcodePrefix) , -strlen( $this->outcodeSuffix ) );
$php = $this->decodeHash( $code );
return $php;
} | php | public function decode( $php )
{
$code = substr( $php, strlen( $this->outcodePrefix) , -strlen( $this->outcodeSuffix ) );
$php = $this->decodeHash( $code );
return $php;
} | [
"public",
"function",
"decode",
"(",
"$",
"php",
")",
"{",
"$",
"code",
"=",
"substr",
"(",
"$",
"php",
",",
"strlen",
"(",
"$",
"this",
"->",
"outcodePrefix",
")",
",",
"-",
"strlen",
"(",
"$",
"this",
"->",
"outcodeSuffix",
")",
")",
";",
"$",
... | Returns decoded and stripped PHP Content.
@access public
@param string $php Encoded PHP Content
@return string | [
"Returns",
"decoded",
"and",
"stripped",
"PHP",
"Content",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L76-L81 | train |
CeusMedia/Common | src/FS/File/PHP/Encoder.php | FS_File_PHP_Encoder.decodeFile | public function decodeFile( $fileName, $overwrite = FALSE )
{
if( file_exists( $fileName ) )
{
if( $this->isEncoded( $fileName ) )
{
$file = new FS_File_Editor( $fileName );
$php = $file->readString();
$code = $this->encode( $php );
$dirname = dirname( $fileName );
$basename = basename( $fileName );
$target = $dirname."/".substr( $basename, strlen( $this->filePrefix) , -strlen( $this->fileSuffix ) );
if( $fileName == $target && !$overwrite )
throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' );
$file->writeString( $code );
return TRUE;
}
}
return FALSE;
} | php | public function decodeFile( $fileName, $overwrite = FALSE )
{
if( file_exists( $fileName ) )
{
if( $this->isEncoded( $fileName ) )
{
$file = new FS_File_Editor( $fileName );
$php = $file->readString();
$code = $this->encode( $php );
$dirname = dirname( $fileName );
$basename = basename( $fileName );
$target = $dirname."/".substr( $basename, strlen( $this->filePrefix) , -strlen( $this->fileSuffix ) );
if( $fileName == $target && !$overwrite )
throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' );
$file->writeString( $code );
return TRUE;
}
}
return FALSE;
} | [
"public",
"function",
"decodeFile",
"(",
"$",
"fileName",
",",
"$",
"overwrite",
"=",
"FALSE",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEncoded",
"(",
"$",
"fileName",
")",
")",
"{",
... | Decodes an encoded PHP File.
@access public
@return void | [
"Decodes",
"an",
"encoded",
"PHP",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L88-L107 | train |
CeusMedia/Common | src/FS/File/PHP/Encoder.php | FS_File_PHP_Encoder.decodeHash | protected function decodeHash( $code )
{
$php = gzinflate( base64_decode( $code ) );
$php = substr( $php, strlen( $this->incodePrefix) , -strlen( $this->incodeSuffix ) );
return $php;
} | php | protected function decodeHash( $code )
{
$php = gzinflate( base64_decode( $code ) );
$php = substr( $php, strlen( $this->incodePrefix) , -strlen( $this->incodeSuffix ) );
return $php;
} | [
"protected",
"function",
"decodeHash",
"(",
"$",
"code",
")",
"{",
"$",
"php",
"=",
"gzinflate",
"(",
"base64_decode",
"(",
"$",
"code",
")",
")",
";",
"$",
"php",
"=",
"substr",
"(",
"$",
"php",
",",
"strlen",
"(",
"$",
"this",
"->",
"incodePrefix",... | Returns Hash decoded PHP Content.
@access protected
@param string $php Encoded PHP Content
@return string | [
"Returns",
"Hash",
"decoded",
"PHP",
"Content",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L115-L120 | train |
CeusMedia/Common | src/FS/File/PHP/Encoder.php | FS_File_PHP_Encoder.encode | public function encode( $php )
{
$code = $this->encodeHash( $php );
$php = $this->outcodePrefix.$code.$this->outcodeSuffix;
return $php;
} | php | public function encode( $php )
{
$code = $this->encodeHash( $php );
$php = $this->outcodePrefix.$code.$this->outcodeSuffix;
return $php;
} | [
"public",
"function",
"encode",
"(",
"$",
"php",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"encodeHash",
"(",
"$",
"php",
")",
";",
"$",
"php",
"=",
"$",
"this",
"->",
"outcodePrefix",
".",
"$",
"code",
".",
"$",
"this",
"->",
"outcodeSuffix",... | Returns encoded and wrapped PHP Content.
@access public
@param string $php Encoded PHP Content
@return string | [
"Returns",
"encoded",
"and",
"wrapped",
"PHP",
"Content",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L128-L133 | train |
CeusMedia/Common | src/FS/File/PHP/Encoder.php | FS_File_PHP_Encoder.encodeFile | public function encodeFile( $fileName, $overwrite = FALSE )
{
if( !file_exists( $fileName ) )
return FALSE;
if( $this->isEncoded( $fileName ) )
return TRUE;
$php = FS_File_Reader::load( $fileName );
$code = $this->encode( $php );
$dirname = dirname( $fileName );
$basename = basename( $fileName );
$target = $dirname."/".$this->filePrefix.$basename.$this->fileSuffix;
if( $fileName == $target && !$overwrite )
throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' );
// copy( $fileName, "#".$fileName );
return (bool) FS_File_Writer::save( $target, $code );
} | php | public function encodeFile( $fileName, $overwrite = FALSE )
{
if( !file_exists( $fileName ) )
return FALSE;
if( $this->isEncoded( $fileName ) )
return TRUE;
$php = FS_File_Reader::load( $fileName );
$code = $this->encode( $php );
$dirname = dirname( $fileName );
$basename = basename( $fileName );
$target = $dirname."/".$this->filePrefix.$basename.$this->fileSuffix;
if( $fileName == $target && !$overwrite )
throw new RuntimeException( 'File cannot be overwritten, use Parameter "overwrite".' );
// copy( $fileName, "#".$fileName );
return (bool) FS_File_Writer::save( $target, $code );
} | [
"public",
"function",
"encodeFile",
"(",
"$",
"fileName",
",",
"$",
"overwrite",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"return",
"FALSE",
";",
"if",
"(",
"$",
"this",
"->",
"isEncoded",
"(",
"$",
"file... | Encodes a PHP File.
@access public
@return void | [
"Encodes",
"a",
"PHP",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L140-L155 | train |
CeusMedia/Common | src/FS/File/PHP/Encoder.php | FS_File_PHP_Encoder.isEncoded | public function isEncoded( $fileName )
{
if( file_exists( $fileName ) )
{
$fp = fopen( $fileName, "r" );
$code = fgets( $fp, strlen( $this->outcodePrefix ) );
if( $code == $this->outcodePrefix )
return TRUE;
}
return FALSE;
} | php | public function isEncoded( $fileName )
{
if( file_exists( $fileName ) )
{
$fp = fopen( $fileName, "r" );
$code = fgets( $fp, strlen( $this->outcodePrefix ) );
if( $code == $this->outcodePrefix )
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"isEncoded",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"{",
"$",
"fp",
"=",
"fopen",
"(",
"$",
"fileName",
",",
"\"r\"",
")",
";",
"$",
"code",
"=",
"fgets",
"(",
"$",
"fp",
",... | Indicated whether a PHP File ist encoded.
@access public
@param string $fileName File Name of PHP File to be checked
@return bool | [
"Indicated",
"whether",
"a",
"PHP",
"File",
"ist",
"encoded",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/PHP/Encoder.php#L174-L184 | train |
smasty/Neevo | src/Neevo/Drivers/pgsql.php | PgSQLDriver.getInsertId | public function getInsertId(){
$result = $this->runQuery("SELECT LASTVAL()");
if(!$result)
return false;
$r = $this->fetch($result);
return is_array($r) ? reset($r) : false;
} | php | public function getInsertId(){
$result = $this->runQuery("SELECT LASTVAL()");
if(!$result)
return false;
$r = $this->fetch($result);
return is_array($r) ? reset($r) : false;
} | [
"public",
"function",
"getInsertId",
"(",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"runQuery",
"(",
"\"SELECT LASTVAL()\"",
")",
";",
"if",
"(",
"!",
"$",
"result",
")",
"return",
"false",
";",
"$",
"r",
"=",
"$",
"this",
"->",
"fetch",
"(",
... | Returns the ID generated in the INSERT statement.
@return int | [
"Returns",
"the",
"ID",
"generated",
"in",
"the",
"INSERT",
"statement",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Drivers/pgsql.php#L195-L202 | train |
generationtux/marketo-rest-api-client | src/Api/CustomActivitiesApi.php | CustomActivitiesApi.create | public function create(array $fields)
{
$url = $this->client->url . "/rest/v1/activities/external.json";
$response = $this->post($url, ['input' => $fields]);
if (!$response->success) {
throw new MarketoApiException('Error creating custom activity: ' . $response->errors[0]->message);
}
} | php | public function create(array $fields)
{
$url = $this->client->url . "/rest/v1/activities/external.json";
$response = $this->post($url, ['input' => $fields]);
if (!$response->success) {
throw new MarketoApiException('Error creating custom activity: ' . $response->errors[0]->message);
}
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"fields",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"client",
"->",
"url",
".",
"\"/rest/v1/activities/external.json\"",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"post",
"(",
"$",
"url",
",",
... | Create a new custom activity
@param array $fields
@throws MarketoApiException
@see http://developers.marketo.com/rest-api/endpoint-reference/lead-database-endpoint-reference/#!/Activities/addCustomActivityUsingPOST | [
"Create",
"a",
"new",
"custom",
"activity"
] | a227574f6569ca2c95c2343dd963d7f9d3885afe | https://github.com/generationtux/marketo-rest-api-client/blob/a227574f6569ca2c95c2343dd963d7f9d3885afe/src/Api/CustomActivitiesApi.php#L18-L26 | train |
CeusMedia/Common | src/FS/File/YAML/Writer.php | FS_File_YAML_Writer.save | public static function save( $fileName, $data )
{
$yaml = FS_File_YAML_Spyc::YAMLDump( $data );
return FS_File_Writer::save( $fileName, $yaml );
} | php | public static function save( $fileName, $data )
{
$yaml = FS_File_YAML_Spyc::YAMLDump( $data );
return FS_File_Writer::save( $fileName, $yaml );
} | [
"public",
"static",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"data",
")",
"{",
"$",
"yaml",
"=",
"FS_File_YAML_Spyc",
"::",
"YAMLDump",
"(",
"$",
"data",
")",
";",
"return",
"FS_File_Writer",
"::",
"save",
"(",
"$",
"fileName",
",",
"$",
"ya... | Writes Data into YAML File statically.
@access public
@static
@param string $fileName File Name of YAML File.
@param array $data Array to write into YAML File
@return bool | [
"Writes",
"Data",
"into",
"YAML",
"File",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/YAML/Writer.php#L66-L70 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.