id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
37,500 | CeusMedia/Common | src/ADT/Registry.php | ADT_Registry.remove | public function remove( $key )
{
if( !isset( $GLOBALS[$this->poolKey][$key] ) )
return false;
unset( $GLOBALS[$this->poolKey][$key] );
return true;
} | php | public function remove( $key )
{
if( !isset( $GLOBALS[$this->poolKey][$key] ) )
return false;
unset( $GLOBALS[$this->poolKey][$key] );
return true;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"[",
"$",
"key",
"]",
")",
")",
"return",
"false",
";",
"unset",
"(",
"$",
"GLOBALS",
"[",
"$",
"this",
"->",
"poolKey",
"]",
"[",
"$",
"key",
"]",
")",
";",
"return",
"true",
";",
"}"
] | Removes a registered Object.
@access public
@param string $key Registry Key of registered Object
@return bool | [
"Removes",
"a",
"registered",
"Object",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Registry.php#L145-L151 |
37,501 | CeusMedia/Common | src/FS/File/Log/JSON/Writer.php | FS_File_Log_JSON_Writer.noteData | public static function noteData( $fileName, $data )
{
$data = array_merge(
array(
'timestamp' => time()
),
$data
);
$serial = json_encode( $data )."\n";
if( !file_exists( dirname( $fileName ) ) )
mkDir( dirname( $fileName ), 0700, TRUE );
return error_log( $serial, 3, $fileName );
} | php | public static function noteData( $fileName, $data )
{
$data = array_merge(
array(
'timestamp' => time()
),
$data
);
$serial = json_encode( $data )."\n";
if( !file_exists( dirname( $fileName ) ) )
mkDir( dirname( $fileName ), 0700, TRUE );
return error_log( $serial, 3, $fileName );
} | [
"public",
"static",
"function",
"noteData",
"(",
"$",
"fileName",
",",
"$",
"data",
")",
"{",
"$",
"data",
"=",
"array_merge",
"(",
"array",
"(",
"'timestamp'",
"=>",
"time",
"(",
")",
")",
",",
"$",
"data",
")",
";",
"$",
"serial",
"=",
"json_encode",
"(",
"$",
"data",
")",
".",
"\"\\n\"",
";",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"fileName",
")",
")",
")",
"mkDir",
"(",
"dirname",
"(",
"$",
"fileName",
")",
",",
"0700",
",",
"TRUE",
")",
";",
"return",
"error_log",
"(",
"$",
"serial",
",",
"3",
",",
"$",
"fileName",
")",
";",
"}"
] | Adds Data to Log File statically.
@access public
@static
@param string $fileName File Name of Log File
@param array $data Data Array to note
@return bool | [
"Adds",
"Data",
"to",
"Log",
"File",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Log/JSON/Writer.php#L75-L87 |
37,502 | CeusMedia/Common | src/Alg/Parcel/Packet.php | Alg_Parcel_Packet.addArticle | public function addArticle( $name, $volume )
{
if( !$this->hasVolumeLeft( $volume ) )
throw new OutOfRangeException( 'Article "'.$name.'" does not fit in this Packet "'.$this->name.'".' );
if( !isset( $this->articles[$name] ) )
$this->articles[$name] = 0;
$this->articles[$name]++;
$this->volume += $volume;
} | php | public function addArticle( $name, $volume )
{
if( !$this->hasVolumeLeft( $volume ) )
throw new OutOfRangeException( 'Article "'.$name.'" does not fit in this Packet "'.$this->name.'".' );
if( !isset( $this->articles[$name] ) )
$this->articles[$name] = 0;
$this->articles[$name]++;
$this->volume += $volume;
} | [
"public",
"function",
"addArticle",
"(",
"$",
"name",
",",
"$",
"volume",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasVolumeLeft",
"(",
"$",
"volume",
")",
")",
"throw",
"new",
"OutOfRangeException",
"(",
"'Article \"'",
".",
"$",
"name",
".",
"'\" does not fit in this Packet \"'",
".",
"$",
"this",
"->",
"name",
".",
"'\".'",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"articles",
"[",
"$",
"name",
"]",
")",
")",
"$",
"this",
"->",
"articles",
"[",
"$",
"name",
"]",
"=",
"0",
";",
"$",
"this",
"->",
"articles",
"[",
"$",
"name",
"]",
"++",
";",
"$",
"this",
"->",
"volume",
"+=",
"$",
"volume",
";",
"}"
] | Adds an Article to Packet.
@access public
@param string $name Article Name
@param string $volume Article Volume for this Packet Size
@return void | [
"Adds",
"an",
"Article",
"to",
"Packet",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Parcel/Packet.php#L82-L90 |
37,503 | ncou/Chiron | src/Chiron/Application.php | Application.initErrorVisibility | public function initErrorVisibility($debug = true)
{
/* Display startup errors which cannot be handled by the normal error handler. */
ini_set('display_startup_errors', $debug);
/* Display errors (redundant if the default error handler is overridden). */
ini_set('display_errors', $debug);
/* Report errors at all severity levels (redundant if the default error handler is overridden). */
error_reporting($debug ? E_ALL : 0);
/* Report detected memory leaks. */
ini_set('report_memleaks', $debug);
} | php | public function initErrorVisibility($debug = true)
{
/* Display startup errors which cannot be handled by the normal error handler. */
ini_set('display_startup_errors', $debug);
/* Display errors (redundant if the default error handler is overridden). */
ini_set('display_errors', $debug);
/* Report errors at all severity levels (redundant if the default error handler is overridden). */
error_reporting($debug ? E_ALL : 0);
/* Report detected memory leaks. */
ini_set('report_memleaks', $debug);
} | [
"public",
"function",
"initErrorVisibility",
"(",
"$",
"debug",
"=",
"true",
")",
"{",
"/* Display startup errors which cannot be handled by the normal error handler. */",
"ini_set",
"(",
"'display_startup_errors'",
",",
"$",
"debug",
")",
";",
"/* Display errors (redundant if the default error handler is overridden). */",
"ini_set",
"(",
"'display_errors'",
",",
"$",
"debug",
")",
";",
"/* Report errors at all severity levels (redundant if the default error handler is overridden). */",
"error_reporting",
"(",
"$",
"debug",
"?",
"E_ALL",
":",
"0",
")",
";",
"/* Report detected memory leaks. */",
"ini_set",
"(",
"'report_memleaks'",
",",
"$",
"debug",
")",
";",
"}"
] | Configure whether to display PHP errors or silence them.
Some of the settings affected here are redundant if the error handler is
overridden, but some of them pertain to errors which the error handler
does not receive, namely start-up errors and memory leaks.
@param bool $debug whether to display errors or silence them | [
"Configure",
"whether",
"to",
"display",
"PHP",
"errors",
"or",
"silence",
"them",
"."
] | bfb6f85faba0e54005896b09a7c34e456d1a1bed | https://github.com/ncou/Chiron/blob/bfb6f85faba0e54005896b09a7c34e456d1a1bed/src/Chiron/Application.php#L157-L167 |
37,504 | icewind1991/SearchDAV | src/DAV/SearchPlugin.php | SearchPlugin.getHTTPMethods | public function getHTTPMethods($uri) {
$path = $this->pathHelper->getPathFromUri($uri);
if ($this->searchBackend->getArbiterPath() === $path) {
return ['SEARCH'];
} else {
return [];
}
} | php | public function getHTTPMethods($uri) {
$path = $this->pathHelper->getPathFromUri($uri);
if ($this->searchBackend->getArbiterPath() === $path) {
return ['SEARCH'];
} else {
return [];
}
} | [
"public",
"function",
"getHTTPMethods",
"(",
"$",
"uri",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"pathHelper",
"->",
"getPathFromUri",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"$",
"this",
"->",
"searchBackend",
"->",
"getArbiterPath",
"(",
")",
"===",
"$",
"path",
")",
"{",
"return",
"[",
"'SEARCH'",
"]",
";",
"}",
"else",
"{",
"return",
"[",
"]",
";",
"}",
"}"
] | SEARCH is allowed for users files
@param string $uri
@return array | [
"SEARCH",
"is",
"allowed",
"for",
"users",
"files"
] | 9c24c70774d5c9f05618166d0a860d6dd52e3591 | https://github.com/icewind1991/SearchDAV/blob/9c24c70774d5c9f05618166d0a860d6dd52e3591/src/DAV/SearchPlugin.php#L82-L89 |
37,505 | CeusMedia/Common | src/FS/File/Editor.php | FS_File_Editor.rename | public function rename( $fileName )
{
if( !$fileName )
throw new InvalidArgumentException( 'No File Name given.' );
$result = @rename( $this->fileName, $fileName );
if( $result === FALSE )
throw new RuntimeException( 'File "'.$this->fileName.'" could not been renamed.' );
$this->__construct( $fileName );
return $result;
} | php | public function rename( $fileName )
{
if( !$fileName )
throw new InvalidArgumentException( 'No File Name given.' );
$result = @rename( $this->fileName, $fileName );
if( $result === FALSE )
throw new RuntimeException( 'File "'.$this->fileName.'" could not been renamed.' );
$this->__construct( $fileName );
return $result;
} | [
"public",
"function",
"rename",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"$",
"fileName",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No File Name given.'",
")",
";",
"$",
"result",
"=",
"@",
"rename",
"(",
"$",
"this",
"->",
"fileName",
",",
"$",
"fileName",
")",
";",
"if",
"(",
"$",
"result",
"===",
"FALSE",
")",
"throw",
"new",
"RuntimeException",
"(",
"'File \"'",
".",
"$",
"this",
"->",
"fileName",
".",
"'\" could not been renamed.'",
")",
";",
"$",
"this",
"->",
"__construct",
"(",
"$",
"fileName",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Renames current File.
@access public
@param string $fileName File Name to rename to
@return bool | [
"Renames",
"current",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/FS/File/Editor.php#L104-L113 |
37,506 | CeusMedia/Common | src/Net/HTTP/Sniffer/Language.php | Net_HTTP_Sniffer_Language.getLanguageFromString | public static function getLanguageFromString( $string, $allowed, $default = false )
{
if( !$default)
$default = $allowed[0];
if( !$string )
return $default;
$accepted = preg_split( '/,\s*/', $string );
$currentLanguage = $default;
$currentQuality = 0;
foreach( $accepted as $accept )
{
if( !preg_match( self::$pattern, $accept, $matches ) )
continue;
$languageCode = explode ( '-', $matches[1] );
$languageQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0;
while( count( $languageCode ) )
{
if( in_array( strtolower( join( '-', $languageCode ) ), $allowed ) )
{
if( $languageQuality > $currentQuality )
{
$currentLanguage = strtolower( join( '-', $languageCode ) );
$currentQuality = $languageQuality;
break;
}
}
array_pop( $languageCode );
}
}
return $currentLanguage;
} | php | public static function getLanguageFromString( $string, $allowed, $default = false )
{
if( !$default)
$default = $allowed[0];
if( !$string )
return $default;
$accepted = preg_split( '/,\s*/', $string );
$currentLanguage = $default;
$currentQuality = 0;
foreach( $accepted as $accept )
{
if( !preg_match( self::$pattern, $accept, $matches ) )
continue;
$languageCode = explode ( '-', $matches[1] );
$languageQuality = isset( $matches[2] ) ? (float) $matches[2] : 1.0;
while( count( $languageCode ) )
{
if( in_array( strtolower( join( '-', $languageCode ) ), $allowed ) )
{
if( $languageQuality > $currentQuality )
{
$currentLanguage = strtolower( join( '-', $languageCode ) );
$currentQuality = $languageQuality;
break;
}
}
array_pop( $languageCode );
}
}
return $currentLanguage;
} | [
"public",
"static",
"function",
"getLanguageFromString",
"(",
"$",
"string",
",",
"$",
"allowed",
",",
"$",
"default",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"default",
")",
"$",
"default",
"=",
"$",
"allowed",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"$",
"string",
")",
"return",
"$",
"default",
";",
"$",
"accepted",
"=",
"preg_split",
"(",
"'/,\\s*/'",
",",
"$",
"string",
")",
";",
"$",
"currentLanguage",
"=",
"$",
"default",
";",
"$",
"currentQuality",
"=",
"0",
";",
"foreach",
"(",
"$",
"accepted",
"as",
"$",
"accept",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"self",
"::",
"$",
"pattern",
",",
"$",
"accept",
",",
"$",
"matches",
")",
")",
"continue",
";",
"$",
"languageCode",
"=",
"explode",
"(",
"'-'",
",",
"$",
"matches",
"[",
"1",
"]",
")",
";",
"$",
"languageQuality",
"=",
"isset",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
"?",
"(",
"float",
")",
"$",
"matches",
"[",
"2",
"]",
":",
"1.0",
";",
"while",
"(",
"count",
"(",
"$",
"languageCode",
")",
")",
"{",
"if",
"(",
"in_array",
"(",
"strtolower",
"(",
"join",
"(",
"'-'",
",",
"$",
"languageCode",
")",
")",
",",
"$",
"allowed",
")",
")",
"{",
"if",
"(",
"$",
"languageQuality",
">",
"$",
"currentQuality",
")",
"{",
"$",
"currentLanguage",
"=",
"strtolower",
"(",
"join",
"(",
"'-'",
",",
"$",
"languageCode",
")",
")",
";",
"$",
"currentQuality",
"=",
"$",
"languageQuality",
";",
"break",
";",
"}",
"}",
"array_pop",
"(",
"$",
"languageCode",
")",
";",
"}",
"}",
"return",
"$",
"currentLanguage",
";",
"}"
] | Returns prefered allowed and accepted Language from String.
@access public
@static
@param array $allowed Array of Languages supported and allowed by the Application
@param string $default Default Languages supported and allowed by the Application
@return string | [
"Returns",
"prefered",
"allowed",
"and",
"accepted",
"Language",
"from",
"String",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Sniffer/Language.php#L67-L97 |
37,507 | Assasz/yggdrasil | src/Yggdrasil/Utils/Seeds/AbstractSeeds.php | AbstractSeeds.persist | public function persist(): void
{
foreach ($this->create() as $seed) {
$this->seeder->persist($seed);
$this->persistedSeeds++;
}
$this->seeder->flush();
} | php | public function persist(): void
{
foreach ($this->create() as $seed) {
$this->seeder->persist($seed);
$this->persistedSeeds++;
}
$this->seeder->flush();
} | [
"public",
"function",
"persist",
"(",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"create",
"(",
")",
"as",
"$",
"seed",
")",
"{",
"$",
"this",
"->",
"seeder",
"->",
"persist",
"(",
"$",
"seed",
")",
";",
"$",
"this",
"->",
"persistedSeeds",
"++",
";",
"}",
"$",
"this",
"->",
"seeder",
"->",
"flush",
"(",
")",
";",
"}"
] | Persists seeds in database | [
"Persists",
"seeds",
"in",
"database"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Seeds/AbstractSeeds.php#L45-L53 |
37,508 | Assasz/yggdrasil | src/Yggdrasil/Utils/Seeds/AbstractSeeds.php | AbstractSeeds.clearStorage | protected function clearStorage(string $storage = null): void
{
if (empty($storage)) {
$seedsReflection = new \ReflectionClass(get_class($this));
$storage = strtolower(str_replace('Seeds', '', $seedsReflection->getShortName()));
}
if (!$this->seeder->truncate($storage)) {
throw new SeedsStorageException("Unable to clear seeds storage: {$storage}");
}
} | php | protected function clearStorage(string $storage = null): void
{
if (empty($storage)) {
$seedsReflection = new \ReflectionClass(get_class($this));
$storage = strtolower(str_replace('Seeds', '', $seedsReflection->getShortName()));
}
if (!$this->seeder->truncate($storage)) {
throw new SeedsStorageException("Unable to clear seeds storage: {$storage}");
}
} | [
"protected",
"function",
"clearStorage",
"(",
"string",
"$",
"storage",
"=",
"null",
")",
":",
"void",
"{",
"if",
"(",
"empty",
"(",
"$",
"storage",
")",
")",
"{",
"$",
"seedsReflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"get_class",
"(",
"$",
"this",
")",
")",
";",
"$",
"storage",
"=",
"strtolower",
"(",
"str_replace",
"(",
"'Seeds'",
",",
"''",
",",
"$",
"seedsReflection",
"->",
"getShortName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"seeder",
"->",
"truncate",
"(",
"$",
"storage",
")",
")",
"{",
"throw",
"new",
"SeedsStorageException",
"(",
"\"Unable to clear seeds storage: {$storage}\"",
")",
";",
"}",
"}"
] | Clears given seeds storage
@param string? $storage Storage name, if NULL seeds class name will be used to resolve storage name
@throws \ReflectionException
@throws SeedsStorageException | [
"Clears",
"given",
"seeds",
"storage"
] | bee9bef7713b85799cdd3e9b23dccae33154f3b3 | https://github.com/Assasz/yggdrasil/blob/bee9bef7713b85799cdd3e9b23dccae33154f3b3/src/Yggdrasil/Utils/Seeds/AbstractSeeds.php#L72-L82 |
37,509 | CeusMedia/Common | src/Net/HTTP/Download.php | Net_HTTP_Download.applyDefaultHeaders | static protected function applyDefaultHeaders( $size = NULL, $timestamp = NULL )
{
header( "Pragma: public" );
header( "Expires: -1" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
if( (int) $size > 0 )
header( "Content-Length: ".( (int) $size ) );
$timestamp = ( (float) $timestamp ) > 1 ? $timestamp : time();
header( "Last-Modified: ".date( 'r', (float) $timestamp ) );
} | php | static protected function applyDefaultHeaders( $size = NULL, $timestamp = NULL )
{
header( "Pragma: public" );
header( "Expires: -1" );
header( "Cache-Control: must-revalidate, post-check=0, pre-check=0" );
if( (int) $size > 0 )
header( "Content-Length: ".( (int) $size ) );
$timestamp = ( (float) $timestamp ) > 1 ? $timestamp : time();
header( "Last-Modified: ".date( 'r', (float) $timestamp ) );
} | [
"static",
"protected",
"function",
"applyDefaultHeaders",
"(",
"$",
"size",
"=",
"NULL",
",",
"$",
"timestamp",
"=",
"NULL",
")",
"{",
"header",
"(",
"\"Pragma: public\"",
")",
";",
"header",
"(",
"\"Expires: -1\"",
")",
";",
"header",
"(",
"\"Cache-Control: must-revalidate, post-check=0, pre-check=0\"",
")",
";",
"if",
"(",
"(",
"int",
")",
"$",
"size",
">",
"0",
")",
"header",
"(",
"\"Content-Length: \"",
".",
"(",
"(",
"int",
")",
"$",
"size",
")",
")",
";",
"$",
"timestamp",
"=",
"(",
"(",
"float",
")",
"$",
"timestamp",
")",
">",
"1",
"?",
"$",
"timestamp",
":",
"time",
"(",
")",
";",
"header",
"(",
"\"Last-Modified: \"",
".",
"date",
"(",
"'r'",
",",
"(",
"float",
")",
"$",
"timestamp",
")",
")",
";",
"}"
] | Applies default HTTP headers of download.
Also applies content length and last modification date if parameters are set.
@static
@access protected
@return void | [
"Applies",
"default",
"HTTP",
"headers",
"of",
"download",
".",
"Also",
"applies",
"content",
"length",
"and",
"last",
"modification",
"date",
"if",
"parameters",
"are",
"set",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Download.php#L55-L65 |
37,510 | CeusMedia/Common | src/Net/HTTP/Download.php | Net_HTTP_Download.setMimeType | static private function setMimeType()
{
$UserBrowser = '';
if( preg_match( '@Opera(/| )([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) )
$UserBrowser = "Opera";
elseif( preg_match( '@MSIE ([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) )
$UserBrowser = "IE";
$mime_type = ( $UserBrowser == 'IE' || $UserBrowser == 'Opera' ) ? 'application/octetstream' : 'application/octet-stream';
header( "Content-Type: ". $mime_type);
} | php | static private function setMimeType()
{
$UserBrowser = '';
if( preg_match( '@Opera(/| )([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) )
$UserBrowser = "Opera";
elseif( preg_match( '@MSIE ([0-9].[0-9]{1,2})@', $_SERVER['HTTP_USER_AGENT'] ) )
$UserBrowser = "IE";
$mime_type = ( $UserBrowser == 'IE' || $UserBrowser == 'Opera' ) ? 'application/octetstream' : 'application/octet-stream';
header( "Content-Type: ". $mime_type);
} | [
"static",
"private",
"function",
"setMimeType",
"(",
")",
"{",
"$",
"UserBrowser",
"=",
"''",
";",
"if",
"(",
"preg_match",
"(",
"'@Opera(/| )([0-9].[0-9]{1,2})@'",
",",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
")",
"$",
"UserBrowser",
"=",
"\"Opera\"",
";",
"elseif",
"(",
"preg_match",
"(",
"'@MSIE ([0-9].[0-9]{1,2})@'",
",",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
")",
")",
"$",
"UserBrowser",
"=",
"\"IE\"",
";",
"$",
"mime_type",
"=",
"(",
"$",
"UserBrowser",
"==",
"'IE'",
"||",
"$",
"UserBrowser",
"==",
"'Opera'",
")",
"?",
"'application/octetstream'",
":",
"'application/octet-stream'",
";",
"header",
"(",
"\"Content-Type: \"",
".",
"$",
"mime_type",
")",
";",
"}"
] | Sends Mime Type Header.
@static
@access private
@return void | [
"Sends",
"Mime",
"Type",
"Header",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/HTTP/Download.php#L135-L144 |
37,511 | CeusMedia/Common | src/ADT/Tree/Node.php | ADT_Tree_Node.addChild | public function addChild( $name, $child )
{
if( isset( $this->children[$name] ) )
throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is already existing.' );
$this->children[$name] = $child;
} | php | public function addChild( $name, $child )
{
if( isset( $this->children[$name] ) )
throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is already existing.' );
$this->children[$name] = $child;
} | [
"public",
"function",
"addChild",
"(",
"$",
"name",
",",
"$",
"child",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"name",
"]",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'A Child with Name \"'",
".",
"$",
"name",
".",
"'\" is already existing.'",
")",
";",
"$",
"this",
"->",
"children",
"[",
"$",
"name",
"]",
"=",
"$",
"child",
";",
"}"
] | Adds a child to Tree.
@access public
@param string $name Child name
@param mixed $child Child to add
@return void | [
"Adds",
"a",
"child",
"to",
"Tree",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Node.php#L50-L55 |
37,512 | CeusMedia/Common | src/ADT/Tree/Node.php | ADT_Tree_Node.getChild | public function getChild( $name )
{
if( !array_key_exists( $name, $this->children ) )
throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is not existing.' );
return $this->children[$name];
} | php | public function getChild( $name )
{
if( !array_key_exists( $name, $this->children ) )
throw new InvalidArgumentException( 'A Child with Name "'.$name.'" is not existing.' );
return $this->children[$name];
} | [
"public",
"function",
"getChild",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"children",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'A Child with Name \"'",
".",
"$",
"name",
".",
"'\" is not existing.'",
")",
";",
"return",
"$",
"this",
"->",
"children",
"[",
"$",
"name",
"]",
";",
"}"
] | Returns a child from Tree by its name.
@access public
@param string $name Child name
@return mixed | [
"Returns",
"a",
"child",
"from",
"Tree",
"by",
"its",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Node.php#L73-L78 |
37,513 | CeusMedia/Common | src/ADT/Tree/Node.php | ADT_Tree_Node.removeChild | public function removeChild( $name )
{
if( !array_key_exists( $name, $this->children ) )
return FALSE;
unset( $this->children[$name] );
return TRUE;
} | php | public function removeChild( $name )
{
if( !array_key_exists( $name, $this->children ) )
return FALSE;
unset( $this->children[$name] );
return TRUE;
} | [
"public",
"function",
"removeChild",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"children",
")",
")",
"return",
"FALSE",
";",
"unset",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"name",
"]",
")",
";",
"return",
"TRUE",
";",
"}"
] | Removes a Child from Tree by its name.
@access public
@param string $name Child name
@return bool | [
"Removes",
"a",
"Child",
"from",
"Tree",
"by",
"its",
"name",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/ADT/Tree/Node.php#L118-L124 |
37,514 | CeusMedia/Common | src/Alg/Sort/MapList.php | Alg_Sort_MapList.sort | public static function sort( $data, $key, $direction = self::DIRECTION_ASC )
{
return self::sortByMultipleColumns( $data, array( $key => $direction ) );
} | php | public static function sort( $data, $key, $direction = self::DIRECTION_ASC )
{
return self::sortByMultipleColumns( $data, array( $key => $direction ) );
} | [
"public",
"static",
"function",
"sort",
"(",
"$",
"data",
",",
"$",
"key",
",",
"$",
"direction",
"=",
"self",
"::",
"DIRECTION_ASC",
")",
"{",
"return",
"self",
"::",
"sortByMultipleColumns",
"(",
"$",
"data",
",",
"array",
"(",
"$",
"key",
"=>",
"$",
"direction",
")",
")",
";",
"}"
] | Sorts a List of associative Arrays by a Column and Direction.
@access public
@static
@param array $data List of associative Arrays
@param string $key Column to sort by
@param int $direction Sort Direction (0 - ::DIRECTION_ASC | 1 - ::DIRECTION_DESC)
@return array | [
"Sorts",
"a",
"List",
"of",
"associative",
"Arrays",
"by",
"a",
"Column",
"and",
"Direction",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/MapList.php#L52-L55 |
37,515 | CeusMedia/Common | src/Alg/Sort/MapList.php | Alg_Sort_MapList.sortByMultipleColumns | public static function sortByMultipleColumns( $data, $orders )
{
$key = array_shift( array_keys( $orders ) ); // get first Column
$direction = $orders[$key]; // get first Diection
$orders = array_slice( $orders, 1 ); // remove Order from Order Map
$list = array(); // prepare Index List
foreach( $data as $entry ) // iterate Data Array
$list[$entry[$key]][] = $entry; // index by Column Key
if( $direction == self::DIRECTION_ASC ) // ascending
ksort( $list ); // sort Index List
else // descending
krsort( $list ); // reverse sort Index List
$array = array(); // prepare new Data Array
foreach( $list as $entries ) // iterate Index List
{
if( $orders && count( $entries ) > 1 )
$entries = self::sortByMultipleColumns( $entries, $orders );
foreach( $entries as $entry) // ...
$array[] = $entry; // fill new Data Array
}
return $array; // return new Data Array
} | php | public static function sortByMultipleColumns( $data, $orders )
{
$key = array_shift( array_keys( $orders ) ); // get first Column
$direction = $orders[$key]; // get first Diection
$orders = array_slice( $orders, 1 ); // remove Order from Order Map
$list = array(); // prepare Index List
foreach( $data as $entry ) // iterate Data Array
$list[$entry[$key]][] = $entry; // index by Column Key
if( $direction == self::DIRECTION_ASC ) // ascending
ksort( $list ); // sort Index List
else // descending
krsort( $list ); // reverse sort Index List
$array = array(); // prepare new Data Array
foreach( $list as $entries ) // iterate Index List
{
if( $orders && count( $entries ) > 1 )
$entries = self::sortByMultipleColumns( $entries, $orders );
foreach( $entries as $entry) // ...
$array[] = $entry; // fill new Data Array
}
return $array; // return new Data Array
} | [
"public",
"static",
"function",
"sortByMultipleColumns",
"(",
"$",
"data",
",",
"$",
"orders",
")",
"{",
"$",
"key",
"=",
"array_shift",
"(",
"array_keys",
"(",
"$",
"orders",
")",
")",
";",
"// get first Column",
"$",
"direction",
"=",
"$",
"orders",
"[",
"$",
"key",
"]",
";",
"// get first Diection",
"$",
"orders",
"=",
"array_slice",
"(",
"$",
"orders",
",",
"1",
")",
";",
"// remove Order from Order Map",
"$",
"list",
"=",
"array",
"(",
")",
";",
"// prepare Index List",
"foreach",
"(",
"$",
"data",
"as",
"$",
"entry",
")",
"// iterate Data Array",
"$",
"list",
"[",
"$",
"entry",
"[",
"$",
"key",
"]",
"]",
"[",
"]",
"=",
"$",
"entry",
";",
"// index by Column Key",
"if",
"(",
"$",
"direction",
"==",
"self",
"::",
"DIRECTION_ASC",
")",
"// ascending",
"ksort",
"(",
"$",
"list",
")",
";",
"// sort Index List",
"else",
"// descending",
"krsort",
"(",
"$",
"list",
")",
";",
"// reverse sort Index List",
"$",
"array",
"=",
"array",
"(",
")",
";",
"// prepare new Data Array",
"foreach",
"(",
"$",
"list",
"as",
"$",
"entries",
")",
"// iterate Index List",
"{",
"if",
"(",
"$",
"orders",
"&&",
"count",
"(",
"$",
"entries",
")",
">",
"1",
")",
"$",
"entries",
"=",
"self",
"::",
"sortByMultipleColumns",
"(",
"$",
"entries",
",",
"$",
"orders",
")",
";",
"foreach",
"(",
"$",
"entries",
"as",
"$",
"entry",
")",
"// ...",
"$",
"array",
"[",
"]",
"=",
"$",
"entry",
";",
"// fill new Data Array",
"}",
"return",
"$",
"array",
";",
"// return new Data Array",
"}"
] | Sorts a List of associative Arrays by several Columns and Directions.
@access public
@static
@param array $data List of associative Arrays
@param string $order Map of Columns and their Directions (0 - ::DIRECTION_ASC | 1 - ::DIRECTION_DESC)
@return array | [
"Sorts",
"a",
"List",
"of",
"associative",
"Arrays",
"by",
"several",
"Columns",
"and",
"Directions",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Sort/MapList.php#L65-L87 |
37,516 | CeusMedia/Common | src/Alg/Math/Finance/CompoundInterest.php | Alg_Math_Finance_CompoundInterest.calculateFutureAmount | public static function calculateFutureAmount( $amount, $interest, $periods )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( (int) $periods < 1 )
throw new InvalidArgumentException( "Periods must be at least 1." );
$result = $amount * pow( ( 1 + $interest / 100 ), (int) $periods );
return $result;
} | php | public static function calculateFutureAmount( $amount, $interest, $periods )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( (int) $periods < 1 )
throw new InvalidArgumentException( "Periods must be at least 1." );
$result = $amount * pow( ( 1 + $interest / 100 ), (int) $periods );
return $result;
} | [
"public",
"static",
"function",
"calculateFutureAmount",
"(",
"$",
"amount",
",",
"$",
"interest",
",",
"$",
"periods",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Please use %s (%s) instead'",
",",
"'public library \"CeusMedia/Math\"'",
",",
"'https://packagist.org/packages/ceus-media/math'",
")",
")",
";",
"if",
"(",
"(",
"int",
")",
"$",
"periods",
"<",
"1",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Periods must be at least 1.\"",
")",
";",
"$",
"result",
"=",
"$",
"amount",
"*",
"pow",
"(",
"(",
"1",
"+",
"$",
"interest",
"/",
"100",
")",
",",
"(",
"int",
")",
"$",
"periods",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Calculates Present Amount from Future Amount statically.
@access public
@static
@param float $amount Amount to calculate with
@param float $interest Interest per Period
@param int $periods Number of Periods
@return float | [
"Calculates",
"Present",
"Amount",
"from",
"Future",
"Amount",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L69-L83 |
37,517 | CeusMedia/Common | src/Alg/Math/Finance/CompoundInterest.php | Alg_Math_Finance_CompoundInterest.calculateInterest | public static function calculateInterest( $presentAmount, $futureAmount, $periods )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( (int) $periods < 1 )
throw new InvalidArgumentException( "Periods must be at least 1." );
$i = self::root( $futureAmount / $presentAmount, $periods ) - 1;
$result = $i * 100;
return $result;
} | php | public static function calculateInterest( $presentAmount, $futureAmount, $periods )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( (int) $periods < 1 )
throw new InvalidArgumentException( "Periods must be at least 1." );
$i = self::root( $futureAmount / $presentAmount, $periods ) - 1;
$result = $i * 100;
return $result;
} | [
"public",
"static",
"function",
"calculateInterest",
"(",
"$",
"presentAmount",
",",
"$",
"futureAmount",
",",
"$",
"periods",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Please use %s (%s) instead'",
",",
"'public library \"CeusMedia/Math\"'",
",",
"'https://packagist.org/packages/ceus-media/math'",
")",
")",
";",
"if",
"(",
"(",
"int",
")",
"$",
"periods",
"<",
"1",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Periods must be at least 1.\"",
")",
";",
"$",
"i",
"=",
"self",
"::",
"root",
"(",
"$",
"futureAmount",
"/",
"$",
"presentAmount",
",",
"$",
"periods",
")",
"-",
"1",
";",
"$",
"result",
"=",
"$",
"i",
"*",
"100",
";",
"return",
"$",
"result",
";",
"}"
] | Calculates Future Amount from Present Amount statically.
@access public
@static
@param float $amount Amount to calculate with
@param float $interest Interest per Period
@param int $periods Number of Periods
@return float | [
"Calculates",
"Future",
"Amount",
"from",
"Present",
"Amount",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L94-L109 |
37,518 | CeusMedia/Common | src/Alg/Math/Finance/CompoundInterest.php | Alg_Math_Finance_CompoundInterest.getFutureAmount | public function getFutureAmount( $change = FALSE )
{
$result = self::calculateFutureAmount( $this->amount, $this->interest, $this->periods );
if( $change )
$this->amount = $result;
return $result;
} | php | public function getFutureAmount( $change = FALSE )
{
$result = self::calculateFutureAmount( $this->amount, $this->interest, $this->periods );
if( $change )
$this->amount = $result;
return $result;
} | [
"public",
"function",
"getFutureAmount",
"(",
"$",
"change",
"=",
"FALSE",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"calculateFutureAmount",
"(",
"$",
"this",
"->",
"amount",
",",
"$",
"this",
"->",
"interest",
",",
"$",
"this",
"->",
"periods",
")",
";",
"if",
"(",
"$",
"change",
")",
"$",
"this",
"->",
"amount",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}"
] | Calculates and returns Future Amount from Present Amount.
@access public
@return float | [
"Calculates",
"and",
"returns",
"Future",
"Amount",
"from",
"Present",
"Amount",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L167-L173 |
37,519 | CeusMedia/Common | src/Alg/Math/Finance/CompoundInterest.php | Alg_Math_Finance_CompoundInterest.getInterestFromFutureAmount | public function getInterestFromFutureAmount( $futureAmount, $change = FALSE )
{
$result = self::calculateInterest( $this->amount, $futureAmount, $this->periods );
if( $change )
$this->periods = round( $result );
return $result;
} | php | public function getInterestFromFutureAmount( $futureAmount, $change = FALSE )
{
$result = self::calculateInterest( $this->amount, $futureAmount, $this->periods );
if( $change )
$this->periods = round( $result );
return $result;
} | [
"public",
"function",
"getInterestFromFutureAmount",
"(",
"$",
"futureAmount",
",",
"$",
"change",
"=",
"FALSE",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"calculateInterest",
"(",
"$",
"this",
"->",
"amount",
",",
"$",
"futureAmount",
",",
"$",
"this",
"->",
"periods",
")",
";",
"if",
"(",
"$",
"change",
")",
"$",
"this",
"->",
"periods",
"=",
"round",
"(",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Calculates and returns Interest from Future Amount.
@access public
@return float | [
"Calculates",
"and",
"returns",
"Interest",
"from",
"Future",
"Amount",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L190-L196 |
37,520 | CeusMedia/Common | src/Alg/Math/Finance/CompoundInterest.php | Alg_Math_Finance_CompoundInterest.getPresentAmount | public function getPresentAmount( $change = FALSE )
{
$result = self::calculatePresentAmount( $this->amount, $this->interest, $this->periods );
if( $change )
$this->amount = $result;
return $result;
} | php | public function getPresentAmount( $change = FALSE )
{
$result = self::calculatePresentAmount( $this->amount, $this->interest, $this->periods );
if( $change )
$this->amount = $result;
return $result;
} | [
"public",
"function",
"getPresentAmount",
"(",
"$",
"change",
"=",
"FALSE",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"calculatePresentAmount",
"(",
"$",
"this",
"->",
"amount",
",",
"$",
"this",
"->",
"interest",
",",
"$",
"this",
"->",
"periods",
")",
";",
"if",
"(",
"$",
"change",
")",
"$",
"this",
"->",
"amount",
"=",
"$",
"result",
";",
"return",
"$",
"result",
";",
"}"
] | Calculates and returns Present Amount from Future Amount.
@access public
@return float | [
"Calculates",
"and",
"returns",
"Present",
"Amount",
"from",
"Future",
"Amount",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L226-L232 |
37,521 | CeusMedia/Common | src/Alg/Math/Finance/CompoundInterest.php | Alg_Math_Finance_CompoundInterest.root | protected static function root( $amount, $periods )
{
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'
) );
$sign = ( $amount < 0 && $periods % 2 > 0 ) ? -1 : 1;
$value = pow( abs( $amount ), 1 / $periods );
return $sign * $value;
} | php | protected static function root( $amount, $periods )
{
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'
) );
$sign = ( $amount < 0 && $periods % 2 > 0 ) ? -1 : 1;
$value = pow( abs( $amount ), 1 / $periods );
return $sign * $value;
} | [
"protected",
"static",
"function",
"root",
"(",
"$",
"amount",
",",
"$",
"periods",
")",
"{",
"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'",
")",
")",
";",
"$",
"sign",
"=",
"(",
"$",
"amount",
"<",
"0",
"&&",
"$",
"periods",
"%",
"2",
">",
"0",
")",
"?",
"-",
"1",
":",
"1",
";",
"$",
"value",
"=",
"pow",
"(",
"abs",
"(",
"$",
"amount",
")",
",",
"1",
"/",
"$",
"periods",
")",
";",
"return",
"$",
"sign",
"*",
"$",
"value",
";",
"}"
] | Calculates Root of Period Dimension.
@access protected
@static
@param float $amount Amount
@param int $periods Number of Periods
@return float | [
"Calculates",
"Root",
"of",
"Period",
"Dimension",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Finance/CompoundInterest.php#L242-L255 |
37,522 | CeusMedia/Common | src/CLI/Server/Cron/Parser.php | CLI_Server_Cron_Parser.fill | protected function fill( $value, $length )
{
if( $length && $value != "*" )
{
if( strlen( $value ) < $length )
{
$diff = $length - strlen( $value );
for( $i=0; $i<$diff; $i++ )
$value = "0".$value;
}
}
return $value;
} | php | protected function fill( $value, $length )
{
if( $length && $value != "*" )
{
if( strlen( $value ) < $length )
{
$diff = $length - strlen( $value );
for( $i=0; $i<$diff; $i++ )
$value = "0".$value;
}
}
return $value;
} | [
"protected",
"function",
"fill",
"(",
"$",
"value",
",",
"$",
"length",
")",
"{",
"if",
"(",
"$",
"length",
"&&",
"$",
"value",
"!=",
"\"*\"",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
"<",
"$",
"length",
")",
"{",
"$",
"diff",
"=",
"$",
"length",
"-",
"strlen",
"(",
"$",
"value",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"diff",
";",
"$",
"i",
"++",
")",
"$",
"value",
"=",
"\"0\"",
".",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"value",
";",
"}"
] | Fills numbers with leading Zeros.
@access protected
@param string $value Number to be filled
@param length $int Length to fill to
@return string | [
"Fills",
"numbers",
"with",
"leading",
"Zeros",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L65-L77 |
37,523 | CeusMedia/Common | src/CLI/Server/Cron/Parser.php | CLI_Server_Cron_Parser.getValues | protected function getValues( $value, $fill = 0 )
{
$values = array();
if( substr_count( $value, "-" ) )
{
$parts = explode( "-", $value );
$min = trim( min( $parts ) );
$max = trim( max( $parts ) );
for( $i=$min; $i<=$max; $i++ )
$values[] = $this->fill( $i, $fill );
}
else if( substr_count( $value, "," ) )
{
$parts = explode( ",", $value );
foreach( $parts as $part )
$values[] = $this->fill( $part, $fill );
}
else $values[] = $this->fill( $value, $fill );
return $values;
} | php | protected function getValues( $value, $fill = 0 )
{
$values = array();
if( substr_count( $value, "-" ) )
{
$parts = explode( "-", $value );
$min = trim( min( $parts ) );
$max = trim( max( $parts ) );
for( $i=$min; $i<=$max; $i++ )
$values[] = $this->fill( $i, $fill );
}
else if( substr_count( $value, "," ) )
{
$parts = explode( ",", $value );
foreach( $parts as $part )
$values[] = $this->fill( $part, $fill );
}
else $values[] = $this->fill( $value, $fill );
return $values;
} | [
"protected",
"function",
"getValues",
"(",
"$",
"value",
",",
"$",
"fill",
"=",
"0",
")",
"{",
"$",
"values",
"=",
"array",
"(",
")",
";",
"if",
"(",
"substr_count",
"(",
"$",
"value",
",",
"\"-\"",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\"-\"",
",",
"$",
"value",
")",
";",
"$",
"min",
"=",
"trim",
"(",
"min",
"(",
"$",
"parts",
")",
")",
";",
"$",
"max",
"=",
"trim",
"(",
"max",
"(",
"$",
"parts",
")",
")",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"min",
";",
"$",
"i",
"<=",
"$",
"max",
";",
"$",
"i",
"++",
")",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"fill",
"(",
"$",
"i",
",",
"$",
"fill",
")",
";",
"}",
"else",
"if",
"(",
"substr_count",
"(",
"$",
"value",
",",
"\",\"",
")",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"\",\"",
",",
"$",
"value",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"fill",
"(",
"$",
"part",
",",
"$",
"fill",
")",
";",
"}",
"else",
"$",
"values",
"[",
"]",
"=",
"$",
"this",
"->",
"fill",
"(",
"$",
"value",
",",
"$",
"fill",
")",
";",
"return",
"$",
"values",
";",
"}"
] | Parses one numeric entry of Cron Job.
@access protected
@param string $string One numeric entry of Cron Job
@return void | [
"Parses",
"one",
"numeric",
"entry",
"of",
"Cron",
"Job",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L95-L114 |
37,524 | CeusMedia/Common | src/CLI/Server/Cron/Parser.php | CLI_Server_Cron_Parser.parse | protected function parse( $fileName )
{
if( !file_exists( $fileName ) )
throw new Exception( "Cron Tab File '".$fileName."' is not existing." );
$reader = new FS_File_Reader( $fileName );
$lines = $reader->readArray();
$lines = file( $fileName );
foreach( $lines as $line )
if( trim( $line ) && !preg_match( "@^#@", $line ) )
$this->parseJob( $line );
} | php | protected function parse( $fileName )
{
if( !file_exists( $fileName ) )
throw new Exception( "Cron Tab File '".$fileName."' is not existing." );
$reader = new FS_File_Reader( $fileName );
$lines = $reader->readArray();
$lines = file( $fileName );
foreach( $lines as $line )
if( trim( $line ) && !preg_match( "@^#@", $line ) )
$this->parseJob( $line );
} | [
"protected",
"function",
"parse",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Cron Tab File '\"",
".",
"$",
"fileName",
".",
"\"' is not existing.\"",
")",
";",
"$",
"reader",
"=",
"new",
"FS_File_Reader",
"(",
"$",
"fileName",
")",
";",
"$",
"lines",
"=",
"$",
"reader",
"->",
"readArray",
"(",
")",
";",
"$",
"lines",
"=",
"file",
"(",
"$",
"fileName",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"if",
"(",
"trim",
"(",
"$",
"line",
")",
"&&",
"!",
"preg_match",
"(",
"\"@^#@\"",
",",
"$",
"line",
")",
")",
"$",
"this",
"->",
"parseJob",
"(",
"$",
"line",
")",
";",
"}"
] | Parses Cron Tab File.
@access protected
@param string $fileName Cron Tab File
@return void | [
"Parses",
"Cron",
"Tab",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L122-L132 |
37,525 | CeusMedia/Common | src/CLI/Server/Cron/Parser.php | CLI_Server_Cron_Parser.parseJob | protected function parseJob( $string )
{
$pattern = "@^( |\t)*(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(.*)(\r)?\n$@si";
if( preg_match( $pattern, $string ) )
{
$match = preg_replace( $pattern, "\\2|||\\4|||\\6|||\\8|||\\10|||\\12", $string );
$match = explode( "|||", $match );
$job = new CLI_Server_Cron_Job( $match[5] );
$job->setOption( "minute", $this->getValues( $match[0], 2 ) );
$job->setOption( "hour", $this->getValues( $match[1], 2 ) );
$job->setOption( "day", $this->getValues( $match[2], 2 ) );
$job->setOption( "month", $this->getValues( $match[3], 2 ) );
$job->setOption( "weekday", $this->getValues( $match[4] ) );
$this->jobs[] = $job;
}
} | php | protected function parseJob( $string )
{
$pattern = "@^( |\t)*(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(\*|[0-9,-]+)( |\t)+(.*)(\r)?\n$@si";
if( preg_match( $pattern, $string ) )
{
$match = preg_replace( $pattern, "\\2|||\\4|||\\6|||\\8|||\\10|||\\12", $string );
$match = explode( "|||", $match );
$job = new CLI_Server_Cron_Job( $match[5] );
$job->setOption( "minute", $this->getValues( $match[0], 2 ) );
$job->setOption( "hour", $this->getValues( $match[1], 2 ) );
$job->setOption( "day", $this->getValues( $match[2], 2 ) );
$job->setOption( "month", $this->getValues( $match[3], 2 ) );
$job->setOption( "weekday", $this->getValues( $match[4] ) );
$this->jobs[] = $job;
}
} | [
"protected",
"function",
"parseJob",
"(",
"$",
"string",
")",
"{",
"$",
"pattern",
"=",
"\"@^( |\\t)*(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(\\*|[0-9,-]+)( |\\t)+(.*)(\\r)?\\n$@si\"",
";",
"if",
"(",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"string",
")",
")",
"{",
"$",
"match",
"=",
"preg_replace",
"(",
"$",
"pattern",
",",
"\"\\\\2|||\\\\4|||\\\\6|||\\\\8|||\\\\10|||\\\\12\"",
",",
"$",
"string",
")",
";",
"$",
"match",
"=",
"explode",
"(",
"\"|||\"",
",",
"$",
"match",
")",
";",
"$",
"job",
"=",
"new",
"CLI_Server_Cron_Job",
"(",
"$",
"match",
"[",
"5",
"]",
")",
";",
"$",
"job",
"->",
"setOption",
"(",
"\"minute\"",
",",
"$",
"this",
"->",
"getValues",
"(",
"$",
"match",
"[",
"0",
"]",
",",
"2",
")",
")",
";",
"$",
"job",
"->",
"setOption",
"(",
"\"hour\"",
",",
"$",
"this",
"->",
"getValues",
"(",
"$",
"match",
"[",
"1",
"]",
",",
"2",
")",
")",
";",
"$",
"job",
"->",
"setOption",
"(",
"\"day\"",
",",
"$",
"this",
"->",
"getValues",
"(",
"$",
"match",
"[",
"2",
"]",
",",
"2",
")",
")",
";",
"$",
"job",
"->",
"setOption",
"(",
"\"month\"",
",",
"$",
"this",
"->",
"getValues",
"(",
"$",
"match",
"[",
"3",
"]",
",",
"2",
")",
")",
";",
"$",
"job",
"->",
"setOption",
"(",
"\"weekday\"",
",",
"$",
"this",
"->",
"getValues",
"(",
"$",
"match",
"[",
"4",
"]",
")",
")",
";",
"$",
"this",
"->",
"jobs",
"[",
"]",
"=",
"$",
"job",
";",
"}",
"}"
] | Parses one entry of Cron Tab File.
@access protected
@param string $string One entry of Cron Tab File
@return void | [
"Parses",
"one",
"entry",
"of",
"Cron",
"Tab",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/CLI/Server/Cron/Parser.php#L140-L155 |
37,526 | CeusMedia/Common | src/UI/HTML/Tabs.php | UI_HTML_Tabs.addTab | public function addTab( $label, $content, $fragmentKey = NULL )
{
if( is_null( $fragmentKey ) )
{
$this->tabs[] = $label;
$this->divs[] = $content;
}
else
{
if( isset( $this->tabs[$fragmentKey] ) )
throw new Exception( 'Tab with Fragment ID "'.$fragmentKey.'" is already set' );
$this->tabs[$fragmentKey] = $label;
$this->divs[$fragmentKey] = $content;
}
} | php | public function addTab( $label, $content, $fragmentKey = NULL )
{
if( is_null( $fragmentKey ) )
{
$this->tabs[] = $label;
$this->divs[] = $content;
}
else
{
if( isset( $this->tabs[$fragmentKey] ) )
throw new Exception( 'Tab with Fragment ID "'.$fragmentKey.'" is already set' );
$this->tabs[$fragmentKey] = $label;
$this->divs[$fragmentKey] = $content;
}
} | [
"public",
"function",
"addTab",
"(",
"$",
"label",
",",
"$",
"content",
",",
"$",
"fragmentKey",
"=",
"NULL",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fragmentKey",
")",
")",
"{",
"$",
"this",
"->",
"tabs",
"[",
"]",
"=",
"$",
"label",
";",
"$",
"this",
"->",
"divs",
"[",
"]",
"=",
"$",
"content",
";",
"}",
"else",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"tabs",
"[",
"$",
"fragmentKey",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Tab with Fragment ID \"'",
".",
"$",
"fragmentKey",
".",
"'\" is already set'",
")",
";",
"$",
"this",
"->",
"tabs",
"[",
"$",
"fragmentKey",
"]",
"=",
"$",
"label",
";",
"$",
"this",
"->",
"divs",
"[",
"$",
"fragmentKey",
"]",
"=",
"$",
"content",
";",
"}",
"}"
] | Adds a new Tab by its Label and Content.
@access public
@param string $label Label of Tab
@param string $content Content related to Tab
@return void | [
"Adds",
"a",
"new",
"Tab",
"by",
"its",
"Label",
"and",
"Content",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L80-L94 |
37,527 | CeusMedia/Common | src/UI/HTML/Tabs.php | UI_HTML_Tabs.addTabs | public function addTabs( $tabs = array() )
{
if( !is_array( $tabs ) )
throw new InvalidArgumentException( 'Tabs must be given as array of labels and contents.' );
foreach( $tabs as $label => $content )
$this->addTab( $label, $content );
} | php | public function addTabs( $tabs = array() )
{
if( !is_array( $tabs ) )
throw new InvalidArgumentException( 'Tabs must be given as array of labels and contents.' );
foreach( $tabs as $label => $content )
$this->addTab( $label, $content );
} | [
"public",
"function",
"addTabs",
"(",
"$",
"tabs",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"tabs",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Tabs must be given as array of labels and contents.'",
")",
";",
"foreach",
"(",
"$",
"tabs",
"as",
"$",
"label",
"=>",
"$",
"content",
")",
"$",
"this",
"->",
"addTab",
"(",
"$",
"label",
",",
"$",
"content",
")",
";",
"}"
] | Constructor, can set Tabs.
@access public
@param array $tabs Array of Labels and Contents
@return void | [
"Constructor",
"can",
"set",
"Tabs",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L102-L108 |
37,528 | CeusMedia/Common | src/UI/HTML/Tabs.php | UI_HTML_Tabs.buildScript | public function buildScript( $selector, $options = array() )
{
$options = array_merge( $this->options, $options );
return self::createScript( $selector, $options );
} | php | public function buildScript( $selector, $options = array() )
{
$options = array_merge( $this->options, $options );
return self::createScript( $selector, $options );
} | [
"public",
"function",
"buildScript",
"(",
"$",
"selector",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
";",
"return",
"self",
"::",
"createScript",
"(",
"$",
"selector",
",",
"$",
"options",
")",
";",
"}"
] | Creates JavaScript Call, applying afore set Options and given Options.
@access public
@param string $selector jQuery Selector of Tabs DIV (mostly '#' + ID)
@param array $options Tabs Options Array, additional to afore set Options
@return string
@link http://stilbuero.de/jquery/tabs/ | [
"Creates",
"JavaScript",
"Call",
"applying",
"afore",
"set",
"Options",
"and",
"given",
"Options",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L118-L122 |
37,529 | CeusMedia/Common | src/UI/HTML/Tabs.php | UI_HTML_Tabs.buildTabs | public function buildTabs( $id, $class = NULL )
{
if( empty( $class ) && !empty( $this->options['navClass'] ) )
$class = $this->options['navClass'];
return self::createTabs( $id, $this->tabs, $this->divs, $class );
} | php | public function buildTabs( $id, $class = NULL )
{
if( empty( $class ) && !empty( $this->options['navClass'] ) )
$class = $this->options['navClass'];
return self::createTabs( $id, $this->tabs, $this->divs, $class );
} | [
"public",
"function",
"buildTabs",
"(",
"$",
"id",
",",
"$",
"class",
"=",
"NULL",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"class",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'navClass'",
"]",
")",
")",
"$",
"class",
"=",
"$",
"this",
"->",
"options",
"[",
"'navClass'",
"]",
";",
"return",
"self",
"::",
"createTabs",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"tabs",
",",
"$",
"this",
"->",
"divs",
",",
"$",
"class",
")",
";",
"}"
] | Builds HTML Code of Tabbed Content.
@access public
@param string $id ID of whole Tabbed Content Block
@param string $class CSS Class of Tabs DIV (main container)
@return string | [
"Builds",
"HTML",
"Code",
"of",
"Tabbed",
"Content",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L131-L136 |
37,530 | CeusMedia/Common | src/UI/HTML/Tabs.php | UI_HTML_Tabs.createTabs | public static function createTabs( $id, $labels = array(), $contents = array(), $class = NULL )
{
if( count( $labels ) != count( $contents ) )
throw new Exception( 'Number of labels and contents is not equal.' );
$belowV3 = version_compare( 3, self::$version );
$urlPrefix = ( $belowV3 && getEnv( 'REDIRECT_URL' ) ) ? getEnv( 'REDIRECT_URL' ) : '';
$tabs = array();
$divs = array();
$labels = $labels;
$contents = $contents;
foreach( $labels as $index => $label )
{
$tabKey = is_int( $index ) ? 'tab-'.$index : $index;
$divKey = $index."-container";
$url = $urlPrefix."#".$divKey;
$label = UI_HTML_Tag::create( 'span', $label );
$link = UI_HTML_Tag::create( 'a', $label, array( 'href' => $url ) );
$tabs[] = UI_HTML_Tag::create( 'li', $link, array( 'id' => $tabKey ) );
$divClass = $class ? $class."-container" : NULL;
$attributes = array( 'id' => $divKey, 'class' => $divClass );
$divs[] = UI_HTML_Tag::create( 'div', $contents[$index], $attributes );
self::$counter++;
}
$tabs = UI_HTML_Tag::create( 'ul', implode( "\n", $tabs ), array( 'class' => $class ) );
$divs = implode( "\n", $divs );
$content = UI_HTML_Tag::create( 'div', $tabs.$divs, array( 'id' => $id ) );
return $content;
} | php | public static function createTabs( $id, $labels = array(), $contents = array(), $class = NULL )
{
if( count( $labels ) != count( $contents ) )
throw new Exception( 'Number of labels and contents is not equal.' );
$belowV3 = version_compare( 3, self::$version );
$urlPrefix = ( $belowV3 && getEnv( 'REDIRECT_URL' ) ) ? getEnv( 'REDIRECT_URL' ) : '';
$tabs = array();
$divs = array();
$labels = $labels;
$contents = $contents;
foreach( $labels as $index => $label )
{
$tabKey = is_int( $index ) ? 'tab-'.$index : $index;
$divKey = $index."-container";
$url = $urlPrefix."#".$divKey;
$label = UI_HTML_Tag::create( 'span', $label );
$link = UI_HTML_Tag::create( 'a', $label, array( 'href' => $url ) );
$tabs[] = UI_HTML_Tag::create( 'li', $link, array( 'id' => $tabKey ) );
$divClass = $class ? $class."-container" : NULL;
$attributes = array( 'id' => $divKey, 'class' => $divClass );
$divs[] = UI_HTML_Tag::create( 'div', $contents[$index], $attributes );
self::$counter++;
}
$tabs = UI_HTML_Tag::create( 'ul', implode( "\n", $tabs ), array( 'class' => $class ) );
$divs = implode( "\n", $divs );
$content = UI_HTML_Tag::create( 'div', $tabs.$divs, array( 'id' => $id ) );
return $content;
} | [
"public",
"static",
"function",
"createTabs",
"(",
"$",
"id",
",",
"$",
"labels",
"=",
"array",
"(",
")",
",",
"$",
"contents",
"=",
"array",
"(",
")",
",",
"$",
"class",
"=",
"NULL",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"labels",
")",
"!=",
"count",
"(",
"$",
"contents",
")",
")",
"throw",
"new",
"Exception",
"(",
"'Number of labels and contents is not equal.'",
")",
";",
"$",
"belowV3",
"=",
"version_compare",
"(",
"3",
",",
"self",
"::",
"$",
"version",
")",
";",
"$",
"urlPrefix",
"=",
"(",
"$",
"belowV3",
"&&",
"getEnv",
"(",
"'REDIRECT_URL'",
")",
")",
"?",
"getEnv",
"(",
"'REDIRECT_URL'",
")",
":",
"''",
";",
"$",
"tabs",
"=",
"array",
"(",
")",
";",
"$",
"divs",
"=",
"array",
"(",
")",
";",
"$",
"labels",
"=",
"$",
"labels",
";",
"$",
"contents",
"=",
"$",
"contents",
";",
"foreach",
"(",
"$",
"labels",
"as",
"$",
"index",
"=>",
"$",
"label",
")",
"{",
"$",
"tabKey",
"=",
"is_int",
"(",
"$",
"index",
")",
"?",
"'tab-'",
".",
"$",
"index",
":",
"$",
"index",
";",
"$",
"divKey",
"=",
"$",
"index",
".",
"\"-container\"",
";",
"$",
"url",
"=",
"$",
"urlPrefix",
".",
"\"#\"",
".",
"$",
"divKey",
";",
"$",
"label",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'span'",
",",
"$",
"label",
")",
";",
"$",
"link",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'a'",
",",
"$",
"label",
",",
"array",
"(",
"'href'",
"=>",
"$",
"url",
")",
")",
";",
"$",
"tabs",
"[",
"]",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'li'",
",",
"$",
"link",
",",
"array",
"(",
"'id'",
"=>",
"$",
"tabKey",
")",
")",
";",
"$",
"divClass",
"=",
"$",
"class",
"?",
"$",
"class",
".",
"\"-container\"",
":",
"NULL",
";",
"$",
"attributes",
"=",
"array",
"(",
"'id'",
"=>",
"$",
"divKey",
",",
"'class'",
"=>",
"$",
"divClass",
")",
";",
"$",
"divs",
"[",
"]",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'div'",
",",
"$",
"contents",
"[",
"$",
"index",
"]",
",",
"$",
"attributes",
")",
";",
"self",
"::",
"$",
"counter",
"++",
";",
"}",
"$",
"tabs",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'ul'",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"tabs",
")",
",",
"array",
"(",
"'class'",
"=>",
"$",
"class",
")",
")",
";",
"$",
"divs",
"=",
"implode",
"(",
"\"\\n\"",
",",
"$",
"divs",
")",
";",
"$",
"content",
"=",
"UI_HTML_Tag",
"::",
"create",
"(",
"'div'",
",",
"$",
"tabs",
".",
"$",
"divs",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
")",
")",
";",
"return",
"$",
"content",
";",
"}"
] | Builds HTML Code of Tabbed Content statically.
@access public
@static
@param string $id ID of whole Tabbed Content Block
@param array $label List of Tab Labels
@param array $contents List of Contents related to the Tabs
@param string $class CSS Class of Tabs DIV (main container)
@return string | [
"Builds",
"HTML",
"Code",
"of",
"Tabbed",
"Content",
"statically",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/UI/HTML/Tabs.php#L162-L191 |
37,531 | fxpio/fxp-resource-bundle | DependencyInjection/Compiler/ConverterPass.php | ConverterPass.getRealValue | protected function getRealValue(ContainerBuilder $container, $value)
{
return 0 === strpos($value, '%') ? $container->getParameter(trim($value, '%')) : $value;
} | php | protected function getRealValue(ContainerBuilder $container, $value)
{
return 0 === strpos($value, '%') ? $container->getParameter(trim($value, '%')) : $value;
} | [
"protected",
"function",
"getRealValue",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"value",
")",
"{",
"return",
"0",
"===",
"strpos",
"(",
"$",
"value",
",",
"'%'",
")",
"?",
"$",
"container",
"->",
"getParameter",
"(",
"trim",
"(",
"$",
"value",
",",
"'%'",
")",
")",
":",
"$",
"value",
";",
"}"
] | Get the real value.
@param ContainerBuilder $container The container
@param mixed $value The value or parameter name
@return mixed | [
"Get",
"the",
"real",
"value",
"."
] | a6549ad2013fe751f20c0619382d0589d0d549d7 | https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/ConverterPass.php#L46-L49 |
37,532 | fxpio/fxp-resource-bundle | DependencyInjection/Compiler/ConverterPass.php | ConverterPass.getType | protected function getType(ContainerBuilder $container, $serviceId)
{
$def = $container->getDefinition($serviceId);
$class = $this->getRealValue($container, $def->getClass());
$interfaces = class_implements($class);
$error = sprintf('The service id "%s" must be an class implementing the "%s" interface.', $serviceId, ConverterInterface::class);
if (\in_array(ConverterInterface::class, $interfaces, true)) {
$ref = new \ReflectionClass($class);
/** @var ConverterInterface $instance */
$instance = $ref->newInstanceWithoutConstructor();
$type = $instance->getName();
if ($type) {
return $type;
}
$error = sprintf('The service id "%s" must have the "type" parameter in the "fxp_resource.converter" tag.', $serviceId);
}
throw new InvalidConfigurationException($error);
} | php | protected function getType(ContainerBuilder $container, $serviceId)
{
$def = $container->getDefinition($serviceId);
$class = $this->getRealValue($container, $def->getClass());
$interfaces = class_implements($class);
$error = sprintf('The service id "%s" must be an class implementing the "%s" interface.', $serviceId, ConverterInterface::class);
if (\in_array(ConverterInterface::class, $interfaces, true)) {
$ref = new \ReflectionClass($class);
/** @var ConverterInterface $instance */
$instance = $ref->newInstanceWithoutConstructor();
$type = $instance->getName();
if ($type) {
return $type;
}
$error = sprintf('The service id "%s" must have the "type" parameter in the "fxp_resource.converter" tag.', $serviceId);
}
throw new InvalidConfigurationException($error);
} | [
"protected",
"function",
"getType",
"(",
"ContainerBuilder",
"$",
"container",
",",
"$",
"serviceId",
")",
"{",
"$",
"def",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"$",
"serviceId",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getRealValue",
"(",
"$",
"container",
",",
"$",
"def",
"->",
"getClass",
"(",
")",
")",
";",
"$",
"interfaces",
"=",
"class_implements",
"(",
"$",
"class",
")",
";",
"$",
"error",
"=",
"sprintf",
"(",
"'The service id \"%s\" must be an class implementing the \"%s\" interface.'",
",",
"$",
"serviceId",
",",
"ConverterInterface",
"::",
"class",
")",
";",
"if",
"(",
"\\",
"in_array",
"(",
"ConverterInterface",
"::",
"class",
",",
"$",
"interfaces",
",",
"true",
")",
")",
"{",
"$",
"ref",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"/** @var ConverterInterface $instance */",
"$",
"instance",
"=",
"$",
"ref",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"$",
"type",
"=",
"$",
"instance",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"$",
"type",
")",
"{",
"return",
"$",
"type",
";",
"}",
"$",
"error",
"=",
"sprintf",
"(",
"'The service id \"%s\" must have the \"type\" parameter in the \"fxp_resource.converter\" tag.'",
",",
"$",
"serviceId",
")",
";",
"}",
"throw",
"new",
"InvalidConfigurationException",
"(",
"$",
"error",
")",
";",
"}"
] | Get the converter type name.
@param ContainerBuilder $container The container builder
@param string $serviceId The service id of converter
@throws InvalidConfigurationException When the converter name is not got
@return string | [
"Get",
"the",
"converter",
"type",
"name",
"."
] | a6549ad2013fe751f20c0619382d0589d0d549d7 | https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/ConverterPass.php#L61-L82 |
37,533 | fxpio/fxp-resource-bundle | DependencyInjection/Compiler/ConverterPass.php | ConverterPass.findConverters | private function findConverters(ContainerBuilder $container)
{
$converters = [];
foreach ($container->findTaggedServiceIds('fxp_resource.converter') as $serviceId => $tag) {
$type = isset($tag[0]['type']) ? $this->getRealValue($container, $tag[0]['type']) : $this->getType($container, $serviceId);
$converters[$type] = $container->getDefinition($serviceId);
}
return array_values($converters);
} | php | private function findConverters(ContainerBuilder $container)
{
$converters = [];
foreach ($container->findTaggedServiceIds('fxp_resource.converter') as $serviceId => $tag) {
$type = isset($tag[0]['type']) ? $this->getRealValue($container, $tag[0]['type']) : $this->getType($container, $serviceId);
$converters[$type] = $container->getDefinition($serviceId);
}
return array_values($converters);
} | [
"private",
"function",
"findConverters",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"converters",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"container",
"->",
"findTaggedServiceIds",
"(",
"'fxp_resource.converter'",
")",
"as",
"$",
"serviceId",
"=>",
"$",
"tag",
")",
"{",
"$",
"type",
"=",
"isset",
"(",
"$",
"tag",
"[",
"0",
"]",
"[",
"'type'",
"]",
")",
"?",
"$",
"this",
"->",
"getRealValue",
"(",
"$",
"container",
",",
"$",
"tag",
"[",
"0",
"]",
"[",
"'type'",
"]",
")",
":",
"$",
"this",
"->",
"getType",
"(",
"$",
"container",
",",
"$",
"serviceId",
")",
";",
"$",
"converters",
"[",
"$",
"type",
"]",
"=",
"$",
"container",
"->",
"getDefinition",
"(",
"$",
"serviceId",
")",
";",
"}",
"return",
"array_values",
"(",
"$",
"converters",
")",
";",
"}"
] | Find the converters.
@param ContainerBuilder $container The container service
@return Definition[] The converter definitions | [
"Find",
"the",
"converters",
"."
] | a6549ad2013fe751f20c0619382d0589d0d549d7 | https://github.com/fxpio/fxp-resource-bundle/blob/a6549ad2013fe751f20c0619382d0589d0d549d7/DependencyInjection/Compiler/ConverterPass.php#L91-L101 |
37,534 | CeusMedia/Common | src/Net/Mail/Transport/Default.php | Net_Mail_Transport_Default.send | public function send( $mail, $parameters = array() )
{
$body = $mail->getBody();
$headers = $mail->getHeaders();
$receiver = $mail->getReceiver();
$subject = $mail->getSubject();
// -- VALIDATION & SECURITY CHECK -- //
$this->checkForInjection( $receiver );
$this->checkForInjection( $subject );
if( !$headers->hasField( 'From' ) )
throw new InvalidArgumentException( 'No mail sender defined' );
if( !$receiver )
throw new InvalidArgumentException( 'No mail receiver defined' );
if( !$subject )
throw new InvalidArgumentException( 'No mail subject defined' );
$subject = "=?UTF-8?B?".base64_encode( $subject )."?=";
/* foreach( $headers as $key => $value )
{
$this->checkForInjection( $key );
$this->checkForInjection( $value );
}
*/
// -- HEADERS -- //
// if( $this->mailer )
$headers->setFieldPair( 'X-Mailer', $this->mailer, TRUE );
$headers->setFieldPair( 'Date', date( 'r' ), TRUE );
if( is_array( $parameters ) )
$parameters = implode( PHP_EOL, $parameters );
if( !mail( $receiver, $subject, $body, $headers->toString(), $parameters ) )
throw new RuntimeException( 'Mail could not been sent' );
} | php | public function send( $mail, $parameters = array() )
{
$body = $mail->getBody();
$headers = $mail->getHeaders();
$receiver = $mail->getReceiver();
$subject = $mail->getSubject();
// -- VALIDATION & SECURITY CHECK -- //
$this->checkForInjection( $receiver );
$this->checkForInjection( $subject );
if( !$headers->hasField( 'From' ) )
throw new InvalidArgumentException( 'No mail sender defined' );
if( !$receiver )
throw new InvalidArgumentException( 'No mail receiver defined' );
if( !$subject )
throw new InvalidArgumentException( 'No mail subject defined' );
$subject = "=?UTF-8?B?".base64_encode( $subject )."?=";
/* foreach( $headers as $key => $value )
{
$this->checkForInjection( $key );
$this->checkForInjection( $value );
}
*/
// -- HEADERS -- //
// if( $this->mailer )
$headers->setFieldPair( 'X-Mailer', $this->mailer, TRUE );
$headers->setFieldPair( 'Date', date( 'r' ), TRUE );
if( is_array( $parameters ) )
$parameters = implode( PHP_EOL, $parameters );
if( !mail( $receiver, $subject, $body, $headers->toString(), $parameters ) )
throw new RuntimeException( 'Mail could not been sent' );
} | [
"public",
"function",
"send",
"(",
"$",
"mail",
",",
"$",
"parameters",
"=",
"array",
"(",
")",
")",
"{",
"$",
"body",
"=",
"$",
"mail",
"->",
"getBody",
"(",
")",
";",
"$",
"headers",
"=",
"$",
"mail",
"->",
"getHeaders",
"(",
")",
";",
"$",
"receiver",
"=",
"$",
"mail",
"->",
"getReceiver",
"(",
")",
";",
"$",
"subject",
"=",
"$",
"mail",
"->",
"getSubject",
"(",
")",
";",
"// -- VALIDATION & SECURITY CHECK -- //",
"$",
"this",
"->",
"checkForInjection",
"(",
"$",
"receiver",
")",
";",
"$",
"this",
"->",
"checkForInjection",
"(",
"$",
"subject",
")",
";",
"if",
"(",
"!",
"$",
"headers",
"->",
"hasField",
"(",
"'From'",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No mail sender defined'",
")",
";",
"if",
"(",
"!",
"$",
"receiver",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No mail receiver defined'",
")",
";",
"if",
"(",
"!",
"$",
"subject",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"'No mail subject defined'",
")",
";",
"$",
"subject",
"=",
"\"=?UTF-8?B?\"",
".",
"base64_encode",
"(",
"$",
"subject",
")",
".",
"\"?=\"",
";",
"/*\t\tforeach( $headers as $key => $value )\n\t\t{\n\t\t\t$this->checkForInjection( $key );\n\t\t\t$this->checkForInjection( $value );\n\t\t}\n*/",
"// -- HEADERS -- //",
"//\t\tif( $this->mailer )",
"$",
"headers",
"->",
"setFieldPair",
"(",
"'X-Mailer'",
",",
"$",
"this",
"->",
"mailer",
",",
"TRUE",
")",
";",
"$",
"headers",
"->",
"setFieldPair",
"(",
"'Date'",
",",
"date",
"(",
"'r'",
")",
",",
"TRUE",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"parameters",
")",
")",
"$",
"parameters",
"=",
"implode",
"(",
"PHP_EOL",
",",
"$",
"parameters",
")",
";",
"if",
"(",
"!",
"mail",
"(",
"$",
"receiver",
",",
"$",
"subject",
",",
"$",
"body",
",",
"$",
"headers",
"->",
"toString",
"(",
")",
",",
"$",
"parameters",
")",
")",
"throw",
"new",
"RuntimeException",
"(",
"'Mail could not been sent'",
")",
";",
"}"
] | Sends Mail.
@access public
@param Net_Mail $mail Mail Object
@param array $parameters Additional mail parameters
@return void
@throws RuntimeException|InvalidArgumentException | [
"Sends",
"Mail",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Mail/Transport/Default.php#L85-L119 |
37,535 | CeusMedia/Common | src/Alg/Math/Factorial.php | Alg_Math_Factorial.calculate | public static function calculate( $integer )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( $integer < 0 )
throw new InvalidArgumentException( "Factorial is defined for positive natural Numbers only" );
else if( !is_int( $integer ) )
throw new InvalidArgumentException( "Factorial is defined for natural Numbers (Integer) only" );
else if( $integer == 0 )
return 1;
else
return $integer * self::calculate( $integer - 1 );
return 0;
} | php | public static function calculate( $integer )
{
Deprecation::getInstance()
->setErrorVersion( '0.8.5' )
->setExceptionVersion( '0.9' )
->message( sprintf(
'Please use %s (%s) instead',
'public library "CeusMedia/Math"',
'https://packagist.org/packages/ceus-media/math'
) );
if( $integer < 0 )
throw new InvalidArgumentException( "Factorial is defined for positive natural Numbers only" );
else if( !is_int( $integer ) )
throw new InvalidArgumentException( "Factorial is defined for natural Numbers (Integer) only" );
else if( $integer == 0 )
return 1;
else
return $integer * self::calculate( $integer - 1 );
return 0;
} | [
"public",
"static",
"function",
"calculate",
"(",
"$",
"integer",
")",
"{",
"Deprecation",
"::",
"getInstance",
"(",
")",
"->",
"setErrorVersion",
"(",
"'0.8.5'",
")",
"->",
"setExceptionVersion",
"(",
"'0.9'",
")",
"->",
"message",
"(",
"sprintf",
"(",
"'Please use %s (%s) instead'",
",",
"'public library \"CeusMedia/Math\"'",
",",
"'https://packagist.org/packages/ceus-media/math'",
")",
")",
";",
"if",
"(",
"$",
"integer",
"<",
"0",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Factorial is defined for positive natural Numbers only\"",
")",
";",
"else",
"if",
"(",
"!",
"is_int",
"(",
"$",
"integer",
")",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"Factorial is defined for natural Numbers (Integer) only\"",
")",
";",
"else",
"if",
"(",
"$",
"integer",
"==",
"0",
")",
"return",
"1",
";",
"else",
"return",
"$",
"integer",
"*",
"self",
"::",
"calculate",
"(",
"$",
"integer",
"-",
"1",
")",
";",
"return",
"0",
";",
"}"
] | Calculates Factorial of Integer recursive and returns Integer or Double.
@access public
@static
@param int $integer Integer (<=170) to calculate Factorial for
@return mixed | [
"Calculates",
"Factorial",
"of",
"Integer",
"recursive",
"and",
"returns",
"Integer",
"or",
"Double",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Math/Factorial.php#L49-L68 |
37,536 | smasty/Neevo | src/Neevo/Manager.php | Manager.select | public function select($columns = null, $table = null){
$result = new Result($this->connection, $columns, $table);
foreach($this->observers as $observer){
$result->attachObserver($observer, $this->observers->getInfo());
}
return $result;
} | php | public function select($columns = null, $table = null){
$result = new Result($this->connection, $columns, $table);
foreach($this->observers as $observer){
$result->attachObserver($observer, $this->observers->getInfo());
}
return $result;
} | [
"public",
"function",
"select",
"(",
"$",
"columns",
"=",
"null",
",",
"$",
"table",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"new",
"Result",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"columns",
",",
"$",
"table",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"observer",
")",
"{",
"$",
"result",
"->",
"attachObserver",
"(",
"$",
"observer",
",",
"$",
"this",
"->",
"observers",
"->",
"getInfo",
"(",
")",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | SELECT statement factory.
@param string|array $columns Array or comma-separated list (optional)
@param string $table
@return Result fluent interface | [
"SELECT",
"statement",
"factory",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L91-L97 |
37,537 | smasty/Neevo | src/Neevo/Manager.php | Manager.insert | public function insert($table, $values){
$statement = Statement::createInsert($this->connection, $table, $values);
foreach($this->observers as $observer){
$statement->attachObserver($observer, $this->observers->getInfo());
}
return $statement;
} | php | public function insert($table, $values){
$statement = Statement::createInsert($this->connection, $table, $values);
foreach($this->observers as $observer){
$statement->attachObserver($observer, $this->observers->getInfo());
}
return $statement;
} | [
"public",
"function",
"insert",
"(",
"$",
"table",
",",
"$",
"values",
")",
"{",
"$",
"statement",
"=",
"Statement",
"::",
"createInsert",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"table",
",",
"$",
"values",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"observer",
")",
"{",
"$",
"statement",
"->",
"attachObserver",
"(",
"$",
"observer",
",",
"$",
"this",
"->",
"observers",
"->",
"getInfo",
"(",
")",
")",
";",
"}",
"return",
"$",
"statement",
";",
"}"
] | INSERT statement factory.
@param string $table
@param array|\Traversable $values
@return Statement fluent interface | [
"INSERT",
"statement",
"factory",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L106-L112 |
37,538 | smasty/Neevo | src/Neevo/Manager.php | Manager.update | public function update($table, $data){
$statement = Statement::createUpdate($this->connection, $table, $data);
foreach($this->observers as $observer){
$statement->attachObserver($observer, $this->observers->getInfo());
}
return $statement;
} | php | public function update($table, $data){
$statement = Statement::createUpdate($this->connection, $table, $data);
foreach($this->observers as $observer){
$statement->attachObserver($observer, $this->observers->getInfo());
}
return $statement;
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"$",
"data",
")",
"{",
"$",
"statement",
"=",
"Statement",
"::",
"createUpdate",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"table",
",",
"$",
"data",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"observer",
")",
"{",
"$",
"statement",
"->",
"attachObserver",
"(",
"$",
"observer",
",",
"$",
"this",
"->",
"observers",
"->",
"getInfo",
"(",
")",
")",
";",
"}",
"return",
"$",
"statement",
";",
"}"
] | UPDATE statement factory.
@param string $table
@param array|\Traversable $data
@return Statement fluent interface | [
"UPDATE",
"statement",
"factory",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L121-L127 |
37,539 | smasty/Neevo | src/Neevo/Manager.php | Manager.delete | public function delete($table){
$statement = Statement::createDelete($this->connection, $table);
foreach($this->observers as $observer){
$statement->attachObserver($observer, $this->observers->getInfo());
}
return $statement;
} | php | public function delete($table){
$statement = Statement::createDelete($this->connection, $table);
foreach($this->observers as $observer){
$statement->attachObserver($observer, $this->observers->getInfo());
}
return $statement;
} | [
"public",
"function",
"delete",
"(",
"$",
"table",
")",
"{",
"$",
"statement",
"=",
"Statement",
"::",
"createDelete",
"(",
"$",
"this",
"->",
"connection",
",",
"$",
"table",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"observers",
"as",
"$",
"observer",
")",
"{",
"$",
"statement",
"->",
"attachObserver",
"(",
"$",
"observer",
",",
"$",
"this",
"->",
"observers",
"->",
"getInfo",
"(",
")",
")",
";",
"}",
"return",
"$",
"statement",
";",
"}"
] | DELETE statement factory.
@param string $table
@return Statement fluent interface | [
"DELETE",
"statement",
"factory",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L135-L141 |
37,540 | smasty/Neevo | src/Neevo/Manager.php | Manager.loadFile | public function loadFile($filename){
$this->connection->connect();
$abort = ignore_user_abort();
@set_time_limit(0);
ignore_user_abort(true);
$handle = @fopen($filename, 'r');
if($handle === false){
ignore_user_abort($abort);
throw new NeevoException("Cannot open file '$filename' for SQL import.");
}
$sql = '';
$count = 0;
while(!feof($handle)){
$content = fgets($handle);
$sql .= $content;
if(substr(rtrim($content), -1) === ';'){
// Passed directly to driver without logging.
$this->connection->getDriver()->runQuery($sql);
$sql = '';
$count++;
}
}
if(trim($sql)){
$this->connection->getDriver()->runQuery($sql);
$count++;
}
fclose($handle);
ignore_user_abort($abort);
return $count;
} | php | public function loadFile($filename){
$this->connection->connect();
$abort = ignore_user_abort();
@set_time_limit(0);
ignore_user_abort(true);
$handle = @fopen($filename, 'r');
if($handle === false){
ignore_user_abort($abort);
throw new NeevoException("Cannot open file '$filename' for SQL import.");
}
$sql = '';
$count = 0;
while(!feof($handle)){
$content = fgets($handle);
$sql .= $content;
if(substr(rtrim($content), -1) === ';'){
// Passed directly to driver without logging.
$this->connection->getDriver()->runQuery($sql);
$sql = '';
$count++;
}
}
if(trim($sql)){
$this->connection->getDriver()->runQuery($sql);
$count++;
}
fclose($handle);
ignore_user_abort($abort);
return $count;
} | [
"public",
"function",
"loadFile",
"(",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"connect",
"(",
")",
";",
"$",
"abort",
"=",
"ignore_user_abort",
"(",
")",
";",
"@",
"set_time_limit",
"(",
"0",
")",
";",
"ignore_user_abort",
"(",
"true",
")",
";",
"$",
"handle",
"=",
"@",
"fopen",
"(",
"$",
"filename",
",",
"'r'",
")",
";",
"if",
"(",
"$",
"handle",
"===",
"false",
")",
"{",
"ignore_user_abort",
"(",
"$",
"abort",
")",
";",
"throw",
"new",
"NeevoException",
"(",
"\"Cannot open file '$filename' for SQL import.\"",
")",
";",
"}",
"$",
"sql",
"=",
"''",
";",
"$",
"count",
"=",
"0",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"handle",
")",
")",
"{",
"$",
"content",
"=",
"fgets",
"(",
"$",
"handle",
")",
";",
"$",
"sql",
".=",
"$",
"content",
";",
"if",
"(",
"substr",
"(",
"rtrim",
"(",
"$",
"content",
")",
",",
"-",
"1",
")",
"===",
"';'",
")",
"{",
"// Passed directly to driver without logging.",
"$",
"this",
"->",
"connection",
"->",
"getDriver",
"(",
")",
"->",
"runQuery",
"(",
"$",
"sql",
")",
";",
"$",
"sql",
"=",
"''",
";",
"$",
"count",
"++",
";",
"}",
"}",
"if",
"(",
"trim",
"(",
"$",
"sql",
")",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"getDriver",
"(",
")",
"->",
"runQuery",
"(",
"$",
"sql",
")",
";",
"$",
"count",
"++",
";",
"}",
"fclose",
"(",
"$",
"handle",
")",
";",
"ignore_user_abort",
"(",
"$",
"abort",
")",
";",
"return",
"$",
"count",
";",
"}"
] | Imports a SQL dump from given file.
Based on implementation in Nette\Database.
@copyright 2004 David Grudl, http://davidgrudl.com
@license New BSD license
@param string $filename
@return int Number of executed commands | [
"Imports",
"a",
"SQL",
"dump",
"from",
"given",
"file",
".",
"Based",
"on",
"implementation",
"in",
"Nette",
"\\",
"Database",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L152-L183 |
37,541 | smasty/Neevo | src/Neevo/Manager.php | Manager.attachObserver | public function attachObserver(ObserverInterface $observer, $event){
$this->observers->attach($observer, $event);
$this->connection->attachObserver($observer, $event);
$e = new NeevoException;
$e->attachObserver($observer, $event);
} | php | public function attachObserver(ObserverInterface $observer, $event){
$this->observers->attach($observer, $event);
$this->connection->attachObserver($observer, $event);
$e = new NeevoException;
$e->attachObserver($observer, $event);
} | [
"public",
"function",
"attachObserver",
"(",
"ObserverInterface",
"$",
"observer",
",",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"observers",
"->",
"attach",
"(",
"$",
"observer",
",",
"$",
"event",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"attachObserver",
"(",
"$",
"observer",
",",
"$",
"event",
")",
";",
"$",
"e",
"=",
"new",
"NeevoException",
";",
"$",
"e",
"->",
"attachObserver",
"(",
"$",
"observer",
",",
"$",
"event",
")",
";",
"}"
] | Attaches an observer for debugging.
@param ObserverInterface $observer
@param int $event Event to attach the observer to. | [
"Attaches",
"an",
"observer",
"for",
"debugging",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L227-L232 |
37,542 | smasty/Neevo | src/Neevo/Manager.php | Manager.detachObserver | public function detachObserver(ObserverInterface $observer){
$this->connection->detachObserver($observer);
$this->observers->detach($observer);
$e = new NeevoException;
$e->detachObserver($observer);
} | php | public function detachObserver(ObserverInterface $observer){
$this->connection->detachObserver($observer);
$this->observers->detach($observer);
$e = new NeevoException;
$e->detachObserver($observer);
} | [
"public",
"function",
"detachObserver",
"(",
"ObserverInterface",
"$",
"observer",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"detachObserver",
"(",
"$",
"observer",
")",
";",
"$",
"this",
"->",
"observers",
"->",
"detach",
"(",
"$",
"observer",
")",
";",
"$",
"e",
"=",
"new",
"NeevoException",
";",
"$",
"e",
"->",
"detachObserver",
"(",
"$",
"observer",
")",
";",
"}"
] | Detaches given observer.
@param ObserverInterface $observer | [
"Detaches",
"given",
"observer",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L239-L244 |
37,543 | smasty/Neevo | src/Neevo/Manager.php | Manager.updateStatus | public function updateStatus(ObservableInterface $subject, $event){
$this->last = (string) $subject;
$this->queries++;
} | php | public function updateStatus(ObservableInterface $subject, $event){
$this->last = (string) $subject;
$this->queries++;
} | [
"public",
"function",
"updateStatus",
"(",
"ObservableInterface",
"$",
"subject",
",",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"last",
"=",
"(",
"string",
")",
"$",
"subject",
";",
"$",
"this",
"->",
"queries",
"++",
";",
"}"
] | Receives update from observable subject.
@param ObservableInterface $subject
@param int $event Event type | [
"Receives",
"update",
"from",
"observable",
"subject",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L264-L267 |
37,544 | smasty/Neevo | src/Neevo/Manager.php | Manager.highlightSql | public static function highlightSql($sql){
$keywords1 = 'SELECT|UPDATE|INSERT\s+INTO|DELETE|FROM|VALUES|SET|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|(?:LEFT\s+|RIGHT\s+|INNER\s+)?JOIN';
$keywords2 = 'RANDOM|RAND|ASC|DESC|USING|AND|OR|ON|IN|IS|NOT|NULL|LIKE|TRUE|FALSE|AS';
$sql = str_replace("\\'", '\\'', $sql);
$sql = preg_replace_callback("~(/\\*.*\\*/)|($keywords1)|($keywords2)|('[^']+'|[0-9]+)~", 'self::_highlightCallback', $sql);
$sql = str_replace('\\'', "\\'", $sql);
return '<pre style="color:#555" class="sql-dump">' . trim($sql) . "</pre>\n";
} | php | public static function highlightSql($sql){
$keywords1 = 'SELECT|UPDATE|INSERT\s+INTO|DELETE|FROM|VALUES|SET|WHERE|HAVING|GROUP\s+BY|ORDER\s+BY|LIMIT|OFFSET|(?:LEFT\s+|RIGHT\s+|INNER\s+)?JOIN';
$keywords2 = 'RANDOM|RAND|ASC|DESC|USING|AND|OR|ON|IN|IS|NOT|NULL|LIKE|TRUE|FALSE|AS';
$sql = str_replace("\\'", '\\'', $sql);
$sql = preg_replace_callback("~(/\\*.*\\*/)|($keywords1)|($keywords2)|('[^']+'|[0-9]+)~", 'self::_highlightCallback', $sql);
$sql = str_replace('\\'', "\\'", $sql);
return '<pre style="color:#555" class="sql-dump">' . trim($sql) . "</pre>\n";
} | [
"public",
"static",
"function",
"highlightSql",
"(",
"$",
"sql",
")",
"{",
"$",
"keywords1",
"=",
"'SELECT|UPDATE|INSERT\\s+INTO|DELETE|FROM|VALUES|SET|WHERE|HAVING|GROUP\\s+BY|ORDER\\s+BY|LIMIT|OFFSET|(?:LEFT\\s+|RIGHT\\s+|INNER\\s+)?JOIN'",
";",
"$",
"keywords2",
"=",
"'RANDOM|RAND|ASC|DESC|USING|AND|OR|ON|IN|IS|NOT|NULL|LIKE|TRUE|FALSE|AS'",
";",
"$",
"sql",
"=",
"str_replace",
"(",
"\"\\\\'\"",
",",
"'\\\\''",
",",
"$",
"sql",
")",
";",
"$",
"sql",
"=",
"preg_replace_callback",
"(",
"\"~(/\\\\*.*\\\\*/)|($keywords1)|($keywords2)|('[^']+'|[0-9]+)~\"",
",",
"'self::_highlightCallback'",
",",
"$",
"sql",
")",
";",
"$",
"sql",
"=",
"str_replace",
"(",
"'\\\\''",
",",
"\"\\\\'\"",
",",
"$",
"sql",
")",
";",
"return",
"'<pre style=\"color:#555\" class=\"sql-dump\">'",
".",
"trim",
"(",
"$",
"sql",
")",
".",
"\"</pre>\\n\"",
";",
"}"
] | Highlights given SQL code.
@param string $sql
@return string | [
"Highlights",
"given",
"SQL",
"code",
"."
] | 3a1bf7e8ce24d453bb27dca3a9aca86852789f11 | https://github.com/smasty/Neevo/blob/3a1bf7e8ce24d453bb27dca3a9aca86852789f11/src/Neevo/Manager.php#L302-L310 |
37,545 | CeusMedia/Common | src/Alg/Time/Clock.php | Alg_Time_Clock.getTime | public function getTime( $base = 3, $round = 3 )
{
$time = $this->microtimeStop - $this->microtimeStart;
$time = $time * pow( 10, $base );
$time = round( $time, $round );
return $time;
} | php | public function getTime( $base = 3, $round = 3 )
{
$time = $this->microtimeStop - $this->microtimeStart;
$time = $time * pow( 10, $base );
$time = round( $time, $round );
return $time;
} | [
"public",
"function",
"getTime",
"(",
"$",
"base",
"=",
"3",
",",
"$",
"round",
"=",
"3",
")",
"{",
"$",
"time",
"=",
"$",
"this",
"->",
"microtimeStop",
"-",
"$",
"this",
"->",
"microtimeStart",
";",
"$",
"time",
"=",
"$",
"time",
"*",
"pow",
"(",
"10",
",",
"$",
"base",
")",
";",
"$",
"time",
"=",
"round",
"(",
"$",
"time",
",",
"$",
"round",
")",
";",
"return",
"$",
"time",
";",
"}"
] | Calculates the time difference between start and stop in microseconds.
@access public
@param int $base Time Base ( 0 - sec | 3 - msec | 6 - µsec)
@param int $round Numbers after dot
@return string | [
"Calculates",
"the",
"time",
"difference",
"between",
"start",
"and",
"stop",
"in",
"microseconds",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Time/Clock.php#L77-L83 |
37,546 | CeusMedia/Common | src/Alg/Time/Clock.php | Alg_Time_Clock.stop | public function stop( $base = 3, $round = 3 )
{
$this->microtimeStop = microtime( TRUE );
return $this->getTime( $base, $round );
} | php | public function stop( $base = 3, $round = 3 )
{
$this->microtimeStop = microtime( TRUE );
return $this->getTime( $base, $round );
} | [
"public",
"function",
"stop",
"(",
"$",
"base",
"=",
"3",
",",
"$",
"round",
"=",
"3",
")",
"{",
"$",
"this",
"->",
"microtimeStop",
"=",
"microtime",
"(",
"TRUE",
")",
";",
"return",
"$",
"this",
"->",
"getTime",
"(",
"$",
"base",
",",
"$",
"round",
")",
";",
"}"
] | Stops the watch and return the time difference between start and stop.
@access public
@param int $base Time Base ( 0 - sec | 3 - msec | 6 - µsec)
@param int $round Numbers after dot
@return string | [
"Stops",
"the",
"watch",
"and",
"return",
"the",
"time",
"difference",
"between",
"start",
"and",
"stop",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Alg/Time/Clock.php#L112-L116 |
37,547 | CeusMedia/Common | src/DB/PDO/Connection.php | DB_PDO_Connection.exec | public function exec( $statement ){
$this->logStatement( $statement );
try{
$this->numberExecutes++;
$this->numberStatements++;
return parent::exec( $statement );
}
catch( \PDOException $e ){
$this->logError( $e, $statement ); // logs Error and throws SQL Exception
}
} | php | public function exec( $statement ){
$this->logStatement( $statement );
try{
$this->numberExecutes++;
$this->numberStatements++;
return parent::exec( $statement );
}
catch( \PDOException $e ){
$this->logError( $e, $statement ); // logs Error and throws SQL Exception
}
} | [
"public",
"function",
"exec",
"(",
"$",
"statement",
")",
"{",
"$",
"this",
"->",
"logStatement",
"(",
"$",
"statement",
")",
";",
"try",
"{",
"$",
"this",
"->",
"numberExecutes",
"++",
";",
"$",
"this",
"->",
"numberStatements",
"++",
";",
"return",
"parent",
"::",
"exec",
"(",
"$",
"statement",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logError",
"(",
"$",
"e",
",",
"$",
"statement",
")",
";",
"// logs Error and throws SQL Exception",
"}",
"}"
] | Executes a Statement and returns Number of affected Rows.
@access public
@param string $statement SQL Statement to execute
@return int | [
"Executes",
"a",
"Statement",
"and",
"returns",
"Number",
"of",
"affected",
"Rows",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Connection.php#L122-L132 |
37,548 | CeusMedia/Common | src/DB/PDO/Connection.php | DB_PDO_Connection.getTables | public function getTables( $prefix = NULL ){
$query = "SHOW TABLES" . ( $prefix ? " LIKE '".$prefix."%'" : "" );
return parent::query( $query )->fetchAll( PDO::FETCH_COLUMN );
} | php | public function getTables( $prefix = NULL ){
$query = "SHOW TABLES" . ( $prefix ? " LIKE '".$prefix."%'" : "" );
return parent::query( $query )->fetchAll( PDO::FETCH_COLUMN );
} | [
"public",
"function",
"getTables",
"(",
"$",
"prefix",
"=",
"NULL",
")",
"{",
"$",
"query",
"=",
"\"SHOW TABLES\"",
".",
"(",
"$",
"prefix",
"?",
"\" LIKE '\"",
".",
"$",
"prefix",
".",
"\"%'\"",
":",
"\"\"",
")",
";",
"return",
"parent",
"::",
"query",
"(",
"$",
"query",
")",
"->",
"fetchAll",
"(",
"PDO",
"::",
"FETCH_COLUMN",
")",
";",
"}"
] | Returns list of tables in database.
With given prefix the returned list will be filtered.
@access public
@param string $prefix Table prefix to filter by (optional).
@return array | [
"Returns",
"list",
"of",
"tables",
"in",
"database",
".",
"With",
"given",
"prefix",
"the",
"returned",
"list",
"will",
"be",
"filtered",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Connection.php#L154-L157 |
37,549 | CeusMedia/Common | src/DB/PDO/Connection.php | DB_PDO_Connection.logError | protected function logError( PDOException $exception, $statement ){
if( !$this->logFileErrors )
return;
// throw $exception;
$info = $exception->errorInfo;
$sqlError = isset( $info[2] ) ? $info[2] : NULL;
$sqlCode = $info[1];
$pdoCode = $info[0];
$message = $exception->getMessage();
$statement = preg_replace( "@\r?\n@", " ", $statement );
$statement = preg_replace( "@ +@", " ", $statement );
$note = self::$errorTemplate;
$note = str_replace( "{time}", time(), $note );
$note = str_replace( "{sqlError}", $sqlError, $note );
$note = str_replace( "{sqlCode}", $sqlCode, $note );
$note = str_replace( "{pdoCode}", $pdoCode, $note );
$note = str_replace( "{message}", $message, $note );
$note = str_replace( "{statement}", $statement, $note );
error_log( $note, 3, $this->logFileErrors );
throw new \Exception_SQL( $sqlError, $sqlCode, $pdoCode );
} | php | protected function logError( PDOException $exception, $statement ){
if( !$this->logFileErrors )
return;
// throw $exception;
$info = $exception->errorInfo;
$sqlError = isset( $info[2] ) ? $info[2] : NULL;
$sqlCode = $info[1];
$pdoCode = $info[0];
$message = $exception->getMessage();
$statement = preg_replace( "@\r?\n@", " ", $statement );
$statement = preg_replace( "@ +@", " ", $statement );
$note = self::$errorTemplate;
$note = str_replace( "{time}", time(), $note );
$note = str_replace( "{sqlError}", $sqlError, $note );
$note = str_replace( "{sqlCode}", $sqlCode, $note );
$note = str_replace( "{pdoCode}", $pdoCode, $note );
$note = str_replace( "{message}", $message, $note );
$note = str_replace( "{statement}", $statement, $note );
error_log( $note, 3, $this->logFileErrors );
throw new \Exception_SQL( $sqlError, $sqlCode, $pdoCode );
} | [
"protected",
"function",
"logError",
"(",
"PDOException",
"$",
"exception",
",",
"$",
"statement",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"logFileErrors",
")",
"return",
";",
"//\t\t\tthrow $exception;",
"$",
"info",
"=",
"$",
"exception",
"->",
"errorInfo",
";",
"$",
"sqlError",
"=",
"isset",
"(",
"$",
"info",
"[",
"2",
"]",
")",
"?",
"$",
"info",
"[",
"2",
"]",
":",
"NULL",
";",
"$",
"sqlCode",
"=",
"$",
"info",
"[",
"1",
"]",
";",
"$",
"pdoCode",
"=",
"$",
"info",
"[",
"0",
"]",
";",
"$",
"message",
"=",
"$",
"exception",
"->",
"getMessage",
"(",
")",
";",
"$",
"statement",
"=",
"preg_replace",
"(",
"\"@\\r?\\n@\"",
",",
"\" \"",
",",
"$",
"statement",
")",
";",
"$",
"statement",
"=",
"preg_replace",
"(",
"\"@ +@\"",
",",
"\" \"",
",",
"$",
"statement",
")",
";",
"$",
"note",
"=",
"self",
"::",
"$",
"errorTemplate",
";",
"$",
"note",
"=",
"str_replace",
"(",
"\"{time}\"",
",",
"time",
"(",
")",
",",
"$",
"note",
")",
";",
"$",
"note",
"=",
"str_replace",
"(",
"\"{sqlError}\"",
",",
"$",
"sqlError",
",",
"$",
"note",
")",
";",
"$",
"note",
"=",
"str_replace",
"(",
"\"{sqlCode}\"",
",",
"$",
"sqlCode",
",",
"$",
"note",
")",
";",
"$",
"note",
"=",
"str_replace",
"(",
"\"{pdoCode}\"",
",",
"$",
"pdoCode",
",",
"$",
"note",
")",
";",
"$",
"note",
"=",
"str_replace",
"(",
"\"{message}\"",
",",
"$",
"message",
",",
"$",
"note",
")",
";",
"$",
"note",
"=",
"str_replace",
"(",
"\"{statement}\"",
",",
"$",
"statement",
",",
"$",
"note",
")",
";",
"error_log",
"(",
"$",
"note",
",",
"3",
",",
"$",
"this",
"->",
"logFileErrors",
")",
";",
"throw",
"new",
"\\",
"Exception_SQL",
"(",
"$",
"sqlError",
",",
"$",
"sqlCode",
",",
"$",
"pdoCode",
")",
";",
"}"
] | Notes Information from PDO Exception in Error Log File and throw SQL Exception.
@access protected
@param PDOException $e PDO Exception thrown by invalid SQL Statement
@param string $statement SQL Statement which originated PDO Exception
@return void | [
"Notes",
"Information",
"from",
"PDO",
"Exception",
"in",
"Error",
"Log",
"File",
"and",
"throw",
"SQL",
"Exception",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Connection.php#L166-L188 |
37,550 | CeusMedia/Common | src/DB/PDO/Connection.php | DB_PDO_Connection.logStatement | protected function logStatement( $statement ){
if( !$this->logFileStatements )
return;
$statement = preg_replace( "@(\r)?\n@", " ", $statement );
$message = time()." ".getEnv( 'REMOTE_ADDR' )." ".$statement."\n";
error_log( $message, 3, $this->logFileStatements);
} | php | protected function logStatement( $statement ){
if( !$this->logFileStatements )
return;
$statement = preg_replace( "@(\r)?\n@", " ", $statement );
$message = time()." ".getEnv( 'REMOTE_ADDR' )." ".$statement."\n";
error_log( $message, 3, $this->logFileStatements);
} | [
"protected",
"function",
"logStatement",
"(",
"$",
"statement",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"logFileStatements",
")",
"return",
";",
"$",
"statement",
"=",
"preg_replace",
"(",
"\"@(\\r)?\\n@\"",
",",
"\" \"",
",",
"$",
"statement",
")",
";",
"$",
"message",
"=",
"time",
"(",
")",
".",
"\" \"",
".",
"getEnv",
"(",
"'REMOTE_ADDR'",
")",
".",
"\" \"",
".",
"$",
"statement",
".",
"\"\\n\"",
";",
"error_log",
"(",
"$",
"message",
",",
"3",
",",
"$",
"this",
"->",
"logFileStatements",
")",
";",
"}"
] | Notes a SQL Statement in Statement Log File.
@access protected
@param string $statement SQL Statement
@return void | [
"Notes",
"a",
"SQL",
"Statement",
"in",
"Statement",
"Log",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Connection.php#L196-L202 |
37,551 | CeusMedia/Common | src/DB/PDO/Connection.php | DB_PDO_Connection.rollBack | public function rollBack(){
if( !$this->openTransactions ) // there has been an inner RollBack or no Transaction was opened
return FALSE; // ignore Commit
if( $this->openTransactions == 1 ){ // only 1 Transaction open
parent::rollBack(); // roll back Transaction
$this->innerTransactionFail = FALSE; // forget about failed inner Transactions
}
else
$this->innerTransactionFail = TRUE; // note about failed inner Transactions
$this->openTransactions--; // decrease Transaction Counter
return TRUE;
} | php | public function rollBack(){
if( !$this->openTransactions ) // there has been an inner RollBack or no Transaction was opened
return FALSE; // ignore Commit
if( $this->openTransactions == 1 ){ // only 1 Transaction open
parent::rollBack(); // roll back Transaction
$this->innerTransactionFail = FALSE; // forget about failed inner Transactions
}
else
$this->innerTransactionFail = TRUE; // note about failed inner Transactions
$this->openTransactions--; // decrease Transaction Counter
return TRUE;
} | [
"public",
"function",
"rollBack",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"openTransactions",
")",
"// there has been an inner RollBack or no Transaction was opened",
"return",
"FALSE",
";",
"// ignore Commit",
"if",
"(",
"$",
"this",
"->",
"openTransactions",
"==",
"1",
")",
"{",
"// only 1 Transaction open",
"parent",
"::",
"rollBack",
"(",
")",
";",
"// roll back Transaction",
"$",
"this",
"->",
"innerTransactionFail",
"=",
"FALSE",
";",
"// forget about failed inner Transactions",
"}",
"else",
"$",
"this",
"->",
"innerTransactionFail",
"=",
"TRUE",
";",
"// note about failed inner Transactions",
"$",
"this",
"->",
"openTransactions",
"--",
";",
"// decrease Transaction Counter",
"return",
"TRUE",
";",
"}"
] | Rolls back a Transaction.
@access public
@return bool | [
"Rolls",
"back",
"a",
"Transaction",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Connection.php#L227-L238 |
37,552 | CeusMedia/Common | src/DB/PDO/Connection.php | DB_PDO_Connection.setErrorLogFile | public function setErrorLogFile( $fileName ){
$this->logFileErrors = $fileName;
if( $fileName && !file_exists( dirname( $fileName ) ) )
mkDir( dirname( $fileName ), 0700, TRUE );
} | php | public function setErrorLogFile( $fileName ){
$this->logFileErrors = $fileName;
if( $fileName && !file_exists( dirname( $fileName ) ) )
mkDir( dirname( $fileName ), 0700, TRUE );
} | [
"public",
"function",
"setErrorLogFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"this",
"->",
"logFileErrors",
"=",
"$",
"fileName",
";",
"if",
"(",
"$",
"fileName",
"&&",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"fileName",
")",
")",
")",
"mkDir",
"(",
"dirname",
"(",
"$",
"fileName",
")",
",",
"0700",
",",
"TRUE",
")",
";",
"}"
] | Sets File Name of Error Log.
@access public
@param string $fileName File Name of Statement Error File
@return void | [
"Sets",
"File",
"Name",
"of",
"Error",
"Log",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Connection.php#L246-L250 |
37,553 | CeusMedia/Common | src/DB/PDO/Connection.php | DB_PDO_Connection.setStatementLogFile | public function setStatementLogFile( $fileName ){
$this->logFileStatements = $fileName;
if( $fileName && !file_exists( dirname( $fileName ) ) )
mkDir( dirname( $fileName ), 0700, TRUE );
} | php | public function setStatementLogFile( $fileName ){
$this->logFileStatements = $fileName;
if( $fileName && !file_exists( dirname( $fileName ) ) )
mkDir( dirname( $fileName ), 0700, TRUE );
} | [
"public",
"function",
"setStatementLogFile",
"(",
"$",
"fileName",
")",
"{",
"$",
"this",
"->",
"logFileStatements",
"=",
"$",
"fileName",
";",
"if",
"(",
"$",
"fileName",
"&&",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"fileName",
")",
")",
")",
"mkDir",
"(",
"dirname",
"(",
"$",
"fileName",
")",
",",
"0700",
",",
"TRUE",
")",
";",
"}"
] | Sets File Name of Statement Log.
@access public
@param string $fileName File Name of Statement Log File
@return void | [
"Sets",
"File",
"Name",
"of",
"Statement",
"Log",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/DB/PDO/Connection.php#L258-L262 |
37,554 | CeusMedia/Common | src/Net/Memory/Cache.php | Net_Memory_Cache.has | public function has( $key )
{
$value = $this->store->get( $key );
if( $value === FALSE )
return $this->store->replace( $key, FALSE ) ? TRUE : FALSE;
return TRUE;
} | php | public function has( $key )
{
$value = $this->store->get( $key );
if( $value === FALSE )
return $this->store->replace( $key, FALSE ) ? TRUE : FALSE;
return TRUE;
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"store",
"->",
"get",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"value",
"===",
"FALSE",
")",
"return",
"$",
"this",
"->",
"store",
"->",
"replace",
"(",
"$",
"key",
",",
"FALSE",
")",
"?",
"TRUE",
":",
"FALSE",
";",
"return",
"TRUE",
";",
"}"
] | Indicates whether a Pair is stored by its Key.
@access public
@param string $key Key of Cache Pair
@return bool | [
"Indicates",
"whether",
"a",
"Pair",
"is",
"stored",
"by",
"its",
"Key",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Memory/Cache.php#L122-L128 |
37,555 | CeusMedia/Common | src/Net/Memory/Cache.php | Net_Memory_Cache.set | public function set( $key, $value )
{
return $this->store->set( $key, $value, 0, $this->expires );
} | php | public function set( $key, $value )
{
return $this->store->set( $key, $value, 0, $this->expires );
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"return",
"$",
"this",
"->",
"store",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"0",
",",
"$",
"this",
"->",
"expires",
")",
";",
"}"
] | Stores or replaces a Pair.
@access public
@param string $key Key of Cache Pair
@param int $value Value to store
@return bool | [
"Stores",
"or",
"replaces",
"a",
"Pair",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/Net/Memory/Cache.php#L160-L163 |
37,556 | meritoo/common-library | src/Utilities/MimeTypes.php | MimeTypes.getExtensions | public static function getExtensions(array $mimesTypes, $asUpperCase = false)
{
if (empty($mimesTypes)) {
return [];
}
$extensions = [];
foreach ($mimesTypes as $mimeType) {
$extension = self::getExtension($mimeType);
/*
* No extension for given mime type?
* Nothing to do
*/
if (empty($extension)) {
continue;
}
if ($asUpperCase) {
if (is_array($extension)) {
array_walk($extension, function (&$value) {
$value = strtoupper($value);
});
} else {
$extension = strtoupper($extension);
}
}
$extensions[$mimeType] = $extension;
}
return $extensions;
} | php | public static function getExtensions(array $mimesTypes, $asUpperCase = false)
{
if (empty($mimesTypes)) {
return [];
}
$extensions = [];
foreach ($mimesTypes as $mimeType) {
$extension = self::getExtension($mimeType);
/*
* No extension for given mime type?
* Nothing to do
*/
if (empty($extension)) {
continue;
}
if ($asUpperCase) {
if (is_array($extension)) {
array_walk($extension, function (&$value) {
$value = strtoupper($value);
});
} else {
$extension = strtoupper($extension);
}
}
$extensions[$mimeType] = $extension;
}
return $extensions;
} | [
"public",
"static",
"function",
"getExtensions",
"(",
"array",
"$",
"mimesTypes",
",",
"$",
"asUpperCase",
"=",
"false",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"mimesTypes",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"extensions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"mimesTypes",
"as",
"$",
"mimeType",
")",
"{",
"$",
"extension",
"=",
"self",
"::",
"getExtension",
"(",
"$",
"mimeType",
")",
";",
"/*\n * No extension for given mime type?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"extension",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"asUpperCase",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"extension",
")",
")",
"{",
"array_walk",
"(",
"$",
"extension",
",",
"function",
"(",
"&",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"strtoupper",
"(",
"$",
"value",
")",
";",
"}",
")",
";",
"}",
"else",
"{",
"$",
"extension",
"=",
"strtoupper",
"(",
"$",
"extension",
")",
";",
"}",
"}",
"$",
"extensions",
"[",
"$",
"mimeType",
"]",
"=",
"$",
"extension",
";",
"}",
"return",
"$",
"extensions",
";",
"}"
] | Returns extensions for given mimes types
@param array $mimesTypes The mimes types, e.g. ['video/mpeg', 'image/jpeg']
@param bool $asUpperCase (optional) If is set to true, extensions are returned as upper case. Otherwise - lower
case.
@return array | [
"Returns",
"extensions",
"for",
"given",
"mimes",
"types"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/MimeTypes.php#L690-L723 |
37,557 | meritoo/common-library | src/Utilities/MimeTypes.php | MimeTypes.getExtension | public static function getExtension($mimeType)
{
if (is_string($mimeType) && in_array($mimeType, self::$mimeTypes, true)) {
$data = Arrays::setKeysAsValues(self::$mimeTypes, false);
return $data[$mimeType];
}
return '';
} | php | public static function getExtension($mimeType)
{
if (is_string($mimeType) && in_array($mimeType, self::$mimeTypes, true)) {
$data = Arrays::setKeysAsValues(self::$mimeTypes, false);
return $data[$mimeType];
}
return '';
} | [
"public",
"static",
"function",
"getExtension",
"(",
"$",
"mimeType",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"mimeType",
")",
"&&",
"in_array",
"(",
"$",
"mimeType",
",",
"self",
"::",
"$",
"mimeTypes",
",",
"true",
")",
")",
"{",
"$",
"data",
"=",
"Arrays",
"::",
"setKeysAsValues",
"(",
"self",
"::",
"$",
"mimeTypes",
",",
"false",
")",
";",
"return",
"$",
"data",
"[",
"$",
"mimeType",
"]",
";",
"}",
"return",
"''",
";",
"}"
] | Returns extension for given mime type
@param string $mimeType The mime type, e.g. "video/mpeg"
@return array|string | [
"Returns",
"extension",
"for",
"given",
"mime",
"type"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/MimeTypes.php#L731-L740 |
37,558 | meritoo/common-library | src/Utilities/MimeTypes.php | MimeTypes.getMimeType | public static function getMimeType($filePath)
{
/*
* The file does not exist?
* Nothing to do
*/
if (!is_string($filePath) || !is_readable($filePath)) {
return '';
}
// 1st possibility: the finfo class
if (class_exists('finfo')) {
$finfo = new \finfo();
return $finfo->file($filePath, FILEINFO_MIME_TYPE);
}
// 2nd possibility: the mime_content_type function
if (function_exists('mime_content_type')) {
return mime_content_type($filePath);
}
// Oops, there is no possibility to read the mime type
$template = 'Neither \'finfo\' class nor \'mime_content_type\' function exists. There is no way to read the'
. ' mime type of file \'%s\'.';
$message = sprintf($template, $filePath);
throw new \RuntimeException($message);
} | php | public static function getMimeType($filePath)
{
/*
* The file does not exist?
* Nothing to do
*/
if (!is_string($filePath) || !is_readable($filePath)) {
return '';
}
// 1st possibility: the finfo class
if (class_exists('finfo')) {
$finfo = new \finfo();
return $finfo->file($filePath, FILEINFO_MIME_TYPE);
}
// 2nd possibility: the mime_content_type function
if (function_exists('mime_content_type')) {
return mime_content_type($filePath);
}
// Oops, there is no possibility to read the mime type
$template = 'Neither \'finfo\' class nor \'mime_content_type\' function exists. There is no way to read the'
. ' mime type of file \'%s\'.';
$message = sprintf($template, $filePath);
throw new \RuntimeException($message);
} | [
"public",
"static",
"function",
"getMimeType",
"(",
"$",
"filePath",
")",
"{",
"/*\n * The file does not exist?\n * Nothing to do\n */",
"if",
"(",
"!",
"is_string",
"(",
"$",
"filePath",
")",
"||",
"!",
"is_readable",
"(",
"$",
"filePath",
")",
")",
"{",
"return",
"''",
";",
"}",
"// 1st possibility: the finfo class",
"if",
"(",
"class_exists",
"(",
"'finfo'",
")",
")",
"{",
"$",
"finfo",
"=",
"new",
"\\",
"finfo",
"(",
")",
";",
"return",
"$",
"finfo",
"->",
"file",
"(",
"$",
"filePath",
",",
"FILEINFO_MIME_TYPE",
")",
";",
"}",
"// 2nd possibility: the mime_content_type function",
"if",
"(",
"function_exists",
"(",
"'mime_content_type'",
")",
")",
"{",
"return",
"mime_content_type",
"(",
"$",
"filePath",
")",
";",
"}",
"// Oops, there is no possibility to read the mime type",
"$",
"template",
"=",
"'Neither \\'finfo\\' class nor \\'mime_content_type\\' function exists. There is no way to read the'",
".",
"' mime type of file \\'%s\\'.'",
";",
"$",
"message",
"=",
"sprintf",
"(",
"$",
"template",
",",
"$",
"filePath",
")",
";",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"$",
"message",
")",
";",
"}"
] | Returns mime type of given file
@param string $filePath Path of the file to check
@throws \RuntimeException
@return string | [
"Returns",
"mime",
"type",
"of",
"given",
"file"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/MimeTypes.php#L762-L791 |
37,559 | meritoo/common-library | src/Utilities/MimeTypes.php | MimeTypes.isImage | public static function isImage($mimeType)
{
if (in_array($mimeType, self::$mimeTypes, true)) {
return (bool)preg_match('|^image/.+$|', $mimeType);
}
return false;
} | php | public static function isImage($mimeType)
{
if (in_array($mimeType, self::$mimeTypes, true)) {
return (bool)preg_match('|^image/.+$|', $mimeType);
}
return false;
} | [
"public",
"static",
"function",
"isImage",
"(",
"$",
"mimeType",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"mimeType",
",",
"self",
"::",
"$",
"mimeTypes",
",",
"true",
")",
")",
"{",
"return",
"(",
"bool",
")",
"preg_match",
"(",
"'|^image/.+$|'",
",",
"$",
"mimeType",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Returns information whether the given file type is an image
@param string $mimeType The mime type of file
@return bool | [
"Returns",
"information",
"whether",
"the",
"given",
"file",
"type",
"is",
"an",
"image"
] | b166b8b805ae97c15688d27323cae8976bd0f6dc | https://github.com/meritoo/common-library/blob/b166b8b805ae97c15688d27323cae8976bd0f6dc/src/Utilities/MimeTypes.php#L799-L806 |
37,560 | CeusMedia/Common | src/XML/DOM/XPathQuery.php | XML_DOM_XPathQuery.loadFile | public function loadFile( $fileName )
{
if( !file_exists( $fileName ) )
throw new Exception( 'XML File "'.$fileName.'" is not existing.' );
$this->document = new DOMDocument();
$this->document->load( $fileName );
$this->xPath = new DOMXpath( $this->document );
return true;
} | php | public function loadFile( $fileName )
{
if( !file_exists( $fileName ) )
throw new Exception( 'XML File "'.$fileName.'" is not existing.' );
$this->document = new DOMDocument();
$this->document->load( $fileName );
$this->xPath = new DOMXpath( $this->document );
return true;
} | [
"public",
"function",
"loadFile",
"(",
"$",
"fileName",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fileName",
")",
")",
"throw",
"new",
"Exception",
"(",
"'XML File \"'",
".",
"$",
"fileName",
".",
"'\" is not existing.'",
")",
";",
"$",
"this",
"->",
"document",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"this",
"->",
"document",
"->",
"load",
"(",
"$",
"fileName",
")",
";",
"$",
"this",
"->",
"xPath",
"=",
"new",
"DOMXpath",
"(",
"$",
"this",
"->",
"document",
")",
";",
"return",
"true",
";",
"}"
] | Loads XML from File.
@access public
@param string $fileName File Name to load XML from
@return bool | [
"Loads",
"XML",
"from",
"File",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/XPathQuery.php#L95-L103 |
37,561 | CeusMedia/Common | src/XML/DOM/XPathQuery.php | XML_DOM_XPathQuery.loadUrl | public function loadUrl( $url )
{
$options = array();
foreach( $this->getOptions() as $key => $value )
$options["CURLOPT_".strtoupper( $key )] = $value;
$xml = Net_Reader::readUrl( $url, $options );
if( !$xml )
throw new Exception( 'No XML found for URL "'.$url.'".' );
$this->loadXml( $xml );
return true;
} | php | public function loadUrl( $url )
{
$options = array();
foreach( $this->getOptions() as $key => $value )
$options["CURLOPT_".strtoupper( $key )] = $value;
$xml = Net_Reader::readUrl( $url, $options );
if( !$xml )
throw new Exception( 'No XML found for URL "'.$url.'".' );
$this->loadXml( $xml );
return true;
} | [
"public",
"function",
"loadUrl",
"(",
"$",
"url",
")",
"{",
"$",
"options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getOptions",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"$",
"options",
"[",
"\"CURLOPT_\"",
".",
"strtoupper",
"(",
"$",
"key",
")",
"]",
"=",
"$",
"value",
";",
"$",
"xml",
"=",
"Net_Reader",
"::",
"readUrl",
"(",
"$",
"url",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"$",
"xml",
")",
"throw",
"new",
"Exception",
"(",
"'No XML found for URL \"'",
".",
"$",
"url",
".",
"'\".'",
")",
";",
"$",
"this",
"->",
"loadXml",
"(",
"$",
"xml",
")",
";",
"return",
"true",
";",
"}"
] | Loads XML from URL.
@access public
@param string $url URL to load XML from
@return bool
@todo Error Handling | [
"Loads",
"XML",
"from",
"URL",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/XPathQuery.php#L112-L122 |
37,562 | CeusMedia/Common | src/XML/DOM/XPathQuery.php | XML_DOM_XPathQuery.loadXml | public function loadXml( $xml )
{
$this->document = new DOMDocument();
$validator = new XML_Validator();
if( !$validator->validate( $xml ) ){
$message = $validator->getErrorMessage();
throw new InvalidArgumentException( 'XML is invalid ('.$message.')' );
}
$this->document->loadXml( $xml );
$this->xPath = new DOMXPath( $this->document );
} | php | public function loadXml( $xml )
{
$this->document = new DOMDocument();
$validator = new XML_Validator();
if( !$validator->validate( $xml ) ){
$message = $validator->getErrorMessage();
throw new InvalidArgumentException( 'XML is invalid ('.$message.')' );
}
$this->document->loadXml( $xml );
$this->xPath = new DOMXPath( $this->document );
} | [
"public",
"function",
"loadXml",
"(",
"$",
"xml",
")",
"{",
"$",
"this",
"->",
"document",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"validator",
"=",
"new",
"XML_Validator",
"(",
")",
";",
"if",
"(",
"!",
"$",
"validator",
"->",
"validate",
"(",
"$",
"xml",
")",
")",
"{",
"$",
"message",
"=",
"$",
"validator",
"->",
"getErrorMessage",
"(",
")",
";",
"throw",
"new",
"InvalidArgumentException",
"(",
"'XML is invalid ('",
".",
"$",
"message",
".",
"')'",
")",
";",
"}",
"$",
"this",
"->",
"document",
"->",
"loadXml",
"(",
"$",
"xml",
")",
";",
"$",
"this",
"->",
"xPath",
"=",
"new",
"DOMXPath",
"(",
"$",
"this",
"->",
"document",
")",
";",
"}"
] | Loads XML into XPath Parser.
@access public
@return void | [
"Loads",
"XML",
"into",
"XPath",
"Parser",
"."
] | 1138adf9341782a6284c05884989f7497532bcf4 | https://github.com/CeusMedia/Common/blob/1138adf9341782a6284c05884989f7497532bcf4/src/XML/DOM/XPathQuery.php#L129-L139 |
37,563 | sseffa/laravel-video-api | src/Sseffa/VideoApi/Services/Youtube.php | Youtube.getVideoList | public function getVideoList($id)
{
$this->setId($id);
$list = array();
$data = $this->getData(str_replace('{key}', $this->key, $this->baseChannelUrl));
if(!isset($data->items))
{
throw new \Exception("Video channel not found");
}
foreach($data->items as $value)
{
$list[] = $this->getVideoDetail($value->contentDetails->videoId);
}
return $list;
} | php | public function getVideoList($id)
{
$this->setId($id);
$list = array();
$data = $this->getData(str_replace('{key}', $this->key, $this->baseChannelUrl));
if(!isset($data->items))
{
throw new \Exception("Video channel not found");
}
foreach($data->items as $value)
{
$list[] = $this->getVideoDetail($value->contentDetails->videoId);
}
return $list;
} | [
"public",
"function",
"getVideoList",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"setId",
"(",
"$",
"id",
")",
";",
"$",
"list",
"=",
"array",
"(",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
"str_replace",
"(",
"'{key}'",
",",
"$",
"this",
"->",
"key",
",",
"$",
"this",
"->",
"baseChannelUrl",
")",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"->",
"items",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Video channel not found\"",
")",
";",
"}",
"foreach",
"(",
"$",
"data",
"->",
"items",
"as",
"$",
"value",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$",
"this",
"->",
"getVideoDetail",
"(",
"$",
"value",
"->",
"contentDetails",
"->",
"videoId",
")",
";",
"}",
"return",
"$",
"list",
";",
"}"
] | Get Video List
@param string $id
@return array
@throws \Exception | [
"Get",
"Video",
"List"
] | c8d653aad95cd85624aedce8b38e13e388fb283d | https://github.com/sseffa/laravel-video-api/blob/c8d653aad95cd85624aedce8b38e13e388fb283d/src/Sseffa/VideoApi/Services/Youtube.php#L100-L118 |
37,564 | sseffa/laravel-video-api | src/Sseffa/VideoApi/Services/Youtube.php | Youtube._convert_time | public static function _convert_time($time)
{
$reference = new DateTimeImmutable;
$endTime = $reference->add(new DateInterval($time));
return $endTime->getTimestamp() - $reference->getTimestamp();
} | php | public static function _convert_time($time)
{
$reference = new DateTimeImmutable;
$endTime = $reference->add(new DateInterval($time));
return $endTime->getTimestamp() - $reference->getTimestamp();
} | [
"public",
"static",
"function",
"_convert_time",
"(",
"$",
"time",
")",
"{",
"$",
"reference",
"=",
"new",
"DateTimeImmutable",
";",
"$",
"endTime",
"=",
"$",
"reference",
"->",
"add",
"(",
"new",
"DateInterval",
"(",
"$",
"time",
")",
")",
";",
"return",
"$",
"endTime",
"->",
"getTimestamp",
"(",
")",
"-",
"$",
"reference",
"->",
"getTimestamp",
"(",
")",
";",
"}"
] | Parse the YouTube timestamp to seconds
@param string $time YouTube format timestamp
@return integer Seconds | [
"Parse",
"the",
"YouTube",
"timestamp",
"to",
"seconds"
] | c8d653aad95cd85624aedce8b38e13e388fb283d | https://github.com/sseffa/laravel-video-api/blob/c8d653aad95cd85624aedce8b38e13e388fb283d/src/Sseffa/VideoApi/Services/Youtube.php#L191-L197 |
37,565 | josegonzalez/php-queuesadilla | src/josegonzalez/Queuesadilla/Worker/SequentialWorker.php | SequentialWorker.jobException | public function jobException(Event $event)
{
$data = $event->data();
$this->logger()->alert(sprintf('Exception: "%s"', $data['exception']->getMessage()));
} | php | public function jobException(Event $event)
{
$data = $event->data();
$this->logger()->alert(sprintf('Exception: "%s"', $data['exception']->getMessage()));
} | [
"public",
"function",
"jobException",
"(",
"Event",
"$",
"event",
")",
"{",
"$",
"data",
"=",
"$",
"event",
"->",
"data",
"(",
")",
";",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"alert",
"(",
"sprintf",
"(",
"'Exception: \"%s\"'",
",",
"$",
"data",
"[",
"'exception'",
"]",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}"
] | Event triggered on Worker.job.exception
@param Event $event
@return void | [
"Event",
"triggered",
"on",
"Worker",
".",
"job",
".",
"exception"
] | 437ddfde53931cc98155ee45c83449851bcd481b | https://github.com/josegonzalez/php-queuesadilla/blob/437ddfde53931cc98155ee45c83449851bcd481b/src/josegonzalez/Queuesadilla/Worker/SequentialWorker.php#L218-L222 |
37,566 | josegonzalez/php-queuesadilla | src/josegonzalez/Queuesadilla/Event/EventManagerTrait.php | EventManagerTrait.eventManager | public function eventManager(EmitterInterface $eventManager = null)
{
if ($eventManager !== null) {
$this->eventManager = $eventManager;
} elseif (empty($this->eventManager)) {
$this->eventManager = new EventManager();
}
return $this->eventManager;
} | php | public function eventManager(EmitterInterface $eventManager = null)
{
if ($eventManager !== null) {
$this->eventManager = $eventManager;
} elseif (empty($this->eventManager)) {
$this->eventManager = new EventManager();
}
return $this->eventManager;
} | [
"public",
"function",
"eventManager",
"(",
"EmitterInterface",
"$",
"eventManager",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"eventManager",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"eventManager",
"=",
"$",
"eventManager",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"this",
"->",
"eventManager",
")",
")",
"{",
"$",
"this",
"->",
"eventManager",
"=",
"new",
"EventManager",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"eventManager",
";",
"}"
] | Returns the League\Event\EmitterInterface manager instance for this object.
You can use this instance to register any new listeners or callbacks to the
object events, or create your own events and trigger them at will.
@param \League\Event\EmitterInterface $eventManager the eventManager to set
@return \League\Event\EmitterInterface | [
"Returns",
"the",
"League",
"\\",
"Event",
"\\",
"EmitterInterface",
"manager",
"instance",
"for",
"this",
"object",
"."
] | 437ddfde53931cc98155ee45c83449851bcd481b | https://github.com/josegonzalez/php-queuesadilla/blob/437ddfde53931cc98155ee45c83449851bcd481b/src/josegonzalez/Queuesadilla/Event/EventManagerTrait.php#L37-L46 |
37,567 | josegonzalez/php-queuesadilla | src/josegonzalez/Queuesadilla/Engine/PdoEngine.php | PdoEngine.cleanup | protected function cleanup($queue)
{
$sql = implode(" ", [
sprintf(
'SELECT id FROM %s',
$this->quoteIdentifier($this->config('table'))
),
sprintf('WHERE %s = ?', $this->quoteIdentifier('queue')),
'AND expires_at < ?'
]);
$datetime = new DateTime;
$dtFormatted = $datetime->format('Y-m-d H:i:s');
try {
$sth = $this->connection()->prepare($sql);
$sth->bindParam(1, $queue, PDO::PARAM_STR);
$sth->bindParam(2, $dtFormatted, PDO::PARAM_STR);
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
if (!empty($result)) {
$this->reject([
'id' => $result['id'],
'queue' => $queue
]);
}
} catch (PDOException $e) {
$this->logger()->error($e->getMessage());
}
} | php | protected function cleanup($queue)
{
$sql = implode(" ", [
sprintf(
'SELECT id FROM %s',
$this->quoteIdentifier($this->config('table'))
),
sprintf('WHERE %s = ?', $this->quoteIdentifier('queue')),
'AND expires_at < ?'
]);
$datetime = new DateTime;
$dtFormatted = $datetime->format('Y-m-d H:i:s');
try {
$sth = $this->connection()->prepare($sql);
$sth->bindParam(1, $queue, PDO::PARAM_STR);
$sth->bindParam(2, $dtFormatted, PDO::PARAM_STR);
$sth->execute();
$result = $sth->fetch(PDO::FETCH_ASSOC);
if (!empty($result)) {
$this->reject([
'id' => $result['id'],
'queue' => $queue
]);
}
} catch (PDOException $e) {
$this->logger()->error($e->getMessage());
}
} | [
"protected",
"function",
"cleanup",
"(",
"$",
"queue",
")",
"{",
"$",
"sql",
"=",
"implode",
"(",
"\" \"",
",",
"[",
"sprintf",
"(",
"'SELECT id FROM %s'",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"$",
"this",
"->",
"config",
"(",
"'table'",
")",
")",
")",
",",
"sprintf",
"(",
"'WHERE %s = ?'",
",",
"$",
"this",
"->",
"quoteIdentifier",
"(",
"'queue'",
")",
")",
",",
"'AND expires_at < ?'",
"]",
")",
";",
"$",
"datetime",
"=",
"new",
"DateTime",
";",
"$",
"dtFormatted",
"=",
"$",
"datetime",
"->",
"format",
"(",
"'Y-m-d H:i:s'",
")",
";",
"try",
"{",
"$",
"sth",
"=",
"$",
"this",
"->",
"connection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"sth",
"->",
"bindParam",
"(",
"1",
",",
"$",
"queue",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"$",
"sth",
"->",
"bindParam",
"(",
"2",
",",
"$",
"dtFormatted",
",",
"PDO",
"::",
"PARAM_STR",
")",
";",
"$",
"sth",
"->",
"execute",
"(",
")",
";",
"$",
"result",
"=",
"$",
"sth",
"->",
"fetch",
"(",
"PDO",
"::",
"FETCH_ASSOC",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"result",
")",
")",
"{",
"$",
"this",
"->",
"reject",
"(",
"[",
"'id'",
"=>",
"$",
"result",
"[",
"'id'",
"]",
",",
"'queue'",
"=>",
"$",
"queue",
"]",
")",
";",
"}",
"}",
"catch",
"(",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"logger",
"(",
")",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}"
] | Check if expired jobs are present in the database and reject them
@param string $queue name of the queue
@return void | [
"Check",
"if",
"expired",
"jobs",
"are",
"present",
"in",
"the",
"database",
"and",
"reject",
"them"
] | 437ddfde53931cc98155ee45c83449851bcd481b | https://github.com/josegonzalez/php-queuesadilla/blob/437ddfde53931cc98155ee45c83449851bcd481b/src/josegonzalez/Queuesadilla/Engine/PdoEngine.php#L311-L342 |
37,568 | josegonzalez/php-queuesadilla | src/josegonzalez/Queuesadilla/Engine/PdoEngine.php | PdoEngine.generatePopOrderSql | protected function generatePopOrderSql($options = [])
{
$orderPart = 'ORDER BY priority ASC';
if (isset($options['pop_order']) && $options['pop_order'] === self::POP_ORDER_FIFO) {
$orderPart = 'ORDER BY created_at ASC';
}
return $orderPart;
} | php | protected function generatePopOrderSql($options = [])
{
$orderPart = 'ORDER BY priority ASC';
if (isset($options['pop_order']) && $options['pop_order'] === self::POP_ORDER_FIFO) {
$orderPart = 'ORDER BY created_at ASC';
}
return $orderPart;
} | [
"protected",
"function",
"generatePopOrderSql",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"orderPart",
"=",
"'ORDER BY priority ASC'",
";",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'pop_order'",
"]",
")",
"&&",
"$",
"options",
"[",
"'pop_order'",
"]",
"===",
"self",
"::",
"POP_ORDER_FIFO",
")",
"{",
"$",
"orderPart",
"=",
"'ORDER BY created_at ASC'",
";",
"}",
"return",
"$",
"orderPart",
";",
"}"
] | Generate ORDER sql
@param array $options
@return string
@throws \InvalidArgumentException if the "pop_order" option is not valid or null | [
"Generate",
"ORDER",
"sql"
] | 437ddfde53931cc98155ee45c83449851bcd481b | https://github.com/josegonzalez/php-queuesadilla/blob/437ddfde53931cc98155ee45c83449851bcd481b/src/josegonzalez/Queuesadilla/Engine/PdoEngine.php#L378-L386 |
37,569 | bittools/skyhub-php | src/Api.php | Api.setAuthentication | public function setAuthentication($email, $apiKey)
{
$headers = [
self::HEADER_USER_EMAIL => $email,
self::HEADER_API_KEY => $apiKey,
];
$this->service->setHeaders($headers, true, true);
return $this;
} | php | public function setAuthentication($email, $apiKey)
{
$headers = [
self::HEADER_USER_EMAIL => $email,
self::HEADER_API_KEY => $apiKey,
];
$this->service->setHeaders($headers, true, true);
return $this;
} | [
"public",
"function",
"setAuthentication",
"(",
"$",
"email",
",",
"$",
"apiKey",
")",
"{",
"$",
"headers",
"=",
"[",
"self",
"::",
"HEADER_USER_EMAIL",
"=>",
"$",
"email",
",",
"self",
"::",
"HEADER_API_KEY",
"=>",
"$",
"apiKey",
",",
"]",
";",
"$",
"this",
"->",
"service",
"->",
"setHeaders",
"(",
"$",
"headers",
",",
"true",
",",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Reset the authorization information and use the same instance of the API object to use different accounts.
@param string $email
@param string $apiKey
@return $this | [
"Reset",
"the",
"authorization",
"information",
"and",
"use",
"the",
"same",
"instance",
"of",
"the",
"API",
"object",
"to",
"use",
"different",
"accounts",
"."
] | e57a62a953a0fe79c69181c8cc069b29c91cf743 | https://github.com/bittools/skyhub-php/blob/e57a62a953a0fe79c69181c8cc069b29c91cf743/src/Api.php#L84-L94 |
37,570 | bittools/skyhub-php | src/Api/Handler/Request/Sales/OrderHandler.php | OrderHandler.orders | public function orders($page = 1, $perPage = 30, $saleSystem = null, array $statuses = [])
{
$filters = [];
if (!is_null($saleSystem)) {
$filters['sale_system'] = (string) $saleSystem;
}
if (!is_null($statuses)) {
$filters['statuses'] = (array) $statuses;
}
$query = [
'page' => (int) $page,
'per_page' => (int) $perPage,
'filters' => (array) $filters,
];
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->get($this->baseUrlPath(null, $query));
return $responseHandler;
} | php | public function orders($page = 1, $perPage = 30, $saleSystem = null, array $statuses = [])
{
$filters = [];
if (!is_null($saleSystem)) {
$filters['sale_system'] = (string) $saleSystem;
}
if (!is_null($statuses)) {
$filters['statuses'] = (array) $statuses;
}
$query = [
'page' => (int) $page,
'per_page' => (int) $perPage,
'filters' => (array) $filters,
];
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->get($this->baseUrlPath(null, $query));
return $responseHandler;
} | [
"public",
"function",
"orders",
"(",
"$",
"page",
"=",
"1",
",",
"$",
"perPage",
"=",
"30",
",",
"$",
"saleSystem",
"=",
"null",
",",
"array",
"$",
"statuses",
"=",
"[",
"]",
")",
"{",
"$",
"filters",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"saleSystem",
")",
")",
"{",
"$",
"filters",
"[",
"'sale_system'",
"]",
"=",
"(",
"string",
")",
"$",
"saleSystem",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"statuses",
")",
")",
"{",
"$",
"filters",
"[",
"'statuses'",
"]",
"=",
"(",
"array",
")",
"$",
"statuses",
";",
"}",
"$",
"query",
"=",
"[",
"'page'",
"=>",
"(",
"int",
")",
"$",
"page",
",",
"'per_page'",
"=>",
"(",
"int",
")",
"$",
"perPage",
",",
"'filters'",
"=>",
"(",
"array",
")",
"$",
"filters",
",",
"]",
";",
"/** @var \\SkyHub\\Api\\Handler\\Response\\HandlerInterface $responseHandler */",
"$",
"responseHandler",
"=",
"$",
"this",
"->",
"service",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"baseUrlPath",
"(",
"null",
",",
"$",
"query",
")",
")",
";",
"return",
"$",
"responseHandler",
";",
"}"
] | Retrieves a list of all orders available in SkyHub.
@param int $page
@param int $perPage
@param string $saleSystem
@param array $statuses
@return \SkyHub\Api\Handler\Response\HandlerInterface | [
"Retrieves",
"a",
"list",
"of",
"all",
"orders",
"available",
"in",
"SkyHub",
"."
] | e57a62a953a0fe79c69181c8cc069b29c91cf743 | https://github.com/bittools/skyhub-php/blob/e57a62a953a0fe79c69181c8cc069b29c91cf743/src/Api/Handler/Request/Sales/OrderHandler.php#L53-L74 |
37,571 | bittools/skyhub-php | src/Api/Handler/Request/Sales/OrderHandler.php | OrderHandler.invoice | public function invoice($orderId, $invoiceKey)
{
$transformer = new InvoiceTransformer(self::STATUS_PAID, $invoiceKey);
$body = $transformer->output();
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->post($this->baseUrlPath("$orderId/invoice"), $body);
return $responseHandler;
} | php | public function invoice($orderId, $invoiceKey)
{
$transformer = new InvoiceTransformer(self::STATUS_PAID, $invoiceKey);
$body = $transformer->output();
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->post($this->baseUrlPath("$orderId/invoice"), $body);
return $responseHandler;
} | [
"public",
"function",
"invoice",
"(",
"$",
"orderId",
",",
"$",
"invoiceKey",
")",
"{",
"$",
"transformer",
"=",
"new",
"InvoiceTransformer",
"(",
"self",
"::",
"STATUS_PAID",
",",
"$",
"invoiceKey",
")",
";",
"$",
"body",
"=",
"$",
"transformer",
"->",
"output",
"(",
")",
";",
"/** @var \\SkyHub\\Api\\Handler\\Response\\HandlerInterface $responseHandler */",
"$",
"responseHandler",
"=",
"$",
"this",
"->",
"service",
"(",
")",
"->",
"post",
"(",
"$",
"this",
"->",
"baseUrlPath",
"(",
"\"$orderId/invoice\"",
")",
",",
"$",
"body",
")",
";",
"return",
"$",
"responseHandler",
";",
"}"
] | Invoice an order in SkyHub.
@var string $orderId
@var string $invoiceKey
@return \SkyHub\Api\Handler\Response\HandlerInterface | [
"Invoice",
"an",
"order",
"in",
"SkyHub",
"."
] | e57a62a953a0fe79c69181c8cc069b29c91cf743 | https://github.com/bittools/skyhub-php/blob/e57a62a953a0fe79c69181c8cc069b29c91cf743/src/Api/Handler/Request/Sales/OrderHandler.php#L137-L145 |
37,572 | bittools/skyhub-php | src/Api/Handler/Request/Sales/OrderHandler.php | OrderHandler.cancel | public function cancel($orderId)
{
$transformer = new CancelTransformer(self::STATUS_CANCELLED);
$body = $transformer->output();
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->post($this->baseUrlPath("$orderId/cancel"), $body);
return $responseHandler;
} | php | public function cancel($orderId)
{
$transformer = new CancelTransformer(self::STATUS_CANCELLED);
$body = $transformer->output();
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->post($this->baseUrlPath("$orderId/cancel"), $body);
return $responseHandler;
} | [
"public",
"function",
"cancel",
"(",
"$",
"orderId",
")",
"{",
"$",
"transformer",
"=",
"new",
"CancelTransformer",
"(",
"self",
"::",
"STATUS_CANCELLED",
")",
";",
"$",
"body",
"=",
"$",
"transformer",
"->",
"output",
"(",
")",
";",
"/** @var \\SkyHub\\Api\\Handler\\Response\\HandlerInterface $responseHandler */",
"$",
"responseHandler",
"=",
"$",
"this",
"->",
"service",
"(",
")",
"->",
"post",
"(",
"$",
"this",
"->",
"baseUrlPath",
"(",
"\"$orderId/cancel\"",
")",
",",
"$",
"body",
")",
";",
"return",
"$",
"responseHandler",
";",
"}"
] | Cancel an order in SkyHub.
@var string $orderId
@return \SkyHub\Api\Handler\Response\HandlerInterface | [
"Cancel",
"an",
"order",
"in",
"SkyHub",
"."
] | e57a62a953a0fe79c69181c8cc069b29c91cf743 | https://github.com/bittools/skyhub-php/blob/e57a62a953a0fe79c69181c8cc069b29c91cf743/src/Api/Handler/Request/Sales/OrderHandler.php#L155-L163 |
37,573 | bittools/skyhub-php | src/Api/Handler/Request/Shipment/PlpHandler.php | PlpHandler.group | public function group(array $orders)
{
$transformer = new GroupTransformer($orders);
$body = $transformer->output();
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->post($this->baseUrlPath(), $body);
return $responseHandler;
} | php | public function group(array $orders)
{
$transformer = new GroupTransformer($orders);
$body = $transformer->output();
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->post($this->baseUrlPath(), $body);
return $responseHandler;
} | [
"public",
"function",
"group",
"(",
"array",
"$",
"orders",
")",
"{",
"$",
"transformer",
"=",
"new",
"GroupTransformer",
"(",
"$",
"orders",
")",
";",
"$",
"body",
"=",
"$",
"transformer",
"->",
"output",
"(",
")",
";",
"/** @var \\SkyHub\\Api\\Handler\\Response\\HandlerInterface $responseHandler */",
"$",
"responseHandler",
"=",
"$",
"this",
"->",
"service",
"(",
")",
"->",
"post",
"(",
"$",
"this",
"->",
"baseUrlPath",
"(",
")",
",",
"$",
"body",
")",
";",
"return",
"$",
"responseHandler",
";",
"}"
] | Group multiple orders in a PLP.
@param array $orders
@return \SkyHub\Api\Handler\Response\HandlerInterface | [
"Group",
"multiple",
"orders",
"in",
"a",
"PLP",
"."
] | e57a62a953a0fe79c69181c8cc069b29c91cf743 | https://github.com/bittools/skyhub-php/blob/e57a62a953a0fe79c69181c8cc069b29c91cf743/src/Api/Handler/Request/Shipment/PlpHandler.php#L65-L74 |
37,574 | bittools/skyhub-php | src/Api/Handler/Request/Shipment/PlpHandler.php | PlpHandler.viewFile | public function viewFile($id)
{
$query = [
'plp_id' => $id
];
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->get($this->baseUrlPath('/view', $query));
return $responseHandler;
} | php | public function viewFile($id)
{
$query = [
'plp_id' => $id
];
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->get($this->baseUrlPath('/view', $query));
return $responseHandler;
} | [
"public",
"function",
"viewFile",
"(",
"$",
"id",
")",
"{",
"$",
"query",
"=",
"[",
"'plp_id'",
"=>",
"$",
"id",
"]",
";",
"/** @var \\SkyHub\\Api\\Handler\\Response\\HandlerInterface $responseHandler */",
"$",
"responseHandler",
"=",
"$",
"this",
"->",
"service",
"(",
")",
"->",
"get",
"(",
"$",
"this",
"->",
"baseUrlPath",
"(",
"'/view'",
",",
"$",
"query",
")",
")",
";",
"return",
"$",
"responseHandler",
";",
"}"
] | Get PLP file
@param string $id
@return \SkyHub\Api\Handler\Response\HandlerInterface | [
"Get",
"PLP",
"file"
] | e57a62a953a0fe79c69181c8cc069b29c91cf743 | https://github.com/bittools/skyhub-php/blob/e57a62a953a0fe79c69181c8cc069b29c91cf743/src/Api/Handler/Request/Shipment/PlpHandler.php#L84-L94 |
37,575 | bittools/skyhub-php | src/Api/Handler/Request/Shipment/PlpHandler.php | PlpHandler.ungroup | public function ungroup($id)
{
$params = [
'plp_id' => $id,
];
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->delete($this->baseUrlPath(), $params);
return $responseHandler;
} | php | public function ungroup($id)
{
$params = [
'plp_id' => $id,
];
/** @var \SkyHub\Api\Handler\Response\HandlerInterface $responseHandler */
$responseHandler = $this->service()->delete($this->baseUrlPath(), $params);
return $responseHandler;
} | [
"public",
"function",
"ungroup",
"(",
"$",
"id",
")",
"{",
"$",
"params",
"=",
"[",
"'plp_id'",
"=>",
"$",
"id",
",",
"]",
";",
"/** @var \\SkyHub\\Api\\Handler\\Response\\HandlerInterface $responseHandler */",
"$",
"responseHandler",
"=",
"$",
"this",
"->",
"service",
"(",
")",
"->",
"delete",
"(",
"$",
"this",
"->",
"baseUrlPath",
"(",
")",
",",
"$",
"params",
")",
";",
"return",
"$",
"responseHandler",
";",
"}"
] | Ungroup a PLP.
@param string $id
@return \SkyHub\Api\Handler\Response\HandlerInterface | [
"Ungroup",
"a",
"PLP",
"."
] | e57a62a953a0fe79c69181c8cc069b29c91cf743 | https://github.com/bittools/skyhub-php/blob/e57a62a953a0fe79c69181c8cc069b29c91cf743/src/Api/Handler/Request/Shipment/PlpHandler.php#L104-L113 |
37,576 | digitickets/omnipay-barclays-epdq | src/Omnipay/BarclaysEpdq/Message/EssentialPurchaseRequest.php | EssentialPurchaseRequest.setReturnUrl | public function setReturnUrl($value)
{
$value = substr($value, 0, 200);
$this->setParameter('returnUrl', $value);
$this->setParameter('declineUrl', $value);
$this->setParameter('exceptionUrl', $value);
return $this;
} | php | public function setReturnUrl($value)
{
$value = substr($value, 0, 200);
$this->setParameter('returnUrl', $value);
$this->setParameter('declineUrl', $value);
$this->setParameter('exceptionUrl', $value);
return $this;
} | [
"public",
"function",
"setReturnUrl",
"(",
"$",
"value",
")",
"{",
"$",
"value",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"200",
")",
";",
"$",
"this",
"->",
"setParameter",
"(",
"'returnUrl'",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"setParameter",
"(",
"'declineUrl'",
",",
"$",
"value",
")",
";",
"$",
"this",
"->",
"setParameter",
"(",
"'exceptionUrl'",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] | This method keeps the backward compatibility with setDeclineUrl and setExceptionUrl.
It fills returnUrl, declineUrl and exceptionUrl with the same value.
@param string $value Max length of 200
@return $this | [
"This",
"method",
"keeps",
"the",
"backward",
"compatibility",
"with",
"setDeclineUrl",
"and",
"setExceptionUrl",
".",
"It",
"fills",
"returnUrl",
"declineUrl",
"and",
"exceptionUrl",
"with",
"the",
"same",
"value",
"."
] | 34d1dcac8325d206b7da8878aea1993083781a6c | https://github.com/digitickets/omnipay-barclays-epdq/blob/34d1dcac8325d206b7da8878aea1993083781a6c/src/Omnipay/BarclaysEpdq/Message/EssentialPurchaseRequest.php#L80-L88 |
37,577 | digitickets/omnipay-barclays-epdq | src/Omnipay/BarclaysEpdq/Message/EssentialPurchaseRequest.php | EssentialPurchaseRequest.setItems | public function setItems($items)
{
$newItems = new ItemBag();
foreach ($items as $item) {
$newItems->add(new Item($item->getParameters()));
}
return parent::setItems($newItems);
} | php | public function setItems($items)
{
$newItems = new ItemBag();
foreach ($items as $item) {
$newItems->add(new Item($item->getParameters()));
}
return parent::setItems($newItems);
} | [
"public",
"function",
"setItems",
"(",
"$",
"items",
")",
"{",
"$",
"newItems",
"=",
"new",
"ItemBag",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"newItems",
"->",
"add",
"(",
"new",
"Item",
"(",
"$",
"item",
"->",
"getParameters",
"(",
")",
")",
")",
";",
"}",
"return",
"parent",
"::",
"setItems",
"(",
"$",
"newItems",
")",
";",
"}"
] | Set items for request
Cast the items to instances of \Omnipay\BarclaysEpdq\Item
@param array|\Omnipay\Common\ItemBag|\Omnipay\Common\Item[] $items
@return AbstractRequest | [
"Set",
"items",
"for",
"request"
] | 34d1dcac8325d206b7da8878aea1993083781a6c | https://github.com/digitickets/omnipay-barclays-epdq/blob/34d1dcac8325d206b7da8878aea1993083781a6c/src/Omnipay/BarclaysEpdq/Message/EssentialPurchaseRequest.php#L337-L345 |
37,578 | limen/redisun | src/Model.php | Model.newQuery | public function newQuery()
{
$this->orderBys = [];
$this->limit = null;
$this->offset = null;
return $this->freshQueryBuilder();
} | php | public function newQuery()
{
$this->orderBys = [];
$this->limit = null;
$this->offset = null;
return $this->freshQueryBuilder();
} | [
"public",
"function",
"newQuery",
"(",
")",
"{",
"$",
"this",
"->",
"orderBys",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"limit",
"=",
"null",
";",
"$",
"this",
"->",
"offset",
"=",
"null",
";",
"return",
"$",
"this",
"->",
"freshQueryBuilder",
"(",
")",
";",
"}"
] | Refresh query builder
@return $this | [
"Refresh",
"query",
"builder"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L128-L135 |
37,579 | limen/redisun | src/Model.php | Model.createNotExists | public function createNotExists($id, $value, $ttl = null)
{
return $this->create($id, $value, $ttl, false);
} | php | public function createNotExists($id, $value, $ttl = null)
{
return $this->create($id, $value, $ttl, false);
} | [
"public",
"function",
"createNotExists",
"(",
"$",
"id",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"id",
",",
"$",
"value",
",",
"$",
"ttl",
",",
"false",
")",
";",
"}"
] | Similar to setnx
@param $id
@param $value
@param null $ttl
@return bool | [
"Similar",
"to",
"setnx"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L396-L399 |
37,580 | limen/redisun | src/Model.php | Model.createExists | public function createExists($id, $value, $ttl = null)
{
return $this->create($id, $value, $ttl, true);
} | php | public function createExists($id, $value, $ttl = null)
{
return $this->create($id, $value, $ttl, true);
} | [
"public",
"function",
"createExists",
"(",
"$",
"id",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"create",
"(",
"$",
"id",
",",
"$",
"value",
",",
"$",
"ttl",
",",
"true",
")",
";",
"}"
] | Similar to setxx
@param $id
@param $value
@param null $ttl
@return bool | [
"Similar",
"to",
"setxx"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L408-L411 |
37,581 | limen/redisun | src/Model.php | Model.insertExists | public function insertExists(array $bindings, $value, $ttl = null)
{
return $this->insert($bindings, $value, $ttl, true);
} | php | public function insertExists(array $bindings, $value, $ttl = null)
{
return $this->insert($bindings, $value, $ttl, true);
} | [
"public",
"function",
"insertExists",
"(",
"array",
"$",
"bindings",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"insert",
"(",
"$",
"bindings",
",",
"$",
"value",
",",
"$",
"ttl",
",",
"true",
")",
";",
"}"
] | Insert when key exists
@param array $bindings
@param $value
@param null $ttl
@return mixed | [
"Insert",
"when",
"key",
"exists"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L445-L448 |
37,582 | limen/redisun | src/Model.php | Model.insertNotExists | public function insertNotExists(array $bindings, $value, $ttl = null)
{
return $this->insert($bindings, $value, $ttl, false);
} | php | public function insertNotExists(array $bindings, $value, $ttl = null)
{
return $this->insert($bindings, $value, $ttl, false);
} | [
"public",
"function",
"insertNotExists",
"(",
"array",
"$",
"bindings",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"insert",
"(",
"$",
"bindings",
",",
"$",
"value",
",",
"$",
"ttl",
",",
"false",
")",
";",
"}"
] | Insert when key not exists
@param array $bindings
@param $value
@param null $ttl
@return mixed | [
"Insert",
"when",
"key",
"not",
"exists"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L458-L461 |
37,583 | limen/redisun | src/Model.php | Model.find | public function find($id)
{
$this->newQuery();
$this->queryBuilder->whereEqual($this->primaryFieldName, $id);
$queryKey = $this->queryBuilder->firstQueryKey();
if (!$this->isCompleteKey($queryKey)) {
return null;
}
list($method, $parameters) = $this->getFindMethodAndParameters();
array_unshift($parameters, $queryKey);
$value = call_user_func_array([$this->redClient, $method], $parameters);
return $value;
} | php | public function find($id)
{
$this->newQuery();
$this->queryBuilder->whereEqual($this->primaryFieldName, $id);
$queryKey = $this->queryBuilder->firstQueryKey();
if (!$this->isCompleteKey($queryKey)) {
return null;
}
list($method, $parameters) = $this->getFindMethodAndParameters();
array_unshift($parameters, $queryKey);
$value = call_user_func_array([$this->redClient, $method], $parameters);
return $value;
} | [
"public",
"function",
"find",
"(",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"newQuery",
"(",
")",
";",
"$",
"this",
"->",
"queryBuilder",
"->",
"whereEqual",
"(",
"$",
"this",
"->",
"primaryFieldName",
",",
"$",
"id",
")",
";",
"$",
"queryKey",
"=",
"$",
"this",
"->",
"queryBuilder",
"->",
"firstQueryKey",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isCompleteKey",
"(",
"$",
"queryKey",
")",
")",
"{",
"return",
"null",
";",
"}",
"list",
"(",
"$",
"method",
",",
"$",
"parameters",
")",
"=",
"$",
"this",
"->",
"getFindMethodAndParameters",
"(",
")",
";",
"array_unshift",
"(",
"$",
"parameters",
",",
"$",
"queryKey",
")",
";",
"$",
"value",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"redClient",
",",
"$",
"method",
"]",
",",
"$",
"parameters",
")",
";",
"return",
"$",
"value",
";",
"}"
] | find an item
@param $id int|string Primary key
@return mixed | [
"find",
"an",
"item"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L468-L486 |
37,584 | limen/redisun | src/Model.php | Model.getAndSet | public function getAndSet($value, $ttl = null)
{
$keys = $this->queryBuilder->getQueryKeys();
if (count($keys) > 1) {
throw new Exception('GetAndSet doesnt support multiple keys');
} elseif (count($keys) == 0) {
throw new Exception('No query keys');
}
$key = $keys[0];
if (!$this->isCompleteKey($key)) {
throw new Exception('Not complete key');
}
$value = $this->castValueForUpdate($value);
$commandName = 'getset' . ucfirst($this->type);
$command = $this->commandFactory->getCommand($commandName, [$key], $value);
if (!is_null($ttl)) {
$command->setTtl($ttl);
}
$result = $this->executeCommand($command);
$data = isset($result[$key]) ? $result[$key] : null;
if ($data && $this->type == static::TYPE_HASH) {
$data = $this->resolveHash($data);
}
return $data;
} | php | public function getAndSet($value, $ttl = null)
{
$keys = $this->queryBuilder->getQueryKeys();
if (count($keys) > 1) {
throw new Exception('GetAndSet doesnt support multiple keys');
} elseif (count($keys) == 0) {
throw new Exception('No query keys');
}
$key = $keys[0];
if (!$this->isCompleteKey($key)) {
throw new Exception('Not complete key');
}
$value = $this->castValueForUpdate($value);
$commandName = 'getset' . ucfirst($this->type);
$command = $this->commandFactory->getCommand($commandName, [$key], $value);
if (!is_null($ttl)) {
$command->setTtl($ttl);
}
$result = $this->executeCommand($command);
$data = isset($result[$key]) ? $result[$key] : null;
if ($data && $this->type == static::TYPE_HASH) {
$data = $this->resolveHash($data);
}
return $data;
} | [
"public",
"function",
"getAndSet",
"(",
"$",
"value",
",",
"$",
"ttl",
"=",
"null",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"queryBuilder",
"->",
"getQueryKeys",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"keys",
")",
">",
"1",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'GetAndSet doesnt support multiple keys'",
")",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"keys",
")",
"==",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'No query keys'",
")",
";",
"}",
"$",
"key",
"=",
"$",
"keys",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isCompleteKey",
"(",
"$",
"key",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Not complete key'",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"castValueForUpdate",
"(",
"$",
"value",
")",
";",
"$",
"commandName",
"=",
"'getset'",
".",
"ucfirst",
"(",
"$",
"this",
"->",
"type",
")",
";",
"$",
"command",
"=",
"$",
"this",
"->",
"commandFactory",
"->",
"getCommand",
"(",
"$",
"commandName",
",",
"[",
"$",
"key",
"]",
",",
"$",
"value",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"ttl",
")",
")",
"{",
"$",
"command",
"->",
"setTtl",
"(",
"$",
"ttl",
")",
";",
"}",
"$",
"result",
"=",
"$",
"this",
"->",
"executeCommand",
"(",
"$",
"command",
")",
";",
"$",
"data",
"=",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
"?",
"$",
"result",
"[",
"$",
"key",
"]",
":",
"null",
";",
"if",
"(",
"$",
"data",
"&&",
"$",
"this",
"->",
"type",
"==",
"static",
"::",
"TYPE_HASH",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"resolveHash",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Get key and set new value
@param string|array $value
@param null $ttl
@return mixed
@throws Exception | [
"Get",
"key",
"and",
"set",
"new",
"value"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L617-L644 |
37,585 | limen/redisun | src/Model.php | Model.prepareKeys | protected function prepareKeys($forGet = true)
{
$queryKeys = $this->queryBuilder->getQueryKeys();
// Caution! Would get all items.
if (!$queryKeys) {
$queryKeys = [$this->key];
}
$existKeys = $this->getExistKeys($queryKeys);
if ($forGet) {
$this->setOrderByFieldIndices();
if ($this->orderByFieldIndices) {
uasort($existKeys, [$this, 'sortByFields']);
}
if ($this->offset || $this->limit) {
$existKeys = array_slice($existKeys, (int)$this->offset, $this->limit);
}
}
return $existKeys;
} | php | protected function prepareKeys($forGet = true)
{
$queryKeys = $this->queryBuilder->getQueryKeys();
// Caution! Would get all items.
if (!$queryKeys) {
$queryKeys = [$this->key];
}
$existKeys = $this->getExistKeys($queryKeys);
if ($forGet) {
$this->setOrderByFieldIndices();
if ($this->orderByFieldIndices) {
uasort($existKeys, [$this, 'sortByFields']);
}
if ($this->offset || $this->limit) {
$existKeys = array_slice($existKeys, (int)$this->offset, $this->limit);
}
}
return $existKeys;
} | [
"protected",
"function",
"prepareKeys",
"(",
"$",
"forGet",
"=",
"true",
")",
"{",
"$",
"queryKeys",
"=",
"$",
"this",
"->",
"queryBuilder",
"->",
"getQueryKeys",
"(",
")",
";",
"// Caution! Would get all items.",
"if",
"(",
"!",
"$",
"queryKeys",
")",
"{",
"$",
"queryKeys",
"=",
"[",
"$",
"this",
"->",
"key",
"]",
";",
"}",
"$",
"existKeys",
"=",
"$",
"this",
"->",
"getExistKeys",
"(",
"$",
"queryKeys",
")",
";",
"if",
"(",
"$",
"forGet",
")",
"{",
"$",
"this",
"->",
"setOrderByFieldIndices",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"orderByFieldIndices",
")",
"{",
"uasort",
"(",
"$",
"existKeys",
",",
"[",
"$",
"this",
",",
"'sortByFields'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"offset",
"||",
"$",
"this",
"->",
"limit",
")",
"{",
"$",
"existKeys",
"=",
"array_slice",
"(",
"$",
"existKeys",
",",
"(",
"int",
")",
"$",
"this",
"->",
"offset",
",",
"$",
"this",
"->",
"limit",
")",
";",
"}",
"}",
"return",
"$",
"existKeys",
";",
"}"
] | Prepare query keys
@param bool $forGet
@return array | [
"Prepare",
"query",
"keys"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L704-L728 |
37,586 | limen/redisun | src/Model.php | Model.getUpdateMethod | protected function getUpdateMethod()
{
$method = '';
switch ($this->type) {
case 'string':
$method = 'set';
break;
case 'list':
$method = $this->listPushMethod;
break;
case 'set':
$method = 'sadd';
break;
case 'zset':
$method = 'zadd';
break;
case 'hash':
$method = 'hmset';
break;
default:
break;
}
return $method;
} | php | protected function getUpdateMethod()
{
$method = '';
switch ($this->type) {
case 'string':
$method = 'set';
break;
case 'list':
$method = $this->listPushMethod;
break;
case 'set':
$method = 'sadd';
break;
case 'zset':
$method = 'zadd';
break;
case 'hash':
$method = 'hmset';
break;
default:
break;
}
return $method;
} | [
"protected",
"function",
"getUpdateMethod",
"(",
")",
"{",
"$",
"method",
"=",
"''",
";",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"'string'",
":",
"$",
"method",
"=",
"'set'",
";",
"break",
";",
"case",
"'list'",
":",
"$",
"method",
"=",
"$",
"this",
"->",
"listPushMethod",
";",
"break",
";",
"case",
"'set'",
":",
"$",
"method",
"=",
"'sadd'",
";",
"break",
";",
"case",
"'zset'",
":",
"$",
"method",
"=",
"'zadd'",
";",
"break",
";",
"case",
"'hash'",
":",
"$",
"method",
"=",
"'hmset'",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"$",
"method",
";",
"}"
] | Get update method according to redis data type
@return string | [
"Get",
"update",
"method",
"according",
"to",
"redis",
"data",
"type"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L853-L877 |
37,587 | limen/redisun | src/Model.php | Model.castValueForUpdate | protected function castValueForUpdate($value)
{
switch ($this->type) {
case 'string':
$value = [(string)$value];
break;
case 'list':
case 'set':
$value = (array)$value;
break;
case 'zset':
$casted = [];
foreach ($value as $k => $v) {
$casted[] = $v;
$casted[] = $k;
}
$value = $casted;
break;
case 'hash':
$casted = [];
foreach ($value as $k => $v) {
$casted[] = $k;
$casted[] = $v;
}
$value = $casted;
break;
default:
break;
}
return $value;
} | php | protected function castValueForUpdate($value)
{
switch ($this->type) {
case 'string':
$value = [(string)$value];
break;
case 'list':
case 'set':
$value = (array)$value;
break;
case 'zset':
$casted = [];
foreach ($value as $k => $v) {
$casted[] = $v;
$casted[] = $k;
}
$value = $casted;
break;
case 'hash':
$casted = [];
foreach ($value as $k => $v) {
$casted[] = $k;
$casted[] = $v;
}
$value = $casted;
break;
default:
break;
}
return $value;
} | [
"protected",
"function",
"castValueForUpdate",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"'string'",
":",
"$",
"value",
"=",
"[",
"(",
"string",
")",
"$",
"value",
"]",
";",
"break",
";",
"case",
"'list'",
":",
"case",
"'set'",
":",
"$",
"value",
"=",
"(",
"array",
")",
"$",
"value",
";",
"break",
";",
"case",
"'zset'",
":",
"$",
"casted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"casted",
"[",
"]",
"=",
"$",
"v",
";",
"$",
"casted",
"[",
"]",
"=",
"$",
"k",
";",
"}",
"$",
"value",
"=",
"$",
"casted",
";",
"break",
";",
"case",
"'hash'",
":",
"$",
"casted",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"casted",
"[",
"]",
"=",
"$",
"k",
";",
"$",
"casted",
"[",
"]",
"=",
"$",
"v",
";",
"}",
"$",
"value",
"=",
"$",
"casted",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Cast value data type for update according to redis data type
@param $value
@return array | [
"Cast",
"value",
"data",
"type",
"for",
"update",
"according",
"to",
"redis",
"data",
"type"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L885-L916 |
37,588 | limen/redisun | src/Model.php | Model.getFindMethodAndParameters | protected function getFindMethodAndParameters()
{
$method = '';
$parameters = [];
switch ($this->type) {
case 'string':
$method = 'get';
break;
case 'list':
$method = 'lrange';
$parameters = [0, -1];
break;
case 'set':
$method = 'smembers';
break;
case 'zset':
$method = 'zrange';
$parameters = [0, -1];
break;
case 'hash':
$method = 'hgetall';
break;
default:
break;
}
return [$method, $parameters];
} | php | protected function getFindMethodAndParameters()
{
$method = '';
$parameters = [];
switch ($this->type) {
case 'string':
$method = 'get';
break;
case 'list':
$method = 'lrange';
$parameters = [0, -1];
break;
case 'set':
$method = 'smembers';
break;
case 'zset':
$method = 'zrange';
$parameters = [0, -1];
break;
case 'hash':
$method = 'hgetall';
break;
default:
break;
}
return [$method, $parameters];
} | [
"protected",
"function",
"getFindMethodAndParameters",
"(",
")",
"{",
"$",
"method",
"=",
"''",
";",
"$",
"parameters",
"=",
"[",
"]",
";",
"switch",
"(",
"$",
"this",
"->",
"type",
")",
"{",
"case",
"'string'",
":",
"$",
"method",
"=",
"'get'",
";",
"break",
";",
"case",
"'list'",
":",
"$",
"method",
"=",
"'lrange'",
";",
"$",
"parameters",
"=",
"[",
"0",
",",
"-",
"1",
"]",
";",
"break",
";",
"case",
"'set'",
":",
"$",
"method",
"=",
"'smembers'",
";",
"break",
";",
"case",
"'zset'",
":",
"$",
"method",
"=",
"'zrange'",
";",
"$",
"parameters",
"=",
"[",
"0",
",",
"-",
"1",
"]",
";",
"break",
";",
"case",
"'hash'",
":",
"$",
"method",
"=",
"'hgetall'",
";",
"break",
";",
"default",
":",
"break",
";",
"}",
"return",
"[",
"$",
"method",
",",
"$",
"parameters",
"]",
";",
"}"
] | Get find method and default parameters according to redis data type.
@return array | [
"Get",
"find",
"method",
"and",
"default",
"parameters",
"according",
"to",
"redis",
"data",
"type",
"."
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L922-L950 |
37,589 | limen/redisun | src/Model.php | Model.getExistKeys | protected function getExistKeys($queryKeys)
{
$keys = $this->markUnboundFields($queryKeys);
$exist = [];
if ($keys) {
$command = $this->commandFactory->getCommand('keys', $keys);
$exist = $this->executeCommand($command);
$exist = array_unique($exist);
}
return $exist;
} | php | protected function getExistKeys($queryKeys)
{
$keys = $this->markUnboundFields($queryKeys);
$exist = [];
if ($keys) {
$command = $this->commandFactory->getCommand('keys', $keys);
$exist = $this->executeCommand($command);
$exist = array_unique($exist);
}
return $exist;
} | [
"protected",
"function",
"getExistKeys",
"(",
"$",
"queryKeys",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"markUnboundFields",
"(",
"$",
"queryKeys",
")",
";",
"$",
"exist",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"keys",
")",
"{",
"$",
"command",
"=",
"$",
"this",
"->",
"commandFactory",
"->",
"getCommand",
"(",
"'keys'",
",",
"$",
"keys",
")",
";",
"$",
"exist",
"=",
"$",
"this",
"->",
"executeCommand",
"(",
"$",
"command",
")",
";",
"$",
"exist",
"=",
"array_unique",
"(",
"$",
"exist",
")",
";",
"}",
"return",
"$",
"exist",
";",
"}"
] | Get existed keys in redis database
@param $queryKeys
@return array|mixed | [
"Get",
"existed",
"keys",
"in",
"redis",
"database"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L958-L973 |
37,590 | limen/redisun | src/Model.php | Model.hasUnboundField | protected function hasUnboundField($key)
{
$parts = $this->explodeKey($key);
foreach ($parts as $part) {
if ($this->isUnboundField($part)) {
return true;
}
}
return false;
} | php | protected function hasUnboundField($key)
{
$parts = $this->explodeKey($key);
foreach ($parts as $part) {
if ($this->isUnboundField($part)) {
return true;
}
}
return false;
} | [
"protected",
"function",
"hasUnboundField",
"(",
"$",
"key",
")",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"explodeKey",
"(",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isUnboundField",
"(",
"$",
"part",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check a key whether has unbound field
@param $key
@return bool | [
"Check",
"a",
"key",
"whether",
"has",
"unbound",
"field"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L1007-L1018 |
37,591 | limen/redisun | src/Model.php | Model.setOrderByFieldIndices | private function setOrderByFieldIndices()
{
$keyParts = $this->explodeKey($this->key);
foreach ($this->orderBys as $field => $order) {
$needle = $this->fieldWrapper[0] . $field . $this->fieldWrapper[1];
$this->orderByFieldIndices[array_search($needle, $keyParts)] = $order;
}
} | php | private function setOrderByFieldIndices()
{
$keyParts = $this->explodeKey($this->key);
foreach ($this->orderBys as $field => $order) {
$needle = $this->fieldWrapper[0] . $field . $this->fieldWrapper[1];
$this->orderByFieldIndices[array_search($needle, $keyParts)] = $order;
}
} | [
"private",
"function",
"setOrderByFieldIndices",
"(",
")",
"{",
"$",
"keyParts",
"=",
"$",
"this",
"->",
"explodeKey",
"(",
"$",
"this",
"->",
"key",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"orderBys",
"as",
"$",
"field",
"=>",
"$",
"order",
")",
"{",
"$",
"needle",
"=",
"$",
"this",
"->",
"fieldWrapper",
"[",
"0",
"]",
".",
"$",
"field",
".",
"$",
"this",
"->",
"fieldWrapper",
"[",
"1",
"]",
";",
"$",
"this",
"->",
"orderByFieldIndices",
"[",
"array_search",
"(",
"$",
"needle",
",",
"$",
"keyParts",
")",
"]",
"=",
"$",
"order",
";",
"}",
"}"
] | Set order by field and order | [
"Set",
"order",
"by",
"field",
"and",
"order"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L1120-L1128 |
37,592 | limen/redisun | src/Model.php | Model.resolveHashes | private function resolveHashes(array $hashes)
{
$assoc = [];
foreach ($hashes as $k => $hash) {
$item = $this->resolveHash($hash);
if ($item) {
$assoc[$k] = $item;
}
}
return $assoc;
} | php | private function resolveHashes(array $hashes)
{
$assoc = [];
foreach ($hashes as $k => $hash) {
$item = $this->resolveHash($hash);
if ($item) {
$assoc[$k] = $item;
}
}
return $assoc;
} | [
"private",
"function",
"resolveHashes",
"(",
"array",
"$",
"hashes",
")",
"{",
"$",
"assoc",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"hashes",
"as",
"$",
"k",
"=>",
"$",
"hash",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"resolveHash",
"(",
"$",
"hash",
")",
";",
"if",
"(",
"$",
"item",
")",
"{",
"$",
"assoc",
"[",
"$",
"k",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"assoc",
";",
"}"
] | raw hash data to associate array
@param array $hashes
@return array | [
"raw",
"hash",
"data",
"to",
"associate",
"array"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Model.php#L1172-L1183 |
37,593 | limen/redisun | src/Commands/Command.php | Command.parseResponse | function parseResponse($data)
{
if (empty($data)) {
return [];
}
if (isset($data[0]) && count($data[0]) === $this->getKeysCount()) {
$items = array_combine($data[0], $data[1]);
return array_filter($items, [$this, 'notNil']);
}
throw new Exception('Error when evaluate lua script. Response is: ' . json_encode($data));
} | php | function parseResponse($data)
{
if (empty($data)) {
return [];
}
if (isset($data[0]) && count($data[0]) === $this->getKeysCount()) {
$items = array_combine($data[0], $data[1]);
return array_filter($items, [$this, 'notNil']);
}
throw new Exception('Error when evaluate lua script. Response is: ' . json_encode($data));
} | [
"function",
"parseResponse",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"&&",
"count",
"(",
"$",
"data",
"[",
"0",
"]",
")",
"===",
"$",
"this",
"->",
"getKeysCount",
"(",
")",
")",
"{",
"$",
"items",
"=",
"array_combine",
"(",
"$",
"data",
"[",
"0",
"]",
",",
"$",
"data",
"[",
"1",
"]",
")",
";",
"return",
"array_filter",
"(",
"$",
"items",
",",
"[",
"$",
"this",
",",
"'notNil'",
"]",
")",
";",
"}",
"throw",
"new",
"Exception",
"(",
"'Error when evaluate lua script. Response is: '",
".",
"json_encode",
"(",
"$",
"data",
")",
")",
";",
"}"
] | Resolve data returned from "eval"
@param $data
@return mixed
@throws Exception | [
"Resolve",
"data",
"returned",
"from",
"eval"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/Commands/Command.php#L99-L112 |
37,594 | limen/redisun | src/QueryBuilder.php | QueryBuilder.getValidQueryKeys | protected function getValidQueryKeys()
{
$whereIns = [];
foreach ($this->whereBetweens as $field => $range) {
$whereIns[$field] = range($range[0], $range[1]);
}
foreach ($whereIns as $key => $value) {
$this->whereIn($key, $value);
}
$this->queryKeys = [];
foreach ($this->whereIns as $field => $range) {
if ($this->queryKeys === []) {
foreach ($range as $value) {
$this->queryKeys[] = $this->bindValue($this->key, $field, $value);
}
} else {
$queryKeys = $this->queryKeys;
$this->queryKeys = [];
foreach ($queryKeys as $item) {
foreach ($range as $value) {
$this->queryKeys[] = $this->bindValue($item, $field, $value);
}
}
}
}
$this->queryKeys = array_unique(array_values($this->queryKeys));
return $this;
} | php | protected function getValidQueryKeys()
{
$whereIns = [];
foreach ($this->whereBetweens as $field => $range) {
$whereIns[$field] = range($range[0], $range[1]);
}
foreach ($whereIns as $key => $value) {
$this->whereIn($key, $value);
}
$this->queryKeys = [];
foreach ($this->whereIns as $field => $range) {
if ($this->queryKeys === []) {
foreach ($range as $value) {
$this->queryKeys[] = $this->bindValue($this->key, $field, $value);
}
} else {
$queryKeys = $this->queryKeys;
$this->queryKeys = [];
foreach ($queryKeys as $item) {
foreach ($range as $value) {
$this->queryKeys[] = $this->bindValue($item, $field, $value);
}
}
}
}
$this->queryKeys = array_unique(array_values($this->queryKeys));
return $this;
} | [
"protected",
"function",
"getValidQueryKeys",
"(",
")",
"{",
"$",
"whereIns",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"whereBetweens",
"as",
"$",
"field",
"=>",
"$",
"range",
")",
"{",
"$",
"whereIns",
"[",
"$",
"field",
"]",
"=",
"range",
"(",
"$",
"range",
"[",
"0",
"]",
",",
"$",
"range",
"[",
"1",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"whereIns",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"whereIn",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"queryKeys",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"whereIns",
"as",
"$",
"field",
"=>",
"$",
"range",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"queryKeys",
"===",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"range",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"queryKeys",
"[",
"]",
"=",
"$",
"this",
"->",
"bindValue",
"(",
"$",
"this",
"->",
"key",
",",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"}",
"else",
"{",
"$",
"queryKeys",
"=",
"$",
"this",
"->",
"queryKeys",
";",
"$",
"this",
"->",
"queryKeys",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"queryKeys",
"as",
"$",
"item",
")",
"{",
"foreach",
"(",
"$",
"range",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"queryKeys",
"[",
"]",
"=",
"$",
"this",
"->",
"bindValue",
"(",
"$",
"item",
",",
"$",
"field",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}",
"$",
"this",
"->",
"queryKeys",
"=",
"array_unique",
"(",
"array_values",
"(",
"$",
"this",
"->",
"queryKeys",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Get valid query keys
@return $this | [
"Get",
"valid",
"query",
"keys"
] | c9c8f91a761b5e893415d28615f0bdf9dbc34fd4 | https://github.com/limen/redisun/blob/c9c8f91a761b5e893415d28615f0bdf9dbc34fd4/src/QueryBuilder.php#L157-L190 |
37,595 | cybercog/laravel-likeable | src/Services/LikeableService.php | LikeableService.addLikeTo | public function addLikeTo(LikeableContract $likeable, $type, $userId)
{
$userId = $this->getLikerUserId($userId);
$like = $likeable->likesAndDislikes()->where([
'user_id' => $userId,
])->first();
if (!$like) {
$likeable->likes()->create([
'user_id' => $userId,
'type_id' => $this->getLikeTypeId($type),
]);
return;
}
if ($like->type_id == $this->getLikeTypeId($type)) {
return;
}
$like->delete();
$likeable->likes()->create([
'user_id' => $userId,
'type_id' => $this->getLikeTypeId($type),
]);
} | php | public function addLikeTo(LikeableContract $likeable, $type, $userId)
{
$userId = $this->getLikerUserId($userId);
$like = $likeable->likesAndDislikes()->where([
'user_id' => $userId,
])->first();
if (!$like) {
$likeable->likes()->create([
'user_id' => $userId,
'type_id' => $this->getLikeTypeId($type),
]);
return;
}
if ($like->type_id == $this->getLikeTypeId($type)) {
return;
}
$like->delete();
$likeable->likes()->create([
'user_id' => $userId,
'type_id' => $this->getLikeTypeId($type),
]);
} | [
"public",
"function",
"addLikeTo",
"(",
"LikeableContract",
"$",
"likeable",
",",
"$",
"type",
",",
"$",
"userId",
")",
"{",
"$",
"userId",
"=",
"$",
"this",
"->",
"getLikerUserId",
"(",
"$",
"userId",
")",
";",
"$",
"like",
"=",
"$",
"likeable",
"->",
"likesAndDislikes",
"(",
")",
"->",
"where",
"(",
"[",
"'user_id'",
"=>",
"$",
"userId",
",",
"]",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"like",
")",
"{",
"$",
"likeable",
"->",
"likes",
"(",
")",
"->",
"create",
"(",
"[",
"'user_id'",
"=>",
"$",
"userId",
",",
"'type_id'",
"=>",
"$",
"this",
"->",
"getLikeTypeId",
"(",
"$",
"type",
")",
",",
"]",
")",
";",
"return",
";",
"}",
"if",
"(",
"$",
"like",
"->",
"type_id",
"==",
"$",
"this",
"->",
"getLikeTypeId",
"(",
"$",
"type",
")",
")",
"{",
"return",
";",
"}",
"$",
"like",
"->",
"delete",
"(",
")",
";",
"$",
"likeable",
"->",
"likes",
"(",
")",
"->",
"create",
"(",
"[",
"'user_id'",
"=>",
"$",
"userId",
",",
"'type_id'",
"=>",
"$",
"this",
"->",
"getLikeTypeId",
"(",
"$",
"type",
")",
",",
"]",
")",
";",
"}"
] | Add a like to likeable model by user.
@param \Cog\Likeable\Contracts\Likeable $likeable
@param string $type
@param string $userId
@return void
@throws \Cog\Likeable\Exceptions\LikerNotDefinedException
@throws \Cog\Likeable\Exceptions\LikeTypeInvalidException | [
"Add",
"a",
"like",
"to",
"likeable",
"model",
"by",
"user",
"."
] | 1d5a39b3bc33fc168e7530504a2e84f96f8e90d2 | https://github.com/cybercog/laravel-likeable/blob/1d5a39b3bc33fc168e7530504a2e84f96f8e90d2/src/Services/LikeableService.php#L43-L70 |
37,596 | cybercog/laravel-likeable | src/Services/LikeableService.php | LikeableService.removeLikeFrom | public function removeLikeFrom(LikeableContract $likeable, $type, $userId)
{
$like = $likeable->likesAndDislikes()->where([
'user_id' => $this->getLikerUserId($userId),
'type_id' => $this->getLikeTypeId($type),
])->first();
if (!$like) {
return;
}
$like->delete();
} | php | public function removeLikeFrom(LikeableContract $likeable, $type, $userId)
{
$like = $likeable->likesAndDislikes()->where([
'user_id' => $this->getLikerUserId($userId),
'type_id' => $this->getLikeTypeId($type),
])->first();
if (!$like) {
return;
}
$like->delete();
} | [
"public",
"function",
"removeLikeFrom",
"(",
"LikeableContract",
"$",
"likeable",
",",
"$",
"type",
",",
"$",
"userId",
")",
"{",
"$",
"like",
"=",
"$",
"likeable",
"->",
"likesAndDislikes",
"(",
")",
"->",
"where",
"(",
"[",
"'user_id'",
"=>",
"$",
"this",
"->",
"getLikerUserId",
"(",
"$",
"userId",
")",
",",
"'type_id'",
"=>",
"$",
"this",
"->",
"getLikeTypeId",
"(",
"$",
"type",
")",
",",
"]",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"like",
")",
"{",
"return",
";",
"}",
"$",
"like",
"->",
"delete",
"(",
")",
";",
"}"
] | Remove a like to likeable model by user.
@param \Cog\Likeable\Contracts\Likeable $likeable
@param string $type
@param int|null $userId
@return void
@throws \Cog\Likeable\Exceptions\LikerNotDefinedException
@throws \Cog\Likeable\Exceptions\LikeTypeInvalidException | [
"Remove",
"a",
"like",
"to",
"likeable",
"model",
"by",
"user",
"."
] | 1d5a39b3bc33fc168e7530504a2e84f96f8e90d2 | https://github.com/cybercog/laravel-likeable/blob/1d5a39b3bc33fc168e7530504a2e84f96f8e90d2/src/Services/LikeableService.php#L83-L95 |
37,597 | cybercog/laravel-likeable | src/Services/LikeableService.php | LikeableService.decrementLikesCount | public function decrementLikesCount(LikeableContract $likeable)
{
$counter = $likeable->likesCounter()->first();
if (!$counter) {
return;
}
$counter->decrement('count');
} | php | public function decrementLikesCount(LikeableContract $likeable)
{
$counter = $likeable->likesCounter()->first();
if (!$counter) {
return;
}
$counter->decrement('count');
} | [
"public",
"function",
"decrementLikesCount",
"(",
"LikeableContract",
"$",
"likeable",
")",
"{",
"$",
"counter",
"=",
"$",
"likeable",
"->",
"likesCounter",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"counter",
")",
"{",
"return",
";",
"}",
"$",
"counter",
"->",
"decrement",
"(",
"'count'",
")",
";",
"}"
] | Decrement the total like count stored in the counter.
@param \Cog\Likeable\Contracts\Likeable $likeable
@return void | [
"Decrement",
"the",
"total",
"like",
"count",
"stored",
"in",
"the",
"counter",
"."
] | 1d5a39b3bc33fc168e7530504a2e84f96f8e90d2 | https://github.com/cybercog/laravel-likeable/blob/1d5a39b3bc33fc168e7530504a2e84f96f8e90d2/src/Services/LikeableService.php#L163-L172 |
37,598 | cybercog/laravel-likeable | src/Services/LikeableService.php | LikeableService.incrementLikesCount | public function incrementLikesCount(LikeableContract $likeable)
{
$counter = $likeable->likesCounter()->first();
if (!$counter) {
$counter = $likeable->likesCounter()->create([
'count' => 0,
'type_id' => LikeType::LIKE,
]);
}
$counter->increment('count');
} | php | public function incrementLikesCount(LikeableContract $likeable)
{
$counter = $likeable->likesCounter()->first();
if (!$counter) {
$counter = $likeable->likesCounter()->create([
'count' => 0,
'type_id' => LikeType::LIKE,
]);
}
$counter->increment('count');
} | [
"public",
"function",
"incrementLikesCount",
"(",
"LikeableContract",
"$",
"likeable",
")",
"{",
"$",
"counter",
"=",
"$",
"likeable",
"->",
"likesCounter",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"counter",
")",
"{",
"$",
"counter",
"=",
"$",
"likeable",
"->",
"likesCounter",
"(",
")",
"->",
"create",
"(",
"[",
"'count'",
"=>",
"0",
",",
"'type_id'",
"=>",
"LikeType",
"::",
"LIKE",
",",
"]",
")",
";",
"}",
"$",
"counter",
"->",
"increment",
"(",
"'count'",
")",
";",
"}"
] | Increment the total like count stored in the counter.
@param \Cog\Likeable\Contracts\Likeable $likeable
@return void | [
"Increment",
"the",
"total",
"like",
"count",
"stored",
"in",
"the",
"counter",
"."
] | 1d5a39b3bc33fc168e7530504a2e84f96f8e90d2 | https://github.com/cybercog/laravel-likeable/blob/1d5a39b3bc33fc168e7530504a2e84f96f8e90d2/src/Services/LikeableService.php#L180-L192 |
37,599 | cybercog/laravel-likeable | src/Services/LikeableService.php | LikeableService.decrementDislikesCount | public function decrementDislikesCount(LikeableContract $likeable)
{
$counter = $likeable->dislikesCounter()->first();
if (!$counter) {
return;
}
$counter->decrement('count');
} | php | public function decrementDislikesCount(LikeableContract $likeable)
{
$counter = $likeable->dislikesCounter()->first();
if (!$counter) {
return;
}
$counter->decrement('count');
} | [
"public",
"function",
"decrementDislikesCount",
"(",
"LikeableContract",
"$",
"likeable",
")",
"{",
"$",
"counter",
"=",
"$",
"likeable",
"->",
"dislikesCounter",
"(",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"!",
"$",
"counter",
")",
"{",
"return",
";",
"}",
"$",
"counter",
"->",
"decrement",
"(",
"'count'",
")",
";",
"}"
] | Decrement the total dislike count stored in the counter.
@param \Cog\Likeable\Contracts\Likeable $likeable
@return void | [
"Decrement",
"the",
"total",
"dislike",
"count",
"stored",
"in",
"the",
"counter",
"."
] | 1d5a39b3bc33fc168e7530504a2e84f96f8e90d2 | https://github.com/cybercog/laravel-likeable/blob/1d5a39b3bc33fc168e7530504a2e84f96f8e90d2/src/Services/LikeableService.php#L200-L209 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.