id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36,400 | meritoo/common-library | src/Utilities/Miscellaneous.php | Miscellaneous.concatenatePaths | public static function concatenatePaths($paths)
{
// If paths are not provided as array, get the paths from methods' arguments
if (!is_array($paths)) {
$paths = func_get_args();
}
// No paths provided?
// Nothing to do
if (empty($paths)) {
return '';
}
$concatenated = '';
$firstWindowsBased = false;
$separator = DIRECTORY_SEPARATOR;
foreach ($paths as $path) {
$path = trim($path);
// Empty paths are useless
if (empty($path)) {
continue;
}
// Does the first path is a Windows-based path?
if (Arrays::isFirstElement($paths, $path)) {
$firstWindowsBased = Regex::isWindowsBasedPath($path);
if ($firstWindowsBased) {
$separator = '\\';
}
}
// Remove the starting / beginning directory's separator
$path = self::removeStartingDirectorySeparator($path, $separator);
// Removes the ending directory's separator
$path = self::removeEndingDirectorySeparator($path, $separator);
/*
* If OS is Windows, first part of the concatenated path should be the first passed path,
* because in Windows paths starts with drive letter, e.g. "C:", and the directory separator is not
* necessary at the beginning.
*/
if ($firstWindowsBased && empty($concatenated)) {
$concatenated = $path;
continue;
}
// Concatenate the paths / strings with OS-related directory separator between them (slash or backslash)
$concatenated = sprintf('%s%s%s', $concatenated, $separator, $path);
}
return $concatenated;
} | php | public static function concatenatePaths($paths)
{
// If paths are not provided as array, get the paths from methods' arguments
if (!is_array($paths)) {
$paths = func_get_args();
}
// No paths provided?
// Nothing to do
if (empty($paths)) {
return '';
}
$concatenated = '';
$firstWindowsBased = false;
$separator = DIRECTORY_SEPARATOR;
foreach ($paths as $path) {
$path = trim($path);
// Empty paths are useless
if (empty($path)) {
continue;
}
// Does the first path is a Windows-based path?
if (Arrays::isFirstElement($paths, $path)) {
$firstWindowsBased = Regex::isWindowsBasedPath($path);
if ($firstWindowsBased) {
$separator = '\\';
}
}
// Remove the starting / beginning directory's separator
$path = self::removeStartingDirectorySeparator($path, $separator);
// Removes the ending directory's separator
$path = self::removeEndingDirectorySeparator($path, $separator);
/*
* If OS is Windows, first part of the concatenated path should be the first passed path,
* because in Windows paths starts with drive letter, e.g. "C:", and the directory separator is not
* necessary at the beginning.
*/
if ($firstWindowsBased && empty($concatenated)) {
$concatenated = $path;
continue;
}
// Concatenate the paths / strings with OS-related directory separator between them (slash or backslash)
$concatenated = sprintf('%s%s%s', $concatenated, $separator, $path);
}
return $concatenated;
} | [
"public",
"static",
"function",
"concatenatePaths",
"(",
"$",
"paths",
")",
"{",
"// If paths are not provided as array, get the paths from methods' arguments",
"if",
"(",
"!",
"is_array",
"(",
"$",
"paths",
")",
")",
"{",
"$",
"paths",
"=",
"func_get_args",
"(",
")",
";",
"}",
"// No paths provided?",
"// Nothing to do",
"if",
"(",
"empty",
"(",
"$",
"paths",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"concatenated",
"=",
"''",
";",
"$",
"firstWindowsBased",
"=",
"false",
";",
"$",
"separator",
"=",
"DIRECTORY_SEPARATOR",
";",
"foreach",
"(",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
")",
";",
"// Empty paths are useless",
"if",
"(",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"continue",
";",
"}",
"// Does the first path is a Windows-based path?",
"if",
"(",
"Arrays",
"::",
"isFirstElement",
"(",
"$",
"paths",
",",
"$",
"path",
")",
")",
"{",
"$",
"firstWindowsBased",
"=",
"Regex",
"::",
"isWindowsBasedPath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"firstWindowsBased",
")",
"{",
"$",
"separator",
"=",
"'\\\\'",
";",
"}",
"}",
"// Remove the starting / beginning directory's separator",
"$",
"path",
"=",
"self",
"::",
"removeStartingDirectorySeparator",
"(",
"$",
"path",
",",
"$",
"separator",
")",
";",
"// Removes the ending directory's separator",
"$",
"path",
"=",
"self",
"::",
"removeEndingDirectorySeparator",
"(",
"$",
"path",
",",
"$",
"separator",
")",
";",
"/*\n * If OS is Windows, first part of the concatenated path should be the first passed path,\n * because in Windows paths starts with drive letter, e.g. \"C:\", and the directory separator is not\n * necessary at the beginning.\n */",
"if",
"(",
"$",
"firstWindowsBased",
"&&",
"empty",
"(",
"$",
"concatenated",
")",
")",
"{",
"$",
"concatenated",
"=",
"$",
"path",
";",
"continue",
";",
"}",
"// Concatenate the paths / strings with OS-related directory separator between them (slash or backslash)",
"$",
"concatenated",
"=",
"sprintf",
"(",
"'%s%s%s'",
",",
"$",
"concatenated",
",",
"$",
"separator",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"concatenated",
";",
"}"
] | Returns concatenated given paths
The paths may be passed as:
- an array of paths / strings
- strings passed as following arguments
Examples:
- concatenatePaths(['path/first', 'path/second', 'path/third']);
- concatenatePaths('path/first', 'path/second', 'path/third');
@param array|string $paths Paths co concatenate. As described above: an array of paths / strings or strings
passed as following arguments.
@return string | [
"Returns",
"concatenated",
"given",
"paths"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Miscellaneous.php#L962-L1018 |
36,401 | meritoo/common-library | src/Utilities/Miscellaneous.php | Miscellaneous.removeEndingDirectorySeparator | public static function removeEndingDirectorySeparator($text, $separator = '')
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($text)) {
return '';
}
if (empty($separator)) {
$separator = DIRECTORY_SEPARATOR;
}
$effect = trim($text);
if (Regex::endsWithDirectorySeparator($effect, $separator)) {
$effect = mb_substr($effect, 0, mb_strlen($effect) - mb_strlen($separator));
}
return $effect;
} | php | public static function removeEndingDirectorySeparator($text, $separator = '')
{
/*
* Not a string?
* Nothing to do
*/
if (!is_string($text)) {
return '';
}
if (empty($separator)) {
$separator = DIRECTORY_SEPARATOR;
}
$effect = trim($text);
if (Regex::endsWithDirectorySeparator($effect, $separator)) {
$effect = mb_substr($effect, 0, mb_strlen($effect) - mb_strlen($separator));
}
return $effect;
} | [
"public",
"static",
"function",
"removeEndingDirectorySeparator",
"(",
"$",
"text",
",",
"$",
"separator",
"=",
"''",
")",
"{",
"/*\n * Not a string?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"text",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"separator",
")",
")",
"{",
"$",
"separator",
"=",
"DIRECTORY_SEPARATOR",
";",
"}",
"$",
"effect",
"=",
"trim",
"(",
"$",
"text",
")",
";",
"if",
"(",
"Regex",
"::",
"endsWithDirectorySeparator",
"(",
"$",
"effect",
",",
"$",
"separator",
")",
")",
"{",
"$",
"effect",
"=",
"mb_substr",
"(",
"$",
"effect",
",",
"0",
",",
"mb_strlen",
"(",
"$",
"effect",
")",
"-",
"mb_strlen",
"(",
"$",
"separator",
")",
")",
";",
"}",
"return",
"$",
"effect",
";",
"}"
] | Removes the ending directory's separator
@param string $text Text 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 | [
"Removes",
"the",
"ending",
"directory",
"s",
"separator"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Miscellaneous.php#L1059-L1080 |
36,402 | meritoo/common-library | src/Utilities/Miscellaneous.php | Miscellaneous.fillMissingZeros | public static function fillMissingZeros($number, $length, $before = true)
{
/*
* It's not a number? Empty string is not a number too.
* Nothing to do
*/
if (!is_numeric($number)) {
return '';
}
$text = trim($number);
$textLength = mb_strlen($text);
if ($length <= $textLength) {
return $text;
}
for ($i = ($length - $textLength); 0 < $i; --$i) {
if ($before) {
$text = '0' . $text;
continue;
}
$text .= '0';
}
return $text;
} | php | public static function fillMissingZeros($number, $length, $before = true)
{
/*
* It's not a number? Empty string is not a number too.
* Nothing to do
*/
if (!is_numeric($number)) {
return '';
}
$text = trim($number);
$textLength = mb_strlen($text);
if ($length <= $textLength) {
return $text;
}
for ($i = ($length - $textLength); 0 < $i; --$i) {
if ($before) {
$text = '0' . $text;
continue;
}
$text .= '0';
}
return $text;
} | [
"public",
"static",
"function",
"fillMissingZeros",
"(",
"$",
"number",
",",
"$",
"length",
",",
"$",
"before",
"=",
"true",
")",
"{",
"/*\n * It's not a number? Empty string is not a number too.\n * Nothing to do\n */",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"number",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"text",
"=",
"trim",
"(",
"$",
"number",
")",
";",
"$",
"textLength",
"=",
"mb_strlen",
"(",
"$",
"text",
")",
";",
"if",
"(",
"$",
"length",
"<=",
"$",
"textLength",
")",
"{",
"return",
"$",
"text",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"(",
"$",
"length",
"-",
"$",
"textLength",
")",
";",
"0",
"<",
"$",
"i",
";",
"--",
"$",
"i",
")",
"{",
"if",
"(",
"$",
"before",
")",
"{",
"$",
"text",
"=",
"'0'",
".",
"$",
"text",
";",
"continue",
";",
"}",
"$",
"text",
".=",
"'0'",
";",
"}",
"return",
"$",
"text",
";",
"}"
] | Adds missing the "0" characters to given number until given length is reached
Example:
- number: 201
- length: 6
- will be returned: 000201
If "before" parameter is false, zeros will be inserted after given number. If given number is longer than
given length the number will be returned as it was given to the method.
@param mixed $number Number for who the "0" characters should be inserted
@param int $length Wanted length of final number
@param bool $before (optional) If false, 0 characters will be inserted after given number
@return string | [
"Adds",
"missing",
"the",
"0",
"characters",
"to",
"given",
"number",
"until",
"given",
"length",
"is",
"reached"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Miscellaneous.php#L1144-L1172 |
36,403 | meritoo/common-library | src/Utilities/Miscellaneous.php | Miscellaneous.getInvertedColor | public static function getInvertedColor($color)
{
// Prepare the color for later usage
$color = trim($color);
$withHash = Regex::startsWith($color, '#');
/*
* Verify and get valid value of color.
* An exception will be thrown if the value is not a color.
*/
$validColor = Regex::getValidColorHexValue($color);
// Grab color's components
$red = hexdec(substr($validColor, 0, 2));
$green = hexdec(substr($validColor, 2, 2));
$blue = hexdec(substr($validColor, 4, 2));
// Calculate inverted color's components
$redInverted = self::getValidColorComponent(255 - $red);
$greenInverted = self::getValidColorComponent(255 - $green);
$blueInverted = self::getValidColorComponent(255 - $blue);
// Voila, here is the inverted color
$invertedColor = sprintf('%s%s%s', $redInverted, $greenInverted, $blueInverted);
if ($withHash) {
return sprintf('#%s', $invertedColor);
}
return $invertedColor;
} | php | public static function getInvertedColor($color)
{
// Prepare the color for later usage
$color = trim($color);
$withHash = Regex::startsWith($color, '#');
/*
* Verify and get valid value of color.
* An exception will be thrown if the value is not a color.
*/
$validColor = Regex::getValidColorHexValue($color);
// Grab color's components
$red = hexdec(substr($validColor, 0, 2));
$green = hexdec(substr($validColor, 2, 2));
$blue = hexdec(substr($validColor, 4, 2));
// Calculate inverted color's components
$redInverted = self::getValidColorComponent(255 - $red);
$greenInverted = self::getValidColorComponent(255 - $green);
$blueInverted = self::getValidColorComponent(255 - $blue);
// Voila, here is the inverted color
$invertedColor = sprintf('%s%s%s', $redInverted, $greenInverted, $blueInverted);
if ($withHash) {
return sprintf('#%s', $invertedColor);
}
return $invertedColor;
} | [
"public",
"static",
"function",
"getInvertedColor",
"(",
"$",
"color",
")",
"{",
"// Prepare the color for later usage",
"$",
"color",
"=",
"trim",
"(",
"$",
"color",
")",
";",
"$",
"withHash",
"=",
"Regex",
"::",
"startsWith",
"(",
"$",
"color",
",",
"'#'",
")",
";",
"/*\n * Verify and get valid value of color.\n * An exception will be thrown if the value is not a color.\n */",
"$",
"validColor",
"=",
"Regex",
"::",
"getValidColorHexValue",
"(",
"$",
"color",
")",
";",
"// Grab color's components",
"$",
"red",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"validColor",
",",
"0",
",",
"2",
")",
")",
";",
"$",
"green",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"validColor",
",",
"2",
",",
"2",
")",
")",
";",
"$",
"blue",
"=",
"hexdec",
"(",
"substr",
"(",
"$",
"validColor",
",",
"4",
",",
"2",
")",
")",
";",
"// Calculate inverted color's components",
"$",
"redInverted",
"=",
"self",
"::",
"getValidColorComponent",
"(",
"255",
"-",
"$",
"red",
")",
";",
"$",
"greenInverted",
"=",
"self",
"::",
"getValidColorComponent",
"(",
"255",
"-",
"$",
"green",
")",
";",
"$",
"blueInverted",
"=",
"self",
"::",
"getValidColorComponent",
"(",
"255",
"-",
"$",
"blue",
")",
";",
"// Voila, here is the inverted color",
"$",
"invertedColor",
"=",
"sprintf",
"(",
"'%s%s%s'",
",",
"$",
"redInverted",
",",
"$",
"greenInverted",
",",
"$",
"blueInverted",
")",
";",
"if",
"(",
"$",
"withHash",
")",
"{",
"return",
"sprintf",
"(",
"'#%s'",
",",
"$",
"invertedColor",
")",
";",
"}",
"return",
"$",
"invertedColor",
";",
"}"
] | Returns inverted value of color for given color
@param string $color Hexadecimal value of color to invert (with or without hash), e.g. "dd244c" or "#22a5fe"
@return string | [
"Returns",
"inverted",
"value",
"of",
"color",
"for",
"given",
"color"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Miscellaneous.php#L1239-L1269 |
36,404 | meritoo/common-library | src/Utilities/Miscellaneous.php | Miscellaneous.getProjectRootPath | public static function getProjectRootPath()
{
$projectRootPath = '';
$fileName = 'composer.json';
$directoryPath = __DIR__;
// Path of directory it's not the path of last directory?
while (DIRECTORY_SEPARATOR !== $directoryPath) {
$filePath = static::concatenatePaths($directoryPath, $fileName);
/*
* Is here file we are looking for?
* Maybe it's a project's root path
*/
if (file_exists($filePath)) {
$projectRootPath = $directoryPath;
}
$directoryPath = dirname($directoryPath);
}
return $projectRootPath;
} | php | public static function getProjectRootPath()
{
$projectRootPath = '';
$fileName = 'composer.json';
$directoryPath = __DIR__;
// Path of directory it's not the path of last directory?
while (DIRECTORY_SEPARATOR !== $directoryPath) {
$filePath = static::concatenatePaths($directoryPath, $fileName);
/*
* Is here file we are looking for?
* Maybe it's a project's root path
*/
if (file_exists($filePath)) {
$projectRootPath = $directoryPath;
}
$directoryPath = dirname($directoryPath);
}
return $projectRootPath;
} | [
"public",
"static",
"function",
"getProjectRootPath",
"(",
")",
"{",
"$",
"projectRootPath",
"=",
"''",
";",
"$",
"fileName",
"=",
"'composer.json'",
";",
"$",
"directoryPath",
"=",
"__DIR__",
";",
"// Path of directory it's not the path of last directory?",
"while",
"(",
"DIRECTORY_SEPARATOR",
"!==",
"$",
"directoryPath",
")",
"{",
"$",
"filePath",
"=",
"static",
"::",
"concatenatePaths",
"(",
"$",
"directoryPath",
",",
"$",
"fileName",
")",
";",
"/*\n * Is here file we are looking for?\n * Maybe it's a project's root path\n */",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
")",
"{",
"$",
"projectRootPath",
"=",
"$",
"directoryPath",
";",
"}",
"$",
"directoryPath",
"=",
"dirname",
"(",
"$",
"directoryPath",
")",
";",
"}",
"return",
"$",
"projectRootPath",
";",
"}"
] | Returns project's root path.
Looks for directory that contains composer.json.
@return string | [
"Returns",
"project",
"s",
"root",
"path",
".",
"Looks",
"for",
"directory",
"that",
"contains",
"composer",
".",
"json",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Miscellaneous.php#L1277-L1300 |
36,405 | CeusMedia/Common | src/CLI/Fork/Server/Abstract.php | CLI_Fork_Server_Abstract.handleSignal | protected function handleSignal( $signalNumber )
{
switch( $signalNumber )
{
case SIGTERM:
$this->signalTerm = TRUE;
@unlink( $this->filePid );
break;
case SIGHUP:
$this->signalHangup = TRUE;
break;
default:
$this->report( 'Funny signal: ' . $signalNumber );
}
} | php | protected function handleSignal( $signalNumber )
{
switch( $signalNumber )
{
case SIGTERM:
$this->signalTerm = TRUE;
@unlink( $this->filePid );
break;
case SIGHUP:
$this->signalHangup = TRUE;
break;
default:
$this->report( 'Funny signal: ' . $signalNumber );
}
} | [
"protected",
"function",
"handleSignal",
"(",
"$",
"signalNumber",
")",
"{",
"switch",
"(",
"$",
"signalNumber",
")",
"{",
"case",
"SIGTERM",
":",
"$",
"this",
"->",
"signalTerm",
"=",
"TRUE",
";",
"@",
"unlink",
"(",
"$",
"this",
"->",
"filePid",
")",
";",
"break",
";",
"case",
"SIGHUP",
":",
"$",
"this",
"->",
"signalHangup",
"=",
"TRUE",
";",
"break",
";",
"default",
":",
"$",
"this",
"->",
"report",
"(",
"'Funny signal: '",
".",
"$",
"signalNumber",
")",
";",
"}",
"}"
] | Do funky things with signals | [
"Do",
"funky",
"things",
"with",
"signals"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Fork/Server/Abstract.php#L105-L119 |
36,406 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.addRule | public function addRule( ADT_CSS_Rule $rule ){
$got = $this->getRuleBySelector( $rule->selector );
if( $got )
foreach( $rule->getProperties() as $property )
$got->setPropertyByKey( $property->getKey(), $property->getValue() );
else{
if( !preg_match( '/([a-z])|(#|\.[a-z])/i', $rule->getSelector() ) )
throw new InvalidArgumentException( 'Invalid selector' );
$this->rules[] = $rule;
}
} | php | public function addRule( ADT_CSS_Rule $rule ){
$got = $this->getRuleBySelector( $rule->selector );
if( $got )
foreach( $rule->getProperties() as $property )
$got->setPropertyByKey( $property->getKey(), $property->getValue() );
else{
if( !preg_match( '/([a-z])|(#|\.[a-z])/i', $rule->getSelector() ) )
throw new InvalidArgumentException( 'Invalid selector' );
$this->rules[] = $rule;
}
} | [
"public",
"function",
"addRule",
"(",
"ADT_CSS_Rule",
"$",
"rule",
")",
"{",
"$",
"got",
"=",
"$",
"this",
"->",
"getRuleBySelector",
"(",
"$",
"rule",
"->",
"selector",
")",
";",
"if",
"(",
"$",
"got",
")",
"foreach",
"(",
"$",
"rule",
"->",
"getProperties",
"(",
")",
"as",
"$",
"property",
")",
"$",
"got",
"->",
"setPropertyByKey",
"(",
"$",
"property",
"->",
"getKey",
"(",
")",
",",
"$",
"property",
"->",
"getValue",
"(",
")",
")",
";",
"else",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"'/([a-z])|(#|\\.[a-z])/i'",
",",
"$",
"rule",
"->",
"getSelector",
"(",
")",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid selector'",
")",
";",
"$",
"this",
"->",
"rules",
"[",
"]",
"=",
"$",
"rule",
";",
"}",
"}"
] | Add rule object
@access public
@param ADT_CSS_Rule $rule CSS rule object
@return void | [
"Add",
"rule",
"object"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L61-L71 |
36,407 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.getSelectors | public function getSelectors(){
$list = array();
foreach( $this->rules as $rule )
$list[] = $rule->getSelector();
return $list;
} | php | public function getSelectors(){
$list = array();
foreach( $this->rules as $rule )
$list[] = $rule->getSelector();
return $list;
} | [
"public",
"function",
"getSelectors",
"(",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"$",
"list",
"[",
"]",
"=",
"$",
"rule",
"->",
"getSelector",
"(",
")",
";",
"return",
"$",
"list",
";",
"}"
] | Returns a list of selectors.
@access public
@return array | [
"Returns",
"a",
"list",
"of",
"selectors",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L114-L119 |
36,408 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.has | public function has( $selector, $key = NULL ){
$rule = $this->getRuleBySelector( $selector );
if( $rule )
return !$key ? TRUE : $rule->has( $key );
return FALSE;
} | php | public function has( $selector, $key = NULL ){
$rule = $this->getRuleBySelector( $selector );
if( $rule )
return !$key ? TRUE : $rule->has( $key );
return FALSE;
} | [
"public",
"function",
"has",
"(",
"$",
"selector",
",",
"$",
"key",
"=",
"NULL",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"getRuleBySelector",
"(",
"$",
"selector",
")",
";",
"if",
"(",
"$",
"rule",
")",
"return",
"!",
"$",
"key",
"?",
"TRUE",
":",
"$",
"rule",
"->",
"has",
"(",
"$",
"key",
")",
";",
"return",
"FALSE",
";",
"}"
] | Indicates whether a property is existing by its key.
@access public
@param string $selector Rule selector
@return boolean | [
"Indicates",
"whether",
"a",
"property",
"is",
"existing",
"by",
"its",
"key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L127-L132 |
36,409 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.hasRuleBySelector | public function hasRuleBySelector( $selector ){
foreach( $this->rules as $rule )
if( $selector == $rule->getSelector() )
return TRUE;
return FALSE;
} | php | public function hasRuleBySelector( $selector ){
foreach( $this->rules as $rule )
if( $selector == $rule->getSelector() )
return TRUE;
return FALSE;
} | [
"public",
"function",
"hasRuleBySelector",
"(",
"$",
"selector",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"rule",
")",
"if",
"(",
"$",
"selector",
"==",
"$",
"rule",
"->",
"getSelector",
"(",
")",
")",
"return",
"TRUE",
";",
"return",
"FALSE",
";",
"}"
] | Indicates whether a rule is existing by its selector.
@access public
@param string $selector Rule selector
@return boolean | [
"Indicates",
"whether",
"a",
"rule",
"is",
"existing",
"by",
"its",
"selector",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L140-L145 |
36,410 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.remove | public function remove( $selector, $key ){
$rule = $this->getRuleBySelector( $selector );
if( !$rule )
return FALSE;
if( $rule->removePropertyByKey( $key ) ){
if( !$rule->getProperties() )
$this->removeRuleBySelector( $selector );
return TRUE;
}
return FALSE;
} | php | public function remove( $selector, $key ){
$rule = $this->getRuleBySelector( $selector );
if( !$rule )
return FALSE;
if( $rule->removePropertyByKey( $key ) ){
if( !$rule->getProperties() )
$this->removeRuleBySelector( $selector );
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"remove",
"(",
"$",
"selector",
",",
"$",
"key",
")",
"{",
"$",
"rule",
"=",
"$",
"this",
"->",
"getRuleBySelector",
"(",
"$",
"selector",
")",
";",
"if",
"(",
"!",
"$",
"rule",
")",
"return",
"FALSE",
";",
"if",
"(",
"$",
"rule",
"->",
"removePropertyByKey",
"(",
"$",
"key",
")",
")",
"{",
"if",
"(",
"!",
"$",
"rule",
"->",
"getProperties",
"(",
")",
")",
"$",
"this",
"->",
"removeRuleBySelector",
"(",
"$",
"selector",
")",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Removes a property by its key.
@access public
@param string $selector Rule selector
@param string $key Property key
@return boolean | [
"Removes",
"a",
"property",
"by",
"its",
"key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L154-L164 |
36,411 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.removeProperty | public function removeProperty( ADT_CSS_Rule $rule, ADT_CSS_Property $property ){
return $this->remove( $rule->getSelector(), $property->getKey() );
} | php | public function removeProperty( ADT_CSS_Rule $rule, ADT_CSS_Property $property ){
return $this->remove( $rule->getSelector(), $property->getKey() );
} | [
"public",
"function",
"removeProperty",
"(",
"ADT_CSS_Rule",
"$",
"rule",
",",
"ADT_CSS_Property",
"$",
"property",
")",
"{",
"return",
"$",
"this",
"->",
"remove",
"(",
"$",
"rule",
"->",
"getSelector",
"(",
")",
",",
"$",
"property",
"->",
"getKey",
"(",
")",
")",
";",
"}"
] | Removes a property.
@access public
@param ADT_CSS_Rule $rule Rule object
@param ADT_CSS_Property $property Property object
@return boolean | [
"Removes",
"a",
"property",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L173-L175 |
36,412 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.removeRuleBySelector | public function removeRuleBySelector( $selector ){
foreach( $this->rules as $nr => $rule ){
if( $selector == $rule->getSelector() ){
unset( $this->rules[$nr] );
return TRUE;
}
}
return FALSE;
} | php | public function removeRuleBySelector( $selector ){
foreach( $this->rules as $nr => $rule ){
if( $selector == $rule->getSelector() ){
unset( $this->rules[$nr] );
return TRUE;
}
}
return FALSE;
} | [
"public",
"function",
"removeRuleBySelector",
"(",
"$",
"selector",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"nr",
"=>",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"selector",
"==",
"$",
"rule",
"->",
"getSelector",
"(",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"rules",
"[",
"$",
"nr",
"]",
")",
";",
"return",
"TRUE",
";",
"}",
"}",
"return",
"FALSE",
";",
"}"
] | Removes a rule by its selector.
@access public
@param string $selector Rule selector
@return boolean | [
"Removes",
"a",
"rule",
"by",
"its",
"selector",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L193-L201 |
36,413 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.set | public function set( $selector, $key, $value = NULL ){
if( $value === NULL || !strlen( $value ) )
return $this->remove( $selector, $key );
$rule = $this->getRuleBySelector( $selector );
if( !$rule ){
$rule = new ADT_CSS_Rule( $selector );
$this->rules[] = $rule;
}
return $rule->setPropertyByKey( $key, $value );
} | php | public function set( $selector, $key, $value = NULL ){
if( $value === NULL || !strlen( $value ) )
return $this->remove( $selector, $key );
$rule = $this->getRuleBySelector( $selector );
if( !$rule ){
$rule = new ADT_CSS_Rule( $selector );
$this->rules[] = $rule;
}
return $rule->setPropertyByKey( $key, $value );
} | [
"public",
"function",
"set",
"(",
"$",
"selector",
",",
"$",
"key",
",",
"$",
"value",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"NULL",
"||",
"!",
"strlen",
"(",
"$",
"value",
")",
")",
"return",
"$",
"this",
"->",
"remove",
"(",
"$",
"selector",
",",
"$",
"key",
")",
";",
"$",
"rule",
"=",
"$",
"this",
"->",
"getRuleBySelector",
"(",
"$",
"selector",
")",
";",
"if",
"(",
"!",
"$",
"rule",
")",
"{",
"$",
"rule",
"=",
"new",
"ADT_CSS_Rule",
"(",
"$",
"selector",
")",
";",
"$",
"this",
"->",
"rules",
"[",
"]",
"=",
"$",
"rule",
";",
"}",
"return",
"$",
"rule",
"->",
"setPropertyByKey",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Sets a properties value.
@access public
@param string $selector Rule selector
@param string $key Property key
@param string $value Property value
@return boolean | [
"Sets",
"a",
"properties",
"value",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L211-L220 |
36,414 | CeusMedia/Common | src/ADT/CSS/Sheet.php | ADT_CSS_Sheet.setProperty | public function setProperty( ADT_CSS_Rule $rule, ADT_CSS_Property $property ){
return $this->set( $rule->getSelector(), $property->getKey(), $property->getValue() ); //
} | php | public function setProperty( ADT_CSS_Rule $rule, ADT_CSS_Property $property ){
return $this->set( $rule->getSelector(), $property->getKey(), $property->getValue() ); //
} | [
"public",
"function",
"setProperty",
"(",
"ADT_CSS_Rule",
"$",
"rule",
",",
"ADT_CSS_Property",
"$",
"property",
")",
"{",
"return",
"$",
"this",
"->",
"set",
"(",
"$",
"rule",
"->",
"getSelector",
"(",
")",
",",
"$",
"property",
"->",
"getKey",
"(",
")",
",",
"$",
"property",
"->",
"getValue",
"(",
")",
")",
";",
"// ",
"}"
] | Sets a property.
@access public
@param ADT_CSS_Rule $rule Rule object
@param ADT_CSS_Property $property Property object
@return boolean | [
"Sets",
"a",
"property",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/CSS/Sheet.php#L229-L231 |
36,415 | CeusMedia/Common | src/FS/File/SyntaxChecker.php | FS_File_SyntaxChecker.checkFile | public function checkFile( $fileName )
{
$output = shell_exec('php -l "'.$fileName.'"');
if( preg_match( "@^No syntax errors detected@", $output ) )
return TRUE;
$this->error = $output;
return FALSE;
} | php | public function checkFile( $fileName )
{
$output = shell_exec('php -l "'.$fileName.'"');
if( preg_match( "@^No syntax errors detected@", $output ) )
return TRUE;
$this->error = $output;
return FALSE;
} | [
"public",
"function",
"checkFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"output",
"=",
"shell_exec",
"(",
"'php -l \"'",
".",
"$",
"fileName",
".",
"'\"'",
")",
";",
"if",
"(",
"preg_match",
"(",
"\"@^No syntax errors detected@\"",
",",
"$",
"output",
")",
")",
"return",
"TRUE",
";",
"$",
"this",
"->",
"error",
"=",
"$",
"output",
";",
"return",
"FALSE",
";",
"}"
] | Returns whether a PHP Class or Script has valid Syntax.
@access public
@param string $fileName File Name of PHP File to check
@return bool | [
"Returns",
"whether",
"a",
"PHP",
"Class",
"or",
"Script",
"has",
"valid",
"Syntax",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/SyntaxChecker.php#L48-L55 |
36,416 | CeusMedia/Common | src/FS/File/SyntaxChecker.php | FS_File_SyntaxChecker.getShortError | public function getShortError()
{
$error = array_shift( explode( "\n", trim( $this->error ) ) );
$error = preg_replace( "@^Parse error: (.*) in (.*) on (.*)$@i", "\\1 on \\3", $error );
return $error;
} | php | public function getShortError()
{
$error = array_shift( explode( "\n", trim( $this->error ) ) );
$error = preg_replace( "@^Parse error: (.*) in (.*) on (.*)$@i", "\\1 on \\3", $error );
return $error;
} | [
"public",
"function",
"getShortError",
"(",
")",
"{",
"$",
"error",
"=",
"array_shift",
"(",
"explode",
"(",
"\"\\n\"",
",",
"trim",
"(",
"$",
"this",
"->",
"error",
")",
")",
")",
";",
"$",
"error",
"=",
"preg_replace",
"(",
"\"@^Parse error: (.*) in (.*) on (.*)$@i\"",
",",
"\"\\\\1 on \\\\3\"",
",",
"$",
"error",
")",
";",
"return",
"$",
"error",
";",
"}"
] | Returns Error of last File Syntax Check in a shorter Format without File Name and Parser Prefix.
@access public
@return string | [
"Returns",
"Error",
"of",
"last",
"File",
"Syntax",
"Check",
"in",
"a",
"shorter",
"Format",
"without",
"File",
"Name",
"and",
"Parser",
"Prefix",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/SyntaxChecker.php#L72-L77 |
36,417 | CeusMedia/Common | src/Alg/Tree/Menu/Converter.php | Alg_Tree_Menu_Converter.buildMenuListFromOutlines | protected static function buildMenuListFromOutlines( $lines, &$container )
{
foreach( $lines as $line )
{
if( isset( $line['outlines'] ) && count( $line['outlines'] ) )
{
if( isset ( $line['url'] ) )
$item = new ADT_Tree_Menu_Item( $line['url'], $line['text'] );
else
$item = new ADT_Tree_Menu_List( $line['text'] );
self::buildMenuListFromOutlines( $line['outlines'], $item );
$container->addChild( $item );
}
else
{
$item = new ADT_Tree_Menu_Item( $line['url'], $line['text'] );
$container->addChild( $item );
}
}
} | php | protected static function buildMenuListFromOutlines( $lines, &$container )
{
foreach( $lines as $line )
{
if( isset( $line['outlines'] ) && count( $line['outlines'] ) )
{
if( isset ( $line['url'] ) )
$item = new ADT_Tree_Menu_Item( $line['url'], $line['text'] );
else
$item = new ADT_Tree_Menu_List( $line['text'] );
self::buildMenuListFromOutlines( $line['outlines'], $item );
$container->addChild( $item );
}
else
{
$item = new ADT_Tree_Menu_Item( $line['url'], $line['text'] );
$container->addChild( $item );
}
}
} | [
"protected",
"static",
"function",
"buildMenuListFromOutlines",
"(",
"$",
"lines",
",",
"&",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"line",
"[",
"'outlines'",
"]",
")",
"&&",
"count",
"(",
"$",
"line",
"[",
"'outlines'",
"]",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"line",
"[",
"'url'",
"]",
")",
")",
"$",
"item",
"=",
"new",
"ADT_Tree_Menu_Item",
"(",
"$",
"line",
"[",
"'url'",
"]",
",",
"$",
"line",
"[",
"'text'",
"]",
")",
";",
"else",
"$",
"item",
"=",
"new",
"ADT_Tree_Menu_List",
"(",
"$",
"line",
"[",
"'text'",
"]",
")",
";",
"self",
"::",
"buildMenuListFromOutlines",
"(",
"$",
"line",
"[",
"'outlines'",
"]",
",",
"$",
"item",
")",
";",
"$",
"container",
"->",
"addChild",
"(",
"$",
"item",
")",
";",
"}",
"else",
"{",
"$",
"item",
"=",
"new",
"ADT_Tree_Menu_Item",
"(",
"$",
"line",
"[",
"'url'",
"]",
",",
"$",
"line",
"[",
"'text'",
"]",
")",
";",
"$",
"container",
"->",
"addChild",
"(",
"$",
"item",
")",
";",
"}",
"}",
"}"
] | Adds Tree Menu Items from OPML Outlines into a given Tree Menu List recursively.
@access public
@static
@param array $outlines Outline Array from OPML Parser
@param ADT_Tree_Menu_List $container Current working Menu Container, a Tree Menu List initially.
@return void | [
"Adds",
"Tree",
"Menu",
"Items",
"from",
"OPML",
"Outlines",
"into",
"a",
"given",
"Tree",
"Menu",
"List",
"recursively",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Tree/Menu/Converter.php#L53-L72 |
36,418 | CeusMedia/Common | src/Alg/Tree/Menu/Converter.php | Alg_Tree_Menu_Converter.convertFromOpml | public static function convertFromOpml( $opml, $labelRoot, $rootClass = NULL )
{
$parser = new XML_OPML_Parser();
$parser->parse( $opml );
$lines = $parser->getOutlines();
$list = new ADT_Tree_Menu_List( $labelRoot, array( 'class' => $rootClass ) );
self::buildMenuListFromOutlines( $lines, $list );
return $list;
} | php | public static function convertFromOpml( $opml, $labelRoot, $rootClass = NULL )
{
$parser = new XML_OPML_Parser();
$parser->parse( $opml );
$lines = $parser->getOutlines();
$list = new ADT_Tree_Menu_List( $labelRoot, array( 'class' => $rootClass ) );
self::buildMenuListFromOutlines( $lines, $list );
return $list;
} | [
"public",
"static",
"function",
"convertFromOpml",
"(",
"$",
"opml",
",",
"$",
"labelRoot",
",",
"$",
"rootClass",
"=",
"NULL",
")",
"{",
"$",
"parser",
"=",
"new",
"XML_OPML_Parser",
"(",
")",
";",
"$",
"parser",
"->",
"parse",
"(",
"$",
"opml",
")",
";",
"$",
"lines",
"=",
"$",
"parser",
"->",
"getOutlines",
"(",
")",
";",
"$",
"list",
"=",
"new",
"ADT_Tree_Menu_List",
"(",
"$",
"labelRoot",
",",
"array",
"(",
"'class'",
"=>",
"$",
"rootClass",
")",
")",
";",
"self",
"::",
"buildMenuListFromOutlines",
"(",
"$",
"lines",
",",
"$",
"list",
")",
";",
"return",
"$",
"list",
";",
"}"
] | Converts an OPML String to a Tree Menu List.
@access public
@static
@param string $opml OPML String
@param string $labelRoot Label of Top Tree Menu List
@param string $rootClass CSS Class of root node
@return ADT_Tree_Menu_List | [
"Converts",
"an",
"OPML",
"String",
"to",
"a",
"Tree",
"Menu",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Tree/Menu/Converter.php#L83-L92 |
36,419 | CeusMedia/Common | src/Alg/Tree/Menu/Converter.php | Alg_Tree_Menu_Converter.convertFromOpmlFile | public static function convertFromOpmlFile( $fileName, $labelRoot, $rootClass = NULL )
{
$opml = FS_File_Reader::load( $fileName );
return self::convertFromOpml( $opml, $labelRoot, $rootClass );
} | php | public static function convertFromOpmlFile( $fileName, $labelRoot, $rootClass = NULL )
{
$opml = FS_File_Reader::load( $fileName );
return self::convertFromOpml( $opml, $labelRoot, $rootClass );
} | [
"public",
"static",
"function",
"convertFromOpmlFile",
"(",
"$",
"fileName",
",",
"$",
"labelRoot",
",",
"$",
"rootClass",
"=",
"NULL",
")",
"{",
"$",
"opml",
"=",
"FS_File_Reader",
"::",
"load",
"(",
"$",
"fileName",
")",
";",
"return",
"self",
"::",
"convertFromOpml",
"(",
"$",
"opml",
",",
"$",
"labelRoot",
",",
"$",
"rootClass",
")",
";",
"}"
] | Converts an OPML File to a Tree Menu List.
@access public
@static
@param string $fileName File Name of OPML File
@param string $labelRoot Label of Top Tree Menu List
@param string $rootClass CSS Class of root node
@return ADT_Tree_Menu_List | [
"Converts",
"an",
"OPML",
"File",
"to",
"a",
"Tree",
"Menu",
"List",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Tree/Menu/Converter.php#L103-L107 |
36,420 | CeusMedia/Common | src/XML/WDDX/FileWriter.php | XML_WDDX_FileWriter.write | public function write()
{
$wddx = $this->builder->build();
$writer = new FS_File_Writer( $this->fileName );
return $writer->writeString( $wddx );
} | php | public function write()
{
$wddx = $this->builder->build();
$writer = new FS_File_Writer( $this->fileName );
return $writer->writeString( $wddx );
} | [
"public",
"function",
"write",
"(",
")",
"{",
"$",
"wddx",
"=",
"$",
"this",
"->",
"builder",
"->",
"build",
"(",
")",
";",
"$",
"writer",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"return",
"$",
"writer",
"->",
"writeString",
"(",
"$",
"wddx",
")",
";",
"}"
] | Writes collected Data into WDDX File.
@access public
@param string string String to write to WDDX File
@return bool | [
"Writes",
"collected",
"Data",
"into",
"WDDX",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/FileWriter.php#L78-L83 |
36,421 | CeusMedia/Common | src/XML/WDDX/FileWriter.php | XML_WDDX_FileWriter.save | public static function save( $fileName, $data, $packetName = NULL )
{
if( $packetName === NULL )
$wddx = wddx_serialize_value( $data );
else
$wddx = wddx_serialize_value( $data, $packetName );
return FS_File_Writer::save( $fileName, $wddx );
} | php | public static function save( $fileName, $data, $packetName = NULL )
{
if( $packetName === NULL )
$wddx = wddx_serialize_value( $data );
else
$wddx = wddx_serialize_value( $data, $packetName );
return FS_File_Writer::save( $fileName, $wddx );
} | [
"public",
"static",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"data",
",",
"$",
"packetName",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"packetName",
"===",
"NULL",
")",
"$",
"wddx",
"=",
"wddx_serialize_value",
"(",
"$",
"data",
")",
";",
"else",
"$",
"wddx",
"=",
"wddx_serialize_value",
"(",
"$",
"data",
",",
"$",
"packetName",
")",
";",
"return",
"FS_File_Writer",
"::",
"save",
"(",
"$",
"fileName",
",",
"$",
"wddx",
")",
";",
"}"
] | Writes Data into a WDDX File statically.
@access public
@static
@param string $fileName File Name of WDDX File
@param array $data Array of Packet Data
@param string $packetName Packet Name
@return int | [
"Writes",
"Data",
"into",
"a",
"WDDX",
"File",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/WDDX/FileWriter.php#L94-L101 |
36,422 | CeusMedia/Common | src/Net/XMPP/MessageSender.php | Net_XMPP_MessageSender.connect | public function connect( Net_XMPP_JID $sender, $password )
{
$this->xmpp = new Net_XMPP_XMPPHP_XMPP(
$sender->getDomain(),
$this->port,
$sender->getNode(),
$password,
$sender->getResource() ? $sender->getResource() : $this->resource,
$sender->getDomain(),
$this->printLog,
$this->logLevel
);
$this->xmpp->use_encyption = $this->encryption;
$this->xmpp->connect();
$this->xmpp->processUntil( 'session_start' );
} | php | public function connect( Net_XMPP_JID $sender, $password )
{
$this->xmpp = new Net_XMPP_XMPPHP_XMPP(
$sender->getDomain(),
$this->port,
$sender->getNode(),
$password,
$sender->getResource() ? $sender->getResource() : $this->resource,
$sender->getDomain(),
$this->printLog,
$this->logLevel
);
$this->xmpp->use_encyption = $this->encryption;
$this->xmpp->connect();
$this->xmpp->processUntil( 'session_start' );
} | [
"public",
"function",
"connect",
"(",
"Net_XMPP_JID",
"$",
"sender",
",",
"$",
"password",
")",
"{",
"$",
"this",
"->",
"xmpp",
"=",
"new",
"Net_XMPP_XMPPHP_XMPP",
"(",
"$",
"sender",
"->",
"getDomain",
"(",
")",
",",
"$",
"this",
"->",
"port",
",",
"$",
"sender",
"->",
"getNode",
"(",
")",
",",
"$",
"password",
",",
"$",
"sender",
"->",
"getResource",
"(",
")",
"?",
"$",
"sender",
"->",
"getResource",
"(",
")",
":",
"$",
"this",
"->",
"resource",
",",
"$",
"sender",
"->",
"getDomain",
"(",
")",
",",
"$",
"this",
"->",
"printLog",
",",
"$",
"this",
"->",
"logLevel",
")",
";",
"$",
"this",
"->",
"xmpp",
"->",
"use_encyption",
"=",
"$",
"this",
"->",
"encryption",
";",
"$",
"this",
"->",
"xmpp",
"->",
"connect",
"(",
")",
";",
"$",
"this",
"->",
"xmpp",
"->",
"processUntil",
"(",
"'session_start'",
")",
";",
"}"
] | Establishs Connection to XMPP Server.
@access public
@param Net_XMPP_JID $sender JID of sender
@param string $password Password of Sender
@param int $port Port of XMPP Server
@return void | [
"Establishs",
"Connection",
"to",
"XMPP",
"Server",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/MessageSender.php#L97-L112 |
36,423 | CeusMedia/Common | src/Net/XMPP/MessageSender.php | Net_XMPP_MessageSender.disconnect | public function disconnect()
{
if( $this->xmpp )
{
if( $this->printLog )
echo $this->xmpp->log->printout();
$this->xmpp->disconnect();
$this->xmpp = NULL;
return TRUE;
}
return FALSE;
} | php | public function disconnect()
{
if( $this->xmpp )
{
if( $this->printLog )
echo $this->xmpp->log->printout();
$this->xmpp->disconnect();
$this->xmpp = NULL;
return TRUE;
}
return FALSE;
} | [
"public",
"function",
"disconnect",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"xmpp",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"printLog",
")",
"echo",
"$",
"this",
"->",
"xmpp",
"->",
"log",
"->",
"printout",
"(",
")",
";",
"$",
"this",
"->",
"xmpp",
"->",
"disconnect",
"(",
")",
";",
"$",
"this",
"->",
"xmpp",
"=",
"NULL",
";",
"return",
"TRUE",
";",
"}",
"return",
"FALSE",
";",
"}"
] | Closes Connection if still open.
@access public
@return bool | [
"Closes",
"Connection",
"if",
"still",
"open",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/MessageSender.php#L119-L130 |
36,424 | CeusMedia/Common | src/Net/XMPP/MessageSender.php | Net_XMPP_MessageSender.sendMessage | public function sendMessage( $message )
{
if( !$this->receiver )
throw new RuntimeException( 'No Receiver set.' );
$this->sendMessageTo( $message, $this->receiver->get() );
} | php | public function sendMessage( $message )
{
if( !$this->receiver )
throw new RuntimeException( 'No Receiver set.' );
$this->sendMessageTo( $message, $this->receiver->get() );
} | [
"public",
"function",
"sendMessage",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"receiver",
")",
"throw",
"new",
"RuntimeException",
"(",
"'No Receiver set.'",
")",
";",
"$",
"this",
"->",
"sendMessageTo",
"(",
"$",
"message",
",",
"$",
"this",
"->",
"receiver",
"->",
"get",
"(",
")",
")",
";",
"}"
] | Sends Message to set Receiver.
@access public
@param string $message Message to send to Receiver
@return void
@throws RuntimeException if no receiver has been set | [
"Sends",
"Message",
"to",
"set",
"Receiver",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/MessageSender.php#L139-L144 |
36,425 | CeusMedia/Common | src/Net/XMPP/MessageSender.php | Net_XMPP_MessageSender.sendMessageTo | public function sendMessageTo( $message, $receiver )
{
if( is_string( $receiver ) )
$receiver = new Net_XMPP_JID( $receiver );
if( !$this->xmpp )
throw new RuntimeException( 'Not connected to Server.' );
$this->xmpp->message( $receiver->get(), $message );
} | php | public function sendMessageTo( $message, $receiver )
{
if( is_string( $receiver ) )
$receiver = new Net_XMPP_JID( $receiver );
if( !$this->xmpp )
throw new RuntimeException( 'Not connected to Server.' );
$this->xmpp->message( $receiver->get(), $message );
} | [
"public",
"function",
"sendMessageTo",
"(",
"$",
"message",
",",
"$",
"receiver",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"receiver",
")",
")",
"$",
"receiver",
"=",
"new",
"Net_XMPP_JID",
"(",
"$",
"receiver",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"xmpp",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Not connected to Server.'",
")",
";",
"$",
"this",
"->",
"xmpp",
"->",
"message",
"(",
"$",
"receiver",
"->",
"get",
"(",
")",
",",
"$",
"message",
")",
";",
"}"
] | Sends Message to a Receiver.
@access public
@param string $message Message to send to Receiver
@param string $receiver JID of Receiver
@return void
@throws RuntimeException if XMPP connection is not established | [
"Sends",
"Message",
"to",
"a",
"Receiver",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/MessageSender.php#L154-L161 |
36,426 | CeusMedia/Common | src/Net/XMPP/MessageSender.php | Net_XMPP_MessageSender.setReceiver | public function setReceiver( $receiver )
{
if( is_string( $receiver ) )
$receiver = new Net_XMPP_JID( $receiver );
$this->receiver = $receiver;
} | php | public function setReceiver( $receiver )
{
if( is_string( $receiver ) )
$receiver = new Net_XMPP_JID( $receiver );
$this->receiver = $receiver;
} | [
"public",
"function",
"setReceiver",
"(",
"$",
"receiver",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"receiver",
")",
")",
"$",
"receiver",
"=",
"new",
"Net_XMPP_JID",
"(",
"$",
"receiver",
")",
";",
"$",
"this",
"->",
"receiver",
"=",
"$",
"receiver",
";",
"}"
] | Sets Receiver by its JID.
@access public
@param string $receiver JID of Receiver
@return void | [
"Sets",
"Receiver",
"by",
"its",
"JID",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/XMPP/MessageSender.php#L225-L230 |
36,427 | php-toolkit/cli-utils | src/Highlighter.php | Highlighter.highlight | public function highlight(string $source, bool $withLineNumber = false): string
{
$tokenLines = $this->getHighlightedLines($source);
$lines = $this->colorLines($tokenLines);
if ($withLineNumber) {
return $this->lineNumbers($lines);
}
return \implode(\PHP_EOL, $lines);
} | php | public function highlight(string $source, bool $withLineNumber = false): string
{
$tokenLines = $this->getHighlightedLines($source);
$lines = $this->colorLines($tokenLines);
if ($withLineNumber) {
return $this->lineNumbers($lines);
}
return \implode(\PHP_EOL, $lines);
} | [
"public",
"function",
"highlight",
"(",
"string",
"$",
"source",
",",
"bool",
"$",
"withLineNumber",
"=",
"false",
")",
":",
"string",
"{",
"$",
"tokenLines",
"=",
"$",
"this",
"->",
"getHighlightedLines",
"(",
"$",
"source",
")",
";",
"$",
"lines",
"=",
"$",
"this",
"->",
"colorLines",
"(",
"$",
"tokenLines",
")",
";",
"if",
"(",
"$",
"withLineNumber",
")",
"{",
"return",
"$",
"this",
"->",
"lineNumbers",
"(",
"$",
"lines",
")",
";",
"}",
"return",
"\\",
"implode",
"(",
"\\",
"PHP_EOL",
",",
"$",
"lines",
")",
";",
"}"
] | highlight a full php file content
@param string $source
@param bool $withLineNumber with line number
@return string | [
"highlight",
"a",
"full",
"php",
"file",
"content"
] | bc60e7744db8f5452a1421770c00e315d00e3153 | https://github.com/php-toolkit/cli-utils/blob/bc60e7744db8f5452a1421770c00e315d00e3153/src/Highlighter.php#L71-L81 |
36,428 | CeusMedia/Common | src/Alg/Validation/PredicateValidator.php | Alg_Validation_PredicateValidator.isClass | public function isClass( $value, $class )
{
$method = "is".ucFirst( $class );
if( !method_exists( $this->validator, $method ) )
throw new BadMethodCallException( 'Predicate "'.$method.'" is not defined.' );
return $this->validator->$method( $value, $method );
} | php | public function isClass( $value, $class )
{
$method = "is".ucFirst( $class );
if( !method_exists( $this->validator, $method ) )
throw new BadMethodCallException( 'Predicate "'.$method.'" is not defined.' );
return $this->validator->$method( $value, $method );
} | [
"public",
"function",
"isClass",
"(",
"$",
"value",
",",
"$",
"class",
")",
"{",
"$",
"method",
"=",
"\"is\"",
".",
"ucFirst",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"validator",
",",
"$",
"method",
")",
")",
"throw",
"new",
"BadMethodCallException",
"(",
"'Predicate \"'",
".",
"$",
"method",
".",
"'\" is not defined.'",
")",
";",
"return",
"$",
"this",
"->",
"validator",
"->",
"$",
"method",
"(",
"$",
"value",
",",
"$",
"method",
")",
";",
"}"
] | Indicates whether a String is of a specific Character Class.
@access public
@param string $value String to be checked
@param string $class Key of Character Class
@return bool | [
"Indicates",
"whether",
"a",
"String",
"is",
"of",
"a",
"specific",
"Character",
"Class",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/PredicateValidator.php#L63-L69 |
36,429 | CeusMedia/Common | src/Alg/Validation/PredicateValidator.php | Alg_Validation_PredicateValidator.validate | public function validate( $value, $predicate, $argument = NULL )
{
if( !method_exists( $this->validator, $predicate ) )
throw new BadMethodCallException( 'Predicate "'.$predicate.'" is not defined.' );
try
{
return $this->validator->$predicate( $value, $argument );
}
catch( InvalidArgumentException $e )
{
return false;
}
catch( Exception $e )
{
throw $e;
}
} | php | public function validate( $value, $predicate, $argument = NULL )
{
if( !method_exists( $this->validator, $predicate ) )
throw new BadMethodCallException( 'Predicate "'.$predicate.'" is not defined.' );
try
{
return $this->validator->$predicate( $value, $argument );
}
catch( InvalidArgumentException $e )
{
return false;
}
catch( Exception $e )
{
throw $e;
}
} | [
"public",
"function",
"validate",
"(",
"$",
"value",
",",
"$",
"predicate",
",",
"$",
"argument",
"=",
"NULL",
")",
"{",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"this",
"->",
"validator",
",",
"$",
"predicate",
")",
")",
"throw",
"new",
"BadMethodCallException",
"(",
"'Predicate \"'",
".",
"$",
"predicate",
".",
"'\" is not defined.'",
")",
";",
"try",
"{",
"return",
"$",
"this",
"->",
"validator",
"->",
"$",
"predicate",
"(",
"$",
"value",
",",
"$",
"argument",
")",
";",
"}",
"catch",
"(",
"InvalidArgumentException",
"$",
"e",
")",
"{",
"return",
"false",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"}"
] | Indicates whether a String validates against a Predicate.
@access public
@param string $value String to be checked
@param string $predicate Method Name of Predicate
@param string $argument Argument for Predicate
@return bool | [
"Indicates",
"whether",
"a",
"String",
"validates",
"against",
"a",
"Predicate",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Validation/PredicateValidator.php#L79-L95 |
36,430 | CeusMedia/Common | src/FS/File/Gantt/MeetingCollector.php | FS_File_Gantt_MeetingCollector.listProjectFiles | protected static function listProjectFiles( $path )
{
$list = array();
$dir = new DirectoryIterator( $path );
foreach( $dir as $entry )
{
if( $entry->isDot() )
continue;
if( !preg_match( "@\.gan$@", $entry->getFilename() ) )
continue;
$list[] = $entry->getPathname();
}
return $list;
} | php | protected static function listProjectFiles( $path )
{
$list = array();
$dir = new DirectoryIterator( $path );
foreach( $dir as $entry )
{
if( $entry->isDot() )
continue;
if( !preg_match( "@\.gan$@", $entry->getFilename() ) )
continue;
$list[] = $entry->getPathname();
}
return $list;
} | [
"protected",
"static",
"function",
"listProjectFiles",
"(",
"$",
"path",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"dir",
"=",
"new",
"DirectoryIterator",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"dir",
"as",
"$",
"entry",
")",
"{",
"if",
"(",
"$",
"entry",
"->",
"isDot",
"(",
")",
")",
"continue",
";",
"if",
"(",
"!",
"preg_match",
"(",
"\"@\\.gan$@\"",
",",
"$",
"entry",
"->",
"getFilename",
"(",
")",
")",
")",
"continue",
";",
"$",
"list",
"[",
"]",
"=",
"$",
"entry",
"->",
"getPathname",
"(",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Lists all Gantt Project XML Files in a specified Path.
@access protected
@static
@param array $path Path to Gantt Project XML Files
@return array | [
"Lists",
"all",
"Gantt",
"Project",
"XML",
"Files",
"in",
"a",
"specified",
"Path",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/MeetingCollector.php#L114-L127 |
36,431 | CeusMedia/Common | src/FS/File/Gantt/MeetingCollector.php | FS_File_Gantt_MeetingCollector.readProjectFiles | protected static function readProjectFiles( $fileList )
{
$projects = array();
foreach( $fileList as $fileName )
{
$reader = new FS_File_Gantt_MeetingReader( $fileName );
$projects[] = $reader->getProjectData();
}
return $projects;
} | php | protected static function readProjectFiles( $fileList )
{
$projects = array();
foreach( $fileList as $fileName )
{
$reader = new FS_File_Gantt_MeetingReader( $fileName );
$projects[] = $reader->getProjectData();
}
return $projects;
} | [
"protected",
"static",
"function",
"readProjectFiles",
"(",
"$",
"fileList",
")",
"{",
"$",
"projects",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fileList",
"as",
"$",
"fileName",
")",
"{",
"$",
"reader",
"=",
"new",
"FS_File_Gantt_MeetingReader",
"(",
"$",
"fileName",
")",
";",
"$",
"projects",
"[",
"]",
"=",
"$",
"reader",
"->",
"getProjectData",
"(",
")",
";",
"}",
"return",
"$",
"projects",
";",
"}"
] | Reads Gantt Project XML Files and extracts Project and Meeting Dates.
@access protected
@static
@param array $fileList List of Gantt Project XML Files
@return array | [
"Reads",
"Gantt",
"Project",
"XML",
"Files",
"and",
"extracts",
"Project",
"and",
"Meeting",
"Dates",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Gantt/MeetingCollector.php#L136-L145 |
36,432 | CeusMedia/Common | src/ADT/Object.php | ADT_Object.getObjectInfo | public function getObjectInfo()
{
$info = array(
'name' => $this->getClass(),
'parent' => $this->getParent(),
'methods' => $this->getMethods(),
'vars' => $this->getVars(),
);
return $info;
} | php | public function getObjectInfo()
{
$info = array(
'name' => $this->getClass(),
'parent' => $this->getParent(),
'methods' => $this->getMethods(),
'vars' => $this->getVars(),
);
return $info;
} | [
"public",
"function",
"getObjectInfo",
"(",
")",
"{",
"$",
"info",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"this",
"->",
"getClass",
"(",
")",
",",
"'parent'",
"=>",
"$",
"this",
"->",
"getParent",
"(",
")",
",",
"'methods'",
"=>",
"$",
"this",
"->",
"getMethods",
"(",
")",
",",
"'vars'",
"=>",
"$",
"this",
"->",
"getVars",
"(",
")",
",",
")",
";",
"return",
"$",
"info",
";",
"}"
] | Returns an Array with Information about current Object.
@access public
@return array | [
"Returns",
"an",
"Array",
"with",
"Information",
"about",
"current",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Object.php#L65-L74 |
36,433 | CeusMedia/Common | src/ADT/Object.php | ADT_Object.hasMethod | public function hasMethod( $methodName, $callableOnly = TRUE )
{
if( $callableOnly )
return method_exists( $this, $methodName ) && is_callable( array( $this, $methodName ) );
else
return method_exists( $this, $methodName );
} | php | public function hasMethod( $methodName, $callableOnly = TRUE )
{
if( $callableOnly )
return method_exists( $this, $methodName ) && is_callable( array( $this, $methodName ) );
else
return method_exists( $this, $methodName );
} | [
"public",
"function",
"hasMethod",
"(",
"$",
"methodName",
",",
"$",
"callableOnly",
"=",
"TRUE",
")",
"{",
"if",
"(",
"$",
"callableOnly",
")",
"return",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
"&&",
"is_callable",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
")",
";",
"else",
"return",
"method_exists",
"(",
"$",
"this",
",",
"$",
"methodName",
")",
";",
"}"
] | Indicates whether an Method is existing within current Object.
@access public
@param string $methodName Name of Method to check
@param bool $callableOnly Flag: also check if Method is callable
@return bool | [
"Indicates",
"whether",
"an",
"Method",
"is",
"existing",
"within",
"current",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Object.php#L103-L109 |
36,434 | CeusMedia/Common | src/Net/HTTP/Response.php | Net_HTTP_Response.addHeader | public function addHeader( Net_HTTP_Header_Field $field, $emptyBefore = NULL )
{
$this->headers->setField( $field, $emptyBefore );
} | php | public function addHeader( Net_HTTP_Header_Field $field, $emptyBefore = NULL )
{
$this->headers->setField( $field, $emptyBefore );
} | [
"public",
"function",
"addHeader",
"(",
"Net_HTTP_Header_Field",
"$",
"field",
",",
"$",
"emptyBefore",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"headers",
"->",
"setField",
"(",
"$",
"field",
",",
"$",
"emptyBefore",
")",
";",
"}"
] | Adds an HTTP header field object.
@access public
@param Net_HTTP_Header_Field $field HTTP header field object
@return void | [
"Adds",
"an",
"HTTP",
"header",
"field",
"object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response.php#L73-L76 |
36,435 | CeusMedia/Common | src/Net/HTTP/Response.php | Net_HTTP_Response.addHeaderPair | public function addHeaderPair( $name, $value, $emptyBefore = NULL )
{
$this->headers->setField( new Net_HTTP_Header_Field( $name, $value ), $emptyBefore );
} | php | public function addHeaderPair( $name, $value, $emptyBefore = NULL )
{
$this->headers->setField( new Net_HTTP_Header_Field( $name, $value ), $emptyBefore );
} | [
"public",
"function",
"addHeaderPair",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"emptyBefore",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"headers",
"->",
"setField",
"(",
"new",
"Net_HTTP_Header_Field",
"(",
"$",
"name",
",",
"$",
"value",
")",
",",
"$",
"emptyBefore",
")",
";",
"}"
] | Adds an HTTP header.
@access public
@param string $name HTTP header name
@param string $value HTTP header value
@return void | [
"Adds",
"an",
"HTTP",
"header",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response.php#L85-L88 |
36,436 | CeusMedia/Common | src/Net/HTTP/Response.php | Net_HTTP_Response.getHeader | public function getHeader( $key, $first = NULL )
{
$fields = $this->headers->getFieldsByName( $key ); // get all header fields with this header name
if( !$first ) // all header fields shall be returned
return $fields; // return all header fields
if( $fields ) // otherwise: header fields (atleat one) are set
return $fields[0]; // return first header field
return new Net_HTTP_Header_Field( $key, NULL ); // otherwise: return empty fake header field
} | php | public function getHeader( $key, $first = NULL )
{
$fields = $this->headers->getFieldsByName( $key ); // get all header fields with this header name
if( !$first ) // all header fields shall be returned
return $fields; // return all header fields
if( $fields ) // otherwise: header fields (atleat one) are set
return $fields[0]; // return first header field
return new Net_HTTP_Header_Field( $key, NULL ); // otherwise: return empty fake header field
} | [
"public",
"function",
"getHeader",
"(",
"$",
"key",
",",
"$",
"first",
"=",
"NULL",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"headers",
"->",
"getFieldsByName",
"(",
"$",
"key",
")",
";",
"// get all header fields with this header name",
"if",
"(",
"!",
"$",
"first",
")",
"// all header fields shall be returned",
"return",
"$",
"fields",
";",
"// return all header fields",
"if",
"(",
"$",
"fields",
")",
"// otherwise: header fields (atleat one) are set",
"return",
"$",
"fields",
"[",
"0",
"]",
";",
"// return first header field",
"return",
"new",
"Net_HTTP_Header_Field",
"(",
"$",
"key",
",",
"NULL",
")",
";",
"// otherwise: return empty fake header field",
"}"
] | Returns response headers.
@access public
@param string $string Header name
@param bool $first Flag: return first header only
@return array|Net_HTTP_Header_Field List of header fields or only one header field if requested so | [
"Returns",
"response",
"headers",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response.php#L107-L115 |
36,437 | CeusMedia/Common | src/Net/HTTP/Response.php | Net_HTTP_Response.setBody | public function setBody( $body )
{
if( !is_string( $body ) )
throw new InvalidArgumentException( 'Body must be string' );
$this->body = trim( $body );
$this->headers->setFieldPair( "Content-Length", strlen( $this->body ), TRUE );
} | php | public function setBody( $body )
{
if( !is_string( $body ) )
throw new InvalidArgumentException( 'Body must be string' );
$this->body = trim( $body );
$this->headers->setFieldPair( "Content-Length", strlen( $this->body ), TRUE );
} | [
"public",
"function",
"setBody",
"(",
"$",
"body",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"body",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Body must be string'",
")",
";",
"$",
"this",
"->",
"body",
"=",
"trim",
"(",
"$",
"body",
")",
";",
"$",
"this",
"->",
"headers",
"->",
"setFieldPair",
"(",
"\"Content-Length\"",
",",
"strlen",
"(",
"$",
"this",
"->",
"body",
")",
",",
"TRUE",
")",
";",
"}"
] | Sets response message body.
@access public
@param string $body Response message body
@return void | [
"Sets",
"response",
"message",
"body",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response.php#L179-L185 |
36,438 | CeusMedia/Common | src/Net/HTTP/Response.php | Net_HTTP_Response.toString | public function toString()
{
$lines = array();
$lines[] = $this->protocol.'/'.$this->version.' '.$this->status; // add main protocol header
$lines[] = $this->headers->toString(); // add header fields and line break
if( strlen( $this->body ) ) // response body is set
$lines[] = $this->body; // add response body
return join( "\r\n", $lines ); // glue parts with line break and return result
} | php | public function toString()
{
$lines = array();
$lines[] = $this->protocol.'/'.$this->version.' '.$this->status; // add main protocol header
$lines[] = $this->headers->toString(); // add header fields and line break
if( strlen( $this->body ) ) // response body is set
$lines[] = $this->body; // add response body
return join( "\r\n", $lines ); // glue parts with line break and return result
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"lines",
"=",
"array",
"(",
")",
";",
"$",
"lines",
"[",
"]",
"=",
"$",
"this",
"->",
"protocol",
".",
"'/'",
".",
"$",
"this",
"->",
"version",
".",
"' '",
".",
"$",
"this",
"->",
"status",
";",
"// add main protocol header",
"$",
"lines",
"[",
"]",
"=",
"$",
"this",
"->",
"headers",
"->",
"toString",
"(",
")",
";",
"// add header fields and line break",
"if",
"(",
"strlen",
"(",
"$",
"this",
"->",
"body",
")",
")",
"// response body is set",
"$",
"lines",
"[",
"]",
"=",
"$",
"this",
"->",
"body",
";",
"// add response body",
"return",
"join",
"(",
"\"\\r\\n\"",
",",
"$",
"lines",
")",
";",
"// glue parts with line break and return result",
"}"
] | Renders complete response string.
@access public
@return string | [
"Renders",
"complete",
"response",
"string",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Response.php#L244-L252 |
36,439 | CeusMedia/Common | src/Net/HTTP/Sniffer/MimeType.php | Net_HTTP_Sniffer_MimeType.getMimeType | public static function getMimeType( $allowed, $default = false )
{
if( !$default)
$default = $allowed[0];
$pattern = '@^([a-z\*\+]+(/[a-z\*\+]+)*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$@i';
$accepted = getEnv( 'HTTP_ACCEPT' );
if( !$accepted )
return $default;
$accepted = preg_split( '/,\s*/', $accepted );
$curr_mime = $default;
$curr_qual = 0;
foreach( $accepted as $accept)
{
if( !preg_match ( $pattern, $accept, $matches ) )
continue;
$mime_code = explode ( '/', $matches[1] );
$mime_quality = isset( $matches[3] ) ? (float) $matches[3] : 1.0;
while( count( $mime_code ) )
{
if( in_array( strtolower( join( '/', $mime_code ) ), $allowed ) )
{
if( $mime_quality > $curr_qual )
{
$curr_mime = strtolower( join( '/', $mime_code ) );
$curr_qual = $mime_quality;
break;
}
}
array_pop( $mime_code );
}
}
return $curr_mime;
} | php | public static function getMimeType( $allowed, $default = false )
{
if( !$default)
$default = $allowed[0];
$pattern = '@^([a-z\*\+]+(/[a-z\*\+]+)*)(?:;\s*q=(0(?:\.[0-9]{1,3})?|1(?:\.0{1,3})?))?$@i';
$accepted = getEnv( 'HTTP_ACCEPT' );
if( !$accepted )
return $default;
$accepted = preg_split( '/,\s*/', $accepted );
$curr_mime = $default;
$curr_qual = 0;
foreach( $accepted as $accept)
{
if( !preg_match ( $pattern, $accept, $matches ) )
continue;
$mime_code = explode ( '/', $matches[1] );
$mime_quality = isset( $matches[3] ) ? (float) $matches[3] : 1.0;
while( count( $mime_code ) )
{
if( in_array( strtolower( join( '/', $mime_code ) ), $allowed ) )
{
if( $mime_quality > $curr_qual )
{
$curr_mime = strtolower( join( '/', $mime_code ) );
$curr_qual = $mime_quality;
break;
}
}
array_pop( $mime_code );
}
}
return $curr_mime;
} | [
"public",
"static",
"function",
"getMimeType",
"(",
"$",
"allowed",
",",
"$",
"default",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"default",
")",
"$",
"default",
"=",
"$",
"allowed",
"[",
"0",
"]",
";",
"$",
"pattern",
"=",
"'@^([a-z\\*\\+]+(/[a-z\\*\\+]+)*)(?:;\\s*q=(0(?:\\.[0-9]{1,3})?|1(?:\\.0{1,3})?))?$@i'",
";",
"$",
"accepted",
"=",
"getEnv",
"(",
"'HTTP_ACCEPT'",
")",
";",
"if",
"(",
"!",
"$",
"accepted",
")",
"return",
"$",
"default",
";",
"$",
"accepted",
"=",
"preg_split",
"(",
"'/,\\s*/'",
",",
"$",
"accepted",
")",
";",
"$",
"curr_mime",
"=",
"$",
"default",
";",
"$",
"curr_qual",
"=",
"0",
";",
"foreach",
"(",
"$",
"accepted",
"as",
"$",
"accept",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"accept",
",",
"$",
"matches",
")",
")",
"continue",
";",
"$",
"mime_code",
"=",
"explode",
"(",
"'/'",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"mime_quality",
"=",
"isset",
"(",
"$",
"matches",
"[",
"3",
"]",
")",
"?",
"(",
"float",
")",
"$",
"matches",
"[",
"3",
"]",
":",
"1.0",
";",
"while",
"(",
"count",
"(",
"$",
"mime_code",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"join",
"(",
"'/'",
",",
"$",
"mime_code",
")",
")",
",",
"$",
"allowed",
")",
")",
"{",
"if",
"(",
"$",
"mime_quality",
">",
"$",
"curr_qual",
")",
"{",
"$",
"curr_mime",
"=",
"strtolower",
"(",
"join",
"(",
"'/'",
",",
"$",
"mime_code",
")",
")",
";",
"$",
"curr_qual",
"=",
"$",
"mime_quality",
";",
"break",
";",
"}",
"}",
"array_pop",
"(",
"$",
"mime_code",
")",
";",
"}",
"}",
"return",
"$",
"curr_mime",
";",
"}"
] | Returns prefered allowed and accepted Mime Types.
@access public
@static
@param array $allowed Array of Mime Types supported and allowed by the Application
@param string $default Default Mime Types supported and allowed by the Application
@return string | [
"Returns",
"prefered",
"allowed",
"and",
"accepted",
"Mime",
"Types",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Sniffer/MimeType.php#L50-L82 |
36,440 | CeusMedia/Common | src/XML/OPML/FileWriter.php | XML_OPML_FileWriter.save | public static function save( $fileName, $tree, $encoding = "utf-8" )
{
$builder = new XML_DOM_Builder();
$xml = $builder->build( $tree, $encoding );
$file = new FS_File_Writer( $fileName, 0777 );
return $file->writeString( $xml );
} | php | public static function save( $fileName, $tree, $encoding = "utf-8" )
{
$builder = new XML_DOM_Builder();
$xml = $builder->build( $tree, $encoding );
$file = new FS_File_Writer( $fileName, 0777 );
return $file->writeString( $xml );
} | [
"public",
"static",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"tree",
",",
"$",
"encoding",
"=",
"\"utf-8\"",
")",
"{",
"$",
"builder",
"=",
"new",
"XML_DOM_Builder",
"(",
")",
";",
"$",
"xml",
"=",
"$",
"builder",
"->",
"build",
"(",
"$",
"tree",
",",
"$",
"encoding",
")",
";",
"$",
"file",
"=",
"new",
"FS_File_Writer",
"(",
"$",
"fileName",
",",
"0777",
")",
";",
"return",
"$",
"file",
"->",
"writeString",
"(",
"$",
"xml",
")",
";",
"}"
] | Saves OPML Tree to OPML File statically.
@access public
@static
@param string $fileName URI of OPML File
@param XML_DOM_Node tree OPML Tree
@param string encoding Encoding Type
@return bool | [
"Saves",
"OPML",
"Tree",
"to",
"OPML",
"File",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/OPML/FileWriter.php#L65-L71 |
36,441 | CeusMedia/Common | src/ADT/PHP/Class.php | ADT_PHP_Class.& | public function & getMemberByName( $name )
{
if( isset( $this->members[$name] ) )
return $this->members[$name];
throw new RuntimeException( "Member '$name' is unknown" );
} | php | public function & getMemberByName( $name )
{
if( isset( $this->members[$name] ) )
return $this->members[$name];
throw new RuntimeException( "Member '$name' is unknown" );
} | [
"public",
"function",
"&",
"getMemberByName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"members",
"[",
"$",
"name",
"]",
")",
")",
"return",
"$",
"this",
"->",
"members",
"[",
"$",
"name",
"]",
";",
"throw",
"new",
"RuntimeException",
"(",
"\"Member '$name' is unknown\"",
")",
";",
"}"
] | Returns a member data object by its name.
@access public
@param string $name Member name
@return ADT_PHP_Member Member data object | [
"Returns",
"a",
"member",
"data",
"object",
"by",
"its",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/PHP/Class.php#L70-L75 |
36,442 | ncou/Chiron | src/Chiron/Http/Emitter/ResponseEmitter.php | ResponseEmitter.emitHeaders | private function emitHeaders(ResponseInterface $response): void
{
/*
if (headers_sent($file, $line)) {
throw new \RuntimeException(sprintf('Failed to send headers, because headers have already been sent by "%s" at line %d.', $file, $line));
}*/
// headers have already been sent by the developer
if (headers_sent()) {
return;
}
$statusCode = $response->getStatusCode();
// TODO : regarder ici pour voir comment on emet les cookies !!!!! https://github.com/zendframework/zend-diactoros/blob/master/src/Response/SapiEmitterTrait.php#L78
// TODO : regarder ici, car un header peut avoir un tableau de valeurs, dans le cas ou on a mergé 2 headers identiques !!!! https://github.com/slimphp/Slim/blob/3.x/Slim/App.php#L393
// headers
foreach ($response->getHeaders() as $name => $values) {
$first = stripos($name, 'Set-Cookie') === 0 ? false : true;
foreach ($values as $value) {
header(sprintf('%s: %s', $name, $value), $first, $statusCode);
$first = false;
}
}
// TODO : gérer le cas ou il n'y a pas de ReasonPhrase et mettre une chaine vide : https://github.com/zendframework/zend-diactoros/blob/master/src/Response/SapiEmitterTrait.php#L55
// Set proper protocol, status code (and reason phrase) header
/*
if ($response->getReasonPhrase()) {
header(sprintf(
'HTTP/%s %d %s',
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getReasonPhrase()
));
} else {
header(sprintf(
'HTTP/%s %d',
$response->getProtocolVersion(),
$response->getStatusCode()
));
}*/
// It is important to mention that this method should be called after the headers are sent, in order to prevent PHP from changing the status code of the emitted response.
header(sprintf('HTTP/%s %d %s', $response->getProtocolVersion(), $statusCode, $response->getReasonPhrase()), true, $statusCode);
// cookies
//TODO : utiliser les cookies comme des "headers" classiques ('Set-Cookies:xxxxxxx')
//https://github.com/paragonie/PHP-Cookie/blob/master/src/Cookie.php#L358
// foreach ($response->getCookies() as $cookie) {
// setrawcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
// }
// flush();
// }
// cookies
/*
foreach ($this->headers->getCookies() as $cookie) {
if ($cookie->isRaw()) {
setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
} else {
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
}
}*/
} | php | private function emitHeaders(ResponseInterface $response): void
{
/*
if (headers_sent($file, $line)) {
throw new \RuntimeException(sprintf('Failed to send headers, because headers have already been sent by "%s" at line %d.', $file, $line));
}*/
// headers have already been sent by the developer
if (headers_sent()) {
return;
}
$statusCode = $response->getStatusCode();
// TODO : regarder ici pour voir comment on emet les cookies !!!!! https://github.com/zendframework/zend-diactoros/blob/master/src/Response/SapiEmitterTrait.php#L78
// TODO : regarder ici, car un header peut avoir un tableau de valeurs, dans le cas ou on a mergé 2 headers identiques !!!! https://github.com/slimphp/Slim/blob/3.x/Slim/App.php#L393
// headers
foreach ($response->getHeaders() as $name => $values) {
$first = stripos($name, 'Set-Cookie') === 0 ? false : true;
foreach ($values as $value) {
header(sprintf('%s: %s', $name, $value), $first, $statusCode);
$first = false;
}
}
// TODO : gérer le cas ou il n'y a pas de ReasonPhrase et mettre une chaine vide : https://github.com/zendframework/zend-diactoros/blob/master/src/Response/SapiEmitterTrait.php#L55
// Set proper protocol, status code (and reason phrase) header
/*
if ($response->getReasonPhrase()) {
header(sprintf(
'HTTP/%s %d %s',
$response->getProtocolVersion(),
$response->getStatusCode(),
$response->getReasonPhrase()
));
} else {
header(sprintf(
'HTTP/%s %d',
$response->getProtocolVersion(),
$response->getStatusCode()
));
}*/
// It is important to mention that this method should be called after the headers are sent, in order to prevent PHP from changing the status code of the emitted response.
header(sprintf('HTTP/%s %d %s', $response->getProtocolVersion(), $statusCode, $response->getReasonPhrase()), true, $statusCode);
// cookies
//TODO : utiliser les cookies comme des "headers" classiques ('Set-Cookies:xxxxxxx')
//https://github.com/paragonie/PHP-Cookie/blob/master/src/Cookie.php#L358
// foreach ($response->getCookies() as $cookie) {
// setrawcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);
// }
// flush();
// }
// cookies
/*
foreach ($this->headers->getCookies() as $cookie) {
if ($cookie->isRaw()) {
setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
} else {
setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());
}
}*/
} | [
"private",
"function",
"emitHeaders",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"void",
"{",
"/*\n if (headers_sent($file, $line)) {\n throw new \\RuntimeException(sprintf('Failed to send headers, because headers have already been sent by \"%s\" at line %d.', $file, $line));\n }*/",
"// headers have already been sent by the developer",
"if",
"(",
"headers_sent",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"// TODO : regarder ici pour voir comment on emet les cookies !!!!! https://github.com/zendframework/zend-diactoros/blob/master/src/Response/SapiEmitterTrait.php#L78",
"// TODO : regarder ici, car un header peut avoir un tableau de valeurs, dans le cas ou on a mergé 2 headers identiques !!!! https://github.com/slimphp/Slim/blob/3.x/Slim/App.php#L393",
"// headers",
"foreach",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"$",
"first",
"=",
"stripos",
"(",
"$",
"name",
",",
"'Set-Cookie'",
")",
"===",
"0",
"?",
"false",
":",
"true",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"header",
"(",
"sprintf",
"(",
"'%s: %s'",
",",
"$",
"name",
",",
"$",
"value",
")",
",",
"$",
"first",
",",
"$",
"statusCode",
")",
";",
"$",
"first",
"=",
"false",
";",
"}",
"}",
"// TODO : gérer le cas ou il n'y a pas de ReasonPhrase et mettre une chaine vide : https://github.com/zendframework/zend-diactoros/blob/master/src/Response/SapiEmitterTrait.php#L55",
"// Set proper protocol, status code (and reason phrase) header",
"/*\n if ($response->getReasonPhrase()) {\n header(sprintf(\n 'HTTP/%s %d %s',\n $response->getProtocolVersion(),\n $response->getStatusCode(),\n $response->getReasonPhrase()\n ));\n } else {\n header(sprintf(\n 'HTTP/%s %d',\n $response->getProtocolVersion(),\n $response->getStatusCode()\n ));\n }*/",
"// It is important to mention that this method should be called after the headers are sent, in order to prevent PHP from changing the status code of the emitted response.",
"header",
"(",
"sprintf",
"(",
"'HTTP/%s %d %s'",
",",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
",",
"$",
"statusCode",
",",
"$",
"response",
"->",
"getReasonPhrase",
"(",
")",
")",
",",
"true",
",",
"$",
"statusCode",
")",
";",
"// cookies",
"//TODO : utiliser les cookies comme des \"headers\" classiques ('Set-Cookies:xxxxxxx')",
"//https://github.com/paragonie/PHP-Cookie/blob/master/src/Cookie.php#L358",
"// foreach ($response->getCookies() as $cookie) {",
"// setrawcookie($cookie['name'], $cookie['value'], $cookie['expire'], $cookie['path'], $cookie['domain'], $cookie['secure'], $cookie['httponly']);",
"// }",
"// flush();",
"// }",
"// cookies",
"/*\n foreach ($this->headers->getCookies() as $cookie) {\n if ($cookie->isRaw()) {\n setrawcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());\n } else {\n setcookie($cookie->getName(), $cookie->getValue(), $cookie->getExpiresTime(), $cookie->getPath(), $cookie->getDomain(), $cookie->isSecure(), $cookie->isHttpOnly());\n }\n }*/",
"}"
] | Send HTTP Headers.
@param ResponseInterface $response | [
"Send",
"HTTP",
"Headers",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Http/Emitter/ResponseEmitter.php#L105-L170 |
36,443 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.cmy2cmyk | public static function cmy2cmyk( $cmy )
{
list( $c, $m, $y ) = $cmy;
$k = min( $c, $m, $y );
$c = ( $c - $k ) / ( 1 - $k );
$m = ( $m - $k ) / ( 1 - $k );
$y = ( $y - $k ) / ( 1 - $k );
return array( $c, $m, $y, $k );
} | php | public static function cmy2cmyk( $cmy )
{
list( $c, $m, $y ) = $cmy;
$k = min( $c, $m, $y );
$c = ( $c - $k ) / ( 1 - $k );
$m = ( $m - $k ) / ( 1 - $k );
$y = ( $y - $k ) / ( 1 - $k );
return array( $c, $m, $y, $k );
} | [
"public",
"static",
"function",
"cmy2cmyk",
"(",
"$",
"cmy",
")",
"{",
"list",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
")",
"=",
"$",
"cmy",
";",
"$",
"k",
"=",
"min",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
")",
";",
"$",
"c",
"=",
"(",
"$",
"c",
"-",
"$",
"k",
")",
"/",
"(",
"1",
"-",
"$",
"k",
")",
";",
"$",
"m",
"=",
"(",
"$",
"m",
"-",
"$",
"k",
")",
"/",
"(",
"1",
"-",
"$",
"k",
")",
";",
"$",
"y",
"=",
"(",
"$",
"y",
"-",
"$",
"k",
")",
"/",
"(",
"1",
"-",
"$",
"k",
")",
";",
"return",
"array",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
",",
"$",
"k",
")",
";",
"}"
] | Converts CMY to CMYK.
@access public
@static
@param array cmy CMY-Color as array
@return array | [
"Converts",
"CMY",
"to",
"CMYK",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L50-L58 |
36,444 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.cmy2rgb | public static function cmy2rgb( $cmy )
{
list( $c, $m, $y ) = $cmy;
$r = 255 * ( 1 - $c );
$g = 255 * ( 1 - $m );
$b = 255 * ( 1 - $y );
return array( $r, $g, $b );
} | php | public static function cmy2rgb( $cmy )
{
list( $c, $m, $y ) = $cmy;
$r = 255 * ( 1 - $c );
$g = 255 * ( 1 - $m );
$b = 255 * ( 1 - $y );
return array( $r, $g, $b );
} | [
"public",
"static",
"function",
"cmy2rgb",
"(",
"$",
"cmy",
")",
"{",
"list",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
")",
"=",
"$",
"cmy",
";",
"$",
"r",
"=",
"255",
"*",
"(",
"1",
"-",
"$",
"c",
")",
";",
"$",
"g",
"=",
"255",
"*",
"(",
"1",
"-",
"$",
"m",
")",
";",
"$",
"b",
"=",
"255",
"*",
"(",
"1",
"-",
"$",
"y",
")",
";",
"return",
"array",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"}"
] | Converts CMY to RGB.
@access public
@static
@param array cmy CMY-Color as array
@return array | [
"Converts",
"CMY",
"to",
"RGB",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L67-L74 |
36,445 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.cmyk2cmy | public static function cmyk2cmy( $cmyk )
{
list( $c, $m, $y, $k ) = $cmyk;
$c = min( 1, $c * ( 1 - $k ) + $k );
$m = min( 1, $m * ( 1 - $k ) + $k );
$y = min( 1, $y * ( 1 - $k ) + $k );
return array( $c, $m, $y );
} | php | public static function cmyk2cmy( $cmyk )
{
list( $c, $m, $y, $k ) = $cmyk;
$c = min( 1, $c * ( 1 - $k ) + $k );
$m = min( 1, $m * ( 1 - $k ) + $k );
$y = min( 1, $y * ( 1 - $k ) + $k );
return array( $c, $m, $y );
} | [
"public",
"static",
"function",
"cmyk2cmy",
"(",
"$",
"cmyk",
")",
"{",
"list",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
",",
"$",
"k",
")",
"=",
"$",
"cmyk",
";",
"$",
"c",
"=",
"min",
"(",
"1",
",",
"$",
"c",
"*",
"(",
"1",
"-",
"$",
"k",
")",
"+",
"$",
"k",
")",
";",
"$",
"m",
"=",
"min",
"(",
"1",
",",
"$",
"m",
"*",
"(",
"1",
"-",
"$",
"k",
")",
"+",
"$",
"k",
")",
";",
"$",
"y",
"=",
"min",
"(",
"1",
",",
"$",
"y",
"*",
"(",
"1",
"-",
"$",
"k",
")",
"+",
"$",
"k",
")",
";",
"return",
"array",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
")",
";",
"}"
] | Converts CMYK to CMY.
@access public
@static
@param array cmyk CMYK-Color as array
@return array | [
"Converts",
"CMYK",
"to",
"CMY",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L83-L90 |
36,446 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.hsv2rgb | public static function hsv2rgb( $hsv )
{
list( $h, $s, $v ) = $hsv;
$rgb = array();
$h = $h / 60;
$s = $s / 100;
$v = $v / 100;
if( $s == 0 )
{
$rgb[0] = $v * 255;
$rgb[1] = $v * 255;
$rgb[2] = $v * 255;
}
else
{
$rgb_dec = array();
$i = floor( $h );
$p = $v * ( 1 - $s );
$q = $v * ( 1 - $s * ( $h - $i ) );
$t = $v * ( 1 - $s * ( 1 - ( $h - $i ) ) );
switch( $i )
{
case 0:
$rgb_dec[0] = $v;
$rgb_dec[1] = $t;
$rgb_dec[2] = $p;
break;
case 1:
$rgb_dec[0] = $q;
$rgb_dec[1] = $v;
$rgb_dec[2] = $p;
break;
case 2:
$rgb_dec[0] = $p;
$rgb_dec[1] = $v;
$rgb_dec[2] = $t;
break;
case 3:
$rgb_dec[0] = $p;
$rgb_dec[1] = $q;
$rgb_dec[2] = $v;
break;
case 4:
$rgb_dec[0] = $t;
$rgb_dec[1] = $p;
$rgb_dec[2] = $v;
break;
case 5:
$rgb_dec[0] = $v;
$rgb_dec[1] = $p;
$rgb_dec[2] = $q;
break;
case 6:
$rgb_dec[0] = $v;
$rgb_dec[1] = $p;
$rgb_dec[2] = $q;
break;
}
$rgb[0] = round( $rgb_dec[0] * 255 );
$rgb[1] = round( $rgb_dec[1] * 255 );
$rgb[2] = round( $rgb_dec[2] * 255 );
}
return $rgb;
} | php | public static function hsv2rgb( $hsv )
{
list( $h, $s, $v ) = $hsv;
$rgb = array();
$h = $h / 60;
$s = $s / 100;
$v = $v / 100;
if( $s == 0 )
{
$rgb[0] = $v * 255;
$rgb[1] = $v * 255;
$rgb[2] = $v * 255;
}
else
{
$rgb_dec = array();
$i = floor( $h );
$p = $v * ( 1 - $s );
$q = $v * ( 1 - $s * ( $h - $i ) );
$t = $v * ( 1 - $s * ( 1 - ( $h - $i ) ) );
switch( $i )
{
case 0:
$rgb_dec[0] = $v;
$rgb_dec[1] = $t;
$rgb_dec[2] = $p;
break;
case 1:
$rgb_dec[0] = $q;
$rgb_dec[1] = $v;
$rgb_dec[2] = $p;
break;
case 2:
$rgb_dec[0] = $p;
$rgb_dec[1] = $v;
$rgb_dec[2] = $t;
break;
case 3:
$rgb_dec[0] = $p;
$rgb_dec[1] = $q;
$rgb_dec[2] = $v;
break;
case 4:
$rgb_dec[0] = $t;
$rgb_dec[1] = $p;
$rgb_dec[2] = $v;
break;
case 5:
$rgb_dec[0] = $v;
$rgb_dec[1] = $p;
$rgb_dec[2] = $q;
break;
case 6:
$rgb_dec[0] = $v;
$rgb_dec[1] = $p;
$rgb_dec[2] = $q;
break;
}
$rgb[0] = round( $rgb_dec[0] * 255 );
$rgb[1] = round( $rgb_dec[1] * 255 );
$rgb[2] = round( $rgb_dec[2] * 255 );
}
return $rgb;
} | [
"public",
"static",
"function",
"hsv2rgb",
"(",
"$",
"hsv",
")",
"{",
"list",
"(",
"$",
"h",
",",
"$",
"s",
",",
"$",
"v",
")",
"=",
"$",
"hsv",
";",
"$",
"rgb",
"=",
"array",
"(",
")",
";",
"$",
"h",
"=",
"$",
"h",
"/",
"60",
";",
"$",
"s",
"=",
"$",
"s",
"/",
"100",
";",
"$",
"v",
"=",
"$",
"v",
"/",
"100",
";",
"if",
"(",
"$",
"s",
"==",
"0",
")",
"{",
"$",
"rgb",
"[",
"0",
"]",
"=",
"$",
"v",
"*",
"255",
";",
"$",
"rgb",
"[",
"1",
"]",
"=",
"$",
"v",
"*",
"255",
";",
"$",
"rgb",
"[",
"2",
"]",
"=",
"$",
"v",
"*",
"255",
";",
"}",
"else",
"{",
"$",
"rgb_dec",
"=",
"array",
"(",
")",
";",
"$",
"i",
"=",
"floor",
"(",
"$",
"h",
")",
";",
"$",
"p",
"=",
"$",
"v",
"*",
"(",
"1",
"-",
"$",
"s",
")",
";",
"$",
"q",
"=",
"$",
"v",
"*",
"(",
"1",
"-",
"$",
"s",
"*",
"(",
"$",
"h",
"-",
"$",
"i",
")",
")",
";",
"$",
"t",
"=",
"$",
"v",
"*",
"(",
"1",
"-",
"$",
"s",
"*",
"(",
"1",
"-",
"(",
"$",
"h",
"-",
"$",
"i",
")",
")",
")",
";",
"switch",
"(",
"$",
"i",
")",
"{",
"case",
"0",
":",
"$",
"rgb_dec",
"[",
"0",
"]",
"=",
"$",
"v",
";",
"$",
"rgb_dec",
"[",
"1",
"]",
"=",
"$",
"t",
";",
"$",
"rgb_dec",
"[",
"2",
"]",
"=",
"$",
"p",
";",
"break",
";",
"case",
"1",
":",
"$",
"rgb_dec",
"[",
"0",
"]",
"=",
"$",
"q",
";",
"$",
"rgb_dec",
"[",
"1",
"]",
"=",
"$",
"v",
";",
"$",
"rgb_dec",
"[",
"2",
"]",
"=",
"$",
"p",
";",
"break",
";",
"case",
"2",
":",
"$",
"rgb_dec",
"[",
"0",
"]",
"=",
"$",
"p",
";",
"$",
"rgb_dec",
"[",
"1",
"]",
"=",
"$",
"v",
";",
"$",
"rgb_dec",
"[",
"2",
"]",
"=",
"$",
"t",
";",
"break",
";",
"case",
"3",
":",
"$",
"rgb_dec",
"[",
"0",
"]",
"=",
"$",
"p",
";",
"$",
"rgb_dec",
"[",
"1",
"]",
"=",
"$",
"q",
";",
"$",
"rgb_dec",
"[",
"2",
"]",
"=",
"$",
"v",
";",
"break",
";",
"case",
"4",
":",
"$",
"rgb_dec",
"[",
"0",
"]",
"=",
"$",
"t",
";",
"$",
"rgb_dec",
"[",
"1",
"]",
"=",
"$",
"p",
";",
"$",
"rgb_dec",
"[",
"2",
"]",
"=",
"$",
"v",
";",
"break",
";",
"case",
"5",
":",
"$",
"rgb_dec",
"[",
"0",
"]",
"=",
"$",
"v",
";",
"$",
"rgb_dec",
"[",
"1",
"]",
"=",
"$",
"p",
";",
"$",
"rgb_dec",
"[",
"2",
"]",
"=",
"$",
"q",
";",
"break",
";",
"case",
"6",
":",
"$",
"rgb_dec",
"[",
"0",
"]",
"=",
"$",
"v",
";",
"$",
"rgb_dec",
"[",
"1",
"]",
"=",
"$",
"p",
";",
"$",
"rgb_dec",
"[",
"2",
"]",
"=",
"$",
"q",
";",
"break",
";",
"}",
"$",
"rgb",
"[",
"0",
"]",
"=",
"round",
"(",
"$",
"rgb_dec",
"[",
"0",
"]",
"*",
"255",
")",
";",
"$",
"rgb",
"[",
"1",
"]",
"=",
"round",
"(",
"$",
"rgb_dec",
"[",
"1",
"]",
"*",
"255",
")",
";",
"$",
"rgb",
"[",
"2",
"]",
"=",
"round",
"(",
"$",
"rgb_dec",
"[",
"2",
"]",
"*",
"255",
")",
";",
"}",
"return",
"$",
"rgb",
";",
"}"
] | Converts HSV to RGB.
@access public
@static
@param array hsv HSV-Color as array
@return array | [
"Converts",
"HSV",
"to",
"RGB",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L123-L186 |
36,447 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.html2hsv | public static function html2hsv( $string )
{
sscanf( $string, "%2X%2X%2X", $r, $g, $b );
return self::rgb2hsv( array( $r, $g, $b ) );
} | php | public static function html2hsv( $string )
{
sscanf( $string, "%2X%2X%2X", $r, $g, $b );
return self::rgb2hsv( array( $r, $g, $b ) );
} | [
"public",
"static",
"function",
"html2hsv",
"(",
"$",
"string",
")",
"{",
"sscanf",
"(",
"$",
"string",
",",
"\"%2X%2X%2X\"",
",",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"return",
"self",
"::",
"rgb2hsv",
"(",
"array",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
")",
";",
"}"
] | Converts HTML to hsv.
@access public
@static
@param string html HTML-Color as string
@return array | [
"Converts",
"HTML",
"to",
"hsv",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L195-L199 |
36,448 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.html2rgb | public static function html2rgb( $string )
{
sscanf( $string, "%2X%2X%2X", $r, $g, $b );
return array( $r, $g, $b );
} | php | public static function html2rgb( $string )
{
sscanf( $string, "%2X%2X%2X", $r, $g, $b );
return array( $r, $g, $b );
} | [
"public",
"static",
"function",
"html2rgb",
"(",
"$",
"string",
")",
"{",
"sscanf",
"(",
"$",
"string",
",",
"\"%2X%2X%2X\"",
",",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"return",
"array",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"}"
] | Converts HTML to RGB.
@access public
@static
@param string html HTML-Color as string
@return array | [
"Converts",
"HTML",
"to",
"RGB",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L208-L212 |
36,449 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.rgb2cmy | public static function rgb2cmy( $rgb )
{
list( $r, $g, $b ) = $rgb;
$c = 1 - ( $r / 255 );
$m = 1 - ( $g / 255 );
$y = 1 - ( $b / 255 );
return array( $c, $m, $y );
} | php | public static function rgb2cmy( $rgb )
{
list( $r, $g, $b ) = $rgb;
$c = 1 - ( $r / 255 );
$m = 1 - ( $g / 255 );
$y = 1 - ( $b / 255 );
return array( $c, $m, $y );
} | [
"public",
"static",
"function",
"rgb2cmy",
"(",
"$",
"rgb",
")",
"{",
"list",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"=",
"$",
"rgb",
";",
"$",
"c",
"=",
"1",
"-",
"(",
"$",
"r",
"/",
"255",
")",
";",
"$",
"m",
"=",
"1",
"-",
"(",
"$",
"g",
"/",
"255",
")",
";",
"$",
"y",
"=",
"1",
"-",
"(",
"$",
"b",
"/",
"255",
")",
";",
"return",
"array",
"(",
"$",
"c",
",",
"$",
"m",
",",
"$",
"y",
")",
";",
"}"
] | Converts RGB to CMY.
@access public
@static
@param array rgb RGB-Color as array
@return array | [
"Converts",
"RGB",
"to",
"CMY",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L221-L228 |
36,450 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.rgb2hsv | public static function rgb2hsv( $rgb )
{
# return self::rgb2hsv_2( $rgb );
list( $r, $g, $b ) = $rgb;
$v = max( $r, $g, $b );
$t = min( $r, $g, $b );
$s = ( $v == 0 ) ? 0 : ( $v - $t ) / $v;
if( $s == 0 )
$h = 0;
else
{
$a = $v - $t;
$cr = ( $v - $r ) / $a;
$cg = ( $v - $g ) / $a;
$cb = ( $v - $b ) / $a;
$h = ( $r == $v ) ? $cb - $cg : ( ( $g == $v ) ? 2 + $cr - $cb : ( ( $b == $v ) ? $h = 4 + $cg - $cr : 0 ) );
$h = 60 * $h;
$h = ( $h < 0 ) ? $h + 360 : $h;
}
return array( round( $h ), round( $s * 100 ), round( $v / 2.55 ) );
} | php | public static function rgb2hsv( $rgb )
{
# return self::rgb2hsv_2( $rgb );
list( $r, $g, $b ) = $rgb;
$v = max( $r, $g, $b );
$t = min( $r, $g, $b );
$s = ( $v == 0 ) ? 0 : ( $v - $t ) / $v;
if( $s == 0 )
$h = 0;
else
{
$a = $v - $t;
$cr = ( $v - $r ) / $a;
$cg = ( $v - $g ) / $a;
$cb = ( $v - $b ) / $a;
$h = ( $r == $v ) ? $cb - $cg : ( ( $g == $v ) ? 2 + $cr - $cb : ( ( $b == $v ) ? $h = 4 + $cg - $cr : 0 ) );
$h = 60 * $h;
$h = ( $h < 0 ) ? $h + 360 : $h;
}
return array( round( $h ), round( $s * 100 ), round( $v / 2.55 ) );
} | [
"public",
"static",
"function",
"rgb2hsv",
"(",
"$",
"rgb",
")",
"{",
"#\t\treturn self::rgb2hsv_2( $rgb );\r",
"list",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"=",
"$",
"rgb",
";",
"$",
"v",
"=",
"max",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"$",
"t",
"=",
"min",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"$",
"s",
"=",
"(",
"$",
"v",
"==",
"0",
")",
"?",
"0",
":",
"(",
"$",
"v",
"-",
"$",
"t",
")",
"/",
"$",
"v",
";",
"if",
"(",
"$",
"s",
"==",
"0",
")",
"$",
"h",
"=",
"0",
";",
"else",
"{",
"$",
"a",
"=",
"$",
"v",
"-",
"$",
"t",
";",
"$",
"cr",
"=",
"(",
"$",
"v",
"-",
"$",
"r",
")",
"/",
"$",
"a",
";",
"$",
"cg",
"=",
"(",
"$",
"v",
"-",
"$",
"g",
")",
"/",
"$",
"a",
";",
"$",
"cb",
"=",
"(",
"$",
"v",
"-",
"$",
"b",
")",
"/",
"$",
"a",
";",
"$",
"h",
"=",
"(",
"$",
"r",
"==",
"$",
"v",
")",
"?",
"$",
"cb",
"-",
"$",
"cg",
":",
"(",
"(",
"$",
"g",
"==",
"$",
"v",
")",
"?",
"2",
"+",
"$",
"cr",
"-",
"$",
"cb",
":",
"(",
"(",
"$",
"b",
"==",
"$",
"v",
")",
"?",
"$",
"h",
"=",
"4",
"+",
"$",
"cg",
"-",
"$",
"cr",
":",
"0",
")",
")",
";",
"$",
"h",
"=",
"60",
"*",
"$",
"h",
";",
"$",
"h",
"=",
"(",
"$",
"h",
"<",
"0",
")",
"?",
"$",
"h",
"+",
"360",
":",
"$",
"h",
";",
"}",
"return",
"array",
"(",
"round",
"(",
"$",
"h",
")",
",",
"round",
"(",
"$",
"s",
"*",
"100",
")",
",",
"round",
"(",
"$",
"v",
"/",
"2.55",
")",
")",
";",
"}"
] | Converts RGB to HSV.
@access public
@static
@param array rgb RGB-Color as array
@return array | [
"Converts",
"RGB",
"to",
"HSV",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L249-L269 |
36,451 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.rgb2html | public static function rgb2html( $rgb )
{
list( $r, $g, $b ) = $rgb;
$html = sprintf( "%2X%2X%2X", $r, $g, $b );
$html = str_replace( " ", "0", $html );
return $html;
} | php | public static function rgb2html( $rgb )
{
list( $r, $g, $b ) = $rgb;
$html = sprintf( "%2X%2X%2X", $r, $g, $b );
$html = str_replace( " ", "0", $html );
return $html;
} | [
"public",
"static",
"function",
"rgb2html",
"(",
"$",
"rgb",
")",
"{",
"list",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"=",
"$",
"rgb",
";",
"$",
"html",
"=",
"sprintf",
"(",
"\"%2X%2X%2X\"",
",",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"$",
"html",
"=",
"str_replace",
"(",
"\" \"",
",",
"\"0\"",
",",
"$",
"html",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Converts RGB to HTML.
@access public
@static
@param array rgb RGB-Color as array
@return string | [
"Converts",
"RGB",
"to",
"HTML",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L318-L324 |
36,452 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.rgb2xyz | public static function rgb2xyz( $rgb )
{
list( $r, $g, $b ) = $rgb;
$r = $r / 255;
$g = $g / 255;
$b = $b / 255;
$x = 0.430574 * $r + 0.341550 * $g + 0.178325 * $b;
$y = 0.222015 * $r + 0.706655 * $g + 0.071330 * $b;
$z = 0.020183 * $r + 0.129553 * $g + 0.939180 * $b;
return array( $x, $y, $z );
} | php | public static function rgb2xyz( $rgb )
{
list( $r, $g, $b ) = $rgb;
$r = $r / 255;
$g = $g / 255;
$b = $b / 255;
$x = 0.430574 * $r + 0.341550 * $g + 0.178325 * $b;
$y = 0.222015 * $r + 0.706655 * $g + 0.071330 * $b;
$z = 0.020183 * $r + 0.129553 * $g + 0.939180 * $b;
return array( $x, $y, $z );
} | [
"public",
"static",
"function",
"rgb2xyz",
"(",
"$",
"rgb",
")",
"{",
"list",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"=",
"$",
"rgb",
";",
"$",
"r",
"=",
"$",
"r",
"/",
"255",
";",
"$",
"g",
"=",
"$",
"g",
"/",
"255",
";",
"$",
"b",
"=",
"$",
"b",
"/",
"255",
";",
"$",
"x",
"=",
"0.430574",
"*",
"$",
"r",
"+",
"0.341550",
"*",
"$",
"g",
"+",
"0.178325",
"*",
"$",
"b",
";",
"$",
"y",
"=",
"0.222015",
"*",
"$",
"r",
"+",
"0.706655",
"*",
"$",
"g",
"+",
"0.071330",
"*",
"$",
"b",
";",
"$",
"z",
"=",
"0.020183",
"*",
"$",
"r",
"+",
"0.129553",
"*",
"$",
"g",
"+",
"0.939180",
"*",
"$",
"b",
";",
"return",
"array",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"z",
")",
";",
"}"
] | Converts RGB to XYZ.
@access public
@static
@param array rgb RGB-Color as array
@return array | [
"Converts",
"RGB",
"to",
"XYZ",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L333-L343 |
36,453 | CeusMedia/Common | src/Alg/ColorConverter.php | Alg_ColorConverter.xyz2rgb | public static function xyz2rgb( $xyz )
{
list( $x, $y, $z ) = $xyz;
$r = 3.063219 * $x - 1.393326 * $y - 0.475801 * $z;
$g = -0.969245 * $x + 1.875968 * $y + 0.041555 * $z;
$b = 0.067872 * $x - 0.228833 * $y + 1.069251 * $z;
$r = round( $r * 255 );
$g = round( $g * 255 );
$b = round( $b * 255 );
return array( $r, $g, $b );
} | php | public static function xyz2rgb( $xyz )
{
list( $x, $y, $z ) = $xyz;
$r = 3.063219 * $x - 1.393326 * $y - 0.475801 * $z;
$g = -0.969245 * $x + 1.875968 * $y + 0.041555 * $z;
$b = 0.067872 * $x - 0.228833 * $y + 1.069251 * $z;
$r = round( $r * 255 );
$g = round( $g * 255 );
$b = round( $b * 255 );
return array( $r, $g, $b );
} | [
"public",
"static",
"function",
"xyz2rgb",
"(",
"$",
"xyz",
")",
"{",
"list",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"z",
")",
"=",
"$",
"xyz",
";",
"$",
"r",
"=",
"3.063219",
"*",
"$",
"x",
"-",
"1.393326",
"*",
"$",
"y",
"-",
"0.475801",
"*",
"$",
"z",
";",
"$",
"g",
"=",
"-",
"0.969245",
"*",
"$",
"x",
"+",
"1.875968",
"*",
"$",
"y",
"+",
"0.041555",
"*",
"$",
"z",
";",
"$",
"b",
"=",
"0.067872",
"*",
"$",
"x",
"-",
"0.228833",
"*",
"$",
"y",
"+",
"1.069251",
"*",
"$",
"z",
";",
"$",
"r",
"=",
"round",
"(",
"$",
"r",
"*",
"255",
")",
";",
"$",
"g",
"=",
"round",
"(",
"$",
"g",
"*",
"255",
")",
";",
"$",
"b",
"=",
"round",
"(",
"$",
"b",
"*",
"255",
")",
";",
"return",
"array",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"}"
] | Converts XYZ to RGB.
@access public
@static
@param array xyz XYZ-Color as array
@return array | [
"Converts",
"XYZ",
"to",
"RGB",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/ColorConverter.php#L352-L362 |
36,454 | Assasz/yggdrasil | src/Yggdrasil/Utils/Form/FormHandler.php | FormHandler.handle | public function handle(Request $request, string $method = self::HTTP_POST): bool
{
if (!$request->isMethod($method)) {
return false;
}
if ($request->request->has('csrf_token')) {
$session = new Session();
if ($session->get('csrf_token') !== $request->request->get('csrf_token')) {
throw new InvalidCsrfTokenException();
}
$request->request->remove('csrf_token');
}
$this->dataCollection = array_merge($request->request->all(), $request->files->all());
return true;
} | php | public function handle(Request $request, string $method = self::HTTP_POST): bool
{
if (!$request->isMethod($method)) {
return false;
}
if ($request->request->has('csrf_token')) {
$session = new Session();
if ($session->get('csrf_token') !== $request->request->get('csrf_token')) {
throw new InvalidCsrfTokenException();
}
$request->request->remove('csrf_token');
}
$this->dataCollection = array_merge($request->request->all(), $request->files->all());
return true;
} | [
"public",
"function",
"handle",
"(",
"Request",
"$",
"request",
",",
"string",
"$",
"method",
"=",
"self",
"::",
"HTTP_POST",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"request",
"->",
"isMethod",
"(",
"$",
"method",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"request",
"->",
"has",
"(",
"'csrf_token'",
")",
")",
"{",
"$",
"session",
"=",
"new",
"Session",
"(",
")",
";",
"if",
"(",
"$",
"session",
"->",
"get",
"(",
"'csrf_token'",
")",
"!==",
"$",
"request",
"->",
"request",
"->",
"get",
"(",
"'csrf_token'",
")",
")",
"{",
"throw",
"new",
"InvalidCsrfTokenException",
"(",
")",
";",
"}",
"$",
"request",
"->",
"request",
"->",
"remove",
"(",
"'csrf_token'",
")",
";",
"}",
"$",
"this",
"->",
"dataCollection",
"=",
"array_merge",
"(",
"$",
"request",
"->",
"request",
"->",
"all",
"(",
")",
",",
"$",
"request",
"->",
"files",
"->",
"all",
"(",
")",
")",
";",
"return",
"true",
";",
"}"
] | Returns result of form submission
@param Request $request
@param string $method Expected form HTTP method
@return bool
@throws InvalidCsrfTokenException if received CSRF token doesn't match token stored in session | [
"Returns",
"result",
"of",
"form",
"submission"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Form/FormHandler.php#L58-L77 |
36,455 | Assasz/yggdrasil | src/Yggdrasil/Utils/Form/FormHandler.php | FormHandler.getData | public function getData(string $key)
{
if (!$this->hasData($key)) {
throw new \InvalidArgumentException($key . ' not found in submitted form data.');
}
return $this->dataCollection[$key];
} | php | public function getData(string $key)
{
if (!$this->hasData($key)) {
throw new \InvalidArgumentException($key . ' not found in submitted form data.');
}
return $this->dataCollection[$key];
} | [
"public",
"function",
"getData",
"(",
"string",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasData",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"$",
"key",
".",
"' not found in submitted form data.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"dataCollection",
"[",
"$",
"key",
"]",
";",
"}"
] | Returns given form data
@param string $key Key of form data, equivalent to input name
@return mixed
@throws \InvalidArgumentException if data can't be found | [
"Returns",
"given",
"form",
"data"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Form/FormHandler.php#L96-L103 |
36,456 | CeusMedia/Common | src/UI/HTML/Fieldset.php | UI_HTML_Fieldset.render | public function render()
{
$legend = $this->renderInner( $this->legend );
if( !is_string( $legend ) )
throw new InvalidArgumentException( 'Fieldset legend is neither rendered nor renderable' );
$content = $this->renderInner( $this->content );
if( !is_string( $content ) )
throw new InvalidArgumentException( 'Fieldset content is neither rendered nor renderable' );
return UI_HTML_Tag::create( "fieldset", $legend.$content, $this->getAttributes() );
} | php | public function render()
{
$legend = $this->renderInner( $this->legend );
if( !is_string( $legend ) )
throw new InvalidArgumentException( 'Fieldset legend is neither rendered nor renderable' );
$content = $this->renderInner( $this->content );
if( !is_string( $content ) )
throw new InvalidArgumentException( 'Fieldset content is neither rendered nor renderable' );
return UI_HTML_Tag::create( "fieldset", $legend.$content, $this->getAttributes() );
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"legend",
"=",
"$",
"this",
"->",
"renderInner",
"(",
"$",
"this",
"->",
"legend",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"legend",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Fieldset legend is neither rendered nor renderable'",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"renderInner",
"(",
"$",
"this",
"->",
"content",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"content",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Fieldset content is neither rendered nor renderable'",
")",
";",
"return",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"fieldset\"",
",",
"$",
"legend",
".",
"$",
"content",
",",
"$",
"this",
"->",
"getAttributes",
"(",
")",
")",
";",
"}"
] | Returns rendered Fieldset Element.
@access public
@return string | [
"Returns",
"rendered",
"Fieldset",
"Element",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Fieldset.php#L65-L76 |
36,457 | CeusMedia/Common | src/ADT/Graph/DirectedWeighted.php | ADT_Graph_DirectedWeighted.getGrade | public function getGrade( $source, $target )
{
if( $this->isEdge( $source, $target ) )
return 1;
$nodes = $this->getTargetNodes( $source );
foreach( $nodes as $node )
{
$way = $this->getGrade( $node, $target );
return ++$way;
}
return false;
} | php | public function getGrade( $source, $target )
{
if( $this->isEdge( $source, $target ) )
return 1;
$nodes = $this->getTargetNodes( $source );
foreach( $nodes as $node )
{
$way = $this->getGrade( $node, $target );
return ++$way;
}
return false;
} | [
"public",
"function",
"getGrade",
"(",
"$",
"source",
",",
"$",
"target",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEdge",
"(",
"$",
"source",
",",
"$",
"target",
")",
")",
"return",
"1",
";",
"$",
"nodes",
"=",
"$",
"this",
"->",
"getTargetNodes",
"(",
"$",
"source",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"way",
"=",
"$",
"this",
"->",
"getGrade",
"(",
"$",
"node",
",",
"$",
"target",
")",
";",
"return",
"++",
"$",
"way",
";",
"}",
"return",
"false",
";",
"}"
] | Returns distance between two Nodes.
@access public
@param ADT_Graph_Node $source Source Node of this Edge
@param ADT_Graph_Node $target Target Node of this Edge
@return int | [
"Returns",
"distance",
"between",
"two",
"Nodes",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/DirectedWeighted.php#L98-L109 |
36,458 | CeusMedia/Common | src/ADT/Graph/DirectedWeighted.php | ADT_Graph_DirectedWeighted.getPath | public function getPath( $source, $target, $stack = false )
{
if( $this->isEdge( $source, $target ) )
{
if( $stack && is_a( $stack, "stack" ) )
$way = $stack;
else $way = new ADT_List_Stack();
$way->push( $target );
return $way;
}
$nodes = $this->getTargetNodes( $source );
foreach( $nodes as $node )
{
$way = $this->getPath( $node, $target, $stack );
if( $way )
{
$way->push( $node );
return $way;
}
}
return false;
} | php | public function getPath( $source, $target, $stack = false )
{
if( $this->isEdge( $source, $target ) )
{
if( $stack && is_a( $stack, "stack" ) )
$way = $stack;
else $way = new ADT_List_Stack();
$way->push( $target );
return $way;
}
$nodes = $this->getTargetNodes( $source );
foreach( $nodes as $node )
{
$way = $this->getPath( $node, $target, $stack );
if( $way )
{
$way->push( $node );
return $way;
}
}
return false;
} | [
"public",
"function",
"getPath",
"(",
"$",
"source",
",",
"$",
"target",
",",
"$",
"stack",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEdge",
"(",
"$",
"source",
",",
"$",
"target",
")",
")",
"{",
"if",
"(",
"$",
"stack",
"&&",
"is_a",
"(",
"$",
"stack",
",",
"\"stack\"",
")",
")",
"$",
"way",
"=",
"$",
"stack",
";",
"else",
"$",
"way",
"=",
"new",
"ADT_List_Stack",
"(",
")",
";",
"$",
"way",
"->",
"push",
"(",
"$",
"target",
")",
";",
"return",
"$",
"way",
";",
"}",
"$",
"nodes",
"=",
"$",
"this",
"->",
"getTargetNodes",
"(",
"$",
"source",
")",
";",
"foreach",
"(",
"$",
"nodes",
"as",
"$",
"node",
")",
"{",
"$",
"way",
"=",
"$",
"this",
"->",
"getPath",
"(",
"$",
"node",
",",
"$",
"target",
",",
"$",
"stack",
")",
";",
"if",
"(",
"$",
"way",
")",
"{",
"$",
"way",
"->",
"push",
"(",
"$",
"node",
")",
";",
"return",
"$",
"way",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns the way between two Nodes as Stack.
@access public
@param ADT_Graph_Node $source Source Node of this Edge
@param ADT_Graph_Node $target Target Node of this Edge
@param ADT_List_Stack $stack Stack to fill with Node on the way
@return ADT_List_Stack | [
"Returns",
"the",
"way",
"between",
"two",
"Nodes",
"as",
"Stack",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/DirectedWeighted.php#L119-L140 |
36,459 | CeusMedia/Common | src/ADT/Graph/DirectedWeighted.php | ADT_Graph_DirectedWeighted.hasCycle | public function hasCycle()
{
if( $this->hasLoop() )
return true;
else
{
foreach( $this->getNodes() as $node )
if( $this->isPath($node, $node ) )
return true;
}
return false;
} | php | public function hasCycle()
{
if( $this->hasLoop() )
return true;
else
{
foreach( $this->getNodes() as $node )
if( $this->isPath($node, $node ) )
return true;
}
return false;
} | [
"public",
"function",
"hasCycle",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasLoop",
"(",
")",
")",
"return",
"true",
";",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getNodes",
"(",
")",
"as",
"$",
"node",
")",
"if",
"(",
"$",
"this",
"->",
"isPath",
"(",
"$",
"node",
",",
"$",
"node",
")",
")",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Indicates whether Graph has closed sequence of Edges.
@access public
@return bool | [
"Indicates",
"whether",
"Graph",
"has",
"closed",
"sequence",
"of",
"Edges",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/DirectedWeighted.php#L165-L176 |
36,460 | CeusMedia/Common | src/ADT/Graph/DirectedWeighted.php | ADT_Graph_DirectedWeighted.toArray | public function toArray()
{
$a = array();
$nodes = $this->getNodes();
for( $i=0; $i<$this->getNodeSize(); $i++ )
{
$source = $nodes[$i];
$line = array();
for( $j=0; $j<$this->getNodeSize(); $j++ )
{
$target = $nodes[$j];
$value = $this->getEdgeValue( $source, $target );
$line[$target->getNodeName()] = $value;
}
$a[$source->getNodeName()] = $line;
}
return $a;
} | php | public function toArray()
{
$a = array();
$nodes = $this->getNodes();
for( $i=0; $i<$this->getNodeSize(); $i++ )
{
$source = $nodes[$i];
$line = array();
for( $j=0; $j<$this->getNodeSize(); $j++ )
{
$target = $nodes[$j];
$value = $this->getEdgeValue( $source, $target );
$line[$target->getNodeName()] = $value;
}
$a[$source->getNodeName()] = $line;
}
return $a;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"a",
"=",
"array",
"(",
")",
";",
"$",
"nodes",
"=",
"$",
"this",
"->",
"getNodes",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"this",
"->",
"getNodeSize",
"(",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"source",
"=",
"$",
"nodes",
"[",
"$",
"i",
"]",
";",
"$",
"line",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"this",
"->",
"getNodeSize",
"(",
")",
";",
"$",
"j",
"++",
")",
"{",
"$",
"target",
"=",
"$",
"nodes",
"[",
"$",
"j",
"]",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getEdgeValue",
"(",
"$",
"source",
",",
"$",
"target",
")",
";",
"$",
"line",
"[",
"$",
"target",
"->",
"getNodeName",
"(",
")",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"a",
"[",
"$",
"source",
"->",
"getNodeName",
"(",
")",
"]",
"=",
"$",
"line",
";",
"}",
"return",
"$",
"a",
";",
"}"
] | Returns all Nodes and Edges of this Graph as an array.
@access public
@return array | [
"Returns",
"all",
"Nodes",
"and",
"Edges",
"of",
"this",
"Graph",
"as",
"an",
"array",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Graph/DirectedWeighted.php#L226-L243 |
36,461 | php-api-clients/hydrator | src/Hydrator.php | Hydrator.ensureMissingValuesAreNull | protected function ensureMissingValuesAreNull(array $json, string $class): array
{
foreach ($this->getReflectionClassProperties($class) as $key) {
if (isset($json[$key])) {
continue;
}
$json[$key] = null;
}
return $json;
} | php | protected function ensureMissingValuesAreNull(array $json, string $class): array
{
foreach ($this->getReflectionClassProperties($class) as $key) {
if (isset($json[$key])) {
continue;
}
$json[$key] = null;
}
return $json;
} | [
"protected",
"function",
"ensureMissingValuesAreNull",
"(",
"array",
"$",
"json",
",",
"string",
"$",
"class",
")",
":",
"array",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getReflectionClassProperties",
"(",
"$",
"class",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"json",
"[",
"$",
"key",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"json",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"return",
"$",
"json",
";",
"}"
] | Ensure all properties expected by resource are available.
@param array $json
@param string $class
@return array | [
"Ensure",
"all",
"properties",
"expected",
"by",
"resource",
"are",
"available",
"."
] | c882bb96c36a1c746a09b3b5db5560c560a43b46 | https://github.com/php-api-clients/hydrator/blob/c882bb96c36a1c746a09b3b5db5560c560a43b46/src/Hydrator.php#L262-L273 |
36,462 | danielmaier42/Magento2-ConsoleUtility | Console/Output.php | Output.logException | public function logException(\Exception $exception)
{
$this->logError('Error: ' . get_class($exception) . ' - ' . $exception->getMessage() . ' (Code: ' . $exception->getCode() . ')');
$this->logError('File: ' . $exception->getFile() . ' / Line: ' . $exception->getLine());
} | php | public function logException(\Exception $exception)
{
$this->logError('Error: ' . get_class($exception) . ' - ' . $exception->getMessage() . ' (Code: ' . $exception->getCode() . ')');
$this->logError('File: ' . $exception->getFile() . ' / Line: ' . $exception->getLine());
} | [
"public",
"function",
"logException",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"logError",
"(",
"'Error: '",
".",
"get_class",
"(",
"$",
"exception",
")",
".",
"' - '",
".",
"$",
"exception",
"->",
"getMessage",
"(",
")",
".",
"' (Code: '",
".",
"$",
"exception",
"->",
"getCode",
"(",
")",
".",
"')'",
")",
";",
"$",
"this",
"->",
"logError",
"(",
"'File: '",
".",
"$",
"exception",
"->",
"getFile",
"(",
")",
".",
"' / Line: '",
".",
"$",
"exception",
"->",
"getLine",
"(",
")",
")",
";",
"}"
] | region Easy Logging | [
"region",
"Easy",
"Logging"
] | bed046766524bc046cb24251145831de1ed8d681 | https://github.com/danielmaier42/Magento2-ConsoleUtility/blob/bed046766524bc046cb24251145831de1ed8d681/Console/Output.php#L225-L229 |
36,463 | CeusMedia/Common | src/UI/HTML/Exception/Page.php | UI_HTML_Exception_Page.display | public static function display( Exception $e )
{
$view = UI_HTML_Exception_View::render( $e );
print( self::wrapExceptionView( $view ) );
} | php | public static function display( Exception $e )
{
$view = UI_HTML_Exception_View::render( $e );
print( self::wrapExceptionView( $view ) );
} | [
"public",
"static",
"function",
"display",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"view",
"=",
"UI_HTML_Exception_View",
"::",
"render",
"(",
"$",
"e",
")",
";",
"print",
"(",
"self",
"::",
"wrapExceptionView",
"(",
"$",
"view",
")",
")",
";",
"}"
] | Displays rendered Exception Page.
@access public
@param Exception $e Exception to render View for
@return string
@static | [
"Displays",
"rendered",
"Exception",
"Page",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Exception/Page.php#L49-L53 |
36,464 | CeusMedia/Common | src/UI/HTML/Exception/Page.php | UI_HTML_Exception_Page.wrapExceptionView | public static function wrapExceptionView( $view )
{
$page = new UI_HTML_PageFrame();
$page->setTitle( 'Exception' );
$page->addJavaScript( '//cdn.ceusmedia.de/js/jquery/1.4.2.min.js' );
$page->addJavaScript( '//cdn.ceusmedia.de/js/jquery/cmExceptionView/0.1.js' );
$page->addStylesheet( '//cdn.ceusmedia.de/js/jquery/cmExceptionView/0.1.css' );
$page->addStylesheet( '//cdn.ceusmedia.de/css/bootstrap.min.css' );
$options = array( 'foldTraces' => TRUE );
$script = UI_HTML_JQuery::buildPluginCall( 'cmExceptionView', 'dl.exception', $options );
$page->addHead( UI_HTML_Tag::create( 'script', $script ) );
$page->addBody( UI_HTML_Tag::create( 'h2', 'Error' ).$view );
return $page->build( array( 'style' => 'margin: 1em' ) );
} | php | public static function wrapExceptionView( $view )
{
$page = new UI_HTML_PageFrame();
$page->setTitle( 'Exception' );
$page->addJavaScript( '//cdn.ceusmedia.de/js/jquery/1.4.2.min.js' );
$page->addJavaScript( '//cdn.ceusmedia.de/js/jquery/cmExceptionView/0.1.js' );
$page->addStylesheet( '//cdn.ceusmedia.de/js/jquery/cmExceptionView/0.1.css' );
$page->addStylesheet( '//cdn.ceusmedia.de/css/bootstrap.min.css' );
$options = array( 'foldTraces' => TRUE );
$script = UI_HTML_JQuery::buildPluginCall( 'cmExceptionView', 'dl.exception', $options );
$page->addHead( UI_HTML_Tag::create( 'script', $script ) );
$page->addBody( UI_HTML_Tag::create( 'h2', 'Error' ).$view );
return $page->build( array( 'style' => 'margin: 1em' ) );
} | [
"public",
"static",
"function",
"wrapExceptionView",
"(",
"$",
"view",
")",
"{",
"$",
"page",
"=",
"new",
"UI_HTML_PageFrame",
"(",
")",
";",
"$",
"page",
"->",
"setTitle",
"(",
"'Exception'",
")",
";",
"$",
"page",
"->",
"addJavaScript",
"(",
"'//cdn.ceusmedia.de/js/jquery/1.4.2.min.js'",
")",
";",
"$",
"page",
"->",
"addJavaScript",
"(",
"'//cdn.ceusmedia.de/js/jquery/cmExceptionView/0.1.js'",
")",
";",
"$",
"page",
"->",
"addStylesheet",
"(",
"'//cdn.ceusmedia.de/js/jquery/cmExceptionView/0.1.css'",
")",
";",
"$",
"page",
"->",
"addStylesheet",
"(",
"'//cdn.ceusmedia.de/css/bootstrap.min.css'",
")",
";",
"$",
"options",
"=",
"array",
"(",
"'foldTraces'",
"=>",
"TRUE",
")",
";",
"$",
"script",
"=",
"UI_HTML_JQuery",
"::",
"buildPluginCall",
"(",
"'cmExceptionView'",
",",
"'dl.exception'",
",",
"$",
"options",
")",
";",
"$",
"page",
"->",
"addHead",
"(",
"UI_HTML_Tag",
"::",
"create",
"(",
"'script'",
",",
"$",
"script",
")",
")",
";",
"$",
"page",
"->",
"addBody",
"(",
"UI_HTML_Tag",
"::",
"create",
"(",
"'h2'",
",",
"'Error'",
")",
".",
"$",
"view",
")",
";",
"return",
"$",
"page",
"->",
"build",
"(",
"array",
"(",
"'style'",
"=>",
"'margin: 1em'",
")",
")",
";",
"}"
] | Wraps an Exception View to an Exception Page.
@access public
@param UI_HTML_Exception_View $view Exception View
@return string | [
"Wraps",
"an",
"Exception",
"View",
"to",
"an",
"Exception",
"Page",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Exception/Page.php#L73-L86 |
36,465 | meritoo/common-library | src/Utilities/Composer.php | Composer.getValue | public static function getValue($composerJsonPath, $nodeName)
{
$composerJsonString = is_string($composerJsonPath);
$composerJsonReadable = false;
if ($composerJsonString) {
$composerJsonReadable = is_readable($composerJsonPath);
}
/*
* Provided path or name of node are invalid?
* The composer.json file doesn't exist or isn't readable?
* Name of node is unknown?
*
* Nothing to do
*/
if (!$composerJsonString || !is_string($nodeName) || !$composerJsonReadable || empty($nodeName)) {
return null;
}
$content = file_get_contents($composerJsonPath);
$data = json_decode($content);
/*
* Unknown data from the composer.json file or there is no node with given name?
* Nothing to do
*/
if (null === $data || !isset($data->{$nodeName})) {
return null;
}
return $data->{$nodeName};
} | php | public static function getValue($composerJsonPath, $nodeName)
{
$composerJsonString = is_string($composerJsonPath);
$composerJsonReadable = false;
if ($composerJsonString) {
$composerJsonReadable = is_readable($composerJsonPath);
}
/*
* Provided path or name of node are invalid?
* The composer.json file doesn't exist or isn't readable?
* Name of node is unknown?
*
* Nothing to do
*/
if (!$composerJsonString || !is_string($nodeName) || !$composerJsonReadable || empty($nodeName)) {
return null;
}
$content = file_get_contents($composerJsonPath);
$data = json_decode($content);
/*
* Unknown data from the composer.json file or there is no node with given name?
* Nothing to do
*/
if (null === $data || !isset($data->{$nodeName})) {
return null;
}
return $data->{$nodeName};
} | [
"public",
"static",
"function",
"getValue",
"(",
"$",
"composerJsonPath",
",",
"$",
"nodeName",
")",
"{",
"$",
"composerJsonString",
"=",
"is_string",
"(",
"$",
"composerJsonPath",
")",
";",
"$",
"composerJsonReadable",
"=",
"false",
";",
"if",
"(",
"$",
"composerJsonString",
")",
"{",
"$",
"composerJsonReadable",
"=",
"is_readable",
"(",
"$",
"composerJsonPath",
")",
";",
"}",
"/*\n * Provided path or name of node are invalid?\n * The composer.json file doesn't exist or isn't readable?\n * Name of node is unknown?\n *\n * Nothing to do\n */",
"if",
"(",
"!",
"$",
"composerJsonString",
"||",
"!",
"is_string",
"(",
"$",
"nodeName",
")",
"||",
"!",
"$",
"composerJsonReadable",
"||",
"empty",
"(",
"$",
"nodeName",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"composerJsonPath",
")",
";",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"content",
")",
";",
"/*\n * Unknown data from the composer.json file or there is no node with given name?\n * Nothing to do\n */",
"if",
"(",
"null",
"===",
"$",
"data",
"||",
"!",
"isset",
"(",
"$",
"data",
"->",
"{",
"$",
"nodeName",
"}",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"data",
"->",
"{",
"$",
"nodeName",
"}",
";",
"}"
] | Returns value from composer.json file
@param string $composerJsonPath Path of composer.json file
@param string $nodeName Name of node who value should be returned
@return null|string | [
"Returns",
"value",
"from",
"composer",
".",
"json",
"file"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Composer.php#L33-L65 |
36,466 | rollun-com/rollun-logger | src/Logger/src/Processor/ExceptionBacktrace.php | ExceptionBacktrace.getExceptionBacktrace | public function getExceptionBacktrace(\Throwable $e)
{
$backtrace[] = [
'line' => $e->getLine(),
'file' => $e->getFile(),
'code' => $e->getCode(),
'message' => $e->getMessage(),
];
if ($e->getPrevious()) {
return array_merge(
$backtrace,
$this->getExceptionBacktrace($e->getPrevious())
);
}
return $backtrace;
} | php | public function getExceptionBacktrace(\Throwable $e)
{
$backtrace[] = [
'line' => $e->getLine(),
'file' => $e->getFile(),
'code' => $e->getCode(),
'message' => $e->getMessage(),
];
if ($e->getPrevious()) {
return array_merge(
$backtrace,
$this->getExceptionBacktrace($e->getPrevious())
);
}
return $backtrace;
} | [
"public",
"function",
"getExceptionBacktrace",
"(",
"\\",
"Throwable",
"$",
"e",
")",
"{",
"$",
"backtrace",
"[",
"]",
"=",
"[",
"'line'",
"=>",
"$",
"e",
"->",
"getLine",
"(",
")",
",",
"'file'",
"=>",
"$",
"e",
"->",
"getFile",
"(",
")",
",",
"'code'",
"=>",
"$",
"e",
"->",
"getCode",
"(",
")",
",",
"'message'",
"=>",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"]",
";",
"if",
"(",
"$",
"e",
"->",
"getPrevious",
"(",
")",
")",
"{",
"return",
"array_merge",
"(",
"$",
"backtrace",
",",
"$",
"this",
"->",
"getExceptionBacktrace",
"(",
"$",
"e",
"->",
"getPrevious",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"backtrace",
";",
"}"
] | Process exception and all previous exceptions to return one-level array with exceptions backtrace
@param \Throwable $e
@return array | [
"Process",
"exception",
"and",
"all",
"previous",
"exceptions",
"to",
"return",
"one",
"-",
"level",
"array",
"with",
"exceptions",
"backtrace"
] | aa520217298ca3fdcfdda3814b9f397376b79fbc | https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Processor/ExceptionBacktrace.php#L67-L84 |
36,467 | CeusMedia/Common | src/UI/HTML/Indicator.php | UI_HTML_Indicator.build | public function build( $found, $count, $length = NULL )
{
$length = is_null( $length ) ? $this->getOption( 'length' ) : $length;
$found = min( $found, $count );
$ratio = $count ? $found / $count : 0;
$divBar = $this->renderBar( $ratio, $length );
$divRatio = $this->renderRatio( $found, $count );
$divPercentage = $this->renderPercentage( $ratio );
$divIndicator = new UI_HTML_Tag( "div" );
$divIndicator->setContent( $divBar.$divPercentage.$divRatio );
$divIndicator->setAttribute( 'class', $this->getOption( 'classIndicator' ) );
if( $this->getOption( 'id' ) )
$divIndicator->setAttribute( 'id', $this->getOption( 'id' ) );
if( $this->getOption( 'useData' ) ){
$divIndicator->setAttribute( 'data-total', $count );
$divIndicator->setAttribute( 'data-value', $found );
foreach( $this->getOptions() as $key => $value )
// if( strlen( $value ) )
// if( preg_match( "/^use/", $key ) )
$divIndicator->setAttribute( 'data-option-'.$key, (string) $value );
}
if( $this->getOption( 'useColorAtBorder' ) ){
$color = $this->getColorFromRatio( $ratio );
$divIndicator->setAttribute( 'style', "border-color: rgb(".$color[0].",".$color[1].",".$color[2].")" );
}
return $divIndicator->build();
} | php | public function build( $found, $count, $length = NULL )
{
$length = is_null( $length ) ? $this->getOption( 'length' ) : $length;
$found = min( $found, $count );
$ratio = $count ? $found / $count : 0;
$divBar = $this->renderBar( $ratio, $length );
$divRatio = $this->renderRatio( $found, $count );
$divPercentage = $this->renderPercentage( $ratio );
$divIndicator = new UI_HTML_Tag( "div" );
$divIndicator->setContent( $divBar.$divPercentage.$divRatio );
$divIndicator->setAttribute( 'class', $this->getOption( 'classIndicator' ) );
if( $this->getOption( 'id' ) )
$divIndicator->setAttribute( 'id', $this->getOption( 'id' ) );
if( $this->getOption( 'useData' ) ){
$divIndicator->setAttribute( 'data-total', $count );
$divIndicator->setAttribute( 'data-value', $found );
foreach( $this->getOptions() as $key => $value )
// if( strlen( $value ) )
// if( preg_match( "/^use/", $key ) )
$divIndicator->setAttribute( 'data-option-'.$key, (string) $value );
}
if( $this->getOption( 'useColorAtBorder' ) ){
$color = $this->getColorFromRatio( $ratio );
$divIndicator->setAttribute( 'style', "border-color: rgb(".$color[0].",".$color[1].",".$color[2].")" );
}
return $divIndicator->build();
} | [
"public",
"function",
"build",
"(",
"$",
"found",
",",
"$",
"count",
",",
"$",
"length",
"=",
"NULL",
")",
"{",
"$",
"length",
"=",
"is_null",
"(",
"$",
"length",
")",
"?",
"$",
"this",
"->",
"getOption",
"(",
"'length'",
")",
":",
"$",
"length",
";",
"$",
"found",
"=",
"min",
"(",
"$",
"found",
",",
"$",
"count",
")",
";",
"$",
"ratio",
"=",
"$",
"count",
"?",
"$",
"found",
"/",
"$",
"count",
":",
"0",
";",
"$",
"divBar",
"=",
"$",
"this",
"->",
"renderBar",
"(",
"$",
"ratio",
",",
"$",
"length",
")",
";",
"$",
"divRatio",
"=",
"$",
"this",
"->",
"renderRatio",
"(",
"$",
"found",
",",
"$",
"count",
")",
";",
"$",
"divPercentage",
"=",
"$",
"this",
"->",
"renderPercentage",
"(",
"$",
"ratio",
")",
";",
"$",
"divIndicator",
"=",
"new",
"UI_HTML_Tag",
"(",
"\"div\"",
")",
";",
"$",
"divIndicator",
"->",
"setContent",
"(",
"$",
"divBar",
".",
"$",
"divPercentage",
".",
"$",
"divRatio",
")",
";",
"$",
"divIndicator",
"->",
"setAttribute",
"(",
"'class'",
",",
"$",
"this",
"->",
"getOption",
"(",
"'classIndicator'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'id'",
")",
")",
"$",
"divIndicator",
"->",
"setAttribute",
"(",
"'id'",
",",
"$",
"this",
"->",
"getOption",
"(",
"'id'",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'useData'",
")",
")",
"{",
"$",
"divIndicator",
"->",
"setAttribute",
"(",
"'data-total'",
",",
"$",
"count",
")",
";",
"$",
"divIndicator",
"->",
"setAttribute",
"(",
"'data-value'",
",",
"$",
"found",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"//\t\t\t\tif( strlen( $value ) )\r",
"//\t\t\t\tif( preg_match( \"/^use/\", $key ) )\r",
"$",
"divIndicator",
"->",
"setAttribute",
"(",
"'data-option-'",
".",
"$",
"key",
",",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'useColorAtBorder'",
")",
")",
"{",
"$",
"color",
"=",
"$",
"this",
"->",
"getColorFromRatio",
"(",
"$",
"ratio",
")",
";",
"$",
"divIndicator",
"->",
"setAttribute",
"(",
"'style'",
",",
"\"border-color: rgb(\"",
".",
"$",
"color",
"[",
"0",
"]",
".",
"\",\"",
".",
"$",
"color",
"[",
"1",
"]",
".",
"\",\"",
".",
"$",
"color",
"[",
"2",
"]",
".",
"\")\"",
")",
";",
"}",
"return",
"$",
"divIndicator",
"->",
"build",
"(",
")",
";",
"}"
] | Builds HTML of Indicator.
@access public
@param int $found Amount of positive Cases
@param int $count Amount of all Cases
@param int $length Length of inner Indicator Bar
@return string | [
"Builds",
"HTML",
"of",
"Indicator",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Indicator.php#L77-L103 |
36,468 | CeusMedia/Common | src/UI/HTML/Indicator.php | UI_HTML_Indicator.getColor | public function getColor( $found, $count ){
$ratio = $count ? $found / $count : 0;
return $this->getColorFromRatio( $ratio );
} | php | public function getColor( $found, $count ){
$ratio = $count ? $found / $count : 0;
return $this->getColorFromRatio( $ratio );
} | [
"public",
"function",
"getColor",
"(",
"$",
"found",
",",
"$",
"count",
")",
"{",
"$",
"ratio",
"=",
"$",
"count",
"?",
"$",
"found",
"/",
"$",
"count",
":",
"0",
";",
"return",
"$",
"this",
"->",
"getColorFromRatio",
"(",
"$",
"ratio",
")",
";",
"}"
] | Returns RGB list of calculated color
@access public
@param int $found Amount of positive Cases
@param int $count Amount of all Cases
@return array List of RGB values | [
"Returns",
"RGB",
"list",
"of",
"calculated",
"color"
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Indicator.php#L112-L115 |
36,469 | CeusMedia/Common | src/UI/HTML/Indicator.php | UI_HTML_Indicator.getColorFromRatio | public function getColorFromRatio( $ratio ){
if( $this->getOption( 'invertColor' ) )
$ratio = 1 - $ratio;
$colorR = ( 1 - $ratio ) > 0.5 ? 255 : round( ( 1 - $ratio ) * 2 * 255 );
$colorG = $ratio > 0.5 ? 255 : round( $ratio * 2 * 255 );
$colorB = "0";
return array( $colorR, $colorG, $colorB );
} | php | public function getColorFromRatio( $ratio ){
if( $this->getOption( 'invertColor' ) )
$ratio = 1 - $ratio;
$colorR = ( 1 - $ratio ) > 0.5 ? 255 : round( ( 1 - $ratio ) * 2 * 255 );
$colorG = $ratio > 0.5 ? 255 : round( $ratio * 2 * 255 );
$colorB = "0";
return array( $colorR, $colorG, $colorB );
} | [
"public",
"function",
"getColorFromRatio",
"(",
"$",
"ratio",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'invertColor'",
")",
")",
"$",
"ratio",
"=",
"1",
"-",
"$",
"ratio",
";",
"$",
"colorR",
"=",
"(",
"1",
"-",
"$",
"ratio",
")",
">",
"0.5",
"?",
"255",
":",
"round",
"(",
"(",
"1",
"-",
"$",
"ratio",
")",
"*",
"2",
"*",
"255",
")",
";",
"$",
"colorG",
"=",
"$",
"ratio",
">",
"0.5",
"?",
"255",
":",
"round",
"(",
"$",
"ratio",
"*",
"2",
"*",
"255",
")",
";",
"$",
"colorB",
"=",
"\"0\"",
";",
"return",
"array",
"(",
"$",
"colorR",
",",
"$",
"colorG",
",",
"$",
"colorB",
")",
";",
"}"
] | Returns RGB list of color calculated by ratio.
@access public
@param float $ratio Ratio (between 0 and 1)
@return array List of RGB values | [
"Returns",
"RGB",
"list",
"of",
"color",
"calculated",
"by",
"ratio",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Indicator.php#L123-L130 |
36,470 | CeusMedia/Common | src/UI/HTML/Indicator.php | UI_HTML_Indicator.renderBar | protected function renderBar( $ratio, $length = 100 )
{
$css = array();
// $width = floor( $ratio * $length );
$width = max( 0, min( 100, $ratio * 100 ) );
$css['width'] = $width.'%';
if( $this->getOption( 'useColor' ) )
{
$color = $this->getColorFromRatio( $ratio );
$css['background-color'] = "rgb(".$color[0].",".$color[1].",".$color[2].")";
}
$attributes = array(
'class' => $this->getOption( 'classInner' ),
'style' => $css,
);
$bar = UI_HTML_Tag::create( 'div', "", $attributes );
$attributes = array( 'class' => $this->getOption( 'classOuter' ) );
$css = array();
if( $length !== 100 )
$css['width'] = preg_match( "/%$/", $length ) ? $length : $length.'px';
if( $this->getOption( 'useColor' ) && $this->getOption( 'useColorAtBorder' ) )
$css['border-color'] = "rgb(".$color[0].",".$color[1].",".$color[2].")";
$attributes['style'] = $css;
return UI_HTML_Tag::create( "span", $bar, $attributes );
} | php | protected function renderBar( $ratio, $length = 100 )
{
$css = array();
// $width = floor( $ratio * $length );
$width = max( 0, min( 100, $ratio * 100 ) );
$css['width'] = $width.'%';
if( $this->getOption( 'useColor' ) )
{
$color = $this->getColorFromRatio( $ratio );
$css['background-color'] = "rgb(".$color[0].",".$color[1].",".$color[2].")";
}
$attributes = array(
'class' => $this->getOption( 'classInner' ),
'style' => $css,
);
$bar = UI_HTML_Tag::create( 'div', "", $attributes );
$attributes = array( 'class' => $this->getOption( 'classOuter' ) );
$css = array();
if( $length !== 100 )
$css['width'] = preg_match( "/%$/", $length ) ? $length : $length.'px';
if( $this->getOption( 'useColor' ) && $this->getOption( 'useColorAtBorder' ) )
$css['border-color'] = "rgb(".$color[0].",".$color[1].",".$color[2].")";
$attributes['style'] = $css;
return UI_HTML_Tag::create( "span", $bar, $attributes );
} | [
"protected",
"function",
"renderBar",
"(",
"$",
"ratio",
",",
"$",
"length",
"=",
"100",
")",
"{",
"$",
"css",
"=",
"array",
"(",
")",
";",
"//\t\t$width\t\t\t= floor( $ratio * $length );\r",
"$",
"width",
"=",
"max",
"(",
"0",
",",
"min",
"(",
"100",
",",
"$",
"ratio",
"*",
"100",
")",
")",
";",
"$",
"css",
"[",
"'width'",
"]",
"=",
"$",
"width",
".",
"'%'",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'useColor'",
")",
")",
"{",
"$",
"color",
"=",
"$",
"this",
"->",
"getColorFromRatio",
"(",
"$",
"ratio",
")",
";",
"$",
"css",
"[",
"'background-color'",
"]",
"=",
"\"rgb(\"",
".",
"$",
"color",
"[",
"0",
"]",
".",
"\",\"",
".",
"$",
"color",
"[",
"1",
"]",
".",
"\",\"",
".",
"$",
"color",
"[",
"2",
"]",
".",
"\")\"",
";",
"}",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"this",
"->",
"getOption",
"(",
"'classInner'",
")",
",",
"'style'",
"=>",
"$",
"css",
",",
")",
";",
"$",
"bar",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'div'",
",",
"\"\"",
",",
"$",
"attributes",
")",
";",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"this",
"->",
"getOption",
"(",
"'classOuter'",
")",
")",
";",
"$",
"css",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"length",
"!==",
"100",
")",
"$",
"css",
"[",
"'width'",
"]",
"=",
"preg_match",
"(",
"\"/%$/\"",
",",
"$",
"length",
")",
"?",
"$",
"length",
":",
"$",
"length",
".",
"'px'",
";",
"if",
"(",
"$",
"this",
"->",
"getOption",
"(",
"'useColor'",
")",
"&&",
"$",
"this",
"->",
"getOption",
"(",
"'useColorAtBorder'",
")",
")",
"$",
"css",
"[",
"'border-color'",
"]",
"=",
"\"rgb(\"",
".",
"$",
"color",
"[",
"0",
"]",
".",
"\",\"",
".",
"$",
"color",
"[",
"1",
"]",
".",
"\",\"",
".",
"$",
"color",
"[",
"2",
"]",
".",
"\")\"",
";",
"$",
"attributes",
"[",
"'style'",
"]",
"=",
"$",
"css",
";",
"return",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"span\"",
",",
"$",
"bar",
",",
"$",
"attributes",
")",
";",
"}"
] | Builds HTML Code of Indicator Bar.
@access protected
@param float $ratio Ratio (between 0 and 1)
@param int $length Length of Indicator
@return string | [
"Builds",
"HTML",
"Code",
"of",
"Indicator",
"Bar",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Indicator.php#L194-L220 |
36,471 | CeusMedia/Common | src/UI/HTML/Indicator.php | UI_HTML_Indicator.renderPercentage | protected function renderPercentage( $ratio )
{
if( !$this->getOption( 'usePercentage' ) )
return "";
$value = floor( $ratio * 100 )." %";
$attributes = array( 'class' => $this->getOption( 'classPercentage' ) );
$div = UI_HTML_Tag::create( "span", $value, $attributes );
return $div;
} | php | protected function renderPercentage( $ratio )
{
if( !$this->getOption( 'usePercentage' ) )
return "";
$value = floor( $ratio * 100 )." %";
$attributes = array( 'class' => $this->getOption( 'classPercentage' ) );
$div = UI_HTML_Tag::create( "span", $value, $attributes );
return $div;
} | [
"protected",
"function",
"renderPercentage",
"(",
"$",
"ratio",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getOption",
"(",
"'usePercentage'",
")",
")",
"return",
"\"\"",
";",
"$",
"value",
"=",
"floor",
"(",
"$",
"ratio",
"*",
"100",
")",
".",
"\" %\"",
";",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"this",
"->",
"getOption",
"(",
"'classPercentage'",
")",
")",
";",
"$",
"div",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"span\"",
",",
"$",
"value",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"div",
";",
"}"
] | Builds HTML Code of Percentage Block.
@access protected
@param float $ratio Ratio (between 0 and 1)
@return string | [
"Builds",
"HTML",
"Code",
"of",
"Percentage",
"Block",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Indicator.php#L228-L236 |
36,472 | CeusMedia/Common | src/UI/HTML/Indicator.php | UI_HTML_Indicator.renderRatio | protected function renderRatio( $found, $count )
{
if( !$this->getOption( 'useRatio' ) )
return "";
$content = $found."/".$count;
$attributes = array( 'class' => $this->getOption( 'classRatio' ) );
$div = UI_HTML_Tag::create( "span", $content, $attributes );
return $div;
} | php | protected function renderRatio( $found, $count )
{
if( !$this->getOption( 'useRatio' ) )
return "";
$content = $found."/".$count;
$attributes = array( 'class' => $this->getOption( 'classRatio' ) );
$div = UI_HTML_Tag::create( "span", $content, $attributes );
return $div;
} | [
"protected",
"function",
"renderRatio",
"(",
"$",
"found",
",",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getOption",
"(",
"'useRatio'",
")",
")",
"return",
"\"\"",
";",
"$",
"content",
"=",
"$",
"found",
".",
"\"/\"",
".",
"$",
"count",
";",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"this",
"->",
"getOption",
"(",
"'classRatio'",
")",
")",
";",
"$",
"div",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"\"span\"",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"div",
";",
"}"
] | Builds HTML Code of Ratio Block.
@access protected
@param int $found Amount of positive Cases
@param int $count Amount of all Cases
@return string | [
"Builds",
"HTML",
"Code",
"of",
"Ratio",
"Block",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Indicator.php#L245-L253 |
36,473 | CeusMedia/Common | src/UI/HTML/Indicator.php | UI_HTML_Indicator.setOption | public function setOption( $key, $value )
{
if( !array_key_exists( $key, $this->defaultOptions ) )
throw new OutOfRangeException( 'Option "'.$key.'" is not a valid Indicator Option.' );
return parent::setOption( $key, $value );
} | php | public function setOption( $key, $value )
{
if( !array_key_exists( $key, $this->defaultOptions ) )
throw new OutOfRangeException( 'Option "'.$key.'" is not a valid Indicator Option.' );
return parent::setOption( $key, $value );
} | [
"public",
"function",
"setOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"defaultOptions",
")",
")",
"throw",
"new",
"OutOfRangeException",
"(",
"'Option \"'",
".",
"$",
"key",
".",
"'\" is not a valid Indicator Option.'",
")",
";",
"return",
"parent",
"::",
"setOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}"
] | Sets Option.
@access public
@param string $key Option Key (useColor|usePercentage|useRatio)
@param bool $values Flag: switch Option
@return bool | [
"Sets",
"Option",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Indicator.php#L284-L289 |
36,474 | CeusMedia/Common | src/UI/HTML/CSS/TreeMenu.php | UI_HTML_CSS_TreeMenu.buildItemWithChildren | protected static function buildItemWithChildren( ADT_Tree_Menu_Item &$node, $level, $contentDrop = NULL )
{
$contentDrop = $contentDrop !== NULL ? $contentDrop : self::$contentDropDefault;
$children = "";
$label = self::buildLabelSpan( $node->label, $level, $node->class, $node->disabled, $node->url );
if( $node->hasChildren() )
{
$children = array();
foreach( $node->getChildren() as $child )
$children[] = self::buildItemWithChildren( $child, $level + 1, $contentDrop );
$classList = $node->getAttribute( 'classList' );
$attributes = array( 'class' => $classList );
$children = "\n".UI_HTML_Elements::unorderedList( $children, $level + 1, $attributes );
$children .= '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
$drop = $level > 1 ? $contentDrop : " ";
$label = '<span class="drop">'.$label.$drop.'</span><!--[if gt IE 6]><!-->';
}
$classLink = $node->getAttribute( 'classLink' )." level-".$level;
$classItem = $node->getAttribute( 'classItem' )." level-".$level;
$labelLink = $label;
if( $node->url && !$node->getAttribute( 'disabled' ) )
$labelLink = UI_HTML_Elements::Link( $node->url, $label, $classLink );
if( $node->hasChildren() )
$labelLink .= '<!--<![endif]--><!--[if lt IE 7]><table border="0" cellpadding="0" cellspacing="0"><tr><td><![endif]-->';
$attributes = array( 'class' => $classItem );
if( $node->getAttribute( 'disabled' ) )
$attributes['class'] .= " disabled";
return UI_HTML_Elements::ListItem( $labelLink.$children, $level, $attributes );
} | php | protected static function buildItemWithChildren( ADT_Tree_Menu_Item &$node, $level, $contentDrop = NULL )
{
$contentDrop = $contentDrop !== NULL ? $contentDrop : self::$contentDropDefault;
$children = "";
$label = self::buildLabelSpan( $node->label, $level, $node->class, $node->disabled, $node->url );
if( $node->hasChildren() )
{
$children = array();
foreach( $node->getChildren() as $child )
$children[] = self::buildItemWithChildren( $child, $level + 1, $contentDrop );
$classList = $node->getAttribute( 'classList' );
$attributes = array( 'class' => $classList );
$children = "\n".UI_HTML_Elements::unorderedList( $children, $level + 1, $attributes );
$children .= '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
$drop = $level > 1 ? $contentDrop : " ";
$label = '<span class="drop">'.$label.$drop.'</span><!--[if gt IE 6]><!-->';
}
$classLink = $node->getAttribute( 'classLink' )." level-".$level;
$classItem = $node->getAttribute( 'classItem' )." level-".$level;
$labelLink = $label;
if( $node->url && !$node->getAttribute( 'disabled' ) )
$labelLink = UI_HTML_Elements::Link( $node->url, $label, $classLink );
if( $node->hasChildren() )
$labelLink .= '<!--<![endif]--><!--[if lt IE 7]><table border="0" cellpadding="0" cellspacing="0"><tr><td><![endif]-->';
$attributes = array( 'class' => $classItem );
if( $node->getAttribute( 'disabled' ) )
$attributes['class'] .= " disabled";
return UI_HTML_Elements::ListItem( $labelLink.$children, $level, $attributes );
} | [
"protected",
"static",
"function",
"buildItemWithChildren",
"(",
"ADT_Tree_Menu_Item",
"&",
"$",
"node",
",",
"$",
"level",
",",
"$",
"contentDrop",
"=",
"NULL",
")",
"{",
"$",
"contentDrop",
"=",
"$",
"contentDrop",
"!==",
"NULL",
"?",
"$",
"contentDrop",
":",
"self",
"::",
"$",
"contentDropDefault",
";",
"$",
"children",
"=",
"\"\"",
";",
"$",
"label",
"=",
"self",
"::",
"buildLabelSpan",
"(",
"$",
"node",
"->",
"label",
",",
"$",
"level",
",",
"$",
"node",
"->",
"class",
",",
"$",
"node",
"->",
"disabled",
",",
"$",
"node",
"->",
"url",
")",
";",
"if",
"(",
"$",
"node",
"->",
"hasChildren",
"(",
")",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"node",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"$",
"children",
"[",
"]",
"=",
"self",
"::",
"buildItemWithChildren",
"(",
"$",
"child",
",",
"$",
"level",
"+",
"1",
",",
"$",
"contentDrop",
")",
";",
"$",
"classList",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"'classList'",
")",
";",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"classList",
")",
";",
"$",
"children",
"=",
"\"\\n\"",
".",
"UI_HTML_Elements",
"::",
"unorderedList",
"(",
"$",
"children",
",",
"$",
"level",
"+",
"1",
",",
"$",
"attributes",
")",
";",
"$",
"children",
".=",
"'<!--[if lte IE 6]></td></tr></table></a><![endif]-->'",
";",
"$",
"drop",
"=",
"$",
"level",
">",
"1",
"?",
"$",
"contentDrop",
":",
"\" \"",
";",
"$",
"label",
"=",
"'<span class=\"drop\">'",
".",
"$",
"label",
".",
"$",
"drop",
".",
"'</span><!--[if gt IE 6]><!-->'",
";",
"}",
"$",
"classLink",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"'classLink'",
")",
".",
"\" level-\"",
".",
"$",
"level",
";",
"$",
"classItem",
"=",
"$",
"node",
"->",
"getAttribute",
"(",
"'classItem'",
")",
".",
"\" level-\"",
".",
"$",
"level",
";",
"$",
"labelLink",
"=",
"$",
"label",
";",
"if",
"(",
"$",
"node",
"->",
"url",
"&&",
"!",
"$",
"node",
"->",
"getAttribute",
"(",
"'disabled'",
")",
")",
"$",
"labelLink",
"=",
"UI_HTML_Elements",
"::",
"Link",
"(",
"$",
"node",
"->",
"url",
",",
"$",
"label",
",",
"$",
"classLink",
")",
";",
"if",
"(",
"$",
"node",
"->",
"hasChildren",
"(",
")",
")",
"$",
"labelLink",
".=",
"'<!--<![endif]--><!--[if lt IE 7]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><![endif]-->'",
";",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"classItem",
")",
";",
"if",
"(",
"$",
"node",
"->",
"getAttribute",
"(",
"'disabled'",
")",
")",
"$",
"attributes",
"[",
"'class'",
"]",
".=",
"\" disabled\"",
";",
"return",
"UI_HTML_Elements",
"::",
"ListItem",
"(",
"$",
"labelLink",
".",
"$",
"children",
",",
"$",
"level",
",",
"$",
"attributes",
")",
";",
"}"
] | Builds HTML of a List Item with its nested Tree Menu Items statically.
@access protected
@static
@param ADT_Tree_Menu_Item $node Tree Menu Item
@param string $contentDrop Indicator HTML Code for Items containing further Items
@return string | [
"Builds",
"HTML",
"of",
"a",
"List",
"Item",
"with",
"its",
"nested",
"Tree",
"Menu",
"Items",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/CSS/TreeMenu.php#L92-L120 |
36,475 | CeusMedia/Common | src/UI/HTML/CSS/TreeMenu.php | UI_HTML_CSS_TreeMenu.buildItemWithChildrenFromArray | protected static function buildItemWithChildrenFromArray( &$node, $level, $contentDrop = NULL )
{
$contentDrop = $contentDrop !== NULL ? $contentDrop : self::$contentDropDefault;
$children = "";
$class = isset( $node['class'] ) ? $node['class'] : 'option';
$disabled = isset( $node['disabled'] ) ? $node['disabled'] : FALSE;
$label = self::buildLabelSpan( $node['label'], $level, $class, $disabled, $node['url'] );
if( isset( $node['children'] ) && $node['children'] )
{
$children = array();
foreach( $node['children'] as $child )
$children[] = self::buildItemWithChildrenFromArray( $child, $level + 1 );
$classList = isset( $node['classList'] ) ? $node['classList'] : NULL;
$attributes = array( 'class' => $classList );
$children = "\n".UI_HTML_Elements::unorderedList( $children, $level + 1, $attributes );
$children .= '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
$drop = $level > 1 ? $contentDrop : " ";
$label = '<span class="drop">'.$label.$drop.'</span><!--[if gt IE 6]><!-->';
}
$classLink = isset( $node['classLink'] ) ? $node['classLink']." level-".$level : NULL;
$classItem = isset( $node['classItem'] ) ? $node['classItem']." level-".$level : NULL;
$labelLink = UI_HTML_Elements::Link( $node['url'], $label, $classLink );
if( isset( $node['children'] ) && $node['children'] )
$labelLink .= '<!--<![endif]--><!--[if lt IE 7]><table border="0" cellpadding="0" cellspacing="0"><tr><td><![endif]-->';
$attributes = array( 'class' => $classItem );
return UI_HTML_Elements::ListItem( $labelLink.$children, $level, $attributes );
} | php | protected static function buildItemWithChildrenFromArray( &$node, $level, $contentDrop = NULL )
{
$contentDrop = $contentDrop !== NULL ? $contentDrop : self::$contentDropDefault;
$children = "";
$class = isset( $node['class'] ) ? $node['class'] : 'option';
$disabled = isset( $node['disabled'] ) ? $node['disabled'] : FALSE;
$label = self::buildLabelSpan( $node['label'], $level, $class, $disabled, $node['url'] );
if( isset( $node['children'] ) && $node['children'] )
{
$children = array();
foreach( $node['children'] as $child )
$children[] = self::buildItemWithChildrenFromArray( $child, $level + 1 );
$classList = isset( $node['classList'] ) ? $node['classList'] : NULL;
$attributes = array( 'class' => $classList );
$children = "\n".UI_HTML_Elements::unorderedList( $children, $level + 1, $attributes );
$children .= '<!--[if lte IE 6]></td></tr></table></a><![endif]-->';
$drop = $level > 1 ? $contentDrop : " ";
$label = '<span class="drop">'.$label.$drop.'</span><!--[if gt IE 6]><!-->';
}
$classLink = isset( $node['classLink'] ) ? $node['classLink']." level-".$level : NULL;
$classItem = isset( $node['classItem'] ) ? $node['classItem']." level-".$level : NULL;
$labelLink = UI_HTML_Elements::Link( $node['url'], $label, $classLink );
if( isset( $node['children'] ) && $node['children'] )
$labelLink .= '<!--<![endif]--><!--[if lt IE 7]><table border="0" cellpadding="0" cellspacing="0"><tr><td><![endif]-->';
$attributes = array( 'class' => $classItem );
return UI_HTML_Elements::ListItem( $labelLink.$children, $level, $attributes );
} | [
"protected",
"static",
"function",
"buildItemWithChildrenFromArray",
"(",
"&",
"$",
"node",
",",
"$",
"level",
",",
"$",
"contentDrop",
"=",
"NULL",
")",
"{",
"$",
"contentDrop",
"=",
"$",
"contentDrop",
"!==",
"NULL",
"?",
"$",
"contentDrop",
":",
"self",
"::",
"$",
"contentDropDefault",
";",
"$",
"children",
"=",
"\"\"",
";",
"$",
"class",
"=",
"isset",
"(",
"$",
"node",
"[",
"'class'",
"]",
")",
"?",
"$",
"node",
"[",
"'class'",
"]",
":",
"'option'",
";",
"$",
"disabled",
"=",
"isset",
"(",
"$",
"node",
"[",
"'disabled'",
"]",
")",
"?",
"$",
"node",
"[",
"'disabled'",
"]",
":",
"FALSE",
";",
"$",
"label",
"=",
"self",
"::",
"buildLabelSpan",
"(",
"$",
"node",
"[",
"'label'",
"]",
",",
"$",
"level",
",",
"$",
"class",
",",
"$",
"disabled",
",",
"$",
"node",
"[",
"'url'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'children'",
"]",
")",
"&&",
"$",
"node",
"[",
"'children'",
"]",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"node",
"[",
"'children'",
"]",
"as",
"$",
"child",
")",
"$",
"children",
"[",
"]",
"=",
"self",
"::",
"buildItemWithChildrenFromArray",
"(",
"$",
"child",
",",
"$",
"level",
"+",
"1",
")",
";",
"$",
"classList",
"=",
"isset",
"(",
"$",
"node",
"[",
"'classList'",
"]",
")",
"?",
"$",
"node",
"[",
"'classList'",
"]",
":",
"NULL",
";",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"classList",
")",
";",
"$",
"children",
"=",
"\"\\n\"",
".",
"UI_HTML_Elements",
"::",
"unorderedList",
"(",
"$",
"children",
",",
"$",
"level",
"+",
"1",
",",
"$",
"attributes",
")",
";",
"$",
"children",
".=",
"'<!--[if lte IE 6]></td></tr></table></a><![endif]-->'",
";",
"$",
"drop",
"=",
"$",
"level",
">",
"1",
"?",
"$",
"contentDrop",
":",
"\" \"",
";",
"$",
"label",
"=",
"'<span class=\"drop\">'",
".",
"$",
"label",
".",
"$",
"drop",
".",
"'</span><!--[if gt IE 6]><!-->'",
";",
"}",
"$",
"classLink",
"=",
"isset",
"(",
"$",
"node",
"[",
"'classLink'",
"]",
")",
"?",
"$",
"node",
"[",
"'classLink'",
"]",
".",
"\" level-\"",
".",
"$",
"level",
":",
"NULL",
";",
"$",
"classItem",
"=",
"isset",
"(",
"$",
"node",
"[",
"'classItem'",
"]",
")",
"?",
"$",
"node",
"[",
"'classItem'",
"]",
".",
"\" level-\"",
".",
"$",
"level",
":",
"NULL",
";",
"$",
"labelLink",
"=",
"UI_HTML_Elements",
"::",
"Link",
"(",
"$",
"node",
"[",
"'url'",
"]",
",",
"$",
"label",
",",
"$",
"classLink",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"node",
"[",
"'children'",
"]",
")",
"&&",
"$",
"node",
"[",
"'children'",
"]",
")",
"$",
"labelLink",
".=",
"'<!--<![endif]--><!--[if lt IE 7]><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><![endif]-->'",
";",
"$",
"attributes",
"=",
"array",
"(",
"'class'",
"=>",
"$",
"classItem",
")",
";",
"return",
"UI_HTML_Elements",
"::",
"ListItem",
"(",
"$",
"labelLink",
".",
"$",
"children",
",",
"$",
"level",
",",
"$",
"attributes",
")",
";",
"}"
] | Builds HTML of a List Item with its nested Tree Menu Items from Data Array statically.
@access protected
@static
@param array $node Data Array of Tree Menu Item
@param string $contentDrop Indicator HTML Code for Items containing further Items
@return string | [
"Builds",
"HTML",
"of",
"a",
"List",
"Item",
"with",
"its",
"nested",
"Tree",
"Menu",
"Items",
"from",
"Data",
"Array",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/CSS/TreeMenu.php#L130-L156 |
36,476 | CeusMedia/Common | src/UI/HTML/CSS/TreeMenu.php | UI_HTML_CSS_TreeMenu.buildMenu | public static function buildMenu( ADT_Tree_Menu_List $tree, $contentDrop = NULL, $attributes = array() )
{
$list = array();
foreach( $tree->getChildren() as $child )
$list[] = self::buildItemWithChildren( $child, 1, $contentDrop );
return UI_HTML_Elements::unorderedList( $list, 1, $attributes );
} | php | public static function buildMenu( ADT_Tree_Menu_List $tree, $contentDrop = NULL, $attributes = array() )
{
$list = array();
foreach( $tree->getChildren() as $child )
$list[] = self::buildItemWithChildren( $child, 1, $contentDrop );
return UI_HTML_Elements::unorderedList( $list, 1, $attributes );
} | [
"public",
"static",
"function",
"buildMenu",
"(",
"ADT_Tree_Menu_List",
"$",
"tree",
",",
"$",
"contentDrop",
"=",
"NULL",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tree",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"$",
"list",
"[",
"]",
"=",
"self",
"::",
"buildItemWithChildren",
"(",
"$",
"child",
",",
"1",
",",
"$",
"contentDrop",
")",
";",
"return",
"UI_HTML_Elements",
"::",
"unorderedList",
"(",
"$",
"list",
",",
"1",
",",
"$",
"attributes",
")",
";",
"}"
] | Builds HTML of Tree Menu from Tree Menu List Data Object statically.
@access public
@static
@param ADT_Tree_Menu_List $tree Tree Menu List Data Object
@param string $contentDrop Indicator HTML Code for Items containing further Items
@param array $attributes Map of HTML Attributes of List Tag
@return string | [
"Builds",
"HTML",
"of",
"Tree",
"Menu",
"from",
"Tree",
"Menu",
"List",
"Data",
"Object",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/CSS/TreeMenu.php#L187-L193 |
36,477 | CeusMedia/Common | src/UI/HTML/CSS/TreeMenu.php | UI_HTML_CSS_TreeMenu.buildMenuFromArray | public static function buildMenuFromArray( $tree, $contentDrop = NULL )
{
$list = array();
foreach( $tree['children'] as $child )
$list[] = self::buildItemWithChildrenFromArray( $child, 1, $contentDrop );
return UI_HTML_Elements::unorderedList( $list, 1 );
} | php | public static function buildMenuFromArray( $tree, $contentDrop = NULL )
{
$list = array();
foreach( $tree['children'] as $child )
$list[] = self::buildItemWithChildrenFromArray( $child, 1, $contentDrop );
return UI_HTML_Elements::unorderedList( $list, 1 );
} | [
"public",
"static",
"function",
"buildMenuFromArray",
"(",
"$",
"tree",
",",
"$",
"contentDrop",
"=",
"NULL",
")",
"{",
"$",
"list",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"tree",
"[",
"'children'",
"]",
"as",
"$",
"child",
")",
"$",
"list",
"[",
"]",
"=",
"self",
"::",
"buildItemWithChildrenFromArray",
"(",
"$",
"child",
",",
"1",
",",
"$",
"contentDrop",
")",
";",
"return",
"UI_HTML_Elements",
"::",
"unorderedList",
"(",
"$",
"list",
",",
"1",
")",
";",
"}"
] | Builds HTML of Tree Menu from Data Array statically.
@access public
@static
@param array $tree Data Array with Tree Menu Structure
@param string $contentDrop Indicator HTML Code for Items containing further Items
@return string | [
"Builds",
"HTML",
"of",
"Tree",
"Menu",
"from",
"Data",
"Array",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/CSS/TreeMenu.php#L203-L209 |
36,478 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getConstantValue | public static function getConstantValue($class, $constant)
{
$reflection = new \ReflectionClass($class);
if (self::hasConstant($class, $constant)) {
return $reflection->getConstant($constant);
}
return null;
} | php | public static function getConstantValue($class, $constant)
{
$reflection = new \ReflectionClass($class);
if (self::hasConstant($class, $constant)) {
return $reflection->getConstant($constant);
}
return null;
} | [
"public",
"static",
"function",
"getConstantValue",
"(",
"$",
"class",
",",
"$",
"constant",
")",
"{",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"if",
"(",
"self",
"::",
"hasConstant",
"(",
"$",
"class",
",",
"$",
"constant",
")",
")",
"{",
"return",
"$",
"reflection",
"->",
"getConstant",
"(",
"$",
"constant",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns value of given constant
@param object|string $class The object or name of object's class
@param string $constant Name of the constant that contains a value
@return mixed | [
"Returns",
"value",
"of",
"given",
"constant"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L147-L156 |
36,479 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getPropertyValue | public static function getPropertyValue($source, $property, $force = false)
{
if (Regex::contains($property, '.')) {
return self::getPropertyValueByPropertiesChain($source, $property, $force);
}
[
$value,
$valueFound,
] = self::getPropertyValueByReflectionProperty($source, $property);
if (!$valueFound) {
[
$value,
$valueFound,
] = self::getPropertyValueByParentClasses($source, $property);
}
if (!$valueFound && ($force || self::hasProperty($source, $property))) {
[
$value,
$valueFound,
] = self::getPropertyValueByGetter($source, $property);
}
if (!$valueFound) {
$byReflectionProperty = self::getPropertyValueByReflectionProperty($source, $property);
$value = $byReflectionProperty[0];
}
return $value;
} | php | public static function getPropertyValue($source, $property, $force = false)
{
if (Regex::contains($property, '.')) {
return self::getPropertyValueByPropertiesChain($source, $property, $force);
}
[
$value,
$valueFound,
] = self::getPropertyValueByReflectionProperty($source, $property);
if (!$valueFound) {
[
$value,
$valueFound,
] = self::getPropertyValueByParentClasses($source, $property);
}
if (!$valueFound && ($force || self::hasProperty($source, $property))) {
[
$value,
$valueFound,
] = self::getPropertyValueByGetter($source, $property);
}
if (!$valueFound) {
$byReflectionProperty = self::getPropertyValueByReflectionProperty($source, $property);
$value = $byReflectionProperty[0];
}
return $value;
} | [
"public",
"static",
"function",
"getPropertyValue",
"(",
"$",
"source",
",",
"$",
"property",
",",
"$",
"force",
"=",
"false",
")",
"{",
"if",
"(",
"Regex",
"::",
"contains",
"(",
"$",
"property",
",",
"'.'",
")",
")",
"{",
"return",
"self",
"::",
"getPropertyValueByPropertiesChain",
"(",
"$",
"source",
",",
"$",
"property",
",",
"$",
"force",
")",
";",
"}",
"[",
"$",
"value",
",",
"$",
"valueFound",
",",
"]",
"=",
"self",
"::",
"getPropertyValueByReflectionProperty",
"(",
"$",
"source",
",",
"$",
"property",
")",
";",
"if",
"(",
"!",
"$",
"valueFound",
")",
"{",
"[",
"$",
"value",
",",
"$",
"valueFound",
",",
"]",
"=",
"self",
"::",
"getPropertyValueByParentClasses",
"(",
"$",
"source",
",",
"$",
"property",
")",
";",
"}",
"if",
"(",
"!",
"$",
"valueFound",
"&&",
"(",
"$",
"force",
"||",
"self",
"::",
"hasProperty",
"(",
"$",
"source",
",",
"$",
"property",
")",
")",
")",
"{",
"[",
"$",
"value",
",",
"$",
"valueFound",
",",
"]",
"=",
"self",
"::",
"getPropertyValueByGetter",
"(",
"$",
"source",
",",
"$",
"property",
")",
";",
"}",
"if",
"(",
"!",
"$",
"valueFound",
")",
"{",
"$",
"byReflectionProperty",
"=",
"self",
"::",
"getPropertyValueByReflectionProperty",
"(",
"$",
"source",
",",
"$",
"property",
")",
";",
"$",
"value",
"=",
"$",
"byReflectionProperty",
"[",
"0",
"]",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Returns value of given property
@param mixed $source Object that should contains given property
@param string $property Name of the property that contains a value. It may be also multiple properties
dot-separated, e.g. "invoice.user.email".
@param bool $force (optional) If is set to true, try to retrieve value even if the object doesn't have
property. Otherwise - not.
@return mixed | [
"Returns",
"value",
"of",
"given",
"property"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L168-L199 |
36,480 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getPropertyValues | public static function getPropertyValues($objects, $property, $force = false)
{
/*
* No objects?
* Nothing to do
*/
if (empty($objects)) {
return [];
}
if ($objects instanceof Collection) {
$objects = $objects->toArray();
}
$values = [];
$objects = Arrays::makeArray($objects);
foreach ($objects as $object) {
$value = self::getPropertyValue($object, $property, $force);
if (null !== $value) {
$values[] = $value;
}
}
return $values;
} | php | public static function getPropertyValues($objects, $property, $force = false)
{
/*
* No objects?
* Nothing to do
*/
if (empty($objects)) {
return [];
}
if ($objects instanceof Collection) {
$objects = $objects->toArray();
}
$values = [];
$objects = Arrays::makeArray($objects);
foreach ($objects as $object) {
$value = self::getPropertyValue($object, $property, $force);
if (null !== $value) {
$values[] = $value;
}
}
return $values;
} | [
"public",
"static",
"function",
"getPropertyValues",
"(",
"$",
"objects",
",",
"$",
"property",
",",
"$",
"force",
"=",
"false",
")",
"{",
"/*\n * No objects?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"objects",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"objects",
"instanceof",
"Collection",
")",
"{",
"$",
"objects",
"=",
"$",
"objects",
"->",
"toArray",
"(",
")",
";",
"}",
"$",
"values",
"=",
"[",
"]",
";",
"$",
"objects",
"=",
"Arrays",
"::",
"makeArray",
"(",
"$",
"objects",
")",
";",
"foreach",
"(",
"$",
"objects",
"as",
"$",
"object",
")",
"{",
"$",
"value",
"=",
"self",
"::",
"getPropertyValue",
"(",
"$",
"object",
",",
"$",
"property",
",",
"$",
"force",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"value",
")",
"{",
"$",
"values",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] | Returns values of given property for given objects.
Looks for proper getter for the property.
@param array|Collection|object $objects The objects that should contain given property. It may be also one
object.
@param string $property Name of the property that contains a value
@param bool $force (optional) If is set to true, try to retrieve value even if the
object does not have property. Otherwise - not.
@return array | [
"Returns",
"values",
"of",
"given",
"property",
"for",
"given",
"objects",
".",
"Looks",
"for",
"proper",
"getter",
"for",
"the",
"property",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L212-L238 |
36,481 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getClassName | public static function getClassName($source, $withoutNamespace = false)
{
/*
* First argument is not proper source of class?
* Nothing to do
*/
if (empty($source) || (!is_array($source) && !is_object($source) && !is_string($source))) {
return null;
}
$name = '';
/*
* An array of objects was provided?
* Let's use first of them
*/
if (is_array($source)) {
$source = Arrays::getFirstElement($source);
}
// Let's prepare name of class
if (is_object($source)) {
$name = get_class($source);
} elseif (is_string($source) && (class_exists($source) || trait_exists($source))) {
$name = $source;
}
/*
* Name of class is still unknown?
* Nothing to do
*/
if (empty($name)) {
return null;
}
/*
* Namespace is not required?
* Let's return name of class only
*/
if ($withoutNamespace) {
$classOnly = Miscellaneous::getLastElementOfString($name, '\\');
if (null !== $classOnly) {
$name = $classOnly;
}
return $name;
}
return static::getRealClass($name);
} | php | public static function getClassName($source, $withoutNamespace = false)
{
/*
* First argument is not proper source of class?
* Nothing to do
*/
if (empty($source) || (!is_array($source) && !is_object($source) && !is_string($source))) {
return null;
}
$name = '';
/*
* An array of objects was provided?
* Let's use first of them
*/
if (is_array($source)) {
$source = Arrays::getFirstElement($source);
}
// Let's prepare name of class
if (is_object($source)) {
$name = get_class($source);
} elseif (is_string($source) && (class_exists($source) || trait_exists($source))) {
$name = $source;
}
/*
* Name of class is still unknown?
* Nothing to do
*/
if (empty($name)) {
return null;
}
/*
* Namespace is not required?
* Let's return name of class only
*/
if ($withoutNamespace) {
$classOnly = Miscellaneous::getLastElementOfString($name, '\\');
if (null !== $classOnly) {
$name = $classOnly;
}
return $name;
}
return static::getRealClass($name);
} | [
"public",
"static",
"function",
"getClassName",
"(",
"$",
"source",
",",
"$",
"withoutNamespace",
"=",
"false",
")",
"{",
"/*\n * First argument is not proper source of class?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"source",
")",
"||",
"(",
"!",
"is_array",
"(",
"$",
"source",
")",
"&&",
"!",
"is_object",
"(",
"$",
"source",
")",
"&&",
"!",
"is_string",
"(",
"$",
"source",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"name",
"=",
"''",
";",
"/*\n * An array of objects was provided?\n * Let's use first of them\n */",
"if",
"(",
"is_array",
"(",
"$",
"source",
")",
")",
"{",
"$",
"source",
"=",
"Arrays",
"::",
"getFirstElement",
"(",
"$",
"source",
")",
";",
"}",
"// Let's prepare name of class",
"if",
"(",
"is_object",
"(",
"$",
"source",
")",
")",
"{",
"$",
"name",
"=",
"get_class",
"(",
"$",
"source",
")",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"source",
")",
"&&",
"(",
"class_exists",
"(",
"$",
"source",
")",
"||",
"trait_exists",
"(",
"$",
"source",
")",
")",
")",
"{",
"$",
"name",
"=",
"$",
"source",
";",
"}",
"/*\n * Name of class is still unknown?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"return",
"null",
";",
"}",
"/*\n * Namespace is not required?\n * Let's return name of class only\n */",
"if",
"(",
"$",
"withoutNamespace",
")",
"{",
"$",
"classOnly",
"=",
"Miscellaneous",
"::",
"getLastElementOfString",
"(",
"$",
"name",
",",
"'\\\\'",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"classOnly",
")",
"{",
"$",
"name",
"=",
"$",
"classOnly",
";",
"}",
"return",
"$",
"name",
";",
"}",
"return",
"static",
"::",
"getRealClass",
"(",
"$",
"name",
")",
";",
"}"
] | Returns a class name for given source
@param array|object|string $source An array of objects, namespaces, object or namespace
@param bool $withoutNamespace (optional) If is set to true, namespace is omitted. Otherwise -
not, full name of class is returned, with namespace.
@return null|string | [
"Returns",
"a",
"class",
"name",
"for",
"given",
"source"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L248-L298 |
36,482 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getClassNamespace | public static function getClassNamespace($source)
{
$fullClassName = self::getClassName($source);
if (null === $fullClassName || '' === $fullClassName) {
return '';
}
$className = self::getClassName($source, true);
if ($className === $fullClassName) {
return $className;
}
return Miscellaneous::getStringWithoutLastElement($fullClassName, '\\');
} | php | public static function getClassNamespace($source)
{
$fullClassName = self::getClassName($source);
if (null === $fullClassName || '' === $fullClassName) {
return '';
}
$className = self::getClassName($source, true);
if ($className === $fullClassName) {
return $className;
}
return Miscellaneous::getStringWithoutLastElement($fullClassName, '\\');
} | [
"public",
"static",
"function",
"getClassNamespace",
"(",
"$",
"source",
")",
"{",
"$",
"fullClassName",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"source",
")",
";",
"if",
"(",
"null",
"===",
"$",
"fullClassName",
"||",
"''",
"===",
"$",
"fullClassName",
")",
"{",
"return",
"''",
";",
"}",
"$",
"className",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"source",
",",
"true",
")",
";",
"if",
"(",
"$",
"className",
"===",
"$",
"fullClassName",
")",
"{",
"return",
"$",
"className",
";",
"}",
"return",
"Miscellaneous",
"::",
"getStringWithoutLastElement",
"(",
"$",
"fullClassName",
",",
"'\\\\'",
")",
";",
"}"
] | Returns namespace of class for given source
@param array|object|string $source An array of objects, namespaces, object or namespace
@return string | [
"Returns",
"namespace",
"of",
"class",
"for",
"given",
"source"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L306-L321 |
36,483 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.isChildOfClass | public static function isChildOfClass($childClass, $parentClass)
{
$childClassName = self::getClassName($childClass);
$parentClassName = self::getClassName($parentClass);
$parents = class_parents($childClassName);
if (is_array($parents) && 0 < count($parents)) {
return in_array($parentClassName, $parents, true);
}
return false;
} | php | public static function isChildOfClass($childClass, $parentClass)
{
$childClassName = self::getClassName($childClass);
$parentClassName = self::getClassName($parentClass);
$parents = class_parents($childClassName);
if (is_array($parents) && 0 < count($parents)) {
return in_array($parentClassName, $parents, true);
}
return false;
} | [
"public",
"static",
"function",
"isChildOfClass",
"(",
"$",
"childClass",
",",
"$",
"parentClass",
")",
"{",
"$",
"childClassName",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"childClass",
")",
";",
"$",
"parentClassName",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"parentClass",
")",
";",
"$",
"parents",
"=",
"class_parents",
"(",
"$",
"childClassName",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"parents",
")",
"&&",
"0",
"<",
"count",
"(",
"$",
"parents",
")",
")",
"{",
"return",
"in_array",
"(",
"$",
"parentClassName",
",",
"$",
"parents",
",",
"true",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns information if given child class is a subclass of given parent class
@param array|object|string $childClass The child class. An array of objects, namespaces, object or namespace.
@param array|object|string $parentClass The parent class. An array of objects, namespaces, object or namespace.
@return bool | [
"Returns",
"information",
"if",
"given",
"child",
"class",
"is",
"a",
"subclass",
"of",
"given",
"parent",
"class"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L345-L357 |
36,484 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getProperties | public static function getProperties($source, $filter = null, $includeParents = false): array
{
$className = self::getClassName($source);
$reflection = new \ReflectionClass($className);
if (null === $filter) {
$filter = \ReflectionProperty::IS_PRIVATE
+ \ReflectionProperty::IS_PROTECTED
+ \ReflectionProperty::IS_PUBLIC
+ \ReflectionProperty::IS_STATIC;
}
$properties = $reflection->getProperties($filter);
$parentProperties = [];
if ($includeParents) {
$parent = self::getParentClass($source);
if (false !== $parent) {
$parentClass = $parent->getName();
$parentProperties = self::getProperties($parentClass, $filter, $includeParents);
}
}
return array_merge($properties, $parentProperties);
} | php | public static function getProperties($source, $filter = null, $includeParents = false): array
{
$className = self::getClassName($source);
$reflection = new \ReflectionClass($className);
if (null === $filter) {
$filter = \ReflectionProperty::IS_PRIVATE
+ \ReflectionProperty::IS_PROTECTED
+ \ReflectionProperty::IS_PUBLIC
+ \ReflectionProperty::IS_STATIC;
}
$properties = $reflection->getProperties($filter);
$parentProperties = [];
if ($includeParents) {
$parent = self::getParentClass($source);
if (false !== $parent) {
$parentClass = $parent->getName();
$parentProperties = self::getProperties($parentClass, $filter, $includeParents);
}
}
return array_merge($properties, $parentProperties);
} | [
"public",
"static",
"function",
"getProperties",
"(",
"$",
"source",
",",
"$",
"filter",
"=",
"null",
",",
"$",
"includeParents",
"=",
"false",
")",
":",
"array",
"{",
"$",
"className",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"source",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"if",
"(",
"null",
"===",
"$",
"filter",
")",
"{",
"$",
"filter",
"=",
"\\",
"ReflectionProperty",
"::",
"IS_PRIVATE",
"+",
"\\",
"ReflectionProperty",
"::",
"IS_PROTECTED",
"+",
"\\",
"ReflectionProperty",
"::",
"IS_PUBLIC",
"+",
"\\",
"ReflectionProperty",
"::",
"IS_STATIC",
";",
"}",
"$",
"properties",
"=",
"$",
"reflection",
"->",
"getProperties",
"(",
"$",
"filter",
")",
";",
"$",
"parentProperties",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"includeParents",
")",
"{",
"$",
"parent",
"=",
"self",
"::",
"getParentClass",
"(",
"$",
"source",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"parent",
")",
"{",
"$",
"parentClass",
"=",
"$",
"parent",
"->",
"getName",
"(",
")",
";",
"$",
"parentProperties",
"=",
"self",
"::",
"getProperties",
"(",
"$",
"parentClass",
",",
"$",
"filter",
",",
"$",
"includeParents",
")",
";",
"}",
"}",
"return",
"array_merge",
"(",
"$",
"properties",
",",
"$",
"parentProperties",
")",
";",
"}"
] | Returns given object properties
@param array|object|string $source An array of objects, namespaces, object or namespace
@param int $filter (optional) Filter of properties. Uses \ReflectionProperty class
constants. By default all properties are returned.
@param bool $includeParents (optional) If is set to true, properties of parent classes are
included (recursively). Otherwise - not.
@return \ReflectionProperty[] | [
"Returns",
"given",
"object",
"properties"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L369-L394 |
36,485 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getParentClass | public static function getParentClass($source)
{
$className = self::getClassName($source);
$reflection = new \ReflectionClass($className);
return $reflection->getParentClass();
} | php | public static function getParentClass($source)
{
$className = self::getClassName($source);
$reflection = new \ReflectionClass($className);
return $reflection->getParentClass();
} | [
"public",
"static",
"function",
"getParentClass",
"(",
"$",
"source",
")",
"{",
"$",
"className",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"source",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"return",
"$",
"reflection",
"->",
"getParentClass",
"(",
")",
";",
"}"
] | Returns a parent class or false if there is no parent class
@param array|object|string $source An array of objects, namespaces, object or namespace
@return bool|\ReflectionClass | [
"Returns",
"a",
"parent",
"class",
"or",
"false",
"if",
"there",
"is",
"no",
"parent",
"class"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L402-L408 |
36,486 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getOneChildClass | public static function getOneChildClass($parentClass)
{
$childClasses = self::getChildClasses($parentClass);
/*
* No child classes?
* Oops, the base / parent class hasn't child class
*/
if (empty($childClasses)) {
throw MissingChildClassesException::create($parentClass);
}
/*
* More than 1 child class?
* Oops, the base / parent class has too many child classes
*/
if (count($childClasses) > 1) {
throw TooManyChildClassesException::create($parentClass, $childClasses);
}
return trim($childClasses[0]);
} | php | public static function getOneChildClass($parentClass)
{
$childClasses = self::getChildClasses($parentClass);
/*
* No child classes?
* Oops, the base / parent class hasn't child class
*/
if (empty($childClasses)) {
throw MissingChildClassesException::create($parentClass);
}
/*
* More than 1 child class?
* Oops, the base / parent class has too many child classes
*/
if (count($childClasses) > 1) {
throw TooManyChildClassesException::create($parentClass, $childClasses);
}
return trim($childClasses[0]);
} | [
"public",
"static",
"function",
"getOneChildClass",
"(",
"$",
"parentClass",
")",
"{",
"$",
"childClasses",
"=",
"self",
"::",
"getChildClasses",
"(",
"$",
"parentClass",
")",
";",
"/*\n * No child classes?\n * Oops, the base / parent class hasn't child class\n */",
"if",
"(",
"empty",
"(",
"$",
"childClasses",
")",
")",
"{",
"throw",
"MissingChildClassesException",
"::",
"create",
"(",
"$",
"parentClass",
")",
";",
"}",
"/*\n * More than 1 child class?\n * Oops, the base / parent class has too many child classes\n */",
"if",
"(",
"count",
"(",
"$",
"childClasses",
")",
">",
"1",
")",
"{",
"throw",
"TooManyChildClassesException",
"::",
"create",
"(",
"$",
"parentClass",
",",
"$",
"childClasses",
")",
";",
"}",
"return",
"trim",
"(",
"$",
"childClasses",
"[",
"0",
"]",
")",
";",
"}"
] | Returns namespace of one child class which extends given class.
Extended class should has only one child class.
@param array|object|string $parentClass Class who child class should be returned. An array of objects,
namespaces, object or namespace.
@throws MissingChildClassesException
@throws TooManyChildClassesException
@return mixed | [
"Returns",
"namespace",
"of",
"one",
"child",
"class",
"which",
"extends",
"given",
"class",
".",
"Extended",
"class",
"should",
"has",
"only",
"one",
"child",
"class",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L473-L494 |
36,487 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getProperty | public static function getProperty($class, $property, $filter = null)
{
$className = self::getClassName($class);
$properties = self::getProperties($className, $filter);
if (!empty($properties)) {
/** @var \ReflectionProperty $reflectionProperty */
foreach ($properties as $reflectionProperty) {
if ($reflectionProperty->getName() === $property) {
return $reflectionProperty;
}
}
}
return null;
} | php | public static function getProperty($class, $property, $filter = null)
{
$className = self::getClassName($class);
$properties = self::getProperties($className, $filter);
if (!empty($properties)) {
/** @var \ReflectionProperty $reflectionProperty */
foreach ($properties as $reflectionProperty) {
if ($reflectionProperty->getName() === $property) {
return $reflectionProperty;
}
}
}
return null;
} | [
"public",
"static",
"function",
"getProperty",
"(",
"$",
"class",
",",
"$",
"property",
",",
"$",
"filter",
"=",
"null",
")",
"{",
"$",
"className",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"class",
")",
";",
"$",
"properties",
"=",
"self",
"::",
"getProperties",
"(",
"$",
"className",
",",
"$",
"filter",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"properties",
")",
")",
"{",
"/** @var \\ReflectionProperty $reflectionProperty */",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"reflectionProperty",
")",
"{",
"if",
"(",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
"===",
"$",
"property",
")",
"{",
"return",
"$",
"reflectionProperty",
";",
"}",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns property, the \ReflectionProperty instance, of given object
@param array|object|string $class An array of objects, namespaces, object or namespace
@param string $property Name of the property
@param int $filter (optional) Filter of properties. Uses \ReflectionProperty class constants.
By default all properties are allowed / processed.
@return null|\ReflectionProperty | [
"Returns",
"property",
"the",
"\\",
"ReflectionProperty",
"instance",
"of",
"given",
"object"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L505-L520 |
36,488 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getParentClassName | public static function getParentClassName($class)
{
$className = self::getClassName($class);
$reflection = new \ReflectionClass($className);
$parentClass = $reflection->getParentClass();
if (null === $parentClass || false === $parentClass) {
return null;
}
return $parentClass->getName();
} | php | public static function getParentClassName($class)
{
$className = self::getClassName($class);
$reflection = new \ReflectionClass($className);
$parentClass = $reflection->getParentClass();
if (null === $parentClass || false === $parentClass) {
return null;
}
return $parentClass->getName();
} | [
"public",
"static",
"function",
"getParentClassName",
"(",
"$",
"class",
")",
"{",
"$",
"className",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"class",
")",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"parentClass",
"=",
"$",
"reflection",
"->",
"getParentClass",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"parentClass",
"||",
"false",
"===",
"$",
"parentClass",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"parentClass",
"->",
"getName",
"(",
")",
";",
"}"
] | Returns name of the parent class.
If given class does not extend another, returns null.
@param array|object|string $class An array of objects, namespaces, object or namespace
@return null|string | [
"Returns",
"name",
"of",
"the",
"parent",
"class",
".",
"If",
"given",
"class",
"does",
"not",
"extend",
"another",
"returns",
"null",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L570-L581 |
36,489 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.setPropertyValue | public static function setPropertyValue($object, $property, $value)
{
$reflectionProperty = self::getProperty($object, $property);
// Oops, property does not exist
if (null === $reflectionProperty) {
throw NotExistingPropertyException::create($object, $property);
}
$isPublic = $reflectionProperty->isPublic();
if (!$isPublic) {
$reflectionProperty->setAccessible(true);
}
$reflectionProperty->setValue($object, $value);
if (!$isPublic) {
$reflectionProperty->setAccessible(false);
}
} | php | public static function setPropertyValue($object, $property, $value)
{
$reflectionProperty = self::getProperty($object, $property);
// Oops, property does not exist
if (null === $reflectionProperty) {
throw NotExistingPropertyException::create($object, $property);
}
$isPublic = $reflectionProperty->isPublic();
if (!$isPublic) {
$reflectionProperty->setAccessible(true);
}
$reflectionProperty->setValue($object, $value);
if (!$isPublic) {
$reflectionProperty->setAccessible(false);
}
} | [
"public",
"static",
"function",
"setPropertyValue",
"(",
"$",
"object",
",",
"$",
"property",
",",
"$",
"value",
")",
"{",
"$",
"reflectionProperty",
"=",
"self",
"::",
"getProperty",
"(",
"$",
"object",
",",
"$",
"property",
")",
";",
"// Oops, property does not exist",
"if",
"(",
"null",
"===",
"$",
"reflectionProperty",
")",
"{",
"throw",
"NotExistingPropertyException",
"::",
"create",
"(",
"$",
"object",
",",
"$",
"property",
")",
";",
"}",
"$",
"isPublic",
"=",
"$",
"reflectionProperty",
"->",
"isPublic",
"(",
")",
";",
"if",
"(",
"!",
"$",
"isPublic",
")",
"{",
"$",
"reflectionProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"}",
"$",
"reflectionProperty",
"->",
"setValue",
"(",
"$",
"object",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"$",
"isPublic",
")",
"{",
"$",
"reflectionProperty",
"->",
"setAccessible",
"(",
"false",
")",
";",
"}",
"}"
] | Sets value of given property in given object
@param mixed $object Object that should contains given property
@param string $property Name of the property
@param mixed $value Value of the property
@throws NotExistingPropertyException | [
"Sets",
"value",
"of",
"given",
"property",
"in",
"given",
"object"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L591-L611 |
36,490 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.setPropertiesValues | public static function setPropertiesValues($object, array $propertiesValues)
{
/*
* No properties?
* Nothing to do
*/
if (empty($propertiesValues)) {
return;
}
foreach ($propertiesValues as $property => $value) {
static::setPropertyValue($object, $property, $value);
}
} | php | public static function setPropertiesValues($object, array $propertiesValues)
{
/*
* No properties?
* Nothing to do
*/
if (empty($propertiesValues)) {
return;
}
foreach ($propertiesValues as $property => $value) {
static::setPropertyValue($object, $property, $value);
}
} | [
"public",
"static",
"function",
"setPropertiesValues",
"(",
"$",
"object",
",",
"array",
"$",
"propertiesValues",
")",
"{",
"/*\n * No properties?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"propertiesValues",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"propertiesValues",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"static",
"::",
"setPropertyValue",
"(",
"$",
"object",
",",
"$",
"property",
",",
"$",
"value",
")",
";",
"}",
"}"
] | Sets values of properties in given object
@param mixed $object Object that should contains given property
@param array $propertiesValues Key-value pairs, where key - name of the property, value - value of the property | [
"Sets",
"values",
"of",
"properties",
"in",
"given",
"object"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L619-L632 |
36,491 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getPropertyValueByReflectionProperty | private static function getPropertyValueByReflectionProperty(
$object,
string $property,
?\ReflectionProperty $reflectionProperty = null
) {
$value = null;
$valueFound = false;
$className = self::getClassName($object);
try {
if (null === $reflectionProperty) {
$reflectionProperty = new \ReflectionProperty($className, $property);
}
$value = $reflectionProperty->getValue($object);
$valueFound = true;
} catch (\ReflectionException $exception) {
}
if (null !== $reflectionProperty) {
$reflectionProperty->setAccessible(true);
$value = $reflectionProperty->getValue($object);
$valueFound = true;
$reflectionProperty->setAccessible(false);
}
return [
$value,
$valueFound,
];
} | php | private static function getPropertyValueByReflectionProperty(
$object,
string $property,
?\ReflectionProperty $reflectionProperty = null
) {
$value = null;
$valueFound = false;
$className = self::getClassName($object);
try {
if (null === $reflectionProperty) {
$reflectionProperty = new \ReflectionProperty($className, $property);
}
$value = $reflectionProperty->getValue($object);
$valueFound = true;
} catch (\ReflectionException $exception) {
}
if (null !== $reflectionProperty) {
$reflectionProperty->setAccessible(true);
$value = $reflectionProperty->getValue($object);
$valueFound = true;
$reflectionProperty->setAccessible(false);
}
return [
$value,
$valueFound,
];
} | [
"private",
"static",
"function",
"getPropertyValueByReflectionProperty",
"(",
"$",
"object",
",",
"string",
"$",
"property",
",",
"?",
"\\",
"ReflectionProperty",
"$",
"reflectionProperty",
"=",
"null",
")",
"{",
"$",
"value",
"=",
"null",
";",
"$",
"valueFound",
"=",
"false",
";",
"$",
"className",
"=",
"self",
"::",
"getClassName",
"(",
"$",
"object",
")",
";",
"try",
"{",
"if",
"(",
"null",
"===",
"$",
"reflectionProperty",
")",
"{",
"$",
"reflectionProperty",
"=",
"new",
"\\",
"ReflectionProperty",
"(",
"$",
"className",
",",
"$",
"property",
")",
";",
"}",
"$",
"value",
"=",
"$",
"reflectionProperty",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"$",
"valueFound",
"=",
"true",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"exception",
")",
"{",
"}",
"if",
"(",
"null",
"!==",
"$",
"reflectionProperty",
")",
"{",
"$",
"reflectionProperty",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"value",
"=",
"$",
"reflectionProperty",
"->",
"getValue",
"(",
"$",
"object",
")",
";",
"$",
"valueFound",
"=",
"true",
";",
"$",
"reflectionProperty",
"->",
"setAccessible",
"(",
"false",
")",
";",
"}",
"return",
"[",
"$",
"value",
",",
"$",
"valueFound",
",",
"]",
";",
"}"
] | Returns value of given property using the property represented by reflection.
If value cannot be fetched, makes the property accessible temporarily.
@param mixed $object Object that should contains given property
@param string $property Name of the property that contains a value
@param null|\ReflectionProperty $reflectionProperty (optional) Property represented by reflection
@return mixed | [
"Returns",
"value",
"of",
"given",
"property",
"using",
"the",
"property",
"represented",
"by",
"reflection",
".",
"If",
"value",
"cannot",
"be",
"fetched",
"makes",
"the",
"property",
"accessible",
"temporarily",
"."
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L658-L690 |
36,492 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getPropertyValueByGetter | private static function getPropertyValueByGetter($source, string $property): array
{
$value = null;
$valueFound = false;
$reflectionObject = new \ReflectionObject($source);
$property = Inflector::classify($property);
$gettersPrefixes = [
'get',
'has',
'is',
];
foreach ($gettersPrefixes as $prefix) {
$getter = sprintf('%s%s', $prefix, $property);
if ($reflectionObject->hasMethod($getter)) {
$method = new \ReflectionMethod($source, $getter);
/*
* Getter is not accessible publicly?
* I have to skip it, to avoid an error like this:
*
* Call to protected method My\ExtraClass::getExtraProperty() from context 'My\ExtraClass'
*/
if ($method->isProtected() || $method->isPrivate()) {
continue;
}
$value = $source->{$getter}();
$valueFound = true;
break;
}
}
return [
$value,
$valueFound,
];
} | php | private static function getPropertyValueByGetter($source, string $property): array
{
$value = null;
$valueFound = false;
$reflectionObject = new \ReflectionObject($source);
$property = Inflector::classify($property);
$gettersPrefixes = [
'get',
'has',
'is',
];
foreach ($gettersPrefixes as $prefix) {
$getter = sprintf('%s%s', $prefix, $property);
if ($reflectionObject->hasMethod($getter)) {
$method = new \ReflectionMethod($source, $getter);
/*
* Getter is not accessible publicly?
* I have to skip it, to avoid an error like this:
*
* Call to protected method My\ExtraClass::getExtraProperty() from context 'My\ExtraClass'
*/
if ($method->isProtected() || $method->isPrivate()) {
continue;
}
$value = $source->{$getter}();
$valueFound = true;
break;
}
}
return [
$value,
$valueFound,
];
} | [
"private",
"static",
"function",
"getPropertyValueByGetter",
"(",
"$",
"source",
",",
"string",
"$",
"property",
")",
":",
"array",
"{",
"$",
"value",
"=",
"null",
";",
"$",
"valueFound",
"=",
"false",
";",
"$",
"reflectionObject",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"source",
")",
";",
"$",
"property",
"=",
"Inflector",
"::",
"classify",
"(",
"$",
"property",
")",
";",
"$",
"gettersPrefixes",
"=",
"[",
"'get'",
",",
"'has'",
",",
"'is'",
",",
"]",
";",
"foreach",
"(",
"$",
"gettersPrefixes",
"as",
"$",
"prefix",
")",
"{",
"$",
"getter",
"=",
"sprintf",
"(",
"'%s%s'",
",",
"$",
"prefix",
",",
"$",
"property",
")",
";",
"if",
"(",
"$",
"reflectionObject",
"->",
"hasMethod",
"(",
"$",
"getter",
")",
")",
"{",
"$",
"method",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"source",
",",
"$",
"getter",
")",
";",
"/*\n * Getter is not accessible publicly?\n * I have to skip it, to avoid an error like this:\n *\n * Call to protected method My\\ExtraClass::getExtraProperty() from context 'My\\ExtraClass'\n */",
"if",
"(",
"$",
"method",
"->",
"isProtected",
"(",
")",
"||",
"$",
"method",
"->",
"isPrivate",
"(",
")",
")",
"{",
"continue",
";",
"}",
"$",
"value",
"=",
"$",
"source",
"->",
"{",
"$",
"getter",
"}",
"(",
")",
";",
"$",
"valueFound",
"=",
"true",
";",
"break",
";",
"}",
"}",
"return",
"[",
"$",
"value",
",",
"$",
"valueFound",
",",
"]",
";",
"}"
] | Returns value of given property using getter of the property
An array with 2 elements is returned:
- value of given property
- information if the value was found (because null may be returned)
@param mixed $source Object that should contains given property
@param string $property Name of the property that contains a value
@return array | [
"Returns",
"value",
"of",
"given",
"property",
"using",
"getter",
"of",
"the",
"property"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L703-L744 |
36,493 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getPropertyValueByParentClasses | private static function getPropertyValueByParentClasses($source, string $property): array
{
$properties = self::getProperties($source, null, true);
if (empty($properties)) {
return [
null,
false,
];
}
foreach ($properties as $reflectionProperty) {
if ($reflectionProperty->getName() === $property) {
$byReflectionProperty = self::getPropertyValueByReflectionProperty(
$source,
$property,
$reflectionProperty
);
return [
$byReflectionProperty[0],
true,
];
}
}
return [
null,
false,
];
} | php | private static function getPropertyValueByParentClasses($source, string $property): array
{
$properties = self::getProperties($source, null, true);
if (empty($properties)) {
return [
null,
false,
];
}
foreach ($properties as $reflectionProperty) {
if ($reflectionProperty->getName() === $property) {
$byReflectionProperty = self::getPropertyValueByReflectionProperty(
$source,
$property,
$reflectionProperty
);
return [
$byReflectionProperty[0],
true,
];
}
}
return [
null,
false,
];
} | [
"private",
"static",
"function",
"getPropertyValueByParentClasses",
"(",
"$",
"source",
",",
"string",
"$",
"property",
")",
":",
"array",
"{",
"$",
"properties",
"=",
"self",
"::",
"getProperties",
"(",
"$",
"source",
",",
"null",
",",
"true",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"properties",
")",
")",
"{",
"return",
"[",
"null",
",",
"false",
",",
"]",
";",
"}",
"foreach",
"(",
"$",
"properties",
"as",
"$",
"reflectionProperty",
")",
"{",
"if",
"(",
"$",
"reflectionProperty",
"->",
"getName",
"(",
")",
"===",
"$",
"property",
")",
"{",
"$",
"byReflectionProperty",
"=",
"self",
"::",
"getPropertyValueByReflectionProperty",
"(",
"$",
"source",
",",
"$",
"property",
",",
"$",
"reflectionProperty",
")",
";",
"return",
"[",
"$",
"byReflectionProperty",
"[",
"0",
"]",
",",
"true",
",",
"]",
";",
"}",
"}",
"return",
"[",
"null",
",",
"false",
",",
"]",
";",
"}"
] | Returns value of given property using parent classes
@param mixed $source Object that should contains given property
@param string $property Name of the property that contains a value
@return array | [
"Returns",
"value",
"of",
"given",
"property",
"using",
"parent",
"classes"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L753-L783 |
36,494 | meritoo/common-library | src/Utilities/Reflection.php | Reflection.getPropertyValueByPropertiesChain | private static function getPropertyValueByPropertiesChain($source, $property, $force)
{
$exploded = explode('.', $property);
$property = $exploded[0];
$source = self::getPropertyValue($source, $property, $force);
/*
* Value of processed property from the chain is not null?
* Let's dig more and get proper value
*
* Required to avoid bug:
* \ReflectionObject::__construct() expects parameter 1 to be object, null given
* (...)
* 4. at \ReflectionObject->__construct (null)
* 5. at Reflection ::getPropertyValue (null, 'name', true)
* 6. at ListService->getItemValue (object(Deal), 'project.name', '0')
*
* while using "project.name" as property - $project has $name property ($project exists in the Deal class)
* and the $project equals null
*
* Meritoo <github@meritoo.pl>
* 2016-11-07
*/
if (null !== $source) {
unset($exploded[0]);
$property = implode('.', $exploded);
return self::getPropertyValue($source, $property, $force);
}
return null;
} | php | private static function getPropertyValueByPropertiesChain($source, $property, $force)
{
$exploded = explode('.', $property);
$property = $exploded[0];
$source = self::getPropertyValue($source, $property, $force);
/*
* Value of processed property from the chain is not null?
* Let's dig more and get proper value
*
* Required to avoid bug:
* \ReflectionObject::__construct() expects parameter 1 to be object, null given
* (...)
* 4. at \ReflectionObject->__construct (null)
* 5. at Reflection ::getPropertyValue (null, 'name', true)
* 6. at ListService->getItemValue (object(Deal), 'project.name', '0')
*
* while using "project.name" as property - $project has $name property ($project exists in the Deal class)
* and the $project equals null
*
* Meritoo <github@meritoo.pl>
* 2016-11-07
*/
if (null !== $source) {
unset($exploded[0]);
$property = implode('.', $exploded);
return self::getPropertyValue($source, $property, $force);
}
return null;
} | [
"private",
"static",
"function",
"getPropertyValueByPropertiesChain",
"(",
"$",
"source",
",",
"$",
"property",
",",
"$",
"force",
")",
"{",
"$",
"exploded",
"=",
"explode",
"(",
"'.'",
",",
"$",
"property",
")",
";",
"$",
"property",
"=",
"$",
"exploded",
"[",
"0",
"]",
";",
"$",
"source",
"=",
"self",
"::",
"getPropertyValue",
"(",
"$",
"source",
",",
"$",
"property",
",",
"$",
"force",
")",
";",
"/*\n * Value of processed property from the chain is not null?\n * Let's dig more and get proper value\n *\n * Required to avoid bug:\n * \\ReflectionObject::__construct() expects parameter 1 to be object, null given\n * (...)\n * 4. at \\ReflectionObject->__construct (null)\n * 5. at Reflection ::getPropertyValue (null, 'name', true)\n * 6. at ListService->getItemValue (object(Deal), 'project.name', '0')\n *\n * while using \"project.name\" as property - $project has $name property ($project exists in the Deal class)\n * and the $project equals null\n *\n * Meritoo <github@meritoo.pl>\n * 2016-11-07\n */",
"if",
"(",
"null",
"!==",
"$",
"source",
")",
"{",
"unset",
"(",
"$",
"exploded",
"[",
"0",
"]",
")",
";",
"$",
"property",
"=",
"implode",
"(",
"'.'",
",",
"$",
"exploded",
")",
";",
"return",
"self",
"::",
"getPropertyValue",
"(",
"$",
"source",
",",
"$",
"property",
",",
"$",
"force",
")",
";",
"}",
"return",
"null",
";",
"}"
] | Returns value of given property represented as chain of properties
@param mixed $source Object that should contains given property
@param string $property Dot-separated properties, e.g. "invoice.user.email"
@param bool $force (optional) If is set to true, try to retrieve value even if the object doesn't have
property. Otherwise - not.
@return mixed | [
"Returns",
"value",
"of",
"given",
"property",
"represented",
"as",
"chain",
"of",
"properties"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Reflection.php#L794-L826 |
36,495 | CeusMedia/Common | src/Alg/Math/ComplexNumber.php | Alg_Math_ComplexNumber.add | public function add( $complex )
{
$a = $this->getRealPart();
$b = $this->getImagePart();
$c = $complex->getRealPart();
$d = $complex->getImagePart();
$real = $a + $c;
$image = $b + $d;
return new ComplexNumber( $real, $image );
} | php | public function add( $complex )
{
$a = $this->getRealPart();
$b = $this->getImagePart();
$c = $complex->getRealPart();
$d = $complex->getImagePart();
$real = $a + $c;
$image = $b + $d;
return new ComplexNumber( $real, $image );
} | [
"public",
"function",
"add",
"(",
"$",
"complex",
")",
"{",
"$",
"a",
"=",
"$",
"this",
"->",
"getRealPart",
"(",
")",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"getImagePart",
"(",
")",
";",
"$",
"c",
"=",
"$",
"complex",
"->",
"getRealPart",
"(",
")",
";",
"$",
"d",
"=",
"$",
"complex",
"->",
"getImagePart",
"(",
")",
";",
"$",
"real",
"=",
"$",
"a",
"+",
"$",
"c",
";",
"$",
"image",
"=",
"$",
"b",
"+",
"$",
"d",
";",
"return",
"new",
"ComplexNumber",
"(",
"$",
"real",
",",
"$",
"image",
")",
";",
"}"
] | Addition of complex numbers.
@access public
@param ComplexNumber $complex Complex number to be added
@return ComplexNumber | [
"Addition",
"of",
"complex",
"numbers",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/ComplexNumber.php#L74-L83 |
36,496 | CeusMedia/Common | src/Alg/Math/ComplexNumber.php | Alg_Math_ComplexNumber.toString | public function toString()
{
$code = $this->getRealPart();
if( $this->image >= 0 )
$code .= "+".$this->getImagePart()."i";
else
$code .= "".$this->getImagePart()."i";
return $code;
} | php | public function toString()
{
$code = $this->getRealPart();
if( $this->image >= 0 )
$code .= "+".$this->getImagePart()."i";
else
$code .= "".$this->getImagePart()."i";
return $code;
} | [
"public",
"function",
"toString",
"(",
")",
"{",
"$",
"code",
"=",
"$",
"this",
"->",
"getRealPart",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"image",
">=",
"0",
")",
"$",
"code",
".=",
"\"+\"",
".",
"$",
"this",
"->",
"getImagePart",
"(",
")",
".",
"\"i\"",
";",
"else",
"$",
"code",
".=",
"\"\"",
".",
"$",
"this",
"->",
"getImagePart",
"(",
")",
".",
"\"i\"",
";",
"return",
"$",
"code",
";",
"}"
] | Returns the complex number as a representative string.
@access public
@return mixed | [
"Returns",
"the",
"complex",
"number",
"as",
"a",
"representative",
"string",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/ComplexNumber.php#L161-L169 |
36,497 | ncou/Chiron | src/Chiron/Routing/Resolver/ControllerResolver.php | ControllerResolver.resolve | public function resolve($toResolve): callable
{
$resolved = $toResolve;
if (! is_callable($toResolve) && is_string($toResolve)) {
$class = $toResolve;
$method = '__invoke';
// check for chiron callable as "class@method"
if (preg_match(static::PATTERN, $toResolve, $matches)) {
$class = $matches[1];
$method = $matches[2];
}
// check if the class is present un the container
if ($this->container instanceof ContainerInterface && $this->container->has($class)) {
$class = $this->container->get($class);
} else {
// if not present, try to instantitate it with the autoloader
if (! class_exists($class)) {
throw new \RuntimeException(sprintf('Callable "%s" does not exist', $class));
}
// do not instantiate the classe when you use the magic method for generic static methods.
// TODO : regarder si il est possible d'améliorer le code comme ca => https://github.com/middlewares/utils/blob/master/src/RequestHandlerContainer.php#L84
// TODO : ou comme ici => https://github.com/PHP-DI/Invoker/blob/master/src/CallableResolver.php#L122
if (! method_exists($class, '__callStatic')) {
$class = new $class();
}
}
// For a class that implements RequestHandlerInterface, we will call the handle() method.
if ($class instanceof RequestHandlerInterface) {
$method = 'handle';
}
$resolved = [$class, $method];
}
if (! is_callable($resolved)) {
throw new \InvalidArgumentException(sprintf(
'(%s) is not resolvable.',
is_array($toResolve) || is_object($toResolve) || is_null($toResolve) ? json_encode($toResolve) : $toResolve
));
}
return $resolved;
} | php | public function resolve($toResolve): callable
{
$resolved = $toResolve;
if (! is_callable($toResolve) && is_string($toResolve)) {
$class = $toResolve;
$method = '__invoke';
// check for chiron callable as "class@method"
if (preg_match(static::PATTERN, $toResolve, $matches)) {
$class = $matches[1];
$method = $matches[2];
}
// check if the class is present un the container
if ($this->container instanceof ContainerInterface && $this->container->has($class)) {
$class = $this->container->get($class);
} else {
// if not present, try to instantitate it with the autoloader
if (! class_exists($class)) {
throw new \RuntimeException(sprintf('Callable "%s" does not exist', $class));
}
// do not instantiate the classe when you use the magic method for generic static methods.
// TODO : regarder si il est possible d'améliorer le code comme ca => https://github.com/middlewares/utils/blob/master/src/RequestHandlerContainer.php#L84
// TODO : ou comme ici => https://github.com/PHP-DI/Invoker/blob/master/src/CallableResolver.php#L122
if (! method_exists($class, '__callStatic')) {
$class = new $class();
}
}
// For a class that implements RequestHandlerInterface, we will call the handle() method.
if ($class instanceof RequestHandlerInterface) {
$method = 'handle';
}
$resolved = [$class, $method];
}
if (! is_callable($resolved)) {
throw new \InvalidArgumentException(sprintf(
'(%s) is not resolvable.',
is_array($toResolve) || is_object($toResolve) || is_null($toResolve) ? json_encode($toResolve) : $toResolve
));
}
return $resolved;
} | [
"public",
"function",
"resolve",
"(",
"$",
"toResolve",
")",
":",
"callable",
"{",
"$",
"resolved",
"=",
"$",
"toResolve",
";",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"toResolve",
")",
"&&",
"is_string",
"(",
"$",
"toResolve",
")",
")",
"{",
"$",
"class",
"=",
"$",
"toResolve",
";",
"$",
"method",
"=",
"'__invoke'",
";",
"// check for chiron callable as \"class@method\"",
"if",
"(",
"preg_match",
"(",
"static",
"::",
"PATTERN",
",",
"$",
"toResolve",
",",
"$",
"matches",
")",
")",
"{",
"$",
"class",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"method",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"// check if the class is present un the container",
"if",
"(",
"$",
"this",
"->",
"container",
"instanceof",
"ContainerInterface",
"&&",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"class",
")",
";",
"}",
"else",
"{",
"// if not present, try to instantitate it with the autoloader",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'Callable \"%s\" does not exist'",
",",
"$",
"class",
")",
")",
";",
"}",
"// do not instantiate the classe when you use the magic method for generic static methods.",
"// TODO : regarder si il est possible d'améliorer le code comme ca => https://github.com/middlewares/utils/blob/master/src/RequestHandlerContainer.php#L84",
"// TODO : ou comme ici => https://github.com/PHP-DI/Invoker/blob/master/src/CallableResolver.php#L122",
"if",
"(",
"!",
"method_exists",
"(",
"$",
"class",
",",
"'__callStatic'",
")",
")",
"{",
"$",
"class",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"}",
"// For a class that implements RequestHandlerInterface, we will call the handle() method.",
"if",
"(",
"$",
"class",
"instanceof",
"RequestHandlerInterface",
")",
"{",
"$",
"method",
"=",
"'handle'",
";",
"}",
"$",
"resolved",
"=",
"[",
"$",
"class",
",",
"$",
"method",
"]",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"resolved",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'(%s) is not resolvable.'",
",",
"is_array",
"(",
"$",
"toResolve",
")",
"||",
"is_object",
"(",
"$",
"toResolve",
")",
"||",
"is_null",
"(",
"$",
"toResolve",
")",
"?",
"json_encode",
"(",
"$",
"toResolve",
")",
":",
"$",
"toResolve",
")",
")",
";",
"}",
"return",
"$",
"resolved",
";",
"}"
] | Resolve toResolve into a callable that that the router can dispatch.
If toResolve is of the format 'class@method', then try to extract 'class'
from the container otherwise instantiate it and then dispatch 'method'.
@param callable|string $toResolve
@throws \RuntimeException if the callable does not exist
@throws \InvalidArgumentException if the callable is not resolvable
@return callable | [
"Resolve",
"toResolve",
"into",
"a",
"callable",
"that",
"that",
"the",
"router",
"can",
"dispatch",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Resolver/ControllerResolver.php#L61-L106 |
36,498 | CeusMedia/Common | src/Net/Site/Crawler.php | Net_Site_Crawler.buildUrl | protected function buildUrl( $parts )
{
$url = new ADT_StringBuffer();
if( isset( $parts['user'] ) && isset( $parts['pass'] ) && $parts['user'] )
$url->append( $parts['user'].":".$parts['pass']."@" );
if( substr( $parts['path'], 0, 1 ) != "/" )
$parts['path'] = "/".$parts['path'];
$host = $parts['host'].( !empty( $parts['port'] ) ? ":".$parts['port'] : "" );
$url->append( $host.$parts['path'] );
if( isset( $parts['query'] ) )
$url->append( "?".$parts['query'] );
$url = str_replace( "//", "/", $url->toString() );
$url = $parts['scheme']."://".$url;
return $url;
} | php | protected function buildUrl( $parts )
{
$url = new ADT_StringBuffer();
if( isset( $parts['user'] ) && isset( $parts['pass'] ) && $parts['user'] )
$url->append( $parts['user'].":".$parts['pass']."@" );
if( substr( $parts['path'], 0, 1 ) != "/" )
$parts['path'] = "/".$parts['path'];
$host = $parts['host'].( !empty( $parts['port'] ) ? ":".$parts['port'] : "" );
$url->append( $host.$parts['path'] );
if( isset( $parts['query'] ) )
$url->append( "?".$parts['query'] );
$url = str_replace( "//", "/", $url->toString() );
$url = $parts['scheme']."://".$url;
return $url;
} | [
"protected",
"function",
"buildUrl",
"(",
"$",
"parts",
")",
"{",
"$",
"url",
"=",
"new",
"ADT_StringBuffer",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'user'",
"]",
")",
"&&",
"isset",
"(",
"$",
"parts",
"[",
"'pass'",
"]",
")",
"&&",
"$",
"parts",
"[",
"'user'",
"]",
")",
"$",
"url",
"->",
"append",
"(",
"$",
"parts",
"[",
"'user'",
"]",
".",
"\":\"",
".",
"$",
"parts",
"[",
"'pass'",
"]",
".",
"\"@\"",
")",
";",
"if",
"(",
"substr",
"(",
"$",
"parts",
"[",
"'path'",
"]",
",",
"0",
",",
"1",
")",
"!=",
"\"/\"",
")",
"$",
"parts",
"[",
"'path'",
"]",
"=",
"\"/\"",
".",
"$",
"parts",
"[",
"'path'",
"]",
";",
"$",
"host",
"=",
"$",
"parts",
"[",
"'host'",
"]",
".",
"(",
"!",
"empty",
"(",
"$",
"parts",
"[",
"'port'",
"]",
")",
"?",
"\":\"",
".",
"$",
"parts",
"[",
"'port'",
"]",
":",
"\"\"",
")",
";",
"$",
"url",
"->",
"append",
"(",
"$",
"host",
".",
"$",
"parts",
"[",
"'path'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"parts",
"[",
"'query'",
"]",
")",
")",
"$",
"url",
"->",
"append",
"(",
"\"?\"",
".",
"$",
"parts",
"[",
"'query'",
"]",
")",
";",
"$",
"url",
"=",
"str_replace",
"(",
"\"//\"",
",",
"\"/\"",
",",
"$",
"url",
"->",
"toString",
"(",
")",
")",
";",
"$",
"url",
"=",
"$",
"parts",
"[",
"'scheme'",
"]",
".",
"\"://\"",
".",
"$",
"url",
";",
"return",
"$",
"url",
";",
"}"
] | Builds URL from Parts.
@access protected
@param array $parts Parts of URL
@return string | [
"Builds",
"URL",
"from",
"Parts",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/Crawler.php#L103-L117 |
36,499 | CeusMedia/Common | src/Net/Site/Crawler.php | Net_Site_Crawler.getDocument | protected function getDocument( $content, $url )
{
$doc = new DOMDocument();
ob_start();
if( !@$doc->loadHTML( $content ) )
{
$content = ob_get_clean();
if( $content )
$this->errors[$url] = $content;
throw new RuntimeException( 'Error reading HTML.' );
}
ob_end_clean();
return $doc;
} | php | protected function getDocument( $content, $url )
{
$doc = new DOMDocument();
ob_start();
if( !@$doc->loadHTML( $content ) )
{
$content = ob_get_clean();
if( $content )
$this->errors[$url] = $content;
throw new RuntimeException( 'Error reading HTML.' );
}
ob_end_clean();
return $doc;
} | [
"protected",
"function",
"getDocument",
"(",
"$",
"content",
",",
"$",
"url",
")",
"{",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"ob_start",
"(",
")",
";",
"if",
"(",
"!",
"@",
"$",
"doc",
"->",
"loadHTML",
"(",
"$",
"content",
")",
")",
"{",
"$",
"content",
"=",
"ob_get_clean",
"(",
")",
";",
"if",
"(",
"$",
"content",
")",
"$",
"this",
"->",
"errors",
"[",
"$",
"url",
"]",
"=",
"$",
"content",
";",
"throw",
"new",
"RuntimeException",
"(",
"'Error reading HTML.'",
")",
";",
"}",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"doc",
";",
"}"
] | Tries to get DOM Document from HTML Content or logs Errors and throws Exception.
@access public
@param string $content HTML Content
@param string $url URL of HTML Page
@return DOMDocument | [
"Tries",
"to",
"get",
"DOM",
"Document",
"from",
"HTML",
"Content",
"or",
"logs",
"Errors",
"and",
"throws",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/Crawler.php#L224-L237 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.