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/XML/Namespaces.php | XML_Namespaces.detectNamespacesFromXml | public function detectNamespacesFromXml( $xml )
{
$namespaces = self::getNamespacesFromXml( $xml );
$this->namespaces = array_merge( $this->namespaces, $namespaces );
return count( $namespaces );
} | php | public function detectNamespacesFromXml( $xml )
{
$namespaces = self::getNamespacesFromXml( $xml );
$this->namespaces = array_merge( $this->namespaces, $namespaces );
return count( $namespaces );
} | [
"public",
"function",
"detectNamespacesFromXml",
"(",
"$",
"xml",
")",
"{",
"$",
"namespaces",
"=",
"self",
"::",
"getNamespacesFromXml",
"(",
"$",
"xml",
")",
";",
"$",
"this",
"->",
"namespaces",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"namespaces",
... | Detects Namespaces from a XML File and returns Number of found Namespaces.
@access public
@param DOMDocument $doc DOM Document of XML File
@return void | [
"Detects",
"Namespaces",
"from",
"a",
"XML",
"File",
"and",
"returns",
"Number",
"of",
"found",
"Namespaces",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Namespaces.php#L87-L92 | train |
CeusMedia/Common | src/Net/Mail/Body.php | Net_Mail_Body.getMimeType | public function getMimeType()
{
$field = $this->headers->getField( 'Content-Type' );
$parts = explode( ';', $field->getValue() );
return $parts[0];
} | php | public function getMimeType()
{
$field = $this->headers->getField( 'Content-Type' );
$parts = explode( ';', $field->getValue() );
return $parts[0];
} | [
"public",
"function",
"getMimeType",
"(",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"headers",
"->",
"getField",
"(",
"'Content-Type'",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"';'",
",",
"$",
"field",
"->",
"getValue",
"(",
")",
")",
";",... | Returns mail part MIME type.
@access public
@return string | [
"Returns",
"mail",
"part",
"MIME",
"type",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Body.php#L110-L115 | train |
CeusMedia/Common | src/Net/Mail/Body.php | Net_Mail_Body.render | public function render()
{
return $this->headers->toString().Net_Mail::$delimiter.Net_Mail::$delimiter.$this->content/*.PHP_EOL*/;
} | php | public function render()
{
return $this->headers->toString().Net_Mail::$delimiter.Net_Mail::$delimiter.$this->content/*.PHP_EOL*/;
} | [
"public",
"function",
"render",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"headers",
"->",
"toString",
"(",
")",
".",
"Net_Mail",
"::",
"$",
"delimiter",
".",
"Net_Mail",
"::",
"$",
"delimiter",
".",
"$",
"this",
"->",
"content",
"/*.PHP_EOL*/",
";",
... | Returns rendered Mail Part of Body, containing Header Fields and Body Content.
@access public
@return string | [
"Returns",
"rendered",
"Mail",
"Part",
"of",
"Body",
"containing",
"Header",
"Fields",
"and",
"Body",
"Content",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Body.php#L122-L125 | train |
CeusMedia/Common | src/XML/DOM/ObjectFileDeserializer.php | XML_DOM_ObjectFileDeserializer.deserialize | public static function deserialize( $fileName )
{
$reader = new FS_File_Reader( $fileName );
$xml = $reader->readString( $fileName );
return parent::deserialize( $xml );
} | php | public static function deserialize( $fileName )
{
$reader = new FS_File_Reader( $fileName );
$xml = $reader->readString( $fileName );
return parent::deserialize( $xml );
} | [
"public",
"static",
"function",
"deserialize",
"(",
"$",
"fileName",
")",
"{",
"$",
"reader",
"=",
"new",
"FS_File_Reader",
"(",
"$",
"fileName",
")",
";",
"$",
"xml",
"=",
"$",
"reader",
"->",
"readString",
"(",
"$",
"fileName",
")",
";",
"return",
"p... | Builds Object from XML File of a serialized Object.
@access public
@static
@param string $fileName XML File of a serialized Object
@return Object | [
"Builds",
"Object",
"from",
"XML",
"File",
"of",
"a",
"serialized",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectFileDeserializer.php#L51-L56 | train |
CeusMedia/Common | src/Net/Reader.php | Net_Reader.getHeader | public function getHeader( $key = NULL )
{
if( !$this->info )
throw new RuntimeException( "No Request has been sent, yet." );
if( !$key )
return $this->headers;
if( !array_key_exists( $key, $this->headers ) )
throw new InvalidArgumentException( 'Header Key "'.$key.'" is invalid.' );
return $this->headers[$key];
} | php | public function getHeader( $key = NULL )
{
if( !$this->info )
throw new RuntimeException( "No Request has been sent, yet." );
if( !$key )
return $this->headers;
if( !array_key_exists( $key, $this->headers ) )
throw new InvalidArgumentException( 'Header Key "'.$key.'" is invalid.' );
return $this->headers[$key];
} | [
"public",
"function",
"getHeader",
"(",
"$",
"key",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"info",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"No Request has been sent, yet.\"",
")",
";",
"if",
"(",
"!",
"$",
"key",
")",
"return",... | Returns Headers Array or a specified header from last request.
@access public
@param string $key Header key
@return mixed | [
"Returns",
"Headers",
"Array",
"or",
"a",
"specified",
"header",
"from",
"last",
"request",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Reader.php#L95-L104 | train |
CeusMedia/Common | src/Net/Reader.php | Net_Reader.getInfo | public function getInfo( $key = NULL )
{
if( !$this->info )
throw new RuntimeException( "No Request has been sent, yet." );
if( !$key )
return $this->info;
if( !array_key_exists( $key, $this->info ) )
throw new InvalidArgumentException( 'Status Key "'.$key.'" is invalid.' );
return $this->info[$key];
} | php | public function getInfo( $key = NULL )
{
if( !$this->info )
throw new RuntimeException( "No Request has been sent, yet." );
if( !$key )
return $this->info;
if( !array_key_exists( $key, $this->info ) )
throw new InvalidArgumentException( 'Status Key "'.$key.'" is invalid.' );
return $this->info[$key];
} | [
"public",
"function",
"getInfo",
"(",
"$",
"key",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"info",
")",
"throw",
"new",
"RuntimeException",
"(",
"\"No Request has been sent, yet.\"",
")",
";",
"if",
"(",
"!",
"$",
"key",
")",
"return",
... | Returns information map or single information from last request.
@access public
@param string $key Information key
@return mixed | [
"Returns",
"information",
"map",
"or",
"single",
"information",
"from",
"last",
"request",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Reader.php#L116-L125 | train |
CeusMedia/Common | src/Net/Reader.php | Net_Reader.read | public function read( $curlOptions = array() )
{
$curl = new Net_CURL( $this->url );
$curl->setOption( CURLOPT_SSL_VERIFYHOST, $this->verifyHost );
$curl->setOption( CURLOPT_SSL_VERIFYPEER, $this->verifyPeer );
$curl->setOption( CURLOPT_FOLLOWLOCATION, !ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) );
$curl->setOption( CURLOPT_HEADER, TRUE );
if( self::$userAgent )
$curl->setOption( CURLOPT_USERAGENT, self::$userAgent );
if( $this->username )
$curl->setOption( CURLOPT_USERPWD, $this->username.":".$this->password );
if( $this->proxyAddress ){
$curl->setOption( CURLOPT_HTTPPROXYTUNNEL, TRUE);
$curl->setOption( CURLOPT_PROXY, $this->proxyAddress );
$curl->setOption( CURLOPT_PROXYTYPE, $this->proxyType );
if( $this->proxyAuth )
$curl->setOption( CURLOPT_PROXYUSERPWD, $this->proxyAuth );
}
foreach( $curlOptions as $key => $value )
{
if( is_string( $key ) )
{
if( !( preg_match( "@^CURLOPT_@", $key ) && defined( $key ) ) )
throw new InvalidArgumentException( 'Invalid option constant key "'.$key.'"' );
$key = constant( $key );
}
if( !is_int( $key ) )
throw new InvalidArgumentException( 'Option must be given as integer or string' );
$curl->setOption( $key, $value );
}
$result = $curl->exec( TRUE, FALSE );
$response = Net_HTTP_Response_Parser::fromString( $result );
$this->body = $response->getBody();
$this->headers = $response->getHeaders();
$this->info = $curl->getInfo();
$code = $curl->getInfo( Net_CURL::INFO_HTTP_CODE );
$error = $curl->getInfo( Net_CURL::INFO_ERROR );
$errno = $curl->getInfo( Net_CURL::INFO_ERRNO );
if( $errno )
throw new Exception_IO( 'HTTP request failed: '.$error, $errno, $this->url );
if( !in_array( $code, array( '200', '301', '303', '304', '307' ) ) )
throw new Exception_IO( 'HTTP request failed', $code, $this->url );
return $this->body;
} | php | public function read( $curlOptions = array() )
{
$curl = new Net_CURL( $this->url );
$curl->setOption( CURLOPT_SSL_VERIFYHOST, $this->verifyHost );
$curl->setOption( CURLOPT_SSL_VERIFYPEER, $this->verifyPeer );
$curl->setOption( CURLOPT_FOLLOWLOCATION, !ini_get( 'safe_mode' ) && !ini_get( 'open_basedir' ) );
$curl->setOption( CURLOPT_HEADER, TRUE );
if( self::$userAgent )
$curl->setOption( CURLOPT_USERAGENT, self::$userAgent );
if( $this->username )
$curl->setOption( CURLOPT_USERPWD, $this->username.":".$this->password );
if( $this->proxyAddress ){
$curl->setOption( CURLOPT_HTTPPROXYTUNNEL, TRUE);
$curl->setOption( CURLOPT_PROXY, $this->proxyAddress );
$curl->setOption( CURLOPT_PROXYTYPE, $this->proxyType );
if( $this->proxyAuth )
$curl->setOption( CURLOPT_PROXYUSERPWD, $this->proxyAuth );
}
foreach( $curlOptions as $key => $value )
{
if( is_string( $key ) )
{
if( !( preg_match( "@^CURLOPT_@", $key ) && defined( $key ) ) )
throw new InvalidArgumentException( 'Invalid option constant key "'.$key.'"' );
$key = constant( $key );
}
if( !is_int( $key ) )
throw new InvalidArgumentException( 'Option must be given as integer or string' );
$curl->setOption( $key, $value );
}
$result = $curl->exec( TRUE, FALSE );
$response = Net_HTTP_Response_Parser::fromString( $result );
$this->body = $response->getBody();
$this->headers = $response->getHeaders();
$this->info = $curl->getInfo();
$code = $curl->getInfo( Net_CURL::INFO_HTTP_CODE );
$error = $curl->getInfo( Net_CURL::INFO_ERROR );
$errno = $curl->getInfo( Net_CURL::INFO_ERRNO );
if( $errno )
throw new Exception_IO( 'HTTP request failed: '.$error, $errno, $this->url );
if( !in_array( $code, array( '200', '301', '303', '304', '307' ) ) )
throw new Exception_IO( 'HTTP request failed', $code, $this->url );
return $this->body;
} | [
"public",
"function",
"read",
"(",
"$",
"curlOptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"curl",
"=",
"new",
"Net_CURL",
"(",
"$",
"this",
"->",
"url",
")",
";",
"$",
"curl",
"->",
"setOption",
"(",
"CURLOPT_SSL_VERIFYHOST",
",",
"$",
"this",
"-... | Requests set URL and returns response.
@access public
@return string $curlOptions Map of cURL options
@todo Auth | [
"Requests",
"set",
"URL",
"and",
"returns",
"response",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Reader.php#L153-L199 | train |
CeusMedia/Common | src/UI/HTML/Panel.php | UI_HTML_Panel.build | public function build( $id, $theme = "default" )
{
return $this->create( $id, $this->content, $this->header, $this->abstract, $this->footer, $theme, $this->attributes );
} | php | public function build( $id, $theme = "default" )
{
return $this->create( $id, $this->content, $this->header, $this->abstract, $this->footer, $theme, $this->attributes );
} | [
"public",
"function",
"build",
"(",
"$",
"id",
",",
"$",
"theme",
"=",
"\"default\"",
")",
"{",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"content",
",",
"$",
"this",
"->",
"header",
",",
"$",
"this",
"->",
"a... | Builds HTML Code of Panel after settings Contents using the set methods.
@param string $id Tag ID of Panel
@param string $theme Theme / additional CSS Class of Panel
@return string | [
"Builds",
"HTML",
"Code",
"of",
"Panel",
"after",
"settings",
"Contents",
"using",
"the",
"set",
"methods",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Panel.php#L78-L81 | train |
CeusMedia/Common | src/UI/HTML/Panel.php | UI_HTML_Panel.create | public static function create( $id, $content, $header, $abstract = NULL, $footer = NULL, $theme= "default", $attributes = array() )
{
$divContInner = self::wrap( (string) $content, self::$classContentInner );
$divCont = self::wrap( $divContInner, self::$classContent );
$divAbstract = "";
$divHead = "";
$divFoot = "";
if( !is_null( $abstract ) )
{
$divAbstractInner = self::wrap( $abstract, self::$classAbstractInner );
$divAbstract = self::wrap( $divAbstractInner, self::$classAbstract );
}
if( !is_null( $footer ) )
{
$divFootInner = self::wrap( $footer, self::$classFooterInner );
$divFoot = self::wrap( $divFootInner, self::$classFooter );
}
if( !is_null( $header ) )
{
$divHeadInner = self::wrap( $header, self::$classHeaderInner );
$divHead = self::wrap( $divHeadInner, self::$classHeader );
}
$classes = $theme ? self::$classPanel." ".$theme : self::$classPanel;
$attributes = array_merge( array( "id" => $id ), $attributes );
$divPanel = self::wrap( $divHead.$divAbstract.$divCont.$divFoot, $classes, $attributes );
return $divPanel;
} | php | public static function create( $id, $content, $header, $abstract = NULL, $footer = NULL, $theme= "default", $attributes = array() )
{
$divContInner = self::wrap( (string) $content, self::$classContentInner );
$divCont = self::wrap( $divContInner, self::$classContent );
$divAbstract = "";
$divHead = "";
$divFoot = "";
if( !is_null( $abstract ) )
{
$divAbstractInner = self::wrap( $abstract, self::$classAbstractInner );
$divAbstract = self::wrap( $divAbstractInner, self::$classAbstract );
}
if( !is_null( $footer ) )
{
$divFootInner = self::wrap( $footer, self::$classFooterInner );
$divFoot = self::wrap( $divFootInner, self::$classFooter );
}
if( !is_null( $header ) )
{
$divHeadInner = self::wrap( $header, self::$classHeaderInner );
$divHead = self::wrap( $divHeadInner, self::$classHeader );
}
$classes = $theme ? self::$classPanel." ".$theme : self::$classPanel;
$attributes = array_merge( array( "id" => $id ), $attributes );
$divPanel = self::wrap( $divHead.$divAbstract.$divCont.$divFoot, $classes, $attributes );
return $divPanel;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"id",
",",
"$",
"content",
",",
"$",
"header",
",",
"$",
"abstract",
"=",
"NULL",
",",
"$",
"footer",
"=",
"NULL",
",",
"$",
"theme",
"=",
"\"default\"",
",",
"$",
"attributes",
"=",
"array",
"(",
... | Builds HTML Code of Panel statically.
@access public
@static
@param string $id Tag ID of Panel
@param string $content Content of Panel
@param string $header Content of Header
@param string $abstract Content of Abstract
@param string $footer Content of Footer
@param string $theme Theme / additional CSS Class of Panel
@param array $attributes Map of Attributes of Panel DIV
@return string | [
"Builds",
"HTML",
"Code",
"of",
"Panel",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Panel.php#L96-L124 | train |
CeusMedia/Common | src/UI/HTML/Panel.php | UI_HTML_Panel.wrap | protected static function wrap( $content, $class, $attributes = array() )
{
$attributes = array_merge( $attributes, array( 'class' => $class ) );
return UI_HTML_Tag::create( "div", $content, $attributes );
} | php | protected static function wrap( $content, $class, $attributes = array() )
{
$attributes = array_merge( $attributes, array( 'class' => $class ) );
return UI_HTML_Tag::create( "div", $content, $attributes );
} | [
"protected",
"static",
"function",
"wrap",
"(",
"$",
"content",
",",
"$",
"class",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attributes",
"=",
"array_merge",
"(",
"$",
"attributes",
",",
"array",
"(",
"'class'",
"=>",
"$",
"class"... | Wraps Content in DIV.
@access protected
@static
@param string $content ...
@param string $class CSS Class of DIV
@param array $attributes Array of Attributes
@return string | [
"Wraps",
"Content",
"in",
"DIV",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Panel.php#L203-L207 | train |
CeusMedia/Common | src/FS/File/ICal/Builder.php | FS_File_Ical_Builder.build | public function build( $tree )
{
$lines = array();
$children = $tree->getChildren();
foreach( $children as $child )
foreach( self::buildRecursive( $child ) as $line )
$lines[] = $line;
return implode( self::$lineBreak, $lines );
} | php | public function build( $tree )
{
$lines = array();
$children = $tree->getChildren();
foreach( $children as $child )
foreach( self::buildRecursive( $child ) as $line )
$lines[] = $line;
return implode( self::$lineBreak, $lines );
} | [
"public",
"function",
"build",
"(",
"$",
"tree",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"$",
"children",
"=",
"$",
"tree",
"->",
"getChildren",
"(",
")",
";",
"foreach",
"(",
"$",
"children",
"as",
"$",
"child",
")",
"foreach",
"(",
... | Builds Array of iCal Lines from XML Tree.
@access public
@param XML_DOM_Node $tree XML Tree
@return array | [
"Builds",
"Array",
"of",
"iCal",
"Lines",
"from",
"XML",
"Tree",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Builder.php#L66-L74 | train |
CeusMedia/Common | src/FS/File/ICal/Builder.php | FS_File_Ical_Builder.buildLine | protected static function buildLine( $name, $param, $content )
{
$params = array();
foreach( $param as $key => $value )
$params[] = strtoupper( trim( $key ) )."=".$value;
$param = implode( ",", $params );
if( $param )
{
$param = " ;".$param;
if( strlen( $param ) > 75 )
{
$rest = $param;
$param = "";
while( strlen( $rest ) > 75 )
{
$param .= substr( $rest, 0, 74 ).self::$lineBreak;
$rest = " ".substr( $rest, 74 );
}
}
$param = self::$lineBreak.$param;
}
$content = ":".$content;
if( strlen( $content ) > 75 )
{
$rest = $content;
$content = "";
while( strlen( $rest ) > 75 )
{
$content .= substr( $rest, 0, 74 ).self::$lineBreak;
$rest = " ".substr( $rest, 74 );
}
}
$line = strtoupper( $name ).$param.$content;
$line = $line;
return $line;
} | php | protected static function buildLine( $name, $param, $content )
{
$params = array();
foreach( $param as $key => $value )
$params[] = strtoupper( trim( $key ) )."=".$value;
$param = implode( ",", $params );
if( $param )
{
$param = " ;".$param;
if( strlen( $param ) > 75 )
{
$rest = $param;
$param = "";
while( strlen( $rest ) > 75 )
{
$param .= substr( $rest, 0, 74 ).self::$lineBreak;
$rest = " ".substr( $rest, 74 );
}
}
$param = self::$lineBreak.$param;
}
$content = ":".$content;
if( strlen( $content ) > 75 )
{
$rest = $content;
$content = "";
while( strlen( $rest ) > 75 )
{
$content .= substr( $rest, 0, 74 ).self::$lineBreak;
$rest = " ".substr( $rest, 74 );
}
}
$line = strtoupper( $name ).$param.$content;
$line = $line;
return $line;
} | [
"protected",
"static",
"function",
"buildLine",
"(",
"$",
"name",
",",
"$",
"param",
",",
"$",
"content",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"param",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"params",
... | Builds iCal Line.
@access protected
@static
@param string name Line Name
@param array param Line Parameters
@param string content Line Value
@return string | [
"Builds",
"iCal",
"Line",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Builder.php#L85-L122 | train |
CeusMedia/Common | src/FS/File/ICal/Builder.php | FS_File_Ical_Builder.buildRecursive | protected static function buildRecursive( $node )
{
$lines = array();
$name = $node->getNodeName();
$value = $node->getContent();
$param = $node->getAttributes();
if( NULL === $value )
{
$lines[] = "BEGIN:".strtoupper( $name );
$children = $node->getChildren();
foreach( $children as $child )
foreach( self::buildRecursive( $child ) as $line )
$lines[] = $line;
$lines[] = "END:".strtoupper( $name );
}
else
$lines[] = self::buildLine( $name, $param, $value );
return $lines;
} | php | protected static function buildRecursive( $node )
{
$lines = array();
$name = $node->getNodeName();
$value = $node->getContent();
$param = $node->getAttributes();
if( NULL === $value )
{
$lines[] = "BEGIN:".strtoupper( $name );
$children = $node->getChildren();
foreach( $children as $child )
foreach( self::buildRecursive( $child ) as $line )
$lines[] = $line;
$lines[] = "END:".strtoupper( $name );
}
else
$lines[] = self::buildLine( $name, $param, $value );
return $lines;
} | [
"protected",
"static",
"function",
"buildRecursive",
"(",
"$",
"node",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"$",
"name",
"=",
"$",
"node",
"->",
"getNodeName",
"(",
")",
";",
"$",
"value",
"=",
"$",
"node",
"->",
"getContent",
"(",
... | Builds Array of iCal Lines from XML Tree recursive.
@access protected
@static
@param XML_DOM_Node node XML Node
@return array | [
"Builds",
"Array",
"of",
"iCal",
"Lines",
"from",
"XML",
"Tree",
"recursive",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/ICal/Builder.php#L131-L149 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.getFullUri | public static function getFullUri($withoutHost = false)
{
$requestedUrl = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'REQUEST_URI');
/*
* Unknown requested url?
* Nothing to do
*/
if (empty($requestedUrl)) {
return '';
}
/*
* Without host / server name?
* All is done
*/
if ($withoutHost) {
return $requestedUrl;
}
return self::getServerNameOrIp(true) . $requestedUrl;
} | php | public static function getFullUri($withoutHost = false)
{
$requestedUrl = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'REQUEST_URI');
/*
* Unknown requested url?
* Nothing to do
*/
if (empty($requestedUrl)) {
return '';
}
/*
* Without host / server name?
* All is done
*/
if ($withoutHost) {
return $requestedUrl;
}
return self::getServerNameOrIp(true) . $requestedUrl;
} | [
"public",
"static",
"function",
"getFullUri",
"(",
"$",
"withoutHost",
"=",
"false",
")",
"{",
"$",
"requestedUrl",
"=",
"Miscellaneous",
"::",
"getSafelyGlobalVariable",
"(",
"INPUT_SERVER",
",",
"'REQUEST_URI'",
")",
";",
"/*\n * Unknown requested url?\n ... | Returns full uri string
@param bool $withoutHost (optional) If is set to true, means that host / server name is omitted
@return string | [
"Returns",
"full",
"uri",
"string"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L25-L46 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.getServerNameOrIp | public static function getServerNameOrIp($withProtocol = false)
{
$host = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'HTTP_HOST');
/*
* Unknown host / server?
* Nothing to do
*/
if (empty($host)) {
return '';
}
/*
* With protocol?
* Let's include the protocol
*/
if ($withProtocol) {
return sprintf('%s://%s', self::getProtocolName(), $host);
}
return $host;
} | php | public static function getServerNameOrIp($withProtocol = false)
{
$host = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'HTTP_HOST');
/*
* Unknown host / server?
* Nothing to do
*/
if (empty($host)) {
return '';
}
/*
* With protocol?
* Let's include the protocol
*/
if ($withProtocol) {
return sprintf('%s://%s', self::getProtocolName(), $host);
}
return $host;
} | [
"public",
"static",
"function",
"getServerNameOrIp",
"(",
"$",
"withProtocol",
"=",
"false",
")",
"{",
"$",
"host",
"=",
"Miscellaneous",
"::",
"getSafelyGlobalVariable",
"(",
"INPUT_SERVER",
",",
"'HTTP_HOST'",
")",
";",
"/*\n * Unknown host / server?\n ... | Returns server name or IP address
@param bool $withProtocol (optional) If is set to true, protocol name is included. Otherwise isn't.
@return string | [
"Returns",
"server",
"name",
"or",
"IP",
"address"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L54-L75 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.getProtocolName | public static function getProtocolName()
{
$matches = [];
$protocolData = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'SERVER_PROTOCOL'); // e.g. HTTP/1.1
$matchCount = preg_match('|(.+)\/(.+)|', $protocolData, $matches);
/*
* $matches[1] - protocol name, e.g. HTTP
* $matches[2] - protocol version, e.g. 1.1
*/
// Oops, cannot match protocol
if (0 === $matchCount) {
return '';
}
return strtolower($matches[1]);
} | php | public static function getProtocolName()
{
$matches = [];
$protocolData = Miscellaneous::getSafelyGlobalVariable(INPUT_SERVER, 'SERVER_PROTOCOL'); // e.g. HTTP/1.1
$matchCount = preg_match('|(.+)\/(.+)|', $protocolData, $matches);
/*
* $matches[1] - protocol name, e.g. HTTP
* $matches[2] - protocol version, e.g. 1.1
*/
// Oops, cannot match protocol
if (0 === $matchCount) {
return '';
}
return strtolower($matches[1]);
} | [
"public",
"static",
"function",
"getProtocolName",
"(",
")",
"{",
"$",
"matches",
"=",
"[",
"]",
";",
"$",
"protocolData",
"=",
"Miscellaneous",
"::",
"getSafelyGlobalVariable",
"(",
"INPUT_SERVER",
",",
"'SERVER_PROTOCOL'",
")",
";",
"// e.g. HTTP/1.1",
"$",
"m... | Returns protocol name
@return string | [
"Returns",
"protocol",
"name"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L82-L99 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.getUserWebBrowserName | public static function getUserWebBrowserName($withVersion = false)
{
$info = self::getUserWebBrowserInfo();
$knownBrowsers = [
'Firefox/([\d\.]+)$' => 'Mozilla Firefox',
'OPR/([\d\.]+)$' => 'Opera',
'Chrome/([\d\.]+)$' => 'Google Chrome',
'Safari/([\d\.]+)$' => 'Apple Safari',
];
foreach ($knownBrowsers as $pattern => $browserName) {
$matches = [];
$matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches);
if ($matchCount > 0) {
if ($withVersion) {
$version = $matches[1];
return sprintf('%s %s', $browserName, $version);
}
return $browserName;
}
}
return '';
} | php | public static function getUserWebBrowserName($withVersion = false)
{
$info = self::getUserWebBrowserInfo();
$knownBrowsers = [
'Firefox/([\d\.]+)$' => 'Mozilla Firefox',
'OPR/([\d\.]+)$' => 'Opera',
'Chrome/([\d\.]+)$' => 'Google Chrome',
'Safari/([\d\.]+)$' => 'Apple Safari',
];
foreach ($knownBrowsers as $pattern => $browserName) {
$matches = [];
$matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches);
if ($matchCount > 0) {
if ($withVersion) {
$version = $matches[1];
return sprintf('%s %s', $browserName, $version);
}
return $browserName;
}
}
return '';
} | [
"public",
"static",
"function",
"getUserWebBrowserName",
"(",
"$",
"withVersion",
"=",
"false",
")",
"{",
"$",
"info",
"=",
"self",
"::",
"getUserWebBrowserInfo",
"(",
")",
";",
"$",
"knownBrowsers",
"=",
"[",
"'Firefox/([\\d\\.]+)$'",
"=>",
"'Mozilla Firefox'",
... | Returns name and version of user's web browser
@param bool $withVersion (optional) If is set to true, version of the browser is returned too. Otherwise -
name only.
@return string | [
"Returns",
"name",
"and",
"version",
"of",
"user",
"s",
"web",
"browser"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L128-L155 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.getUserOperatingSystemName | public static function getUserOperatingSystemName()
{
$info = self::getUserWebBrowserInfo();
$knownSystems = [
'Linux' => 'Linux',
'Win' => 'Windows',
'Mac' => 'Mac OS',
];
foreach ($knownSystems as $pattern => $systemName) {
$matches = [];
$matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches);
if ($matchCount > 0) {
return $systemName;
}
}
return '';
} | php | public static function getUserOperatingSystemName()
{
$info = self::getUserWebBrowserInfo();
$knownSystems = [
'Linux' => 'Linux',
'Win' => 'Windows',
'Mac' => 'Mac OS',
];
foreach ($knownSystems as $pattern => $systemName) {
$matches = [];
$matchCount = preg_match(sprintf('|%s|', $pattern), $info, $matches);
if ($matchCount > 0) {
return $systemName;
}
}
return '';
} | [
"public",
"static",
"function",
"getUserOperatingSystemName",
"(",
")",
"{",
"$",
"info",
"=",
"self",
"::",
"getUserWebBrowserInfo",
"(",
")",
";",
"$",
"knownSystems",
"=",
"[",
"'Linux'",
"=>",
"'Linux'",
",",
"'Win'",
"=>",
"'Windows'",
",",
"'Mac'",
"=>... | Returns name of user's operating system
@return string | [
"Returns",
"name",
"of",
"user",
"s",
"operating",
"system"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L188-L208 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.replenishProtocol | public static function replenishProtocol($url, $protocol = '')
{
// Let's trim the url
if (is_string($url)) {
$url = trim($url);
}
/*
* Url is not provided?
* Nothing to do
*/
if (empty($url)) {
return '';
}
/*
* It's a valid url?
* Let's return it
*/
if (Regex::isValidUrl($url, true)) {
return $url;
}
// Protocol is not provided?
if (empty($protocol)) {
$protocol = self::getProtocolName();
}
return sprintf('%s://%s', $protocol, $url);
} | php | public static function replenishProtocol($url, $protocol = '')
{
// Let's trim the url
if (is_string($url)) {
$url = trim($url);
}
/*
* Url is not provided?
* Nothing to do
*/
if (empty($url)) {
return '';
}
/*
* It's a valid url?
* Let's return it
*/
if (Regex::isValidUrl($url, true)) {
return $url;
}
// Protocol is not provided?
if (empty($protocol)) {
$protocol = self::getProtocolName();
}
return sprintf('%s://%s', $protocol, $url);
} | [
"public",
"static",
"function",
"replenishProtocol",
"(",
"$",
"url",
",",
"$",
"protocol",
"=",
"''",
")",
"{",
"// Let's trim the url",
"if",
"(",
"is_string",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"}",... | Replenishes protocol in the given url
@param string $url The url to check and replenish
@param string $protocol (optional) The protocol which is replenished. If is empty, protocol of current request
is used.
@return string | [
"Replenishes",
"protocol",
"in",
"the",
"given",
"url"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L271-L300 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.getSecuredUrl | public static function getSecuredUrl($url, $user = '', $password = '')
{
/*
* Url is not provided?
* Nothing to do
*/
if (empty($url)) {
return '';
}
$protocol = self::getProtocolName();
$host = self::getServerNameOrIp();
if (!Regex::startsWith($url, '/')) {
$url = sprintf('/%s', $url);
}
$url = $host . $url;
if (!empty($user) && !empty($password)) {
$url = sprintf('%s:%s@%s', $user, $password, $url);
}
return sprintf('%s://%s', $protocol, $url);
} | php | public static function getSecuredUrl($url, $user = '', $password = '')
{
/*
* Url is not provided?
* Nothing to do
*/
if (empty($url)) {
return '';
}
$protocol = self::getProtocolName();
$host = self::getServerNameOrIp();
if (!Regex::startsWith($url, '/')) {
$url = sprintf('/%s', $url);
}
$url = $host . $url;
if (!empty($user) && !empty($password)) {
$url = sprintf('%s:%s@%s', $user, $password, $url);
}
return sprintf('%s://%s', $protocol, $url);
} | [
"public",
"static",
"function",
"getSecuredUrl",
"(",
"$",
"url",
",",
"$",
"user",
"=",
"''",
",",
"$",
"password",
"=",
"''",
")",
"{",
"/*\n * Url is not provided?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",... | Returns url to resource secured by given htpasswd login and password
@param string $url A path / url to some resource, e.g. page, image, css file
@param string $user (optional) User name used to log in
@param string $password (optional) User password used to log in
@return string | [
"Returns",
"url",
"to",
"resource",
"secured",
"by",
"given",
"htpasswd",
"login",
"and",
"password"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L310-L334 | train |
meritoo/common-library | src/Utilities/Uri.php | Uri.addProtocolToUrl | public static function addProtocolToUrl($url, $protocol = 'http')
{
$pattern = sprintf('/^%s.*/', $protocol);
if ((bool)preg_match($pattern, $url)) {
return $url;
}
return sprintf('%s://%s', $protocol, $url);
} | php | public static function addProtocolToUrl($url, $protocol = 'http')
{
$pattern = sprintf('/^%s.*/', $protocol);
if ((bool)preg_match($pattern, $url)) {
return $url;
}
return sprintf('%s://%s', $protocol, $url);
} | [
"public",
"static",
"function",
"addProtocolToUrl",
"(",
"$",
"url",
",",
"$",
"protocol",
"=",
"'http'",
")",
"{",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/^%s.*/'",
",",
"$",
"protocol",
")",
";",
"if",
"(",
"(",
"bool",
")",
"preg_match",
"(",
"$",
... | Adds protocol to given url, if the url does not contain given protocol.
Returns the new url.
@param string $url Url string
@param string $protocol (optional) Protocol string
@return string | [
"Adds",
"protocol",
"to",
"given",
"url",
"if",
"the",
"url",
"does",
"not",
"contain",
"given",
"protocol",
".",
"Returns",
"the",
"new",
"url",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Uri.php#L344-L353 | train |
CeusMedia/Common | src/XML/RPC/Client.php | XML_RPC_Client.call | public function call( $method, $parameters ){
$params = array();
foreach( $parameters as $parameter )
$params[] = '<param>'.self::encodeXmlParameter( $parameter ).'</param>';
$method = '<methodName>'.$method.'</methodName>';
$params = '<params>'.join( $params ).'</params>';
$call = '<methodCall>'.$method.$params.'</methodCall>';
return self::parseResponse( Net_HTTP_Post::sendData( $this->url, $call ) );
} | php | public function call( $method, $parameters ){
$params = array();
foreach( $parameters as $parameter )
$params[] = '<param>'.self::encodeXmlParameter( $parameter ).'</param>';
$method = '<methodName>'.$method.'</methodName>';
$params = '<params>'.join( $params ).'</params>';
$call = '<methodCall>'.$method.$params.'</methodCall>';
return self::parseResponse( Net_HTTP_Post::sendData( $this->url, $call ) );
} | [
"public",
"function",
"call",
"(",
"$",
"method",
",",
"$",
"parameters",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameter",
")",
"$",
"params",
"[",
"]",
"=",
"'<param>'",
".",
"self",
... | Calls XML-RPC method with parameters and returns resulting answer data.
@access public
@param string $method Method XML-RPC
@param array $parameters List of method parameters
@return mixed | [
"Calls",
"XML",
"-",
"RPC",
"method",
"with",
"parameters",
"and",
"returns",
"resulting",
"answer",
"data",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/RPC/Client.php#L65-L73 | train |
CeusMedia/Common | src/UI/Image/EvolutionGraph.php | UI_Image_EvolutionGraph.addGraph | public function addGraph( $legend, $color, $data )
{
$position = count( $this->graphs );
$this->graphs[$position] = array(
'legend' => $legend,
'color' => $color,
'values' => $data,
);
} | php | public function addGraph( $legend, $color, $data )
{
$position = count( $this->graphs );
$this->graphs[$position] = array(
'legend' => $legend,
'color' => $color,
'values' => $data,
);
} | [
"public",
"function",
"addGraph",
"(",
"$",
"legend",
",",
"$",
"color",
",",
"$",
"data",
")",
"{",
"$",
"position",
"=",
"count",
"(",
"$",
"this",
"->",
"graphs",
")",
";",
"$",
"this",
"->",
"graphs",
"[",
"$",
"position",
"]",
"=",
"array",
... | Adds another Graph with Legend, Line Color and Values.
@access public
@param string $legend Legend Label of Graph
@param array $color Array of RGB-Values
@param array $data Array of Values of Graph
@return void | [
"Adds",
"another",
"Graph",
"with",
"Legend",
"Line",
"Color",
"and",
"Values",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/Image/EvolutionGraph.php#L93-L101 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Driver/DriverCollection.php | DriverCollection.add | public function add(string $key, string $driver): void
{
if (!in_array(DriverInterface::class, class_implements($driver))) {
throw new NotDriverProvidedException($key . ' is not a driver.');
}
$this->drivers[$key] = $driver;
} | php | public function add(string $key, string $driver): void
{
if (!in_array(DriverInterface::class, class_implements($driver))) {
throw new NotDriverProvidedException($key . ' is not a driver.');
}
$this->drivers[$key] = $driver;
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"key",
",",
"string",
"$",
"driver",
")",
":",
"void",
"{",
"if",
"(",
"!",
"in_array",
"(",
"DriverInterface",
"::",
"class",
",",
"class_implements",
"(",
"$",
"driver",
")",
")",
")",
"{",
"throw",
... | Adds driver to collection
@param string $key Name of driver
@param string $driver
@throws NotDriverProvidedException if given object is of another instance than DriverInterface | [
"Adds",
"driver",
"to",
"collection"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Driver/DriverCollection.php#L61-L68 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Driver/DriverCollection.php | DriverCollection.get | public function get(string $key): DriverInterface
{
if (!$this->has($key)) {
throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.');
}
return $this->drivers[$key]::install($this->appConfiguration);
} | php | public function get(string $key): DriverInterface
{
if (!$this->has($key)) {
throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.');
}
return $this->drivers[$key]::install($this->appConfiguration);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"key",
")",
":",
"DriverInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"DriverNotFoundException",
"(",
"'Driver you are looking for doesn\\'t exist. Ma... | Returns configured driver instance
This method in fact 'installs' driver in application
@param string $key Name of driver
@return DriverInterface
@throws DriverNotFoundException if requested driver doesn't exist | [
"Returns",
"configured",
"driver",
"instance",
"This",
"method",
"in",
"fact",
"installs",
"driver",
"in",
"application"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Driver/DriverCollection.php#L78-L85 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Driver/DriverCollection.php | DriverCollection.remove | public function remove(string $key): void
{
if (!$this->has($key)) {
throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.');
}
unset($this->drivers[$key]);
} | php | public function remove(string $key): void
{
if (!$this->has($key)) {
throw new DriverNotFoundException('Driver you are looking for doesn\'t exist. Make sure that ' . $key . ' driver is properly configured.');
}
unset($this->drivers[$key]);
} | [
"public",
"function",
"remove",
"(",
"string",
"$",
"key",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"DriverNotFoundException",
"(",
"'Driver you are looking for doesn\\'t exist. Make sure ... | Removes given driver from collection
Better way to do that is removing driver from AppConfiguration registry, but it was easy to implement
@param string $key Name of driver
@throws DriverNotFoundException if requested driver doesn't exist | [
"Removes",
"given",
"driver",
"from",
"collection",
"Better",
"way",
"to",
"do",
"that",
"is",
"removing",
"driver",
"from",
"AppConfiguration",
"registry",
"but",
"it",
"was",
"easy",
"to",
"implement"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Driver/DriverCollection.php#L105-L112 | train |
CeusMedia/Common | src/UI/HTML/Tree/Menu.php | UI_HTML_Tree_Menu.buildMenuRecursive | protected function buildMenuRecursive( ADT_Tree_Menu_List $tree, $level = 1 )
{
$list = array();
foreach( $tree->getChildren() as $child )
{
$class = $child->getAttributes()->get( 'class' );
$label = $child->label;
if( !empty( $child->url ) )
$label = UI_HTML_Elements::Link( $child->url, $child->label, $class, $this->target );
else
$label = UI_HTML_Tag::create( 'span', $child->label );
$sublist = "";
if( $child->hasChildren() )
$sublist = "\n".$this->buildMenuRecursive( $child, $level+1 );
$classes = array( 'level-'.$level );
if( $child->hasChildren() )
$classes[] = "parent";
$class = implode( " ", $classes );
$list[] = UI_HTML_Elements::ListItem( $label.$sublist, $level, array( 'class' => $class ) );
}
$list = UI_HTML_Elements::unorderedList( $list, $level );
return $list;
} | php | protected function buildMenuRecursive( ADT_Tree_Menu_List $tree, $level = 1 )
{
$list = array();
foreach( $tree->getChildren() as $child )
{
$class = $child->getAttributes()->get( 'class' );
$label = $child->label;
if( !empty( $child->url ) )
$label = UI_HTML_Elements::Link( $child->url, $child->label, $class, $this->target );
else
$label = UI_HTML_Tag::create( 'span', $child->label );
$sublist = "";
if( $child->hasChildren() )
$sublist = "\n".$this->buildMenuRecursive( $child, $level+1 );
$classes = array( 'level-'.$level );
if( $child->hasChildren() )
$classes[] = "parent";
$class = implode( " ", $classes );
$list[] = UI_HTML_Elements::ListItem( $label.$sublist, $level, array( 'class' => $class ) );
}
$list = UI_HTML_Elements::unorderedList( $list, $level );
return $list;
} | [
"protected",
"function",
"buildMenuRecursive",
"(",
"ADT_Tree_Menu_List",
"$",
"tree",
",",
"$",
"level",
"=",
"1",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tree",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",... | Builds Tree Menu from Tree Menu Structure.
@access protected
@static
@param ADT_Tree_Menu_List $list Tree Menu Structure
@param string $parent ID of parent Node
@param array $steps List of Steps in Tree
@param int $level Depth Level of Tree
@return string | [
"Builds",
"Tree",
"Menu",
"from",
"Tree",
"Menu",
"Structure",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tree/Menu.php#L107-L130 | train |
CeusMedia/Common | src/UI/HTML/Pagination.php | UI_HTML_Pagination.buildItem | protected function buildItem( $text, $class = NULL )
{
$list = array();
if( $class )
$list[] = $class;
$item = UI_HTML_Elements::ListItem( $text, 0, array( 'class' => $class ) );
return $item;
} | php | protected function buildItem( $text, $class = NULL )
{
$list = array();
if( $class )
$list[] = $class;
$item = UI_HTML_Elements::ListItem( $text, 0, array( 'class' => $class ) );
return $item;
} | [
"protected",
"function",
"buildItem",
"(",
"$",
"text",
",",
"$",
"class",
"=",
"NULL",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"class",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"class",
";",
"$",
"item",
"=",
"UI_HTML_... | Builds List Item of Pagination Link.
@access protected
@param string $text Text or HTML of Paging Button Span
@param string $class Additive Style Class of Paging Button Span
@return string | [
"Builds",
"List",
"Item",
"of",
"Pagination",
"Link",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Pagination.php#L226-L233 | train |
CeusMedia/Common | src/UI/HTML/Pagination.php | UI_HTML_Pagination.buildLinkUrl | protected function buildLinkUrl( $offset )
{
$param = $this->getOption( 'param' );
$param[$this->getOption( 'keyOffset' )] = $offset;
$list = array();
foreach( $param as $key => $value )
$list[] = $key.$this->getOption( 'keyAssign' ).$value;
$param = implode( $this->getOption( 'keyParam' ), $list );
$link = $this->getOption( 'uri' ).$this->getOption( 'keyRequest' ).$param;
return $link;
} | php | protected function buildLinkUrl( $offset )
{
$param = $this->getOption( 'param' );
$param[$this->getOption( 'keyOffset' )] = $offset;
$list = array();
foreach( $param as $key => $value )
$list[] = $key.$this->getOption( 'keyAssign' ).$value;
$param = implode( $this->getOption( 'keyParam' ), $list );
$link = $this->getOption( 'uri' ).$this->getOption( 'keyRequest' ).$param;
return $link;
} | [
"protected",
"function",
"buildLinkUrl",
"(",
"$",
"offset",
")",
"{",
"$",
"param",
"=",
"$",
"this",
"->",
"getOption",
"(",
"'param'",
")",
";",
"$",
"param",
"[",
"$",
"this",
"->",
"getOption",
"(",
"'keyOffset'",
")",
"]",
"=",
"$",
"offset",
"... | Builds Link URL of Paging Button.
@access protected
@param int $offset Currently offset entries
@return string | [
"Builds",
"Link",
"URL",
"of",
"Paging",
"Button",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Pagination.php#L241-L251 | train |
CeusMedia/Common | src/ADT/Tree/Menu/Item.php | ADT_Tree_Menu_Item.toArray | public function toArray()
{
$array = array(
'url' => $this->url,
'label' => $this->label,
'classLink' => $this->attributes->get( 'classLink' ),
'classItem' => $this->attributes->get( 'classItem' ),
'classList' => $this->attributes->get( 'classList' ),
'children' => parent::toArray()
);
return $array;
} | php | public function toArray()
{
$array = array(
'url' => $this->url,
'label' => $this->label,
'classLink' => $this->attributes->get( 'classLink' ),
'classItem' => $this->attributes->get( 'classItem' ),
'classList' => $this->attributes->get( 'classList' ),
'children' => parent::toArray()
);
return $array;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"array",
"=",
"array",
"(",
"'url'",
"=>",
"$",
"this",
"->",
"url",
",",
"'label'",
"=>",
"$",
"this",
"->",
"label",
",",
"'classLink'",
"=>",
"$",
"this",
"->",
"attributes",
"->",
"get",
"(",
... | Returns recursive Array Structure of this Item and its nested Tree Menu Items.
@access public
@return array | [
"Returns",
"recursive",
"Array",
"Structure",
"of",
"this",
"Item",
"and",
"its",
"nested",
"Tree",
"Menu",
"Items",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Menu/Item.php#L87-L98 | train |
CeusMedia/Common | src/ADT/OptionObject.php | ADT_OptionObject.declareOptions | public function declareOptions( $optionKeys = array() )
{
if( !is_array( $optionKeys ) )
throw new InvalidArgumentException( 'Option Keys must be an Array.' );
foreach( $optionKeys as $key )
{
if( !is_string( $key ) )
throw new InvalidArgumentException( 'Option Keys must be an Array List of Strings.' );
$this->options[$key] = NULL;
}
} | php | public function declareOptions( $optionKeys = array() )
{
if( !is_array( $optionKeys ) )
throw new InvalidArgumentException( 'Option Keys must be an Array.' );
foreach( $optionKeys as $key )
{
if( !is_string( $key ) )
throw new InvalidArgumentException( 'Option Keys must be an Array List of Strings.' );
$this->options[$key] = NULL;
}
} | [
"public",
"function",
"declareOptions",
"(",
"$",
"optionKeys",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"optionKeys",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Option Keys must be an Array.'",
")",
";",
"forea... | Declares a Set of Options.
@access public
@param array $optionKeys List of Option Keys
@return void | [
"Declares",
"a",
"Set",
"of",
"Options",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L103-L113 | train |
CeusMedia/Common | src/ADT/OptionObject.php | ADT_OptionObject.getOption | public function getOption( $key, $throwException = TRUE )
{
if( !$this->hasOption( $key ) )
{
if( $throwException )
throw new OutOfRangeException( 'Option "'.$key.'" is not defined' );
return NULL;
}
return $this->options[$key];
} | php | public function getOption( $key, $throwException = TRUE )
{
if( !$this->hasOption( $key ) )
{
if( $throwException )
throw new OutOfRangeException( 'Option "'.$key.'" is not defined' );
return NULL;
}
return $this->options[$key];
} | [
"public",
"function",
"getOption",
"(",
"$",
"key",
",",
"$",
"throwException",
"=",
"TRUE",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"$",
"throwException",
")",
"throw",
"new",
"OutOfRangeE... | Returns an Option Value by Option Key.
@access public
@param string $key Option Key
@param bool $throwException Flag: throw Exception is key is not set, NULL otherwise
@throws OutOfRangeException if key is not set and $throwException is true
@return mixed | [
"Returns",
"an",
"Option",
"Value",
"by",
"Option",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L123-L132 | train |
CeusMedia/Common | src/ADT/OptionObject.php | ADT_OptionObject.removeOption | public function removeOption( $key )
{
if( !$this->hasOption( $key ) )
return FALSE;
unset( $this->options[$key] );
return TRUE;
} | php | public function removeOption( $key )
{
if( !$this->hasOption( $key ) )
return FALSE;
unset( $this->options[$key] );
return TRUE;
} | [
"public",
"function",
"removeOption",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasOption",
"(",
"$",
"key",
")",
")",
"return",
"FALSE",
";",
"unset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
")",
";",
"retur... | Removes an option by its key.
@access public
@param string $key Option Key
@return bool | [
"Removes",
"an",
"option",
"by",
"its",
"key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L206-L212 | train |
CeusMedia/Common | src/ADT/OptionObject.php | ADT_OptionObject.setOption | public function setOption( $key, $value )
{
if( isset( $this->options[$key] ) && $this->options[$key] === $value )
return FALSE;
$this->options[$key] = $value;
return TRUE;
} | php | public function setOption( $key, $value )
{
if( isset( $this->options[$key] ) && $this->options[$key] === $value )
return FALSE;
$this->options[$key] = $value;
return TRUE;
} | [
"public",
"function",
"setOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",
"===",
"$",
"value",
")... | Sets an options.
@access public
@param string $key Option Key
@param mixed $value Option Value
@return bool | [
"Sets",
"an",
"options",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/OptionObject.php#L221-L227 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isValidEmail | public static function isValidEmail($email)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($email)) {
return false;
}
$pattern = self::getEmailPattern();
return (bool)preg_match($pattern, $email);
} | php | public static function isValidEmail($email)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($email)) {
return false;
}
$pattern = self::getEmailPattern();
return (bool)preg_match($pattern, $email);
} | [
"public",
"static",
"function",
"isValidEmail",
"(",
"$",
"email",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"email",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pattern",
"=",
"... | Returns information if given e-mail address is valid
@param string $email E-mail address to validate / verify
@return bool
Examples:
a) valid e-mails:
- ni@g-m.pl
- ni@gm.pl
- ni@g_m.pl
b) invalid e-mails:
- ni@g-m.p
- n@g-m.pl | [
"Returns",
"information",
"if",
"given",
"e",
"-",
"mail",
"address",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L72-L85 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isValidUrl | public static function isValidUrl($url, $requireProtocol = false)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($url)) {
return false;
}
$pattern = self::getUrlPattern($requireProtocol);
return (bool)preg_match($pattern, $url);
} | php | public static function isValidUrl($url, $requireProtocol = false)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($url)) {
return false;
}
$pattern = self::getUrlPattern($requireProtocol);
return (bool)preg_match($pattern, $url);
} | [
"public",
"static",
"function",
"isValidUrl",
"(",
"$",
"url",
",",
"$",
"requireProtocol",
"=",
"false",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"url",
")",
")",
"{",
"return",
"false... | Returns information if given url address is valid
@param string $url The url to validate / verify
@param bool $requireProtocol (optional) If is set to true, the protocol is required to be passed in the url.
Otherwise - not.
@return bool | [
"Returns",
"information",
"if",
"given",
"url",
"address",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L155-L168 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isValidPhoneNumber | public static function isValidPhoneNumber($phoneNumber)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($phoneNumber)) {
return false;
}
$pattern = self::getPhoneNumberPattern();
return (bool)preg_match($pattern, trim($phoneNumber));
} | php | public static function isValidPhoneNumber($phoneNumber)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($phoneNumber)) {
return false;
}
$pattern = self::getPhoneNumberPattern();
return (bool)preg_match($pattern, trim($phoneNumber));
} | [
"public",
"static",
"function",
"isValidPhoneNumber",
"(",
"$",
"phoneNumber",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"phoneNumber",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pa... | Returns information if given phone number is valid
@param string $phoneNumber The phone number to validate / verify
@return bool | [
"Returns",
"information",
"if",
"given",
"phone",
"number",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L176-L189 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.arrayFilter | public static function arrayFilter($array, $arrayColumnKey, $filterExpression, $itsRegularExpression = false)
{
/*
* No elements?
* Nothing to do
*/
if (empty($array)) {
return [];
}
$effect = $array;
foreach ($effect as $key => &$item) {
if (!isset($item[$arrayColumnKey])) {
continue;
}
$value = $item[$arrayColumnKey];
if ($itsRegularExpression) {
$matchesCount = preg_match($filterExpression, $value);
$remove = 0 === $matchesCount;
} else {
if (is_string($value)) {
$value = sprintf('\'%s\'', $value);
} elseif (is_bool($value)) {
if (true === $value) {
$value = 'true';
} else {
$value = 'false';
}
}
eval(sprintf('$isEqual = %s%s;', $value, $filterExpression));
/** @var bool $isEqual */
$remove = !$isEqual;
}
if ($remove) {
unset($effect[$key]);
}
}
return $effect;
} | php | public static function arrayFilter($array, $arrayColumnKey, $filterExpression, $itsRegularExpression = false)
{
/*
* No elements?
* Nothing to do
*/
if (empty($array)) {
return [];
}
$effect = $array;
foreach ($effect as $key => &$item) {
if (!isset($item[$arrayColumnKey])) {
continue;
}
$value = $item[$arrayColumnKey];
if ($itsRegularExpression) {
$matchesCount = preg_match($filterExpression, $value);
$remove = 0 === $matchesCount;
} else {
if (is_string($value)) {
$value = sprintf('\'%s\'', $value);
} elseif (is_bool($value)) {
if (true === $value) {
$value = 'true';
} else {
$value = 'false';
}
}
eval(sprintf('$isEqual = %s%s;', $value, $filterExpression));
/** @var bool $isEqual */
$remove = !$isEqual;
}
if ($remove) {
unset($effect[$key]);
}
}
return $effect;
} | [
"public",
"static",
"function",
"arrayFilter",
"(",
"$",
"array",
",",
"$",
"arrayColumnKey",
",",
"$",
"filterExpression",
",",
"$",
"itsRegularExpression",
"=",
"false",
")",
"{",
"/*\n * No elements?\n * Nothing to do\n */",
"if",
"(",
"empty"... | Filters array by given expression and column
Expression can be simple compare expression, like " == 2", or regular expression.
Returns filtered array.
@param array $array The 2-dimensional array that should be filtered
@param string $arrayColumnKey Column name
@param string $filterExpression Simple filter expression (e.g. "== 2" or "!= \'home\'") or regular
expression (e.g. "/\d+/" or "/[a-z]+[,;]{2,}/")
@param bool $itsRegularExpression (optional) If is set to true, means that filter expression is a regular
expression. Otherwise - not (default behaviour).
@return array | [
"Filters",
"array",
"by",
"given",
"expression",
"and",
"column"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L239-L284 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isLetterOrDigit | public static function isLetterOrDigit($char)
{
$pattern = self::getLetterOrDigitPattern();
return is_scalar($char) && (bool)preg_match($pattern, $char);
} | php | public static function isLetterOrDigit($char)
{
$pattern = self::getLetterOrDigitPattern();
return is_scalar($char) && (bool)preg_match($pattern, $char);
} | [
"public",
"static",
"function",
"isLetterOrDigit",
"(",
"$",
"char",
")",
"{",
"$",
"pattern",
"=",
"self",
"::",
"getLetterOrDigitPattern",
"(",
")",
";",
"return",
"is_scalar",
"(",
"$",
"char",
")",
"&&",
"(",
"bool",
")",
"preg_match",
"(",
"$",
"pat... | Returns information if given character is a letter or digit
@param string $char Character to check
@return bool | [
"Returns",
"information",
"if",
"given",
"character",
"is",
"a",
"letter",
"or",
"digit"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L491-L496 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.startsWithDirectorySeparator | public static function startsWithDirectorySeparator($string, $separator = '')
{
if (empty($separator)) {
$separator = DIRECTORY_SEPARATOR;
}
return self::startsWith($string, $separator);
} | php | public static function startsWithDirectorySeparator($string, $separator = '')
{
if (empty($separator)) {
$separator = DIRECTORY_SEPARATOR;
}
return self::startsWith($string, $separator);
} | [
"public",
"static",
"function",
"startsWithDirectorySeparator",
"(",
"$",
"string",
",",
"$",
"separator",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"separator",
")",
")",
"{",
"$",
"separator",
"=",
"DIRECTORY_SEPARATOR",
";",
"}",
"return",
"sel... | Returns information if the string starts with directory's separator
@param string $string String that may contain a directory's separator at the start / beginning
@param string $separator (optional) The directory's separator, e.g. "/". If is empty (not provided), system's
separator is used.
@return bool | [
"Returns",
"information",
"if",
"the",
"string",
"starts",
"with",
"directory",
"s",
"separator"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L544-L551 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.endsWithDirectorySeparator | public static function endsWithDirectorySeparator($text, $separator = '')
{
if (empty($separator)) {
$separator = DIRECTORY_SEPARATOR;
}
return self::endsWith($text, $separator);
} | php | public static function endsWithDirectorySeparator($text, $separator = '')
{
if (empty($separator)) {
$separator = DIRECTORY_SEPARATOR;
}
return self::endsWith($text, $separator);
} | [
"public",
"static",
"function",
"endsWithDirectorySeparator",
"(",
"$",
"text",
",",
"$",
"separator",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"separator",
")",
")",
"{",
"$",
"separator",
"=",
"DIRECTORY_SEPARATOR",
";",
"}",
"return",
"self",
... | Returns information if the string ends with directory's separator
@param string $text String that may contain a directory's separator at the end
@param string $separator (optional) The directory's separator, e.g. "/". If is empty (not provided), system's
separator is used.
@return string | [
"Returns",
"information",
"if",
"the",
"string",
"ends",
"with",
"directory",
"s",
"separator"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L561-L568 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.contains | public static function contains($haystack, $needle)
{
if (1 === strlen($needle) && !self::isLetterOrDigit($needle)) {
$needle = '\\' . $needle;
}
return (bool)preg_match('|.*' . $needle . '.*|', $haystack);
} | php | public static function contains($haystack, $needle)
{
if (1 === strlen($needle) && !self::isLetterOrDigit($needle)) {
$needle = '\\' . $needle;
}
return (bool)preg_match('|.*' . $needle . '.*|', $haystack);
} | [
"public",
"static",
"function",
"contains",
"(",
"$",
"haystack",
",",
"$",
"needle",
")",
"{",
"if",
"(",
"1",
"===",
"strlen",
"(",
"$",
"needle",
")",
"&&",
"!",
"self",
"::",
"isLetterOrDigit",
"(",
"$",
"needle",
")",
")",
"{",
"$",
"needle",
... | Returns information if one string contains another string
@param string $haystack The string to search in
@param string $needle The string to be search for
@return bool | [
"Returns",
"information",
"if",
"one",
"string",
"contains",
"another",
"string"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L612-L619 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isValidNip | public static function isValidNip($nip)
{
$nip = preg_replace('/[\D]/', '', $nip);
$invalidNips = [
'1234567890',
'0000000000',
];
if (!preg_match('/^[\d]{10}$/', $nip) || in_array($nip, $invalidNips, true)) {
return false;
}
$sum = 0;
$weights = [
6,
5,
7,
2,
3,
4,
5,
6,
7,
];
for ($i = 0; $i < 9; ++$i) {
$sum += $weights[$i] * $nip[$i];
}
$modulo = $sum % 11;
$numberControl = (10 === $modulo) ? 0 : $modulo;
return $numberControl === (int)$nip[9];
} | php | public static function isValidNip($nip)
{
$nip = preg_replace('/[\D]/', '', $nip);
$invalidNips = [
'1234567890',
'0000000000',
];
if (!preg_match('/^[\d]{10}$/', $nip) || in_array($nip, $invalidNips, true)) {
return false;
}
$sum = 0;
$weights = [
6,
5,
7,
2,
3,
4,
5,
6,
7,
];
for ($i = 0; $i < 9; ++$i) {
$sum += $weights[$i] * $nip[$i];
}
$modulo = $sum % 11;
$numberControl = (10 === $modulo) ? 0 : $modulo;
return $numberControl === (int)$nip[9];
} | [
"public",
"static",
"function",
"isValidNip",
"(",
"$",
"nip",
")",
"{",
"$",
"nip",
"=",
"preg_replace",
"(",
"'/[\\D]/'",
",",
"''",
",",
"$",
"nip",
")",
";",
"$",
"invalidNips",
"=",
"[",
"'1234567890'",
",",
"'0000000000'",
",",
"]",
";",
"if",
... | Returns information if given NIP number is valid
@param string $nip A given NIP number
@return bool
@see https://pl.wikipedia.org/wiki/NIP#Znaczenie_numeru | [
"Returns",
"information",
"if",
"given",
"NIP",
"number",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L699-L733 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isValidMoneyValue | public static function isValidMoneyValue($value)
{
/*
* Not a scalar value?
* Nothing to do
*/
if (!is_scalar($value)) {
return false;
}
$pattern = self::getMoneyPattern();
return (bool)preg_match($pattern, $value);
} | php | public static function isValidMoneyValue($value)
{
/*
* Not a scalar value?
* Nothing to do
*/
if (!is_scalar($value)) {
return false;
}
$pattern = self::getMoneyPattern();
return (bool)preg_match($pattern, $value);
} | [
"public",
"static",
"function",
"isValidMoneyValue",
"(",
"$",
"value",
")",
"{",
"/*\n * Not a scalar value?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pattern",... | Returns information if given value is valid money-related value
@param mixed $value Value to verify
@return bool | [
"Returns",
"information",
"if",
"given",
"value",
"is",
"valid",
"money",
"-",
"related",
"value"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L751-L764 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.getValidColorHexValue | public static function getValidColorHexValue($color, $throwException = true)
{
/*
* Not a scalar value?
* Nothing to do
*/
if (!is_scalar($color)) {
return false;
}
$color = Miscellaneous::replace($color, '/#/', '');
$length = strlen($color);
/*
* Color is not 3 or 6 characters long?
* Nothing to do
*/
if (3 !== $length && 6 !== $length) {
if ($throwException) {
throw new IncorrectColorHexLengthException($color);
}
return false;
}
/*
* Color is 3 characters long?
* Let's make it 6 characters long
*/
if (3 === $length) {
$color = Miscellaneous::replace($color, '/(.)(.)(.)/', '$1$1$2$2$3$3');
}
$pattern = self::$patterns['color'];
$match = (bool)preg_match($pattern, $color);
/*
* It's valid color
* Nothing to do more
*/
if ($match) {
return strtolower($color);
}
if ($throwException) {
throw new InvalidColorHexValueException($color);
}
return false;
} | php | public static function getValidColorHexValue($color, $throwException = true)
{
/*
* Not a scalar value?
* Nothing to do
*/
if (!is_scalar($color)) {
return false;
}
$color = Miscellaneous::replace($color, '/#/', '');
$length = strlen($color);
/*
* Color is not 3 or 6 characters long?
* Nothing to do
*/
if (3 !== $length && 6 !== $length) {
if ($throwException) {
throw new IncorrectColorHexLengthException($color);
}
return false;
}
/*
* Color is 3 characters long?
* Let's make it 6 characters long
*/
if (3 === $length) {
$color = Miscellaneous::replace($color, '/(.)(.)(.)/', '$1$1$2$2$3$3');
}
$pattern = self::$patterns['color'];
$match = (bool)preg_match($pattern, $color);
/*
* It's valid color
* Nothing to do more
*/
if ($match) {
return strtolower($color);
}
if ($throwException) {
throw new InvalidColorHexValueException($color);
}
return false;
} | [
"public",
"static",
"function",
"getValidColorHexValue",
"(",
"$",
"color",
",",
"$",
"throwException",
"=",
"true",
")",
"{",
"/*\n * Not a scalar value?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"color",
")",
")",
"{",
... | Returns valid given hexadecimal value of color.
If the value is invalid, throws an exception or returns false.
@param string $color Color to verify
@param bool $throwException (optional) If is set to true, throws an exception if given color is invalid
(default behaviour). Otherwise - not.
@throws IncorrectColorHexLengthException
@throws InvalidColorHexValueException
@return bool|string | [
"Returns",
"valid",
"given",
"hexadecimal",
"value",
"of",
"color",
".",
"If",
"the",
"value",
"is",
"invalid",
"throws",
"an",
"exception",
"or",
"returns",
"false",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L777-L826 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isValidBundleName | public static function isValidBundleName($bundleName)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($bundleName)) {
return false;
}
$pattern = self::getBundleNamePattern();
return (bool)preg_match($pattern, $bundleName);
} | php | public static function isValidBundleName($bundleName)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($bundleName)) {
return false;
}
$pattern = self::getBundleNamePattern();
return (bool)preg_match($pattern, $bundleName);
} | [
"public",
"static",
"function",
"isValidBundleName",
"(",
"$",
"bundleName",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"bundleName",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"patte... | Returns information if given name of bundle is valid
@param string $bundleName Full name of bundle to verify, e.g. "MyExtraBundle"
@return bool | [
"Returns",
"information",
"if",
"given",
"name",
"of",
"bundle",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L834-L847 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isValidHtmlAttribute | public static function isValidHtmlAttribute($htmlAttribute)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($htmlAttribute)) {
return false;
}
$pattern = self::getHtmlAttributePattern();
return (bool)preg_match($pattern, $htmlAttribute);
} | php | public static function isValidHtmlAttribute($htmlAttribute)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($htmlAttribute)) {
return false;
}
$pattern = self::getHtmlAttributePattern();
return (bool)preg_match($pattern, $htmlAttribute);
} | [
"public",
"static",
"function",
"isValidHtmlAttribute",
"(",
"$",
"htmlAttribute",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"htmlAttribute",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",... | Returns information if given html attribute is valid
@param string $htmlAttribute The html attribute to verify
@return bool | [
"Returns",
"information",
"if",
"given",
"html",
"attribute",
"is",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L875-L888 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.areValidHtmlAttributes | public static function areValidHtmlAttributes($htmlAttributes)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($htmlAttributes)) {
return false;
}
$pattern = self::getHtmlAttributePattern();
return (bool)preg_match_all($pattern, $htmlAttributes);
} | php | public static function areValidHtmlAttributes($htmlAttributes)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($htmlAttributes)) {
return false;
}
$pattern = self::getHtmlAttributePattern();
return (bool)preg_match_all($pattern, $htmlAttributes);
} | [
"public",
"static",
"function",
"areValidHtmlAttributes",
"(",
"$",
"htmlAttributes",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"htmlAttributes",
")",
")",
"{",
"return",
"false",
";",
"}",
... | Returns information if given html attributes are valid
@param string $htmlAttributes The html attributes to verify
@return bool | [
"Returns",
"information",
"if",
"given",
"html",
"attributes",
"are",
"valid"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L896-L909 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isBinaryValue | public static function isBinaryValue($value)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($value)) {
return false;
}
$pattern = self::$patterns['binaryValue'];
return (bool)preg_match($pattern, $value);
} | php | public static function isBinaryValue($value)
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($value)) {
return false;
}
$pattern = self::$patterns['binaryValue'];
return (bool)preg_match($pattern, $value);
} | [
"public",
"static",
"function",
"isBinaryValue",
"(",
"$",
"value",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pattern",
"=",
... | Returns information if given value is a binary value
@param string $value Value to verify
@return bool | [
"Returns",
"information",
"if",
"given",
"value",
"is",
"a",
"binary",
"value"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L917-L930 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.isSizeValue | public static function isSizeValue($value, $separator = ' x ')
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($value)) {
return false;
}
$pattern = self::getSizePattern($separator);
return (bool)preg_match($pattern, $value);
} | php | public static function isSizeValue($value, $separator = ' x ')
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($value)) {
return false;
}
$pattern = self::getSizePattern($separator);
return (bool)preg_match($pattern, $value);
} | [
"public",
"static",
"function",
"isSizeValue",
"(",
"$",
"value",
",",
"$",
"separator",
"=",
"' x '",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false"... | Returns information if given value is a size value
@param string $value Value to verify
@param string $separator (optional) Separator used to split width and height. Default: " x ".
@return bool | [
"Returns",
"information",
"if",
"given",
"value",
"is",
"a",
"size",
"value"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L967-L980 | train |
meritoo/common-library | src/Utilities/Regex.php | Regex.createSlug | public static function createSlug($value)
{
/*
* Not a scalar value?
* Nothing to do
*/
if (!is_scalar($value)) {
return false;
}
/*
* It's an empty string?
* Nothing to do
*/
if ('' === $value) {
return '';
}
$id = 'Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();';
$transliterator = \Transliterator::create($id);
$cleanValue = trim($value);
$result = $transliterator->transliterate($cleanValue);
return preg_replace('/[-\s]+/', '-', $result);
} | php | public static function createSlug($value)
{
/*
* Not a scalar value?
* Nothing to do
*/
if (!is_scalar($value)) {
return false;
}
/*
* It's an empty string?
* Nothing to do
*/
if ('' === $value) {
return '';
}
$id = 'Latin-ASCII; NFD; [:Nonspacing Mark:] Remove; NFC; [:Punctuation:] Remove; Lower();';
$transliterator = \Transliterator::create($id);
$cleanValue = trim($value);
$result = $transliterator->transliterate($cleanValue);
return preg_replace('/[-\s]+/', '-', $result);
} | [
"public",
"static",
"function",
"createSlug",
"(",
"$",
"value",
")",
"{",
"/*\n * Not a scalar value?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"/*\n * It's an ... | Returns slug for given value
@param string $value Value that should be transformed to slug
@return bool|string | [
"Returns",
"slug",
"for",
"given",
"value"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Regex.php#L988-L1013 | train |
CeusMedia/Common | src/FS/File/CSV/IteratorReader.php | FS_File_CSV_IteratorReader.toArray | public function toArray( $useHeaders = false )
{
$list = array();
if( $useHeaders )
{
$headers = $this->iterator->next();
while( $data = $this->iterator->next() )
{
$list[] = array_combine( $headers, $data );
}
}
else
{
while( $list[] = $this->iterator->next() );
}
return $list;
} | php | public function toArray( $useHeaders = false )
{
$list = array();
if( $useHeaders )
{
$headers = $this->iterator->next();
while( $data = $this->iterator->next() )
{
$list[] = array_combine( $headers, $data );
}
}
else
{
while( $list[] = $this->iterator->next() );
}
return $list;
} | [
"public",
"function",
"toArray",
"(",
"$",
"useHeaders",
"=",
"false",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"useHeaders",
")",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"iterator",
"->",
"next",
"(",
")",
";",
"w... | Returns CSV Data as Array or associative Array.
@access public
@param bool $useHeaders Flag: use first Line as Headers and return associative Array
@return array | [
"Returns",
"CSV",
"Data",
"as",
"Array",
"or",
"associative",
"Array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/IteratorReader.php#L61-L77 | train |
ncou/Chiron | src/Chiron/Handler/Formatter/HtmlFormatter.php | HtmlFormatter.arrayToHtml | private function arrayToHtml(array $data): string
{
$html = file_get_contents($this->path);
foreach ($data as $key => $val) {
$html = str_replace("{{ $$key }}", $val, $html);
}
return $html;
} | php | private function arrayToHtml(array $data): string
{
$html = file_get_contents($this->path);
foreach ($data as $key => $val) {
$html = str_replace("{{ $$key }}", $val, $html);
}
return $html;
} | [
"private",
"function",
"arrayToHtml",
"(",
"array",
"$",
"data",
")",
":",
"string",
"{",
"$",
"html",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"path",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$... | Render the page with given data.
@param array $data
@return string | [
"Render",
"the",
"page",
"with",
"given",
"data",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Handler/Formatter/HtmlFormatter.php#L47-L56 | train |
CeusMedia/Common | src/FS/File/List/Writer.php | FS_File_List_Writer.add | public function add( $item, $force = FALSE )
{
if( in_array( $item, $this->list ) && !$force )
throw new DomainException( 'Item "'.$item.'" is already existing. See Option "force".' );
$this->list[] = $item;
return $this->write();
} | php | public function add( $item, $force = FALSE )
{
if( in_array( $item, $this->list ) && !$force )
throw new DomainException( 'Item "'.$item.'" is already existing. See Option "force".' );
$this->list[] = $item;
return $this->write();
} | [
"public",
"function",
"add",
"(",
"$",
"item",
",",
"$",
"force",
"=",
"FALSE",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"item",
",",
"$",
"this",
"->",
"list",
")",
"&&",
"!",
"$",
"force",
")",
"throw",
"new",
"DomainException",
"(",
"'Item \"'... | Adds an Item to the current List.
@access public
@param string $item Item to add
@param bool $force Flag: force overwriting
@return void | [
"Adds",
"an",
"Item",
"to",
"the",
"current",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L64-L70 | train |
CeusMedia/Common | src/FS/File/List/Writer.php | FS_File_List_Writer.removeIndex | public function removeIndex( $index )
{
if( !isset( $this->list[$index] ) )
throw new DomainException( 'Item with Index '.$index.' is not existing.' );
unset( $this->list[$index] );
return $this->write();
} | php | public function removeIndex( $index )
{
if( !isset( $this->list[$index] ) )
throw new DomainException( 'Item with Index '.$index.' is not existing.' );
unset( $this->list[$index] );
return $this->write();
} | [
"public",
"function",
"removeIndex",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"index",
"]",
")",
")",
"throw",
"new",
"DomainException",
"(",
"'Item with Index '",
".",
"$",
"index",
".",
"' is not... | Removes an Item from current List by its Index.
@access public
@param int $index Index of Item
@return bool | [
"Removes",
"an",
"Item",
"from",
"current",
"List",
"by",
"its",
"Index",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L93-L99 | train |
CeusMedia/Common | src/FS/File/List/Writer.php | FS_File_List_Writer.save | public static function save( $fileName, $list, $mode = 0755, $user = NULL, $group = NULL )
{
$file = new FS_File_Writer( $fileName, $mode, $user, $group );
return $file->writeArray( $list ) !== FALSE;
} | php | public static function save( $fileName, $list, $mode = 0755, $user = NULL, $group = NULL )
{
$file = new FS_File_Writer( $fileName, $mode, $user, $group );
return $file->writeArray( $list ) !== FALSE;
} | [
"public",
"static",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"list",
",",
"$",
"mode",
"=",
"0755",
",",
"$",
"user",
"=",
"NULL",
",",
"$",
"group",
"=",
"NULL",
")",
"{",
"$",
"file",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"fileName",... | Saves a List to File.
@access public
@static
@param string $fileName File Name of List, absolute or relative URI
@param array $list List to save
@param string $mode UNIX rights for chmod()
@param string $user User Name for chown()
@param string $group Group Name for chgrp()
@return bool | [
"Saves",
"a",
"List",
"to",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L112-L116 | train |
CeusMedia/Common | src/FS/File/List/Writer.php | FS_File_List_Writer.write | protected function write( $mode = 0755, $user = NULL, $group = NULL )
{
return $this->save( $this->fileName, $this->list, $mode, $user, $group );
} | php | protected function write( $mode = 0755, $user = NULL, $group = NULL )
{
return $this->save( $this->fileName, $this->list, $mode, $user, $group );
} | [
"protected",
"function",
"write",
"(",
"$",
"mode",
"=",
"0755",
",",
"$",
"user",
"=",
"NULL",
",",
"$",
"group",
"=",
"NULL",
")",
"{",
"return",
"$",
"this",
"->",
"save",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"this",
"->",
"list",
","... | Writes the current List to File.
@access protected
@param string $mode UNIX rights for chmod()
@param string $user User Name for chown()
@param string $group Group Name for chgrp()
@return bool | [
"Writes",
"the",
"current",
"List",
"to",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/List/Writer.php#L126-L129 | train |
theodorejb/peachy-sql | lib/BaseStatement.php | BaseStatement.getFirst | public function getFirst()
{
$row = $this->getIterator()->current();
if ($row !== null) {
$this->close(); // don't leave the SQL statement open
}
return $row;
} | php | public function getFirst()
{
$row = $this->getIterator()->current();
if ($row !== null) {
$this->close(); // don't leave the SQL statement open
}
return $row;
} | [
"public",
"function",
"getFirst",
"(",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
"->",
"current",
"(",
")",
";",
"if",
"(",
"$",
"row",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"// don't lea... | Returns the first selected row, or null if zero rows were returned
@return array|null | [
"Returns",
"the",
"first",
"selected",
"row",
"or",
"null",
"if",
"zero",
"rows",
"were",
"returned"
] | f179c6fa6c4293c2713b6b59022f3cfc90890a98 | https://github.com/theodorejb/peachy-sql/blob/f179c6fa6c4293c2713b6b59022f3cfc90890a98/lib/BaseStatement.php#L52-L61 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.addAttribute | public function addAttribute( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
{
$key = $nsPrefix ? $nsPrefix.':'.$name : $name;
if( $nsPrefix )
{
$namespaces = $this->getDocNamespaces();
$key = $nsPrefix ? $nsPrefix.':'.$name : $name;
if( $this->hasAttribute( $name, $nsPrefix ) )
throw new RuntimeException( 'Attribute "'.$key.'" is already set' );
if( array_key_exists( $nsPrefix, $namespaces ) )
return parent::addAttribute( $key, $value, $namespaces[$nsPrefix] );
if( $nsURI )
return parent::addAttribute( $key, $value, $nsURI );
throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
}
if( $this->hasAttribute( $name ) )
throw new RuntimeException( 'Attribute "'.$name.'" is already set' );
parent::addAttribute( $name, $value );
} | php | public function addAttribute( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
{
$key = $nsPrefix ? $nsPrefix.':'.$name : $name;
if( $nsPrefix )
{
$namespaces = $this->getDocNamespaces();
$key = $nsPrefix ? $nsPrefix.':'.$name : $name;
if( $this->hasAttribute( $name, $nsPrefix ) )
throw new RuntimeException( 'Attribute "'.$key.'" is already set' );
if( array_key_exists( $nsPrefix, $namespaces ) )
return parent::addAttribute( $key, $value, $namespaces[$nsPrefix] );
if( $nsURI )
return parent::addAttribute( $key, $value, $nsURI );
throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
}
if( $this->hasAttribute( $name ) )
throw new RuntimeException( 'Attribute "'.$name.'" is already set' );
parent::addAttribute( $name, $value );
} | [
"public",
"function",
"addAttribute",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"NULL",
",",
"$",
"nsPrefix",
"=",
"NULL",
",",
"$",
"nsURI",
"=",
"NULL",
")",
"{",
"$",
"key",
"=",
"$",
"nsPrefix",
"?",
"$",
"nsPrefix",
".",
"':'",
".",
"$",
"na... | Adds an attributes.
@access public
@param string $name Name of attribute
@param string $value Value of attribute
@param string $nsPrefix Namespace prefix of attribute
@param string $nsURI Namespace URI of attribute
@return void
@throws RuntimeException if attribute is already set
@throws RuntimeException if namespace prefix is neither registered nor given | [
"Adds",
"an",
"attributes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L56-L74 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.addChild | public function addChild( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
{
$child = NULL;
if( $nsPrefix )
{
$namespaces = $this->getDocNamespaces();
$key = $nsPrefix ? $nsPrefix.':'.$name : $name;
if( array_key_exists( $nsPrefix, $namespaces ) )
$child = parent::addChild( $name, NULL, $namespaces[$nsPrefix] );
else if( $nsURI )
$child = parent::addChild( $key, NULL, $nsURI );
else
throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
}
else
$child = parent::addChild( $name );
if( $value !== NULL )
$child->setValue( $value );
return $child;
} | php | public function addChild( $name, $value = NULL, $nsPrefix = NULL, $nsURI = NULL )
{
$child = NULL;
if( $nsPrefix )
{
$namespaces = $this->getDocNamespaces();
$key = $nsPrefix ? $nsPrefix.':'.$name : $name;
if( array_key_exists( $nsPrefix, $namespaces ) )
$child = parent::addChild( $name, NULL, $namespaces[$nsPrefix] );
else if( $nsURI )
$child = parent::addChild( $key, NULL, $nsURI );
else
throw new RuntimeException( 'Namespace prefix is not registered and namespace URI is missing' );
}
else
$child = parent::addChild( $name );
if( $value !== NULL )
$child->setValue( $value );
return $child;
} | [
"public",
"function",
"addChild",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"NULL",
",",
"$",
"nsPrefix",
"=",
"NULL",
",",
"$",
"nsURI",
"=",
"NULL",
")",
"{",
"$",
"child",
"=",
"NULL",
";",
"if",
"(",
"$",
"nsPrefix",
")",
"{",
"$",
"namespace... | Adds a child element. Sets node content as CDATA section if necessary.
@access public
@param string $name Name of child element
@param string $value Value of child element
@param string $nsPrefix Namespace prefix of child element
@param string $nsURI Namespace URI of child element
@return XML_Element
@throws RuntimeException if namespace prefix is neither registered nor given | [
"Adds",
"a",
"child",
"element",
".",
"Sets",
"node",
"content",
"as",
"CDATA",
"section",
"if",
"necessary",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L97-L116 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.addChildCData | public function addChildCData( $name, $text, $nsPrefix = NULL, $nsURI = NULL )
{
$child = $this->addChild( $name, NULL, $nsPrefix, $nsURI );
$child->addCData( $text );
return $child;
} | php | public function addChildCData( $name, $text, $nsPrefix = NULL, $nsURI = NULL )
{
$child = $this->addChild( $name, NULL, $nsPrefix, $nsURI );
$child->addCData( $text );
return $child;
} | [
"public",
"function",
"addChildCData",
"(",
"$",
"name",
",",
"$",
"text",
",",
"$",
"nsPrefix",
"=",
"NULL",
",",
"$",
"nsURI",
"=",
"NULL",
")",
"{",
"$",
"child",
"=",
"$",
"this",
"->",
"addChild",
"(",
"$",
"name",
",",
"NULL",
",",
"$",
"ns... | Create a child element with CDATA value
@param string $name The name of the child element to add.
@param string $cdata_text The CDATA value of the child element.
@param string $nsPrefix Namespace prefix of child element
@param string $nsURI Namespace URI of child element
@return XML_Element
@reprecated use addChild instead | [
"Create",
"a",
"child",
"element",
"with",
"CDATA",
"value"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L127-L132 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.countChildren | public function countChildren( $nsPrefix = NULL )
{
$i = 0;
foreach( $this->children( $nsPrefix, TRUE ) as $node )
$i++;
return $i;
} | php | public function countChildren( $nsPrefix = NULL )
{
$i = 0;
foreach( $this->children( $nsPrefix, TRUE ) as $node )
$i++;
return $i;
} | [
"public",
"function",
"countChildren",
"(",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
"as",
"$",
"node",
")",
"$",
"i",
"++",
";",
"retu... | Returns count of children.
@access public
@return int | [
"Returns",
"count",
"of",
"children",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L162-L168 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.getAttribute | public function getAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
if( !isset( $data[$name] ) )
throw new RuntimeException( 'Attribute "'.( $nsPrefix ? $nsPrefix.':'.$name : $name ).'" is not set' );
return (string) $data[$name];
} | php | public function getAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
if( !isset( $data[$name] ) )
throw new RuntimeException( 'Attribute "'.( $nsPrefix ? $nsPrefix.':'.$name : $name ).'" is not set' );
return (string) $data[$name];
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"data",
"=",
"$",
"nsPrefix",
"?",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
":",
"$",
"this",
"->",
"attributes"... | Returns the value of an attribute by it's name.
@access public
@param string $name Name of attribute
@param string $nsPrefix Namespace prefix of attribute
@return bool
@throws RuntimeException if attribute is not set | [
"Returns",
"the",
"value",
"of",
"an",
"attribute",
"by",
"it",
"s",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L178-L184 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.getAttributeNames | public function getAttributeNames( $nsPrefix = NULL )
{
$list = array();
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $name => $value )
$list[] = $name;
return $list;
} | php | public function getAttributeNames( $nsPrefix = NULL )
{
$list = array();
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $name => $value )
$list[] = $name;
return $list;
} | [
"public",
"function",
"getAttributeNames",
"(",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"data",
"=",
"$",
"nsPrefix",
"?",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
":",
... | Returns List of attribute names.
@access public
@param string $nsPrefix Namespace prefix of attribute
@return array | [
"Returns",
"List",
"of",
"attribute",
"names",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L192-L199 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.getAttributes | public function getAttributes( $nsPrefix = NULL )
{
$list = array();
foreach( $this->attributes( $nsPrefix, TRUE ) as $name => $value )
$list[$name] = (string) $value;
return $list;
} | php | public function getAttributes( $nsPrefix = NULL )
{
$list = array();
foreach( $this->attributes( $nsPrefix, TRUE ) as $name => $value )
$list[$name] = (string) $value;
return $list;
} | [
"public",
"function",
"getAttributes",
"(",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
"as",
"$",
"name",
"=>",
"$",
"va... | Returns map of attributes.
@access public
@param string $nsPrefix Namespace prefix of attributes
@return array | [
"Returns",
"map",
"of",
"attributes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L207-L213 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.hasAttribute | public function hasAttribute( $name, $nsPrefix = NULL )
{
$names = $this->getAttributeNames( $nsPrefix );
return in_array( $name, $names );
} | php | public function hasAttribute( $name, $nsPrefix = NULL )
{
$names = $this->getAttributeNames( $nsPrefix );
return in_array( $name, $names );
} | [
"public",
"function",
"hasAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"names",
"=",
"$",
"this",
"->",
"getAttributeNames",
"(",
"$",
"nsPrefix",
")",
";",
"return",
"in_array",
"(",
"$",
"name",
",",
"$",
"names",
... | Indicates whether an attribute is existing by it's name.
@access public
@param string $name Name of attribute
@param string $nsPrefix Namespace prefix of attribute
@return bool | [
"Indicates",
"whether",
"an",
"attribute",
"is",
"existing",
"by",
"it",
"s",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L232-L236 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.removeAttribute | public function removeAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $key => $attributeNode )
{
if( $key == $name )
{
unset( $data[$key] );
return TRUE;
}
}
return FALSE;
} | php | public function removeAttribute( $name, $nsPrefix = NULL )
{
$data = $nsPrefix ? $this->attributes( $nsPrefix, TRUE ) : $this->attributes();
foreach( $data as $key => $attributeNode )
{
if( $key == $name )
{
unset( $data[$key] );
return TRUE;
}
}
return FALSE;
} | [
"public",
"function",
"removeAttribute",
"(",
"$",
"name",
",",
"$",
"nsPrefix",
"=",
"NULL",
")",
"{",
"$",
"data",
"=",
"$",
"nsPrefix",
"?",
"$",
"this",
"->",
"attributes",
"(",
"$",
"nsPrefix",
",",
"TRUE",
")",
":",
"$",
"this",
"->",
"attribut... | Removes an attribute by it's name.
@access public
@param string $name Name of attribute
@param string $nsPrefix Namespace prefix of attribute
@return boolean | [
"Removes",
"an",
"attribute",
"by",
"it",
"s",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L245-L257 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.setAttribute | public function setAttribute( $name, $value, $nsPrefix = NULL, $nsURI = NULL )
{
if( $value !== NULL )
{
if( !$this->hasAttribute( $name, $nsPrefix ) )
return $this->addAttribute( $name, $value, $nsPrefix, $nsURI );
$this->removeAttribute( $name, $nsPrefix );
$this->addAttribute( $name, $value, $nsPrefix, $nsURI );
}
else if( $this->hasAttribute( $name, $nsPrefix ) )
{
$this->removeAttribute( $name, $nsPrefix );
}
} | php | public function setAttribute( $name, $value, $nsPrefix = NULL, $nsURI = NULL )
{
if( $value !== NULL )
{
if( !$this->hasAttribute( $name, $nsPrefix ) )
return $this->addAttribute( $name, $value, $nsPrefix, $nsURI );
$this->removeAttribute( $name, $nsPrefix );
$this->addAttribute( $name, $value, $nsPrefix, $nsURI );
}
else if( $this->hasAttribute( $name, $nsPrefix ) )
{
$this->removeAttribute( $name, $nsPrefix );
}
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"nsPrefix",
"=",
"NULL",
",",
"$",
"nsURI",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"value",
"!==",
"NULL",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasAttri... | Sets an attribute from by it's name.
Adds attribute if not existing.
Removes attribute if value is NULL.
@access public
@param string $name Name of attribute
@param string $value Value of attribute, NULL means removal
@param string $nsPrefix Namespace prefix of attribute
@param string $nsURI Namespace URI of attribute
@return void | [
"Sets",
"an",
"attribute",
"from",
"by",
"it",
"s",
"name",
".",
"Adds",
"attribute",
"if",
"not",
"existing",
".",
"Removes",
"attribute",
"if",
"value",
"is",
"NULL",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L293-L306 | train |
CeusMedia/Common | src/XML/Element.php | XML_Element.setValue | public function setValue( $value, $cdata = FALSE )
{
if( !is_string( $value ) && $value !== NULL )
throw new InvalidArgumentException( 'Value must be a string or NULL' );
$value = preg_replace( "/(.*)<!\[CDATA\[(.*)\]\]>(.*)/iU", "\\1\\2\\3", $value );
if( $cdata || preg_match( '/&|</', $value ) ) // string is known or detected to be CDATA
{
$dom = dom_import_simplexml( $this ); // import node in DOM
$cdata = $dom->ownerDocument->createCDATASection( $value ); // create a new CDATA section
$dom->nodeValue = ""; // clear node content
$dom->appendChild( $cdata ); // add CDATA section
}
else // normal node content
{
dom_import_simplexml( $this )->nodeValue = $value; // set node content
}
} | php | public function setValue( $value, $cdata = FALSE )
{
if( !is_string( $value ) && $value !== NULL )
throw new InvalidArgumentException( 'Value must be a string or NULL' );
$value = preg_replace( "/(.*)<!\[CDATA\[(.*)\]\]>(.*)/iU", "\\1\\2\\3", $value );
if( $cdata || preg_match( '/&|</', $value ) ) // string is known or detected to be CDATA
{
$dom = dom_import_simplexml( $this ); // import node in DOM
$cdata = $dom->ownerDocument->createCDATASection( $value ); // create a new CDATA section
$dom->nodeValue = ""; // clear node content
$dom->appendChild( $cdata ); // add CDATA section
}
else // normal node content
{
dom_import_simplexml( $this )->nodeValue = $value; // set node content
}
} | [
"public",
"function",
"setValue",
"(",
"$",
"value",
",",
"$",
"cdata",
"=",
"FALSE",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"&&",
"$",
"value",
"!==",
"NULL",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Value must be ... | Returns Text Value.
@access public
@return string | [
"Returns",
"Text",
"Value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/Element.php#L313-L330 | train |
CeusMedia/Common | src/FS/File/CSV/Iterator.php | FS_File_CSV_Iterator.next | public function next()
{
if( is_resource( $this->filePointer ) )
{
if( !feof( $this->filePointer ) )
{
$data = fgetcsv(
$this->filePointer,
self::$maxRowSize,
$this->delimiter,
$this->enclosure
);
//A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error.
if( count( $data ) == 1 && ( !isset( $data[0] ) || trim( $data[0] ) == '') )
return $this->next();
if( $data )
{
$this->currentElement = $data;
$this->rowCounter++;
return TRUE;
}
}
}
return FALSE;
} | php | public function next()
{
if( is_resource( $this->filePointer ) )
{
if( !feof( $this->filePointer ) )
{
$data = fgetcsv(
$this->filePointer,
self::$maxRowSize,
$this->delimiter,
$this->enclosure
);
//A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error.
if( count( $data ) == 1 && ( !isset( $data[0] ) || trim( $data[0] ) == '') )
return $this->next();
if( $data )
{
$this->currentElement = $data;
$this->rowCounter++;
return TRUE;
}
}
}
return FALSE;
} | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"filePointer",
")",
")",
"{",
"if",
"(",
"!",
"feof",
"(",
"$",
"this",
"->",
"filePointer",
")",
")",
"{",
"$",
"data",
"=",
"fgetcsv",
"(",
"$",
"thi... | Indicates whether the end of file is not reached.
@access public
@return boolean FALSE on EOF reached, TRUE otherwise | [
"Indicates",
"whether",
"the",
"end",
"of",
"file",
"is",
"not",
"reached",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Iterator.php#L76-L100 | train |
CeusMedia/Common | src/FS/File/CSV/Iterator.php | FS_File_CSV_Iterator.valid | public function valid()
{
if( $this->next() )
return TRUE;
if( is_resource( $this->filePointer ) )
fclose( $this->filePointer );
return FALSE;
} | php | public function valid()
{
if( $this->next() )
return TRUE;
if( is_resource( $this->filePointer ) )
fclose( $this->filePointer );
return FALSE;
} | [
"public",
"function",
"valid",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"next",
"(",
")",
")",
"return",
"TRUE",
";",
"if",
"(",
"is_resource",
"(",
"$",
"this",
"->",
"filePointer",
")",
")",
"fclose",
"(",
"$",
"this",
"->",
"filePointer",
")... | Indicates whether the next row is a valid row.
@access public
@return boolean | [
"Indicates",
"whether",
"the",
"next",
"row",
"is",
"a",
"valid",
"row",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Iterator.php#L118-L125 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.getUrl | public function getUrl( $email ){
$hash = md5( strtolower( trim( $email ) ) );
$query = array(
's' => $this->size,
'd' => $this->default,
'r' => $this->rate,
);
return $this->url.$hash.'?'.http_build_query( $query, NULL, '&' );
} | php | public function getUrl( $email ){
$hash = md5( strtolower( trim( $email ) ) );
$query = array(
's' => $this->size,
'd' => $this->default,
'r' => $this->rate,
);
return $this->url.$hash.'?'.http_build_query( $query, NULL, '&' );
} | [
"public",
"function",
"getUrl",
"(",
"$",
"email",
")",
"{",
"$",
"hash",
"=",
"md5",
"(",
"strtolower",
"(",
"trim",
"(",
"$",
"email",
")",
")",
")",
";",
"$",
"query",
"=",
"array",
"(",
"'s'",
"=>",
"$",
"this",
"->",
"size",
",",
"'d'",
"=... | Returns URL of Gravatar image.
@access public
@param string $email Email address to get Gravatar image for
@return string Gravatar URL | [
"Returns",
"URL",
"of",
"Gravatar",
"image",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L96-L104 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.renderImage | public function renderImage( $email, $attributes = array() ){
$attributes['src'] = $this->getUrl( $email );
$attributes['width'] = $this->size;
$attributes['height'] = $this->size;
return UI_HTML_Tag::create( 'img', NULL, $attributes );
} | php | public function renderImage( $email, $attributes = array() ){
$attributes['src'] = $this->getUrl( $email );
$attributes['width'] = $this->size;
$attributes['height'] = $this->size;
return UI_HTML_Tag::create( 'img', NULL, $attributes );
} | [
"public",
"function",
"renderImage",
"(",
"$",
"email",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"attributes",
"[",
"'src'",
"]",
"=",
"$",
"this",
"->",
"getUrl",
"(",
"$",
"email",
")",
";",
"$",
"attributes",
"[",
"'width'",
... | Returns rendered image HTML code.
@access public
@param string $email Email address to get Gravatar image for
@param array $attributes Additional HTML tag attributes
@return string Image HTML code | [
"Returns",
"rendered",
"image",
"HTML",
"code",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L130-L135 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.setSize | public function setSize( $size ){
if( !is_integer( $size ) )
throw new InvalidArgumentException( 'Size must be an integer' );
if( $size < 1 )
throw new OutOfBoundsException( 'Size must be atleast 1 pixel' );
if( $size > 512 )
throw new OutOfBoundsException( 'Size must be atmost 512 pixels' );
$this->size = $size;
} | php | public function setSize( $size ){
if( !is_integer( $size ) )
throw new InvalidArgumentException( 'Size must be an integer' );
if( $size < 1 )
throw new OutOfBoundsException( 'Size must be atleast 1 pixel' );
if( $size > 512 )
throw new OutOfBoundsException( 'Size must be atmost 512 pixels' );
$this->size = $size;
} | [
"public",
"function",
"setSize",
"(",
"$",
"size",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"size",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Size must be an integer'",
")",
";",
"if",
"(",
"$",
"size",
"<",
"1",
")",
"throw",... | Sets size of image to get from Gravatar.
@access public
@param integer $size Size of image (within 1 and 512) in pixels
@return void | [
"Sets",
"size",
"of",
"image",
"to",
"get",
"from",
"Gravatar",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L167-L175 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.removeImage | public function removeImage( $email, $password, $imageId, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$data = array( 'password' => $password, 'userimage' => $imageId );
$response = $this->callXmlRpc( $email, 'deleteUserImage', $data );
return $response[0];
} | php | public function removeImage( $email, $password, $imageId, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$data = array( 'password' => $password, 'userimage' => $imageId );
$response = $this->callXmlRpc( $email, 'deleteUserImage', $data );
return $response[0];
} | [
"public",
"function",
"removeImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"imageId",
",",
"$",
"rating",
"=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"data",
"=",
"array",
"(",
"'password'"... | ...
Implements XML RPC method 'grav.deleteUserImage'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"deleteUserImage",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L182-L187 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.saveImage | public function saveImage( $email, $password, $imageDataBase64, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveData', array(
'password' => $password,
'data' => $imageDataBase64,
'rating' => $rating
) );
return $response[0];
} | php | public function saveImage( $email, $password, $imageDataBase64, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveData', array(
'password' => $password,
'data' => $imageDataBase64,
'rating' => $rating
) );
return $response[0];
} | [
"public",
"function",
"saveImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"imageDataBase64",
",",
"$",
"rating",
"=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->... | ...
Implements XML RPC method 'grav.saveData'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"saveData",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L194-L202 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.saveImageFromUrl | public function saveImageFromUrl( $email, $password, $imageUrl, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveUrl', array(
'password' => $password,
'url' => $imageUrl,
'rating' => $rating
) );
return $response[0];
} | php | public function saveImageFromUrl( $email, $password, $imageUrl, $rating = 0 ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'saveUrl', array(
'password' => $password,
'url' => $imageUrl,
'rating' => $rating
) );
return $response[0];
} | [
"public",
"function",
"saveImageFromUrl",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"imageUrl",
",",
"$",
"rating",
"=",
"0",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->... | ...
Implements XML RPC method 'grav.saveUrl'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"saveUrl",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L209-L217 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.setAddressImage | public function setAddressImage( $email, $password, $address, $imageId ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'useUserimage', array(
'password' => $password,
'addresses' => array( $address ),
'userimage' => $imageId
) );
return $response[0];
} | php | public function setAddressImage( $email, $password, $address, $imageId ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'useUserimage', array(
'password' => $password,
'addresses' => array( $address ),
'userimage' => $imageId
) );
return $response[0];
} | [
"public",
"function",
"setAddressImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"address",
",",
"$",
"imageId",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"callXmlRp... | ...
Implements XML RPC method 'grav.useUserimage'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"useUserimage",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L224-L232 | train |
CeusMedia/Common | src/Net/API/Gravatar.php | Net_API_Gravatar.unsetAddressImage | public function unsetAddressImage( $email, $password, $address ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'removeImage', array(
'password' => $password,
'addresses' => array( $address ),
) );
return $response[0];
} | php | public function unsetAddressImage( $email, $password, $address ){
throw new RuntimeException( 'Not tested yet' );
$response = $this->callXmlRpc( $email, 'removeImage', array(
'password' => $password,
'addresses' => array( $address ),
) );
return $response[0];
} | [
"public",
"function",
"unsetAddressImage",
"(",
"$",
"email",
",",
"$",
"password",
",",
"$",
"address",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Not tested yet'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"callXmlRpc",
"(",
"$",
"emai... | ...
Implements XML RPC method 'grav.removeImage'.
@todo test, code doc | [
"...",
"Implements",
"XML",
"RPC",
"method",
"grav",
".",
"removeImage",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/API/Gravatar.php#L239-L246 | train |
meritoo/common-library | src/Traits/Collection/MainTrait.php | MainTrait.remove | public function remove($element)
{
if ($this->count() > 0) {
foreach ($this->elements as $index => $existing) {
if ($element === $existing) {
unset($this->elements[$index]);
break;
}
}
}
return $this;
} | php | public function remove($element)
{
if ($this->count() > 0) {
foreach ($this->elements as $index => $existing) {
if ($element === $existing) {
unset($this->elements[$index]);
break;
}
}
}
return $this;
} | [
"public",
"function",
"remove",
"(",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"index",
"=>",
"$",
"existing",
")",
"{",
"if",
"(",
"... | Removes given element
@param mixed $element The element to remove
@return $this | [
"Removes",
"given",
"element"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Traits/Collection/MainTrait.php#L91-L104 | train |
meritoo/common-library | src/Traits/Collection/MainTrait.php | MainTrait.has | public function has($element)
{
$index = Arrays::getIndexOf($this->elements, $element);
return null !== $index && false !== $index;
} | php | public function has($element)
{
$index = Arrays::getIndexOf($this->elements, $element);
return null !== $index && false !== $index;
} | [
"public",
"function",
"has",
"(",
"$",
"element",
")",
"{",
"$",
"index",
"=",
"Arrays",
"::",
"getIndexOf",
"(",
"$",
"this",
"->",
"elements",
",",
"$",
"element",
")",
";",
"return",
"null",
"!==",
"$",
"index",
"&&",
"false",
"!==",
"$",
"index",... | Returns information if the collection has given element, iow. if given element exists in the collection
@param mixed $element The element to verify
@return bool | [
"Returns",
"information",
"if",
"the",
"collection",
"has",
"given",
"element",
"iow",
".",
"if",
"given",
"element",
"exists",
"in",
"the",
"collection"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Traits/Collection/MainTrait.php#L144-L149 | train |
meritoo/common-library | src/Traits/Collection/MainTrait.php | MainTrait.getByIndex | public function getByIndex($index)
{
if (isset($this->elements[$index])) {
return $this->elements[$index];
}
return null;
} | php | public function getByIndex($index)
{
if (isset($this->elements[$index])) {
return $this->elements[$index];
}
return null;
} | [
"public",
"function",
"getByIndex",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"elements",
"[",
"$",
"index",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"elements",
"[",
"$",
"index",
"]",
";",
"}",
"return",
"... | Returns element with given index
@param mixed $index Index / key of the element
@return null|mixed | [
"Returns",
"element",
"with",
"given",
"index"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Traits/Collection/MainTrait.php#L199-L206 | train |
railken/amethyst-invoice | src/Models/InvoiceItem.php | InvoiceItem.calculatePriceTaxable | public function calculatePriceTaxable()
{
$money = new Money(round($this->price, 2, PHP_ROUND_HALF_UP) * 100, new Currency($this->invoice->currency));
return $money;
} | php | public function calculatePriceTaxable()
{
$money = new Money(round($this->price, 2, PHP_ROUND_HALF_UP) * 100, new Currency($this->invoice->currency));
return $money;
} | [
"public",
"function",
"calculatePriceTaxable",
"(",
")",
"{",
"$",
"money",
"=",
"new",
"Money",
"(",
"round",
"(",
"$",
"this",
"->",
"price",
",",
"2",
",",
"PHP_ROUND_HALF_UP",
")",
"*",
"100",
",",
"new",
"Currency",
"(",
"$",
"this",
"->",
"invoic... | Calculate the price taxable.
@return Money | [
"Calculate",
"the",
"price",
"taxable",
"."
] | 605cf27aaa82aea7328d5e5ae5f69b1e7e86120e | https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/Models/InvoiceItem.php#L116-L121 | train |
CeusMedia/Common | src/Alg/Math/Prime.php | Alg_Math_Prime.getPrimeFactors | public static function getPrimeFactors( $number, $list = array() )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$edge = floor( sqrt( $number ) );
$primes = self::getPrimes( $edge );
if( self::isPrime( $number ) )
{
$list[] = $number;
}
else if( count( $primes ) )
{
rsort( $primes );
foreach( $primes as $prime )
{
if( $number % $prime == 0 )
{
$tmp = $list;
$tmp[] = $prime;
$rest = $number / $prime;
$result = self::getPrimeFactors( $rest, $tmp );
if( count( $result ) )
{
sort( $result );
return $result;
}
}
}
}
return $list;
} | php | public static function getPrimeFactors( $number, $list = array() )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$edge = floor( sqrt( $number ) );
$primes = self::getPrimes( $edge );
if( self::isPrime( $number ) )
{
$list[] = $number;
}
else if( count( $primes ) )
{
rsort( $primes );
foreach( $primes as $prime )
{
if( $number % $prime == 0 )
{
$tmp = $list;
$tmp[] = $prime;
$rest = $number / $prime;
$result = self::getPrimeFactors( $rest, $tmp );
if( count( $result ) )
{
sort( $result );
return $result;
}
}
}
}
return $list;
} | [
"public",
"static",
"function",
"getPrimeFactors",
"(",
"$",
"number",
",",
"$",
"list",
"=",
"array",
"(",
")",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
... | Returns a List of Prime Factors if given Number is dividable with Prime Numbers.
@access public
@static
@param int $number
@param array $list
@return array | [
"Returns",
"a",
"List",
"of",
"Prime",
"Factors",
"if",
"given",
"Number",
"is",
"dividable",
"with",
"Prime",
"Numbers",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Prime.php#L51-L87 | train |
CeusMedia/Common | src/Alg/Math/Prime.php | Alg_Math_Prime.getPrimes | public static function getPrimes( $max )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$primes = $numbers = array();
for( $i=2; $i<=$max; $i++ )
$numbers[$i] = true;
$edge = floor( sqrt( $max ) );
for( $i=2; $i<=$edge; $i++ )
if( $numbers[$i] )
foreach( $numbers as $key => $prime )
if( $key > $i )
if( $prime )
if( $key % $i == 0 )
$numbers[$key] = false;
foreach( $numbers as $key => $prime )
if( $prime )
$primes[] = $key;
return $primes;
} | php | public static function getPrimes( $max )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
$primes = $numbers = array();
for( $i=2; $i<=$max; $i++ )
$numbers[$i] = true;
$edge = floor( sqrt( $max ) );
for( $i=2; $i<=$edge; $i++ )
if( $numbers[$i] )
foreach( $numbers as $key => $prime )
if( $key > $i )
if( $prime )
if( $key % $i == 0 )
$numbers[$key] = false;
foreach( $numbers as $key => $prime )
if( $prime )
$primes[] = $key;
return $primes;
} | [
"public",
"static",
"function",
"getPrimes",
"(",
"$",
"max",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Please... | Returns all Primes from 2 to a given Number
@access public
@static
@param int $max Greatest Number to get Primes for
@return array | [
"Returns",
"all",
"Primes",
"from",
"2",
"to",
"a",
"given",
"Number"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Prime.php#L96-L123 | train |
CeusMedia/Common | src/Alg/Math/Prime.php | Alg_Math_Prime.isPrime | public static function isPrime( $number )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( $number < 2 )
return false;
$edge = floor( sqrt( $number ) );
for( $i=2; $i<=$edge; $i++ )
if( $number % $i == 0 )
return false;
return true;
} | php | public static function isPrime( $number )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( $number < 2 )
return false;
$edge = floor( sqrt( $number ) );
for( $i=2; $i<=$edge; $i++ )
if( $number % $i == 0 )
return false;
return true;
} | [
"public",
"static",
"function",
"isPrime",
"(",
"$",
"number",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Pleas... | Indicates whether a given Number is a Prime Number.
@access public
@static
@param int $number Number to be checked
@return bool | [
"Indicates",
"whether",
"a",
"given",
"Number",
"is",
"a",
"Prime",
"Number",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Prime.php#L132-L149 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.handle | public function handle(Request $request)
{
$response = new Response();
$response = $this->executePassiveActions($request, $response);
$response = $this->executeAction($request, $response);
if ($response->isClientError() || $response->isServerError()) {
return $this->handleError($request, $response);
}
return $response;
} | php | public function handle(Request $request)
{
$response = new Response();
$response = $this->executePassiveActions($request, $response);
$response = $this->executeAction($request, $response);
if ($response->isClientError() || $response->isServerError()) {
return $this->handleError($request, $response);
}
return $response;
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"executePassiveActions",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"$"... | Handles request and returns response to the client
@param Request $request
@return mixed|Response
@throws \Exception | [
"Handles",
"request",
"and",
"returns",
"response",
"to",
"the",
"client"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L59-L70 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.executePassiveActions | private function executePassiveActions(Request $request, Response $response): Response
{
foreach ($this->getRouter()->getConfiguration()->getPassiveActions() as $action => $whitelist) {
$activeAction = $this->getRouter()->getActionAlias($request);
if (!in_array($activeAction, $whitelist) && !in_array('all', $whitelist)) {
continue;
}
if (in_array('-' . $activeAction, $whitelist) && in_array('all', $whitelist)) {
continue;
}
$route = $this->getRouter()->getAliasedRoute($action, [], Router::PASSIVE_ACTION);
if (!method_exists($route->getController(), $route->getAction())) {
throw new ActionNotFoundException($action . ' passive action is present in registry, but can\'t be found or is improperly configured.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
$response = $controller->{$route->getAction()}(...$route->getActionParams());
}
return $response;
} | php | private function executePassiveActions(Request $request, Response $response): Response
{
foreach ($this->getRouter()->getConfiguration()->getPassiveActions() as $action => $whitelist) {
$activeAction = $this->getRouter()->getActionAlias($request);
if (!in_array($activeAction, $whitelist) && !in_array('all', $whitelist)) {
continue;
}
if (in_array('-' . $activeAction, $whitelist) && in_array('all', $whitelist)) {
continue;
}
$route = $this->getRouter()->getAliasedRoute($action, [], Router::PASSIVE_ACTION);
if (!method_exists($route->getController(), $route->getAction())) {
throw new ActionNotFoundException($action . ' passive action is present in registry, but can\'t be found or is improperly configured.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
$response = $controller->{$route->getAction()}(...$route->getActionParams());
}
return $response;
} | [
"private",
"function",
"executePassiveActions",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
":",
"Response",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getPassiveActions"... | Executes passive actions existing in registry
@param Request $request
@param Response $response
@return Response
@throws ActionNotFoundException if passive action can't be found
@throws \Exception | [
"Executes",
"passive",
"actions",
"existing",
"in",
"registry"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L81-L106 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.executeAction | private function executeAction(Request $request, Response $response)
{
$route = $this->getRouter()->getRoute($request);
if (!method_exists($route->getController(), $route->getAction())) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent($this->getRouter()->getConfiguration()->getNotFoundMsg() ?? 'Not found.')
->setStatusCode(Response::HTTP_NOT_FOUND);
}
throw new ActionNotFoundException($route->getAction() . ' for ' . $route->getController() . ' not found.');
}
$errorController = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (1 === preg_match('(Partial|Passive)', $route->getAction()) || $errorController === $route->getController()) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent('Forbidden.')
->setStatusCode(Response::HTTP_FORBIDDEN);
}
throw new ActionForbiddenException('Partial, passive and error actions cannot be requested by user.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$route->getAction()}(...$route->getActionParams());
} | php | private function executeAction(Request $request, Response $response)
{
$route = $this->getRouter()->getRoute($request);
if (!method_exists($route->getController(), $route->getAction())) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent($this->getRouter()->getConfiguration()->getNotFoundMsg() ?? 'Not found.')
->setStatusCode(Response::HTTP_NOT_FOUND);
}
throw new ActionNotFoundException($route->getAction() . ' for ' . $route->getController() . ' not found.');
}
$errorController = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (1 === preg_match('(Partial|Passive)', $route->getAction()) || $errorController === $route->getController()) {
if ('prod' === $this->configuration['framework']['env']) {
return $response
->setContent('Forbidden.')
->setStatusCode(Response::HTTP_FORBIDDEN);
}
throw new ActionForbiddenException('Partial, passive and error actions cannot be requested by user.');
}
$controllerName = $route->getController();
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$route->getAction()}(...$route->getActionParams());
} | [
"private",
"function",
"executeAction",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getRoute",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"method_ex... | Executes active action
@param Request $request
@param Response $response Response returned by passive actions execution
@return mixed|Response
@throws ActionNotFoundException if requested action can't be found in dev mode
@throws ActionForbiddenException if requested action is partial, passive or belongs to ErrorController in dev mode | [
"Executes",
"active",
"action"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L117-L147 | train |
Assasz/yggdrasil | src/Yggdrasil/Core/Kernel.php | Kernel.handleError | private function handleError(Request $request, Response $response)
{
$controllerName = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (!class_exists($controllerName)) {
return $response;
}
$actionName = 'code' . $response->getStatusCode() . 'Action';
if (!method_exists($controllerName, $actionName)) {
$actionName = 'defaultAction';
}
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$actionName}();
} | php | private function handleError(Request $request, Response $response)
{
$controllerName = $this->getRouter()->getConfiguration()->getControllerNamespace() . 'ErrorController';
if (!class_exists($controllerName)) {
return $response;
}
$actionName = 'code' . $response->getStatusCode() . 'Action';
if (!method_exists($controllerName, $actionName)) {
$actionName = 'defaultAction';
}
$controller = new $controllerName($this->drivers, $request, $response);
return $controller->{$actionName}();
} | [
"private",
"function",
"handleError",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"controllerName",
"=",
"$",
"this",
"->",
"getRouter",
"(",
")",
"->",
"getConfiguration",
"(",
")",
"->",
"getControllerNamespace",
"(",
"... | Handles HTTP errors, that may occur on action execution stage
@param Request $request
@param Response $response Response returned by action execution
@return mixed|Response | [
"Handles",
"HTTP",
"errors",
"that",
"may",
"occur",
"on",
"action",
"execution",
"stage"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Core/Kernel.php#L156-L173 | train |
smasty/Neevo | src/Neevo/Connection.php | Connection.connect | public function connect(){
if($this->connected !== false)
return;
$this->driver->connect($this->config);
$this->connected = true;
$this->notifyObservers(ObserverInterface::CONNECT);
} | php | public function connect(){
if($this->connected !== false)
return;
$this->driver->connect($this->config);
$this->connected = true;
$this->notifyObservers(ObserverInterface::CONNECT);
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"connected",
"!==",
"false",
")",
"return",
";",
"$",
"this",
"->",
"driver",
"->",
"connect",
"(",
"$",
"this",
"->",
"config",
")",
";",
"$",
"this",
"->",
"connected",
... | Opens database connection. | [
"Opens",
"database",
"connection",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Connection.php#L146-L153 | train |
smasty/Neevo | src/Neevo/Connection.php | Connection.alias | public static function alias(&$config, $key, $alias){
if(!isset($config[$alias]))
return;
$tmp = & $config;
foreach(explode('.', $key) as $key){
$tmp = & $tmp[$key];
}
if(!isset($tmp))
$tmp = $config[$alias];
} | php | public static function alias(&$config, $key, $alias){
if(!isset($config[$alias]))
return;
$tmp = & $config;
foreach(explode('.', $key) as $key){
$tmp = & $tmp[$key];
}
if(!isset($tmp))
$tmp = $config[$alias];
} | [
"public",
"static",
"function",
"alias",
"(",
"&",
"$",
"config",
",",
"$",
"key",
",",
"$",
"alias",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"config",
"[",
"$",
"alias",
"]",
")",
")",
"return",
";",
"$",
"tmp",
"=",
"&",
"$",
"config",
... | Creates an alias for configuration value.
@param array $config Passed by reference
@param string $key
@param string $alias Alias of $key | [
"Creates",
"an",
"alias",
"for",
"configuration",
"value",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Connection.php#L282-L291 | train |
smasty/Neevo | src/Neevo/Connection.php | Connection.setDriver | protected function setDriver($driver){
if(strcasecmp($driver, 'sqlite') === 0) // Backward compatibility
$driver = 'SQLite2';
$class = "Neevo\\Drivers\\{$driver}Driver";
if(!class_exists($class)){
$file = __DIR__ . '/Drivers/' . strtolower($driver) . '.php';
if(!file_exists($file))
throw new DriverException("$driver driver file ($file) does not exist.");
if(is_readable($file))
include_once $file;
else
throw new DriverException("$driver driver file ($file) is not readable.");
}
if(!$this->isDriver($class))
throw new DriverException("Class '$class' is not a valid Neevo driver class.");
$this->driver = new $class;
// Set statement parser
if($this->isParser($class))
$this->parser = $class;
} | php | protected function setDriver($driver){
if(strcasecmp($driver, 'sqlite') === 0) // Backward compatibility
$driver = 'SQLite2';
$class = "Neevo\\Drivers\\{$driver}Driver";
if(!class_exists($class)){
$file = __DIR__ . '/Drivers/' . strtolower($driver) . '.php';
if(!file_exists($file))
throw new DriverException("$driver driver file ($file) does not exist.");
if(is_readable($file))
include_once $file;
else
throw new DriverException("$driver driver file ($file) is not readable.");
}
if(!$this->isDriver($class))
throw new DriverException("Class '$class' is not a valid Neevo driver class.");
$this->driver = new $class;
// Set statement parser
if($this->isParser($class))
$this->parser = $class;
} | [
"protected",
"function",
"setDriver",
"(",
"$",
"driver",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"driver",
",",
"'sqlite'",
")",
"===",
"0",
")",
"// Backward compatibility",
"$",
"driver",
"=",
"'SQLite2'",
";",
"$",
"class",
"=",
"\"Neevo\\\\Drivers\... | Sets the driver and statement parser.
@param string $driver
@throws DriverException | [
"Sets",
"the",
"driver",
"and",
"statement",
"parser",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Connection.php#L299-L322 | train |
CeusMedia/Common | src/Alg/Validation/LanguageValidator.php | Alg_Validation_LanguageValidator.getLanguage | public function getLanguage( $language )
{
$pattern = '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i';
if( !$language )
return $this->default;
$accepted = preg_split( '/,\s*/', $language );
$curr_lang = $this->default;
$curr_qual = 0;
foreach( $accepted as $accept)
{
if( !preg_match ( $pattern, $accept, $matches) )
continue;
$lang_code = explode ( '-', $matches[1] );
$lang_quality = isset( $matches[2] ) ? (float)$matches[2] : 1.0;
while (count ($lang_code))
{
if( in_array( strtolower( join( '-', $lang_code ) ), $this->allowed ) )
{
if( $lang_quality > $curr_qual )
{
$curr_lang = strtolower( join( '-', $lang_code ) );
$curr_qual = $lang_quality;
break;
}
}
array_pop ($lang_code);
}
}
return $curr_lang;
} | php | public function getLanguage( $language )
{
$pattern = '/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$/i';
if( !$language )
return $this->default;
$accepted = preg_split( '/,\s*/', $language );
$curr_lang = $this->default;
$curr_qual = 0;
foreach( $accepted as $accept)
{
if( !preg_match ( $pattern, $accept, $matches) )
continue;
$lang_code = explode ( '-', $matches[1] );
$lang_quality = isset( $matches[2] ) ? (float)$matches[2] : 1.0;
while (count ($lang_code))
{
if( in_array( strtolower( join( '-', $lang_code ) ), $this->allowed ) )
{
if( $lang_quality > $curr_qual )
{
$curr_lang = strtolower( join( '-', $lang_code ) );
$curr_qual = $lang_quality;
break;
}
}
array_pop ($lang_code);
}
}
return $curr_lang;
} | [
"public",
"function",
"getLanguage",
"(",
"$",
"language",
")",
"{",
"$",
"pattern",
"=",
"'/^([a-z]{1,8}(?:-[a-z]{1,8})*)(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$/i'",
";",
"if",
"(",
"!",
"$",
"language",
")",
"return",
"$",
"this",
"->",
"default",
";",
... | Returns prefered allowed and accepted Language.
@access public
@param string $language Language to prove
@return string | [
"Returns",
"prefered",
"allowed",
"and",
"accepted",
"Language",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/LanguageValidator.php#L77-L106 | train |
CeusMedia/Common | src/Alg/Validation/LanguageValidator.php | Alg_Validation_LanguageValidator.validate | public static function validate( $language, $allowed, $default = NULL )
{
$validator = new Alg_Validation_LanguageValidator( $allowed, $default );
$language = $validator->getLanguage( $language );
return $language;
} | php | public static function validate( $language, $allowed, $default = NULL )
{
$validator = new Alg_Validation_LanguageValidator( $allowed, $default );
$language = $validator->getLanguage( $language );
return $language;
} | [
"public",
"static",
"function",
"validate",
"(",
"$",
"language",
",",
"$",
"allowed",
",",
"$",
"default",
"=",
"NULL",
")",
"{",
"$",
"validator",
"=",
"new",
"Alg_Validation_LanguageValidator",
"(",
"$",
"allowed",
",",
"$",
"default",
")",
";",
"$",
... | Validates Language statically and returns valid Language.
@access public
@static
@param string $language Language to validate
@param array $allowed List of allowed Languages
@param string $default Default Language
@return string | [
"Validates",
"Language",
"statically",
"and",
"returns",
"valid",
"Language",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/LanguageValidator.php#L117-L122 | train |
CeusMedia/Common | src/Alg/Math/Algebra/Vector/ScalarProduct.php | Alg_Math_Algebra_Vector_ScalarProduct.produce | public function produce( $vector1, $vector2 )
{
$sum = 0;
if( $vector1->getDimension() != $vector2->getDimension() )
throw new Exception( 'Dimensions of Vectors are not compatible.' );
for( $i=0; $i<$vector1->getDimension(); $i++)
$sum += $vector1->getValueFromIndex( $i ) * $vector2->getValueFromIndex( $i );
return $sum;
} | php | public function produce( $vector1, $vector2 )
{
$sum = 0;
if( $vector1->getDimension() != $vector2->getDimension() )
throw new Exception( 'Dimensions of Vectors are not compatible.' );
for( $i=0; $i<$vector1->getDimension(); $i++)
$sum += $vector1->getValueFromIndex( $i ) * $vector2->getValueFromIndex( $i );
return $sum;
} | [
"public",
"function",
"produce",
"(",
"$",
"vector1",
",",
"$",
"vector2",
")",
"{",
"$",
"sum",
"=",
"0",
";",
"if",
"(",
"$",
"vector1",
"->",
"getDimension",
"(",
")",
"!=",
"$",
"vector2",
"->",
"getDimension",
"(",
")",
")",
"throw",
"new",
"E... | Returns Scalar Product of two Vectors
@access public
@param Alg_Math_Algebra_Vector $vector1 Vector 1
@param Alg_Math_Algebra_Vector $vector2 Vector 2
@return mixed | [
"Returns",
"Scalar",
"Product",
"of",
"two",
"Vectors"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Algebra/Vector/ScalarProduct.php#L58-L67 | train |
rollun-com/rollun-logger | src/Logger/src/Formatter/FluentdFormatter.php | FluentdFormatter.format | public function format($event)
{
$event = $this->reachUpFirstNestedLevel($event);
$event = $this->clearEmptyArrayInEvent($event);
return json_encode($event);
} | php | public function format($event)
{
$event = $this->reachUpFirstNestedLevel($event);
$event = $this->clearEmptyArrayInEvent($event);
return json_encode($event);
} | [
"public",
"function",
"format",
"(",
"$",
"event",
")",
"{",
"$",
"event",
"=",
"$",
"this",
"->",
"reachUpFirstNestedLevel",
"(",
"$",
"event",
")",
";",
"$",
"event",
"=",
"$",
"this",
"->",
"clearEmptyArrayInEvent",
"(",
"$",
"event",
")",
";",
"ret... | Formats data into a single line to be written by the writer.
@param array $event event data
@return string|array Either a formatted line to write to the log, or the
updated event information to provide to the writer. | [
"Formats",
"data",
"into",
"a",
"single",
"line",
"to",
"be",
"written",
"by",
"the",
"writer",
"."
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Formatter/FluentdFormatter.php#L25-L30 | train |
rollun-com/rollun-logger | src/Logger/src/Formatter/FluentdFormatter.php | FluentdFormatter.clearEmptyArrayInEvent | private function clearEmptyArrayInEvent(array $event) {
$repackEvent = [];
foreach ($event as $key => $value) {
if(is_array($value) && count($value) > 0) {
$repackEvent[$key] = $this->clearEmptyArrayInEvent($value);
}else if(!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | php | private function clearEmptyArrayInEvent(array $event) {
$repackEvent = [];
foreach ($event as $key => $value) {
if(is_array($value) && count($value) > 0) {
$repackEvent[$key] = $this->clearEmptyArrayInEvent($value);
}else if(!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | [
"private",
"function",
"clearEmptyArrayInEvent",
"(",
"array",
"$",
"event",
")",
"{",
"$",
"repackEvent",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"event",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")"... | Clear empty array in event
@param array $event
@return array | [
"Clear",
"empty",
"array",
"in",
"event"
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Formatter/FluentdFormatter.php#L36-L46 | train |
rollun-com/rollun-logger | src/Logger/src/Formatter/FluentdFormatter.php | FluentdFormatter.reachUpFirstNestedLevel | private function reachUpFirstNestedLevel(array $event)
{
$repackEvent = [];
foreach ($event as $key => $value) {
if (is_array($value)) {
foreach ($value as $nestedKey => $nestedValue) {
$repackEvent["$key.$nestedKey"] = $nestedValue;
}
} else if (!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | php | private function reachUpFirstNestedLevel(array $event)
{
$repackEvent = [];
foreach ($event as $key => $value) {
if (is_array($value)) {
foreach ($value as $nestedKey => $nestedValue) {
$repackEvent["$key.$nestedKey"] = $nestedValue;
}
} else if (!is_array($value)) {
$repackEvent[$key] = $value;
}
}
return $repackEvent;
} | [
"private",
"function",
"reachUpFirstNestedLevel",
"(",
"array",
"$",
"event",
")",
"{",
"$",
"repackEvent",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"event",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")... | reach up first nested arrays in event
@param array $event
@return array | [
"reach",
"up",
"first",
"nested",
"arrays",
"in",
"event"
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Formatter/FluentdFormatter.php#L53-L66 | train |
CeusMedia/Common | src/FS/File/Permissions.php | FS_File_Permissions.getAsInteger | public function getAsInteger()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return octdec( substr( sprintf( '%o', $permissions ), -4 ) );
} | php | public function getAsInteger()
{
$permissions = @fileperms( $this->pathName );
if( FALSE === $permissions )
throw new InvalidArgumentException( 'Could not get permissions of file "'.$this->pathName.'"' );
return octdec( substr( sprintf( '%o', $permissions ), -4 ) );
} | [
"public",
"function",
"getAsInteger",
"(",
")",
"{",
"$",
"permissions",
"=",
"@",
"fileperms",
"(",
"$",
"this",
"->",
"pathName",
")",
";",
"if",
"(",
"FALSE",
"===",
"$",
"permissions",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Could not get... | Returns permissions as integer value.
@access public
@return integer Integer value of permissions of current file
@throws RuntimeException if no valid file is set | [
"Returns",
"permissions",
"as",
"integer",
"value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Permissions.php#L63-L69 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.