repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
CeusMedia/Common
src/XML/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", "(", "$", ...
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
train
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", ...
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
train
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...
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
train
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"...
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
train
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", "*...
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
train
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", "-", "...
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
train
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", ";", "$", ...
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
train
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", "...
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
train
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
train
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", "-",...
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
train
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", ",...
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
train
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", ",", "$", ...
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
train
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", ";", "$...
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
train
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", ...
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
train
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...
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
train
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....
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
train
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", "(",...
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
train
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"...
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
train
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", "&&", "i...
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
train
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", ...
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
train
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", "(",...
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
train
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", ")", "{", "i...
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
train
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", "(", ")", "....
region Easy Logging
[ "region", "Easy", "Logging" ]
bed046766524bc046cb24251145831de1ed8d681
https://github.com/danielmaier42/Magento2-ConsoleUtility/blob/bed046766524bc046cb24251145831de1ed8d681/Console/Output.php#L225-L229
train
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
train
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.ceus...
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
train
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", "(", "$", "co...
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
train
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", "(", ")", ",", "'c...
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
train
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", ...
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
train
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
train
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", ")",...
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
train
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", ",...
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
train
CeusMedia/Common
src/UI/HTML/Indicator.php
UI_HTML_Indicator.renderPercentage
protected function renderPercentage( $ratio ) { if( !$this->getOption( 'usePercentage' ) ) return ""; $value = floor( $ratio * 100 )."&nbsp;%"; $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 )."&nbsp;%"; $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", ")", ".", "\...
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
train
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", ".", "\"/\"", ".", "$", "...
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
train
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 \"'", ".", "$",...
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
train
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 : "&nbsp;"; $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 : "&nbsp;"; $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", "...
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
train
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 : "&nbsp;"; $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 : "&nbsp;"; $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", ...
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
train
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", ...
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
train
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...
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
train
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", ",", ...
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
train
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", "::", "g...
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
train
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", ")", ")", "{", ...
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
train
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", ")", "|...
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
train
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...
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
train
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", ...
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
train
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", ")", ";", "...
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
train
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", ")", ";", "r...
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
train
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\...
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
train
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", "::", ...
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
train
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", ")", ";", ...
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
train
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 doe...
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
train
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",...
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
train
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"...
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
train
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", "\\", "Refle...
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
train
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", ")", ";", "...
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
train
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",...
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
train
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", "(", ...
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
train
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", "(", ")...
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
train
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", ")", ")", "{", "$", "...
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
train
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'", "]", ")", ...
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
train
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", ")", ...
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
train
CeusMedia/Common
src/Net/Site/Crawler.php
Net_Site_Crawler.getHTML
protected function getHTML( $url ) { $this->reader->setUrl( $url ); try { $content = $this->reader->read( array( 'CURLOPT_FOLLOWLOCATION' => TRUE, 'CURLOPT_COOKIEJAR' => 'cookies.txt', 'CURLOPT_COOKIEFILE' => 'cookies.txt' ) ); $contentType = $this->reader->getInfo( 'content_type' ); return $contentType === 'text/html' ? $content : ''; } catch( RuntimeException $e ) { $this->errors[$url] = $e->getMessage(); throw $e; } }
php
protected function getHTML( $url ) { $this->reader->setUrl( $url ); try { $content = $this->reader->read( array( 'CURLOPT_FOLLOWLOCATION' => TRUE, 'CURLOPT_COOKIEJAR' => 'cookies.txt', 'CURLOPT_COOKIEFILE' => 'cookies.txt' ) ); $contentType = $this->reader->getInfo( 'content_type' ); return $contentType === 'text/html' ? $content : ''; } catch( RuntimeException $e ) { $this->errors[$url] = $e->getMessage(); throw $e; } }
[ "protected", "function", "getHTML", "(", "$", "url", ")", "{", "$", "this", "->", "reader", "->", "setUrl", "(", "$", "url", ")", ";", "try", "{", "$", "content", "=", "$", "this", "->", "reader", "->", "read", "(", "array", "(", "'CURLOPT_FOLLOWLOCA...
Reads HTML Page and returns Content or logs Errors and throws Exception. @access public @param string $url URL to get Content for @return string
[ "Reads", "HTML", "Page", "and", "returns", "Content", "or", "logs", "Errors", "and", "throws", "Exception", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/Crawler.php#L255-L273
train
CeusMedia/Common
src/Net/Site/Crawler.php
Net_Site_Crawler.getLinksFromDocument
protected function getLinksFromDocument( $document, $onlyWithLabel = FALSE ) { $baseUrl = $this->getBaseUrl( $document ); $links = array(); $nodes = $document->getElementsByTagName( "a" ); foreach( $nodes as $node ) { $ref = $node->getAttribute( 'href' ); $ref = trim( preg_replace( "@^\./@", "", $ref ) ); if( strlen( $ref ) ){ $base = $document->getElementsByTagName( "base" ); // remark( $ref ); if( preg_match( "@^(#|mailto:|javascript:)@", $ref ) ) continue; if( $base->length && preg_match( "@^\.\./@", $ref ) ) continue; if( preg_match( "@^\.?/@", $ref ) ) $ref = $baseUrl.$ref; else if( preg_match( "@^\./@", $ref ) ) $ref = preg_replace( "@^\./@", "", $ref ); if( !preg_match( "@^https?://@", $ref ) ) $ref = $baseUrl.$ref; $label = trim( strip_tags( $node->nodeValue ) ); if( $node->hasAttribute( 'title' ) ) $label = trim( strip_tags( $node->getAttribute( 'title' ) ) ); if( $onlyWithLabel && !strlen( $label ) ) continue; $links[$ref] = $label; } } return $links; }
php
protected function getLinksFromDocument( $document, $onlyWithLabel = FALSE ) { $baseUrl = $this->getBaseUrl( $document ); $links = array(); $nodes = $document->getElementsByTagName( "a" ); foreach( $nodes as $node ) { $ref = $node->getAttribute( 'href' ); $ref = trim( preg_replace( "@^\./@", "", $ref ) ); if( strlen( $ref ) ){ $base = $document->getElementsByTagName( "base" ); // remark( $ref ); if( preg_match( "@^(#|mailto:|javascript:)@", $ref ) ) continue; if( $base->length && preg_match( "@^\.\./@", $ref ) ) continue; if( preg_match( "@^\.?/@", $ref ) ) $ref = $baseUrl.$ref; else if( preg_match( "@^\./@", $ref ) ) $ref = preg_replace( "@^\./@", "", $ref ); if( !preg_match( "@^https?://@", $ref ) ) $ref = $baseUrl.$ref; $label = trim( strip_tags( $node->nodeValue ) ); if( $node->hasAttribute( 'title' ) ) $label = trim( strip_tags( $node->getAttribute( 'title' ) ) ); if( $onlyWithLabel && !strlen( $label ) ) continue; $links[$ref] = $label; } } return $links; }
[ "protected", "function", "getLinksFromDocument", "(", "$", "document", ",", "$", "onlyWithLabel", "=", "FALSE", ")", "{", "$", "baseUrl", "=", "$", "this", "->", "getBaseUrl", "(", "$", "document", ")", ";", "$", "links", "=", "array", "(", ")", ";", "...
Parses a HTML Document and returns extracted Link URLs. @access protected @param DOMDocument $document DOM Document of HTML Content @param boolean $onlyWithLabel Flag: note only links with label @return array
[ "Parses", "a", "HTML", "Document", "and", "returns", "extracted", "Link", "URLs", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Site/Crawler.php#L294-L325
train
CeusMedia/Common
src/Alg/Math/Analysis/Sequence.php
Alg_Math_Analysis_Sequence.isConvergent
public function isConvergent() { for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++) { $diff = abs ($this->getValue ($i+1) - $this->getValue ($i)); if (!$old_diff) $old_diff = $diff; else { if ($diff >= $old_diff) return false; } } return true; }
php
public function isConvergent() { for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++) { $diff = abs ($this->getValue ($i+1) - $this->getValue ($i)); if (!$old_diff) $old_diff = $diff; else { if ($diff >= $old_diff) return false; } } return true; }
[ "public", "function", "isConvergent", "(", ")", "{", "for", "(", "$", "i", "=", "$", "this", "->", "interval", "->", "getStart", "(", ")", ";", "$", "i", "<", "$", "this", "->", "interval", "->", "getEnd", "(", ")", ";", "$", "i", "++", ")", "{...
Indicates whether this Sequence is convergent. @access public @return bool
[ "Indicates", "whether", "this", "Sequence", "is", "convergent", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Sequence.php#L92-L105
train
CeusMedia/Common
src/Alg/Math/Analysis/Sequence.php
Alg_Math_Analysis_Sequence.toArray
public function toArray() { $array = array (); for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++) { $value = $this->getValue ($i); $array [$i] = $value; } return $array; }
php
public function toArray() { $array = array (); for ($i=$this->interval->getStart(); $i<$this->interval->getEnd(); $i++) { $value = $this->getValue ($i); $array [$i] = $value; } return $array; }
[ "public", "function", "toArray", "(", ")", "{", "$", "array", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "$", "this", "->", "interval", "->", "getStart", "(", ")", ";", "$", "i", "<", "$", "this", "->", "interval", "->", "getEnd", ...
Returns Sequence as Array. @access public @return array
[ "Returns", "Sequence", "as", "Array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Analysis/Sequence.php#L122-L131
train
CeusMedia/Common
src/XML/DOM/ObjectDeserializer.php
XML_DOM_ObjectDeserializer.deserialize
public static function deserialize( $xml, $strict = TRUE ) { $parser = new XML_DOM_Parser(); $tree = $parser->parse( $xml ); $class = $tree->getAttribute( 'class' ); if( !class_exists( $class ) ) throw new Exception( 'Class "'.$class.'" has not been loaded, yet.' ); $object = new $class(); self::deserializeVarsRec( $tree->getChildren(), $object ); return $object; }
php
public static function deserialize( $xml, $strict = TRUE ) { $parser = new XML_DOM_Parser(); $tree = $parser->parse( $xml ); $class = $tree->getAttribute( 'class' ); if( !class_exists( $class ) ) throw new Exception( 'Class "'.$class.'" has not been loaded, yet.' ); $object = new $class(); self::deserializeVarsRec( $tree->getChildren(), $object ); return $object; }
[ "public", "static", "function", "deserialize", "(", "$", "xml", ",", "$", "strict", "=", "TRUE", ")", "{", "$", "parser", "=", "new", "XML_DOM_Parser", "(", ")", ";", "$", "tree", "=", "$", "parser", "->", "parse", "(", "$", "xml", ")", ";", "$", ...
Builds Object from XML of a serialized Object. @access public @param string $xml XML String of a serialized Object @return mixed
[ "Builds", "Object", "from", "XML", "of", "a", "serialized", "Object", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectDeserializer.php#L50-L60
train
CeusMedia/Common
src/XML/DOM/ObjectDeserializer.php
XML_DOM_ObjectDeserializer.deserializeVarsRec
protected static function deserializeVarsRec( $children, &$element ) { foreach( $children as $child ) { $name = $child->getAttribute( 'name' ); $vartype = $child->getNodeName(); if( is_object( $element ) ) { if( !isset( $element->$name ) ) $element->$name = NULL; $pointer =& $element->$name; } else { if( !isset( $element->$name ) ) $element[$name] = NULL; $pointer =& $element[$name]; } switch( $vartype ) { case 'boolean': $pointer = (bool) $child->getContent(); break; case 'string': $pointer = utf8_decode( $child->getContent() ); break; case 'integer': $pointer = (int) $child->getContent(); break; case 'double': $pointer = (double) $child->getContent(); break; case 'array': $pointer = array(); self::deserializeVarsRec( $child->getChildren(), $pointer ); break; case 'object': $class = $child->getAttribute( 'class' ); $pointer = new $class(); self::deserializeVarsRec( $child->getChildren(), $pointer ); break; default: $pointer = NULL; break; } } }
php
protected static function deserializeVarsRec( $children, &$element ) { foreach( $children as $child ) { $name = $child->getAttribute( 'name' ); $vartype = $child->getNodeName(); if( is_object( $element ) ) { if( !isset( $element->$name ) ) $element->$name = NULL; $pointer =& $element->$name; } else { if( !isset( $element->$name ) ) $element[$name] = NULL; $pointer =& $element[$name]; } switch( $vartype ) { case 'boolean': $pointer = (bool) $child->getContent(); break; case 'string': $pointer = utf8_decode( $child->getContent() ); break; case 'integer': $pointer = (int) $child->getContent(); break; case 'double': $pointer = (double) $child->getContent(); break; case 'array': $pointer = array(); self::deserializeVarsRec( $child->getChildren(), $pointer ); break; case 'object': $class = $child->getAttribute( 'class' ); $pointer = new $class(); self::deserializeVarsRec( $child->getChildren(), $pointer ); break; default: $pointer = NULL; break; } } }
[ "protected", "static", "function", "deserializeVarsRec", "(", "$", "children", ",", "&", "$", "element", ")", "{", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "name", "=", "$", "child", "->", "getAttribute", "(", "'name'", ")", ...
Adds nested Vars to an Element by their Type while supporting nested Arrays. @access protected @param array $children Array of Vars to add @param mixed $element current Position in Object @return string
[ "Adds", "nested", "Vars", "to", "an", "Element", "by", "their", "Type", "while", "supporting", "nested", "Arrays", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/ObjectDeserializer.php#L69-L116
train
CeusMedia/Common
src/XML/DOM/FileEditor.php
XML_DOM_FileEditor.addNode
public function addNode( $nodePath, $name, $content = "", $attributes = array() ) { $branch = $this->getNode( $nodePath ); $node = new XML_DOM_Node( $name, $content, $attributes ); $branch->addChild( $node ); return (bool) $this->write(); }
php
public function addNode( $nodePath, $name, $content = "", $attributes = array() ) { $branch = $this->getNode( $nodePath ); $node = new XML_DOM_Node( $name, $content, $attributes ); $branch->addChild( $node ); return (bool) $this->write(); }
[ "public", "function", "addNode", "(", "$", "nodePath", ",", "$", "name", ",", "$", "content", "=", "\"\"", ",", "$", "attributes", "=", "array", "(", ")", ")", "{", "$", "branch", "=", "$", "this", "->", "getNode", "(", "$", "nodePath", ")", ";", ...
Adds a new Node Attribute to an existing Node. @access public @param string $nodePath Path to existring Node in XML Tree @param string $name Name of new Node @param string $content Cotnent of new Node @param array $attributes Array of Attribute of new Content @return bool
[ "Adds", "a", "new", "Node", "Attribute", "to", "an", "existing", "Node", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L71-L77
train
CeusMedia/Common
src/XML/DOM/FileEditor.php
XML_DOM_FileEditor.editNodeAttribute
public function editNodeAttribute( $nodePath, $key, $value ) { $node = $this->getNode( $nodePath ); if( $node->setAttribute( $key, $value ) ) return (bool) $this->write(); return FALSE; }
php
public function editNodeAttribute( $nodePath, $key, $value ) { $node = $this->getNode( $nodePath ); if( $node->setAttribute( $key, $value ) ) return (bool) $this->write(); return FALSE; }
[ "public", "function", "editNodeAttribute", "(", "$", "nodePath", ",", "$", "key", ",", "$", "value", ")", "{", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "nodePath", ")", ";", "if", "(", "$", "node", "->", "setAttribute", "(", "$", "...
Modifies a Node Attribute by its Path and Attribute Key. @access public @param string $nodePath Path to Node in XML Tree @param string $key Attribute Key @return bool
[ "Modifies", "a", "Node", "Attribute", "by", "its", "Path", "and", "Attribute", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L86-L92
train
CeusMedia/Common
src/XML/DOM/FileEditor.php
XML_DOM_FileEditor.editNodeContent
public function editNodeContent( $nodePath, $content ) { $node = $this->getNode( $nodePath ); if( $node->setContent( $content ) ) return (bool) $this->write(); return FALSE; }
php
public function editNodeContent( $nodePath, $content ) { $node = $this->getNode( $nodePath ); if( $node->setContent( $content ) ) return (bool) $this->write(); return FALSE; }
[ "public", "function", "editNodeContent", "(", "$", "nodePath", ",", "$", "content", ")", "{", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "nodePath", ")", ";", "if", "(", "$", "node", "->", "setContent", "(", "$", "content", ")", ")", ...
Modifies a Node Content by its Path. @access public @param string $nodePath Path to Node in XML Tree @param string $content Content to set to Node @return bool
[ "Modifies", "a", "Node", "Content", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L101-L107
train
CeusMedia/Common
src/XML/DOM/FileEditor.php
XML_DOM_FileEditor.getNode
protected function getNode( $nodePath ) { $pathNodes = explode( "/", $nodePath ); $xmlNode =& $this->xmlTree; while( $pathNodes ) { $pathNode = trim( array_shift( $pathNodes ) ); $matches = array(); if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $pathNode, $matches ) ) { $pathNode = $matches[1][0]; $itemNumber = $matches[2][0]; $nodes = $xmlNode->getChildren( $pathNode ); if( !isset( $nodes[$itemNumber] ) ) throw new InvalidArgumentException( 'Node not existing.' ); $xmlNode =& $nodes[$itemNumber]; continue; } $xmlNode =& $xmlNode->getChild( $pathNode ); continue; } return $xmlNode; }
php
protected function getNode( $nodePath ) { $pathNodes = explode( "/", $nodePath ); $xmlNode =& $this->xmlTree; while( $pathNodes ) { $pathNode = trim( array_shift( $pathNodes ) ); $matches = array(); if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $pathNode, $matches ) ) { $pathNode = $matches[1][0]; $itemNumber = $matches[2][0]; $nodes = $xmlNode->getChildren( $pathNode ); if( !isset( $nodes[$itemNumber] ) ) throw new InvalidArgumentException( 'Node not existing.' ); $xmlNode =& $nodes[$itemNumber]; continue; } $xmlNode =& $xmlNode->getChild( $pathNode ); continue; } return $xmlNode; }
[ "protected", "function", "getNode", "(", "$", "nodePath", ")", "{", "$", "pathNodes", "=", "explode", "(", "\"/\"", ",", "$", "nodePath", ")", ";", "$", "xmlNode", "=", "&", "$", "this", "->", "xmlTree", ";", "while", "(", "$", "pathNodes", ")", "{",...
Returns Node Object for a Node Path. @access public @param string $nodePath Path to Node in XML Tree @return bool
[ "Returns", "Node", "Object", "for", "a", "Node", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L115-L137
train
CeusMedia/Common
src/XML/DOM/FileEditor.php
XML_DOM_FileEditor.removeNode
public function removeNode( $nodePath ) { $pathNodes = explode( "/", $nodePath ); $nodeName = array_pop( $pathNodes ); $nodePath = implode( "/", $pathNodes ); $nodeNumber = 0; $branch = $this->getNode( $nodePath ); if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $nodeName, $matches ) ) { $nodeName = $matches[1][0]; $nodeNumber = $matches[2][0]; } $nodes =& $branch->getChildren(); $index = -1; for( $i=0; $i<count( $nodes ); $i++ ) { if( !$nodeName || $nodes[$i]->getNodeName() == $nodeName ) { $index++; if( $index != $nodeNumber ) continue; unset( $nodes[$i] ); return (bool) $this->write(); } } throw new InvalidArgumentException( 'Node not found.' ); }
php
public function removeNode( $nodePath ) { $pathNodes = explode( "/", $nodePath ); $nodeName = array_pop( $pathNodes ); $nodePath = implode( "/", $pathNodes ); $nodeNumber = 0; $branch = $this->getNode( $nodePath ); if( preg_match_all( "@^(.*)\[([0-9]+)\]$@", $nodeName, $matches ) ) { $nodeName = $matches[1][0]; $nodeNumber = $matches[2][0]; } $nodes =& $branch->getChildren(); $index = -1; for( $i=0; $i<count( $nodes ); $i++ ) { if( !$nodeName || $nodes[$i]->getNodeName() == $nodeName ) { $index++; if( $index != $nodeNumber ) continue; unset( $nodes[$i] ); return (bool) $this->write(); } } throw new InvalidArgumentException( 'Node not found.' ); }
[ "public", "function", "removeNode", "(", "$", "nodePath", ")", "{", "$", "pathNodes", "=", "explode", "(", "\"/\"", ",", "$", "nodePath", ")", ";", "$", "nodeName", "=", "array_pop", "(", "$", "pathNodes", ")", ";", "$", "nodePath", "=", "implode", "("...
Removes a Node by its Path. @access public @param string $nodePath Path to Node in XML Tree @return bool
[ "Removes", "a", "Node", "by", "its", "Path", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L145-L171
train
CeusMedia/Common
src/XML/DOM/FileEditor.php
XML_DOM_FileEditor.removeNodeAttribute
public function removeNodeAttribute( $nodePath, $key ) { $node = $this->getNode( $nodePath ); if( $node->removeAttribute( $key ) ) return (bool) $this->write(); return FALSE; }
php
public function removeNodeAttribute( $nodePath, $key ) { $node = $this->getNode( $nodePath ); if( $node->removeAttribute( $key ) ) return (bool) $this->write(); return FALSE; }
[ "public", "function", "removeNodeAttribute", "(", "$", "nodePath", ",", "$", "key", ")", "{", "$", "node", "=", "$", "this", "->", "getNode", "(", "$", "nodePath", ")", ";", "if", "(", "$", "node", "->", "removeAttribute", "(", "$", "key", ")", ")", ...
Removes a Node Attribute by its Path and Attribute Key. @access public @param string $nodePath Path to Node in XML Tree @param string $key Attribute Key @return bool
[ "Removes", "a", "Node", "Attribute", "by", "its", "Path", "and", "Attribute", "Key", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/FileEditor.php#L180-L186
train
fxpio/fxp-resource-bundle
DependencyInjection/Compiler/DomainPass.php
DomainPass.getResolveTargets
private function getResolveTargets(ContainerBuilder $container) { if (null === $this->resolveTargets) { $this->resolveTargets = []; if ($container->hasDefinition('doctrine.orm.listeners.resolve_target_entity')) { $def = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity'); foreach ($def->getMethodCalls() as $call) { if ('addResolveTargetEntity' === $call[0]) { $this->resolveTargets[$call[1][0]] = $call[1][1]; } } } } return $this->resolveTargets; }
php
private function getResolveTargets(ContainerBuilder $container) { if (null === $this->resolveTargets) { $this->resolveTargets = []; if ($container->hasDefinition('doctrine.orm.listeners.resolve_target_entity')) { $def = $container->getDefinition('doctrine.orm.listeners.resolve_target_entity'); foreach ($def->getMethodCalls() as $call) { if ('addResolveTargetEntity' === $call[0]) { $this->resolveTargets[$call[1][0]] = $call[1][1]; } } } } return $this->resolveTargets; }
[ "private", "function", "getResolveTargets", "(", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "null", "===", "$", "this", "->", "resolveTargets", ")", "{", "$", "this", "->", "resolveTargets", "=", "[", "]", ";", "if", "(", "$", "container", ...
Get the resolve target classes. @param ContainerBuilder $container The container @return array
[ "Get", "the", "resolve", "target", "classes", "." ]
a6549ad2013fe751f20c0619382d0589d0d549d7
https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/DomainPass.php#L49-L66
train
spiral/pagination
src/Paginator.php
Paginator.setCount
private function setCount(int $count): self { $this->count = max($count, 0); if ($this->count > 0) { $this->countPages = (int)ceil($this->count / $this->limit); } else { $this->countPages = 1; } return $this; }
php
private function setCount(int $count): self { $this->count = max($count, 0); if ($this->count > 0) { $this->countPages = (int)ceil($this->count / $this->limit); } else { $this->countPages = 1; } return $this; }
[ "private", "function", "setCount", "(", "int", "$", "count", ")", ":", "self", "{", "$", "this", "->", "count", "=", "max", "(", "$", "count", ",", "0", ")", ";", "if", "(", "$", "this", "->", "count", ">", "0", ")", "{", "$", "this", "->", "...
Non-Immutable version of withCount. @param int $count @return self|$this
[ "Non", "-", "Immutable", "version", "of", "withCount", "." ]
c2ccf0c3c38fc6cdb2e547685008898dc5804e6f
https://github.com/spiral/pagination/blob/c2ccf0c3c38fc6cdb2e547685008898dc5804e6f/src/Paginator.php#L206-L216
train
railken/amethyst-invoice
src/InvoiceNumber/IncrementalWithYearInvoice.php
IncrementalWithYearInvoice.calculateNextFreeNumber
public function calculateNextFreeNumber() { $year = (new \DateTime())->format('Y'); /** @var \Railken\Amethyst\Models\InvoiceModel */ $result = $this->getManager() ->getRepository() ->newQuery() ->where('number', 'like', '%/'.$year) ->orderBy(DB::raw("CAST(REPLACE(number, '/{$year}', '') AS DECIMAL(10,2))"), 'desc') ->first(); $number = $result ? intval(str_replace("/{$year}", '', $result->number)) + 1 : 1; return $number.'/'.$year; }
php
public function calculateNextFreeNumber() { $year = (new \DateTime())->format('Y'); /** @var \Railken\Amethyst\Models\InvoiceModel */ $result = $this->getManager() ->getRepository() ->newQuery() ->where('number', 'like', '%/'.$year) ->orderBy(DB::raw("CAST(REPLACE(number, '/{$year}', '') AS DECIMAL(10,2))"), 'desc') ->first(); $number = $result ? intval(str_replace("/{$year}", '', $result->number)) + 1 : 1; return $number.'/'.$year; }
[ "public", "function", "calculateNextFreeNumber", "(", ")", "{", "$", "year", "=", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "format", "(", "'Y'", ")", ";", "/** @var \\Railken\\Amethyst\\Models\\InvoiceModel */", "$", "result", "=", "$", "this", "->",...
Calculate next free number. @return string
[ "Calculate", "next", "free", "number", "." ]
605cf27aaa82aea7328d5e5ae5f69b1e7e86120e
https://github.com/railken/amethyst-invoice/blob/605cf27aaa82aea7328d5e5ae5f69b1e7e86120e/src/InvoiceNumber/IncrementalWithYearInvoice.php#L51-L66
train
CeusMedia/Common
src/Alg/Math/Average.php
Alg_Math_Average.arithmetic
public static function arithmetic( $values, $accuracy = NULL ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $sum = 0; foreach( $values as $value ) $sum += $value; $result = $sum / count( $values ); if( $accuracy >= 0 ) $result = round( $result, $accuracy ); return $result; }
php
public static function arithmetic( $values, $accuracy = NULL ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $sum = 0; foreach( $values as $value ) $sum += $value; $result = $sum / count( $values ); if( $accuracy >= 0 ) $result = round( $result, $accuracy ); return $result; }
[ "public", "static", "function", "arithmetic", "(", "$", "values", ",", "$", "accuracy", "=", "NULL", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", ...
Calculates artithmetic Average. @access public @static @param array $values Array of Values. @param int $accuracy Accuracy of Result @return float
[ "Calculates", "artithmetic", "Average", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Average.php#L51-L68
train
CeusMedia/Common
src/Alg/Math/Average.php
Alg_Math_Average.geometric
public static function geometric( $values, $accuracy = NULL ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $product = 1; foreach( $values as $value ) $product *= $value; $result = pow( $product, 1 / count( $values ) ); if( $accuracy >= 0 ) $result = round( $result, $accuracy ); return $result; }
php
public static function geometric( $values, $accuracy = NULL ) { Deprecation::getInstance() ->setErrorVersion( '0.8.5' ) ->setExceptionVersion( '0.9' ) ->message( sprintf( 'Please use %s (%s) instead', 'public library "CeusMedia/Math"', 'https://packagist.org/packages/ceus-media/math' ) ); $product = 1; foreach( $values as $value ) $product *= $value; $result = pow( $product, 1 / count( $values ) ); if( $accuracy >= 0 ) $result = round( $result, $accuracy ); return $result; }
[ "public", "static", "function", "geometric", "(", "$", "values", ",", "$", "accuracy", "=", "NULL", ")", "{", "Deprecation", "::", "getInstance", "(", ")", "->", "setErrorVersion", "(", "'0.8.5'", ")", "->", "setExceptionVersion", "(", "'0.9'", ")", "->", ...
Calculates geometric Average. @access public @static @param array $values Array of Values @param int $accuracy Accuracy of Result @return float
[ "Calculates", "geometric", "Average", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Average.php#L78-L95
train
rollun-com/rollun-logger
src/Logger/src/Processor/LifeCycleTokenInjector.php
LifeCycleTokenInjector.process
public function process(array $event) { if (!isset($event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) { $event[LifeCycleToken::KEY_LIFECYCLE_TOKEN] = $this->token->toString(); } elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN]) && ($this->token->toString() !== $event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) { $event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN] = $this->token->toString(); } if ($this->token->hasParentToken()) { if (!isset($event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN])) { $event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken() ->toString(); } elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN]) && $this->token->getParentToken() ->toString() !== $event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN]) { $event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken() ->toString(); } } return $event; }
php
public function process(array $event) { if (!isset($event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) { $event[LifeCycleToken::KEY_LIFECYCLE_TOKEN] = $this->token->toString(); } elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN]) && ($this->token->toString() !== $event[LifeCycleToken::KEY_LIFECYCLE_TOKEN])) { $event['context'][LifeCycleToken::KEY_ORIGINAL_LIFECYCLE_TOKEN] = $this->token->toString(); } if ($this->token->hasParentToken()) { if (!isset($event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN])) { $event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken() ->toString(); } elseif (!isset($event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN]) && $this->token->getParentToken() ->toString() !== $event[LifeCycleToken::KEY_PARENT_LIFECYCLE_TOKEN]) { $event['context'][LifeCycleToken::KEY_ORIGINAL_PARENT_LIFECYCLE_TOKEN] = $this->token->getParentToken() ->toString(); } } return $event; }
[ "public", "function", "process", "(", "array", "$", "event", ")", "{", "if", "(", "!", "isset", "(", "$", "event", "[", "LifeCycleToken", "::", "KEY_LIFECYCLE_TOKEN", "]", ")", ")", "{", "$", "event", "[", "LifeCycleToken", "::", "KEY_LIFECYCLE_TOKEN", "]"...
Processes a log message before it is given to the writers @param array $event @return array
[ "Processes", "a", "log", "message", "before", "it", "is", "given", "to", "the", "writers" ]
aa520217298ca3fdcfdda3814b9f397376b79fbc
https://github.com/rollun-com/rollun-logger/blob/aa520217298ca3fdcfdda3814b9f397376b79fbc/src/Logger/src/Processor/LifeCycleTokenInjector.php#L34-L55
train
CeusMedia/Common
src/FS/File/Arc/TarGzip.php
FS_File_Arc_TarGzip.open
public function open( $fileName ) { if( !file_exists( $fileName ) ) // If the tar file doesn't exist... throw new Exception( "TGZ file '".$fileName."' is not existing." ); $this->fileName = $fileName; $this->readGzipTar( $fileName ); }
php
public function open( $fileName ) { if( !file_exists( $fileName ) ) // If the tar file doesn't exist... throw new Exception( "TGZ file '".$fileName."' is not existing." ); $this->fileName = $fileName; $this->readGzipTar( $fileName ); }
[ "public", "function", "open", "(", "$", "fileName", ")", "{", "if", "(", "!", "file_exists", "(", "$", "fileName", ")", ")", "// If the tar file doesn't exist...\r", "throw", "new", "Exception", "(", "\"TGZ file '\"", ".", "$", "fileName", ".", "\"' is not exist...
Opens an existing Tar Gzip File and loads contents. @access public @param string $fileName Name of Tar Gzip Archive to open @return bool
[ "Opens", "an", "existing", "Tar", "Gzip", "File", "and", "loads", "contents", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/TarGzip.php#L60-L66
train
CeusMedia/Common
src/FS/File/Arc/TarGzip.php
FS_File_Arc_TarGzip.readGzipTar
private function readGzipTar( $fileName ) { $f = new FS_File_Arc_Gzip( $fileName ); $this->content = $f->readString(); $this->parseTar(); // Parse the TAR file return true; }
php
private function readGzipTar( $fileName ) { $f = new FS_File_Arc_Gzip( $fileName ); $this->content = $f->readString(); $this->parseTar(); // Parse the TAR file return true; }
[ "private", "function", "readGzipTar", "(", "$", "fileName", ")", "{", "$", "f", "=", "new", "FS_File_Arc_Gzip", "(", "$", "fileName", ")", ";", "$", "this", "->", "content", "=", "$", "f", "->", "readString", "(", ")", ";", "$", "this", "->", "parseT...
Reads an existing Tar Gzip File. @access private @param string $fileName Name of Tar Gzip Archive to read @return bool
[ "Reads", "an", "existing", "Tar", "Gzip", "File", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/TarGzip.php#L74-L80
train
CeusMedia/Common
src/FS/File/Arc/TarGzip.php
FS_File_Arc_TarGzip.save
public function save( $fileName = false ) { if( !$fileName ) { if( !$this->fileName ) throw new Exception( "No TGZ file name for saving given." ); $fileName = $this->fileName; } $this->generateTar(); // Encode processed files into TAR file format $f = new FS_File_Arc_Gzip( $fileName ); $f->writeString( $this->content); return true; }
php
public function save( $fileName = false ) { if( !$fileName ) { if( !$this->fileName ) throw new Exception( "No TGZ file name for saving given." ); $fileName = $this->fileName; } $this->generateTar(); // Encode processed files into TAR file format $f = new FS_File_Arc_Gzip( $fileName ); $f->writeString( $this->content); return true; }
[ "public", "function", "save", "(", "$", "fileName", "=", "false", ")", "{", "if", "(", "!", "$", "fileName", ")", "{", "if", "(", "!", "$", "this", "->", "fileName", ")", "throw", "new", "Exception", "(", "\"No TGZ file name for saving given.\"", ")", ";...
Write down the currently loaded Tar Gzip Archive. @access public @param string $fileName Name of Tar Gzip Archive to save @return bool
[ "Write", "down", "the", "currently", "loaded", "Tar", "Gzip", "Archive", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Arc/TarGzip.php#L88-L100
train
CeusMedia/Common
src/Net/Mail.php
Net_Mail.getBody
public function getBody() { $number = count( $this->parts ); if( !$number ) return ''; $innerBoundary = $this->mimeBoundary.'-1'; $contents = array( 'This is a multi-part message in MIME format.'); $contents[] = '--'.$this->mimeBoundary; $contents[] = 'Content-Type: multipart/alternative;'; $contents[] = ' boundary="'.$innerBoundary.'"'.Net_Mail::$delimiter; foreach( $this->parts as $part ) if( $part instanceof Net_Mail_Body ) $contents[] = '--'.$innerBoundary.Net_Mail::$delimiter.$part->render(); $contents[] = '--'.$innerBoundary.'--'.Net_Mail::$delimiter; foreach( $this->parts as $part ) if( $part instanceof Net_Mail_Attachment ) $contents[] = '--'.$this->mimeBoundary.Net_Mail::$delimiter.$part->render(); $contents[] = '--'.$this->mimeBoundary.'--'.Net_Mail::$delimiter; return join( Net_Mail::$delimiter, $contents ); }
php
public function getBody() { $number = count( $this->parts ); if( !$number ) return ''; $innerBoundary = $this->mimeBoundary.'-1'; $contents = array( 'This is a multi-part message in MIME format.'); $contents[] = '--'.$this->mimeBoundary; $contents[] = 'Content-Type: multipart/alternative;'; $contents[] = ' boundary="'.$innerBoundary.'"'.Net_Mail::$delimiter; foreach( $this->parts as $part ) if( $part instanceof Net_Mail_Body ) $contents[] = '--'.$innerBoundary.Net_Mail::$delimiter.$part->render(); $contents[] = '--'.$innerBoundary.'--'.Net_Mail::$delimiter; foreach( $this->parts as $part ) if( $part instanceof Net_Mail_Attachment ) $contents[] = '--'.$this->mimeBoundary.Net_Mail::$delimiter.$part->render(); $contents[] = '--'.$this->mimeBoundary.'--'.Net_Mail::$delimiter; return join( Net_Mail::$delimiter, $contents ); }
[ "public", "function", "getBody", "(", ")", "{", "$", "number", "=", "count", "(", "$", "this", "->", "parts", ")", ";", "if", "(", "!", "$", "number", ")", "return", "''", ";", "$", "innerBoundary", "=", "$", "this", "->", "mimeBoundary", ".", "'-1...
Returns Mail Body. @access public @return string
[ "Returns", "Mail", "Body", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail.php#L110-L132
train
ncou/Chiron
src/Chiron/Routing/Router.php
Router.processGroups
private function processGroups(): void { // Call the $group by reference because in the case : group of group the size of the array is modified because a new group is added in the group() function. foreach ($this->groups as $key => &$group) { unset($this->groups[$key]); $group(); //array_pop($this->groups); } }
php
private function processGroups(): void { // Call the $group by reference because in the case : group of group the size of the array is modified because a new group is added in the group() function. foreach ($this->groups as $key => &$group) { unset($this->groups[$key]); $group(); //array_pop($this->groups); } }
[ "private", "function", "processGroups", "(", ")", ":", "void", "{", "// Call the $group by reference because in the case : group of group the size of the array is modified because a new group is added in the group() function.", "foreach", "(", "$", "this", "->", "groups", "as", "$", ...
Process all groups.
[ "Process", "all", "groups", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L271-L279
train
ncou/Chiron
src/Chiron/Routing/Router.php
Router.replaceAssertPatterns
private function replaceAssertPatterns(array $requirements, string $path): string { $patternAssert = []; foreach ($requirements as $attribute => $pattern) { // it will replace {attribute_name} to {attribute_name:$pattern}, work event if there is alreay a patter {attribute_name:pattern_to_remove} to {attribute_name:$pattern} // the second regex group (starting with the char ':') will be discarded. $patternAssert['/{(' . $attribute . ')(\:.*)?}/'] = '{$1:' . $pattern . '}'; //$patternAssert['/{(' . $attribute . ')}/'] = '{$1:' . $pattern . '}'; // TODO : réfléchir si on utilise cette regex, dans ce cas seulement les propriétés qui n'ont pas déjà un pattern de défini (c'est à dire une partie avec ':pattern') } return preg_replace(array_keys($patternAssert), array_values($patternAssert), $path); }
php
private function replaceAssertPatterns(array $requirements, string $path): string { $patternAssert = []; foreach ($requirements as $attribute => $pattern) { // it will replace {attribute_name} to {attribute_name:$pattern}, work event if there is alreay a patter {attribute_name:pattern_to_remove} to {attribute_name:$pattern} // the second regex group (starting with the char ':') will be discarded. $patternAssert['/{(' . $attribute . ')(\:.*)?}/'] = '{$1:' . $pattern . '}'; //$patternAssert['/{(' . $attribute . ')}/'] = '{$1:' . $pattern . '}'; // TODO : réfléchir si on utilise cette regex, dans ce cas seulement les propriétés qui n'ont pas déjà un pattern de défini (c'est à dire une partie avec ':pattern') } return preg_replace(array_keys($patternAssert), array_values($patternAssert), $path); }
[ "private", "function", "replaceAssertPatterns", "(", "array", "$", "requirements", ",", "string", "$", "path", ")", ":", "string", "{", "$", "patternAssert", "=", "[", "]", ";", "foreach", "(", "$", "requirements", "as", "$", "attribute", "=>", "$", "patte...
Add or replace the requirement pattern inside the route path. @param array $requirements @param string $path @return string
[ "Add", "or", "replace", "the", "requirement", "pattern", "inside", "the", "route", "path", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L289-L300
train
ncou/Chiron
src/Chiron/Routing/Router.php
Router.replaceWordPatterns
private function replaceWordPatterns(string $path): string { return preg_replace(array_keys($this->patternMatchers), array_values($this->patternMatchers), $path); }
php
private function replaceWordPatterns(string $path): string { return preg_replace(array_keys($this->patternMatchers), array_values($this->patternMatchers), $path); }
[ "private", "function", "replaceWordPatterns", "(", "string", "$", "path", ")", ":", "string", "{", "return", "preg_replace", "(", "array_keys", "(", "$", "this", "->", "patternMatchers", ")", ",", "array_values", "(", "$", "this", "->", "patternMatchers", ")",...
Replace word patterns with regex in route path. @param string $path @return string
[ "Replace", "word", "patterns", "with", "regex", "in", "route", "path", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L309-L312
train
ncou/Chiron
src/Chiron/Routing/Router.php
Router.addRoute
private function addRoute(array $httpMethod, string $routePath, string $routeId): void { $routeDatas = $this->parser->parse($routePath); foreach ($httpMethod as $method) { foreach ($routeDatas as $routeData) { $this->generator->addRoute($method, $routeData, $routeId); } } }
php
private function addRoute(array $httpMethod, string $routePath, string $routeId): void { $routeDatas = $this->parser->parse($routePath); foreach ($httpMethod as $method) { foreach ($routeDatas as $routeData) { $this->generator->addRoute($method, $routeData, $routeId); } } }
[ "private", "function", "addRoute", "(", "array", "$", "httpMethod", ",", "string", "$", "routePath", ",", "string", "$", "routeId", ")", ":", "void", "{", "$", "routeDatas", "=", "$", "this", "->", "parser", "->", "parse", "(", "$", "routePath", ")", "...
Adds a route to the collection. The syntax used in the $route string depends on the used route parser. @param string[] $httpMethod @param string $routePath @param string $routeId
[ "Adds", "a", "route", "to", "the", "collection", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L323-L331
train
ncou/Chiron
src/Chiron/Routing/Router.php
Router.getNamedRoute
public function getNamedRoute(string $name): Route { foreach ($this->getRoutes() as $route) { if ($route->getName() === $name) { return $route; } } throw new InvalidArgumentException('Named route does not exist for name: ' . $name); }
php
public function getNamedRoute(string $name): Route { foreach ($this->getRoutes() as $route) { if ($route->getName() === $name) { return $route; } } throw new InvalidArgumentException('Named route does not exist for name: ' . $name); }
[ "public", "function", "getNamedRoute", "(", "string", "$", "name", ")", ":", "Route", "{", "foreach", "(", "$", "this", "->", "getRoutes", "(", ")", "as", "$", "route", ")", "{", "if", "(", "$", "route", "->", "getName", "(", ")", "===", "$", "name...
Get a named route. @param string $name Route name @throws \InvalidArgumentException If named route does not exist @return \Chiron\Routing\Route
[ "Get", "a", "named", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L354-L363
train
ncou/Chiron
src/Chiron/Routing/Router.php
Router.removeNamedRoute
public function removeNamedRoute(string $name) { $route = $this->getNamedRoute($name); // no exception, route exists, now remove by id unset($this->routes[$route->getIdentifier()]); }
php
public function removeNamedRoute(string $name) { $route = $this->getNamedRoute($name); // no exception, route exists, now remove by id unset($this->routes[$route->getIdentifier()]); }
[ "public", "function", "removeNamedRoute", "(", "string", "$", "name", ")", "{", "$", "route", "=", "$", "this", "->", "getNamedRoute", "(", "$", "name", ")", ";", "// no exception, route exists, now remove by id", "unset", "(", "$", "this", "->", "routes", "["...
Remove named route. @param string $name Route name @throws \InvalidArgumentException If named route does not exist
[ "Remove", "named", "route", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L372-L377
train
ncou/Chiron
src/Chiron/Routing/Router.php
Router.pathFor
public function pathFor(string $name, array $data = [], array $queryParams = []): string { $url = $this->relativePathFor($name, $data, $queryParams); if ($this->basePath) { $url = $this->basePath . $url; } return $url; }
php
public function pathFor(string $name, array $data = [], array $queryParams = []): string { $url = $this->relativePathFor($name, $data, $queryParams); if ($this->basePath) { $url = $this->basePath . $url; } return $url; }
[ "public", "function", "pathFor", "(", "string", "$", "name", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "queryParams", "=", "[", "]", ")", ":", "string", "{", "$", "url", "=", "$", "this", "->", "relativePathFor", "(", "$", "name"...
Build the path for a named route including the base path. @param string $name Route name @param array $data Named argument replacement data @param array $queryParams Optional query string parameters @throws InvalidArgumentException If named route does not exist @throws InvalidArgumentException If required data not provided @return string
[ "Build", "the", "path", "for", "a", "named", "route", "including", "the", "base", "path", "." ]
bfb6f85faba0e54005896b09a7c34e456d1a1bed
https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Routing/Router.php#L391-L400
train
CeusMedia/Common
src/FS/Folder/MethodSortCheck.php
FS_Folder_MethodSortCheck.checkOrder
public function checkOrder() { $this->count = 0; $this->found = 0; $this->files = array(); $extensions = implode( "|", $this->extensions ); $pattern = "@^[A-Z].*\.(".$extensions.")$@"; $filter = new FS_File_RecursiveRegexFilter( $this->path, $pattern ); foreach( $filter as $entry ) { if( preg_match( "@^(_|\.)@", $entry->getFilename() ) ) continue; $this->count++; $check = new FS_File_PHP_MethodSortCheck( $entry->getPathname() ); if( $check->compare() ) continue; $this->found++; $list1 = $check->getOriginalList(); $list2 = $check->getSortedList(); do{ $line1 = array_shift( $list1 ); $line2 = array_shift( $list2 ); if( $line1 != $line2 ) break; } while( count( $list1 ) && count( $list2 ) ); $fileName = substr( $entry->getPathname(), strlen( $this->path ) + 1 ); $this->files[$entry->getPathname()] = array( 'fileName' => $fileName, 'pathName' => $entry->getPathname(), 'original' => $line1, 'sorted' => $line2, ); } return !$this->found; }
php
public function checkOrder() { $this->count = 0; $this->found = 0; $this->files = array(); $extensions = implode( "|", $this->extensions ); $pattern = "@^[A-Z].*\.(".$extensions.")$@"; $filter = new FS_File_RecursiveRegexFilter( $this->path, $pattern ); foreach( $filter as $entry ) { if( preg_match( "@^(_|\.)@", $entry->getFilename() ) ) continue; $this->count++; $check = new FS_File_PHP_MethodSortCheck( $entry->getPathname() ); if( $check->compare() ) continue; $this->found++; $list1 = $check->getOriginalList(); $list2 = $check->getSortedList(); do{ $line1 = array_shift( $list1 ); $line2 = array_shift( $list2 ); if( $line1 != $line2 ) break; } while( count( $list1 ) && count( $list2 ) ); $fileName = substr( $entry->getPathname(), strlen( $this->path ) + 1 ); $this->files[$entry->getPathname()] = array( 'fileName' => $fileName, 'pathName' => $entry->getPathname(), 'original' => $line1, 'sorted' => $line2, ); } return !$this->found; }
[ "public", "function", "checkOrder", "(", ")", "{", "$", "this", "->", "count", "=", "0", ";", "$", "this", "->", "found", "=", "0", ";", "$", "this", "->", "files", "=", "array", "(", ")", ";", "$", "extensions", "=", "implode", "(", "\"|\"", ","...
Indicates whether all Methods in all Files are ordered correctly. @access public @return bool
[ "Indicates", "whether", "all", "Methods", "in", "all", "Files", "are", "ordered", "correctly", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/MethodSortCheck.php#L66-L101
train
CeusMedia/Common
src/FS/Folder/MethodSortCheck.php
FS_Folder_MethodSortCheck.getPercentage
public function getPercentage( $accuracy = 0 ) { if( !$this->count ) return 0; return round( $this->found / $this->count * 100, $accuracy ); }
php
public function getPercentage( $accuracy = 0 ) { if( !$this->count ) return 0; return round( $this->found / $this->count * 100, $accuracy ); }
[ "public", "function", "getPercentage", "(", "$", "accuracy", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "count", ")", "return", "0", ";", "return", "round", "(", "$", "this", "->", "found", "/", "$", "this", "->", "count", "*", "100", ...
Returns Percentage Value of Ratio between Number of found and scanned Files. @access public @param int $accuracy Number of Digits after Dot @return float
[ "Returns", "Percentage", "Value", "of", "Ratio", "between", "Number", "of", "found", "and", "scanned", "Files", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/Folder/MethodSortCheck.php#L139-L144
train
CeusMedia/Common
src/UI/HTML/Exception/View.php
UI_HTML_Exception_View.getMeaningOfSQLSTATE
protected static function getMeaningOfSQLSTATE( $SQLSTATE ) { $class1 = substr( $SQLSTATE, 0, 2 ); $class2 = substr( $SQLSTATE, 2, 3 ); $root = XML_ElementReader::readFile( dirname( __FILE__ ).'/SQLSTATE.xml' ); $query = 'class[@id="'.$class1.'"]/subclass[@id="000"]'; $result = $root->xpath( $query ); $class = array_pop( $result ); if( $class ){ $query = 'class[@id="'.$class1.'"]/subclass[@id="'.$class2.'"]'; $result = $root->xpath( $query ); $subclass = array_pop( $result ); if( $subclass ) return $class->getAttribute( 'meaning' ).' - '.$subclass->getAttribute( 'meaning' ); return $class->getAttribute( 'meaning' ); } return ''; }
php
protected static function getMeaningOfSQLSTATE( $SQLSTATE ) { $class1 = substr( $SQLSTATE, 0, 2 ); $class2 = substr( $SQLSTATE, 2, 3 ); $root = XML_ElementReader::readFile( dirname( __FILE__ ).'/SQLSTATE.xml' ); $query = 'class[@id="'.$class1.'"]/subclass[@id="000"]'; $result = $root->xpath( $query ); $class = array_pop( $result ); if( $class ){ $query = 'class[@id="'.$class1.'"]/subclass[@id="'.$class2.'"]'; $result = $root->xpath( $query ); $subclass = array_pop( $result ); if( $subclass ) return $class->getAttribute( 'meaning' ).' - '.$subclass->getAttribute( 'meaning' ); return $class->getAttribute( 'meaning' ); } return ''; }
[ "protected", "static", "function", "getMeaningOfSQLSTATE", "(", "$", "SQLSTATE", ")", "{", "$", "class1", "=", "substr", "(", "$", "SQLSTATE", ",", "0", ",", "2", ")", ";", "$", "class2", "=", "substr", "(", "$", "SQLSTATE", ",", "2", ",", "3", ")", ...
Resolves SQLSTATE Code and returns its Meaning. @access protected @static @return string @see http://developer.mimer.com/documentation/html_92/Mimer_SQL_Mobile_DocSet/App_Return_Codes2.html @see http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqls.doc/sqls520.htm
[ "Resolves", "SQLSTATE", "Code", "and", "returns", "its", "Meaning", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Exception/View.php#L62-L80
train
CeusMedia/Common
src/FS/File/CSV/Reader.php
FS_File_CSV_Reader.getColumnHeaders
public function getColumnHeaders() { if( !$this->withHeaders ) throw new RuntimeException( 'Column headers not enabled' ); $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); if( !$iterator->valid() ) throw new RuntimeException( 'Invalid CSV file' ); return $iterator->current(); }
php
public function getColumnHeaders() { if( !$this->withHeaders ) throw new RuntimeException( 'Column headers not enabled' ); $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); if( !$iterator->valid() ) throw new RuntimeException( 'Invalid CSV file' ); return $iterator->current(); }
[ "public", "function", "getColumnHeaders", "(", ")", "{", "if", "(", "!", "$", "this", "->", "withHeaders", ")", "throw", "new", "RuntimeException", "(", "'Column headers not enabled'", ")", ";", "$", "iterator", "=", "new", "FS_File_CSV_Iterator", "(", "$", "t...
Returns columns headers if used. @access public @return array
[ "Returns", "columns", "headers", "if", "used", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L74-L82
train
CeusMedia/Common
src/FS/File/CSV/Reader.php
FS_File_CSV_Reader.getRowCount
public function getRowCount() { $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); $counter = 0; while( $iterator->next() ) $counter++; if( $counter && $this->withHeaders ) $counter--; return $counter; }
php
public function getRowCount() { $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); $counter = 0; while( $iterator->next() ) $counter++; if( $counter && $this->withHeaders ) $counter--; return $counter; }
[ "public", "function", "getRowCount", "(", ")", "{", "$", "iterator", "=", "new", "FS_File_CSV_Iterator", "(", "$", "this", "->", "fileName", ",", "$", "this", "->", "delimiter", ")", ";", "$", "counter", "=", "0", ";", "while", "(", "$", "iterator", "-...
Returns the count of data rows. @access public @return int
[ "Returns", "the", "count", "of", "data", "rows", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L109-L118
train
CeusMedia/Common
src/FS/File/CSV/Reader.php
FS_File_CSV_Reader.toArray
public function toArray() { $data = array(); $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); while( $iterator->next() ) $data[] = $iterator->current(); if( $this->withHeaders ) array_shift( $data ); return $data; }
php
public function toArray() { $data = array(); $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); while( $iterator->next() ) $data[] = $iterator->current(); if( $this->withHeaders ) array_shift( $data ); return $data; }
[ "public", "function", "toArray", "(", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "iterator", "=", "new", "FS_File_CSV_Iterator", "(", "$", "this", "->", "fileName", ",", "$", "this", "->", "delimiter", ")", ";", "while", "(", "$", "iter...
Reads data an returns an array. @access public @return array
[ "Reads", "data", "an", "returns", "an", "array", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L147-L156
train
CeusMedia/Common
src/FS/File/CSV/Reader.php
FS_File_CSV_Reader.toAssocArray
public function toAssocArray( $headerMap = array() ) { $data = array(); $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); $keys = $this->getColumnHeaders( $headerMap ); $line = 0; if( $this->withHeaders ) { $iterator->next(); $line++; } while( $iterator->valid() ) { $line++; $values = $iterator->current(); if( count( $keys ) != count( $values ) ) throw new RuntimeException( 'Invalid line '.$line.' in file "'.$this->fileName.'"' ); $data[] = array_combine( $keys, $values ); } return $data; }
php
public function toAssocArray( $headerMap = array() ) { $data = array(); $iterator = new FS_File_CSV_Iterator( $this->fileName, $this->delimiter ); $keys = $this->getColumnHeaders( $headerMap ); $line = 0; if( $this->withHeaders ) { $iterator->next(); $line++; } while( $iterator->valid() ) { $line++; $values = $iterator->current(); if( count( $keys ) != count( $values ) ) throw new RuntimeException( 'Invalid line '.$line.' in file "'.$this->fileName.'"' ); $data[] = array_combine( $keys, $values ); } return $data; }
[ "public", "function", "toAssocArray", "(", "$", "headerMap", "=", "array", "(", ")", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "iterator", "=", "new", "FS_File_CSV_Iterator", "(", "$", "this", "->", "fileName", ",", "$", "this", "->", ...
Reads data and returns an associative array if column headers are used. @access public @return array
[ "Reads", "data", "and", "returns", "an", "associative", "array", "if", "column", "headers", "are", "used", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/CSV/Reader.php#L163-L183
train
meritoo/common-library
src/Utilities/Bootstrap4CssSelector.php
Bootstrap4CssSelector.getFieldErrorSelector
public static function getFieldErrorSelector($formName, $fieldId) { $labelSelector = CssSelector::getLabelSelector($formName, $fieldId); if (empty($labelSelector)) { return ''; } $errorContainerSelector = static::getFieldErrorContainerSelector(); return sprintf('%s %s', $labelSelector, $errorContainerSelector); }
php
public static function getFieldErrorSelector($formName, $fieldId) { $labelSelector = CssSelector::getLabelSelector($formName, $fieldId); if (empty($labelSelector)) { return ''; } $errorContainerSelector = static::getFieldErrorContainerSelector(); return sprintf('%s %s', $labelSelector, $errorContainerSelector); }
[ "public", "static", "function", "getFieldErrorSelector", "(", "$", "formName", ",", "$", "fieldId", ")", "{", "$", "labelSelector", "=", "CssSelector", "::", "getLabelSelector", "(", "$", "formName", ",", "$", "fieldId", ")", ";", "if", "(", "empty", "(", ...
Returns selector of field's validation error @param string $formName Name of form (value of the "name" attribute) @param string $fieldId ID of field (value of the "id" attribute) @return string
[ "Returns", "selector", "of", "field", "s", "validation", "error" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Bootstrap4CssSelector.php#L36-L47
train
meritoo/common-library
src/Utilities/Bootstrap4CssSelector.php
Bootstrap4CssSelector.getRadioButtonErrorSelector
public static function getRadioButtonErrorSelector($formName, $fieldSetIndex) { $fieldSetSelector = CssSelector::getFieldSetByIndexSelector($formName, $fieldSetIndex); if (empty($fieldSetSelector)) { return ''; } $errorContainerSelector = static::getFieldErrorContainerSelector(); return sprintf('%s legend.col-form-label %s', $fieldSetSelector, $errorContainerSelector); }
php
public static function getRadioButtonErrorSelector($formName, $fieldSetIndex) { $fieldSetSelector = CssSelector::getFieldSetByIndexSelector($formName, $fieldSetIndex); if (empty($fieldSetSelector)) { return ''; } $errorContainerSelector = static::getFieldErrorContainerSelector(); return sprintf('%s legend.col-form-label %s', $fieldSetSelector, $errorContainerSelector); }
[ "public", "static", "function", "getRadioButtonErrorSelector", "(", "$", "formName", ",", "$", "fieldSetIndex", ")", "{", "$", "fieldSetSelector", "=", "CssSelector", "::", "getFieldSetByIndexSelector", "(", "$", "formName", ",", "$", "fieldSetIndex", ")", ";", "i...
Returns selector of radio-button's validation error @param string $formName Name of form (value of the "name" attribute) @param int $fieldSetIndex Index/Position of the field-set @return string
[ "Returns", "selector", "of", "radio", "-", "button", "s", "validation", "error" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Bootstrap4CssSelector.php#L56-L67
train
meritoo/common-library
src/Utilities/Bootstrap4CssSelector.php
Bootstrap4CssSelector.getFieldGroupSelector
public static function getFieldGroupSelector($formName) { $formSelector = CssSelector::getFormByNameSelector($formName); if (empty($formSelector)) { return ''; } return sprintf('%s .form-group', $formSelector); }
php
public static function getFieldGroupSelector($formName) { $formSelector = CssSelector::getFormByNameSelector($formName); if (empty($formSelector)) { return ''; } return sprintf('%s .form-group', $formSelector); }
[ "public", "static", "function", "getFieldGroupSelector", "(", "$", "formName", ")", "{", "$", "formSelector", "=", "CssSelector", "::", "getFormByNameSelector", "(", "$", "formName", ")", ";", "if", "(", "empty", "(", "$", "formSelector", ")", ")", "{", "ret...
Returns selector of field's group @param string $formName Name of form (value of the "name" attribute) @return string
[ "Returns", "selector", "of", "field", "s", "group" ]
b166b8b805ae97c15688d27323cae8976bd0f6dc
https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/Bootstrap4CssSelector.php#L75-L84
train
CeusMedia/Common
src/Alg/Search/Binary.php
Alg_Search_Binary.search
public function search( $list, $search, $pos = 0 ) { $size = sizeof( $list ); if( $size == 1 ) { if( $list[0] == $search ) return $list[0]; else return -1; } else { $this->counter++; $mid = floor( $size / 2 ); if( $search < $list[$mid] ) { $list = array_slice( $list, 0, $mid ); return $this->search( $list, $search, $pos ); } else { $list = array_slice( $list, $mid ); return $this->search( $list, $search, $pos ); } } }
php
public function search( $list, $search, $pos = 0 ) { $size = sizeof( $list ); if( $size == 1 ) { if( $list[0] == $search ) return $list[0]; else return -1; } else { $this->counter++; $mid = floor( $size / 2 ); if( $search < $list[$mid] ) { $list = array_slice( $list, 0, $mid ); return $this->search( $list, $search, $pos ); } else { $list = array_slice( $list, $mid ); return $this->search( $list, $search, $pos ); } } }
[ "public", "function", "search", "(", "$", "list", ",", "$", "search", ",", "$", "pos", "=", "0", ")", "{", "$", "size", "=", "sizeof", "(", "$", "list", ")", ";", "if", "(", "$", "size", "==", "1", ")", "{", "if", "(", "$", "list", "[", "0"...
Searches in List and returns position if found, else 0. @access public @param array $list List to search in @param mixed $search Element to search @param int $pos Position (initial = 0) @return int
[ "Searches", "in", "List", "and", "returns", "position", "if", "found", "else", "0", "." ]
1138adf9341782a6284c05884989f7497532bcf4
https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Search/Binary.php#L51-L76
train