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/DB/TableReader.php | DB_TableReader.getOrderQuery | protected function getOrderQuery( $orders = array() )
{
if( is_array( $orders ) && count( $orders ) )
{
$order = array();
foreach( $orders as $key => $value )
$order[] = $key.' '.$value;
$orders = ' ORDER BY '.implode( ', ', $order );
}
else
$orders = '';
return $orders;
} | php | protected function getOrderQuery( $orders = array() )
{
if( is_array( $orders ) && count( $orders ) )
{
$order = array();
foreach( $orders as $key => $value )
$order[] = $key.' '.$value;
$orders = ' ORDER BY '.implode( ', ', $order );
}
else
$orders = '';
return $orders;
} | [
"protected",
"function",
"getOrderQuery",
"(",
"$",
"orders",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"orders",
")",
"&&",
"count",
"(",
"$",
"orders",
")",
")",
"{",
"$",
"order",
"=",
"array",
"(",
")",
";",
"foreach",
... | Builds Query Order.
@access protected
@param array $orders Array of Orders, like array('field1'=>'ASC','field'=>'DESC')
@return string | [
"Builds",
"Query",
"Order",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L339-L351 | train |
CeusMedia/Common | src/DB/TableReader.php | DB_TableReader.isFocused | public function isFocused()
{
if( $this->focus !== FALSE && $this->focusKey )
return 'primary';
if( count( $this->foreignFocuses ) )
return 'foreign';
return FALSE;
} | php | public function isFocused()
{
if( $this->focus !== FALSE && $this->focusKey )
return 'primary';
if( count( $this->foreignFocuses ) )
return 'foreign';
return FALSE;
} | [
"public",
"function",
"isFocused",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"focus",
"!==",
"FALSE",
"&&",
"$",
"this",
"->",
"focusKey",
")",
"return",
"'primary'",
";",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"foreignFocuses",
")",
")",
"re... | Indicates wheter the focus on a key is set.
@access public
@return bool | [
"Indicates",
"wheter",
"the",
"focus",
"on",
"a",
"key",
"is",
"set",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L378-L385 | train |
CeusMedia/Common | src/DB/TableReader.php | DB_TableReader.setForeignKeys | public function setForeignKeys( $keys )
{
$found = TRUE;
$this->foreignKeys = array();
foreach( $keys as $key )
{
if( !in_array( $key, $this->foreignKeys ) )
$this->foreignKeys[] = $key;
else $found = FALSE;
}
return $found;
} | php | public function setForeignKeys( $keys )
{
$found = TRUE;
$this->foreignKeys = array();
foreach( $keys as $key )
{
if( !in_array( $key, $this->foreignKeys ) )
$this->foreignKeys[] = $key;
else $found = FALSE;
}
return $found;
} | [
"public",
"function",
"setForeignKeys",
"(",
"$",
"keys",
")",
"{",
"$",
"found",
"=",
"TRUE",
";",
"$",
"this",
"->",
"foreignKeys",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"in_array",
... | Setting all foreign keys of this Table.
@access public
@param array $keys all foreign keys of the Table
@return bool | [
"Setting",
"all",
"foreign",
"keys",
"of",
"this",
"Table",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/TableReader.php#L418-L429 | train |
CeusMedia/Common | src/Net/HTTP/CrossDomainProxy.php | Net_HTTP_CrossDomainProxy.forward | public function forward( $throwException = FALSE )
{
$query = getEnv( 'QUERY_STRING' ); // get GET Query String
$url = $this->url."?".$query; // build Service Request URL
return self::requestUrl( $url, $this->username, $this->password, $throwException );
} | php | public function forward( $throwException = FALSE )
{
$query = getEnv( 'QUERY_STRING' ); // get GET Query String
$url = $this->url."?".$query; // build Service Request URL
return self::requestUrl( $url, $this->username, $this->password, $throwException );
} | [
"public",
"function",
"forward",
"(",
"$",
"throwException",
"=",
"FALSE",
")",
"{",
"$",
"query",
"=",
"getEnv",
"(",
"'QUERY_STRING'",
")",
";",
"// get GET Query String",
"$",
"url",
"=",
"$",
"this",
"->",
"url",
".",
"\"?\"",
".",
"$",
"query",
";"... | Forwards GET or POST Request and returns Response Data.
@access public
@param bool $throwException Check Service Response for Exception and throw a found Exception further
@return string | [
"Forwards",
"GET",
"or",
"POST",
"Request",
"and",
"returns",
"Response",
"Data",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/CrossDomainProxy.php#L73-L78 | train |
Assasz/yggdrasil | src/Yggdrasil/Utils/Templating/RoutingExtension.php | RoutingExtension.getAsset | public function getAsset(string $path): string
{
return $this->router->getConfiguration()->getBaseUrl() . ltrim($path, '/');
} | php | public function getAsset(string $path): string
{
return $this->router->getConfiguration()->getBaseUrl() . ltrim($path, '/');
} | [
"public",
"function",
"getAsset",
"(",
"string",
"$",
"path",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"router",
"->",
"getConfiguration",
"(",
")",
"->",
"getBaseUrl",
"(",
")",
".",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
";",
"}"
... | Returns absolute path for requested asset like CSS file
@param string $path Path of asset relative to web directory
@return string | [
"Returns",
"absolute",
"path",
"for",
"requested",
"asset",
"like",
"CSS",
"file"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Templating/RoutingExtension.php#L74-L77 | train |
CeusMedia/Common | src/CLI/Output.php | CLI_Output.append | public function append( $string = "", $sleep = 0 ){
$this->sameLine( trim( $this->lastLine ) . $string, $sleep );
} | php | public function append( $string = "", $sleep = 0 ){
$this->sameLine( trim( $this->lastLine ) . $string, $sleep );
} | [
"public",
"function",
"append",
"(",
"$",
"string",
"=",
"\"\"",
",",
"$",
"sleep",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"sameLine",
"(",
"trim",
"(",
"$",
"this",
"->",
"lastLine",
")",
".",
"$",
"string",
",",
"$",
"sleep",
")",
";",
"}"
] | Adds text to current line.
@access public
@param string $string Text to display
@param integer $sleep Seconds to sleep afterwards
@return void | [
"Adds",
"text",
"to",
"current",
"line",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Output.php#L52-L54 | train |
CeusMedia/Common | src/CLI/Output.php | CLI_Output.newLine | public function newLine( $string = "", $sleep = 0 ){
$string = Alg_Text_Trimmer::trimCentric( $string, 78 ); // trim string to <80 columns
$this->lastLine = $string;
print( "\n" . $string );
if( $sleep )
sleep( $sleep );
} | php | public function newLine( $string = "", $sleep = 0 ){
$string = Alg_Text_Trimmer::trimCentric( $string, 78 ); // trim string to <80 columns
$this->lastLine = $string;
print( "\n" . $string );
if( $sleep )
sleep( $sleep );
} | [
"public",
"function",
"newLine",
"(",
"$",
"string",
"=",
"\"\"",
",",
"$",
"sleep",
"=",
"0",
")",
"{",
"$",
"string",
"=",
"Alg_Text_Trimmer",
"::",
"trimCentric",
"(",
"$",
"string",
",",
"78",
")",
";",
"// trim string to <80 columns",
"$",
"this",
... | Display text in new line.
@access public
@param string $string Text to display
@param integer $sleep Seconds to sleep afterwards
@return void | [
"Display",
"text",
"in",
"new",
"line",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Output.php#L63-L69 | train |
CeusMedia/Common | src/CLI/Output.php | CLI_Output.sameLine | public function sameLine( $string = "", $sleep = 0 ){
$string = Alg_Text_Trimmer::trimCentric( $string, 78 ); // trim string to <80 columns
$spaces = max( 0, strlen( $this->lastLine ) - strlen( $string ) );
$this->lastLine = $string;
$fill = str_repeat( " ", $spaces );
print( "\r" . $string . $fill );
if( $sleep )
sleep( $sleep );
} | php | public function sameLine( $string = "", $sleep = 0 ){
$string = Alg_Text_Trimmer::trimCentric( $string, 78 ); // trim string to <80 columns
$spaces = max( 0, strlen( $this->lastLine ) - strlen( $string ) );
$this->lastLine = $string;
$fill = str_repeat( " ", $spaces );
print( "\r" . $string . $fill );
if( $sleep )
sleep( $sleep );
} | [
"public",
"function",
"sameLine",
"(",
"$",
"string",
"=",
"\"\"",
",",
"$",
"sleep",
"=",
"0",
")",
"{",
"$",
"string",
"=",
"Alg_Text_Trimmer",
"::",
"trimCentric",
"(",
"$",
"string",
",",
"78",
")",
";",
"// trim string to <80 columns",
"$",
"spaces",... | Display text in current line.
@access public
@param string $string Text to display
@param integer $sleep Seconds to sleep afterwards
@return void | [
"Display",
"text",
"in",
"current",
"line",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Output.php#L78-L86 | train |
CeusMedia/Common | src/DB/MySQL/Connection.php | DB_MySQL_Connection.connectDatabase | public function connectDatabase( $type, $host, $user, $pass, $database = NULL )
{
switch( $type )
{
case 'connect':
$resource = mysql_connect( $host, $user, $pass );
break;
case 'pconnect':
$resource = mysql_pconnect( $host, $user, $pass );
break;
default:
throw new InvalidArgumentException( 'Database Connection Type "'.$type.'" is invalid' );
}
if( !$resource )
throw new Exception( 'Database Connection failed for User "'.$user.'@'.$host.'"' );
$this->dbc = $resource;
if( $database )
return $this->selectDB( $database );
return TRUE;
} | php | public function connectDatabase( $type, $host, $user, $pass, $database = NULL )
{
switch( $type )
{
case 'connect':
$resource = mysql_connect( $host, $user, $pass );
break;
case 'pconnect':
$resource = mysql_pconnect( $host, $user, $pass );
break;
default:
throw new InvalidArgumentException( 'Database Connection Type "'.$type.'" is invalid' );
}
if( !$resource )
throw new Exception( 'Database Connection failed for User "'.$user.'@'.$host.'"' );
$this->dbc = $resource;
if( $database )
return $this->selectDB( $database );
return TRUE;
} | [
"public",
"function",
"connectDatabase",
"(",
"$",
"type",
",",
"$",
"host",
",",
"$",
"user",
",",
"$",
"pass",
",",
"$",
"database",
"=",
"NULL",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'connect'",
":",
"$",
"resource",
"=",
"mys... | Sets up a Database Connection.
@access public
@param string $type Connection Type (connect|pconnect)
@param string $host Database Host Name
@param string $user Database User Name
@param string $pass Database User Password
@param string $database Database to select
@return bool Flag: Database Connection established | [
"Sets",
"up",
"a",
"Database",
"Connection",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/MySQL/Connection.php#L130-L149 | train |
theodorejb/peachy-sql | lib/PeachySql.php | PeachySql.insertRow | public function insertRow(string $table, array $colVals): InsertResult
{
$result = $this->insertBatch($table, [$colVals]);
$ids = $result->getIds();
$id = empty($ids) ? 0 : $ids[0];
return new InsertResult($id, $result->getAffected());
} | php | public function insertRow(string $table, array $colVals): InsertResult
{
$result = $this->insertBatch($table, [$colVals]);
$ids = $result->getIds();
$id = empty($ids) ? 0 : $ids[0];
return new InsertResult($id, $result->getAffected());
} | [
"public",
"function",
"insertRow",
"(",
"string",
"$",
"table",
",",
"array",
"$",
"colVals",
")",
":",
"InsertResult",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"insertBatch",
"(",
"$",
"table",
",",
"[",
"$",
"colVals",
"]",
")",
";",
"$",
"ids",... | Inserts one row | [
"Inserts",
"one",
"row"
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/PeachySql.php#L66-L72 | train |
theodorejb/peachy-sql | lib/PeachySql.php | PeachySql.insertRows | public function insertRows(string $table, array $colVals, int $identityIncrement = 1): BulkInsertResult
{
// check whether the query needs to be split into multiple batches
$batches = Insert::batchRows($colVals, $this->options->getMaxBoundParams(), $this->options->getMaxInsertRows());
$ids = [];
$affected = 0;
foreach ($batches as $batch) {
$result = $this->insertBatch($table, $batch, $identityIncrement);
$ids = array_merge($ids, $result->getIds());
$affected += $result->getAffected();
}
return new BulkInsertResult($ids, $affected, count($batches));
} | php | public function insertRows(string $table, array $colVals, int $identityIncrement = 1): BulkInsertResult
{
// check whether the query needs to be split into multiple batches
$batches = Insert::batchRows($colVals, $this->options->getMaxBoundParams(), $this->options->getMaxInsertRows());
$ids = [];
$affected = 0;
foreach ($batches as $batch) {
$result = $this->insertBatch($table, $batch, $identityIncrement);
$ids = array_merge($ids, $result->getIds());
$affected += $result->getAffected();
}
return new BulkInsertResult($ids, $affected, count($batches));
} | [
"public",
"function",
"insertRows",
"(",
"string",
"$",
"table",
",",
"array",
"$",
"colVals",
",",
"int",
"$",
"identityIncrement",
"=",
"1",
")",
":",
"BulkInsertResult",
"{",
"// check whether the query needs to be split into multiple batches",
"$",
"batches",
"=",... | Insert multiple rows | [
"Insert",
"multiple",
"rows"
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/PeachySql.php#L77-L91 | train |
theodorejb/peachy-sql | lib/PeachySql.php | PeachySql.updateRows | public function updateRows(string $table, array $set, array $where): int
{
$update = new Update($this->options);
$sqlParams = $update->buildQuery($table, $set, $where);
return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
} | php | public function updateRows(string $table, array $set, array $where): int
{
$update = new Update($this->options);
$sqlParams = $update->buildQuery($table, $set, $where);
return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
} | [
"public",
"function",
"updateRows",
"(",
"string",
"$",
"table",
",",
"array",
"$",
"set",
",",
"array",
"$",
"where",
")",
":",
"int",
"{",
"$",
"update",
"=",
"new",
"Update",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"sqlParams",
"=",
"$... | Updates the specified columns and values in rows matching the where clause
Returns the number of affected rows | [
"Updates",
"the",
"specified",
"columns",
"and",
"values",
"in",
"rows",
"matching",
"the",
"where",
"clause",
"Returns",
"the",
"number",
"of",
"affected",
"rows"
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/PeachySql.php#L97-L102 | train |
theodorejb/peachy-sql | lib/PeachySql.php | PeachySql.deleteFrom | public function deleteFrom(string $table, array $where): int
{
$delete = new Delete($this->options);
$sqlParams = $delete->buildQuery($table, $where);
return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
} | php | public function deleteFrom(string $table, array $where): int
{
$delete = new Delete($this->options);
$sqlParams = $delete->buildQuery($table, $where);
return $this->query($sqlParams->getSql(), $sqlParams->getParams())->getAffected();
} | [
"public",
"function",
"deleteFrom",
"(",
"string",
"$",
"table",
",",
"array",
"$",
"where",
")",
":",
"int",
"{",
"$",
"delete",
"=",
"new",
"Delete",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"sqlParams",
"=",
"$",
"delete",
"->",
"buildQue... | Deletes rows from the table matching the where clause
Returns the number of affected rows | [
"Deletes",
"rows",
"from",
"the",
"table",
"matching",
"the",
"where",
"clause",
"Returns",
"the",
"number",
"of",
"affected",
"rows"
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/PeachySql.php#L108-L113 | train |
CeusMedia/Common | src/Alg/Math/Algebra/Vector/CrossProduct.php | Alg_Math_Algebra_Vector_CrossProduct.produce | public function produce( $vector1, $vector2 )
{
if( $vector1->getDimension() != $vector2->getDimension() )
throw new Exception( 'Dimensions of Vectors are not compatible.' );
if( $vector1->getDimension() == 3 )
{
$x = $vector1->getValueFromIndex( 1 ) * $vector2->getValueFromIndex( 2 ) - $vector1->getValueFromIndex( 2 ) * $vector2->getValueFromIndex( 1 );
$y = $vector1->getValueFromIndex( 2 ) * $vector2->getValueFromIndex( 0 ) - $vector1->getValueFromIndex( 0 ) * $vector2->getValueFromIndex( 2 );
$z = $vector1->getValueFromIndex( 0 ) * $vector2->getValueFromIndex( 1 ) - $vector1->getValueFromIndex( 1 ) * $vector2->getValueFromIndex( 0 );
$c = new Alg_Math_Algebra_Vector( $x, $y, $z );
}
return $c;
} | php | public function produce( $vector1, $vector2 )
{
if( $vector1->getDimension() != $vector2->getDimension() )
throw new Exception( 'Dimensions of Vectors are not compatible.' );
if( $vector1->getDimension() == 3 )
{
$x = $vector1->getValueFromIndex( 1 ) * $vector2->getValueFromIndex( 2 ) - $vector1->getValueFromIndex( 2 ) * $vector2->getValueFromIndex( 1 );
$y = $vector1->getValueFromIndex( 2 ) * $vector2->getValueFromIndex( 0 ) - $vector1->getValueFromIndex( 0 ) * $vector2->getValueFromIndex( 2 );
$z = $vector1->getValueFromIndex( 0 ) * $vector2->getValueFromIndex( 1 ) - $vector1->getValueFromIndex( 1 ) * $vector2->getValueFromIndex( 0 );
$c = new Alg_Math_Algebra_Vector( $x, $y, $z );
}
return $c;
} | [
"public",
"function",
"produce",
"(",
"$",
"vector1",
",",
"$",
"vector2",
")",
"{",
"if",
"(",
"$",
"vector1",
"->",
"getDimension",
"(",
")",
"!=",
"$",
"vector2",
"->",
"getDimension",
"(",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Dimensions of V... | Returns Cross Product of two Vectors
@access public
@param Alg_Math_Algebra_Vector $vector1 Vector 1
@param Alg_Math_Algebra_Vector $vector2 Vector 2
@return Alg_Math_Algebra_Vector | [
"Returns",
"Cross",
"Product",
"of",
"two",
"Vectors"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/Vector/CrossProduct.php#L59-L71 | train |
janbuecker/sculpin-meta-navigation-bundle | MenuGenerator.php | MenuGenerator.setMenu | protected function setMenu(SourceSet $sourceSet)
{
// Second loop to set the menu which was initialized during the first loop
foreach ($sourceSet->updatedSources() as $source) {
/** @var \Sculpin\Core\Source\FileSource $source */
if ($source->isGenerated() || !$source->canBeFormatted()) {
// Skip generated sources.
// Only takes pages that can be formatted (AKA *.md)
continue;
}
$source->data()->set('menu', $this->menu);
}
} | php | protected function setMenu(SourceSet $sourceSet)
{
// Second loop to set the menu which was initialized during the first loop
foreach ($sourceSet->updatedSources() as $source) {
/** @var \Sculpin\Core\Source\FileSource $source */
if ($source->isGenerated() || !$source->canBeFormatted()) {
// Skip generated sources.
// Only takes pages that can be formatted (AKA *.md)
continue;
}
$source->data()->set('menu', $this->menu);
}
} | [
"protected",
"function",
"setMenu",
"(",
"SourceSet",
"$",
"sourceSet",
")",
"{",
"// Second loop to set the menu which was initialized during the first loop",
"foreach",
"(",
"$",
"sourceSet",
"->",
"updatedSources",
"(",
")",
"as",
"$",
"source",
")",
"{",
"/** @var \... | Now that the menu structure has been created, inject it back to the page.
@param SourceSet $sourceSet
@return void | [
"Now",
"that",
"the",
"menu",
"structure",
"has",
"been",
"created",
"inject",
"it",
"back",
"to",
"the",
"page",
"."
] | a3b1e2e307292f6b25fdda9f678421beb75bbc57 | https://github.com/janbuecker/sculpin-meta-navigation-bundle/blob/a3b1e2e307292f6b25fdda9f678421beb75bbc57/MenuGenerator.php#L106-L120 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.changeGroup | public function changeGroup( $groupName, $recursive = FALSE )
{
if( !$groupName )
throw new InvalidArgumentException( 'Group is missing' );
$number = (int) chgrp( $this->folderName, $groupName );
if( !$recursive )
return $number;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $this->folderName ),
RecursiveIteratorIterator::SELF_FIRST
);
foreach( $iterator as $item )
$number += (int) chgrp( $item, $groupName );
return $number;
} | php | public function changeGroup( $groupName, $recursive = FALSE )
{
if( !$groupName )
throw new InvalidArgumentException( 'Group is missing' );
$number = (int) chgrp( $this->folderName, $groupName );
if( !$recursive )
return $number;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $this->folderName ),
RecursiveIteratorIterator::SELF_FIRST
);
foreach( $iterator as $item )
$number += (int) chgrp( $item, $groupName );
return $number;
} | [
"public",
"function",
"changeGroup",
"(",
"$",
"groupName",
",",
"$",
"recursive",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"groupName",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Group is missing'",
")",
";",
"$",
"number",
"=",
"(",
"int... | Sets group of current folder.
@access public
@param string $groupName Group to set
@param bool $recursive Flag: change nested files and folders,too
@return bool | [
"Sets",
"group",
"of",
"current",
"folder",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L74-L89 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.changeMode | public function changeMode( $mode, $recursive = FALSE )
{
if( !is_int( $mode ) )
throw new InvalidArgumentException( 'Mode must be of integer' );
$number = (int) chmod( $this->folderName, $mode );
if( !$recursive )
return $number;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $this->folderName ),
RecursiveIteratorIterator::SELF_FIRST
);
foreach( $iterator as $item )
$number += (int) chmod( $item, $mode );
return $number;
} | php | public function changeMode( $mode, $recursive = FALSE )
{
if( !is_int( $mode ) )
throw new InvalidArgumentException( 'Mode must be of integer' );
$number = (int) chmod( $this->folderName, $mode );
if( !$recursive )
return $number;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $this->folderName ),
RecursiveIteratorIterator::SELF_FIRST
);
foreach( $iterator as $item )
$number += (int) chmod( $item, $mode );
return $number;
} | [
"public",
"function",
"changeMode",
"(",
"$",
"mode",
",",
"$",
"recursive",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"mode",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Mode must be of integer'",
")",
";",
"$",
"number"... | Sets permissions on current folder and its containing files and folders.
@access public
@param int $mode Permission mode, like 0750, 01770, 02755
@param bool $recursive Flag: change nested files and folders,too
@return int Number of affected files and folders | [
"Sets",
"permissions",
"on",
"current",
"folder",
"and",
"its",
"containing",
"files",
"and",
"folders",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L98-L114 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.changeOwner | public function changeOwner( $userName, $recursive = FALSE )
{
if( !$userName )
throw new InvalidArgumentException( 'User missing' );
$number = (int) chown( $this->folderName, $userName );
if( !$recursive )
return $number;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $this->folderName ),
RecursiveIteratorIterator::SELF_FIRST
);
foreach( $iterator as $item )
$number += (int) chown( $item, $userName );
return $number;
} | php | public function changeOwner( $userName, $recursive = FALSE )
{
if( !$userName )
throw new InvalidArgumentException( 'User missing' );
$number = (int) chown( $this->folderName, $userName );
if( !$recursive )
return $number;
$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator( $this->folderName ),
RecursiveIteratorIterator::SELF_FIRST
);
foreach( $iterator as $item )
$number += (int) chown( $item, $userName );
return $number;
} | [
"public",
"function",
"changeOwner",
"(",
"$",
"userName",
",",
"$",
"recursive",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"userName",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'User missing'",
")",
";",
"$",
"number",
"=",
"(",
"int",
"... | Sets owner of current folder.
@access public
@param string $userName User to set
@param bool $recursive Flag: change nested files and folders,too
@return bool | [
"Sets",
"owner",
"of",
"current",
"folder",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L123-L138 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.copyFolder | public static function copyFolder( $sourceFolder, $targetFolder, $force = FALSE, $skipDotEntries = TRUE )
{
if( !self::isFolder( $sourceFolder ) ) // Source Folder not existing
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be copied because it is not existing' );
$count = 0; // initialize Object Counter
$sourceFolder = self::correctPath( $sourceFolder ); // add Slash to Source Folder
$targetFolder = self::correctPath( $targetFolder ); // add Slash to Target Folder
if( self::isFolder( $targetFolder ) && !$force ) // Target Folder is existing, not forced
throw new RuntimeException( 'Folder "'.$targetFolder.'" is already existing. See Option "force"' );
else if( !self::isFolder( $targetFolder ) ) // Target Folder is not existing
$count += (int) self::createFolder( $targetFolder ); // create TargetFolder and count
$index = new FS_Folder_Iterator( $sourceFolder, TRUE, TRUE, $skipDotEntries ); // Index of Source Folder
foreach( $index as $entry )
{
if( $entry->isDot() ) // Dot Folders
continue; // skip them
if( $entry->isDir() ) // nested Folder
{
$source = $entry->getPathname(); // Source Folder Name
$target = $targetFolder.$entry->getFilename()."/"; // Target Folder Name
$count += self::copyFolder( $source, $target, $force, $skipDotEntries ); // copy Folder recursive and count
}
else if( $entry->isFile() ) // nested File
{
$targetFile = $targetFolder.$entry->getFilename();
if( file_exists( $targetFile ) && !$force )
throw new RuntimeException( 'File "'.$targetFile.'" is already existing. See Option "force"' );
$count += (int) copy( $entry->getPathname(), $targetFile ); // copy File and count
}
}
return $count; // return Object Count
} | php | public static function copyFolder( $sourceFolder, $targetFolder, $force = FALSE, $skipDotEntries = TRUE )
{
if( !self::isFolder( $sourceFolder ) ) // Source Folder not existing
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be copied because it is not existing' );
$count = 0; // initialize Object Counter
$sourceFolder = self::correctPath( $sourceFolder ); // add Slash to Source Folder
$targetFolder = self::correctPath( $targetFolder ); // add Slash to Target Folder
if( self::isFolder( $targetFolder ) && !$force ) // Target Folder is existing, not forced
throw new RuntimeException( 'Folder "'.$targetFolder.'" is already existing. See Option "force"' );
else if( !self::isFolder( $targetFolder ) ) // Target Folder is not existing
$count += (int) self::createFolder( $targetFolder ); // create TargetFolder and count
$index = new FS_Folder_Iterator( $sourceFolder, TRUE, TRUE, $skipDotEntries ); // Index of Source Folder
foreach( $index as $entry )
{
if( $entry->isDot() ) // Dot Folders
continue; // skip them
if( $entry->isDir() ) // nested Folder
{
$source = $entry->getPathname(); // Source Folder Name
$target = $targetFolder.$entry->getFilename()."/"; // Target Folder Name
$count += self::copyFolder( $source, $target, $force, $skipDotEntries ); // copy Folder recursive and count
}
else if( $entry->isFile() ) // nested File
{
$targetFile = $targetFolder.$entry->getFilename();
if( file_exists( $targetFile ) && !$force )
throw new RuntimeException( 'File "'.$targetFile.'" is already existing. See Option "force"' );
$count += (int) copy( $entry->getPathname(), $targetFile ); // copy File and count
}
}
return $count; // return Object Count
} | [
"public",
"static",
"function",
"copyFolder",
"(",
"$",
"sourceFolder",
",",
"$",
"targetFolder",
",",
"$",
"force",
"=",
"FALSE",
",",
"$",
"skipDotEntries",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isFolder",
"(",
"$",
"sourceFolder",
")",... | Copies a Folder recursive to another Path and returns Number of copied Files and Folders.
@access public
@static
@param string $sourceFolder Folder Name of Folder to copy
@param string $targetFolder Folder Name to Target Folder
@param bool $force Flag: force Copy if file is existing
@param bool $skipDotEntries Flag: skip Files and Folders starting with Dot
@return int | [
"Copies",
"a",
"Folder",
"recursive",
"to",
"another",
"Path",
"and",
"returns",
"Number",
"of",
"copied",
"Files",
"and",
"Folders",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L150-L183 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.createFolder | public static function createFolder( $folderName, $mode = 0770, $userName = NULL, $groupName = NULL )
{
if( self::isFolder( $folderName ) )
return FALSE;
if( false === @mkdir( $folderName, $mode, TRUE ) ) // create Folder recursive
throw new RuntimeException( 'Folder "'.$folderName.'" could not be created' );
chmod( $folderName, $mode );
if( $userName ) // User is set
chown( $folderName, $userName ); // change Owner to User
if( $groupName ) // Group is set
chgrp( $folderName, $groupName );
return TRUE;
} | php | public static function createFolder( $folderName, $mode = 0770, $userName = NULL, $groupName = NULL )
{
if( self::isFolder( $folderName ) )
return FALSE;
if( false === @mkdir( $folderName, $mode, TRUE ) ) // create Folder recursive
throw new RuntimeException( 'Folder "'.$folderName.'" could not be created' );
chmod( $folderName, $mode );
if( $userName ) // User is set
chown( $folderName, $userName ); // change Owner to User
if( $groupName ) // Group is set
chgrp( $folderName, $groupName );
return TRUE;
} | [
"public",
"static",
"function",
"createFolder",
"(",
"$",
"folderName",
",",
"$",
"mode",
"=",
"0770",
",",
"$",
"userName",
"=",
"NULL",
",",
"$",
"groupName",
"=",
"NULL",
")",
"{",
"if",
"(",
"self",
"::",
"isFolder",
"(",
"$",
"folderName",
")",
... | Creates a Folder by creating all Folders in Path recursive.
@access public
@static
@param string $folderName Folder to create
@param int $mode Permission Mode, default: 0770
@param string $userName User Name
@param string $groupName Group Name
@return bool | [
"Creates",
"a",
"Folder",
"by",
"creating",
"all",
"Folders",
"in",
"Path",
"recursive",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L195-L207 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.copy | public function copy( $targetFolder, $force = FALSE, $skipDotEntries = TRUE, $useCopy = FALSE )
{
$result = self::copyFolder( $this->folderName, $targetFolder, $force, $skipDotEntries );
if( $result && $useCopy )
$this->folderName = $targetFolder;
return $result;
} | php | public function copy( $targetFolder, $force = FALSE, $skipDotEntries = TRUE, $useCopy = FALSE )
{
$result = self::copyFolder( $this->folderName, $targetFolder, $force, $skipDotEntries );
if( $result && $useCopy )
$this->folderName = $targetFolder;
return $result;
} | [
"public",
"function",
"copy",
"(",
"$",
"targetFolder",
",",
"$",
"force",
"=",
"FALSE",
",",
"$",
"skipDotEntries",
"=",
"TRUE",
",",
"$",
"useCopy",
"=",
"FALSE",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"copyFolder",
"(",
"$",
"this",
"->",
"fo... | Copies current Folder to another Folder and returns Number of copied Files and Folders.
@access public
@param string $targetFolder Folder Name of Target Folder
@param bool $useCopy Flag: switch current Folder to Copy afterwards
@param bool $force Flag: force Copy if file is existing
@param bool $skipDotEntries Flag: skip Files and Folders starting with Dot
@return int | [
"Copies",
"current",
"Folder",
"to",
"another",
"Folder",
"and",
"returns",
"Number",
"of",
"copied",
"Files",
"and",
"Folders",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L218-L224 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.moveFolder | public static function moveFolder( $sourceFolder, $targetPath, $force = FALSE )
{
$sourceName = basename( $sourceFolder ); // Folder Name of Source Folder
$sourcePath = dirname( $sourceFolder ); // Path to Source Folder
$sourceFolder = self::correctPath( $sourceFolder ); // add Slash to Source Path
$targetPath = self::correctPath( $targetPath ); // add Slash to Target Path
if( !self::isFolder( $sourcePath ) ) // Path of Source Folder not existing
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be moved since it is not existing' );
if( self::isFolder( $targetPath.$sourceName ) && !$force ) // Path of Target Folder is already existing
throw new RuntimeException( 'Folder "'.$targetPath.$sourceName.'" is already existing' );
if( !self::isFolder( $targetPath ) ) // Path to Target Folder not existing
self::createFolder( $targetPath ); //
if( $sourceFolder == $targetPath ) // Source and Target Path are equal
return FALSE; // do nothing and return
if( FALSE === @rename( $sourceFolder, $targetPath.$sourceName ) ) // move Source Folder to Target Path
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be moved to "'.$targetPath.'"' );
return TRUE;
} | php | public static function moveFolder( $sourceFolder, $targetPath, $force = FALSE )
{
$sourceName = basename( $sourceFolder ); // Folder Name of Source Folder
$sourcePath = dirname( $sourceFolder ); // Path to Source Folder
$sourceFolder = self::correctPath( $sourceFolder ); // add Slash to Source Path
$targetPath = self::correctPath( $targetPath ); // add Slash to Target Path
if( !self::isFolder( $sourcePath ) ) // Path of Source Folder not existing
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be moved since it is not existing' );
if( self::isFolder( $targetPath.$sourceName ) && !$force ) // Path of Target Folder is already existing
throw new RuntimeException( 'Folder "'.$targetPath.$sourceName.'" is already existing' );
if( !self::isFolder( $targetPath ) ) // Path to Target Folder not existing
self::createFolder( $targetPath ); //
if( $sourceFolder == $targetPath ) // Source and Target Path are equal
return FALSE; // do nothing and return
if( FALSE === @rename( $sourceFolder, $targetPath.$sourceName ) ) // move Source Folder to Target Path
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be moved to "'.$targetPath.'"' );
return TRUE;
} | [
"public",
"static",
"function",
"moveFolder",
"(",
"$",
"sourceFolder",
",",
"$",
"targetPath",
",",
"$",
"force",
"=",
"FALSE",
")",
"{",
"$",
"sourceName",
"=",
"basename",
"(",
"$",
"sourceFolder",
")",
";",
"// Folder Name of Source Folder",
"$",
"sourceP... | Moves a Folder to another Path.
@access public
@static
@param string $sourceFolder Folder Name of Source Folder, eg. /path/to/source/folder
@param string $targetPath Folder Path of Target Folder, eg. /path/to/target
@param string $force Flag: continue if Target Folder is already existing, otherwise break
@return bool | [
"Moves",
"a",
"Folder",
"to",
"another",
"Path",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L235-L252 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.move | public function move( $folderPath, $force = FALSE )
{
if( !$this->moveFolder( $this->folderName, $folderPath, $force ) )
return FALSE;
$this->folderName = $folderPath;
return TRUE;
} | php | public function move( $folderPath, $force = FALSE )
{
if( !$this->moveFolder( $this->folderName, $folderPath, $force ) )
return FALSE;
$this->folderName = $folderPath;
return TRUE;
} | [
"public",
"function",
"move",
"(",
"$",
"folderPath",
",",
"$",
"force",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"moveFolder",
"(",
"$",
"this",
"->",
"folderName",
",",
"$",
"folderPath",
",",
"$",
"force",
")",
")",
"return",
"... | Moves current Folder to another Path.
@access public
@param string $folderPath Folder Path of Target Folder
@param string $force Flag: continue if Target Folder is already existing, otherwise break
@return bool | [
"Moves",
"current",
"Folder",
"to",
"another",
"Path",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L261-L267 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.rename | public function rename( $folderName )
{
if( !$this->renameFolder( $this->folderName, $folderName ) )
return FALSE;
$this->folderName = dirname( $this->folderName )."/".basename( $folderName );
return TRUE;
} | php | public function rename( $folderName )
{
if( !$this->renameFolder( $this->folderName, $folderName ) )
return FALSE;
$this->folderName = dirname( $this->folderName )."/".basename( $folderName );
return TRUE;
} | [
"public",
"function",
"rename",
"(",
"$",
"folderName",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"renameFolder",
"(",
"$",
"this",
"->",
"folderName",
",",
"$",
"folderName",
")",
")",
"return",
"FALSE",
";",
"$",
"this",
"->",
"folderName",
"=",
... | Renames current Folder.
@access public
@param string $folderName Folder Name to rename to
@return bool | [
"Renames",
"current",
"Folder",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L275-L281 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.renameFolder | public static function renameFolder( $sourceFolder, $targetName )
{
$targetName = basename( $targetName );
if( !self::isFolder( $sourceFolder ) ) // Source Folder not existing
throw new RuntimeException( 'Folder "'.$sourceFolder.'" is not existing' );
$sourcePath = self::correctPath( dirname( $sourceFolder ) ); // Path to Source Folder
if( basename( $sourceFolder ) == $targetName ) // Source Name and Target name is equal
return FALSE;
if( self::isFolder( $sourcePath.$targetName ) ) // Target Folder is already existing
throw new RuntimeException( 'Folder "'.$sourcePath.$targetName.'" is already existing' );
if( FALSE === @rename( $sourceFolder, $sourcePath.$targetName ) ) // rename Source Folder to Target Folder
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be renamed to "'.$sourcePath.$targetName.'"' );
return TRUE;
} | php | public static function renameFolder( $sourceFolder, $targetName )
{
$targetName = basename( $targetName );
if( !self::isFolder( $sourceFolder ) ) // Source Folder not existing
throw new RuntimeException( 'Folder "'.$sourceFolder.'" is not existing' );
$sourcePath = self::correctPath( dirname( $sourceFolder ) ); // Path to Source Folder
if( basename( $sourceFolder ) == $targetName ) // Source Name and Target name is equal
return FALSE;
if( self::isFolder( $sourcePath.$targetName ) ) // Target Folder is already existing
throw new RuntimeException( 'Folder "'.$sourcePath.$targetName.'" is already existing' );
if( FALSE === @rename( $sourceFolder, $sourcePath.$targetName ) ) // rename Source Folder to Target Folder
throw new RuntimeException( 'Folder "'.$sourceFolder.'" cannot be renamed to "'.$sourcePath.$targetName.'"' );
return TRUE;
} | [
"public",
"static",
"function",
"renameFolder",
"(",
"$",
"sourceFolder",
",",
"$",
"targetName",
")",
"{",
"$",
"targetName",
"=",
"basename",
"(",
"$",
"targetName",
")",
";",
"if",
"(",
"!",
"self",
"::",
"isFolder",
"(",
"$",
"sourceFolder",
")",
")"... | Renames a Folder to another Folder Name.
@access public
@static
@param string $sourceFolder Folder to rename
@param string $targetName New Name of Folder
@return bool | [
"Renames",
"a",
"Folder",
"to",
"another",
"Folder",
"Name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L291-L305 | train |
CeusMedia/Common | src/FS/Folder/Editor.php | FS_Folder_Editor.removeFolder | public static function removeFolder( $folderName, $force = FALSE, $strict = TRUE )
{
$folderName = self::correctPath( $folderName);
$count = 1; // current Folder is first Object
if( !file_exists( $folderName ) )
{
if( $strict )
throw new RuntimeException( 'Folder "'.$folderName.'" is not existing' );
else
return 0;
}
$index = new DirectoryIterator( $folderName );
foreach( $index as $entry )
{
if( !$entry->isDot() )
{
if( !$force ) // nested Files or Folders found
throw new RuntimeException( 'Folder '.$folderName.' is not empty. See Option "force"' );
if( $entry->isFile() || $entry->isLink() )
{
if( FALSE === @unlink( $entry->getPathname() ) ) // remove File and count
throw new RuntimeException( 'File "'.$folderName.$entry->getFilename().'" is not removable' ); // throw Exception for File
$count ++;
}
else if( $entry->isDir() )
{
$count += self::removeFolder( $entry->getPathname(), $force ); // call Method with nested Folder
}
}
}
rmdir( $folderName ); // remove Folder
return $count;
$dir = dir( $folderName ); // index Folder
while( $entry = $dir->read() ) // iterate Objects
{
if( preg_match( "@^(\.){1,2}$@", $entry ) ) // if is Dot Object
continue; // continue
$pathName = $folderName.$entry; // Name of nested Object
if( !$force ) // nested Files or Folders found
throw new RuntimeException( 'Folder '.$folderName.' is not empty. See Option "force"' );
if( is_file( $pathName ) ) // is nested File
{
if( FALSE === unlink( $pathName ) ) // remove File and count
throw new RuntimeException( 'File "'.$pathName.'" is not removable' ); // throw Exception for File
$count ++;
}
if( is_dir( $pathName ) ) // is nested Folder
$count += self::removeFolder( $pathName, $force ); // call Method with nested Folder
}
$dir->close(); // close Directory Handler
rmDir( $folderName ); // remove Folder
return $count; // return counted Objects
} | php | public static function removeFolder( $folderName, $force = FALSE, $strict = TRUE )
{
$folderName = self::correctPath( $folderName);
$count = 1; // current Folder is first Object
if( !file_exists( $folderName ) )
{
if( $strict )
throw new RuntimeException( 'Folder "'.$folderName.'" is not existing' );
else
return 0;
}
$index = new DirectoryIterator( $folderName );
foreach( $index as $entry )
{
if( !$entry->isDot() )
{
if( !$force ) // nested Files or Folders found
throw new RuntimeException( 'Folder '.$folderName.' is not empty. See Option "force"' );
if( $entry->isFile() || $entry->isLink() )
{
if( FALSE === @unlink( $entry->getPathname() ) ) // remove File and count
throw new RuntimeException( 'File "'.$folderName.$entry->getFilename().'" is not removable' ); // throw Exception for File
$count ++;
}
else if( $entry->isDir() )
{
$count += self::removeFolder( $entry->getPathname(), $force ); // call Method with nested Folder
}
}
}
rmdir( $folderName ); // remove Folder
return $count;
$dir = dir( $folderName ); // index Folder
while( $entry = $dir->read() ) // iterate Objects
{
if( preg_match( "@^(\.){1,2}$@", $entry ) ) // if is Dot Object
continue; // continue
$pathName = $folderName.$entry; // Name of nested Object
if( !$force ) // nested Files or Folders found
throw new RuntimeException( 'Folder '.$folderName.' is not empty. See Option "force"' );
if( is_file( $pathName ) ) // is nested File
{
if( FALSE === unlink( $pathName ) ) // remove File and count
throw new RuntimeException( 'File "'.$pathName.'" is not removable' ); // throw Exception for File
$count ++;
}
if( is_dir( $pathName ) ) // is nested Folder
$count += self::removeFolder( $pathName, $force ); // call Method with nested Folder
}
$dir->close(); // close Directory Handler
rmDir( $folderName ); // remove Folder
return $count; // return counted Objects
} | [
"public",
"static",
"function",
"removeFolder",
"(",
"$",
"folderName",
",",
"$",
"force",
"=",
"FALSE",
",",
"$",
"strict",
"=",
"TRUE",
")",
"{",
"$",
"folderName",
"=",
"self",
"::",
"correctPath",
"(",
"$",
"folderName",
")",
";",
"$",
"count",
"="... | Removes a Folder recursive and returns Number of removed Folders and Files.
Because there where Permission Issues with DirectoryIterator it uses the old 'dir' command.
@access public
@static
@param string $folderName Folder to be removed
@param bool $force Flag: force to remove nested Files and Folders
@return int | [
"Removes",
"a",
"Folder",
"recursive",
"and",
"returns",
"Number",
"of",
"removed",
"Folders",
"and",
"Files",
".",
"Because",
"there",
"where",
"Permission",
"Issues",
"with",
"DirectoryIterator",
"it",
"uses",
"the",
"old",
"dir",
"command",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/Editor.php#L327-L381 | train |
ncou/Chiron | src/Chiron/Http/Session/SessionManager.php | SessionManager.destroy | public function destroy(): bool
{
if (! $this->isStarted()) {
$this->start();
}
$name = $this->getName();
$params = $this->getCookieParams();
$this->clear();
$destroyed = session_destroy();
if ($destroyed) {
call_user_func($this->delete_cookie, $name, $params);
}
return $destroyed;
} | php | public function destroy(): bool
{
if (! $this->isStarted()) {
$this->start();
}
$name = $this->getName();
$params = $this->getCookieParams();
$this->clear();
$destroyed = session_destroy();
if ($destroyed) {
call_user_func($this->delete_cookie, $name, $params);
}
return $destroyed;
} | [
"public",
"function",
"destroy",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isStarted",
"(",
")",
")",
"{",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}",
"$",
"name",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"$... | Destroys the session entirely.
@return bool
@see http://php.net/manual/en/function.session-destroy.php | [
"Destroys",
"the",
"session",
"entirely",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Session/SessionManager.php#L245-L259 | train |
ncou/Chiron | src/Chiron/Http/Session/SessionManager.php | SessionManager.setCookieParams2 | public function setCookieParams2(int $lifetime, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = false): void
{
session_set_cookie_params($lifetime, $path, $domain, $secure, $httpOnly);
} | php | public function setCookieParams2(int $lifetime, string $path = null, string $domain = null, bool $secure = false, bool $httpOnly = false): void
{
session_set_cookie_params($lifetime, $path, $domain, $secure, $httpOnly);
} | [
"public",
"function",
"setCookieParams2",
"(",
"int",
"$",
"lifetime",
",",
"string",
"$",
"path",
"=",
"null",
",",
"string",
"$",
"domain",
"=",
"null",
",",
"bool",
"$",
"secure",
"=",
"false",
",",
"bool",
"$",
"httpOnly",
"=",
"false",
")",
":",
... | Set cookie parameters.
@see http://php.net/manual/en/function.session-set-cookie-params.php
@param int $lifetime The lifetime of the cookie in seconds.
@param string $path The path where information is stored.
@param string $domain The domain of the cookie.
@param bool $secure The cookie should only be sent over secure connections.
@param bool $httpOnly The cookie can only be accessed through the HTTP protocol. | [
"Set",
"cookie",
"parameters",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Session/SessionManager.php#L369-L372 | train |
ncou/Chiron | src/Chiron/Http/Session/SessionManager.php | SessionManager.regenerateId | public function regenerateId(bool $deleteOldSession = true): bool
{
if ($this->isStarted()) {
return session_regenerate_id($deleteOldSession);
}
// TODO : ajouter un else et lever une exception si on essaye de faire un regenerate ID alors que la session n'est pas démarrée !!!!
return false;
} | php | public function regenerateId(bool $deleteOldSession = true): bool
{
if ($this->isStarted()) {
return session_regenerate_id($deleteOldSession);
}
// TODO : ajouter un else et lever une exception si on essaye de faire un regenerate ID alors que la session n'est pas démarrée !!!!
return false;
} | [
"public",
"function",
"regenerateId",
"(",
"bool",
"$",
"deleteOldSession",
"=",
"true",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"isStarted",
"(",
")",
")",
"{",
"return",
"session_regenerate_id",
"(",
"$",
"deleteOldSession",
")",
";",
"}",
... | Regenerate id.
Regenerate the session ID, using session save handler's
native ID generation Can safely be called in the middle of a session.
@param bool $deleteOldSession
@return bool | [
"Regenerate",
"id",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Session/SessionManager.php#L428-L436 | train |
ncou/Chiron | src/Chiron/Http/Session/SessionManager.php | SessionManager.setName | public function setName(string $name): string
{
if ($this->isStarted()) {
throw new LogicException('Cannot change the name of an active session');
}
if (! preg_match('/^[a-zA-Z0-9]+$/', $name)) {
throw new InvalidArgumentException('Session name provided contains invalid characters; must be alphanumeric only and cannot be empty');
}
if (! preg_match('/.*[a-zA-Z]+.*/', $name)) {
throw new InvalidArgumentException('Session name cannot be a numeric');
}
return session_name($name);
} | php | public function setName(string $name): string
{
if ($this->isStarted()) {
throw new LogicException('Cannot change the name of an active session');
}
if (! preg_match('/^[a-zA-Z0-9]+$/', $name)) {
throw new InvalidArgumentException('Session name provided contains invalid characters; must be alphanumeric only and cannot be empty');
}
if (! preg_match('/.*[a-zA-Z]+.*/', $name)) {
throw new InvalidArgumentException('Session name cannot be a numeric');
}
return session_name($name);
} | [
"public",
"function",
"setName",
"(",
"string",
"$",
"name",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"isStarted",
"(",
")",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"'Cannot change the name of an active session'",
")",
";",
"}",
"if",
... | Sets the current session name.
@param string $name The session name to use.
@return string
@see session_name() | [
"Sets",
"the",
"current",
"session",
"name",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Session/SessionManager.php#L447-L462 | train |
ncou/Chiron | src/Chiron/Http/Session/SessionManager.php | SessionManager.destroy2 | public static function destroy2()
{
if (self::status() === \PHP_SESSION_ACTIVE) {
//session_unset();
self::flush();
session_destroy();
session_write_close();
// TODO : utiliser 42000 comme nombre au lieu de -1heure => https://github.com/odan/slim-session/blob/master/src/Slim/Session/Adapter/PhpSessionAdapter.php#L39
// delete the session cookie => lifetime = -1h (60 * 60)
if (ini_get('session.use_cookies')) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 3600,
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
}
}
//return $this->clear(false);
} | php | public static function destroy2()
{
if (self::status() === \PHP_SESSION_ACTIVE) {
//session_unset();
self::flush();
session_destroy();
session_write_close();
// TODO : utiliser 42000 comme nombre au lieu de -1heure => https://github.com/odan/slim-session/blob/master/src/Slim/Session/Adapter/PhpSessionAdapter.php#L39
// delete the session cookie => lifetime = -1h (60 * 60)
if (ini_get('session.use_cookies')) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 3600,
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
}
}
//return $this->clear(false);
} | [
"public",
"static",
"function",
"destroy2",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"status",
"(",
")",
"===",
"\\",
"PHP_SESSION_ACTIVE",
")",
"{",
"//session_unset();",
"self",
"::",
"flush",
"(",
")",
";",
"session_destroy",
"(",
")",
";",
"session_writ... | Destroy all session data.
@return $this | [
"Destroy",
"all",
"session",
"data",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Session/SessionManager.php#L576-L601 | train |
theodorejb/peachy-sql | lib/Mysql/Statement.php | Statement.close | public function close(): void
{
if ($this->stmt === null) {
throw new \Exception('Statement has already been closed');
}
if (!$this->stmt->close()) {
throw new SqlException('Failed to close statement', $this->stmt->error_list, $this->query, $this->params);
}
$this->stmt = null;
$this->meta = null;
} | php | public function close(): void
{
if ($this->stmt === null) {
throw new \Exception('Statement has already been closed');
}
if (!$this->stmt->close()) {
throw new SqlException('Failed to close statement', $this->stmt->error_list, $this->query, $this->params);
}
$this->stmt = null;
$this->meta = null;
} | [
"public",
"function",
"close",
"(",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"stmt",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Statement has already been closed'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
... | Closes the prepared statement and deallocates the statement handle.
@throws SqlException if failure closing the statement | [
"Closes",
"the",
"prepared",
"statement",
"and",
"deallocates",
"the",
"statement",
"handle",
"."
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/Mysql/Statement.php#L90-L102 | train |
CeusMedia/Common | src/Net/HTTP/Header/Field/Parser.php | Net_HTTP_Header_Field_Parser.decodeQualifiedValues | static public function decodeQualifiedValues( $qualifiedValues, $sortByLength = FALSE ){
$pattern = '/^(\S+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/iU';
$parts = preg_split( '/,\s*/', $qualifiedValues );
$codes = array();
foreach( $parts as $part )
if( preg_match ( $pattern, $part, $matches ) )
$codes[$matches[1]] = isset( $matches[2] ) ? (float) $matches[2] : 1.0;
$map = array();
foreach( $codes as $code => $quality ){
if( !isset( $map[(string)$quality] ) )
$map[(string)$quality] = array();
$map[(string)$quality][strlen( $code)] = $code;
if( $sortByLength )
krsort( $map[(string)$quality] ); // sort inner list by code length
}
krsort( $map ); // sort outer list by quality
$list = array();
foreach( $map as $quality => $codes ) // reduce map to list
foreach( $codes as $code )
$list[$code] = (float) $quality;
return $list;
} | php | static public function decodeQualifiedValues( $qualifiedValues, $sortByLength = FALSE ){
$pattern = '/^(\S+)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/iU';
$parts = preg_split( '/,\s*/', $qualifiedValues );
$codes = array();
foreach( $parts as $part )
if( preg_match ( $pattern, $part, $matches ) )
$codes[$matches[1]] = isset( $matches[2] ) ? (float) $matches[2] : 1.0;
$map = array();
foreach( $codes as $code => $quality ){
if( !isset( $map[(string)$quality] ) )
$map[(string)$quality] = array();
$map[(string)$quality][strlen( $code)] = $code;
if( $sortByLength )
krsort( $map[(string)$quality] ); // sort inner list by code length
}
krsort( $map ); // sort outer list by quality
$list = array();
foreach( $map as $quality => $codes ) // reduce map to list
foreach( $codes as $code )
$list[$code] = (float) $quality;
return $list;
} | [
"static",
"public",
"function",
"decodeQualifiedValues",
"(",
"$",
"qualifiedValues",
",",
"$",
"sortByLength",
"=",
"FALSE",
")",
"{",
"$",
"pattern",
"=",
"'/^(\\S+)(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/iU'",
";",
"$",
"parts",
"=",
"preg_split",
"(",
"... | Tries to decode qualified values into a map of values ordered by their quality.
@static
@access public
@param string $string String of qualified values to decode
@param boolean $sortByLength Flag: assume longer key as more qualified for keys with same quality (default: FALSE)
@return array Map of qualified values ordered by quality | [
"Tries",
"to",
"decode",
"qualified",
"values",
"into",
"a",
"map",
"of",
"values",
"ordered",
"by",
"their",
"quality",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Field/Parser.php#L49-L70 | train |
CeusMedia/Common | src/Net/HTTP/Header/Field/Parser.php | Net_HTTP_Header_Field_Parser.parse | static public function parse( $headerFieldString, $decodeQualifiedValues = FALSE ){
if( !preg_match( '/^\S+:\s*.+$/', trim( $headerFieldString ) ) )
throw new InvalidArgumentException( 'Given string is not an HTTP header' );
list( $key, $value ) = preg_split( '/:/', trim( $headerFieldString ), 2 );
$value = trim( $value );
if( $decodeQualifiedValues )
$value = self::decodeQualifiedValues( $value );
return new Net_HTTP_Header_Field( trim( $key ), $value );
} | php | static public function parse( $headerFieldString, $decodeQualifiedValues = FALSE ){
if( !preg_match( '/^\S+:\s*.+$/', trim( $headerFieldString ) ) )
throw new InvalidArgumentException( 'Given string is not an HTTP header' );
list( $key, $value ) = preg_split( '/:/', trim( $headerFieldString ), 2 );
$value = trim( $value );
if( $decodeQualifiedValues )
$value = self::decodeQualifiedValues( $value );
return new Net_HTTP_Header_Field( trim( $key ), $value );
} | [
"static",
"public",
"function",
"parse",
"(",
"$",
"headerFieldString",
",",
"$",
"decodeQualifiedValues",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/^\\S+:\\s*.+$/'",
",",
"trim",
"(",
"$",
"headerFieldString",
")",
")",
")",
"throw",
"ne... | Parses a header field string into a header field object.
@static
@access public
@param string $headerFieldString String to header field to parse
@param boolean $decodeQualifiedValues Flag: decode qualified values (default: FALSE)
@return Net_HTTP_Header_Field Header field object
@throws InvalidArgumentException If given string is not a valid header field | [
"Parses",
"a",
"header",
"field",
"string",
"into",
"a",
"header",
"field",
"object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Header/Field/Parser.php#L82-L90 | train |
railken/amethyst-invoice | src/Models/Invoice.php | Invoice.formatPrice | public function formatPrice($price)
{
$currencies = new ISOCurrencies();
$numberFormatter = new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY);
$moneyFormatter = new IntlMoneyFormatter($numberFormatter, $currencies);
return $moneyFormatter->format($price);
} | php | public function formatPrice($price)
{
$currencies = new ISOCurrencies();
$numberFormatter = new \NumberFormatter($this->locale, \NumberFormatter::CURRENCY);
$moneyFormatter = new IntlMoneyFormatter($numberFormatter, $currencies);
return $moneyFormatter->format($price);
} | [
"public",
"function",
"formatPrice",
"(",
"$",
"price",
")",
"{",
"$",
"currencies",
"=",
"new",
"ISOCurrencies",
"(",
")",
";",
"$",
"numberFormatter",
"=",
"new",
"\\",
"NumberFormatter",
"(",
"$",
"this",
"->",
"locale",
",",
"\\",
"NumberFormatter",
":... | Readable price.
@param Money $price
@return string | [
"Readable",
"price",
"."
] | 605cf27aaa82aea7328d5e5ae5f69b1e7e86120e | https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Models/Invoice.php#L112-L120 | train |
CeusMedia/Common | src/FS/File/INI.php | FS_File_INI.get | public function get( $key, $section = NULL )
{
if( !is_null( $this->sections ) && $this->sections->has( $section ) )
return $this->sections->get( $section )->get( $key );
if( !is_null( $this->pairs ) )
return $this->pairs->get( $key );
return NULL;
} | php | public function get( $key, $section = NULL )
{
if( !is_null( $this->sections ) && $this->sections->has( $section ) )
return $this->sections->get( $section )->get( $key );
if( !is_null( $this->pairs ) )
return $this->pairs->get( $key );
return NULL;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"section",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"sections",
")",
"&&",
"$",
"this",
"->",
"sections",
"->",
"has",
"(",
"$",
"section",
")",
")",
"return... | Returns Value by its Key.
@access public
@param string $key Key
@param boolean $section Flag: use Sections
@return string|NULL Value if set, NULL otherwise | [
"Returns",
"Value",
"by",
"its",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/INI.php#L51-L58 | train |
CeusMedia/Common | src/Net/HTTP/Sniffer/Charset.php | Net_HTTP_Sniffer_Charset.getCharsetFromString | public static function getCharsetFromString( $string, $allowed, $default = false )
{
if( !$default)
$default = $allowed[0];
if( !$string )
return $default;
$accepted = preg_split( '/,\s*/', $string );
$currentCharset = $default;
$currentQuality = 0;
foreach( $accepted as $accept )
{
if( !preg_match ( self::$pattern, $accept, $matches ) )
continue;
$charsetQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0;
if( $charsetQuality > $currentQuality )
{
$currentCharset = strtolower( $matches[1] );
$currentQuality = $charsetQuality;
}
}
return $currentCharset;
} | php | public static function getCharsetFromString( $string, $allowed, $default = false )
{
if( !$default)
$default = $allowed[0];
if( !$string )
return $default;
$accepted = preg_split( '/,\s*/', $string );
$currentCharset = $default;
$currentQuality = 0;
foreach( $accepted as $accept )
{
if( !preg_match ( self::$pattern, $accept, $matches ) )
continue;
$charsetQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0;
if( $charsetQuality > $currentQuality )
{
$currentCharset = strtolower( $matches[1] );
$currentQuality = $charsetQuality;
}
}
return $currentCharset;
} | [
"public",
"static",
"function",
"getCharsetFromString",
"(",
"$",
"string",
",",
"$",
"allowed",
",",
"$",
"default",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"default",
")",
"$",
"default",
"=",
"$",
"allowed",
"[",
"0",
"]",
";",
"if",
"(",
"... | Returns prefered allowed and accepted Character Set from String.
@access public
@static
@param array $allowed Array of Character Sets supported and allowed by the Application
@param string $default Default Character Sets supported and allowed by the Application
@return string | [
"Returns",
"prefered",
"allowed",
"and",
"accepted",
"Character",
"Set",
"from",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Sniffer/Charset.php#L67-L88 | train |
ncou/Chiron | src/Chiron/Handler/Formatter/XmlFormatter.php | XmlFormatter.cleanKeysForXml | private function cleanKeysForXml(array $input): array
{
$return = [];
foreach ($input as $key => $value) {
// first remove the line return because the regex using "." pattern prevent to include the line return in the preg_replace.
$key = str_replace("\n", '_', $key);
$startCharacterPattern =
'[A-Z]|_|[a-z]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\x{2FF}]|[\x{370}-\x{37D}]|[\x{37F}-\x{1FFF}]|'
. '[\x{200C}-\x{200D}]|[\x{2070}-\x{218F}]|[\x{2C00}-\x{2FEF}]|[\x{3001}-\x{D7FF}]|[\x{F900}-\x{FDCF}]'
. '|[\x{FDF0}-\x{FFFD}]|[\x{10000}-\x{EFFFF}]';
$characterPattern = $startCharacterPattern . '|\-|\.|[0-9]|\xB7|[\x{300}-\x{36F}]|[\x{203F}-\x{2040}]';
$key = preg_replace('/(?!' . $characterPattern . ')./u', '_', $key);
$key = preg_replace('/^(?!' . $startCharacterPattern . ')./u', '_', $key);
if (is_array($value)) {
$value = $this->cleanKeysForXml($value);
}
$return[$key] = $value;
}
return $return;
} | php | private function cleanKeysForXml(array $input): array
{
$return = [];
foreach ($input as $key => $value) {
// first remove the line return because the regex using "." pattern prevent to include the line return in the preg_replace.
$key = str_replace("\n", '_', $key);
$startCharacterPattern =
'[A-Z]|_|[a-z]|[\xC0-\xD6]|[\xD8-\xF6]|[\xF8-\x{2FF}]|[\x{370}-\x{37D}]|[\x{37F}-\x{1FFF}]|'
. '[\x{200C}-\x{200D}]|[\x{2070}-\x{218F}]|[\x{2C00}-\x{2FEF}]|[\x{3001}-\x{D7FF}]|[\x{F900}-\x{FDCF}]'
. '|[\x{FDF0}-\x{FFFD}]|[\x{10000}-\x{EFFFF}]';
$characterPattern = $startCharacterPattern . '|\-|\.|[0-9]|\xB7|[\x{300}-\x{36F}]|[\x{203F}-\x{2040}]';
$key = preg_replace('/(?!' . $characterPattern . ')./u', '_', $key);
$key = preg_replace('/^(?!' . $startCharacterPattern . ')./u', '_', $key);
if (is_array($value)) {
$value = $this->cleanKeysForXml($value);
}
$return[$key] = $value;
}
return $return;
} | [
"private",
"function",
"cleanKeysForXml",
"(",
"array",
"$",
"input",
")",
":",
"array",
"{",
"$",
"return",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"input",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"// first remove the line return because the regex ... | Ensure all keys in this associative array are valid XML tag names by replacing invalid
characters with an `_`.
@see https://www.w3.org/TR/xml/#sec-common-syn | [
"Ensure",
"all",
"keys",
"in",
"this",
"associative",
"array",
"are",
"valid",
"XML",
"tag",
"names",
"by",
"replacing",
"invalid",
"characters",
"with",
"an",
"_",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Formatter/XmlFormatter.php#L184-L204 | train |
CeusMedia/Common | src/FS/File/Log/Tracker/ShortReader.php | FS_File_Log_Tracker_ShortReader.getBrowsers | public function getBrowsers()
{
if( !$this->_open )
{
trigger_error( "Log File not read", E_USER_ERROR );
return array();
}
$remote_addrs = array();
$browsers = array();
foreach( $this->data as $entry )
{
if( $entry['remote_addr'] != $this->skip && $entry['http_user_agent'] )
{
if( isset( $remote_addrs[$entry['remote_addr']] ) )
{
if( $remote_addrs[$entry['remote_addr']] < $entry['timestamp'] - 30 * 60 )
{
if( isset( $browsers[$entry['http_user_agent']] ) )
$browsers[$entry['http_user_agent']] ++;
else
$browsers[$entry['http_user_agent']] = 1;
}
$remote_addrs[$entry['remote_addr']] = $entry['timestamp'];
}
else
{
if( isset( $browsers[$entry['http_user_agent']] ) )
$browsers[$entry['http_user_agent']] ++;
else
$browsers[$entry['http_user_agent']] = 1;
$remote_addrs[$entry['remote_addr']] = $entry['timestamp'];
}
}
}
arsort( $browsers );
$lines = array();
foreach( $browsers as $browser => $count )
$lines[] = "<tr><td>".$browser."</td><td>".$count."</td></tr>";
$lines = implode( "\n\t", $lines );
$content = "<table>".$lines."</table>";
return $content;
} | php | public function getBrowsers()
{
if( !$this->_open )
{
trigger_error( "Log File not read", E_USER_ERROR );
return array();
}
$remote_addrs = array();
$browsers = array();
foreach( $this->data as $entry )
{
if( $entry['remote_addr'] != $this->skip && $entry['http_user_agent'] )
{
if( isset( $remote_addrs[$entry['remote_addr']] ) )
{
if( $remote_addrs[$entry['remote_addr']] < $entry['timestamp'] - 30 * 60 )
{
if( isset( $browsers[$entry['http_user_agent']] ) )
$browsers[$entry['http_user_agent']] ++;
else
$browsers[$entry['http_user_agent']] = 1;
}
$remote_addrs[$entry['remote_addr']] = $entry['timestamp'];
}
else
{
if( isset( $browsers[$entry['http_user_agent']] ) )
$browsers[$entry['http_user_agent']] ++;
else
$browsers[$entry['http_user_agent']] = 1;
$remote_addrs[$entry['remote_addr']] = $entry['timestamp'];
}
}
}
arsort( $browsers );
$lines = array();
foreach( $browsers as $browser => $count )
$lines[] = "<tr><td>".$browser."</td><td>".$count."</td></tr>";
$lines = implode( "\n\t", $lines );
$content = "<table>".$lines."</table>";
return $content;
} | [
"public",
"function",
"getBrowsers",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_open",
")",
"{",
"trigger_error",
"(",
"\"Log File not read\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"array",
"(",
")",
";",
"}",
"$",
"remote_addrs",
"=",
"arra... | Returns used Browsers of unique Visitors.
@access public
@return array | [
"Returns",
"used",
"Browsers",
"of",
"unique",
"Visitors",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/Tracker/ShortReader.php#L66-L107 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.indentSign | public function indentSign( $offset, $sign = NULL, $factor = NULL )
{
extract( self::$channels[$this->channel] );
$sign = $sign ? $sign : $indentSign;
$factor = $factor ? $factor : $indentFactor;
return str_repeat( $sign, $offset * $factor );
} | php | public function indentSign( $offset, $sign = NULL, $factor = NULL )
{
extract( self::$channels[$this->channel] );
$sign = $sign ? $sign : $indentSign;
$factor = $factor ? $factor : $indentFactor;
return str_repeat( $sign, $offset * $factor );
} | [
"public",
"function",
"indentSign",
"(",
"$",
"offset",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"extract",
"(",
"self",
"::",
"$",
"channels",
"[",
"$",
"this",
"->",
"channel",
"]",
")",
";",
"$",
"sign",
"=",
"... | Returns whitespaces.
@access public
@param int $offset amount of space
@param string $sign Space Sign
@param int $factor Space Factor
@return string | [
"Returns",
"whitespaces",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L90-L96 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printArray | public function printArray( $array, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_array( $array ) )
{
extract( self::$channels[$this->channel] );
$space = $this->indentSign( $offset, $sign, $factor );
if( $key !== NULL )
echo $space."[A] ".$key.$lineBreak;
foreach( $array as $key => $value )
{
if( is_array( $value ) && count( $value ) )
$this->printArray( $value, $offset + 1, $key, $sign, $factor );
else
$this->printMixed( $value, $offset + 1, $key, $sign, $factor );
}
}
else
$this->printMixed( $array, $offset, $key, $sign, $factor );
} | php | public function printArray( $array, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_array( $array ) )
{
extract( self::$channels[$this->channel] );
$space = $this->indentSign( $offset, $sign, $factor );
if( $key !== NULL )
echo $space."[A] ".$key.$lineBreak;
foreach( $array as $key => $value )
{
if( is_array( $value ) && count( $value ) )
$this->printArray( $value, $offset + 1, $key, $sign, $factor );
else
$this->printMixed( $value, $offset + 1, $key, $sign, $factor );
}
}
else
$this->printMixed( $array, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printArray",
"(",
"$",
"array",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"array",
")",
")",
"{"... | Prints out an Array.
@access public
@param array $array Array variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"an",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L108-L126 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printBoolean | public function printBoolean( $bool, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_bool( $bool ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[B] ".$key.$booleanOpen.( $bool ? "TRUE" : "FALSE" ).$booleanClose.$lineBreak;
}
else
$this->printMixed( $bool, $offset, $key, $sign, $factor );
} | php | public function printBoolean( $bool, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_bool( $bool ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[B] ".$key.$booleanOpen.( $bool ? "TRUE" : "FALSE" ).$booleanClose.$lineBreak;
}
else
$this->printMixed( $bool, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printBoolean",
"(",
"$",
"bool",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_bool",
"(",
"$",
"bool",
")",
")",
"{",... | Prints out a boolean variable.
@access public
@param bool $bool boolean variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"a",
"boolean",
"variable",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L138-L149 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printDouble | public function printDouble( $double, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
return $this->printFloat( $double, $offset, $key, $sign,$factor );
} | php | public function printDouble( $double, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
return $this->printFloat( $double, $offset, $key, $sign,$factor );
} | [
"public",
"function",
"printDouble",
"(",
"$",
"double",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"printFloat",
"(",
"$",
"d... | Prints out an Double variable.
@access public
@param double $double double variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"an",
"Double",
"variable",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L161-L164 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printFloat | public function printFloat( $float, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_float( $float ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[F] ".$key.$float.$lineBreak;
}
else
$this->printMixed( $float, $offset, $key, $sign, $factor );
} | php | public function printFloat( $float, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_float( $float ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[F] ".$key.$float.$lineBreak;
}
else
$this->printMixed( $float, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printFloat",
"(",
"$",
"float",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_float",
"(",
"$",
"float",
")",
")",
"{"... | Prints out an Float variable.
@access public
@param float $float float variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"an",
"Float",
"variable",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L176-L187 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printInteger | public function printInteger( $integer, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_int( $integer ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[I] ".$key.$integer.$lineBreak;
}
else
$this->printMixed( $integer, $offset, $key, $sign, $factor );
} | php | public function printInteger( $integer, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_int( $integer ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[I] ".$key.$integer.$lineBreak;
}
else
$this->printMixed( $integer, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printInteger",
"(",
"$",
"integer",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_int",
"(",
"$",
"integer",
")",
")",
... | Prints out an Integer variable.
@access public
@param int $integer Integer variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"an",
"Integer",
"variable",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L199-L210 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printJson | public function printJson( $mixed, $sign = NULL, $factor = NULL, $return = FALSE )
{
if( $return )
ob_start();
extract( self::$channels[$this->channel] );
$o = new UI_DevOutput();
echo $lineBreak;
$space = $this->indentSign( 1, $sign, $factor );
$json = ADT_JSON_Formater::format( $mixed );
$json = str_replace( "\n", $lineBreak, $json );
$json = str_replace( " ", $space, $json );
echo $json;
if( $return )
return ob_get_clean();
} | php | public function printJson( $mixed, $sign = NULL, $factor = NULL, $return = FALSE )
{
if( $return )
ob_start();
extract( self::$channels[$this->channel] );
$o = new UI_DevOutput();
echo $lineBreak;
$space = $this->indentSign( 1, $sign, $factor );
$json = ADT_JSON_Formater::format( $mixed );
$json = str_replace( "\n", $lineBreak, $json );
$json = str_replace( " ", $space, $json );
echo $json;
if( $return )
return ob_get_clean();
} | [
"public",
"function",
"printJson",
"(",
"$",
"mixed",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
",",
"$",
"return",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"return",
")",
"ob_start",
"(",
")",
";",
"extract",
"(",
"self",
":... | Prints out a variable as JSON.
@access public
@param mixed $mixed variable of every kind to print out
@param string $sign Space Sign
@param int $factor Space Factor
@param boolean $return Flag: Return output instead of printing it
@return void | [
"Prints",
"out",
"a",
"variable",
"as",
"JSON",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L221-L235 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printMixed | public function printMixed( $mixed, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL, $return = FALSE )
{
if( $return )
ob_start();
if( is_object( $mixed ) || gettype( $mixed ) == "object" )
$this->printObject( $mixed, $offset, $key, $sign, $factor );
else if( is_array( $mixed ) )
$this->printArray( $mixed, $offset, $key, $sign, $factor );
else if( is_string( $mixed ) )
$this->printString( $mixed, $offset, $key, $sign, $factor );
else if( is_int($mixed ) )
$this->printInteger( $mixed, $offset, $key, $sign, $factor );
else if( is_float($mixed ) )
$this->printFloat( $mixed, $offset, $key, $sign, $factor );
else if( is_double( $mixed ) )
$this->printDouble( $mixed, $offset, $key, $sign, $factor );
else if( is_resource( $mixed ) )
$this->printResource( $mixed, $offset, $key, $sign, $factor );
else if( is_bool($mixed ) )
$this->printBoolean( $mixed, $offset, $key, $sign, $factor );
else if( $mixed === NULL )
$this->printNull( $mixed, $offset, $key, $sign, $factor );
if( $return )
return ob_get_clean();
} | php | public function printMixed( $mixed, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL, $return = FALSE )
{
if( $return )
ob_start();
if( is_object( $mixed ) || gettype( $mixed ) == "object" )
$this->printObject( $mixed, $offset, $key, $sign, $factor );
else if( is_array( $mixed ) )
$this->printArray( $mixed, $offset, $key, $sign, $factor );
else if( is_string( $mixed ) )
$this->printString( $mixed, $offset, $key, $sign, $factor );
else if( is_int($mixed ) )
$this->printInteger( $mixed, $offset, $key, $sign, $factor );
else if( is_float($mixed ) )
$this->printFloat( $mixed, $offset, $key, $sign, $factor );
else if( is_double( $mixed ) )
$this->printDouble( $mixed, $offset, $key, $sign, $factor );
else if( is_resource( $mixed ) )
$this->printResource( $mixed, $offset, $key, $sign, $factor );
else if( is_bool($mixed ) )
$this->printBoolean( $mixed, $offset, $key, $sign, $factor );
else if( $mixed === NULL )
$this->printNull( $mixed, $offset, $key, $sign, $factor );
if( $return )
return ob_get_clean();
} | [
"public",
"function",
"printMixed",
"(",
"$",
"mixed",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
",",
"$",
"return",
"=",
"FALSE",
")",
"{",
"if",
"(",
"$",
"retu... | Prints out a variable by getting Type and using a suitable Method.
@access public
@param mixed $mixed variable of every kind to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@param boolean $return Flag: Return output instead of printing it
@return void | [
"Prints",
"out",
"a",
"variable",
"by",
"getting",
"Type",
"and",
"using",
"a",
"suitable",
"Method",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L248-L272 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printNull | public function printNull( $null, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( $null === NULL )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[N] ".$key.$booleanOpen."NULL".$booleanClose.$lineBreak;
}
else
$this->printMixed( $null, $offset, $key, $sign, $factor );
} | php | public function printNull( $null, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( $null === NULL )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[N] ".$key.$booleanOpen."NULL".$booleanClose.$lineBreak;
}
else
$this->printMixed( $null, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printNull",
"(",
"$",
"null",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"null",
"===",
"NULL",
")",
"{",
"extract... | Prints out NULL.
@access public
@param NULL $null boolean variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"NULL",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L284-L295 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printObject | public function printObject( $object, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_object( $object ) || gettype( $object ) == "object" )
{
extract( self::$channels[$this->channel] );
$ins_key = ( $key !== NULL ) ? $key." -> " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[O] ".$ins_key."".$highlightOpen.get_class( $object ).$highlightClose.$lineBreak;
$vars = get_object_vars( $object );
foreach( $vars as $key => $value )
{
if( is_object( $value ) )
$this->printObject( $value, $offset + 1, $key, $sign, $factor );
else if( is_array( $value ) )
$this->printArray( $value, $offset + 1, $key, $sign, $factor );
else
$this->printMixed( $value, $offset + 1, $key, $sign, $factor );
}
}
else
$this->printMixed( $object, $offset, $key, $sign, $factor );
} | php | public function printObject( $object, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_object( $object ) || gettype( $object ) == "object" )
{
extract( self::$channels[$this->channel] );
$ins_key = ( $key !== NULL ) ? $key." -> " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[O] ".$ins_key."".$highlightOpen.get_class( $object ).$highlightClose.$lineBreak;
$vars = get_object_vars( $object );
foreach( $vars as $key => $value )
{
if( is_object( $value ) )
$this->printObject( $value, $offset + 1, $key, $sign, $factor );
else if( is_array( $value ) )
$this->printArray( $value, $offset + 1, $key, $sign, $factor );
else
$this->printMixed( $value, $offset + 1, $key, $sign, $factor );
}
}
else
$this->printMixed( $object, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printObject",
"(",
"$",
"object",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"object",
")",
"||",
... | Prints out a Object.
@access public
@param mixed $object Object variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"a",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L307-L328 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printResource | public function printResource( $resource, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_resource( $resource ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[R] ".$key.$resource.$lineBreak;
}
else
$this->printMixed( $object, $offset, $key, $sign, $factor );
} | php | public function printResource( $resource, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_resource( $resource ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
echo $space."[R] ".$key.$resource.$lineBreak;
}
else
$this->printMixed( $object, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printResource",
"(",
"$",
"resource",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"resource",
")",
... | Prints out a Resource.
@access public
@param mixed $object Object variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"a",
"Resource",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L340-L351 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.printString | public function printString( $string, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_string( $string ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
if( $lineBreak != "\n" )
$string = htmlspecialchars( $string );
if( strlen( $string > $stringMaxLength ) )
$string = Alg_Text_Trimmer::trimCentric( $string, $stringMaxLength, $stringTrimMask );
echo $space."[S] ".$key.$string.$lineBreak;
}
else
$this->printMixed( $string, $offset, $key, $sign, $factor );
} | php | public function printString( $string, $offset = 0, $key = NULL, $sign = NULL, $factor = NULL )
{
if( is_string( $string ) )
{
extract( self::$channels[$this->channel] );
$key = ( $key !== NULL ) ? $key." => " : "";
$space = $this->indentSign( $offset, $sign, $factor );
if( $lineBreak != "\n" )
$string = htmlspecialchars( $string );
if( strlen( $string > $stringMaxLength ) )
$string = Alg_Text_Trimmer::trimCentric( $string, $stringMaxLength, $stringTrimMask );
echo $space."[S] ".$key.$string.$lineBreak;
}
else
$this->printMixed( $string, $offset, $key, $sign, $factor );
} | [
"public",
"function",
"printString",
"(",
"$",
"string",
",",
"$",
"offset",
"=",
"0",
",",
"$",
"key",
"=",
"NULL",
",",
"$",
"sign",
"=",
"NULL",
",",
"$",
"factor",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"string",
")",
")",
... | Prints out a String variable.
@access public
@param string $string String variable to print out
@param int $offset Intent Offset Level
@param string $key Element Key Name
@param string $sign Space Sign
@param int $factor Space Factor
@return void | [
"Prints",
"out",
"a",
"String",
"variable",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L363-L378 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.remark | public function remark( $text, $parameters = array() )
{
$param = "";
if( is_array( $parameters ) && count( $parameters ) )
{
$param = array();
foreach( $parameters as $key => $value )
{
if( is_int( $key ) )
$param[] = $value;
else
$param[] = $key." -> ".$value;
}
$param = ": ".implode( " | ", $param );
}
echo $text.$param;
} | php | public function remark( $text, $parameters = array() )
{
$param = "";
if( is_array( $parameters ) && count( $parameters ) )
{
$param = array();
foreach( $parameters as $key => $value )
{
if( is_int( $key ) )
$param[] = $value;
else
$param[] = $key." -> ".$value;
}
$param = ": ".implode( " | ", $param );
}
echo $text.$param;
} | [
"public",
"function",
"remark",
"(",
"$",
"text",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"param",
"=",
"\"\"",
";",
"if",
"(",
"is_array",
"(",
"$",
"parameters",
")",
"&&",
"count",
"(",
"$",
"parameters",
")",
")",
"{",
... | Prints out a String and Parameters.
@access public
@param string $text String to print out
@param array $parameters Associative Array of Parameters to append
@return void | [
"Prints",
"out",
"a",
"String",
"and",
"Parameters",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L387-L403 | train |
CeusMedia/Common | src/UI/DevOutput.php | UI_DevOutput.setChannel | public function setChannel( $channel = NULL )
{
if( !is_string( $channel ) )
$channel = 'auto';
$channel = strtolower( $channel );
if( !in_array( $channel, array( 'auto', 'console', 'html' ) ) )
throw new OutOfRangeException( 'Channel type "'.$channel.'" is not supported' );
if( $channel === "auto" ){
$channel = 'html';
if( getEnv( 'PROMPT' ) || getEnv( 'SHELL' ) || $channel == "console" )
$channel = 'console';
}
$this->channel = $channel;
} | php | public function setChannel( $channel = NULL )
{
if( !is_string( $channel ) )
$channel = 'auto';
$channel = strtolower( $channel );
if( !in_array( $channel, array( 'auto', 'console', 'html' ) ) )
throw new OutOfRangeException( 'Channel type "'.$channel.'" is not supported' );
if( $channel === "auto" ){
$channel = 'html';
if( getEnv( 'PROMPT' ) || getEnv( 'SHELL' ) || $channel == "console" )
$channel = 'console';
}
$this->channel = $channel;
} | [
"public",
"function",
"setChannel",
"(",
"$",
"channel",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"channel",
")",
")",
"$",
"channel",
"=",
"'auto'",
";",
"$",
"channel",
"=",
"strtolower",
"(",
"$",
"channel",
")",
";",
"if",
... | Sets output channel type.
Auto mode assumes HTML at first and will fall back to Console if detected.
@access public
@param string $channel Type of channel (auto, console, html);
@return void
@throws OutOfRangeException if an invalid channel type is to be set | [
"Sets",
"output",
"channel",
"type",
".",
"Auto",
"mode",
"assumes",
"HTML",
"at",
"first",
"and",
"will",
"fall",
"back",
"to",
"Console",
"if",
"detected",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/DevOutput.php#L418-L431 | train |
CeusMedia/Common | src/FS/File/Log/JSON/Reader.php | FS_File_Log_JSON_Reader.getList | public function getList( $reverse = FALSE, $limit = 0 )
{
return $this->read( $this->fileName, $reverse, $limit );
} | php | public function getList( $reverse = FALSE, $limit = 0 )
{
return $this->read( $this->fileName, $reverse, $limit );
} | [
"public",
"function",
"getList",
"(",
"$",
"reverse",
"=",
"FALSE",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"read",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"reverse",
",",
"$",
"limit",
")",
";",
"}"
] | Returns List of parsed Lines.
@access public
@param bool $reverse Flag: revert List
@param int $limit Optional: limit List
@return array | [
"Returns",
"List",
"of",
"parsed",
"Lines",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/JSON/Reader.php#L63-L66 | train |
CeusMedia/Common | src/FS/File/Log/JSON/Reader.php | FS_File_Log_JSON_Reader.read | public static function read( $fileName, $reverse = FALSE, $limit = 0 )
{
$data = array();
if( !file_exists( $fileName ) )
throw new Exception( 'Log File "'.$fileName.'" is not existing.' );
$lines = file( $fileName );
foreach( $lines as $line )
{
$line = trim( $line );
if( !$line )
continue;
$data[] = json_decode( $line, TRUE );
}
if( $reverse )
$data = array_reverse( $data );
if( $limit )
$data = array_slice( $data, 0, $limit );
return $data;
} | php | public static function read( $fileName, $reverse = FALSE, $limit = 0 )
{
$data = array();
if( !file_exists( $fileName ) )
throw new Exception( 'Log File "'.$fileName.'" is not existing.' );
$lines = file( $fileName );
foreach( $lines as $line )
{
$line = trim( $line );
if( !$line )
continue;
$data[] = json_decode( $line, TRUE );
}
if( $reverse )
$data = array_reverse( $data );
if( $limit )
$data = array_slice( $data, 0, $limit );
return $data;
} | [
"public",
"static",
"function",
"read",
"(",
"$",
"fileName",
",",
"$",
"reverse",
"=",
"FALSE",
",",
"$",
"limit",
"=",
"0",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"thro... | Reads and returns List of parsed Lines statically.
@access public
@static
@param string $fileName File Name of Log File
@param bool $reverse Flag: revert List
@param int $limit Optional: limit List
@return array | [
"Reads",
"and",
"returns",
"List",
"of",
"parsed",
"Lines",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/JSON/Reader.php#L77-L95 | train |
CeusMedia/Common | src/ADT/PHP/Container.php | ADT_PHP_Container.getClassFromClassName | public function getClassFromClassName( $className, ADT_PHP_Interface $relatedArtefact )
{
if( !isset( $this->classNameList[$className] ) )
throw new Exception( 'Unknown class "'.$className.'"' );
$list = $this->classNameList[$className];
$category = $relatedArtefact->getCategory();
$package = $relatedArtefact->getPackage();
if( isset( $list[$category][$package] ) ) // found Class in same Category same Package
return $list[$category][$package]; // return Data Object of Class
if( isset( $list[$category] ) ) // found Class in same Category but different Package
return array_shift( $list[$category] ); // this is a Guess: return Data Object of guessed Class
$firstCategory = array_shift( $list );
return array_shift( $firstCategory );
} | php | public function getClassFromClassName( $className, ADT_PHP_Interface $relatedArtefact )
{
if( !isset( $this->classNameList[$className] ) )
throw new Exception( 'Unknown class "'.$className.'"' );
$list = $this->classNameList[$className];
$category = $relatedArtefact->getCategory();
$package = $relatedArtefact->getPackage();
if( isset( $list[$category][$package] ) ) // found Class in same Category same Package
return $list[$category][$package]; // return Data Object of Class
if( isset( $list[$category] ) ) // found Class in same Category but different Package
return array_shift( $list[$category] ); // this is a Guess: return Data Object of guessed Class
$firstCategory = array_shift( $list );
return array_shift( $firstCategory );
} | [
"public",
"function",
"getClassFromClassName",
"(",
"$",
"className",
",",
"ADT_PHP_Interface",
"$",
"relatedArtefact",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"classNameList",
"[",
"$",
"className",
"]",
")",
")",
"throw",
"new",
"Excepti... | Searches for a Class by its Name in same Category and Package.
Otherwise searches in different Packages and finally in different Categories.
@access public
@param string $className Name of Class to find Data Object for
@param ADT_PHP_Interface $relatedArtefact A related Class or Interface (for Package and Category Information)
@return ADT_PHP_Class
@throws Exception if Class is not known | [
"Searches",
"for",
"a",
"Class",
"by",
"its",
"Name",
"in",
"same",
"Category",
"and",
"Package",
".",
"Otherwise",
"searches",
"in",
"different",
"Packages",
"and",
"finally",
"in",
"different",
"Categories",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/PHP/Container.php#L57-L73 | train |
CeusMedia/Common | src/ADT/PHP/Container.php | ADT_PHP_Container.getInterfaceFromInterfaceName | public function getInterfaceFromInterfaceName( $interfaceName, ADT_PHP_Interface $relatedArtefact )
{
if( !isset( $this->interfaceNameList[$interfaceName] ) )
throw new Exception( 'Unknown interface "'.$interfaceName.'"' );
$list = $this->interfaceNameList[$interfaceName];
$category = $relatedArtefact->getCategory();
$package = $relatedArtefact->getPackage();
if( isset( $list[$category][$package] ) ) // found Interface in same Category same Package
return $list[$category][$package]; // return Data Object of Interface
if( isset( $list[$category] ) ) // found Interface in same Category but different Package
return array_shift( $list[$category] ); // this is a Guess: return Data Object of guessed Interface
return array_shift( array_shift( $list ) );
} | php | public function getInterfaceFromInterfaceName( $interfaceName, ADT_PHP_Interface $relatedArtefact )
{
if( !isset( $this->interfaceNameList[$interfaceName] ) )
throw new Exception( 'Unknown interface "'.$interfaceName.'"' );
$list = $this->interfaceNameList[$interfaceName];
$category = $relatedArtefact->getCategory();
$package = $relatedArtefact->getPackage();
if( isset( $list[$category][$package] ) ) // found Interface in same Category same Package
return $list[$category][$package]; // return Data Object of Interface
if( isset( $list[$category] ) ) // found Interface in same Category but different Package
return array_shift( $list[$category] ); // this is a Guess: return Data Object of guessed Interface
return array_shift( array_shift( $list ) );
} | [
"public",
"function",
"getInterfaceFromInterfaceName",
"(",
"$",
"interfaceName",
",",
"ADT_PHP_Interface",
"$",
"relatedArtefact",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"interfaceNameList",
"[",
"$",
"interfaceName",
"]",
")",
")",
"throw",... | Searches for an Interface by its Name in same Category and Package.
Otherwise is searches in different Packages and finally in different Categories.
@access public
@param string $interfaceName Name of Interface to find Data Object for
@param ADT_PHP_Interface $relatedArtefact A related Class or Interface (for Package and Category Information)
@return ADT_PHP_Interface
@throws Exception if Interface is not known | [
"Searches",
"for",
"an",
"Interface",
"by",
"its",
"Name",
"in",
"same",
"Category",
"and",
"Package",
".",
"Otherwise",
"is",
"searches",
"in",
"different",
"Packages",
"and",
"finally",
"in",
"different",
"Categories",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/PHP/Container.php#L115-L130 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.extendPossibleOptionsWithShortcuts | protected function extendPossibleOptionsWithShortcuts()
{
foreach( $this->shortcuts as $short => $long )
{
if( !isset( $this->possibleOptions[$long] ) )
throw new InvalidArgumentException( 'Invalid shortcut to not existing option "'.$long.'" .' );
$this->possibleOptions[$short] = $this->possibleOptions[$long];
}
} | php | protected function extendPossibleOptionsWithShortcuts()
{
foreach( $this->shortcuts as $short => $long )
{
if( !isset( $this->possibleOptions[$long] ) )
throw new InvalidArgumentException( 'Invalid shortcut to not existing option "'.$long.'" .' );
$this->possibleOptions[$short] = $this->possibleOptions[$long];
}
} | [
"protected",
"function",
"extendPossibleOptionsWithShortcuts",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"shortcuts",
"as",
"$",
"short",
"=>",
"$",
"long",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"possibleOptions",
"[",
"$",
"... | Extends internal Option List with afore set Shortcut List.
@access protected
@return void | [
"Extends",
"internal",
"Option",
"List",
"with",
"afore",
"set",
"Shortcut",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L59-L67 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.finishOptions | protected function finishOptions()
{
foreach( $this->shortcuts as $short => $long )
{
if( !array_key_exists( $short, $this->foundOptions ) )
continue;
$this->foundOptions[$long] = $this->foundOptions[$short];
unset( $this->foundOptions[$short] );
}
} | php | protected function finishOptions()
{
foreach( $this->shortcuts as $short => $long )
{
if( !array_key_exists( $short, $this->foundOptions ) )
continue;
$this->foundOptions[$long] = $this->foundOptions[$short];
unset( $this->foundOptions[$short] );
}
} | [
"protected",
"function",
"finishOptions",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"shortcuts",
"as",
"$",
"short",
"=>",
"$",
"long",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"short",
",",
"$",
"this",
"->",
"foundOptions",
")"... | Resolves parsed Option Shortcuts.
@access protected
@return void | [
"Resolves",
"parsed",
"Option",
"Shortcuts",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L74-L83 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.onEndOfLine | protected function onEndOfLine( &$status, &$buffer, &$option )
{
if( $status == self::STATUS_READ_ARGUMENT )
$this->foundArguments[] = $buffer;
else if( $status == self::STATUS_READ_OPTION_VALUE ) // still reading an option value
$this->onReadOptionValue( ' ', $status, $buffer, $option ); // close reading and save last option
else if( $status == self::STATUS_READ_OPTION_KEY )
{
if( !array_key_exists( $option, $this->possibleOptions ) )
throw new InvalidArgumentException( 'Invalid option: '.$option.'.' );
if( $this->possibleOptions[$option] )
throw new RuntimeException( 'Missing value of option "'.$option.'".' );
$this->foundOptions[$option] = TRUE;
}
if( count( $this->foundArguments ) < $this->numberArguments )
throw new RuntimeException( 'Missing argument.' );
$this->finishOptions();
$this->parsed = TRUE;
} | php | protected function onEndOfLine( &$status, &$buffer, &$option )
{
if( $status == self::STATUS_READ_ARGUMENT )
$this->foundArguments[] = $buffer;
else if( $status == self::STATUS_READ_OPTION_VALUE ) // still reading an option value
$this->onReadOptionValue( ' ', $status, $buffer, $option ); // close reading and save last option
else if( $status == self::STATUS_READ_OPTION_KEY )
{
if( !array_key_exists( $option, $this->possibleOptions ) )
throw new InvalidArgumentException( 'Invalid option: '.$option.'.' );
if( $this->possibleOptions[$option] )
throw new RuntimeException( 'Missing value of option "'.$option.'".' );
$this->foundOptions[$option] = TRUE;
}
if( count( $this->foundArguments ) < $this->numberArguments )
throw new RuntimeException( 'Missing argument.' );
$this->finishOptions();
$this->parsed = TRUE;
} | [
"protected",
"function",
"onEndOfLine",
"(",
"&",
"$",
"status",
",",
"&",
"$",
"buffer",
",",
"&",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"status",
"==",
"self",
"::",
"STATUS_READ_ARGUMENT",
")",
"$",
"this",
"->",
"foundArguments",
"[",
"]",
"=",
... | Handles open Argument or Option at the End of the Argument String.
@access protected
@param int $status Status Reference
@param string $buffer Argument Buffer Reference
@param string $option Option Buffer Reference
@return void | [
"Handles",
"open",
"Argument",
"or",
"Option",
"at",
"the",
"End",
"of",
"the",
"Argument",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L117-L135 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.onReadArgument | protected function onReadArgument( $sign, &$status, &$buffer )
{
if( $sign == " " )
{
$this->foundArguments[] = $buffer;
$buffer = "";
$status = self::STATUS_START;
return;
}
$buffer .= $sign;
} | php | protected function onReadArgument( $sign, &$status, &$buffer )
{
if( $sign == " " )
{
$this->foundArguments[] = $buffer;
$buffer = "";
$status = self::STATUS_START;
return;
}
$buffer .= $sign;
} | [
"protected",
"function",
"onReadArgument",
"(",
"$",
"sign",
",",
"&",
"$",
"status",
",",
"&",
"$",
"buffer",
")",
"{",
"if",
"(",
"$",
"sign",
"==",
"\" \"",
")",
"{",
"$",
"this",
"->",
"foundArguments",
"[",
"]",
"=",
"$",
"buffer",
";",
"$",
... | Handles current Sign in STATUS_READ_ARGUMENT.
@access protected
@param string $sign Sign to handle
@param int $status Status Reference
@param string $buffer Argument Buffer Reference
@param string $option Option Buffer Reference
@return void | [
"Handles",
"current",
"Sign",
"in",
"STATUS_READ_ARGUMENT",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L146-L156 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.onReadOptionKey | protected function onReadOptionKey( $sign, &$status, &$buffer, &$option )
{
if( in_array( $sign, array( " ", ":", "=" ) ) )
{
if( !array_key_exists( $option, $this->possibleOptions ) )
throw new InvalidArgumentException( 'Invalid option "'.$option.'"' );
if( !$this->possibleOptions[$option] )
{
if( $sign !== " " )
throw new InvalidArgumentException( 'Option "'.$option.'" cannot receive a value' );
$this->foundOptions[$option] = TRUE;
$status = self::STATUS_START;
}
else
{
$buffer = "";
$status = self::STATUS_READ_OPTION_VALUE;
}
}
else if( $sign !== "-" )
$option .= $sign;
} | php | protected function onReadOptionKey( $sign, &$status, &$buffer, &$option )
{
if( in_array( $sign, array( " ", ":", "=" ) ) )
{
if( !array_key_exists( $option, $this->possibleOptions ) )
throw new InvalidArgumentException( 'Invalid option "'.$option.'"' );
if( !$this->possibleOptions[$option] )
{
if( $sign !== " " )
throw new InvalidArgumentException( 'Option "'.$option.'" cannot receive a value' );
$this->foundOptions[$option] = TRUE;
$status = self::STATUS_START;
}
else
{
$buffer = "";
$status = self::STATUS_READ_OPTION_VALUE;
}
}
else if( $sign !== "-" )
$option .= $sign;
} | [
"protected",
"function",
"onReadOptionKey",
"(",
"$",
"sign",
",",
"&",
"$",
"status",
",",
"&",
"$",
"buffer",
",",
"&",
"$",
"option",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"sign",
",",
"array",
"(",
"\" \"",
",",
"\":\"",
",",
"\"=\"",
")",... | Handles current Sign in STATUS_READ_OPTION_KEY.
@access protected
@param string $sign Sign to handle
@param int $status Status Reference
@param string $buffer Argument Buffer Reference
@param string $option Option Buffer Reference
@return void | [
"Handles",
"current",
"Sign",
"in",
"STATUS_READ_OPTION_KEY",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L167-L188 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.onReadOptionValue | protected function onReadOptionValue( $sign, &$status, &$buffer, &$option )
{
if( $sign == "-" ) // illegal Option following
throw new RuntimeException( 'Missing value of option "'.$option.'"' );
if( $sign == " " ) // closing value...
{
if( !$buffer ){ // no value
if( !$this->possibleOptions[$option] ) // no value required/defined
$this->foundOptions[$option] = TRUE; // assign true for existance
return; //
}
if( $this->possibleOptions[$option] !== TRUE ){ // must match regexp
if( !preg_match( $this->possibleOptions[$option], $buffer ) ) // not matching
throw new InvalidArgumentException( 'Argument "'.$option.'" has invalid value' );
}
$this->foundOptions[$option] = $buffer;
$buffer = "";
$status = self::STATUS_START;
return;
}
$buffer .= $sign;
} | php | protected function onReadOptionValue( $sign, &$status, &$buffer, &$option )
{
if( $sign == "-" ) // illegal Option following
throw new RuntimeException( 'Missing value of option "'.$option.'"' );
if( $sign == " " ) // closing value...
{
if( !$buffer ){ // no value
if( !$this->possibleOptions[$option] ) // no value required/defined
$this->foundOptions[$option] = TRUE; // assign true for existance
return; //
}
if( $this->possibleOptions[$option] !== TRUE ){ // must match regexp
if( !preg_match( $this->possibleOptions[$option], $buffer ) ) // not matching
throw new InvalidArgumentException( 'Argument "'.$option.'" has invalid value' );
}
$this->foundOptions[$option] = $buffer;
$buffer = "";
$status = self::STATUS_START;
return;
}
$buffer .= $sign;
} | [
"protected",
"function",
"onReadOptionValue",
"(",
"$",
"sign",
",",
"&",
"$",
"status",
",",
"&",
"$",
"buffer",
",",
"&",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"sign",
"==",
"\"-\"",
")",
"// illegal Option following",
"throw",
"new",
"RuntimeExcepti... | Handles current Sign in STATUS_READ_OPTION_VALUE.
@access protected
@param string $sign Sign to handle
@param int $status Status Reference
@param string $buffer Argument Buffer Reference
@param string $option Option Buffer Reference
@return void | [
"Handles",
"current",
"Sign",
"in",
"STATUS_READ_OPTION_VALUE",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L199-L220 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.onReady | protected function onReady( $sign, &$status, &$buffer, &$option )
{
if( $sign == "-" )
{
$option = "";
$status = self::STATUS_READ_OPTION_KEY;
}
else if( preg_match( "@[a-z0-9]@i", $sign ) )
{
$buffer .= $sign;
$status = self::STATUS_READ_ARGUMENT;
}
} | php | protected function onReady( $sign, &$status, &$buffer, &$option )
{
if( $sign == "-" )
{
$option = "";
$status = self::STATUS_READ_OPTION_KEY;
}
else if( preg_match( "@[a-z0-9]@i", $sign ) )
{
$buffer .= $sign;
$status = self::STATUS_READ_ARGUMENT;
}
} | [
"protected",
"function",
"onReady",
"(",
"$",
"sign",
",",
"&",
"$",
"status",
",",
"&",
"$",
"buffer",
",",
"&",
"$",
"option",
")",
"{",
"if",
"(",
"$",
"sign",
"==",
"\"-\"",
")",
"{",
"$",
"option",
"=",
"\"\"",
";",
"$",
"status",
"=",
"se... | Handles current Sign in STATUS_READY.
@access protected
@param string $sign Sign to handle
@param int $status Status Reference
@param string $buffer Argument Buffer Reference
@param string $option Option Buffer Reference
@return void | [
"Handles",
"current",
"Sign",
"in",
"STATUS_READY",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L231-L243 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.parse | public function parse( $string )
{
if( !is_string( $string ) ) // no String given
throw new InvalidArgumentException( 'Given argument is not a string' ); // throw Exception
$this->extendPossibleOptionsWithShortcuts(); // realize Shortcuts
$position = 0; // initiate Sign Pointer
$status = self::STATUS_START; // initiate Status
$buffer = ""; // initiate Argument Buffer
$option = ""; // initiate Option Buffer
while( isset( $string[$position] ) ) // loop until End of String
{
$sign = $string[$position]; // get current Sign
$position ++; // increase Sign Pointer
switch( $status ) // handle Sign depending on Status
{
case self::STATUS_START: // open for all Signs
$this->onReady( $sign, $status, $buffer, $option ); // handle Sign
break;
case self::STATUS_READ_OPTION_KEY: // open for Option Key Signs
$this->onReadOptionKey( $sign, $status, $buffer, $option ); // handle Sign
break;
case self::STATUS_READ_OPTION_VALUE: // open for Option Value Signs
$this->onReadOptionValue( $sign, $status, $buffer, $option ); // handle Sign
break;
case self::STATUS_READ_ARGUMENT: // open for Argument Signs
$this->onReadArgument( $sign, $status, $buffer ); // handle Sign
break;
}
}
$this->onEndOfLine( $status, $buffer, $option ); // close open States
} | php | public function parse( $string )
{
if( !is_string( $string ) ) // no String given
throw new InvalidArgumentException( 'Given argument is not a string' ); // throw Exception
$this->extendPossibleOptionsWithShortcuts(); // realize Shortcuts
$position = 0; // initiate Sign Pointer
$status = self::STATUS_START; // initiate Status
$buffer = ""; // initiate Argument Buffer
$option = ""; // initiate Option Buffer
while( isset( $string[$position] ) ) // loop until End of String
{
$sign = $string[$position]; // get current Sign
$position ++; // increase Sign Pointer
switch( $status ) // handle Sign depending on Status
{
case self::STATUS_START: // open for all Signs
$this->onReady( $sign, $status, $buffer, $option ); // handle Sign
break;
case self::STATUS_READ_OPTION_KEY: // open for Option Key Signs
$this->onReadOptionKey( $sign, $status, $buffer, $option ); // handle Sign
break;
case self::STATUS_READ_OPTION_VALUE: // open for Option Value Signs
$this->onReadOptionValue( $sign, $status, $buffer, $option ); // handle Sign
break;
case self::STATUS_READ_ARGUMENT: // open for Argument Signs
$this->onReadArgument( $sign, $status, $buffer ); // handle Sign
break;
}
}
$this->onEndOfLine( $status, $buffer, $option ); // close open States
} | [
"public",
"function",
"parse",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"string",
")",
")",
"// no String given",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Given argument is not a string'",
")",
";",
"// throw Exception",
"$"... | Parses given Argument String and extracts Arguments and Options.
@access public
@param string $string String of Arguments and Options
@return void | [
"Parses",
"given",
"Argument",
"String",
"and",
"extracts",
"Arguments",
"and",
"Options",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L251-L285 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.setNumberOfMandatoryArguments | public function setNumberOfMandatoryArguments( $number = 0 )
{
if( !is_int( $number ) ) // no Integer given
throw new InvalidArgument( 'No integer given' ); // throw Exception
if( $number === $this->numberArguments ) // this Number is already set
return FALSE; // do nothing
$this->numberArguments = $number; // set new Argument Number
return TRUE; // indicate Success
} | php | public function setNumberOfMandatoryArguments( $number = 0 )
{
if( !is_int( $number ) ) // no Integer given
throw new InvalidArgument( 'No integer given' ); // throw Exception
if( $number === $this->numberArguments ) // this Number is already set
return FALSE; // do nothing
$this->numberArguments = $number; // set new Argument Number
return TRUE; // indicate Success
} | [
"public",
"function",
"setNumberOfMandatoryArguments",
"(",
"$",
"number",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"number",
")",
")",
"// no Integer given",
"throw",
"new",
"InvalidArgument",
"(",
"'No integer given'",
")",
";",
"// throw Exce... | Sets mininum Number of Arguments.
@access public
@param int $number Minimum Number of Arguments
@return bool | [
"Sets",
"mininum",
"Number",
"of",
"Arguments",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L293-L301 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.setPossibleOptions | public function setPossibleOptions( $options )
{
if( !is_array( $options ) ) // no Array given
throw InvalidArgumentException( 'No array given.' ); // throw Exception
if( $options === $this->possibleOptions ) // threse Options are already set
return FALSE; // do nothing
$this->possibleOptions = $options; // set new Options
return TRUE; // indicate Success
} | php | public function setPossibleOptions( $options )
{
if( !is_array( $options ) ) // no Array given
throw InvalidArgumentException( 'No array given.' ); // throw Exception
if( $options === $this->possibleOptions ) // threse Options are already set
return FALSE; // do nothing
$this->possibleOptions = $options; // set new Options
return TRUE; // indicate Success
} | [
"public",
"function",
"setPossibleOptions",
"(",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"options",
")",
")",
"// no Array given",
"throw",
"InvalidArgumentException",
"(",
"'No array given.'",
")",
";",
"// throw Exception",
"if",
"(",
... | Sets Map of Options with optional Regex Patterns.
@access public
@param array $options Map of Options and their Regex Patterns (or empty for a Non-Value-Option)
@return bool | [
"Sets",
"Map",
"of",
"Options",
"with",
"optional",
"Regex",
"Patterns",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L309-L317 | train |
CeusMedia/Common | src/CLI/Command/ArgumentParser.php | CLI_Command_ArgumentParser.setShortcuts | public function setShortcuts( $shortcuts )
{
if( !is_array( $shortcuts ) ) // no Array given
throw InvalidArgumentException( 'No array given.' ); // throw Exception
foreach( $shortcuts as $short => $long ) // iterate Shortcuts
if( !array_key_exists( $long, $this->possibleOptions ) ) // related Option is not set
throw new OutOfBoundsException( 'Option "'.$long.'" not set' ); // throw Exception
if( $shortcuts === $this->shortcuts ) // these Shortcuts are already set
return FALSE; // do nothing
$this->shortcuts = $shortcuts; // set new Shortcuts
return TRUE; // indicate Success
} | php | public function setShortcuts( $shortcuts )
{
if( !is_array( $shortcuts ) ) // no Array given
throw InvalidArgumentException( 'No array given.' ); // throw Exception
foreach( $shortcuts as $short => $long ) // iterate Shortcuts
if( !array_key_exists( $long, $this->possibleOptions ) ) // related Option is not set
throw new OutOfBoundsException( 'Option "'.$long.'" not set' ); // throw Exception
if( $shortcuts === $this->shortcuts ) // these Shortcuts are already set
return FALSE; // do nothing
$this->shortcuts = $shortcuts; // set new Shortcuts
return TRUE; // indicate Success
} | [
"public",
"function",
"setShortcuts",
"(",
"$",
"shortcuts",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"shortcuts",
")",
")",
"// no Array given",
"throw",
"InvalidArgumentException",
"(",
"'No array given.'",
")",
";",
"// throw Exception",
"foreach",
"("... | Sets Map between Shortcuts and afore set Options.
@access public
@param array $shortcuts Array of Shortcuts for Options
@return bool | [
"Sets",
"Map",
"between",
"Shortcuts",
"and",
"afore",
"set",
"Options",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Command/ArgumentParser.php#L325-L336 | train |
CeusMedia/Common | src/Net/HTTP/PartitionCookie.php | Net_HTTP_PartitionCookie.set | public function set( $key, $value, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$key = str_replace( ".", "_", $key );
$this->data[$key] = $value;
$this->save( $path, $domain, $secure, $httpOnly );
} | php | public function set( $key, $value, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$key = str_replace( ".", "_", $key );
$this->data[$key] = $value;
$this->save( $path, $domain, $secure, $httpOnly );
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"path",
"=",
"NULL",
",",
"$",
"domain",
"=",
"NULL",
",",
"$",
"secure",
"=",
"NULL",
",",
"$",
"httpOnly",
"=",
"NULL",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
... | Sets a Cookie to this PartitionCookie.
@access public
@param string $key Key of Cookie
@param string $value Value of Cookie
@param string $path Path of cookie
@param string $domain Domain of cookie
@param boolean $secure Flag: only with secured HTTPS connection
@param boolean $httponly Flag: allow access via HTTP protocol only
@return void | [
"Sets",
"a",
"Cookie",
"to",
"this",
"PartitionCookie",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PartitionCookie.php#L91-L96 | train |
CeusMedia/Common | src/Net/HTTP/PartitionCookie.php | Net_HTTP_PartitionCookie.save | protected function save( $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$value = json_encode( $this->data );
$path = $path !== NULL ? $path : $this->path;
$domain = $domain !== NULL ? $domain : $this->domain;
$secure = $secure !== NULL ? $secure : $this->secure;
$httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly;
setCookie( $this->partition, $value, $path, $domain, $secure, $httpOnly );
} | php | protected function save( $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$value = json_encode( $this->data );
$path = $path !== NULL ? $path : $this->path;
$domain = $domain !== NULL ? $domain : $this->domain;
$secure = $secure !== NULL ? $secure : $this->secure;
$httpOnly = $httpOnly !== NULL ? $httpOnly : $this->httpOnly;
setCookie( $this->partition, $value, $path, $domain, $secure, $httpOnly );
} | [
"protected",
"function",
"save",
"(",
"$",
"path",
"=",
"NULL",
",",
"$",
"domain",
"=",
"NULL",
",",
"$",
"secure",
"=",
"NULL",
",",
"$",
"httpOnly",
"=",
"NULL",
")",
"{",
"$",
"value",
"=",
"json_encode",
"(",
"$",
"this",
"->",
"data",
")",
... | Saves PartitionCookie by sending to Browser.
@access protected
@return void | [
"Saves",
"PartitionCookie",
"by",
"sending",
"to",
"Browser",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PartitionCookie.php#L103-L111 | train |
CeusMedia/Common | src/Net/HTTP/PartitionCookie.php | Net_HTTP_PartitionCookie.remove | public function remove( $key, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$key = str_replace( ".", "_", $key );
if( !isset( $this->data[$key] ) )
return;
unset( $this->data[$key] );
$this->save( $path, $domain, $secure, $httpOnly );
} | php | public function remove( $key, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL )
{
$key = str_replace( ".", "_", $key );
if( !isset( $this->data[$key] ) )
return;
unset( $this->data[$key] );
$this->save( $path, $domain, $secure, $httpOnly );
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
",",
"$",
"path",
"=",
"NULL",
",",
"$",
"domain",
"=",
"NULL",
",",
"$",
"secure",
"=",
"NULL",
",",
"$",
"httpOnly",
"=",
"NULL",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"\".\"",
",",
"\"_... | Removes a cookie part.
@access public
@param string $key Key of cookie part
@param string $path Default path of cookie
@param string $domain Domain of cookie
@param boolean $secure Flag: only with secured HTTPS connection
@param boolean $httponly Flag: allow access via HTTP protocol only
@return void | [
"Removes",
"a",
"cookie",
"part",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/PartitionCookie.php#L123-L130 | train |
ncou/Chiron | src/Chiron/Handler/Reporter/LoggerReporter.php | LoggerReporter.setLogLevelThreshold | public function setLogLevelThreshold(string $logLevelThreshold): void
{
if (! array_key_exists($logLevelThreshold, $this->logLevels)) {
throw new InvalidArgumentException('Invalid log level. Must be one of : ' . implode(', ', array_keys($this->logLevels)));
}
$this->logLevelThreshold = $logLevelThreshold;
} | php | public function setLogLevelThreshold(string $logLevelThreshold): void
{
if (! array_key_exists($logLevelThreshold, $this->logLevels)) {
throw new InvalidArgumentException('Invalid log level. Must be one of : ' . implode(', ', array_keys($this->logLevels)));
}
$this->logLevelThreshold = $logLevelThreshold;
} | [
"public",
"function",
"setLogLevelThreshold",
"(",
"string",
"$",
"logLevelThreshold",
")",
":",
"void",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"logLevelThreshold",
",",
"$",
"this",
"->",
"logLevels",
")",
")",
"{",
"throw",
"new",
"InvalidArgumen... | Sets the Log Level Threshold.
@param string $logLevelThreshold The log level threshold | [
"Sets",
"the",
"Log",
"Level",
"Threshold",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Reporter/LoggerReporter.php#L103-L110 | train |
ncou/Chiron | src/Chiron/Handler/Reporter/LoggerReporter.php | LoggerReporter.getLogLevel | private function getLogLevel(Throwable $e): string
{
if ($e instanceof ErrorException && array_key_exists($e->getSeverity(), $this->levelMap)) {
return $this->levelMap[$e->getSeverity()];
}
// default log level for Throwable
return LogLevel::CRITICAL;
} | php | private function getLogLevel(Throwable $e): string
{
if ($e instanceof ErrorException && array_key_exists($e->getSeverity(), $this->levelMap)) {
return $this->levelMap[$e->getSeverity()];
}
// default log level for Throwable
return LogLevel::CRITICAL;
} | [
"private",
"function",
"getLogLevel",
"(",
"Throwable",
"$",
"e",
")",
":",
"string",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"ErrorException",
"&&",
"array_key_exists",
"(",
"$",
"e",
"->",
"getSeverity",
"(",
")",
",",
"$",
"this",
"->",
"levelMap",
")... | Get log level to use for the PSR3 Logger.
By default for the NON 'ErrorException' exception it will always be 'CRITICAL'.
@param Throwable $e
@return string | [
"Get",
"log",
"level",
"to",
"use",
"for",
"the",
"PSR3",
"Logger",
".",
"By",
"default",
"for",
"the",
"NON",
"ErrorException",
"exception",
"it",
"will",
"always",
"be",
"CRITICAL",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Reporter/LoggerReporter.php#L134-L142 | train |
ncou/Chiron | src/Chiron/Handler/Reporter/LoggerReporter.php | LoggerReporter.canReport | public function canReport(Throwable $e): bool
{
$level = $this->getLogLevel($e);
// TODO : utiliser la méthode shouldLog():bool
return $this->logLevels[$level] <= $this->logLevels[$this->logLevelThreshold];
} | php | public function canReport(Throwable $e): bool
{
$level = $this->getLogLevel($e);
// TODO : utiliser la méthode shouldLog():bool
return $this->logLevels[$level] <= $this->logLevels[$this->logLevelThreshold];
} | [
"public",
"function",
"canReport",
"(",
"Throwable",
"$",
"e",
")",
":",
"bool",
"{",
"$",
"level",
"=",
"$",
"this",
"->",
"getLogLevel",
"(",
"$",
"e",
")",
";",
"// TODO : utiliser la méthode shouldLog():bool",
"return",
"$",
"this",
"->",
"logLevels",
"[... | Can we report the exception?
@param \Throwable $e
@return bool | [
"Can",
"we",
"report",
"the",
"exception?"
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Reporter/LoggerReporter.php#L201-L207 | train |
CeusMedia/Common | src/XML/DOM/ObjectFileSerializer.php | XML_DOM_ObjectFileSerializer.serialize | public static function serialize( $object, $fileName )
{
$serial = parent::serialize( $object );
$file = new FS_File_Writer( $fileName );
return $file->writeString( $serial );
} | php | public static function serialize( $object, $fileName )
{
$serial = parent::serialize( $object );
$file = new FS_File_Writer( $fileName );
return $file->writeString( $serial );
} | [
"public",
"static",
"function",
"serialize",
"(",
"$",
"object",
",",
"$",
"fileName",
")",
"{",
"$",
"serial",
"=",
"parent",
"::",
"serialize",
"(",
"$",
"object",
")",
";",
"$",
"file",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"fileName",
")",
";",
... | Writes XML String from an Object to a File.
@access public
@static
@param mixed $object Object to serialize
@param string $fileName XML File to write to
@return void | [
"Writes",
"XML",
"String",
"from",
"an",
"Object",
"to",
"a",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectFileSerializer.php#L54-L59 | train |
CeusMedia/Common | src/Net/HTTP/Request/Sender.php | Net_HTTP_Request_Sender.send | public function send()
{
if( $this->method === 'POST' )
$this->addHeaderPair( 'Content-Length', mb_strlen( $this->data ) );
if( !$this->headers->getFieldsByName( 'connection' ) )
$this->addHeaderPair( 'Connection', 'close' );
$result = "";
$fp = fsockopen( $this->host, $this->port, $errno, $errstr, 2 );
if( !$fp )
throw new RuntimeException( $errstr.' ('.$errno.')' );
$uri = $this->uri/*.( $this->port ? ':'.$this->port : "" )*/;
$lines = array(
$this->method." ".$uri." HTTP/".$this->version,
$this->headers->render(),
);
if( $this->method === 'POST' )
$lines[] = $this->data;
$lines = join( "\r\n", $lines );
fwrite( $fp, $lines ); // send Request
while( !feof( $fp ) ) // receive Response
$result .= fgets( $fp, 1024 ); // collect Response chunks
fclose( $fp ); // close Connection
$response = Net_HTTP_Response_Parser::fromString( $result );
if( count( $response->getHeader( 'Location' ) ) ){
$location = array_shift( $response->getHeader( 'Location' ) );
$this->host = parse_url( $location->getValue(), PHP_URL_HOST );
$this->setPort( parse_url( $location->getValue(), PHP_URL_PORT ) );
$this->setUri( parse_url( $location->getValue(), PHP_URL_PATH ) );
return $this->send();
}
return $response;
} | php | public function send()
{
if( $this->method === 'POST' )
$this->addHeaderPair( 'Content-Length', mb_strlen( $this->data ) );
if( !$this->headers->getFieldsByName( 'connection' ) )
$this->addHeaderPair( 'Connection', 'close' );
$result = "";
$fp = fsockopen( $this->host, $this->port, $errno, $errstr, 2 );
if( !$fp )
throw new RuntimeException( $errstr.' ('.$errno.')' );
$uri = $this->uri/*.( $this->port ? ':'.$this->port : "" )*/;
$lines = array(
$this->method." ".$uri." HTTP/".$this->version,
$this->headers->render(),
);
if( $this->method === 'POST' )
$lines[] = $this->data;
$lines = join( "\r\n", $lines );
fwrite( $fp, $lines ); // send Request
while( !feof( $fp ) ) // receive Response
$result .= fgets( $fp, 1024 ); // collect Response chunks
fclose( $fp ); // close Connection
$response = Net_HTTP_Response_Parser::fromString( $result );
if( count( $response->getHeader( 'Location' ) ) ){
$location = array_shift( $response->getHeader( 'Location' ) );
$this->host = parse_url( $location->getValue(), PHP_URL_HOST );
$this->setPort( parse_url( $location->getValue(), PHP_URL_PORT ) );
$this->setUri( parse_url( $location->getValue(), PHP_URL_PATH ) );
return $this->send();
}
return $response;
} | [
"public",
"function",
"send",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"method",
"===",
"'POST'",
")",
"$",
"this",
"->",
"addHeaderPair",
"(",
"'Content-Length'",
",",
"mb_strlen",
"(",
"$",
"this",
"->",
"data",
")",
")",
";",
"if",
"(",
"!",
... | Sends data via prepared Request.
@access public
@return Net_HTTP_Response | [
"Sends",
"data",
"via",
"prepared",
"Request",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Request/Sender.php#L135-L168 | train |
johnnymast/redbox-dns | src/Resolver.php | Resolver.clear | public function clear()
{
$this->rewind();
$num = $this->count();
for ($i = 0; $i < $num; $i++) {
$this->offsetUnset($i);
}
} | php | public function clear()
{
$this->rewind();
$num = $this->count();
for ($i = 0; $i < $num; $i++) {
$this->offsetUnset($i);
}
} | [
"public",
"function",
"clear",
"(",
")",
"{",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"$",
"num",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"num",
";",
"$",
"i",
"++",
")"... | Clear the array | [
"Clear",
"the",
"array"
] | 2a2aa8aea3c84eb5e5abeb981f821f0756800d6b | https://github.com/johnnymast/redbox-dns/blob/2a2aa8aea3c84eb5e5abeb981f821f0756800d6b/src/Resolver.php#L10-L18 | train |
CeusMedia/Common | src/UI/VariableDumper.php | UI_VariableDumper.dump | public static function dump( $variable, $mode = self::MODE_DUMP, $modeIfNotXDebug = self::MODE_PRINT )
{
ob_start(); // open Buffer
$hasXDebug = extension_loaded( 'xdebug' ); // check for XDebug Extension
if( !$hasXDebug )
$mode = $modeIfNotXDebug;
switch( $mode )
{
case self::MODE_DUMP:
var_dump( $variable ); // print Variable Dump
if( !$hasXDebug )
{
$dump = ob_get_clean(); // get buffered Dump
$dump = preg_replace( "@=>\n +@", ": ", $dump ); // remove Line Break on Relations
$dump = str_replace( "{\n", "\n", $dump ); // remove Array Opener
$dump = str_replace( "}\n", "\n", $dump ); // remove Array Closer
$dump = str_replace( ' ["', " ", $dump ); // remove Variable Key Opener
$dump = str_replace( '"]:', ":", $dump ); // remove Variable Key Closer
$dump = preg_replace( '@string\([0-9]+\)@', "", $dump ); // remove Variable Type for Strings
$dump = preg_replace( '@array\([0-9]+\)@', "", $dump ); // remove Variable Type for Arrays
ob_start(); // open Buffer
xmp( $dump ); // print Dump with XMP
}
break;
case self::MODE_PRINT:
print_m( $variable, self::$modePrintIndentSign, self::$modePrintIndentSize ); // print Dump with indent
break;
}
return ob_get_clean(); // return buffered Dump
} | php | public static function dump( $variable, $mode = self::MODE_DUMP, $modeIfNotXDebug = self::MODE_PRINT )
{
ob_start(); // open Buffer
$hasXDebug = extension_loaded( 'xdebug' ); // check for XDebug Extension
if( !$hasXDebug )
$mode = $modeIfNotXDebug;
switch( $mode )
{
case self::MODE_DUMP:
var_dump( $variable ); // print Variable Dump
if( !$hasXDebug )
{
$dump = ob_get_clean(); // get buffered Dump
$dump = preg_replace( "@=>\n +@", ": ", $dump ); // remove Line Break on Relations
$dump = str_replace( "{\n", "\n", $dump ); // remove Array Opener
$dump = str_replace( "}\n", "\n", $dump ); // remove Array Closer
$dump = str_replace( ' ["', " ", $dump ); // remove Variable Key Opener
$dump = str_replace( '"]:', ":", $dump ); // remove Variable Key Closer
$dump = preg_replace( '@string\([0-9]+\)@', "", $dump ); // remove Variable Type for Strings
$dump = preg_replace( '@array\([0-9]+\)@', "", $dump ); // remove Variable Type for Arrays
ob_start(); // open Buffer
xmp( $dump ); // print Dump with XMP
}
break;
case self::MODE_PRINT:
print_m( $variable, self::$modePrintIndentSign, self::$modePrintIndentSize ); // print Dump with indent
break;
}
return ob_get_clean(); // return buffered Dump
} | [
"public",
"static",
"function",
"dump",
"(",
"$",
"variable",
",",
"$",
"mode",
"=",
"self",
"::",
"MODE_DUMP",
",",
"$",
"modeIfNotXDebug",
"=",
"self",
"::",
"MODE_PRINT",
")",
"{",
"ob_start",
"(",
")",
";",
"// open Buffer",
"$",
"hasXDebug",
"=",
"... | Creates readable Dump of a Variable, either with print_m or var_dump, depending on printMode and installed XDebug Extension
The custom method print_m creates lots of DOM Elements.
Having to much DOM Elements can be avoided by using var_dump, which now is called Print Mode.
But since XDebug extends var_dump it creates even way more DOM Elements.
So, you should use Print Mode and it will be disabled if XDebug is detected.
However, you can force to use Print Mode.
@access protected
@static
@param mixed $element Variable to be dumped
@param bool $forcePrintMode Flag: force to use var_dump even if XDebug is enabled (not recommended)
@return string | [
"Creates",
"readable",
"Dump",
"of",
"a",
"Variable",
"either",
"with",
"print_m",
"or",
"var_dump",
"depending",
"on",
"printMode",
"and",
"installed",
"XDebug",
"Extension"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/VariableDumper.php#L64-L93 | train |
CeusMedia/Common | src/UI/HTML/JQuery.php | UI_HTML_JQuery.buildPluginCall | public static function buildPluginCall( $plugin, $selector, $options = array(), $spaces = 0 )
{
$innerIndent = str_repeat( " ", $spaces + 2 );
$outerIndent = str_repeat( " ", $spaces );
$options = json_encode( $options );
$show = $selector ? '.show()' : "";
$selector = $selector ? '("'.$selector.'")' : "";
return $outerIndent.self::$jQueryFunctionName.'(document).ready(function(){
'.$innerIndent.self::$jQueryFunctionName.$selector.'.'.$plugin.'('.$options.')'.$show.';
'.$outerIndent.'});';
} | php | public static function buildPluginCall( $plugin, $selector, $options = array(), $spaces = 0 )
{
$innerIndent = str_repeat( " ", $spaces + 2 );
$outerIndent = str_repeat( " ", $spaces );
$options = json_encode( $options );
$show = $selector ? '.show()' : "";
$selector = $selector ? '("'.$selector.'")' : "";
return $outerIndent.self::$jQueryFunctionName.'(document).ready(function(){
'.$innerIndent.self::$jQueryFunctionName.$selector.'.'.$plugin.'('.$options.')'.$show.';
'.$outerIndent.'});';
} | [
"public",
"static",
"function",
"buildPluginCall",
"(",
"$",
"plugin",
",",
"$",
"selector",
",",
"$",
"options",
"=",
"array",
"(",
")",
",",
"$",
"spaces",
"=",
"0",
")",
"{",
"$",
"innerIndent",
"=",
"str_repeat",
"(",
"\" \"",
",",
"$",
"spaces",
... | Builds and returns JavaScript Code of jQuery Plugin Call.
@access public
@static
@param string $plugin Name of Plugin Constructor Methode
@param string $selector XPath Selector of HTML Tag(s) to call Plugin on
@param array $option Array of Plugin Constructor Options
@param int $spaces Number of indenting Whitespaces
@return string | [
"Builds",
"and",
"returns",
"JavaScript",
"Code",
"of",
"jQuery",
"Plugin",
"Call",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/JQuery.php#L55-L65 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Routing/RestRouter.php | RestRouter.getInstance | public static function getInstance(RoutingConfiguration $configuration, Request $request): RestRouter
{
if (null === self::$instance) {
self::$instance = new RestRouter($configuration, $request);
}
return self::$instance;
} | php | public static function getInstance(RoutingConfiguration $configuration, Request $request): RestRouter
{
if (null === self::$instance) {
self::$instance = new RestRouter($configuration, $request);
}
return self::$instance;
} | [
"public",
"static",
"function",
"getInstance",
"(",
"RoutingConfiguration",
"$",
"configuration",
",",
"Request",
"$",
"request",
")",
":",
"RestRouter",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"instance",
")",
"{",
"self",
"::",
"$",
"instance",
... | Returns instance of router
@param RoutingConfiguration $configuration
@param Request $request
@return RestRouter | [
"Returns",
"instance",
"of",
"router"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/RestRouter.php#L77-L84 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Routing/RestRouter.php | RestRouter.resolveRoute | public function resolveRoute(): ?Route
{
$query = strtolower(rtrim($this->request->query->get('route'), '/'));
switch(true) {
case preg_match(self::WITH_IDENTIFIER_PATTERN, $query, $matches):
$route = $this->detectRouteForWithIdentifierPattern($matches);
break;
case preg_match(self::NO_IDENTIFIER_PATTERN, $query, $matches):
$route = $this->detectRouteForNoIdentifierPattern($matches);
break;
default:
return null;
}
return $route;
} | php | public function resolveRoute(): ?Route
{
$query = strtolower(rtrim($this->request->query->get('route'), '/'));
switch(true) {
case preg_match(self::WITH_IDENTIFIER_PATTERN, $query, $matches):
$route = $this->detectRouteForWithIdentifierPattern($matches);
break;
case preg_match(self::NO_IDENTIFIER_PATTERN, $query, $matches):
$route = $this->detectRouteForNoIdentifierPattern($matches);
break;
default:
return null;
}
return $route;
} | [
"public",
"function",
"resolveRoute",
"(",
")",
":",
"?",
"Route",
"{",
"$",
"query",
"=",
"strtolower",
"(",
"rtrim",
"(",
"$",
"this",
"->",
"request",
"->",
"query",
"->",
"get",
"(",
"'route'",
")",
",",
"'/'",
")",
")",
";",
"switch",
"(",
"tr... | Resolves route for requested action
@return Route? If route cannot be resolved, NULL is returned | [
"Resolves",
"route",
"for",
"requested",
"action"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/RestRouter.php#L91-L109 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Routing/RestRouter.php | RestRouter.detectRouteForWithIdentifierPattern | private function detectRouteForWithIdentifierPattern(array $matches): ?Route
{
$actions = [
'GET' => 'singleAction',
'PUT' => 'editAction',
'DELETE' => 'destroyAction'
];
if (!isset($actions[$this->request->getMethod()])) {
return null;
}
$controllerName = implode('', array_map('ucfirst', explode('-', $matches['controller'])));
$controller = $this->configuration->getControllerNamespace() . $controllerName . 'Controller';
return (new Route())
->setController($controller)
->setAction($actions[$this->request->getMethod()])
->setActionParams([$matches['id']]);
} | php | private function detectRouteForWithIdentifierPattern(array $matches): ?Route
{
$actions = [
'GET' => 'singleAction',
'PUT' => 'editAction',
'DELETE' => 'destroyAction'
];
if (!isset($actions[$this->request->getMethod()])) {
return null;
}
$controllerName = implode('', array_map('ucfirst', explode('-', $matches['controller'])));
$controller = $this->configuration->getControllerNamespace() . $controllerName . 'Controller';
return (new Route())
->setController($controller)
->setAction($actions[$this->request->getMethod()])
->setActionParams([$matches['id']]);
} | [
"private",
"function",
"detectRouteForWithIdentifierPattern",
"(",
"array",
"$",
"matches",
")",
":",
"?",
"Route",
"{",
"$",
"actions",
"=",
"[",
"'GET'",
"=>",
"'singleAction'",
",",
"'PUT'",
"=>",
"'editAction'",
",",
"'DELETE'",
"=>",
"'destroyAction'",
"]",... | Returns route for WITH_IDENTIFIER query pattern
@param array $matches Result of regular expression match
@return Route? | [
"Returns",
"route",
"for",
"WITH_IDENTIFIER",
"query",
"pattern"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Routing/RestRouter.php#L117-L136 | train |
CeusMedia/Common | src/UI/Image/Graph/Generator.php | UI_Image_Graph_Generator.extendConfigByLabels | protected function extendConfigByLabels( $labels, $request = array() )
{
foreach( $request as $key => $value )
{
$key = str_replace( "_", ".", $key );
if( array_key_exists( $key, $labels ) )
$labels[$key] = $value;
}
foreach( $this->config as $key => $value )
$this->config[$key] = UI_Template::renderString( $value, $labels );
} | php | protected function extendConfigByLabels( $labels, $request = array() )
{
foreach( $request as $key => $value )
{
$key = str_replace( "_", ".", $key );
if( array_key_exists( $key, $labels ) )
$labels[$key] = $value;
}
foreach( $this->config as $key => $value )
$this->config[$key] = UI_Template::renderString( $value, $labels );
} | [
"protected",
"function",
"extendConfigByLabels",
"(",
"$",
"labels",
",",
"$",
"request",
"=",
"array",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"request",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"\"_\"",
... | Extends already set Configuration Data by setting in Labels for Placeholders.
@access protected
@param array $labels Map of Labels to set in
@param array $request Request Parameters to extend Labels
@return void | [
"Extends",
"already",
"set",
"Configuration",
"Data",
"by",
"setting",
"in",
"Labels",
"for",
"Placeholders",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Generator.php#L77-L88 | train |
CeusMedia/Common | src/UI/Image/Graph/Generator.php | UI_Image_Graph_Generator.extendConfigByRequest | protected function extendConfigByRequest( $parameters )
{
foreach( $parameters as $key => $value )
{
$key = str_replace( "_", ".", $key );
if( array_key_exists( $key, $this->config ) )
$this->config[$key] = $value;
}
} | php | protected function extendConfigByRequest( $parameters )
{
foreach( $parameters as $key => $value )
{
$key = str_replace( "_", ".", $key );
if( array_key_exists( $key, $this->config ) )
$this->config[$key] = $value;
}
} | [
"protected",
"function",
"extendConfigByRequest",
"(",
"$",
"parameters",
")",
"{",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"str_replace",
"(",
"\"_\"",
",",
"\".\"",
",",
"$",
"key",
")",
";"... | Extends already set Configuration Data by Request Parameters.
@access protected
@param array $parameters Map of Request Parameters
@return void | [
"Extends",
"already",
"set",
"Configuration",
"Data",
"by",
"Request",
"Parameters",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Generator.php#L96-L104 | train |
CeusMedia/Common | src/UI/Image/Graph/Generator.php | UI_Image_Graph_Generator.loadJpGraph | protected function loadJpGraph( $types = array() )
{
if( $this->pathJpGraph === NULL )
throw new RuntimeException( 'Path to JpGraph has not been set.' );
$types = explode( ",", $types );
require_once( $this->pathJpGraph."src/jpgraph.php" );
foreach( $types as $type )
{
$plotType = strtolower( trim( $type ) );
$fileName = $this->pathJpGraph."src/jpgraph_".$plotType.".php";
require_once( $fileName );
}
} | php | protected function loadJpGraph( $types = array() )
{
if( $this->pathJpGraph === NULL )
throw new RuntimeException( 'Path to JpGraph has not been set.' );
$types = explode( ",", $types );
require_once( $this->pathJpGraph."src/jpgraph.php" );
foreach( $types as $type )
{
$plotType = strtolower( trim( $type ) );
$fileName = $this->pathJpGraph."src/jpgraph_".$plotType.".php";
require_once( $fileName );
}
} | [
"protected",
"function",
"loadJpGraph",
"(",
"$",
"types",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pathJpGraph",
"===",
"NULL",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Path to JpGraph has not been set.'",
")",
";",
"$",
"type... | Loads JpGraph Base Class and all given Plot Type Classes.
@access protected
@param array $type List of Plot Types (e.g. 'line' for 'graph_lineplot.php')
@return void | [
"Loads",
"JpGraph",
"Base",
"Class",
"and",
"all",
"given",
"Plot",
"Type",
"Classes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/Graph/Generator.php#L112-L124 | train |
CeusMedia/Common | src/DB/Result.php | DB_Result.fetchObject | public function fetchObject()
{
if( isset( $this->rows[$this->cursor] ) )
return $this->rows[$this->cursor];
return FALSE;
} | php | public function fetchObject()
{
if( isset( $this->rows[$this->cursor] ) )
return $this->rows[$this->cursor];
return FALSE;
} | [
"public",
"function",
"fetchObject",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"rows",
"[",
"$",
"this",
"->",
"cursor",
"]",
")",
")",
"return",
"$",
"this",
"->",
"rows",
"[",
"$",
"this",
"->",
"cursor",
"]",
";",
"return",
"F... | Returns found row in this result.
@access public
@return Object | [
"Returns",
"found",
"row",
"in",
"this",
"result",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/Result.php#L145-L150 | train |
CeusMedia/Common | src/DB/PDO/DataSourceName.php | DB_PDO_DataSourceName.checkDriverSupport | protected function checkDriverSupport( $driver ){
if( !in_array( $driver, $this->drivers ) )
throw new \RuntimeException( 'PDO driver "'.$driver.'" is not supported' );
if( !in_array( $driver, \PDO::getAvailableDrivers() ) )
throw new \RuntimeException( 'PDO driver "'.$driver.'" is not loaded' );
} | php | protected function checkDriverSupport( $driver ){
if( !in_array( $driver, $this->drivers ) )
throw new \RuntimeException( 'PDO driver "'.$driver.'" is not supported' );
if( !in_array( $driver, \PDO::getAvailableDrivers() ) )
throw new \RuntimeException( 'PDO driver "'.$driver.'" is not loaded' );
} | [
"protected",
"function",
"checkDriverSupport",
"(",
"$",
"driver",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"driver",
",",
"$",
"this",
"->",
"drivers",
")",
")",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'PDO driver \"'",
".",
"$",
"driver",
... | Checks whether current Driver is installed with PHP and supported by Class.
@access protected
@param string $driver Driver Name to check (lowercase)
@return void
@throws RuntimeException if PDO Driver is not supported
@throws RuntimeException if PDO Driver is not loaded | [
"Checks",
"whether",
"current",
"Driver",
"is",
"installed",
"with",
"PHP",
"and",
"supported",
"by",
"Class",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/DataSourceName.php#L106-L111 | train |
CeusMedia/Common | src/DB/PDO/DataSourceName.php | DB_PDO_DataSourceName.renderStatic | public static function renderStatic( $driver, $database, $host = NULL, $port = NULL, $username = NULL, $password = NULL ){
$dsn = new self( $driver, $database );
$dsn->setHost( $host );
$dsn->setPort( $port );
$dsn->setUsername( $username );
$dsn->setPassword( $password );
return $dsn->render();
} | php | public static function renderStatic( $driver, $database, $host = NULL, $port = NULL, $username = NULL, $password = NULL ){
$dsn = new self( $driver, $database );
$dsn->setHost( $host );
$dsn->setPort( $port );
$dsn->setUsername( $username );
$dsn->setPassword( $password );
return $dsn->render();
} | [
"public",
"static",
"function",
"renderStatic",
"(",
"$",
"driver",
",",
"$",
"database",
",",
"$",
"host",
"=",
"NULL",
",",
"$",
"port",
"=",
"NULL",
",",
"$",
"username",
"=",
"NULL",
",",
"$",
"password",
"=",
"NULL",
")",
"{",
"$",
"dsn",
"=",... | Returns Data Source Name String.
@access public
@static
@param string $driver Database Driver (cubrid|dblib|firebird|informix|mysql|mssql|oci|odbc|pgsql|sqlite|sybase)
@param string $database Database Name
@param string $host Host Name or URI
@param int $port Host Port
@param string $username Username
@param string $password Password
@return string | [
"Returns",
"Data",
"Source",
"Name",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/DataSourceName.php#L290-L297 | train |
smasty/Neevo | src/Neevo/Result.php | Result.group | public function group($rule, $having = null){
if($this->validateConditions())
return $this;
$this->resetState();
$this->grouping = array($rule, $having);
return $this;
} | php | public function group($rule, $having = null){
if($this->validateConditions())
return $this;
$this->resetState();
$this->grouping = array($rule, $having);
return $this;
} | [
"public",
"function",
"group",
"(",
"$",
"rule",
",",
"$",
"having",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateConditions",
"(",
")",
")",
"return",
"$",
"this",
";",
"$",
"this",
"->",
"resetState",
"(",
")",
";",
"$",
"this",
... | Defines grouping rule.
@param string $rule
@param string $having Optional
@return Result fluent interface | [
"Defines",
"grouping",
"rule",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L123-L130 | train |
smasty/Neevo | src/Neevo/Result.php | Result.join | public function join($source, $condition){
if($this->validateConditions())
return $this;
if(!(is_string($source) || $source instanceof self || $source instanceof Literal))
throw new InvalidArgumentException('Argument 1 must be a string, Neevo\\Literal or Neevo\\Result.');
if(!(is_string($condition) || $condition instanceof Literal))
throw new InvalidArgumentException('Argument 2 must be a string or Neevo\\Literal.');
if($source instanceof self)
$this->subqueries[] = $source;
$this->resetState();
$type = (func_num_args() > 2) ? func_get_arg(2) : '';
$this->joins[] = array($source, $condition, $type);
return $this;
} | php | public function join($source, $condition){
if($this->validateConditions())
return $this;
if(!(is_string($source) || $source instanceof self || $source instanceof Literal))
throw new InvalidArgumentException('Argument 1 must be a string, Neevo\\Literal or Neevo\\Result.');
if(!(is_string($condition) || $condition instanceof Literal))
throw new InvalidArgumentException('Argument 2 must be a string or Neevo\\Literal.');
if($source instanceof self)
$this->subqueries[] = $source;
$this->resetState();
$type = (func_num_args() > 2) ? func_get_arg(2) : '';
$this->joins[] = array($source, $condition, $type);
return $this;
} | [
"public",
"function",
"join",
"(",
"$",
"source",
",",
"$",
"condition",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"validateConditions",
"(",
")",
")",
"return",
"$",
"this",
";",
"if",
"(",
"!",
"(",
"is_string",
"(",
"$",
"source",
")",
"||",
"$",
... | Performs JOIN on tables.
@param string|Result|Literal $source Table name or subquery
@param string|Literal $condition
@return Result fluent interface | [
"Performs",
"JOIN",
"on",
"tables",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L139-L157 | train |
smasty/Neevo | src/Neevo/Result.php | Result.page | public function page($page, $items){
if($page < 1 || $items < 1)
throw new InvalidArgumentException('Arguments must be positive integers.');
return $this->limit((int) $items, (int) ($items * --$page));
} | php | public function page($page, $items){
if($page < 1 || $items < 1)
throw new InvalidArgumentException('Arguments must be positive integers.');
return $this->limit((int) $items, (int) ($items * --$page));
} | [
"public",
"function",
"page",
"(",
"$",
"page",
",",
"$",
"items",
")",
"{",
"if",
"(",
"$",
"page",
"<",
"1",
"||",
"$",
"items",
"<",
"1",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Arguments must be positive integers.'",
")",
";",
"return",... | Adjusts the LIMIT and OFFSET clauses according to defined page number and number of items per page.
@param int $page Page number
@param int $items Number of items per page
@return Result fluent interface
@throws InvalidArgumentException | [
"Adjusts",
"the",
"LIMIT",
"and",
"OFFSET",
"clauses",
"according",
"to",
"defined",
"page",
"number",
"and",
"number",
"of",
"items",
"per",
"page",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L189-L193 | train |
smasty/Neevo | src/Neevo/Result.php | Result.fetch | public function fetch(){
$this->performed || $this->run();
$row = $this->connection->getDriver()->fetch($this->resultSet);
if(!is_array($row))
return false;
// Type converting
if($this->detectTypes)
$this->detectTypes();
if(!empty($this->columnTypes)){
foreach($this->columnTypes as $col => $type){
if(isset($row[$col]))
$row[$col] = $this->convertType($row[$col], $type);
}
}
return new $this->rowClass($row, $this);
} | php | public function fetch(){
$this->performed || $this->run();
$row = $this->connection->getDriver()->fetch($this->resultSet);
if(!is_array($row))
return false;
// Type converting
if($this->detectTypes)
$this->detectTypes();
if(!empty($this->columnTypes)){
foreach($this->columnTypes as $col => $type){
if(isset($row[$col]))
$row[$col] = $this->convertType($row[$col], $type);
}
}
return new $this->rowClass($row, $this);
} | [
"public",
"function",
"fetch",
"(",
")",
"{",
"$",
"this",
"->",
"performed",
"||",
"$",
"this",
"->",
"run",
"(",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"connection",
"->",
"getDriver",
"(",
")",
"->",
"fetch",
"(",
"$",
"this",
"->",
"re... | Fetches the row on current position.
@return Row|bool | [
"Fetches",
"the",
"row",
"on",
"current",
"position",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L200-L217 | train |
smasty/Neevo | src/Neevo/Result.php | Result.fetchAll | public function fetchAll($limit = null, $offset = null){
$limit = $limit === null ? -1 : (int) $limit;
if($offset !== null)
$this->seek((int) $offset);
$row = $this->fetch();
if(!$row)
return array();
$rows = array();
do{
if($limit === 0)
break;
$rows[] = $row;
$limit--;
} while($row = $this->fetch());
return $rows;
} | php | public function fetchAll($limit = null, $offset = null){
$limit = $limit === null ? -1 : (int) $limit;
if($offset !== null)
$this->seek((int) $offset);
$row = $this->fetch();
if(!$row)
return array();
$rows = array();
do{
if($limit === 0)
break;
$rows[] = $row;
$limit--;
} while($row = $this->fetch());
return $rows;
} | [
"public",
"function",
"fetchAll",
"(",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"limit",
"=",
"$",
"limit",
"===",
"null",
"?",
"-",
"1",
":",
"(",
"int",
")",
"$",
"limit",
";",
"if",
"(",
"$",
"offset",
"!=="... | Fetches all rows in result set.
@param int $limit Limit number of returned rows
@param int $offset Seek to offset (fails on unbuffered results)
@return Row[] | [
"Fetches",
"all",
"rows",
"in",
"result",
"set",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L226-L244 | train |
smasty/Neevo | src/Neevo/Result.php | Result.fetchSingle | public function fetchSingle(){
$this->performed || $this->run();
$row = $this->connection->getDriver()->fetch($this->resultSet);
if(!$row)
return false;
$value = reset($row);
// Type converting
if($this->detectTypes)
$this->detectTypes();
if(!empty($this->columnTypes)){
$key = key($row);
if(isset($this->columnTypes[$key]))
$value = $this->convertType($value, $this->columnTypes[$key]);
}
return $value;
} | php | public function fetchSingle(){
$this->performed || $this->run();
$row = $this->connection->getDriver()->fetch($this->resultSet);
if(!$row)
return false;
$value = reset($row);
// Type converting
if($this->detectTypes)
$this->detectTypes();
if(!empty($this->columnTypes)){
$key = key($row);
if(isset($this->columnTypes[$key]))
$value = $this->convertType($value, $this->columnTypes[$key]);
}
return $value;
} | [
"public",
"function",
"fetchSingle",
"(",
")",
"{",
"$",
"this",
"->",
"performed",
"||",
"$",
"this",
"->",
"run",
"(",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"connection",
"->",
"getDriver",
"(",
")",
"->",
"fetch",
"(",
"$",
"this",
"->",... | Fetches the first value from current row.
@return mixed | [
"Fetches",
"the",
"first",
"value",
"from",
"current",
"row",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L251-L269 | train |
smasty/Neevo | src/Neevo/Result.php | Result.seek | public function seek($offset){
$this->performed || $this->run();
$seek = $this->connection->getDriver()->seek($this->resultSet, $offset);
if($seek)
return $seek;
throw new NeevoException("Cannot seek to offset $offset.");
} | php | public function seek($offset){
$this->performed || $this->run();
$seek = $this->connection->getDriver()->seek($this->resultSet, $offset);
if($seek)
return $seek;
throw new NeevoException("Cannot seek to offset $offset.");
} | [
"public",
"function",
"seek",
"(",
"$",
"offset",
")",
"{",
"$",
"this",
"->",
"performed",
"||",
"$",
"this",
"->",
"run",
"(",
")",
";",
"$",
"seek",
"=",
"$",
"this",
"->",
"connection",
"->",
"getDriver",
"(",
")",
"->",
"seek",
"(",
"$",
"th... | Moves internal result pointer.
@param int $offset
@return bool
@throws NeevoException | [
"Moves",
"internal",
"result",
"pointer",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L308-L314 | train |
smasty/Neevo | src/Neevo/Result.php | Result.count | public function count($column = null){
if($column === null){
$this->performed || $this->run();
return (int) $this->connection->getDriver()->getNumRows($this->resultSet);
}
return $this->aggregation("COUNT(:$column)");
} | php | public function count($column = null){
if($column === null){
$this->performed || $this->run();
return (int) $this->connection->getDriver()->getNumRows($this->resultSet);
}
return $this->aggregation("COUNT(:$column)");
} | [
"public",
"function",
"count",
"(",
"$",
"column",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"column",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"performed",
"||",
"$",
"this",
"->",
"run",
"(",
")",
";",
"return",
"(",
"int",
")",
"$",
"this",
... | Counts number of rows.
@param string $column
@return int
@throws DriverException | [
"Counts",
"number",
"of",
"rows",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L328-L334 | train |
smasty/Neevo | src/Neevo/Result.php | Result.explain | public function explain(){
$driver = $this->getConnection()->getDriver();
$query = $driver->runQuery("EXPLAIN $this");
$rows = array();
while($row = $driver->fetch($query)){
$rows[] = $row;
}
return $rows;
} | php | public function explain(){
$driver = $this->getConnection()->getDriver();
$query = $driver->runQuery("EXPLAIN $this");
$rows = array();
while($row = $driver->fetch($query)){
$rows[] = $row;
}
return $rows;
} | [
"public",
"function",
"explain",
"(",
")",
"{",
"$",
"driver",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"getDriver",
"(",
")",
";",
"$",
"query",
"=",
"$",
"driver",
"->",
"runQuery",
"(",
"\"EXPLAIN $this\"",
")",
";",
"$",
"rows",
"... | Explains performed query.
@return array | [
"Explains",
"performed",
"query",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L383-L393 | train |
smasty/Neevo | src/Neevo/Result.php | Result.setTypes | public function setTypes($types){
if(!($types instanceof Traversable || is_array($types)))
throw new InvalidArgumentException('Argument 1 must be an array or Traversable.');
foreach($types as $column => $type){
$this->setType($column, $type);
}
return $this;
} | php | public function setTypes($types){
if(!($types instanceof Traversable || is_array($types)))
throw new InvalidArgumentException('Argument 1 must be an array or Traversable.');
foreach($types as $column => $type){
$this->setType($column, $type);
}
return $this;
} | [
"public",
"function",
"setTypes",
"(",
"$",
"types",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"types",
"instanceof",
"Traversable",
"||",
"is_array",
"(",
"$",
"types",
")",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Argument 1 must be an array or... | Sets multiple column types at once.
@param array|Traversable $types
@return Result fluent interface | [
"Sets",
"multiple",
"column",
"types",
"at",
"once",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L413-L420 | train |
smasty/Neevo | src/Neevo/Result.php | Result.detectTypes | public function detectTypes(){
$table = $this->getTable();
$this->performed || $this->run();
// Try fetch from cache
$types = (array) $this->connection->getCache()->fetch($table . '_detectedTypes');
if(empty($types)){
try{
$types = $this->connection->getDriver()->getColumnTypes($this->resultSet, $table);
} catch(NeevoException $e){
return $this;
}
}
foreach((array) $types as $col => $type){
$this->columnTypes[$col] = $this->resolveType($type);
}
$this->connection->getCache()->store($table . '_detectedTypes', $this->columnTypes);
return $this;
} | php | public function detectTypes(){
$table = $this->getTable();
$this->performed || $this->run();
// Try fetch from cache
$types = (array) $this->connection->getCache()->fetch($table . '_detectedTypes');
if(empty($types)){
try{
$types = $this->connection->getDriver()->getColumnTypes($this->resultSet, $table);
} catch(NeevoException $e){
return $this;
}
}
foreach((array) $types as $col => $type){
$this->columnTypes[$col] = $this->resolveType($type);
}
$this->connection->getCache()->store($table . '_detectedTypes', $this->columnTypes);
return $this;
} | [
"public",
"function",
"detectTypes",
"(",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"getTable",
"(",
")",
";",
"$",
"this",
"->",
"performed",
"||",
"$",
"this",
"->",
"run",
"(",
")",
";",
"// Try fetch from cache",
"$",
"types",
"=",
"(",
"ar... | Detects column types.
@return Result fluent interface | [
"Detects",
"column",
"types",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L427-L448 | train |
smasty/Neevo | src/Neevo/Result.php | Result.resolveType | protected function resolveType($type){
static $patterns = array(
'bool|bit' => Manager::BOOL,
'bin|blob|bytea' => Manager::BINARY,
'string|char|text|bigint|longlong' => Manager::TEXT,
'int|long|byte|serial|counter' => Manager::INT,
'float|real|double|numeric|number|decimal|money|currency' => Manager::FLOAT,
'time|date|year' => Manager::DATETIME
);
foreach($patterns as $vendor => $universal){
if(preg_match("~$vendor~i", $type))
return $universal;
}
return Manager::TEXT;
} | php | protected function resolveType($type){
static $patterns = array(
'bool|bit' => Manager::BOOL,
'bin|blob|bytea' => Manager::BINARY,
'string|char|text|bigint|longlong' => Manager::TEXT,
'int|long|byte|serial|counter' => Manager::INT,
'float|real|double|numeric|number|decimal|money|currency' => Manager::FLOAT,
'time|date|year' => Manager::DATETIME
);
foreach($patterns as $vendor => $universal){
if(preg_match("~$vendor~i", $type))
return $universal;
}
return Manager::TEXT;
} | [
"protected",
"function",
"resolveType",
"(",
"$",
"type",
")",
"{",
"static",
"$",
"patterns",
"=",
"array",
"(",
"'bool|bit'",
"=>",
"Manager",
"::",
"BOOL",
",",
"'bin|blob|bytea'",
"=>",
"Manager",
"::",
"BINARY",
",",
"'string|char|text|bigint|longlong'",
"=... | Resolves vendor column type.
@param string $type
@return string | [
"Resolves",
"vendor",
"column",
"type",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Result.php#L456-L471 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.