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
|
---|---|---|---|---|---|---|---|---|---|---|---|
16,400 | itgalaxy/bin-wrapper | src/BinWrapper.php | BinWrapper.binCheck | private function binCheck($bin, $args = ['--help'])
{
$isExecutable = is_executable($bin);
if (!$isExecutable) {
throw new \Exception(
'Couldn\'t execute the ' . $bin . ' binary. Make sure it has the right permissions.'
);
}
exec($bin . ' ' . implode(' ', $args), $output, $returnVar);
if ($returnVar !== 0) {
return false;
}
return true;
} | php | private function binCheck($bin, $args = ['--help'])
{
$isExecutable = is_executable($bin);
if (!$isExecutable) {
throw new \Exception(
'Couldn\'t execute the ' . $bin . ' binary. Make sure it has the right permissions.'
);
}
exec($bin . ' ' . implode(' ', $args), $output, $returnVar);
if ($returnVar !== 0) {
return false;
}
return true;
} | [
"private",
"function",
"binCheck",
"(",
"$",
"bin",
",",
"$",
"args",
"=",
"[",
"'--help'",
"]",
")",
"{",
"$",
"isExecutable",
"=",
"is_executable",
"(",
"$",
"bin",
")",
";",
"if",
"(",
"!",
"$",
"isExecutable",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Couldn\\'t execute the '",
".",
"$",
"bin",
".",
"' binary. Make sure it has the right permissions.'",
")",
";",
"}",
"exec",
"(",
"$",
"bin",
".",
"' '",
".",
"implode",
"(",
"' '",
",",
"$",
"args",
")",
",",
"$",
"output",
",",
"$",
"returnVar",
")",
";",
"if",
"(",
"$",
"returnVar",
"!==",
"0",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Todo move to separatly repository | [
"Todo",
"move",
"to",
"separatly",
"repository"
]
| f4217cb6a1ae5a2abea180255ba14ef264118d43 | https://github.com/itgalaxy/bin-wrapper/blob/f4217cb6a1ae5a2abea180255ba14ef264118d43/src/BinWrapper.php#L198-L215 |
16,401 | hollodotme/TreeMDown | src/FileSystem/Tree.php | Tree.getLeafObject | public function getLeafObject( string $filepath ) : Leaf
{
$leafObject = new $this->leafObjectClass( $this->search, $filepath );
if ( $leafObject instanceof Leaf )
{
return $leafObject;
}
throw new \RuntimeException( sprintf( '%s is not a subclass of %s\\Leaf', $this->leafObjectClass, __NAMESPACE__ ) );
} | php | public function getLeafObject( string $filepath ) : Leaf
{
$leafObject = new $this->leafObjectClass( $this->search, $filepath );
if ( $leafObject instanceof Leaf )
{
return $leafObject;
}
throw new \RuntimeException( sprintf( '%s is not a subclass of %s\\Leaf', $this->leafObjectClass, __NAMESPACE__ ) );
} | [
"public",
"function",
"getLeafObject",
"(",
"string",
"$",
"filepath",
")",
":",
"Leaf",
"{",
"$",
"leafObject",
"=",
"new",
"$",
"this",
"->",
"leafObjectClass",
"(",
"$",
"this",
"->",
"search",
",",
"$",
"filepath",
")",
";",
"if",
"(",
"$",
"leafObject",
"instanceof",
"Leaf",
")",
"{",
"return",
"$",
"leafObject",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'%s is not a subclass of %s\\\\Leaf'",
",",
"$",
"this",
"->",
"leafObjectClass",
",",
"__NAMESPACE__",
")",
")",
";",
"}"
]
| Return a new leaf object
@param string $filepath
@throws \RuntimeException
@return Leaf | [
"Return",
"a",
"new",
"leaf",
"object"
]
| 462c4118c70b68963e0176d540fc8502730ffe27 | https://github.com/hollodotme/TreeMDown/blob/462c4118c70b68963e0176d540fc8502730ffe27/src/FileSystem/Tree.php#L197-L207 |
16,402 | BugBuster1701/banner | classes/BannerImage.php | BannerImage.getBannerImageSize | public function getBannerImageSize($BannerImage,$BannerType)
{
switch ($BannerType)
{
case self::BANNER_TYPE_INTERN :
return $this->getImageSizeInternal($BannerImage);
break;
case self::BANNER_TYPE_EXTERN :
return $this->getImageSizeExternal($BannerImage);
break;
case self::BANNER_TYPE_TEXT :
return false;
break;
default :
return false;
break;
}
} | php | public function getBannerImageSize($BannerImage,$BannerType)
{
switch ($BannerType)
{
case self::BANNER_TYPE_INTERN :
return $this->getImageSizeInternal($BannerImage);
break;
case self::BANNER_TYPE_EXTERN :
return $this->getImageSizeExternal($BannerImage);
break;
case self::BANNER_TYPE_TEXT :
return false;
break;
default :
return false;
break;
}
} | [
"public",
"function",
"getBannerImageSize",
"(",
"$",
"BannerImage",
",",
"$",
"BannerType",
")",
"{",
"switch",
"(",
"$",
"BannerType",
")",
"{",
"case",
"self",
"::",
"BANNER_TYPE_INTERN",
":",
"return",
"$",
"this",
"->",
"getImageSizeInternal",
"(",
"$",
"BannerImage",
")",
";",
"break",
";",
"case",
"self",
"::",
"BANNER_TYPE_EXTERN",
":",
"return",
"$",
"this",
"->",
"getImageSizeExternal",
"(",
"$",
"BannerImage",
")",
";",
"break",
";",
"case",
"self",
"::",
"BANNER_TYPE_TEXT",
":",
"return",
"false",
";",
"break",
";",
"default",
":",
"return",
"false",
";",
"break",
";",
"}",
"}"
]
| Get the size of an image
@param string $BannerImage Image path/link
@param string $BannerType intern,extern,text
@return mixed $array / false | [
"Get",
"the",
"size",
"of",
"an",
"image"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L85-L102 |
16,403 | BugBuster1701/banner | classes/BannerImage.php | BannerImage.getImageSizeInternal | protected function getImageSizeInternal($BannerImage)
{
try
{
$arrImageSize = getimagesize(TL_ROOT . '/' . $BannerImage);
}
catch (\Exception $e)
{
$arrImageSize = false;
}
if ($arrImageSize === false)
{
//Workaround for PHP without zlib on SWC files
$arrImageSize = $this->getImageSizeCompressed($BannerImage);
}
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSize,true));
return $arrImageSize;
} | php | protected function getImageSizeInternal($BannerImage)
{
try
{
$arrImageSize = getimagesize(TL_ROOT . '/' . $BannerImage);
}
catch (\Exception $e)
{
$arrImageSize = false;
}
if ($arrImageSize === false)
{
//Workaround for PHP without zlib on SWC files
$arrImageSize = $this->getImageSizeCompressed($BannerImage);
}
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSize,true));
return $arrImageSize;
} | [
"protected",
"function",
"getImageSizeInternal",
"(",
"$",
"BannerImage",
")",
"{",
"try",
"{",
"$",
"arrImageSize",
"=",
"getimagesize",
"(",
"TL_ROOT",
".",
"'/'",
".",
"$",
"BannerImage",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"arrImageSize",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"arrImageSize",
"===",
"false",
")",
"{",
"//Workaround for PHP without zlib on SWC files",
"$",
"arrImageSize",
"=",
"$",
"this",
"->",
"getImageSizeCompressed",
"(",
"$",
"BannerImage",
")",
";",
"}",
"ModuleBannerLog",
"::",
"writeLog",
"(",
"__METHOD__",
",",
"__LINE__",
",",
"'Image Size: '",
".",
"print_r",
"(",
"$",
"arrImageSize",
",",
"true",
")",
")",
";",
"return",
"$",
"arrImageSize",
";",
"}"
]
| Get the size of an internal image
@param string $BannerImage Image path
@return mixed $array / false | [
"Get",
"the",
"size",
"of",
"an",
"internal",
"image"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L110-L129 |
16,404 | BugBuster1701/banner | classes/BannerImage.php | BannerImage.getImageSizeExternal | protected function getImageSizeExternal($BannerImage)
{
$token = md5(uniqid(rand(), true));
$tmpImage = 'system/tmp/mod_banner_fe_'.$token.'.tmp';
// HOOK: proxy module
if ( \Config::get('useProxy')
&& in_array('proxy', \ModuleLoader::getActive())
)
{
$objRequest = new \ProxyRequest();
}
else
{
$objRequest = new \Request();
$objRequest->redirect = true; // #75: Unterstützung der redirects für externe Affiliat Banner
$objRequest->rlimit = 5; // #75: Unterstützung der redirects für externe Affiliat Banner
}
$objRequest->send(html_entity_decode($BannerImage, ENT_NOQUOTES, 'UTF-8'));
//old: Test auf chunked, nicht noetig solange Contao bei HTTP/1.0 bleibt
try
{
$objFile = new \File($tmpImage);
$objFile->write($objRequest->response);
$objFile->close();
}
// Temp directory not writeable
catch (\Exception $e)
{
if ($e->getCode() == 0)
{
log_message('[getImageSizeExternal] tmpFile Problem: notWriteable', 'error.log');
}
else
{
log_message('[getImageSizeExternal] tmpFile Problem: error', 'error.log');
}
return false;
}
$objRequest=null;
unset($objRequest);
$arrImageSize = $this->getImageSizeInternal($tmpImage);
if ($arrImageSize === false) //Workaround fuer PHP ohne zlib bei SWC Files
{
$arrImageSize = $this->getImageSizeCompressed($tmpImage);
}
$objFile->delete();
$objFile = null;
unset($objFile);
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSize,true));
return $arrImageSize;
} | php | protected function getImageSizeExternal($BannerImage)
{
$token = md5(uniqid(rand(), true));
$tmpImage = 'system/tmp/mod_banner_fe_'.$token.'.tmp';
// HOOK: proxy module
if ( \Config::get('useProxy')
&& in_array('proxy', \ModuleLoader::getActive())
)
{
$objRequest = new \ProxyRequest();
}
else
{
$objRequest = new \Request();
$objRequest->redirect = true; // #75: Unterstützung der redirects für externe Affiliat Banner
$objRequest->rlimit = 5; // #75: Unterstützung der redirects für externe Affiliat Banner
}
$objRequest->send(html_entity_decode($BannerImage, ENT_NOQUOTES, 'UTF-8'));
//old: Test auf chunked, nicht noetig solange Contao bei HTTP/1.0 bleibt
try
{
$objFile = new \File($tmpImage);
$objFile->write($objRequest->response);
$objFile->close();
}
// Temp directory not writeable
catch (\Exception $e)
{
if ($e->getCode() == 0)
{
log_message('[getImageSizeExternal] tmpFile Problem: notWriteable', 'error.log');
}
else
{
log_message('[getImageSizeExternal] tmpFile Problem: error', 'error.log');
}
return false;
}
$objRequest=null;
unset($objRequest);
$arrImageSize = $this->getImageSizeInternal($tmpImage);
if ($arrImageSize === false) //Workaround fuer PHP ohne zlib bei SWC Files
{
$arrImageSize = $this->getImageSizeCompressed($tmpImage);
}
$objFile->delete();
$objFile = null;
unset($objFile);
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSize,true));
return $arrImageSize;
} | [
"protected",
"function",
"getImageSizeExternal",
"(",
"$",
"BannerImage",
")",
"{",
"$",
"token",
"=",
"md5",
"(",
"uniqid",
"(",
"rand",
"(",
")",
",",
"true",
")",
")",
";",
"$",
"tmpImage",
"=",
"'system/tmp/mod_banner_fe_'",
".",
"$",
"token",
".",
"'.tmp'",
";",
"// HOOK: proxy module",
"if",
"(",
"\\",
"Config",
"::",
"get",
"(",
"'useProxy'",
")",
"&&",
"in_array",
"(",
"'proxy'",
",",
"\\",
"ModuleLoader",
"::",
"getActive",
"(",
")",
")",
")",
"{",
"$",
"objRequest",
"=",
"new",
"\\",
"ProxyRequest",
"(",
")",
";",
"}",
"else",
"{",
"$",
"objRequest",
"=",
"new",
"\\",
"Request",
"(",
")",
";",
"$",
"objRequest",
"->",
"redirect",
"=",
"true",
";",
"// #75: Unterstützung der redirects für externe Affiliat Banner",
"$",
"objRequest",
"->",
"rlimit",
"=",
"5",
";",
"// #75: Unterstützung der redirects für externe Affiliat Banner",
"}",
"$",
"objRequest",
"->",
"send",
"(",
"html_entity_decode",
"(",
"$",
"BannerImage",
",",
"ENT_NOQUOTES",
",",
"'UTF-8'",
")",
")",
";",
"//old: Test auf chunked, nicht noetig solange Contao bei HTTP/1.0 bleibt",
"try",
"{",
"$",
"objFile",
"=",
"new",
"\\",
"File",
"(",
"$",
"tmpImage",
")",
";",
"$",
"objFile",
"->",
"write",
"(",
"$",
"objRequest",
"->",
"response",
")",
";",
"$",
"objFile",
"->",
"close",
"(",
")",
";",
"}",
"// Temp directory not writeable",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"->",
"getCode",
"(",
")",
"==",
"0",
")",
"{",
"log_message",
"(",
"'[getImageSizeExternal] tmpFile Problem: notWriteable'",
",",
"'error.log'",
")",
";",
"}",
"else",
"{",
"log_message",
"(",
"'[getImageSizeExternal] tmpFile Problem: error'",
",",
"'error.log'",
")",
";",
"}",
"return",
"false",
";",
"}",
"$",
"objRequest",
"=",
"null",
";",
"unset",
"(",
"$",
"objRequest",
")",
";",
"$",
"arrImageSize",
"=",
"$",
"this",
"->",
"getImageSizeInternal",
"(",
"$",
"tmpImage",
")",
";",
"if",
"(",
"$",
"arrImageSize",
"===",
"false",
")",
"//Workaround fuer PHP ohne zlib bei SWC Files ",
"{",
"$",
"arrImageSize",
"=",
"$",
"this",
"->",
"getImageSizeCompressed",
"(",
"$",
"tmpImage",
")",
";",
"}",
"$",
"objFile",
"->",
"delete",
"(",
")",
";",
"$",
"objFile",
"=",
"null",
";",
"unset",
"(",
"$",
"objFile",
")",
";",
"ModuleBannerLog",
"::",
"writeLog",
"(",
"__METHOD__",
",",
"__LINE__",
",",
"'Image Size: '",
".",
"print_r",
"(",
"$",
"arrImageSize",
",",
"true",
")",
")",
";",
"return",
"$",
"arrImageSize",
";",
"}"
]
| Get the size of an external image
@param string $BannerImage Image link
@return mixed $array / false | [
"Get",
"the",
"size",
"of",
"an",
"external",
"image"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L137-L190 |
16,405 | BugBuster1701/banner | classes/BannerImage.php | BannerImage.getImageSizeCompressed | protected function getImageSizeCompressed($BannerImage)
{
$arrImageSize = false;
$res = $this->uncompressSwcData($BannerImage);
if ($res)
{
// width,height
$arrImageSize = array($res[0], $res[1], 13); // 13 = SWC
}
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSize,true));
return $arrImageSize;
} | php | protected function getImageSizeCompressed($BannerImage)
{
$arrImageSize = false;
$res = $this->uncompressSwcData($BannerImage);
if ($res)
{
// width,height
$arrImageSize = array($res[0], $res[1], 13); // 13 = SWC
}
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSize,true));
return $arrImageSize;
} | [
"protected",
"function",
"getImageSizeCompressed",
"(",
"$",
"BannerImage",
")",
"{",
"$",
"arrImageSize",
"=",
"false",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"uncompressSwcData",
"(",
"$",
"BannerImage",
")",
";",
"if",
"(",
"$",
"res",
")",
"{",
"// width,height",
"$",
"arrImageSize",
"=",
"array",
"(",
"$",
"res",
"[",
"0",
"]",
",",
"$",
"res",
"[",
"1",
"]",
",",
"13",
")",
";",
"// 13 = SWC",
"}",
"ModuleBannerLog",
"::",
"writeLog",
"(",
"__METHOD__",
",",
"__LINE__",
",",
"'Image Size: '",
".",
"print_r",
"(",
"$",
"arrImageSize",
",",
"true",
")",
")",
";",
"return",
"$",
"arrImageSize",
";",
"}"
]
| getimagesize without zlib doesn't work
workaround for this
@param string $BannerImage Image
@return mixed $array / false | [
"getimagesize",
"without",
"zlib",
"doesn",
"t",
"work",
"workaround",
"for",
"this"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L199-L211 |
16,406 | BugBuster1701/banner | classes/BannerImage.php | BannerImage.getBannerImageSizeNew | public function getBannerImageSizeNew($oldWidth,$oldHeight,$newWidth=0,$newHeight=0)
{
$Width = $oldWidth; //Default, and flash require this
$Height = $oldHeight; //Default, and flash require this
$oriSize = true; //Attribute for images without conversion
if ($newWidth > 0 && $newHeight > 0)
{
$Width = $newWidth;
$Height = $newHeight;
$oriSize = false;
}
elseif ($newWidth > 0)
{
$Width = $newWidth;
$Height = ceil($newWidth * $oldHeight / $oldWidth);
$oriSize = false;
}
elseif ($newHeight > 0)
{
$Width = ceil($newHeight * $oldWidth / $oldHeight);
$Height = $newHeight;
$oriSize = false;
}
return array($Width,$Height,$oriSize);
} | php | public function getBannerImageSizeNew($oldWidth,$oldHeight,$newWidth=0,$newHeight=0)
{
$Width = $oldWidth; //Default, and flash require this
$Height = $oldHeight; //Default, and flash require this
$oriSize = true; //Attribute for images without conversion
if ($newWidth > 0 && $newHeight > 0)
{
$Width = $newWidth;
$Height = $newHeight;
$oriSize = false;
}
elseif ($newWidth > 0)
{
$Width = $newWidth;
$Height = ceil($newWidth * $oldHeight / $oldWidth);
$oriSize = false;
}
elseif ($newHeight > 0)
{
$Width = ceil($newHeight * $oldWidth / $oldHeight);
$Height = $newHeight;
$oriSize = false;
}
return array($Width,$Height,$oriSize);
} | [
"public",
"function",
"getBannerImageSizeNew",
"(",
"$",
"oldWidth",
",",
"$",
"oldHeight",
",",
"$",
"newWidth",
"=",
"0",
",",
"$",
"newHeight",
"=",
"0",
")",
"{",
"$",
"Width",
"=",
"$",
"oldWidth",
";",
"//Default, and flash require this",
"$",
"Height",
"=",
"$",
"oldHeight",
";",
"//Default, and flash require this",
"$",
"oriSize",
"=",
"true",
";",
"//Attribute for images without conversion",
"if",
"(",
"$",
"newWidth",
">",
"0",
"&&",
"$",
"newHeight",
">",
"0",
")",
"{",
"$",
"Width",
"=",
"$",
"newWidth",
";",
"$",
"Height",
"=",
"$",
"newHeight",
";",
"$",
"oriSize",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"newWidth",
">",
"0",
")",
"{",
"$",
"Width",
"=",
"$",
"newWidth",
";",
"$",
"Height",
"=",
"ceil",
"(",
"$",
"newWidth",
"*",
"$",
"oldHeight",
"/",
"$",
"oldWidth",
")",
";",
"$",
"oriSize",
"=",
"false",
";",
"}",
"elseif",
"(",
"$",
"newHeight",
">",
"0",
")",
"{",
"$",
"Width",
"=",
"ceil",
"(",
"$",
"newHeight",
"*",
"$",
"oldWidth",
"/",
"$",
"oldHeight",
")",
";",
"$",
"Height",
"=",
"$",
"newHeight",
";",
"$",
"oriSize",
"=",
"false",
";",
"}",
"return",
"array",
"(",
"$",
"Width",
",",
"$",
"Height",
",",
"$",
"oriSize",
")",
";",
"}"
]
| Calculate the new size for witdh and height
@param int $oldWidth ,mandatory
@param int $oldHeight ,mandatory
@param int $newWidth ,optional
@param int $newHeight ,optional
@return array $Width,$Height,$oriSize | [
"Calculate",
"the",
"new",
"size",
"for",
"witdh",
"and",
"height"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L323-L348 |
16,407 | BugBuster1701/banner | classes/BannerImage.php | BannerImage.getCheckBannerImageSize | public function getCheckBannerImageSize($arrImageSize, $maxWidth, $maxHeight)
{
//$arrImageSize[0] Breite (max 250px in BE)
//$arrImageSize[1] Hoehe (max 40px in BE)
//$arrImageSize[2] Type
if ($arrImageSize[0] > $arrImageSize[1]) // Breite > Hoehe = Landscape ==
{
if ($arrImageSize[0] > $maxWidth)
{ //neue feste Breite
$newImageSize = $this->getBannerImageSizeNew($arrImageSize[0],$arrImageSize[1], $maxWidth, 0);
$intWidth = $newImageSize[0];
$intHeight = $newImageSize[1];
$oriSize = $newImageSize[2];
}
else
{
$intWidth = $arrImageSize[0];
$intHeight = $arrImageSize[1];
$oriSize = true; // Merkmal fuer Bilder ohne Umrechnung
}
}
else
{ // Hoehe >= Breite, ggf. Hoehe verkleinern
if ($arrImageSize[1] > $maxWidth) // Hoehe > max Breite = Portrait ||
{
// pruefen ob bei neuer Hoehe die Breite zu klein wird
if (($maxWidth*$arrImageSize[0]/$arrImageSize[1]) < $maxHeight)
{
// Breite statt Hoehe setzen, Breite auf maximale Hoehe
$newImageSize = $this->getBannerImageSizeNew($arrImageSize[0],$arrImageSize[1], $maxHeight, 0);
$intWidth = $newImageSize[0];
$intHeight = $newImageSize[1];
$oriSize = $newImageSize[2];
}
else
{
$newImageSize = $this->getBannerImageSizeNew($arrImageSize[0],$arrImageSize[1], 0, $maxHeight);
$intWidth = $newImageSize[0];
$intHeight = $newImageSize[1];
$oriSize = $newImageSize[2];
}
}
else
{
$intWidth = $arrImageSize[0];
$intHeight = $arrImageSize[1];
$oriSize = true; // Merkmal fuer Bilder ohne Umrechnung
}
}
return array($intWidth,$intHeight,$oriSize);
} | php | public function getCheckBannerImageSize($arrImageSize, $maxWidth, $maxHeight)
{
//$arrImageSize[0] Breite (max 250px in BE)
//$arrImageSize[1] Hoehe (max 40px in BE)
//$arrImageSize[2] Type
if ($arrImageSize[0] > $arrImageSize[1]) // Breite > Hoehe = Landscape ==
{
if ($arrImageSize[0] > $maxWidth)
{ //neue feste Breite
$newImageSize = $this->getBannerImageSizeNew($arrImageSize[0],$arrImageSize[1], $maxWidth, 0);
$intWidth = $newImageSize[0];
$intHeight = $newImageSize[1];
$oriSize = $newImageSize[2];
}
else
{
$intWidth = $arrImageSize[0];
$intHeight = $arrImageSize[1];
$oriSize = true; // Merkmal fuer Bilder ohne Umrechnung
}
}
else
{ // Hoehe >= Breite, ggf. Hoehe verkleinern
if ($arrImageSize[1] > $maxWidth) // Hoehe > max Breite = Portrait ||
{
// pruefen ob bei neuer Hoehe die Breite zu klein wird
if (($maxWidth*$arrImageSize[0]/$arrImageSize[1]) < $maxHeight)
{
// Breite statt Hoehe setzen, Breite auf maximale Hoehe
$newImageSize = $this->getBannerImageSizeNew($arrImageSize[0],$arrImageSize[1], $maxHeight, 0);
$intWidth = $newImageSize[0];
$intHeight = $newImageSize[1];
$oriSize = $newImageSize[2];
}
else
{
$newImageSize = $this->getBannerImageSizeNew($arrImageSize[0],$arrImageSize[1], 0, $maxHeight);
$intWidth = $newImageSize[0];
$intHeight = $newImageSize[1];
$oriSize = $newImageSize[2];
}
}
else
{
$intWidth = $arrImageSize[0];
$intHeight = $arrImageSize[1];
$oriSize = true; // Merkmal fuer Bilder ohne Umrechnung
}
}
return array($intWidth,$intHeight,$oriSize);
} | [
"public",
"function",
"getCheckBannerImageSize",
"(",
"$",
"arrImageSize",
",",
"$",
"maxWidth",
",",
"$",
"maxHeight",
")",
"{",
"//$arrImageSize[0] Breite (max 250px in BE)",
"//$arrImageSize[1] Hoehe (max 40px in BE)",
"//$arrImageSize[2] Type",
"if",
"(",
"$",
"arrImageSize",
"[",
"0",
"]",
">",
"$",
"arrImageSize",
"[",
"1",
"]",
")",
"// Breite > Hoehe = Landscape ==",
"{",
"if",
"(",
"$",
"arrImageSize",
"[",
"0",
"]",
">",
"$",
"maxWidth",
")",
"{",
"//neue feste Breite",
"$",
"newImageSize",
"=",
"$",
"this",
"->",
"getBannerImageSizeNew",
"(",
"$",
"arrImageSize",
"[",
"0",
"]",
",",
"$",
"arrImageSize",
"[",
"1",
"]",
",",
"$",
"maxWidth",
",",
"0",
")",
";",
"$",
"intWidth",
"=",
"$",
"newImageSize",
"[",
"0",
"]",
";",
"$",
"intHeight",
"=",
"$",
"newImageSize",
"[",
"1",
"]",
";",
"$",
"oriSize",
"=",
"$",
"newImageSize",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"$",
"intWidth",
"=",
"$",
"arrImageSize",
"[",
"0",
"]",
";",
"$",
"intHeight",
"=",
"$",
"arrImageSize",
"[",
"1",
"]",
";",
"$",
"oriSize",
"=",
"true",
";",
"// Merkmal fuer Bilder ohne Umrechnung",
"}",
"}",
"else",
"{",
"// Hoehe >= Breite, ggf. Hoehe verkleinern",
"if",
"(",
"$",
"arrImageSize",
"[",
"1",
"]",
">",
"$",
"maxWidth",
")",
"// Hoehe > max Breite = Portrait ||",
"{",
"// pruefen ob bei neuer Hoehe die Breite zu klein wird",
"if",
"(",
"(",
"$",
"maxWidth",
"*",
"$",
"arrImageSize",
"[",
"0",
"]",
"/",
"$",
"arrImageSize",
"[",
"1",
"]",
")",
"<",
"$",
"maxHeight",
")",
"{",
"// Breite statt Hoehe setzen, Breite auf maximale Hoehe",
"$",
"newImageSize",
"=",
"$",
"this",
"->",
"getBannerImageSizeNew",
"(",
"$",
"arrImageSize",
"[",
"0",
"]",
",",
"$",
"arrImageSize",
"[",
"1",
"]",
",",
"$",
"maxHeight",
",",
"0",
")",
";",
"$",
"intWidth",
"=",
"$",
"newImageSize",
"[",
"0",
"]",
";",
"$",
"intHeight",
"=",
"$",
"newImageSize",
"[",
"1",
"]",
";",
"$",
"oriSize",
"=",
"$",
"newImageSize",
"[",
"2",
"]",
";",
"}",
"else",
"{",
"$",
"newImageSize",
"=",
"$",
"this",
"->",
"getBannerImageSizeNew",
"(",
"$",
"arrImageSize",
"[",
"0",
"]",
",",
"$",
"arrImageSize",
"[",
"1",
"]",
",",
"0",
",",
"$",
"maxHeight",
")",
";",
"$",
"intWidth",
"=",
"$",
"newImageSize",
"[",
"0",
"]",
";",
"$",
"intHeight",
"=",
"$",
"newImageSize",
"[",
"1",
"]",
";",
"$",
"oriSize",
"=",
"$",
"newImageSize",
"[",
"2",
"]",
";",
"}",
"}",
"else",
"{",
"$",
"intWidth",
"=",
"$",
"arrImageSize",
"[",
"0",
"]",
";",
"$",
"intHeight",
"=",
"$",
"arrImageSize",
"[",
"1",
"]",
";",
"$",
"oriSize",
"=",
"true",
";",
"// Merkmal fuer Bilder ohne Umrechnung",
"}",
"}",
"return",
"array",
"(",
"$",
"intWidth",
",",
"$",
"intHeight",
",",
"$",
"oriSize",
")",
";",
"}"
]
| Calculate the new size if necessary by comparing with maxWidth and maxHeight
@param array $arrImageSize
@param int $maxWidth
@param int $maxHeight
@return array $Width,$Height,$oriSize | [
"Calculate",
"the",
"new",
"size",
"if",
"necessary",
"by",
"comparing",
"with",
"maxWidth",
"and",
"maxHeight"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L358-L408 |
16,408 | BugBuster1701/banner | classes/BannerImage.php | BannerImage.getCheckBannerImageFallback | public function getCheckBannerImageFallback($BannerImage, $intWidth, $intHeight)
{
$fallback_content = false;
$path_parts = pathinfo($BannerImage);
if ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.jpg') )
{
$fallback_ext = '.jpg';
$fallback_content = true;
}
elseif ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.png') )
{
$fallback_ext = '.png';
$fallback_content = true;
}
elseif ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.gif') )
{
$fallback_ext = '.gif';
$fallback_content = true;
}
//if fallback image found, get image with size of flash size
if ($fallback_content === true)
{
//Get Image with sizes of flash
$src_fallback = \Image::get($this->urlEncode($path_parts['dirname'].'/'.$path_parts['filename'].$fallback_ext), $intWidth, $intHeight,'proportional');
return $src_fallback;
}
//no fallback image found
return false;
} | php | public function getCheckBannerImageFallback($BannerImage, $intWidth, $intHeight)
{
$fallback_content = false;
$path_parts = pathinfo($BannerImage);
if ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.jpg') )
{
$fallback_ext = '.jpg';
$fallback_content = true;
}
elseif ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.png') )
{
$fallback_ext = '.png';
$fallback_content = true;
}
elseif ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.gif') )
{
$fallback_ext = '.gif';
$fallback_content = true;
}
//if fallback image found, get image with size of flash size
if ($fallback_content === true)
{
//Get Image with sizes of flash
$src_fallback = \Image::get($this->urlEncode($path_parts['dirname'].'/'.$path_parts['filename'].$fallback_ext), $intWidth, $intHeight,'proportional');
return $src_fallback;
}
//no fallback image found
return false;
} | [
"public",
"function",
"getCheckBannerImageFallback",
"(",
"$",
"BannerImage",
",",
"$",
"intWidth",
",",
"$",
"intHeight",
")",
"{",
"$",
"fallback_content",
"=",
"false",
";",
"$",
"path_parts",
"=",
"pathinfo",
"(",
"$",
"BannerImage",
")",
";",
"if",
"(",
"is_file",
"(",
"TL_ROOT",
".",
"'/'",
".",
"$",
"path_parts",
"[",
"'dirname'",
"]",
".",
"'/'",
".",
"$",
"path_parts",
"[",
"'filename'",
"]",
".",
"'.jpg'",
")",
")",
"{",
"$",
"fallback_ext",
"=",
"'.jpg'",
";",
"$",
"fallback_content",
"=",
"true",
";",
"}",
"elseif",
"(",
"is_file",
"(",
"TL_ROOT",
".",
"'/'",
".",
"$",
"path_parts",
"[",
"'dirname'",
"]",
".",
"'/'",
".",
"$",
"path_parts",
"[",
"'filename'",
"]",
".",
"'.png'",
")",
")",
"{",
"$",
"fallback_ext",
"=",
"'.png'",
";",
"$",
"fallback_content",
"=",
"true",
";",
"}",
"elseif",
"(",
"is_file",
"(",
"TL_ROOT",
".",
"'/'",
".",
"$",
"path_parts",
"[",
"'dirname'",
"]",
".",
"'/'",
".",
"$",
"path_parts",
"[",
"'filename'",
"]",
".",
"'.gif'",
")",
")",
"{",
"$",
"fallback_ext",
"=",
"'.gif'",
";",
"$",
"fallback_content",
"=",
"true",
";",
"}",
"//if fallback image found, get image with size of flash size",
"if",
"(",
"$",
"fallback_content",
"===",
"true",
")",
"{",
"//Get Image with sizes of flash",
"$",
"src_fallback",
"=",
"\\",
"Image",
"::",
"get",
"(",
"$",
"this",
"->",
"urlEncode",
"(",
"$",
"path_parts",
"[",
"'dirname'",
"]",
".",
"'/'",
".",
"$",
"path_parts",
"[",
"'filename'",
"]",
".",
"$",
"fallback_ext",
")",
",",
"$",
"intWidth",
",",
"$",
"intHeight",
",",
"'proportional'",
")",
";",
"return",
"$",
"src_fallback",
";",
"}",
"//no fallback image found",
"return",
"false",
";",
"}"
]
| Search and get a flash fallback image path if exists
@param string $BannerImage Image path (flash file)
@param int $maxWidth Flash file width
@param int $maxHeight Flash file height
@return mixed $string/false Fallback image path / false | [
"Search",
"and",
"get",
"a",
"flash",
"fallback",
"image",
"path",
"if",
"exists"
]
| 3ffac36837923194ab0ebaf308c0b23a3684b005 | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L418-L448 |
16,409 | readdle/fqdb | src/Readdle/Database/FQDBProvider.php | FQDBProvider.defaultFQDB | public static function defaultFQDB() {
if (self::$defaultFQDB)
return self::$defaultFQDB;
if (is_callable(self::$FQDBCreatorCallback))
return self::setDefaultFQDB(call_user_func(self::$FQDBCreatorCallback));
} | php | public static function defaultFQDB() {
if (self::$defaultFQDB)
return self::$defaultFQDB;
if (is_callable(self::$FQDBCreatorCallback))
return self::setDefaultFQDB(call_user_func(self::$FQDBCreatorCallback));
} | [
"public",
"static",
"function",
"defaultFQDB",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"defaultFQDB",
")",
"return",
"self",
"::",
"$",
"defaultFQDB",
";",
"if",
"(",
"is_callable",
"(",
"self",
"::",
"$",
"FQDBCreatorCallback",
")",
")",
"return",
"self",
"::",
"setDefaultFQDB",
"(",
"call_user_func",
"(",
"self",
"::",
"$",
"FQDBCreatorCallback",
")",
")",
";",
"}"
]
| returns default FQDB
@return \Readdle\Database\FQDB | [
"returns",
"default",
"FQDB"
]
| 4ef2e8f3343a7c8fbb309c243be502a160c42083 | https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBProvider.php#L128-L134 |
16,410 | VDMi/Guzzle-oAuth | src/GuzzleOauth/Consumer/Google.php | Google.getUserEmail | public function getUserEmail($info = NULL) {
if (empty($info)) {
$info = $this->getUserInfo();
}
$emails = $info->get('emails');
if (is_array($emails) && count($emails)) {
$email = reset($emails);
return $email['value'];
}
} | php | public function getUserEmail($info = NULL) {
if (empty($info)) {
$info = $this->getUserInfo();
}
$emails = $info->get('emails');
if (is_array($emails) && count($emails)) {
$email = reset($emails);
return $email['value'];
}
} | [
"public",
"function",
"getUserEmail",
"(",
"$",
"info",
"=",
"NULL",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"info",
")",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"getUserInfo",
"(",
")",
";",
"}",
"$",
"emails",
"=",
"$",
"info",
"->",
"get",
"(",
"'emails'",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"emails",
")",
"&&",
"count",
"(",
"$",
"emails",
")",
")",
"{",
"$",
"email",
"=",
"reset",
"(",
"$",
"emails",
")",
";",
"return",
"$",
"email",
"[",
"'value'",
"]",
";",
"}",
"}"
]
| Google can return an array of emails.
We only give back the first one, since we request one e-mail address | [
"Google",
"can",
"return",
"an",
"array",
"of",
"emails",
".",
"We",
"only",
"give",
"back",
"the",
"first",
"one",
"since",
"we",
"request",
"one",
"e",
"-",
"mail",
"address"
]
| e2b2561e4e402e13ba605082bf768b29942f90cb | https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/Consumer/Google.php#L13-L22 |
16,411 | gdbots/pbjx-bundle-php | src/PbjxTokenSigner.php | PbjxTokenSigner.sign | public function sign(string $content, string $aud, ?string $kid = null): PbjxToken
{
$kid = $kid ?: $this->defaultKid;
return PbjxToken::create($content, $aud, $kid, $this->getSecret($kid));
} | php | public function sign(string $content, string $aud, ?string $kid = null): PbjxToken
{
$kid = $kid ?: $this->defaultKid;
return PbjxToken::create($content, $aud, $kid, $this->getSecret($kid));
} | [
"public",
"function",
"sign",
"(",
"string",
"$",
"content",
",",
"string",
"$",
"aud",
",",
"?",
"string",
"$",
"kid",
"=",
"null",
")",
":",
"PbjxToken",
"{",
"$",
"kid",
"=",
"$",
"kid",
"?",
":",
"$",
"this",
"->",
"defaultKid",
";",
"return",
"PbjxToken",
"::",
"create",
"(",
"$",
"content",
",",
"$",
"aud",
",",
"$",
"kid",
",",
"$",
"this",
"->",
"getSecret",
"(",
"$",
"kid",
")",
")",
";",
"}"
]
| Creates a new signed token for the provided content.
@param string $content Pbjx content that is being signed
@param string $aud Pbjx endpoint this token will be sent to
@param string $kid Key ID to use to sign the token.
@return PbjxToken | [
"Creates",
"a",
"new",
"signed",
"token",
"for",
"the",
"provided",
"content",
"."
]
| f3c0088583879fc92f13247a0752634bd8696eac | https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/PbjxTokenSigner.php#L71-L75 |
16,412 | gdbots/pbjx-bundle-php | src/PbjxTokenSigner.php | PbjxTokenSigner.validate | public function validate(string $content, string $aud, string $token): void
{
$actualToken = PbjxToken::fromString($token);
$expectedToken = PbjxToken::create(
$content,
$aud,
$actualToken->getKid(),
$this->getSecret($actualToken->getKid()),
[
'exp' => $actualToken->getExp(),
'iat' => $actualToken->getIat(),
]
);
if (!$actualToken->equals($expectedToken)) {
throw new \InvalidArgumentException('PbjxTokens do not match.', Code::INVALID_ARGUMENT);
}
} | php | public function validate(string $content, string $aud, string $token): void
{
$actualToken = PbjxToken::fromString($token);
$expectedToken = PbjxToken::create(
$content,
$aud,
$actualToken->getKid(),
$this->getSecret($actualToken->getKid()),
[
'exp' => $actualToken->getExp(),
'iat' => $actualToken->getIat(),
]
);
if (!$actualToken->equals($expectedToken)) {
throw new \InvalidArgumentException('PbjxTokens do not match.', Code::INVALID_ARGUMENT);
}
} | [
"public",
"function",
"validate",
"(",
"string",
"$",
"content",
",",
"string",
"$",
"aud",
",",
"string",
"$",
"token",
")",
":",
"void",
"{",
"$",
"actualToken",
"=",
"PbjxToken",
"::",
"fromString",
"(",
"$",
"token",
")",
";",
"$",
"expectedToken",
"=",
"PbjxToken",
"::",
"create",
"(",
"$",
"content",
",",
"$",
"aud",
",",
"$",
"actualToken",
"->",
"getKid",
"(",
")",
",",
"$",
"this",
"->",
"getSecret",
"(",
"$",
"actualToken",
"->",
"getKid",
"(",
")",
")",
",",
"[",
"'exp'",
"=>",
"$",
"actualToken",
"->",
"getExp",
"(",
")",
",",
"'iat'",
"=>",
"$",
"actualToken",
"->",
"getIat",
"(",
")",
",",
"]",
")",
";",
"if",
"(",
"!",
"$",
"actualToken",
"->",
"equals",
"(",
"$",
"expectedToken",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'PbjxTokens do not match.'",
",",
"Code",
"::",
"INVALID_ARGUMENT",
")",
";",
"}",
"}"
]
| Validates that the provided token is valid and okay to use
and also creates a new token with the same secret and content
and compares our result to the provided token to determine
if they are an exact match.
If no exception is thrown the token is valid.
@param string $content Pbjx content that has been signed
@param string $aud Pbjx endpoint this token was sent to
@param string $token The token string (typically from header x-pbjx-token)
@throws \Throwable | [
"Validates",
"that",
"the",
"provided",
"token",
"is",
"valid",
"and",
"okay",
"to",
"use",
"and",
"also",
"creates",
"a",
"new",
"token",
"with",
"the",
"same",
"secret",
"and",
"content",
"and",
"compares",
"our",
"result",
"to",
"the",
"provided",
"token",
"to",
"determine",
"if",
"they",
"are",
"an",
"exact",
"match",
"."
]
| f3c0088583879fc92f13247a0752634bd8696eac | https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/PbjxTokenSigner.php#L91-L108 |
16,413 | axelitus/php-base | src/Str.php | Str.beginsWith | public static function beginsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
$substr = static::sub($input, 0, static::length($search), $encoding);
return (static::compare($substr, $search, $caseInsensitive) === 0);
} | php | public static function beginsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
$substr = static::sub($input, 0, static::length($search), $encoding);
return (static::compare($substr, $search, $caseInsensitive) === 0);
} | [
"public",
"static",
"function",
"beginsWith",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"$",
"substr",
"=",
"static",
"::",
"sub",
"(",
"$",
"input",
",",
"0",
",",
"static",
"::",
"length",
"(",
"$",
"search",
")",
",",
"$",
"encoding",
")",
";",
"return",
"(",
"static",
"::",
"compare",
"(",
"$",
"substr",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
")",
"===",
"0",
")",
";",
"}"
]
| Verifies if a string begins with a substring.
Uses the multibyte function if available with the given encoding $encoding.
The comparison is case-sensitive by default.
@param string $input The input string to compare to.
@param string $search The substring to compare the beginning to.
@param bool $caseInsensitive Whether the comparison is case-sensitive.
@param string $encoding The encoding of the input string.
@return bool Returns true if the input string begins with the given search string.
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Verifies",
"if",
"a",
"string",
"begins",
"with",
"a",
"substring",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L198-L203 |
16,414 | axelitus/php-base | src/Str.php | Str.endsWith | public static function endsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
if (($length = static::length($search, $encoding)) == 0) {
return true;
}
$substr = static::sub($input, -$length, $length, $encoding);
return (static::compare($substr, $search, $caseInsensitive) === 0);
} | php | public static function endsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
if (($length = static::length($search, $encoding)) == 0) {
return true;
}
$substr = static::sub($input, -$length, $length, $encoding);
return (static::compare($substr, $search, $caseInsensitive) === 0);
} | [
"public",
"static",
"function",
"endsWith",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"if",
"(",
"(",
"$",
"length",
"=",
"static",
"::",
"length",
"(",
"$",
"search",
",",
"$",
"encoding",
")",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"$",
"substr",
"=",
"static",
"::",
"sub",
"(",
"$",
"input",
",",
"-",
"$",
"length",
",",
"$",
"length",
",",
"$",
"encoding",
")",
";",
"return",
"(",
"static",
"::",
"compare",
"(",
"$",
"substr",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
")",
"===",
"0",
")",
";",
"}"
]
| Verifies if a string ends with a substring.
Uses the multibyte function if available with the given encoding $encoding.
The comparison is case-sensitive by default.
@param string $input The input string to compare to.
@param string $search The substring to compare the ending to.
@param bool $caseInsensitive Whether the comparison is case-sensitive.
@param string $encoding The encoding of the input string.
@return bool Returns true if the $input string ends with the given $search string.
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Verifies",
"if",
"a",
"string",
"ends",
"with",
"a",
"substring",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L219-L228 |
16,415 | axelitus/php-base | src/Str.php | Str.isOneOf | public static function isOneOf($input, array $values, $caseInsensitive = false, $returnIndex = false)
{
if (is_null($input)) {
return false;
}
foreach ($values as $index => $str) {
if (static::equals($input, $str, $caseInsensitive)) {
return ($returnIndex) ? $index : true;
}
}
return false;
} | php | public static function isOneOf($input, array $values, $caseInsensitive = false, $returnIndex = false)
{
if (is_null($input)) {
return false;
}
foreach ($values as $index => $str) {
if (static::equals($input, $str, $caseInsensitive)) {
return ($returnIndex) ? $index : true;
}
}
return false;
} | [
"public",
"static",
"function",
"isOneOf",
"(",
"$",
"input",
",",
"array",
"$",
"values",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"returnIndex",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"input",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"index",
"=>",
"$",
"str",
")",
"{",
"if",
"(",
"static",
"::",
"equals",
"(",
"$",
"input",
",",
"$",
"str",
",",
"$",
"caseInsensitive",
")",
")",
"{",
"return",
"(",
"$",
"returnIndex",
")",
"?",
"$",
"index",
":",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
]
| Verifies if the input string is one of the values of the given array.
Verifies if the input string is one of the values of the given array. Each of the values
of the array is matched against the input string. The index of the value that matched can
be returned instead of the default bool value. The comparison can be case sensitive or
case insensitive.
@param string $input The input string
@param array $values The string|PrimitiveString array to look for the input string
@param bool $caseInsensitive Whether the comparison is case-sensitive
@param bool $returnIndex Whether to return the matched array's item instead
@return bool|int Whether the input string was found in the array or the item's index if found
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Verifies",
"if",
"the",
"input",
"string",
"is",
"one",
"of",
"the",
"values",
"of",
"the",
"given",
"array",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L246-L259 |
16,416 | axelitus/php-base | src/Str.php | Str.match | public static function match($input, $pattern, array &$matches = null, $flags = 0, $offset = 0)
{
return preg_match($pattern, $input, $matches, $flags, $offset);
} | php | public static function match($input, $pattern, array &$matches = null, $flags = 0, $offset = 0)
{
return preg_match($pattern, $input, $matches, $flags, $offset);
} | [
"public",
"static",
"function",
"match",
"(",
"$",
"input",
",",
"$",
"pattern",
",",
"array",
"&",
"$",
"matches",
"=",
"null",
",",
"$",
"flags",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"input",
",",
"$",
"matches",
",",
"$",
"flags",
",",
"$",
"offset",
")",
";",
"}"
]
| Searches the input string for a match to the regular expression given in pattern.
@param string $input The input string.
@param string $pattern The pattern to search for, as a string.
@param array $matches If matches is provided, then it is filled with the results of search.
$matches[0] will contain the text that matched the full pattern, $matches[1]
will have the text that matched the first captured parenthesized subpattern,
and so on.
@param int $flags The flag modifiers.
@param int $offset The offset from which to start the search (in bytes).
@return int Returns 1 if the pattern matches the input string, 0 if it does not, or false if an error occurred.
@see http://php.net/manual/en/function.preg-match.php | [
"Searches",
"the",
"input",
"string",
"for",
"a",
"match",
"to",
"the",
"regular",
"expression",
"given",
"in",
"pattern",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L276-L279 |
16,417 | axelitus/php-base | src/Str.php | Str.length | public static function length($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strlen') ? mb_strlen($input, $encoding) : strlen($input);
} | php | public static function length($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strlen') ? mb_strlen($input, $encoding) : strlen($input);
} | [
"public",
"static",
"function",
"length",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strlen'",
")",
"?",
"mb_strlen",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
":",
"strlen",
"(",
"$",
"input",
")",
";",
"}"
]
| Gets the length of the given string.
Uses the multibyte function if available with the given encoding $encoding.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string.
@param string $encoding The encoding of the input string for multibyte functions.
@return int Returns the length of the string. | [
"Gets",
"the",
"length",
"of",
"the",
"given",
"string",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L297-L300 |
16,418 | axelitus/php-base | src/Str.php | Str.replace | public static function replace(
$input,
$search,
$replace,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
return function_exists('mb_strlen')
? static::mbStrReplaceCaller($search, $replace, $input, $caseInsensitive, $encoding, $count)
: (($caseInsensitive)
? (str_ireplace($search, $replace, $input, $count)) // @codeCoverageIgnore
// excluded as reaching this line is environment dependent.
: (str_replace($search, $replace, $input, $count)));
} | php | public static function replace(
$input,
$search,
$replace,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
return function_exists('mb_strlen')
? static::mbStrReplaceCaller($search, $replace, $input, $caseInsensitive, $encoding, $count)
: (($caseInsensitive)
? (str_ireplace($search, $replace, $input, $count)) // @codeCoverageIgnore
// excluded as reaching this line is environment dependent.
: (str_replace($search, $replace, $input, $count)));
} | [
"public",
"static",
"function",
"replace",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
",",
"&",
"$",
"count",
"=",
"null",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strlen'",
")",
"?",
"static",
"::",
"mbStrReplaceCaller",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"input",
",",
"$",
"caseInsensitive",
",",
"$",
"encoding",
",",
"$",
"count",
")",
":",
"(",
"(",
"$",
"caseInsensitive",
")",
"?",
"(",
"str_ireplace",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"input",
",",
"$",
"count",
")",
")",
"// @codeCoverageIgnore",
"// excluded as reaching this line is environment dependent.",
":",
"(",
"str_replace",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"input",
",",
"$",
"count",
")",
")",
")",
";",
"}"
]
| Replaces a substring inside a string.
@param string $input The input string
@param string $search The substring to be replaced
@param string $replace The substring replacement
@param bool $caseInsensitive Whether the comparison should be case sensitive
@param string $encoding The encoding of the input string
@param int $count If passed, this will be set to the number of replacements performed.
@return string The string with the substring replaced
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Replaces",
"a",
"substring",
"inside",
"a",
"string",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L380-L394 |
16,419 | axelitus/php-base | src/Str.php | Str.mbStrReplaceCaller | protected static function mbStrReplaceCaller(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
if (is_array($subject)) {
$result = [];
foreach ($subject as $item) {
$result[] = static::mbStrReplaceCaller($search, $replace, $item, $caseInsensitive, $encoding, $count);
}
return $result;
}
if (!is_array($search)) {
return static::mbStrReplaceInternal($search, $replace, $subject, $caseInsensitive, $encoding, $count);
}
$replaceIsArray = is_array($replace);
foreach ($search as $key => $value) {
$subject = static::mbStrReplaceInternal(
$value,
($replaceIsArray ? $replace[$key] : $replace),
$subject,
$caseInsensitive,
$encoding,
$count
);
}
return $subject;
} | php | protected static function mbStrReplaceCaller(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
if (is_array($subject)) {
$result = [];
foreach ($subject as $item) {
$result[] = static::mbStrReplaceCaller($search, $replace, $item, $caseInsensitive, $encoding, $count);
}
return $result;
}
if (!is_array($search)) {
return static::mbStrReplaceInternal($search, $replace, $subject, $caseInsensitive, $encoding, $count);
}
$replaceIsArray = is_array($replace);
foreach ($search as $key => $value) {
$subject = static::mbStrReplaceInternal(
$value,
($replaceIsArray ? $replace[$key] : $replace),
$subject,
$caseInsensitive,
$encoding,
$count
);
}
return $subject;
} | [
"protected",
"static",
"function",
"mbStrReplaceCaller",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"subject",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
",",
"&",
"$",
"count",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"subject",
")",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"subject",
"as",
"$",
"item",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"static",
"::",
"mbStrReplaceCaller",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"item",
",",
"$",
"caseInsensitive",
",",
"$",
"encoding",
",",
"$",
"count",
")",
";",
"}",
"return",
"$",
"result",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"search",
")",
")",
"{",
"return",
"static",
"::",
"mbStrReplaceInternal",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"subject",
",",
"$",
"caseInsensitive",
",",
"$",
"encoding",
",",
"$",
"count",
")",
";",
"}",
"$",
"replaceIsArray",
"=",
"is_array",
"(",
"$",
"replace",
")",
";",
"foreach",
"(",
"$",
"search",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"subject",
"=",
"static",
"::",
"mbStrReplaceInternal",
"(",
"$",
"value",
",",
"(",
"$",
"replaceIsArray",
"?",
"$",
"replace",
"[",
"$",
"key",
"]",
":",
"$",
"replace",
")",
",",
"$",
"subject",
",",
"$",
"caseInsensitive",
",",
"$",
"encoding",
",",
"$",
"count",
")",
";",
"}",
"return",
"$",
"subject",
";",
"}"
]
| Replaces a substring inside a string with multi-byte support
@param string|array $search
@param string|array $replace
@param string|array $subject
@param bool $caseInsensitive
@param string $encoding
@param int $count
@return array|string
@see https://github.com/faceleg/php-mb_str_replace
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Replaces",
"a",
"substring",
"inside",
"a",
"string",
"with",
"multi",
"-",
"byte",
"support"
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L410-L444 |
16,420 | axelitus/php-base | src/Str.php | Str.mbStrReplaceInternal | protected static function mbStrReplaceInternal(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
$searchLength = mb_strlen($search, $encoding);
$subjectLength = mb_strlen($subject, $encoding);
$offset = 0;
$result = '';
while ($offset < $subjectLength) {
$match = $caseInsensitive
? mb_stripos($subject, $search, $offset, $encoding)
: mb_strpos($subject, $search, $offset, $encoding);
if ($match === false) {
if ($offset === 0) {
// No match was ever found, just return the subject.
return $subject;
}
// Append the final portion of the subject to the replaced.
$result .= mb_substr($subject, $offset, $subjectLength - $offset, $encoding);
break;
}
if ($count !== null) {
$count++;
}
$result .= mb_substr($subject, $offset, $match - $offset, $encoding);
$result .= $replace;
$offset = $match + $searchLength;
}
return $result;
} | php | protected static function mbStrReplaceInternal(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
$searchLength = mb_strlen($search, $encoding);
$subjectLength = mb_strlen($subject, $encoding);
$offset = 0;
$result = '';
while ($offset < $subjectLength) {
$match = $caseInsensitive
? mb_stripos($subject, $search, $offset, $encoding)
: mb_strpos($subject, $search, $offset, $encoding);
if ($match === false) {
if ($offset === 0) {
// No match was ever found, just return the subject.
return $subject;
}
// Append the final portion of the subject to the replaced.
$result .= mb_substr($subject, $offset, $subjectLength - $offset, $encoding);
break;
}
if ($count !== null) {
$count++;
}
$result .= mb_substr($subject, $offset, $match - $offset, $encoding);
$result .= $replace;
$offset = $match + $searchLength;
}
return $result;
} | [
"protected",
"static",
"function",
"mbStrReplaceInternal",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"subject",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
",",
"&",
"$",
"count",
"=",
"null",
")",
"{",
"$",
"searchLength",
"=",
"mb_strlen",
"(",
"$",
"search",
",",
"$",
"encoding",
")",
";",
"$",
"subjectLength",
"=",
"mb_strlen",
"(",
"$",
"subject",
",",
"$",
"encoding",
")",
";",
"$",
"offset",
"=",
"0",
";",
"$",
"result",
"=",
"''",
";",
"while",
"(",
"$",
"offset",
"<",
"$",
"subjectLength",
")",
"{",
"$",
"match",
"=",
"$",
"caseInsensitive",
"?",
"mb_stripos",
"(",
"$",
"subject",
",",
"$",
"search",
",",
"$",
"offset",
",",
"$",
"encoding",
")",
":",
"mb_strpos",
"(",
"$",
"subject",
",",
"$",
"search",
",",
"$",
"offset",
",",
"$",
"encoding",
")",
";",
"if",
"(",
"$",
"match",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"offset",
"===",
"0",
")",
"{",
"// No match was ever found, just return the subject.",
"return",
"$",
"subject",
";",
"}",
"// Append the final portion of the subject to the replaced.",
"$",
"result",
".=",
"mb_substr",
"(",
"$",
"subject",
",",
"$",
"offset",
",",
"$",
"subjectLength",
"-",
"$",
"offset",
",",
"$",
"encoding",
")",
";",
"break",
";",
"}",
"if",
"(",
"$",
"count",
"!==",
"null",
")",
"{",
"$",
"count",
"++",
";",
"}",
"$",
"result",
".=",
"mb_substr",
"(",
"$",
"subject",
",",
"$",
"offset",
",",
"$",
"match",
"-",
"$",
"offset",
",",
"$",
"encoding",
")",
";",
"$",
"result",
".=",
"$",
"replace",
";",
"$",
"offset",
"=",
"$",
"match",
"+",
"$",
"searchLength",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Implementation of mb_str_replace. Do not call directly.
@param string|array $search
@param string|array $replace
@param string|array $subject
@param bool $caseInsensitive
@param string $encoding
@param int $count
@return string
@see https://github.com/faceleg/php-mb_str_replace
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Implementation",
"of",
"mb_str_replace",
".",
"Do",
"not",
"call",
"directly",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L460-L495 |
16,421 | axelitus/php-base | src/Str.php | Str.truncate | public static function truncate($input, $limit, $continuation = '...', $isHtml = false)
{
$offset = 0;
$tags = [];
if ($isHtml) {
$input = static::truncateHtml($input, $limit, $offset, $tags);
}
$newString = static::sub($input, 0, $limit = min(static::length($input), $limit + $offset));
$newString .= (static::length($input) > $limit ? $continuation : '');
$newString .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '';
return $newString;
} | php | public static function truncate($input, $limit, $continuation = '...', $isHtml = false)
{
$offset = 0;
$tags = [];
if ($isHtml) {
$input = static::truncateHtml($input, $limit, $offset, $tags);
}
$newString = static::sub($input, 0, $limit = min(static::length($input), $limit + $offset));
$newString .= (static::length($input) > $limit ? $continuation : '');
$newString .= count($tags = array_reverse($tags)) ? '</' . implode('></', $tags) . '>' : '';
return $newString;
} | [
"public",
"static",
"function",
"truncate",
"(",
"$",
"input",
",",
"$",
"limit",
",",
"$",
"continuation",
"=",
"'...'",
",",
"$",
"isHtml",
"=",
"false",
")",
"{",
"$",
"offset",
"=",
"0",
";",
"$",
"tags",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"isHtml",
")",
"{",
"$",
"input",
"=",
"static",
"::",
"truncateHtml",
"(",
"$",
"input",
",",
"$",
"limit",
",",
"$",
"offset",
",",
"$",
"tags",
")",
";",
"}",
"$",
"newString",
"=",
"static",
"::",
"sub",
"(",
"$",
"input",
",",
"0",
",",
"$",
"limit",
"=",
"min",
"(",
"static",
"::",
"length",
"(",
"$",
"input",
")",
",",
"$",
"limit",
"+",
"$",
"offset",
")",
")",
";",
"$",
"newString",
".=",
"(",
"static",
"::",
"length",
"(",
"$",
"input",
")",
">",
"$",
"limit",
"?",
"$",
"continuation",
":",
"''",
")",
";",
"$",
"newString",
".=",
"count",
"(",
"$",
"tags",
"=",
"array_reverse",
"(",
"$",
"tags",
")",
")",
"?",
"'</'",
".",
"implode",
"(",
"'></'",
",",
"$",
"tags",
")",
".",
"'>'",
":",
"''",
";",
"return",
"$",
"newString",
";",
"}"
]
| Truncates a string to the given length.
Truncates a string to the given length. It will optionally preserve HTML tags if $is_html is set to true.
@author FuelPHP (http://fuelphp.com)
@param string $input The string to truncate.
@param int $limit The number of characters to truncate to.
@param string $continuation The string to use to denote it was truncated
@param bool $isHtml Whether the string has HTML
@return string The truncated string
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Truncates",
"a",
"string",
"to",
"the",
"given",
"length",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L512-L525 |
16,422 | axelitus/php-base | src/Str.php | Str.lower | public static function lower($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower($input, $encoding)
: strtolower($input);
} | php | public static function lower($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower($input, $encoding)
: strtolower($input);
} | [
"public",
"static",
"function",
"lower",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtolower'",
")",
"?",
"mb_strtolower",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
":",
"strtolower",
"(",
"$",
"input",
")",
";",
"}"
]
| Returns a lowercased string.
Returns a lowercased string. The $encoding parameter is used to determine the input string encoding
and thus use the proper method. The functions uses mb_strtolower if present and falls back to strtolower.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string
@param string $encoding The encoding of the input string
@return string The lowercased string | [
"Returns",
"a",
"lowercased",
"string",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L600-L605 |
16,423 | axelitus/php-base | src/Str.php | Str.upper | public static function upper($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper($input, $encoding)
: strtoupper($input);
} | php | public static function upper($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper($input, $encoding)
: strtoupper($input);
} | [
"public",
"static",
"function",
"upper",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtoupper'",
")",
"?",
"mb_strtoupper",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
":",
"strtoupper",
"(",
"$",
"input",
")",
";",
"}"
]
| Returns an uppercased string.
Returns an uppercased string. The $encoding parameter is used to determine the input string encoding
and thus use the proper method. The functions uses mb_strtoupper if present and falls back to strtoupper.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string
@param string $encoding The encoding of the input string
@return string The uppercased string | [
"Returns",
"an",
"uppercased",
"string",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L620-L625 |
16,424 | axelitus/php-base | src/Str.php | Str.lcfirst | public static function lcfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: lcfirst($input);
} | php | public static function lcfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: lcfirst($input);
} | [
"public",
"static",
"function",
"lcfirst",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtolower'",
")",
"?",
"mb_strtolower",
"(",
"mb_substr",
"(",
"$",
"input",
",",
"0",
",",
"1",
",",
"$",
"encoding",
")",
",",
"$",
"encoding",
")",
".",
"mb_substr",
"(",
"$",
"input",
",",
"1",
",",
"mb_strlen",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
",",
"$",
"encoding",
")",
":",
"lcfirst",
"(",
"$",
"input",
")",
";",
"}"
]
| Returns a string with the first char as lowercase.
Returns a string with the first char as lowercase. The other characters in the string are left untouched.
The $encoding parameter is used to determine the input string encoding and thus use the proper method.
The function uses mb_strtolower, mb_mb_substr and mb_strlen if present and falls back to lcfirst.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string
@param string $encoding The encoding of the input string
@return string The string with the first char lowercased | [
"Returns",
"a",
"string",
"with",
"the",
"first",
"char",
"as",
"lowercase",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L641-L647 |
16,425 | axelitus/php-base | src/Str.php | Str.ucfirst | public static function ucfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: ucfirst($input);
} | php | public static function ucfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: ucfirst($input);
} | [
"public",
"static",
"function",
"ucfirst",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtoupper'",
")",
"?",
"mb_strtoupper",
"(",
"mb_substr",
"(",
"$",
"input",
",",
"0",
",",
"1",
",",
"$",
"encoding",
")",
",",
"$",
"encoding",
")",
".",
"mb_substr",
"(",
"$",
"input",
",",
"1",
",",
"mb_strlen",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
",",
"$",
"encoding",
")",
":",
"ucfirst",
"(",
"$",
"input",
")",
";",
"}"
]
| Returns a string with the first char as uppercase.
Returns a string with the first char as uppercase. The other characters in the string are left untouched.
The $encoding parameter is used to determine the input string encoding and thus use the proper method.
The function uses mb_strtoupper, mb_mb_substr and mb_strlen if present and falls back to ucfirst.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string
@param string $encoding The encoding of the input string
@return string The string with the first char uppercased | [
"Returns",
"a",
"string",
"with",
"the",
"first",
"char",
"as",
"uppercase",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L663-L669 |
16,426 | axelitus/php-base | src/Str.php | Str.ucwords | public static function ucwords($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_convert_case')
? mb_convert_case($input, MB_CASE_TITLE, $encoding)
: ucwords(strtolower($input));
} | php | public static function ucwords($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_convert_case')
? mb_convert_case($input, MB_CASE_TITLE, $encoding)
: ucwords(strtolower($input));
} | [
"public",
"static",
"function",
"ucwords",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_convert_case'",
")",
"?",
"mb_convert_case",
"(",
"$",
"input",
",",
"MB_CASE_TITLE",
",",
"$",
"encoding",
")",
":",
"ucwords",
"(",
"strtolower",
"(",
"$",
"input",
")",
")",
";",
"}"
]
| Returns a string with the words capitalized.
Returns a string with the words capitalized. The $encoding parameter is used to determine the input string
encoding and thus use the proper method. The function uses mb_convert_case if present and falls back to ucwords.
The ucwords function normally does not lowercase the input string first, this function does.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string
@param string $encoding The encoding of the input string
@return string The string with the words capitalized | [
"Returns",
"a",
"string",
"with",
"the",
"words",
"capitalized",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L685-L690 |
16,427 | axelitus/php-base | src/Str.php | Str.studlyBuildPattern | protected static function studlyBuildPattern(array $separators)
{
$pattern = '';
foreach ($separators as $separator) {
$pattern .= '|' . preg_quote($separator);
}
$pattern = '/(^' . $pattern . ')(.)/';
return $pattern;
} | php | protected static function studlyBuildPattern(array $separators)
{
$pattern = '';
foreach ($separators as $separator) {
$pattern .= '|' . preg_quote($separator);
}
$pattern = '/(^' . $pattern . ')(.)/';
return $pattern;
} | [
"protected",
"static",
"function",
"studlyBuildPattern",
"(",
"array",
"$",
"separators",
")",
"{",
"$",
"pattern",
"=",
"''",
";",
"foreach",
"(",
"$",
"separators",
"as",
"$",
"separator",
")",
"{",
"$",
"pattern",
".=",
"'|'",
".",
"preg_quote",
"(",
"$",
"separator",
")",
";",
"}",
"$",
"pattern",
"=",
"'/(^'",
".",
"$",
"pattern",
".",
"')(.)/'",
";",
"return",
"$",
"pattern",
";",
"}"
]
| Builds the studly patter with the given separators.
@param array $separators The array of separators to use.
@return string Returns the built studly pattern. | [
"Builds",
"the",
"studly",
"patter",
"with",
"the",
"given",
"separators",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L740-L749 |
16,428 | axelitus/php-base | src/Str.php | Str.nsprintf | public static function nsprintf($format, array $args = [])
{
// Filter unnamed %s strings that should not be processed
$filterRegex = '/%s/';
$format = preg_replace($filterRegex, '#[:~s]#', $format);
// The pattern to match variables
$pattern = '/(?<=%)([a-zA-Z0-9_]\w*)(?=\$)/';
// Add predefined values
$pool = ['cr' => "\r", 'lf' => "\n", 'crlf' => "\r\n", 'tab' => "\t"] + $args;
// Build args array and substitute variables with numbers
$args = [];
$pos = 0;
$match = null;
while (static::match($format, $pattern, $match, PREG_OFFSET_CAPTURE, $pos)) {
list($varKey, $varPos) = $match[0];
if (!array_key_exists($varKey, $pool)) {
throw new \BadFunctionCallException("Missing argument '${varKey}'.", E_USER_WARNING);
}
array_push($args, $pool[$varKey]);
$format = substr_replace($format, count($args), $varPos, $wordLength = static::length($varKey));
$pos = $varPos + $wordLength; // skip to end of replacement for next iteration
}
// Return the original %s strings
$filterRegex = '/#\[:~s\]#/';
return preg_replace($filterRegex, '%s', vsprintf($format, $args));
} | php | public static function nsprintf($format, array $args = [])
{
// Filter unnamed %s strings that should not be processed
$filterRegex = '/%s/';
$format = preg_replace($filterRegex, '#[:~s]#', $format);
// The pattern to match variables
$pattern = '/(?<=%)([a-zA-Z0-9_]\w*)(?=\$)/';
// Add predefined values
$pool = ['cr' => "\r", 'lf' => "\n", 'crlf' => "\r\n", 'tab' => "\t"] + $args;
// Build args array and substitute variables with numbers
$args = [];
$pos = 0;
$match = null;
while (static::match($format, $pattern, $match, PREG_OFFSET_CAPTURE, $pos)) {
list($varKey, $varPos) = $match[0];
if (!array_key_exists($varKey, $pool)) {
throw new \BadFunctionCallException("Missing argument '${varKey}'.", E_USER_WARNING);
}
array_push($args, $pool[$varKey]);
$format = substr_replace($format, count($args), $varPos, $wordLength = static::length($varKey));
$pos = $varPos + $wordLength; // skip to end of replacement for next iteration
}
// Return the original %s strings
$filterRegex = '/#\[:~s\]#/';
return preg_replace($filterRegex, '%s', vsprintf($format, $args));
} | [
"public",
"static",
"function",
"nsprintf",
"(",
"$",
"format",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"// Filter unnamed %s strings that should not be processed",
"$",
"filterRegex",
"=",
"'/%s/'",
";",
"$",
"format",
"=",
"preg_replace",
"(",
"$",
"filterRegex",
",",
"'#[:~s]#'",
",",
"$",
"format",
")",
";",
"// The pattern to match variables",
"$",
"pattern",
"=",
"'/(?<=%)([a-zA-Z0-9_]\\w*)(?=\\$)/'",
";",
"// Add predefined values",
"$",
"pool",
"=",
"[",
"'cr'",
"=>",
"\"\\r\"",
",",
"'lf'",
"=>",
"\"\\n\"",
",",
"'crlf'",
"=>",
"\"\\r\\n\"",
",",
"'tab'",
"=>",
"\"\\t\"",
"]",
"+",
"$",
"args",
";",
"// Build args array and substitute variables with numbers",
"$",
"args",
"=",
"[",
"]",
";",
"$",
"pos",
"=",
"0",
";",
"$",
"match",
"=",
"null",
";",
"while",
"(",
"static",
"::",
"match",
"(",
"$",
"format",
",",
"$",
"pattern",
",",
"$",
"match",
",",
"PREG_OFFSET_CAPTURE",
",",
"$",
"pos",
")",
")",
"{",
"list",
"(",
"$",
"varKey",
",",
"$",
"varPos",
")",
"=",
"$",
"match",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"varKey",
",",
"$",
"pool",
")",
")",
"{",
"throw",
"new",
"\\",
"BadFunctionCallException",
"(",
"\"Missing argument '${varKey}'.\"",
",",
"E_USER_WARNING",
")",
";",
"}",
"array_push",
"(",
"$",
"args",
",",
"$",
"pool",
"[",
"$",
"varKey",
"]",
")",
";",
"$",
"format",
"=",
"substr_replace",
"(",
"$",
"format",
",",
"count",
"(",
"$",
"args",
")",
",",
"$",
"varPos",
",",
"$",
"wordLength",
"=",
"static",
"::",
"length",
"(",
"$",
"varKey",
")",
")",
";",
"$",
"pos",
"=",
"$",
"varPos",
"+",
"$",
"wordLength",
";",
"// skip to end of replacement for next iteration",
"}",
"// Return the original %s strings",
"$",
"filterRegex",
"=",
"'/#\\[:~s\\]#/'",
";",
"return",
"preg_replace",
"(",
"$",
"filterRegex",
",",
"'%s'",
",",
"vsprintf",
"(",
"$",
"format",
",",
"$",
"args",
")",
")",
";",
"}"
]
| Function sprintf for named variables inside format.
Args are only used if found in the format.
Predefined tags (which can be overwritten passing them as args):
%cr$s -> \r
%lf$s -> \n
%crlf$s -> \r\n
%tab$s -> \t
This method is based on the work of Nate Bessette (www.twitter.com/frickenate)
@param string $format The format to replace the named variables into
@param array $args The args to be replaced (var => replacement).
@return string|bool The string with args replaced or false on error
@throws \BadFunctionCallException
@throws \LengthException | [
"Function",
"sprintf",
"for",
"named",
"variables",
"inside",
"format",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L872-L904 |
16,429 | ryanwachtl/silverstripe-foundation-forms | code/forms/FoundationSwitchField.php | FoundationSwitchField.getSource | public function getSource() {
if (is_array($this->source)) {
if (count($this->source) != 2) {
user_error('FoundationSwitchField::getSource(): accepts only 2 options', E_USER_ERROR);
}
return array_slice($this->source, 0, 2);
}
} | php | public function getSource() {
if (is_array($this->source)) {
if (count($this->source) != 2) {
user_error('FoundationSwitchField::getSource(): accepts only 2 options', E_USER_ERROR);
}
return array_slice($this->source, 0, 2);
}
} | [
"public",
"function",
"getSource",
"(",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"source",
")",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"source",
")",
"!=",
"2",
")",
"{",
"user_error",
"(",
"'FoundationSwitchField::getSource(): accepts only 2 options'",
",",
"E_USER_ERROR",
")",
";",
"}",
"return",
"array_slice",
"(",
"$",
"this",
"->",
"source",
",",
"0",
",",
"2",
")",
";",
"}",
"}"
]
| Gets the first two items from source array, since SwitchField only works with two values.
@return array | [
"Gets",
"the",
"first",
"two",
"items",
"from",
"source",
"array",
"since",
"SwitchField",
"only",
"works",
"with",
"two",
"values",
"."
]
| 9055449fcb895811187124d81e57b7c93948403f | https://github.com/ryanwachtl/silverstripe-foundation-forms/blob/9055449fcb895811187124d81e57b7c93948403f/code/forms/FoundationSwitchField.php#L26-L33 |
16,430 | gintonicweb/GintonicCMS | src/Shell/GintonicShell.php | GintonicShell.cleanup | public function cleanup()
{
Cache::clear(false, 'default');
Cache::clear(false, '_cake_model_');
Cache::clear(false, '_cake_core_');
$this->dispatchShell('orm_cache clear');
$this->dispatchShell('orm_cache build');
} | php | public function cleanup()
{
Cache::clear(false, 'default');
Cache::clear(false, '_cake_model_');
Cache::clear(false, '_cake_core_');
$this->dispatchShell('orm_cache clear');
$this->dispatchShell('orm_cache build');
} | [
"public",
"function",
"cleanup",
"(",
")",
"{",
"Cache",
"::",
"clear",
"(",
"false",
",",
"'default'",
")",
";",
"Cache",
"::",
"clear",
"(",
"false",
",",
"'_cake_model_'",
")",
";",
"Cache",
"::",
"clear",
"(",
"false",
",",
"'_cake_core_'",
")",
";",
"$",
"this",
"->",
"dispatchShell",
"(",
"'orm_cache clear'",
")",
";",
"$",
"this",
"->",
"dispatchShell",
"(",
"'orm_cache build'",
")",
";",
"}"
]
| Clears the cache
@return void | [
"Clears",
"the",
"cache"
]
| b34445fecea56a7d432d0f3e2f988cde8ead746b | https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Shell/GintonicShell.php#L42-L49 |
16,431 | gintonicweb/GintonicCMS | src/Shell/GintonicShell.php | GintonicShell.migrate | public function migrate($plugin = null)
{
$plugin = ($plugin === null)? '' : ' -p ' . $plugin;
$this->dispatchShell('migrations migrate' . $plugin);
} | php | public function migrate($plugin = null)
{
$plugin = ($plugin === null)? '' : ' -p ' . $plugin;
$this->dispatchShell('migrations migrate' . $plugin);
} | [
"public",
"function",
"migrate",
"(",
"$",
"plugin",
"=",
"null",
")",
"{",
"$",
"plugin",
"=",
"(",
"$",
"plugin",
"===",
"null",
")",
"?",
"''",
":",
"' -p '",
".",
"$",
"plugin",
";",
"$",
"this",
"->",
"dispatchShell",
"(",
"'migrations migrate'",
".",
"$",
"plugin",
")",
";",
"}"
]
| Run the migration, optionally for a plugin
@param string $plugin Plugin name (optional)
@return void | [
"Run",
"the",
"migration",
"optionally",
"for",
"a",
"plugin"
]
| b34445fecea56a7d432d0f3e2f988cde8ead746b | https://github.com/gintonicweb/GintonicCMS/blob/b34445fecea56a7d432d0f3e2f988cde8ead746b/src/Shell/GintonicShell.php#L57-L61 |
16,432 | mayoturis/properties-ini | src/FileSaver.php | FileSaver.save | public function save($fileName, $values, $map = null) {
if ($map !== null) {
$output = $this->createOutputWithMap($values,$map);
} else {
$output = $this->createOutput($values);
}
$this->saveToFile($fileName, $output);
} | php | public function save($fileName, $values, $map = null) {
if ($map !== null) {
$output = $this->createOutputWithMap($values,$map);
} else {
$output = $this->createOutput($values);
}
$this->saveToFile($fileName, $output);
} | [
"public",
"function",
"save",
"(",
"$",
"fileName",
",",
"$",
"values",
",",
"$",
"map",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"map",
"!==",
"null",
")",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"createOutputWithMap",
"(",
"$",
"values",
",",
"$",
"map",
")",
";",
"}",
"else",
"{",
"$",
"output",
"=",
"$",
"this",
"->",
"createOutput",
"(",
"$",
"values",
")",
";",
"}",
"$",
"this",
"->",
"saveToFile",
"(",
"$",
"fileName",
",",
"$",
"output",
")",
";",
"}"
]
| Writes configuration array to file
@param string $fileName File name
@param array $values Configuration values
@param array|null $map File map | [
"Writes",
"configuration",
"array",
"to",
"file"
]
| 79d56d8174637b1124eb90a41ffa3dca4c4a4e93 | https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/FileSaver.php#L24-L32 |
16,433 | mayoturis/properties-ini | src/FileSaver.php | FileSaver.createOutputWithMap | public function createOutputWithMap(array $values, array $map) {
$output = '';
foreach ($map as $outputLine) {
if ($outputLine['type'] == 'empty') {
$output .= PHP_EOL;
} elseif($outputLine['type'] == 'comment') {
$output .= $outputLine['value'] . PHP_EOL;
} else {
$output .= $this->createLine($outputLine['key'], $values[$outputLine['key']], $outputLine) . PHP_EOL;
unset($values[$outputLine['key']]);
}
}
// Add values which are not mapped at the end
$output .= $this->createOutput($values);
return $output;
} | php | public function createOutputWithMap(array $values, array $map) {
$output = '';
foreach ($map as $outputLine) {
if ($outputLine['type'] == 'empty') {
$output .= PHP_EOL;
} elseif($outputLine['type'] == 'comment') {
$output .= $outputLine['value'] . PHP_EOL;
} else {
$output .= $this->createLine($outputLine['key'], $values[$outputLine['key']], $outputLine) . PHP_EOL;
unset($values[$outputLine['key']]);
}
}
// Add values which are not mapped at the end
$output .= $this->createOutput($values);
return $output;
} | [
"public",
"function",
"createOutputWithMap",
"(",
"array",
"$",
"values",
",",
"array",
"$",
"map",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"map",
"as",
"$",
"outputLine",
")",
"{",
"if",
"(",
"$",
"outputLine",
"[",
"'type'",
"]",
"==",
"'empty'",
")",
"{",
"$",
"output",
".=",
"PHP_EOL",
";",
"}",
"elseif",
"(",
"$",
"outputLine",
"[",
"'type'",
"]",
"==",
"'comment'",
")",
"{",
"$",
"output",
".=",
"$",
"outputLine",
"[",
"'value'",
"]",
".",
"PHP_EOL",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"createLine",
"(",
"$",
"outputLine",
"[",
"'key'",
"]",
",",
"$",
"values",
"[",
"$",
"outputLine",
"[",
"'key'",
"]",
"]",
",",
"$",
"outputLine",
")",
".",
"PHP_EOL",
";",
"unset",
"(",
"$",
"values",
"[",
"$",
"outputLine",
"[",
"'key'",
"]",
"]",
")",
";",
"}",
"}",
"// Add values which are not mapped at the end",
"$",
"output",
".=",
"$",
"this",
"->",
"createOutput",
"(",
"$",
"values",
")",
";",
"return",
"$",
"output",
";",
"}"
]
| Creates output string with provided map
@param array $values Configuration values
@param array $map
@return string | [
"Creates",
"output",
"string",
"with",
"provided",
"map"
]
| 79d56d8174637b1124eb90a41ffa3dca4c4a4e93 | https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/FileSaver.php#L41-L58 |
16,434 | mayoturis/properties-ini | src/FileSaver.php | FileSaver.createOutput | public function createOutput($values) {
$output = '';
foreach ($values as $key => $value) {
$output .= $this->createLine($key, $value) . PHP_EOL;
}
return $output;
} | php | public function createOutput($values) {
$output = '';
foreach ($values as $key => $value) {
$output .= $this->createLine($key, $value) . PHP_EOL;
}
return $output;
} | [
"public",
"function",
"createOutput",
"(",
"$",
"values",
")",
"{",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"createLine",
"(",
"$",
"key",
",",
"$",
"value",
")",
".",
"PHP_EOL",
";",
"}",
"return",
"$",
"output",
";",
"}"
]
| Creates output string from configuration values
@param array $values Configuration values
@return string | [
"Creates",
"output",
"string",
"from",
"configuration",
"values"
]
| 79d56d8174637b1124eb90a41ffa3dca4c4a4e93 | https://github.com/mayoturis/properties-ini/blob/79d56d8174637b1124eb90a41ffa3dca4c4a4e93/src/FileSaver.php#L66-L73 |
16,435 | phossa2/middleware | src/Middleware/Queue.php | Queue.fillTheQueue | protected function fillTheQueue(array $middlewares)
{
foreach ($middlewares as $mw) {
// with conditions specified
if (is_array($mw)) {
$this->push($mw[0], $mw[1]);
// no condition
} else {
$this->push($mw);
}
}
} | php | protected function fillTheQueue(array $middlewares)
{
foreach ($middlewares as $mw) {
// with conditions specified
if (is_array($mw)) {
$this->push($mw[0], $mw[1]);
// no condition
} else {
$this->push($mw);
}
}
} | [
"protected",
"function",
"fillTheQueue",
"(",
"array",
"$",
"middlewares",
")",
"{",
"foreach",
"(",
"$",
"middlewares",
"as",
"$",
"mw",
")",
"{",
"// with conditions specified",
"if",
"(",
"is_array",
"(",
"$",
"mw",
")",
")",
"{",
"$",
"this",
"->",
"push",
"(",
"$",
"mw",
"[",
"0",
"]",
",",
"$",
"mw",
"[",
"1",
"]",
")",
";",
"// no condition",
"}",
"else",
"{",
"$",
"this",
"->",
"push",
"(",
"$",
"mw",
")",
";",
"}",
"}",
"}"
]
| Fill the queue with middlewares
@param array $middlewares
@access protected | [
"Fill",
"the",
"queue",
"with",
"middlewares"
]
| 518e97ae48077f2c11adcd3c2393830ed7ab7ce7 | https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Queue.php#L145-L157 |
16,436 | phossa2/middleware | src/Middleware/Queue.php | Queue.evalCondition | protected function evalCondition(
$condition,
RequestInterface $request,
ResponseInterface $response
)/*# : bool */ {
// instanceof ConditionInterface
if (is_object($condition) && $condition instanceof ConditionInterface) {
return $condition->evaluate($request, $response);
// old style callable
} elseif (is_callable($condition)) {
return $condition($request, $response);
// unknown type
} else {
throw new LogicException(
Message::get(Message::CONDITION_INVALID, $condition),
Message::CONDITION_INVALID
);
}
} | php | protected function evalCondition(
$condition,
RequestInterface $request,
ResponseInterface $response
)/*# : bool */ {
// instanceof ConditionInterface
if (is_object($condition) && $condition instanceof ConditionInterface) {
return $condition->evaluate($request, $response);
// old style callable
} elseif (is_callable($condition)) {
return $condition($request, $response);
// unknown type
} else {
throw new LogicException(
Message::get(Message::CONDITION_INVALID, $condition),
Message::CONDITION_INVALID
);
}
} | [
"protected",
"function",
"evalCondition",
"(",
"$",
"condition",
",",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"/*# : bool */",
"{",
"// instanceof ConditionInterface",
"if",
"(",
"is_object",
"(",
"$",
"condition",
")",
"&&",
"$",
"condition",
"instanceof",
"ConditionInterface",
")",
"{",
"return",
"$",
"condition",
"->",
"evaluate",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"// old style callable",
"}",
"elseif",
"(",
"is_callable",
"(",
"$",
"condition",
")",
")",
"{",
"return",
"$",
"condition",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"// unknown type",
"}",
"else",
"{",
"throw",
"new",
"LogicException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"CONDITION_INVALID",
",",
"$",
"condition",
")",
",",
"Message",
"::",
"CONDITION_INVALID",
")",
";",
"}",
"}"
]
| Evaluate the condition
support both a callable returns bool value or an object instance of
ConditionInterface.
@param ConditionInterface|callable $condition
@param RequestInterface $request
@param ResponseInterface $response
@return bool
@throws LogicException if condition is invalid
@access protected | [
"Evaluate",
"the",
"condition"
]
| 518e97ae48077f2c11adcd3c2393830ed7ab7ce7 | https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Queue.php#L204-L224 |
16,437 | paulzi/multicurl | MultiCurl.php | MultiCurl.add | public function add($request)
{
$this->onBefore($request);
array_push($this->_requests, $request);
curl_multi_add_handle($this->_mh, $request->curl);
$this->_updated = true;
} | php | public function add($request)
{
$this->onBefore($request);
array_push($this->_requests, $request);
curl_multi_add_handle($this->_mh, $request->curl);
$this->_updated = true;
} | [
"public",
"function",
"add",
"(",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"onBefore",
"(",
"$",
"request",
")",
";",
"array_push",
"(",
"$",
"this",
"->",
"_requests",
",",
"$",
"request",
")",
";",
"curl_multi_add_handle",
"(",
"$",
"this",
"->",
"_mh",
",",
"$",
"request",
"->",
"curl",
")",
";",
"$",
"this",
"->",
"_updated",
"=",
"true",
";",
"}"
]
| Add request to execute
@param MultiCurlRequest $request | [
"Add",
"request",
"to",
"execute"
]
| 2e326d868add238bb2820f3271e235bfed12e5cb | https://github.com/paulzi/multicurl/blob/2e326d868add238bb2820f3271e235bfed12e5cb/MultiCurl.php#L47-L53 |
16,438 | FrenchFrogs/framework | src/Table/Column/Link.php | Link.getBindedLink | public function getBindedLink($row = [])
{
$bind = array_intersect_key($row, array_fill_keys($this->getBinds(), ''));
// patch pour les paramètre bindé en query
$link = str_replace('%25', '%', $this->getLink());
return vsprintf($link, $bind);
} | php | public function getBindedLink($row = [])
{
$bind = array_intersect_key($row, array_fill_keys($this->getBinds(), ''));
// patch pour les paramètre bindé en query
$link = str_replace('%25', '%', $this->getLink());
return vsprintf($link, $bind);
} | [
"public",
"function",
"getBindedLink",
"(",
"$",
"row",
"=",
"[",
"]",
")",
"{",
"$",
"bind",
"=",
"array_intersect_key",
"(",
"$",
"row",
",",
"array_fill_keys",
"(",
"$",
"this",
"->",
"getBinds",
"(",
")",
",",
"''",
")",
")",
";",
"// patch pour les paramètre bindé en query",
"$",
"link",
"=",
"str_replace",
"(",
"'%25'",
",",
"'%'",
",",
"$",
"this",
"->",
"getLink",
"(",
")",
")",
";",
"return",
"vsprintf",
"(",
"$",
"link",
",",
"$",
"bind",
")",
";",
"}"
]
| Return the binded link
@param array $row
@return string | [
"Return",
"the",
"binded",
"link"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Column/Link.php#L154-L161 |
16,439 | joomla-framework/profiler | src/Profiler.php | Profiler.getTimeBetween | public function getTimeBetween($first, $second)
{
if (!isset($this->lookup[$first]))
{
throw new \LogicException(
sprintf(
'The point %s was not marked in the profiler %s.',
$first,
$this->name
)
);
}
if (!isset($this->lookup[$second]))
{
throw new \LogicException(
sprintf(
'The point %s was not marked in the profiler %s.',
$second,
$this->name
)
);
}
$indexFirst = $this->lookup[$first];
$indexSecond = $this->lookup[$second];
$firstPoint = $this->points[$indexFirst];
$secondPoint = $this->points[$indexSecond];
return abs($secondPoint->getTime() - $firstPoint->getTime());
} | php | public function getTimeBetween($first, $second)
{
if (!isset($this->lookup[$first]))
{
throw new \LogicException(
sprintf(
'The point %s was not marked in the profiler %s.',
$first,
$this->name
)
);
}
if (!isset($this->lookup[$second]))
{
throw new \LogicException(
sprintf(
'The point %s was not marked in the profiler %s.',
$second,
$this->name
)
);
}
$indexFirst = $this->lookup[$first];
$indexSecond = $this->lookup[$second];
$firstPoint = $this->points[$indexFirst];
$secondPoint = $this->points[$indexSecond];
return abs($secondPoint->getTime() - $firstPoint->getTime());
} | [
"public",
"function",
"getTimeBetween",
"(",
"$",
"first",
",",
"$",
"second",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"lookup",
"[",
"$",
"first",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The point %s was not marked in the profiler %s.'",
",",
"$",
"first",
",",
"$",
"this",
"->",
"name",
")",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"lookup",
"[",
"$",
"second",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The point %s was not marked in the profiler %s.'",
",",
"$",
"second",
",",
"$",
"this",
"->",
"name",
")",
")",
";",
"}",
"$",
"indexFirst",
"=",
"$",
"this",
"->",
"lookup",
"[",
"$",
"first",
"]",
";",
"$",
"indexSecond",
"=",
"$",
"this",
"->",
"lookup",
"[",
"$",
"second",
"]",
";",
"$",
"firstPoint",
"=",
"$",
"this",
"->",
"points",
"[",
"$",
"indexFirst",
"]",
";",
"$",
"secondPoint",
"=",
"$",
"this",
"->",
"points",
"[",
"$",
"indexSecond",
"]",
";",
"return",
"abs",
"(",
"$",
"secondPoint",
"->",
"getTime",
"(",
")",
"-",
"$",
"firstPoint",
"->",
"getTime",
"(",
")",
")",
";",
"}"
]
| Get the elapsed time in seconds between the two points.
@param string $first The name of the first point.
@param string $second The name of the second point.
@return float The elapsed time between these points in seconds.
@since 1.0
@throws \LogicException If the points were not marked. | [
"Get",
"the",
"elapsed",
"time",
"in",
"seconds",
"between",
"the",
"two",
"points",
"."
]
| efdea10dc547d8fa853be6737100c844be227ca6 | https://github.com/joomla-framework/profiler/blob/efdea10dc547d8fa853be6737100c844be227ca6/src/Profiler.php#L269-L300 |
16,440 | joomla-framework/profiler | src/Profiler.php | Profiler.setStart | public function setStart($timeStamp = 0.0, $memoryBytes = 0)
{
if (!empty($this->points))
{
throw new \RuntimeException('The start point cannot be adjusted after points are added to the profiler.');
}
$this->startTimeStamp = $timeStamp;
$this->startMemoryBytes = $memoryBytes;
$point = new ProfilePoint('start');
// Store the point.
$this->points[] = $point;
// Add it in the lookup table.
$this->lookup[$point->getName()] = \count($this->points) - 1;
return $this;
} | php | public function setStart($timeStamp = 0.0, $memoryBytes = 0)
{
if (!empty($this->points))
{
throw new \RuntimeException('The start point cannot be adjusted after points are added to the profiler.');
}
$this->startTimeStamp = $timeStamp;
$this->startMemoryBytes = $memoryBytes;
$point = new ProfilePoint('start');
// Store the point.
$this->points[] = $point;
// Add it in the lookup table.
$this->lookup[$point->getName()] = \count($this->points) - 1;
return $this;
} | [
"public",
"function",
"setStart",
"(",
"$",
"timeStamp",
"=",
"0.0",
",",
"$",
"memoryBytes",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"points",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The start point cannot be adjusted after points are added to the profiler.'",
")",
";",
"}",
"$",
"this",
"->",
"startTimeStamp",
"=",
"$",
"timeStamp",
";",
"$",
"this",
"->",
"startMemoryBytes",
"=",
"$",
"memoryBytes",
";",
"$",
"point",
"=",
"new",
"ProfilePoint",
"(",
"'start'",
")",
";",
"// Store the point.",
"$",
"this",
"->",
"points",
"[",
"]",
"=",
"$",
"point",
";",
"// Add it in the lookup table.",
"$",
"this",
"->",
"lookup",
"[",
"$",
"point",
"->",
"getName",
"(",
")",
"]",
"=",
"\\",
"count",
"(",
"$",
"this",
"->",
"points",
")",
"-",
"1",
";",
"return",
"$",
"this",
";",
"}"
]
| Creates a profile point with the specified starting time and memory.
This method will only add a point if no other points have been added as the ProfilePointInterface objects created before changing
the start point would result in inaccurate measurements.
@param float $timeStamp Unix timestamp in microseconds when the profiler should start measuring time.
@param integer $memoryBytes Memory amount in bytes when the profiler should start measuring memory.
@return ProfilerInterface This method is chainable.
@since 1.2.0
@throws \RuntimeException | [
"Creates",
"a",
"profile",
"point",
"with",
"the",
"specified",
"starting",
"time",
"and",
"memory",
"."
]
| efdea10dc547d8fa853be6737100c844be227ca6 | https://github.com/joomla-framework/profiler/blob/efdea10dc547d8fa853be6737100c844be227ca6/src/Profiler.php#L460-L479 |
16,441 | verschoof/bunq-api | src/Service/DefaultInstallationService.php | DefaultInstallationService.install | public function install()
{
$publicKey = $this->certificateStorage->load(CertificateType::PUBLIC_KEY());
$response = $this->sendInstallationPostRequest(
'/v1/installation',
[
'json' => [
'client_public_key' => $publicKey->toString(),
],
]
);
$responseArray = \json_decode((string)$response->getBody(), true);
return [
'token' => $responseArray['Response'][1]['Token']['token'],
'public_key' => $responseArray['Response'][2]['ServerPublicKey']['server_public_key'],
];
} | php | public function install()
{
$publicKey = $this->certificateStorage->load(CertificateType::PUBLIC_KEY());
$response = $this->sendInstallationPostRequest(
'/v1/installation',
[
'json' => [
'client_public_key' => $publicKey->toString(),
],
]
);
$responseArray = \json_decode((string)$response->getBody(), true);
return [
'token' => $responseArray['Response'][1]['Token']['token'],
'public_key' => $responseArray['Response'][2]['ServerPublicKey']['server_public_key'],
];
} | [
"public",
"function",
"install",
"(",
")",
"{",
"$",
"publicKey",
"=",
"$",
"this",
"->",
"certificateStorage",
"->",
"load",
"(",
"CertificateType",
"::",
"PUBLIC_KEY",
"(",
")",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"sendInstallationPostRequest",
"(",
"'/v1/installation'",
",",
"[",
"'json'",
"=>",
"[",
"'client_public_key'",
"=>",
"$",
"publicKey",
"->",
"toString",
"(",
")",
",",
"]",
",",
"]",
")",
";",
"$",
"responseArray",
"=",
"\\",
"json_decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"return",
"[",
"'token'",
"=>",
"$",
"responseArray",
"[",
"'Response'",
"]",
"[",
"1",
"]",
"[",
"'Token'",
"]",
"[",
"'token'",
"]",
",",
"'public_key'",
"=>",
"$",
"responseArray",
"[",
"'Response'",
"]",
"[",
"2",
"]",
"[",
"'ServerPublicKey'",
"]",
"[",
"'server_public_key'",
"]",
",",
"]",
";",
"}"
]
| Registers your public key with the Bunq API.
@return array | [
"Registers",
"your",
"public",
"key",
"with",
"the",
"Bunq",
"API",
"."
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Service/DefaultInstallationService.php#L60-L79 |
16,442 | verschoof/bunq-api | src/Service/DefaultInstallationService.php | DefaultInstallationService.registerDevice | public function registerDevice(Token $token)
{
$this->sendInstallationPostRequest(
'/v1/device-server',
[
'headers' => [
'X-Bunq-Client-Authentication' => $token->toString(),
],
'json' => [
'description' => 'Bunq PHP API Client',
'secret' => $this->apiKey,
'permitted_ips' => $this->permittedIps,
],
]
);
} | php | public function registerDevice(Token $token)
{
$this->sendInstallationPostRequest(
'/v1/device-server',
[
'headers' => [
'X-Bunq-Client-Authentication' => $token->toString(),
],
'json' => [
'description' => 'Bunq PHP API Client',
'secret' => $this->apiKey,
'permitted_ips' => $this->permittedIps,
],
]
);
} | [
"public",
"function",
"registerDevice",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"sendInstallationPostRequest",
"(",
"'/v1/device-server'",
",",
"[",
"'headers'",
"=>",
"[",
"'X-Bunq-Client-Authentication'",
"=>",
"$",
"token",
"->",
"toString",
"(",
")",
",",
"]",
",",
"'json'",
"=>",
"[",
"'description'",
"=>",
"'Bunq PHP API Client'",
",",
"'secret'",
"=>",
"$",
"this",
"->",
"apiKey",
",",
"'permitted_ips'",
"=>",
"$",
"this",
"->",
"permittedIps",
",",
"]",
",",
"]",
")",
";",
"}"
]
| Registers a device with the Bunq API.
@param Token $token
return void | [
"Registers",
"a",
"device",
"with",
"the",
"Bunq",
"API",
"."
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Service/DefaultInstallationService.php#L88-L103 |
16,443 | verschoof/bunq-api | src/Service/DefaultInstallationService.php | DefaultInstallationService.createSession | public function createSession(Token $token)
{
$response = $this->sendInstallationPostRequest(
'/v1/session-server',
[
'headers' => [
'X-Bunq-Client-Authentication' => $token->toString(),
],
'json' => [
'secret' => $this->apiKey,
],
]
);
$responseArray = \json_decode((string)$response->getBody(), true);
return $responseArray['Response'][1]['Token']['token'];
} | php | public function createSession(Token $token)
{
$response = $this->sendInstallationPostRequest(
'/v1/session-server',
[
'headers' => [
'X-Bunq-Client-Authentication' => $token->toString(),
],
'json' => [
'secret' => $this->apiKey,
],
]
);
$responseArray = \json_decode((string)$response->getBody(), true);
return $responseArray['Response'][1]['Token']['token'];
} | [
"public",
"function",
"createSession",
"(",
"Token",
"$",
"token",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"sendInstallationPostRequest",
"(",
"'/v1/session-server'",
",",
"[",
"'headers'",
"=>",
"[",
"'X-Bunq-Client-Authentication'",
"=>",
"$",
"token",
"->",
"toString",
"(",
")",
",",
"]",
",",
"'json'",
"=>",
"[",
"'secret'",
"=>",
"$",
"this",
"->",
"apiKey",
",",
"]",
",",
"]",
")",
";",
"$",
"responseArray",
"=",
"\\",
"json_decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
",",
"true",
")",
";",
"return",
"$",
"responseArray",
"[",
"'Response'",
"]",
"[",
"1",
"]",
"[",
"'Token'",
"]",
"[",
"'token'",
"]",
";",
"}"
]
| Registers a session with the Bunq API.
@param Token $token
@return array | [
"Registers",
"a",
"session",
"with",
"the",
"Bunq",
"API",
"."
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Service/DefaultInstallationService.php#L112-L129 |
16,444 | verschoof/bunq-api | src/Service/DefaultInstallationService.php | DefaultInstallationService.sendInstallationPostRequest | private function sendInstallationPostRequest($url, array $options = [])
{
try {
return $this->httpClient->request('POST', $url, $options);
} catch (ClientException $exception) {
throw new BunqException($exception);
}
} | php | private function sendInstallationPostRequest($url, array $options = [])
{
try {
return $this->httpClient->request('POST', $url, $options);
} catch (ClientException $exception) {
throw new BunqException($exception);
}
} | [
"private",
"function",
"sendInstallationPostRequest",
"(",
"$",
"url",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"httpClient",
"->",
"request",
"(",
"'POST'",
",",
"$",
"url",
",",
"$",
"options",
")",
";",
"}",
"catch",
"(",
"ClientException",
"$",
"exception",
")",
"{",
"throw",
"new",
"BunqException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
]
| Sends a post request using the installation HTTP Client
@param $url
@param array $options
@return ResponseInterface
@throws BunqException | [
"Sends",
"a",
"post",
"request",
"using",
"the",
"installation",
"HTTP",
"Client"
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Service/DefaultInstallationService.php#L140-L147 |
16,445 | mremi/Dolist | src/Mremi/Dolist/Authentication/AuthenticationManager.php | AuthenticationManager.authenticate | private function authenticate()
{
$try = 0;
while (true) {
$try++;
try {
$response = $this->soapClient->__soapCall('GetAuthenticationToken', array(array(
'authenticationRequest' => $this->authenticationRequest->toArray(),
)));
return new AuthenticationTokenResponse(new \DateTime($response->GetAuthenticationTokenResult->DeprecatedDate), $response->GetAuthenticationTokenResult->Key);
} catch (\SoapFault $e) {
if (null !== $this->logger) {
$this->logger->critical(sprintf('[%] %s', __CLASS__, $e->getMessage()));
}
if ($try >= $this->retries) {
throw $e;
}
// waiting 500ms before next call
usleep(500000);
}
}
} | php | private function authenticate()
{
$try = 0;
while (true) {
$try++;
try {
$response = $this->soapClient->__soapCall('GetAuthenticationToken', array(array(
'authenticationRequest' => $this->authenticationRequest->toArray(),
)));
return new AuthenticationTokenResponse(new \DateTime($response->GetAuthenticationTokenResult->DeprecatedDate), $response->GetAuthenticationTokenResult->Key);
} catch (\SoapFault $e) {
if (null !== $this->logger) {
$this->logger->critical(sprintf('[%] %s', __CLASS__, $e->getMessage()));
}
if ($try >= $this->retries) {
throw $e;
}
// waiting 500ms before next call
usleep(500000);
}
}
} | [
"private",
"function",
"authenticate",
"(",
")",
"{",
"$",
"try",
"=",
"0",
";",
"while",
"(",
"true",
")",
"{",
"$",
"try",
"++",
";",
"try",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"soapClient",
"->",
"__soapCall",
"(",
"'GetAuthenticationToken'",
",",
"array",
"(",
"array",
"(",
"'authenticationRequest'",
"=>",
"$",
"this",
"->",
"authenticationRequest",
"->",
"toArray",
"(",
")",
",",
")",
")",
")",
";",
"return",
"new",
"AuthenticationTokenResponse",
"(",
"new",
"\\",
"DateTime",
"(",
"$",
"response",
"->",
"GetAuthenticationTokenResult",
"->",
"DeprecatedDate",
")",
",",
"$",
"response",
"->",
"GetAuthenticationTokenResult",
"->",
"Key",
")",
";",
"}",
"catch",
"(",
"\\",
"SoapFault",
"$",
"e",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"critical",
"(",
"sprintf",
"(",
"'[%] %s'",
",",
"__CLASS__",
",",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"try",
">=",
"$",
"this",
"->",
"retries",
")",
"{",
"throw",
"$",
"e",
";",
"}",
"// waiting 500ms before next call",
"usleep",
"(",
"500000",
")",
";",
"}",
"}",
"}"
]
| Calls the authentication API
@return AuthenticationTokenResponse
@throws \SoapFault | [
"Calls",
"the",
"authentication",
"API"
]
| 452c863aba12ef2965bafdb619c0278f8fc732d0 | https://github.com/mremi/Dolist/blob/452c863aba12ef2965bafdb619c0278f8fc732d0/src/Mremi/Dolist/Authentication/AuthenticationManager.php#L83-L109 |
16,446 | fsi-open/datasource-bundle | DataSource/Extension/Symfony/Form/Field/FormFieldExtension.php | FormFieldExtension.getForm | protected function getForm(FieldTypeInterface $field, $force = false)
{
$datasource = $field->getDataSource();
if ($datasource === null) {
return null;
}
if (!$field->getOption('form_filter')) {
return null;
}
$field_oid = spl_object_hash($field);
if (isset($this->forms[$field_oid]) && !$force) {
return $this->forms[$field_oid];
}
$options = $field->getOption('form_options');
$options = array_merge($options, ['required' => false, 'auto_initialize' => false]);
$form = $this->formFactory->createNamed(
$datasource->getName(),
$this->isFqcnFormTypePossible()
? 'Symfony\Component\Form\Extension\Core\Type\CollectionType'
: 'collection',
null,
['csrf_protection' => false]
);
$fieldsForm = $this->formFactory->createNamed(
DataSourceInterface::PARAMETER_FIELDS,
$this->isFqcnFormTypePossible()
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
: 'form',
null,
['auto_initialize' => false]
);
switch ($field->getComparison()) {
case 'between':
$this->buildBetweenComparisonForm($fieldsForm, $field, $options);
break;
case 'isNull':
$this->buildIsNullComparisonForm($fieldsForm, $field, $options);
break;
default:
switch ($field->getType()) {
case 'boolean':
$this->buildBooleanForm($fieldsForm, $field, $options);
break;
default:
$fieldsForm->add($field->getName(), $this->getFieldFormType($field), $options);
}
}
$form->add($fieldsForm);
$this->forms[$field_oid] = $form;
return $this->forms[$field_oid];
} | php | protected function getForm(FieldTypeInterface $field, $force = false)
{
$datasource = $field->getDataSource();
if ($datasource === null) {
return null;
}
if (!$field->getOption('form_filter')) {
return null;
}
$field_oid = spl_object_hash($field);
if (isset($this->forms[$field_oid]) && !$force) {
return $this->forms[$field_oid];
}
$options = $field->getOption('form_options');
$options = array_merge($options, ['required' => false, 'auto_initialize' => false]);
$form = $this->formFactory->createNamed(
$datasource->getName(),
$this->isFqcnFormTypePossible()
? 'Symfony\Component\Form\Extension\Core\Type\CollectionType'
: 'collection',
null,
['csrf_protection' => false]
);
$fieldsForm = $this->formFactory->createNamed(
DataSourceInterface::PARAMETER_FIELDS,
$this->isFqcnFormTypePossible()
? 'Symfony\Component\Form\Extension\Core\Type\FormType'
: 'form',
null,
['auto_initialize' => false]
);
switch ($field->getComparison()) {
case 'between':
$this->buildBetweenComparisonForm($fieldsForm, $field, $options);
break;
case 'isNull':
$this->buildIsNullComparisonForm($fieldsForm, $field, $options);
break;
default:
switch ($field->getType()) {
case 'boolean':
$this->buildBooleanForm($fieldsForm, $field, $options);
break;
default:
$fieldsForm->add($field->getName(), $this->getFieldFormType($field), $options);
}
}
$form->add($fieldsForm);
$this->forms[$field_oid] = $form;
return $this->forms[$field_oid];
} | [
"protected",
"function",
"getForm",
"(",
"FieldTypeInterface",
"$",
"field",
",",
"$",
"force",
"=",
"false",
")",
"{",
"$",
"datasource",
"=",
"$",
"field",
"->",
"getDataSource",
"(",
")",
";",
"if",
"(",
"$",
"datasource",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"field",
"->",
"getOption",
"(",
"'form_filter'",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"field_oid",
"=",
"spl_object_hash",
"(",
"$",
"field",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"forms",
"[",
"$",
"field_oid",
"]",
")",
"&&",
"!",
"$",
"force",
")",
"{",
"return",
"$",
"this",
"->",
"forms",
"[",
"$",
"field_oid",
"]",
";",
"}",
"$",
"options",
"=",
"$",
"field",
"->",
"getOption",
"(",
"'form_options'",
")",
";",
"$",
"options",
"=",
"array_merge",
"(",
"$",
"options",
",",
"[",
"'required'",
"=>",
"false",
",",
"'auto_initialize'",
"=>",
"false",
"]",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"createNamed",
"(",
"$",
"datasource",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"isFqcnFormTypePossible",
"(",
")",
"?",
"'Symfony\\Component\\Form\\Extension\\Core\\Type\\CollectionType'",
":",
"'collection'",
",",
"null",
",",
"[",
"'csrf_protection'",
"=>",
"false",
"]",
")",
";",
"$",
"fieldsForm",
"=",
"$",
"this",
"->",
"formFactory",
"->",
"createNamed",
"(",
"DataSourceInterface",
"::",
"PARAMETER_FIELDS",
",",
"$",
"this",
"->",
"isFqcnFormTypePossible",
"(",
")",
"?",
"'Symfony\\Component\\Form\\Extension\\Core\\Type\\FormType'",
":",
"'form'",
",",
"null",
",",
"[",
"'auto_initialize'",
"=>",
"false",
"]",
")",
";",
"switch",
"(",
"$",
"field",
"->",
"getComparison",
"(",
")",
")",
"{",
"case",
"'between'",
":",
"$",
"this",
"->",
"buildBetweenComparisonForm",
"(",
"$",
"fieldsForm",
",",
"$",
"field",
",",
"$",
"options",
")",
";",
"break",
";",
"case",
"'isNull'",
":",
"$",
"this",
"->",
"buildIsNullComparisonForm",
"(",
"$",
"fieldsForm",
",",
"$",
"field",
",",
"$",
"options",
")",
";",
"break",
";",
"default",
":",
"switch",
"(",
"$",
"field",
"->",
"getType",
"(",
")",
")",
"{",
"case",
"'boolean'",
":",
"$",
"this",
"->",
"buildBooleanForm",
"(",
"$",
"fieldsForm",
",",
"$",
"field",
",",
"$",
"options",
")",
";",
"break",
";",
"default",
":",
"$",
"fieldsForm",
"->",
"add",
"(",
"$",
"field",
"->",
"getName",
"(",
")",
",",
"$",
"this",
"->",
"getFieldFormType",
"(",
"$",
"field",
")",
",",
"$",
"options",
")",
";",
"}",
"}",
"$",
"form",
"->",
"add",
"(",
"$",
"fieldsForm",
")",
";",
"$",
"this",
"->",
"forms",
"[",
"$",
"field_oid",
"]",
"=",
"$",
"form",
";",
"return",
"$",
"this",
"->",
"forms",
"[",
"$",
"field_oid",
"]",
";",
"}"
]
| Builds form.
@param FieldTypeInterface $field
@param bool $force
@return FormInterface|null | [
"Builds",
"form",
"."
]
| 06964672c838af9f4125065e3a90b2df4e8aa077 | https://github.com/fsi-open/datasource-bundle/blob/06964672c838af9f4125065e3a90b2df4e8aa077/DataSource/Extension/Symfony/Form/Field/FormFieldExtension.php#L175-L238 |
16,447 | codezero-be/cookie | src/VanillaCookie.php | VanillaCookie.decrypt | private function decrypt($cookieValue)
{
if ($this->encrypter && ! empty($cookieValue)) {
return $this->encrypter->decrypt($cookieValue);
}
return $cookieValue;
} | php | private function decrypt($cookieValue)
{
if ($this->encrypter && ! empty($cookieValue)) {
return $this->encrypter->decrypt($cookieValue);
}
return $cookieValue;
} | [
"private",
"function",
"decrypt",
"(",
"$",
"cookieValue",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"encrypter",
"&&",
"!",
"empty",
"(",
"$",
"cookieValue",
")",
")",
"{",
"return",
"$",
"this",
"->",
"encrypter",
"->",
"decrypt",
"(",
"$",
"cookieValue",
")",
";",
"}",
"return",
"$",
"cookieValue",
";",
"}"
]
| Decrypt a cookie
@param string $cookieValue
@return string | [
"Decrypt",
"a",
"cookie"
]
| 5300089c9dc7bd48c9865d53c3aed8bd513da6d2 | https://github.com/codezero-be/cookie/blob/5300089c9dc7bd48c9865d53c3aed8bd513da6d2/src/VanillaCookie.php#L135-L142 |
16,448 | kiwiz/ecl | src/ExpressionLanguage.php | ExpressionLanguage.evaluate | public function evaluate($expression, $values=[]) {
if(is_array($values)) {
return parent::evaluate($expression, $values);
} else {
return $this->parse($expression, $values->getKeys())->getNodes()->evaluate($this->functions, $values);
}
} | php | public function evaluate($expression, $values=[]) {
if(is_array($values)) {
return parent::evaluate($expression, $values);
} else {
return $this->parse($expression, $values->getKeys())->getNodes()->evaluate($this->functions, $values);
}
} | [
"public",
"function",
"evaluate",
"(",
"$",
"expression",
",",
"$",
"values",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"return",
"parent",
"::",
"evaluate",
"(",
"$",
"expression",
",",
"$",
"values",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"parse",
"(",
"$",
"expression",
",",
"$",
"values",
"->",
"getKeys",
"(",
")",
")",
"->",
"getNodes",
"(",
")",
"->",
"evaluate",
"(",
"$",
"this",
"->",
"functions",
",",
"$",
"values",
")",
";",
"}",
"}"
]
| Evaluate an expression.
Overridden to allow passing in a SymbolTable.
@param \Symfony\Component\ExpressionLanguage\Expression|string $expression
@param SymbolTable|array|\ArrayAccess $values
@return mixed | [
"Evaluate",
"an",
"expression",
".",
"Overridden",
"to",
"allow",
"passing",
"in",
"a",
"SymbolTable",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/ExpressionLanguage.php#L53-L59 |
16,449 | tjbp/laravel-verify-emails | src/Foundation/Auth/VerifiesEmails.php | VerifiesEmails.resend | public function resend(Request $request)
{
$user = Auth::user();
if ($user->getVerified()) {
return redirect()->back();
}
$response = VerifyEmail::sendVerificationLink($user, function (Message $message) use ($user) {
$message->subject($user->getVerifyEmailSubject());
});
switch ($response) {
case VerifyEmail::VERIFY_LINK_SENT:
return redirect()->back()->with('status', trans($response));
}
} | php | public function resend(Request $request)
{
$user = Auth::user();
if ($user->getVerified()) {
return redirect()->back();
}
$response = VerifyEmail::sendVerificationLink($user, function (Message $message) use ($user) {
$message->subject($user->getVerifyEmailSubject());
});
switch ($response) {
case VerifyEmail::VERIFY_LINK_SENT:
return redirect()->back()->with('status', trans($response));
}
} | [
"public",
"function",
"resend",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"user",
"=",
"Auth",
"::",
"user",
"(",
")",
";",
"if",
"(",
"$",
"user",
"->",
"getVerified",
"(",
")",
")",
"{",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
";",
"}",
"$",
"response",
"=",
"VerifyEmail",
"::",
"sendVerificationLink",
"(",
"$",
"user",
",",
"function",
"(",
"Message",
"$",
"message",
")",
"use",
"(",
"$",
"user",
")",
"{",
"$",
"message",
"->",
"subject",
"(",
"$",
"user",
"->",
"getVerifyEmailSubject",
"(",
")",
")",
";",
"}",
")",
";",
"switch",
"(",
"$",
"response",
")",
"{",
"case",
"VerifyEmail",
"::",
"VERIFY_LINK_SENT",
":",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"with",
"(",
"'status'",
",",
"trans",
"(",
"$",
"response",
")",
")",
";",
"}",
"}"
]
| Send another verification email.
@param \Illuminate\Http\Request $request
@return \Illuminate\Http\Response | [
"Send",
"another",
"verification",
"email",
"."
]
| 1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6 | https://github.com/tjbp/laravel-verify-emails/blob/1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6/src/Foundation/Auth/VerifiesEmails.php#L28-L44 |
16,450 | tjbp/laravel-verify-emails | src/Foundation/Auth/VerifiesEmails.php | VerifiesEmails.verify | public function verify($token)
{
$response = VerifyEmail::verify(Auth::user(), $token);
switch ($response) {
case VerifyEmail::EMAIL_VERIFIED:
return redirect($this->redirectPath())->with('status', trans($response));
default:
return redirect()->back()
->withErrors(['email' => trans($response)]);
}
} | php | public function verify($token)
{
$response = VerifyEmail::verify(Auth::user(), $token);
switch ($response) {
case VerifyEmail::EMAIL_VERIFIED:
return redirect($this->redirectPath())->with('status', trans($response));
default:
return redirect()->back()
->withErrors(['email' => trans($response)]);
}
} | [
"public",
"function",
"verify",
"(",
"$",
"token",
")",
"{",
"$",
"response",
"=",
"VerifyEmail",
"::",
"verify",
"(",
"Auth",
"::",
"user",
"(",
")",
",",
"$",
"token",
")",
";",
"switch",
"(",
"$",
"response",
")",
"{",
"case",
"VerifyEmail",
"::",
"EMAIL_VERIFIED",
":",
"return",
"redirect",
"(",
"$",
"this",
"->",
"redirectPath",
"(",
")",
")",
"->",
"with",
"(",
"'status'",
",",
"trans",
"(",
"$",
"response",
")",
")",
";",
"default",
":",
"return",
"redirect",
"(",
")",
"->",
"back",
"(",
")",
"->",
"withErrors",
"(",
"[",
"'email'",
"=>",
"trans",
"(",
"$",
"response",
")",
"]",
")",
";",
"}",
"}"
]
| Attempt to verify a user.
@param string $token
@return \Illuminate\Http\Response | [
"Attempt",
"to",
"verify",
"a",
"user",
"."
]
| 1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6 | https://github.com/tjbp/laravel-verify-emails/blob/1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6/src/Foundation/Auth/VerifiesEmails.php#L52-L64 |
16,451 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addColumn | public function addColumn(Column\Column $column)
{
// Join column to the table
$column->setTable($this);
// Add renderer to column if it didn't has one
if (!$column->hasRenderer()) {
$column->setRenderer($this->getRenderer());
}
$this->columns[$column->getName()] = $column;
return $this;
} | php | public function addColumn(Column\Column $column)
{
// Join column to the table
$column->setTable($this);
// Add renderer to column if it didn't has one
if (!$column->hasRenderer()) {
$column->setRenderer($this->getRenderer());
}
$this->columns[$column->getName()] = $column;
return $this;
} | [
"public",
"function",
"addColumn",
"(",
"Column",
"\\",
"Column",
"$",
"column",
")",
"{",
"// Join column to the table",
"$",
"column",
"->",
"setTable",
"(",
"$",
"this",
")",
";",
"// Add renderer to column if it didn't has one",
"if",
"(",
"!",
"$",
"column",
"->",
"hasRenderer",
"(",
")",
")",
"{",
"$",
"column",
"->",
"setRenderer",
"(",
"$",
"this",
"->",
"getRenderer",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"columns",
"[",
"$",
"column",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"column",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a single column to the column container
@param Column\Column $column
@return $this | [
"Add",
"a",
"single",
"column",
"to",
"the",
"column",
"container"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L52-L65 |
16,452 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.getColumnByIndex | public function getColumnByIndex($index)
{
$keys = array_keys($this->columns);
if (empty($keys[$index]) || empty($column = $this->columns[$keys[$index]])) {
throw new \InvalidArgumentException('Table don\'t have a column index : ' . $index);
}
return $column;
} | php | public function getColumnByIndex($index)
{
$keys = array_keys($this->columns);
if (empty($keys[$index]) || empty($column = $this->columns[$keys[$index]])) {
throw new \InvalidArgumentException('Table don\'t have a column index : ' . $index);
}
return $column;
} | [
"public",
"function",
"getColumnByIndex",
"(",
"$",
"index",
")",
"{",
"$",
"keys",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"columns",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"keys",
"[",
"$",
"index",
"]",
")",
"||",
"empty",
"(",
"$",
"column",
"=",
"$",
"this",
"->",
"columns",
"[",
"$",
"keys",
"[",
"$",
"index",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Table don\\'t have a column index : '",
".",
"$",
"index",
")",
";",
"}",
"return",
"$",
"column",
";",
"}"
]
| Return the column from his index
@return Column\Column $column | [
"Return",
"the",
"column",
"from",
"his",
"index"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L126-L134 |
16,453 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addRemoteBoolean | public function addRemoteBoolean($name, $label = '', $function = null)
{
$c = new Column\RemoteBoolean($name, $label, $function);
$this->addColumn($c);
return $c;
} | php | public function addRemoteBoolean($name, $label = '', $function = null)
{
$c = new Column\RemoteBoolean($name, $label, $function);
$this->addColumn($c);
return $c;
} | [
"public",
"function",
"addRemoteBoolean",
"(",
"$",
"name",
",",
"$",
"label",
"=",
"''",
",",
"$",
"function",
"=",
"null",
")",
"{",
"$",
"c",
"=",
"new",
"Column",
"\\",
"RemoteBoolean",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"function",
")",
";",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
")",
";",
"return",
"$",
"c",
";",
"}"
]
| Add boolean switch
@param $name
@param string $label
@return \FrenchFrogs\Table\Column\RemoteBoolean | [
"Add",
"boolean",
"switch"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L268-L274 |
16,454 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addRemoteText | public function addRemoteText($name, $label = '', $function = null)
{
$c = new Column\RemoteText($name, $label, $function);
$this->addColumn($c);
return $c;
} | php | public function addRemoteText($name, $label = '', $function = null)
{
$c = new Column\RemoteText($name, $label, $function);
$this->addColumn($c);
return $c;
} | [
"public",
"function",
"addRemoteText",
"(",
"$",
"name",
",",
"$",
"label",
"=",
"''",
",",
"$",
"function",
"=",
"null",
")",
"{",
"$",
"c",
"=",
"new",
"Column",
"\\",
"RemoteText",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"function",
")",
";",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
")",
";",
"return",
"$",
"c",
";",
"}"
]
| Add remote text
@param $name
@param string $label
@return \FrenchFrogs\Table\Column\RemoteText | [
"Add",
"remote",
"text"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L284-L290 |
16,455 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addRemoteSelect | public function addRemoteSelect($name, $label = '', $index = null, $option = [], $function = null)
{
$c = new Column\RemoteSelect($name, $label, $index, $option, $function);
$this->addColumn($c);
return $c;
} | php | public function addRemoteSelect($name, $label = '', $index = null, $option = [], $function = null)
{
$c = new Column\RemoteSelect($name, $label, $index, $option, $function);
$this->addColumn($c);
return $c;
} | [
"public",
"function",
"addRemoteSelect",
"(",
"$",
"name",
",",
"$",
"label",
"=",
"''",
",",
"$",
"index",
"=",
"null",
",",
"$",
"option",
"=",
"[",
"]",
",",
"$",
"function",
"=",
"null",
")",
"{",
"$",
"c",
"=",
"new",
"Column",
"\\",
"RemoteSelect",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"index",
",",
"$",
"option",
",",
"$",
"function",
")",
";",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
")",
";",
"return",
"$",
"c",
";",
"}"
]
| Add remote select
@param $name
@param string $label
@return \FrenchFrogs\Table\Column\RemoteSelect | [
"Add",
"remote",
"select"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L299-L305 |
16,456 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addButton | public function addButton($name, $label = '%s', $link = '#', $binds = [], $attr = [] )
{
$c = new Column\Button($name, $label, $link, $binds, $attr);
$c->setOptionAsDefault();
$this->addColumn($c);
return $c;
} | php | public function addButton($name, $label = '%s', $link = '#', $binds = [], $attr = [] )
{
$c = new Column\Button($name, $label, $link, $binds, $attr);
$c->setOptionAsDefault();
$this->addColumn($c);
return $c;
} | [
"public",
"function",
"addButton",
"(",
"$",
"name",
",",
"$",
"label",
"=",
"'%s'",
",",
"$",
"link",
"=",
"'#'",
",",
"$",
"binds",
"=",
"[",
"]",
",",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"c",
"=",
"new",
"Column",
"\\",
"Button",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"link",
",",
"$",
"binds",
",",
"$",
"attr",
")",
";",
"$",
"c",
"->",
"setOptionAsDefault",
"(",
")",
";",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
")",
";",
"return",
"$",
"c",
";",
"}"
]
| Add as Button Column
@param $name
@param string $label
@param string $link
@param array $binds
@param array $attr
@return \FrenchFrogs\Table\Column\Button | [
"Add",
"as",
"Button",
"Column"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L372-L379 |
16,457 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addButtonEdit | public function addButtonEdit($link = '#', $binds = [], $is_remote = true, $method = 'post')
{
$c = new Column\Button(configurator()->get('button.edit.name'), configurator()->get('button.edit.label'), $link, $binds);
$c->setOptionAsPrimary();
$c->icon(configurator()->get('button.edit.icon'));
if ($is_remote) {
$c->enableRemote($method);
}
$this->addColumn($c);
return $c;
} | php | public function addButtonEdit($link = '#', $binds = [], $is_remote = true, $method = 'post')
{
$c = new Column\Button(configurator()->get('button.edit.name'), configurator()->get('button.edit.label'), $link, $binds);
$c->setOptionAsPrimary();
$c->icon(configurator()->get('button.edit.icon'));
if ($is_remote) {
$c->enableRemote($method);
}
$this->addColumn($c);
return $c;
} | [
"public",
"function",
"addButtonEdit",
"(",
"$",
"link",
"=",
"'#'",
",",
"$",
"binds",
"=",
"[",
"]",
",",
"$",
"is_remote",
"=",
"true",
",",
"$",
"method",
"=",
"'post'",
")",
"{",
"$",
"c",
"=",
"new",
"Column",
"\\",
"Button",
"(",
"configurator",
"(",
")",
"->",
"get",
"(",
"'button.edit.name'",
")",
",",
"configurator",
"(",
")",
"->",
"get",
"(",
"'button.edit.label'",
")",
",",
"$",
"link",
",",
"$",
"binds",
")",
";",
"$",
"c",
"->",
"setOptionAsPrimary",
"(",
")",
";",
"$",
"c",
"->",
"icon",
"(",
"configurator",
"(",
")",
"->",
"get",
"(",
"'button.edit.icon'",
")",
")",
";",
"if",
"(",
"$",
"is_remote",
")",
"{",
"$",
"c",
"->",
"enableRemote",
"(",
"$",
"method",
")",
";",
"}",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
")",
";",
"return",
"$",
"c",
";",
"}"
]
| Add default edit button
@param string $link
@param array $binds
@param array $attr
@return \FrenchFrogs\Table\Column\Button | [
"Add",
"default",
"edit",
"button"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L420-L433 |
16,458 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addButtonDelete | public function addButtonDelete($link = '#', $binds = [], $is_remote = true, $method = 'delete')
{
$c = new Column\Button(configurator()->get('button.delete.name'), configurator()->get('button.delete.label'), $link, $binds);
$c->setOptionAsDanger();
$c->icon(configurator()->get('button.delete.icon'));
if ($is_remote) {
$c->enableRemote($method);
}
$this->addColumn($c);
return $c;
} | php | public function addButtonDelete($link = '#', $binds = [], $is_remote = true, $method = 'delete')
{
$c = new Column\Button(configurator()->get('button.delete.name'), configurator()->get('button.delete.label'), $link, $binds);
$c->setOptionAsDanger();
$c->icon(configurator()->get('button.delete.icon'));
if ($is_remote) {
$c->enableRemote($method);
}
$this->addColumn($c);
return $c;
} | [
"public",
"function",
"addButtonDelete",
"(",
"$",
"link",
"=",
"'#'",
",",
"$",
"binds",
"=",
"[",
"]",
",",
"$",
"is_remote",
"=",
"true",
",",
"$",
"method",
"=",
"'delete'",
")",
"{",
"$",
"c",
"=",
"new",
"Column",
"\\",
"Button",
"(",
"configurator",
"(",
")",
"->",
"get",
"(",
"'button.delete.name'",
")",
",",
"configurator",
"(",
")",
"->",
"get",
"(",
"'button.delete.label'",
")",
",",
"$",
"link",
",",
"$",
"binds",
")",
";",
"$",
"c",
"->",
"setOptionAsDanger",
"(",
")",
";",
"$",
"c",
"->",
"icon",
"(",
"configurator",
"(",
")",
"->",
"get",
"(",
"'button.delete.icon'",
")",
")",
";",
"if",
"(",
"$",
"is_remote",
")",
"{",
"$",
"c",
"->",
"enableRemote",
"(",
"$",
"method",
")",
";",
"}",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
")",
";",
"return",
"$",
"c",
";",
"}"
]
| Add default delete button
@param string $link
@param array $binds
@param array $attr
@return \FrenchFrogs\Table\Column\Button | [
"Add",
"default",
"delete",
"button"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L443-L453 |
16,459 | FrenchFrogs/framework | src/Table/Table/Columns.php | Columns.addContainer | public function addContainer($name, $label = '', $attr = [])
{
$c = new Column\Container($name, $label, $attr);
$this->addColumn($c);
return $c;
} | php | public function addContainer($name, $label = '', $attr = [])
{
$c = new Column\Container($name, $label, $attr);
$this->addColumn($c);
return $c;
} | [
"public",
"function",
"addContainer",
"(",
"$",
"name",
",",
"$",
"label",
"=",
"''",
",",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"c",
"=",
"new",
"Column",
"\\",
"Container",
"(",
"$",
"name",
",",
"$",
"label",
",",
"$",
"attr",
")",
";",
"$",
"this",
"->",
"addColumn",
"(",
"$",
"c",
")",
";",
"return",
"$",
"c",
";",
"}"
]
| Add a container columns
@param $name
@param string $label
@param array $attr
@return \FrenchFrogs\Table\Column\Container | [
"Add",
"a",
"container",
"columns"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Columns.php#L465-L470 |
16,460 | jpuck/color-mixer | src/Mixer.php | Mixer.addColor | public function addColor($color)
{
if ( ! $color instanceof Color ) {
$color = new Color($color);
}
$this->colors []= $color;
} | php | public function addColor($color)
{
if ( ! $color instanceof Color ) {
$color = new Color($color);
}
$this->colors []= $color;
} | [
"public",
"function",
"addColor",
"(",
"$",
"color",
")",
"{",
"if",
"(",
"!",
"$",
"color",
"instanceof",
"Color",
")",
"{",
"$",
"color",
"=",
"new",
"Color",
"(",
"$",
"color",
")",
";",
"}",
"$",
"this",
"->",
"colors",
"[",
"]",
"=",
"$",
"color",
";",
"}"
]
| Adds a color to the Mixer.
@param mixed Color object or string
@return null | [
"Adds",
"a",
"color",
"to",
"the",
"Mixer",
"."
]
| cea01c3082a921a35e00ae0a287c795d9fd73ada | https://github.com/jpuck/color-mixer/blob/cea01c3082a921a35e00ae0a287c795d9fd73ada/src/Mixer.php#L28-L35 |
16,461 | jpuck/color-mixer | src/Mixer.php | Mixer.mix | public function mix() : Color
{
foreach ($this->colors as $color) {
$colors = $color->dec();
$reds []= $colors[0];
$greens[]= $colors[1];
$blues []= $colors[2];
}
$red = dechex( round(array_sum($reds) / count($reds) ) );
$green = dechex( round(array_sum($greens)/ count($greens)) );
$blue = dechex( round(array_sum($blues) / count($blues) ) );
// pad single-digit hexadecimals with leading zero
foreach ([&$red, &$green, &$blue] as &$color) {
if (strlen($color) === 1) {
$color = "0$color";
}
}
return new Color($red.$green.$blue);
} | php | public function mix() : Color
{
foreach ($this->colors as $color) {
$colors = $color->dec();
$reds []= $colors[0];
$greens[]= $colors[1];
$blues []= $colors[2];
}
$red = dechex( round(array_sum($reds) / count($reds) ) );
$green = dechex( round(array_sum($greens)/ count($greens)) );
$blue = dechex( round(array_sum($blues) / count($blues) ) );
// pad single-digit hexadecimals with leading zero
foreach ([&$red, &$green, &$blue] as &$color) {
if (strlen($color) === 1) {
$color = "0$color";
}
}
return new Color($red.$green.$blue);
} | [
"public",
"function",
"mix",
"(",
")",
":",
"Color",
"{",
"foreach",
"(",
"$",
"this",
"->",
"colors",
"as",
"$",
"color",
")",
"{",
"$",
"colors",
"=",
"$",
"color",
"->",
"dec",
"(",
")",
";",
"$",
"reds",
"[",
"]",
"=",
"$",
"colors",
"[",
"0",
"]",
";",
"$",
"greens",
"[",
"]",
"=",
"$",
"colors",
"[",
"1",
"]",
";",
"$",
"blues",
"[",
"]",
"=",
"$",
"colors",
"[",
"2",
"]",
";",
"}",
"$",
"red",
"=",
"dechex",
"(",
"round",
"(",
"array_sum",
"(",
"$",
"reds",
")",
"/",
"count",
"(",
"$",
"reds",
")",
")",
")",
";",
"$",
"green",
"=",
"dechex",
"(",
"round",
"(",
"array_sum",
"(",
"$",
"greens",
")",
"/",
"count",
"(",
"$",
"greens",
")",
")",
")",
";",
"$",
"blue",
"=",
"dechex",
"(",
"round",
"(",
"array_sum",
"(",
"$",
"blues",
")",
"/",
"count",
"(",
"$",
"blues",
")",
")",
")",
";",
"// pad single-digit hexadecimals with leading zero",
"foreach",
"(",
"[",
"&",
"$",
"red",
",",
"&",
"$",
"green",
",",
"&",
"$",
"blue",
"]",
"as",
"&",
"$",
"color",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"color",
")",
"===",
"1",
")",
"{",
"$",
"color",
"=",
"\"0$color\"",
";",
"}",
"}",
"return",
"new",
"Color",
"(",
"$",
"red",
".",
"$",
"green",
".",
"$",
"blue",
")",
";",
"}"
]
| Get the mixed color.
@return Color Returns a new Color object from the Mixer. | [
"Get",
"the",
"mixed",
"color",
"."
]
| cea01c3082a921a35e00ae0a287c795d9fd73ada | https://github.com/jpuck/color-mixer/blob/cea01c3082a921a35e00ae0a287c795d9fd73ada/src/Mixer.php#L52-L73 |
16,462 | FrenchFrogs/framework | src/Table/Table/Table.php | Table.isSourceQueryBuilder | public function isSourceQueryBuilder()
{
return is_object($this->getSource()) && get_class($this->getSource()) == \Illuminate\Database\Query\Builder::class;
} | php | public function isSourceQueryBuilder()
{
return is_object($this->getSource()) && get_class($this->getSource()) == \Illuminate\Database\Query\Builder::class;
} | [
"public",
"function",
"isSourceQueryBuilder",
"(",
")",
"{",
"return",
"is_object",
"(",
"$",
"this",
"->",
"getSource",
"(",
")",
")",
"&&",
"get_class",
"(",
"$",
"this",
"->",
"getSource",
"(",
")",
")",
"==",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Query",
"\\",
"Builder",
"::",
"class",
";",
"}"
]
| Return true if the source is an instance of \Illuminate\Database\Query\Builder
@return bool | [
"Return",
"true",
"if",
"the",
"source",
"is",
"an",
"instance",
"of",
"\\",
"Illuminate",
"\\",
"Database",
"\\",
"Query",
"\\",
"Builder"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Table.php#L261-L264 |
16,463 | FrenchFrogs/framework | src/Table/Table/Table.php | Table.extractJson | public function extractJson()
{
foreach($this->getRows() as &$row) {
foreach($this->getJsonFields() as $field) {
if (isset($row[$field])) {
$data = json_decode($row[$field], JSON_OBJECT_AS_ARRAY);
foreach((array) $data as $k => $v) {
$row[sprintf('_%s__%s', $field, $k)] = $v;
}
}
}
}
return $this;
} | php | public function extractJson()
{
foreach($this->getRows() as &$row) {
foreach($this->getJsonFields() as $field) {
if (isset($row[$field])) {
$data = json_decode($row[$field], JSON_OBJECT_AS_ARRAY);
foreach((array) $data as $k => $v) {
$row[sprintf('_%s__%s', $field, $k)] = $v;
}
}
}
}
return $this;
} | [
"public",
"function",
"extractJson",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRows",
"(",
")",
"as",
"&",
"$",
"row",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getJsonFields",
"(",
")",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"row",
"[",
"$",
"field",
"]",
")",
")",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"row",
"[",
"$",
"field",
"]",
",",
"JSON_OBJECT_AS_ARRAY",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"data",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"row",
"[",
"sprintf",
"(",
"'_%s__%s'",
",",
"$",
"field",
",",
"$",
"k",
")",
"]",
"=",
"$",
"v",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| Extract json data
@return $this | [
"Extract",
"json",
"data"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Table/Table/Table.php#L409-L425 |
16,464 | axelitus/php-base | src/BigFloat.php | BigFloat.isEven | public static function isEven($value, $scale = null)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be of type float (or string representing a big float)."
);
}
return static::equals(static::mod($value, 2.0, $scale), 0.0, $scale);
} | php | public static function isEven($value, $scale = null)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be of type float (or string representing a big float)."
);
}
return static::equals(static::mod($value, 2.0, $scale), 0.0, $scale);
} | [
"public",
"static",
"function",
"isEven",
"(",
"$",
"value",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be of type float (or string representing a big float).\"",
")",
";",
"}",
"return",
"static",
"::",
"equals",
"(",
"static",
"::",
"mod",
"(",
"$",
"value",
",",
"2.0",
",",
"$",
"scale",
")",
",",
"0.0",
",",
"$",
"scale",
")",
";",
"}"
]
| Tests if the given value is even.
@param float|string $value The value to test.
@param null|int $scale The scale to use for BCMath functions.
If null is given the value set by {@link bcscale()} is used.
@throws \InvalidArgumentException
@return bool Returns true if the given value is even, false otherwise. | [
"Tests",
"if",
"the",
"given",
"value",
"is",
"even",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigFloat.php#L53-L62 |
16,465 | axelitus/php-base | src/BigFloat.php | BigFloat.isOdd | public static function isOdd($value, $scale = null)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be of type float (or string representing a big float)."
);
}
return static::equals(static::abs(static::mod($value, 2.0, $scale)), 1.0, $scale);
} | php | public static function isOdd($value, $scale = null)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be of type float (or string representing a big float)."
);
}
return static::equals(static::abs(static::mod($value, 2.0, $scale)), 1.0, $scale);
} | [
"public",
"static",
"function",
"isOdd",
"(",
"$",
"value",
",",
"$",
"scale",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be of type float (or string representing a big float).\"",
")",
";",
"}",
"return",
"static",
"::",
"equals",
"(",
"static",
"::",
"abs",
"(",
"static",
"::",
"mod",
"(",
"$",
"value",
",",
"2.0",
",",
"$",
"scale",
")",
")",
",",
"1.0",
",",
"$",
"scale",
")",
";",
"}"
]
| Tests if the given value is odd.
@param float|string $value The value to test.
@param null|int $scale The scale to use for BCMath functions.
If null is given the value set by {@link bcscale()} is used.
@throws \InvalidArgumentException
@return bool Returns true if the given value is odd, false otherwise. | [
"Tests",
"if",
"the",
"given",
"value",
"is",
"odd",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigFloat.php#L74-L83 |
16,466 | axelitus/php-base | src/BigFloat.php | BigFloat.inRange | public static function inRange($value, $lower, $upper, $lowerExclusive = false, $upperExclusive = false)
{
if (!static::is($value) || !static::is($lower) || !static::is($upper)) {
throw new \InvalidArgumentException(
"The \$value, \$lower and \$upper parameters must be of type float"
. " (or string representing a big float)."
);
}
$lowerLimit = min($lower, $upper);
if (!(($lowerExclusive) ? $lowerLimit < $value : $lowerLimit <= $value)) {
return false;
}
$upperLimit = max($lower, $upper);
if (!(($upperExclusive) ? $upperLimit > $value : $upperLimit >= $value)) {
return false;
}
return true;
} | php | public static function inRange($value, $lower, $upper, $lowerExclusive = false, $upperExclusive = false)
{
if (!static::is($value) || !static::is($lower) || !static::is($upper)) {
throw new \InvalidArgumentException(
"The \$value, \$lower and \$upper parameters must be of type float"
. " (or string representing a big float)."
);
}
$lowerLimit = min($lower, $upper);
if (!(($lowerExclusive) ? $lowerLimit < $value : $lowerLimit <= $value)) {
return false;
}
$upperLimit = max($lower, $upper);
if (!(($upperExclusive) ? $upperLimit > $value : $upperLimit >= $value)) {
return false;
}
return true;
} | [
"public",
"static",
"function",
"inRange",
"(",
"$",
"value",
",",
"$",
"lower",
",",
"$",
"upper",
",",
"$",
"lowerExclusive",
"=",
"false",
",",
"$",
"upperExclusive",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"value",
")",
"||",
"!",
"static",
"::",
"is",
"(",
"$",
"lower",
")",
"||",
"!",
"static",
"::",
"is",
"(",
"$",
"upper",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value, \\$lower and \\$upper parameters must be of type float\"",
".",
"\" (or string representing a big float).\"",
")",
";",
"}",
"$",
"lowerLimit",
"=",
"min",
"(",
"$",
"lower",
",",
"$",
"upper",
")",
";",
"if",
"(",
"!",
"(",
"(",
"$",
"lowerExclusive",
")",
"?",
"$",
"lowerLimit",
"<",
"$",
"value",
":",
"$",
"lowerLimit",
"<=",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"upperLimit",
"=",
"max",
"(",
"$",
"lower",
",",
"$",
"upper",
")",
";",
"if",
"(",
"!",
"(",
"(",
"$",
"upperExclusive",
")",
"?",
"$",
"upperLimit",
">",
"$",
"value",
":",
"$",
"upperLimit",
">=",
"$",
"value",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Tests if an integer is in a range.
Tests if a value is in a range. The function will correct the limits if inverted. The tested range
can be set to have its lower and upper limits inclusive (bounds closed) or exclusive (bounds opened) using
the $lowerExclusive and $upperExclusive parameters (all possible variations: ]a,b[ -or- ]a,b] -or- [a,b[
-or- [a,b]).
@param float|string $value The value to test in range.
@param float|string $lower The range's lower limit.
@param float|string $upper The range's upper limit.
@param bool $lowerExclusive Whether the lower bound is exclusive.
@param bool $upperExclusive Whether the upper bound is exclusive.
@return bool Whether the value is in the given range given the bounds configurations.
@throws \InvalidArgumentException
@SuppressWarnings(PHPMD.BooleanArgumentFlag) | [
"Tests",
"if",
"an",
"integer",
"is",
"in",
"a",
"range",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigFloat.php#L178-L198 |
16,467 | axelitus/php-base | src/BigFloat.php | BigFloat.abs | public static function abs($float)
{
if (!static::is($float)) {
throw new \InvalidArgumentException(
"The \$float parameter must be of type float (or string representing a big float)."
);
}
if (Float::is($float)) {
return Float::abs($float);
} else {
return Str::replace($float, '-', '');
}
} | php | public static function abs($float)
{
if (!static::is($float)) {
throw new \InvalidArgumentException(
"The \$float parameter must be of type float (or string representing a big float)."
);
}
if (Float::is($float)) {
return Float::abs($float);
} else {
return Str::replace($float, '-', '');
}
} | [
"public",
"static",
"function",
"abs",
"(",
"$",
"float",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"float",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$float parameter must be of type float (or string representing a big float).\"",
")",
";",
"}",
"if",
"(",
"Float",
"::",
"is",
"(",
"$",
"float",
")",
")",
"{",
"return",
"Float",
"::",
"abs",
"(",
"$",
"float",
")",
";",
"}",
"else",
"{",
"return",
"Str",
"::",
"replace",
"(",
"$",
"float",
",",
"'-'",
",",
"''",
")",
";",
"}",
"}"
]
| Gets the absolute value of the given float.
@param int|string $float The number to get the absolute value of.
@return int|string Returns the absolute value of the given float. | [
"Gets",
"the",
"absolute",
"value",
"of",
"the",
"given",
"float",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigFloat.php#L245-L258 |
16,468 | phramework/jsonapi | src/Controller/Base.php | Base.viewData | public static function viewData(
$data,
$links = null,
$meta = null,
$included = null
) {
$viewParameters = new \stdClass();
if ($links) {
$viewParameters->links = $links;
}
$viewParameters->data = $data;
if ($included !== null) {
$viewParameters->included = $included;
}
if ($meta) {
$viewParameters->meta = $meta;
}
\Phramework\Phramework::view($viewParameters);
unset($viewParameters);
return true;
} | php | public static function viewData(
$data,
$links = null,
$meta = null,
$included = null
) {
$viewParameters = new \stdClass();
if ($links) {
$viewParameters->links = $links;
}
$viewParameters->data = $data;
if ($included !== null) {
$viewParameters->included = $included;
}
if ($meta) {
$viewParameters->meta = $meta;
}
\Phramework\Phramework::view($viewParameters);
unset($viewParameters);
return true;
} | [
"public",
"static",
"function",
"viewData",
"(",
"$",
"data",
",",
"$",
"links",
"=",
"null",
",",
"$",
"meta",
"=",
"null",
",",
"$",
"included",
"=",
"null",
")",
"{",
"$",
"viewParameters",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"if",
"(",
"$",
"links",
")",
"{",
"$",
"viewParameters",
"->",
"links",
"=",
"$",
"links",
";",
"}",
"$",
"viewParameters",
"->",
"data",
"=",
"$",
"data",
";",
"if",
"(",
"$",
"included",
"!==",
"null",
")",
"{",
"$",
"viewParameters",
"->",
"included",
"=",
"$",
"included",
";",
"}",
"if",
"(",
"$",
"meta",
")",
"{",
"$",
"viewParameters",
"->",
"meta",
"=",
"$",
"meta",
";",
"}",
"\\",
"Phramework",
"\\",
"Phramework",
"::",
"view",
"(",
"$",
"viewParameters",
")",
";",
"unset",
"(",
"$",
"viewParameters",
")",
";",
"return",
"true",
";",
"}"
]
| View JSONAPI data
@param object $data
@uses \Phramework\Viewers\JSONAPI
@return boolean | [
"View",
"JSONAPI",
"data"
]
| af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726 | https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L85-L112 |
16,469 | phramework/jsonapi | src/Controller/Base.php | Base.getRequestInclude | protected static function getRequestInclude($parameters, $modelClass = null)
{
//work with arrays
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
$include = [];
if ($modelClass !== null) {
//Add additional include by default from resource model's relationships
foreach ($modelClass::getRelationships() as $relationshipKey => $relationship) {
if (($relationship->flags & Relationship::FLAG_INCLUDE_BY_DEFAULT) != 0) {
$include[] = $include;
}
}
}
if (!isset($parameters->include) || empty($parameters->include)) {
return $include;
}
//split parameter using , (for multiple values)
foreach (explode(',', $parameters->include) as $i) {
$include[] = trim($i);
}
return array_unique($include);
} | php | protected static function getRequestInclude($parameters, $modelClass = null)
{
//work with arrays
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
$include = [];
if ($modelClass !== null) {
//Add additional include by default from resource model's relationships
foreach ($modelClass::getRelationships() as $relationshipKey => $relationship) {
if (($relationship->flags & Relationship::FLAG_INCLUDE_BY_DEFAULT) != 0) {
$include[] = $include;
}
}
}
if (!isset($parameters->include) || empty($parameters->include)) {
return $include;
}
//split parameter using , (for multiple values)
foreach (explode(',', $parameters->include) as $i) {
$include[] = trim($i);
}
return array_unique($include);
} | [
"protected",
"static",
"function",
"getRequestInclude",
"(",
"$",
"parameters",
",",
"$",
"modelClass",
"=",
"null",
")",
"{",
"//work with arrays",
"if",
"(",
"!",
"is_object",
"(",
"$",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"$",
"include",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"modelClass",
"!==",
"null",
")",
"{",
"//Add additional include by default from resource model's relationships",
"foreach",
"(",
"$",
"modelClass",
"::",
"getRelationships",
"(",
")",
"as",
"$",
"relationshipKey",
"=>",
"$",
"relationship",
")",
"{",
"if",
"(",
"(",
"$",
"relationship",
"->",
"flags",
"&",
"Relationship",
"::",
"FLAG_INCLUDE_BY_DEFAULT",
")",
"!=",
"0",
")",
"{",
"$",
"include",
"[",
"]",
"=",
"$",
"include",
";",
"}",
"}",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"parameters",
"->",
"include",
")",
"||",
"empty",
"(",
"$",
"parameters",
"->",
"include",
")",
")",
"{",
"return",
"$",
"include",
";",
"}",
"//split parameter using , (for multiple values)",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"parameters",
"->",
"include",
")",
"as",
"$",
"i",
")",
"{",
"$",
"include",
"[",
"]",
"=",
"trim",
"(",
"$",
"i",
")",
";",
"}",
"return",
"array_unique",
"(",
"$",
"include",
")",
";",
"}"
]
| Extract included related resources from parameters
@param object $parameters Request parameters
@param string|null $modelClass If not null, will add additional include by default from resource model's relationships
@return string[] | [
"Extract",
"included",
"related",
"resources",
"from",
"parameters"
]
| af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726 | https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L120-L148 |
16,470 | phramework/jsonapi | src/Controller/Base.php | Base.getRequestData | protected static function getRequestData($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
return $parameters->data;
} | php | protected static function getRequestData($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
return $parameters->data;
} | [
"protected",
"static",
"function",
"getRequestData",
"(",
"$",
"parameters",
")",
"{",
"//work with objects",
"if",
"(",
"!",
"is_object",
"(",
"$",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"//Require data",
"Request",
"::",
"requireParameters",
"(",
"$",
"parameters",
",",
"[",
"'data'",
"]",
")",
";",
"return",
"$",
"parameters",
"->",
"data",
";",
"}"
]
| Get request primary data
@param object $parameters Request parameters
@uses Request::requireParameters
@return object|object[] | [
"Get",
"request",
"primary",
"data"
]
| af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726 | https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L196-L207 |
16,471 | phramework/jsonapi | src/Controller/Base.php | Base.getRequestRelationships | protected static function getRequestRelationships($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
//Require data['relationships']
if (isset($parameters->data->relationships)) {
return (object) $parameters->data->relationships;
} else {
return new \stdClass();
}
} | php | protected static function getRequestRelationships($parameters)
{
//work with objects
if (!is_object($parameters) && is_array($parameters)) {
$parameters = (object) $parameters;
}
//Require data
Request::requireParameters($parameters, ['data']);
//Require data['relationships']
if (isset($parameters->data->relationships)) {
return (object) $parameters->data->relationships;
} else {
return new \stdClass();
}
} | [
"protected",
"static",
"function",
"getRequestRelationships",
"(",
"$",
"parameters",
")",
"{",
"//work with objects",
"if",
"(",
"!",
"is_object",
"(",
"$",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"parameters",
")",
")",
"{",
"$",
"parameters",
"=",
"(",
"object",
")",
"$",
"parameters",
";",
"}",
"//Require data",
"Request",
"::",
"requireParameters",
"(",
"$",
"parameters",
",",
"[",
"'data'",
"]",
")",
";",
"//Require data['relationships']",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"->",
"data",
"->",
"relationships",
")",
")",
"{",
"return",
"(",
"object",
")",
"$",
"parameters",
"->",
"data",
"->",
"relationships",
";",
"}",
"else",
"{",
"return",
"new",
"\\",
"stdClass",
"(",
")",
";",
"}",
"}"
]
| Get request relationships if any attributes.
@param object $parameters Request parameters
@return object | [
"Get",
"request",
"relationships",
"if",
"any",
"attributes",
"."
]
| af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726 | https://github.com/phramework/jsonapi/blob/af20882a8b6f6e5be9c8e09e5b87f6c23a4b0726/src/Controller/Base.php#L214-L230 |
16,472 | sasedev/composer-plugin-filecopier | src/Sasedev/Composer/Plugin/Filescopier/Processor.php | Processor.startsWith | private function startsWith($string, $prefix) {
return $prefix === "" || strrpos($string, $prefix, -strlen($string)) !== FALSE;
} | php | private function startsWith($string, $prefix) {
return $prefix === "" || strrpos($string, $prefix, -strlen($string)) !== FALSE;
} | [
"private",
"function",
"startsWith",
"(",
"$",
"string",
",",
"$",
"prefix",
")",
"{",
"return",
"$",
"prefix",
"===",
"\"\"",
"||",
"strrpos",
"(",
"$",
"string",
",",
"$",
"prefix",
",",
"-",
"strlen",
"(",
"$",
"string",
")",
")",
"!==",
"FALSE",
";",
"}"
]
| Check if a string starts with a prefix
@param string $string
@param string $prefix
@return boolean | [
"Check",
"if",
"a",
"string",
"starts",
"with",
"a",
"prefix"
]
| 0cb2430d9a95b3955e05a8fe43054751c08b9f07 | https://github.com/sasedev/composer-plugin-filecopier/blob/0cb2430d9a95b3955e05a8fe43054751c08b9f07/src/Sasedev/Composer/Plugin/Filescopier/Processor.php#L189-L191 |
16,473 | sasedev/composer-plugin-filecopier | src/Sasedev/Composer/Plugin/Filescopier/Processor.php | Processor.endswith | private function endswith($string, $suffix)
{
$strlen = strlen($string);
$testlen = strlen($suffix);
if ($testlen > $strlen) {
return false;
}
return substr_compare($string, $suffix, -$testlen) === 0;
} | php | private function endswith($string, $suffix)
{
$strlen = strlen($string);
$testlen = strlen($suffix);
if ($testlen > $strlen) {
return false;
}
return substr_compare($string, $suffix, -$testlen) === 0;
} | [
"private",
"function",
"endswith",
"(",
"$",
"string",
",",
"$",
"suffix",
")",
"{",
"$",
"strlen",
"=",
"strlen",
"(",
"$",
"string",
")",
";",
"$",
"testlen",
"=",
"strlen",
"(",
"$",
"suffix",
")",
";",
"if",
"(",
"$",
"testlen",
">",
"$",
"strlen",
")",
"{",
"return",
"false",
";",
"}",
"return",
"substr_compare",
"(",
"$",
"string",
",",
"$",
"suffix",
",",
"-",
"$",
"testlen",
")",
"===",
"0",
";",
"}"
]
| Check if a string ends with a suffix
@param string $string
@param string $suffix
@return boolean | [
"Check",
"if",
"a",
"string",
"ends",
"with",
"a",
"suffix"
]
| 0cb2430d9a95b3955e05a8fe43054751c08b9f07 | https://github.com/sasedev/composer-plugin-filecopier/blob/0cb2430d9a95b3955e05a8fe43054751c08b9f07/src/Sasedev/Composer/Plugin/Filescopier/Processor.php#L201-L210 |
16,474 | harp-orm/query | src/Compiler/Delete.php | Delete.render | public static function render(Query\Delete $query)
{
return Compiler::withDb($query->getDb(), function () use ($query) {
return Compiler::expression(array(
'DELETE',
$query->getType(),
Aliased::combine($query->getTable()),
Compiler::word('FROM', Aliased::combine($query->getFrom())),
Join::combine($query->getJoin()),
Compiler::word('WHERE', Condition::combine($query->getWhere())),
Compiler::word('ORDER BY', Direction::combine($query->getOrder())),
Compiler::word('LIMIT', $query->getLimit()),
));
});
} | php | public static function render(Query\Delete $query)
{
return Compiler::withDb($query->getDb(), function () use ($query) {
return Compiler::expression(array(
'DELETE',
$query->getType(),
Aliased::combine($query->getTable()),
Compiler::word('FROM', Aliased::combine($query->getFrom())),
Join::combine($query->getJoin()),
Compiler::word('WHERE', Condition::combine($query->getWhere())),
Compiler::word('ORDER BY', Direction::combine($query->getOrder())),
Compiler::word('LIMIT', $query->getLimit()),
));
});
} | [
"public",
"static",
"function",
"render",
"(",
"Query",
"\\",
"Delete",
"$",
"query",
")",
"{",
"return",
"Compiler",
"::",
"withDb",
"(",
"$",
"query",
"->",
"getDb",
"(",
")",
",",
"function",
"(",
")",
"use",
"(",
"$",
"query",
")",
"{",
"return",
"Compiler",
"::",
"expression",
"(",
"array",
"(",
"'DELETE'",
",",
"$",
"query",
"->",
"getType",
"(",
")",
",",
"Aliased",
"::",
"combine",
"(",
"$",
"query",
"->",
"getTable",
"(",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'FROM'",
",",
"Aliased",
"::",
"combine",
"(",
"$",
"query",
"->",
"getFrom",
"(",
")",
")",
")",
",",
"Join",
"::",
"combine",
"(",
"$",
"query",
"->",
"getJoin",
"(",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'WHERE'",
",",
"Condition",
"::",
"combine",
"(",
"$",
"query",
"->",
"getWhere",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'ORDER BY'",
",",
"Direction",
"::",
"combine",
"(",
"$",
"query",
"->",
"getOrder",
"(",
")",
")",
")",
",",
"Compiler",
"::",
"word",
"(",
"'LIMIT'",
",",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
",",
")",
")",
";",
"}",
")",
";",
"}"
]
| Render a Delete object
@param Query\Delete $query
@return string | [
"Render",
"a",
"Delete",
"object"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Delete.php#L19-L33 |
16,475 | darkwebdesign/doctrine-unit-testing | src/Mocks/CacheRegionMock.php | CacheRegionMock.getReturn | private function getReturn($method, $default)
{
if (isset($this->returns[$method]) && ! empty($this->returns[$method])) {
return array_shift($this->returns[$method]);
}
return $default;
} | php | private function getReturn($method, $default)
{
if (isset($this->returns[$method]) && ! empty($this->returns[$method])) {
return array_shift($this->returns[$method]);
}
return $default;
} | [
"private",
"function",
"getReturn",
"(",
"$",
"method",
",",
"$",
"default",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"returns",
"[",
"$",
"method",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"this",
"->",
"returns",
"[",
"$",
"method",
"]",
")",
")",
"{",
"return",
"array_shift",
"(",
"$",
"this",
"->",
"returns",
"[",
"$",
"method",
"]",
")",
";",
"}",
"return",
"$",
"default",
";",
"}"
]
| Dequeue a value for a specific method invocation
@param string $method
@param mixed $default
@return mixed | [
"Dequeue",
"a",
"value",
"for",
"a",
"specific",
"method",
"invocation"
]
| 0daf50359563bc0679925e573a7105d6cd57168a | https://github.com/darkwebdesign/doctrine-unit-testing/blob/0daf50359563bc0679925e573a7105d6cd57168a/src/Mocks/CacheRegionMock.php#L39-L46 |
16,476 | bestit/commercetools-order-export-bundle | src/DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$builder = new TreeBuilder();
$rootNode = $builder->root('best_it_ct_order_export');
$rootNode
->children()
->arrayNode('commercetools_client')
->isRequired()
->children()
->scalarNode('id')->cannotBeEmpty()->isRequired()->end()
->scalarNode('secret')->cannotBeEmpty()->isRequired()->end()
->scalarNode('project')->cannotBeEmpty()->isRequired()->end()
->scalarNode('scope')->cannotBeEmpty()->isRequired()->end()
->end()
->end()
->scalarNode('filesystem')
->info('Please provide the service id for your flysystem file system.')
->isRequired()
->end()
->scalarNode('logger')
->info('Please provide the service id for your logging service.')
->defaultValue('logger')
->end()
->arrayNode('orders')
->children()
->booleanNode('with_pagination')
->defaultValue(true)
->info(
'Should we use a paginated list of orders (or is the result list changing by "itself")?'
)
->end()
->arrayNode('default_where')
->info(
'Add where clauses for orders: ' .
'https://dev.commercetools.com/http-api-projects-orders.html#query-orders'
)
->prototype('scalar')->end()
->end()
->scalarNode('file_template')
->info('Which template is used for the export of a single order?')
->defaultValue('detail.xml.twig')
->end()
->scalarNode('name_scheme')
->defaultValue('order_{{id}}_{{YmdHis}}.xml')
->info(
'Provide an order field name or a format string for the date function enclosed ' .
'with {{ and }}.'
)
->end()
->end()
->end();
return $builder;
} | php | public function getConfigTreeBuilder()
{
$builder = new TreeBuilder();
$rootNode = $builder->root('best_it_ct_order_export');
$rootNode
->children()
->arrayNode('commercetools_client')
->isRequired()
->children()
->scalarNode('id')->cannotBeEmpty()->isRequired()->end()
->scalarNode('secret')->cannotBeEmpty()->isRequired()->end()
->scalarNode('project')->cannotBeEmpty()->isRequired()->end()
->scalarNode('scope')->cannotBeEmpty()->isRequired()->end()
->end()
->end()
->scalarNode('filesystem')
->info('Please provide the service id for your flysystem file system.')
->isRequired()
->end()
->scalarNode('logger')
->info('Please provide the service id for your logging service.')
->defaultValue('logger')
->end()
->arrayNode('orders')
->children()
->booleanNode('with_pagination')
->defaultValue(true)
->info(
'Should we use a paginated list of orders (or is the result list changing by "itself")?'
)
->end()
->arrayNode('default_where')
->info(
'Add where clauses for orders: ' .
'https://dev.commercetools.com/http-api-projects-orders.html#query-orders'
)
->prototype('scalar')->end()
->end()
->scalarNode('file_template')
->info('Which template is used for the export of a single order?')
->defaultValue('detail.xml.twig')
->end()
->scalarNode('name_scheme')
->defaultValue('order_{{id}}_{{YmdHis}}.xml')
->info(
'Provide an order field name or a format string for the date function enclosed ' .
'with {{ and }}.'
)
->end()
->end()
->end();
return $builder;
} | [
"public",
"function",
"getConfigTreeBuilder",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"rootNode",
"=",
"$",
"builder",
"->",
"root",
"(",
"'best_it_ct_order_export'",
")",
";",
"$",
"rootNode",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'commercetools_client'",
")",
"->",
"isRequired",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'id'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'secret'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'project'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'scope'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'filesystem'",
")",
"->",
"info",
"(",
"'Please provide the service id for your flysystem file system.'",
")",
"->",
"isRequired",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'logger'",
")",
"->",
"info",
"(",
"'Please provide the service id for your logging service.'",
")",
"->",
"defaultValue",
"(",
"'logger'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'orders'",
")",
"->",
"children",
"(",
")",
"->",
"booleanNode",
"(",
"'with_pagination'",
")",
"->",
"defaultValue",
"(",
"true",
")",
"->",
"info",
"(",
"'Should we use a paginated list of orders (or is the result list changing by \"itself\")?'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'default_where'",
")",
"->",
"info",
"(",
"'Add where clauses for orders: '",
".",
"'https://dev.commercetools.com/http-api-projects-orders.html#query-orders'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'file_template'",
")",
"->",
"info",
"(",
"'Which template is used for the export of a single order?'",
")",
"->",
"defaultValue",
"(",
"'detail.xml.twig'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'name_scheme'",
")",
"->",
"defaultValue",
"(",
"'order_{{id}}_{{YmdHis}}.xml'",
")",
"->",
"info",
"(",
"'Provide an order field name or a format string for the date function enclosed '",
".",
"'with {{ and }}.'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"builder",
";",
"}"
]
| Parses the config.
@return TreeBuilder | [
"Parses",
"the",
"config",
"."
]
| 44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845 | https://github.com/bestit/commercetools-order-export-bundle/blob/44bd0dedff6edab5ecf5803dcf6d24ffe0dbf845/src/DependencyInjection/Configuration.php#L21-L76 |
16,477 | Atlantic18/CoralCoreBundle | Service/Request/Request.php | Request.isCacheable | private function isCacheable(RequestHandleInterface $handle)
{
if(null === $this->cache)
{
return false;
}
if($handle->getMethod() != self::GET)
{
return false;
}
return true;
} | php | private function isCacheable(RequestHandleInterface $handle)
{
if(null === $this->cache)
{
return false;
}
if($handle->getMethod() != self::GET)
{
return false;
}
return true;
} | [
"private",
"function",
"isCacheable",
"(",
"RequestHandleInterface",
"$",
"handle",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"cache",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"handle",
"->",
"getMethod",
"(",
")",
"!=",
"self",
"::",
"GET",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
]
| Returns true if handle is possible to be cached
@param RequestHandleInterface $handle Request handle
@return boolean True if can be cached | [
"Returns",
"true",
"if",
"handle",
"is",
"possible",
"to",
"be",
"cached"
]
| 7d74ffaf51046ad13cbfc2b0b69d656a499f38ab | https://github.com/Atlantic18/CoralCoreBundle/blob/7d74ffaf51046ad13cbfc2b0b69d656a499f38ab/Service/Request/Request.php#L49-L61 |
16,478 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.onGet | public function onGet(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'GET'));
} | php | public function onGet(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'GET'));
} | [
"public",
"function",
"onGet",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'GET'",
")",
")",
";",
"}"
]
| reply with given class or callable for GET request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute | [
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"GET",
"request",
"on",
"given",
"path"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L88-L91 |
16,479 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.passThroughOnGet | public function passThroughOnGet(
string $path = '/[a-zA-Z0-9-_]+.html$',
$target = HtmlFilePassThrough::class
): ConfigurableRoute {
return $this->onGet($path, $target);
} | php | public function passThroughOnGet(
string $path = '/[a-zA-Z0-9-_]+.html$',
$target = HtmlFilePassThrough::class
): ConfigurableRoute {
return $this->onGet($path, $target);
} | [
"public",
"function",
"passThroughOnGet",
"(",
"string",
"$",
"path",
"=",
"'/[a-zA-Z0-9-_]+.html$'",
",",
"$",
"target",
"=",
"HtmlFilePassThrough",
"::",
"class",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"onGet",
"(",
"$",
"path",
",",
"$",
"target",
")",
";",
"}"
]
| reply with HTML file stored in pages path
@param string $path optional path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target optional code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute
@since 4.0.0 | [
"reply",
"with",
"HTML",
"file",
"stored",
"in",
"pages",
"path"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L101-L106 |
16,480 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.apiIndexOnGet | public function apiIndexOnGet(string $path): ConfigurableRoute
{
return $this->onGet($path, new Index($this->routes, $this->mimeTypes));
} | php | public function apiIndexOnGet(string $path): ConfigurableRoute
{
return $this->onGet($path, new Index($this->routes, $this->mimeTypes));
} | [
"public",
"function",
"apiIndexOnGet",
"(",
"string",
"$",
"path",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"onGet",
"(",
"$",
"path",
",",
"new",
"Index",
"(",
"$",
"this",
"->",
"routes",
",",
"$",
"this",
"->",
"mimeTypes",
")",
")",
";",
"}"
]
| reply with API index overview
@param string $path
@return \stubbles\webapp\routing\ConfigurableRoute
@since 6.1.0 | [
"reply",
"with",
"API",
"index",
"overview"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L115-L118 |
16,481 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.redirectOnGet | public function redirectOnGet(string $path, $target, int $statusCode = 302): ConfigurableRoute
{
return $this->onGet($path, new Redirect($target, $statusCode));
} | php | public function redirectOnGet(string $path, $target, int $statusCode = 302): ConfigurableRoute
{
return $this->onGet($path, new Redirect($target, $statusCode));
} | [
"public",
"function",
"redirectOnGet",
"(",
"string",
"$",
"path",
",",
"$",
"target",
",",
"int",
"$",
"statusCode",
"=",
"302",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"onGet",
"(",
"$",
"path",
",",
"new",
"Redirect",
"(",
"$",
"target",
",",
"$",
"statusCode",
")",
")",
";",
"}"
]
| reply with a redirect
If the given $target is a string it is used in different ways:
- if the string starts with http it is assumed to be a complete uri
- else it is assumed to be a path within the application
@param string $path path this route is applicable for
@param string|\stubbles\peer\http\HttpUri $target path or uri to redirect to
@param int $statusCode optional status code for redirect, defaults to 302
@return \stubbles\webapp\routing\ConfigurableRoute
@since 6.1.0 | [
"reply",
"with",
"a",
"redirect"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L133-L136 |
16,482 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.onHead | public function onHead(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'HEAD'));
} | php | public function onHead(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'HEAD'));
} | [
"public",
"function",
"onHead",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'HEAD'",
")",
")",
";",
"}"
]
| reply with given class or callable for HEAD request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute | [
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"HEAD",
"request",
"on",
"given",
"path"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L145-L148 |
16,483 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.onPost | public function onPost(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'POST'));
} | php | public function onPost(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'POST'));
} | [
"public",
"function",
"onPost",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'POST'",
")",
")",
";",
"}"
]
| reply with given class or callable for POST request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute | [
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"POST",
"request",
"on",
"given",
"path"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L157-L160 |
16,484 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.onPut | public function onPut(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'PUT'));
} | php | public function onPut(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'PUT'));
} | [
"public",
"function",
"onPut",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'PUT'",
")",
")",
";",
"}"
]
| reply with given class or callable for PUT request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute | [
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"PUT",
"request",
"on",
"given",
"path"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L169-L172 |
16,485 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.onDelete | public function onDelete(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'DELETE'));
} | php | public function onDelete(string $path, $target): ConfigurableRoute
{
return $this->addRoute(new Route($path, $target, 'DELETE'));
} | [
"public",
"function",
"onDelete",
"(",
"string",
"$",
"path",
",",
"$",
"target",
")",
":",
"ConfigurableRoute",
"{",
"return",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"path",
",",
"$",
"target",
",",
"'DELETE'",
")",
")",
";",
"}"
]
| reply with given class or callable for DELETE request on given path
@param string $path path this route is applicable for
@param string|callable|\stubbles\webapp\Target $target code to be executed when the route is active
@return \stubbles\webapp\routing\ConfigurableRoute | [
"reply",
"with",
"given",
"class",
"or",
"callable",
"for",
"DELETE",
"request",
"on",
"given",
"path"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L181-L184 |
16,486 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.findResource | public function findResource($uri, string $requestMethod = null): UriResource
{
$calledUri = CalledUri::castFrom($uri, $requestMethod);
$matchingRoutes = $this->routes->match($calledUri);
if ($matchingRoutes->hasExactMatch()) {
return $this->handleMatchingRoute(
$calledUri,
$matchingRoutes->exactMatch()
);
}
if ($matchingRoutes->exist()) {
return $this->handleNonMethodMatchingRoutes(
$calledUri,
$matchingRoutes
);
}
return new NotFound(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes()
);
} | php | public function findResource($uri, string $requestMethod = null): UriResource
{
$calledUri = CalledUri::castFrom($uri, $requestMethod);
$matchingRoutes = $this->routes->match($calledUri);
if ($matchingRoutes->hasExactMatch()) {
return $this->handleMatchingRoute(
$calledUri,
$matchingRoutes->exactMatch()
);
}
if ($matchingRoutes->exist()) {
return $this->handleNonMethodMatchingRoutes(
$calledUri,
$matchingRoutes
);
}
return new NotFound(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes()
);
} | [
"public",
"function",
"findResource",
"(",
"$",
"uri",
",",
"string",
"$",
"requestMethod",
"=",
"null",
")",
":",
"UriResource",
"{",
"$",
"calledUri",
"=",
"CalledUri",
"::",
"castFrom",
"(",
"$",
"uri",
",",
"$",
"requestMethod",
")",
";",
"$",
"matchingRoutes",
"=",
"$",
"this",
"->",
"routes",
"->",
"match",
"(",
"$",
"calledUri",
")",
";",
"if",
"(",
"$",
"matchingRoutes",
"->",
"hasExactMatch",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handleMatchingRoute",
"(",
"$",
"calledUri",
",",
"$",
"matchingRoutes",
"->",
"exactMatch",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"matchingRoutes",
"->",
"exist",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"handleNonMethodMatchingRoutes",
"(",
"$",
"calledUri",
",",
"$",
"matchingRoutes",
")",
";",
"}",
"return",
"new",
"NotFound",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
")",
")",
";",
"}"
]
| returns resource which is applicable for given request
@param string|\stubbles\webapp\routing\CalledUri $uri actually called uri
@param string $requestMethod optional when $calledUri is an instance of stubbles\webapp\routing\CalledUri
@return \stubbles\webapp\routing\UriResource | [
"returns",
"resource",
"which",
"is",
"applicable",
"for",
"given",
"request"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L221-L245 |
16,487 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.handleMatchingRoute | private function handleMatchingRoute(CalledUri $calledUri, Route $route): UriResource
{
if ($route->requiresAuth()) {
return new ProtectedResource(
$route->authConstraint(),
$this->resolveResource($calledUri, $route),
$this->injector
);
}
return $this->resolveResource($calledUri, $route);
} | php | private function handleMatchingRoute(CalledUri $calledUri, Route $route): UriResource
{
if ($route->requiresAuth()) {
return new ProtectedResource(
$route->authConstraint(),
$this->resolveResource($calledUri, $route),
$this->injector
);
}
return $this->resolveResource($calledUri, $route);
} | [
"private",
"function",
"handleMatchingRoute",
"(",
"CalledUri",
"$",
"calledUri",
",",
"Route",
"$",
"route",
")",
":",
"UriResource",
"{",
"if",
"(",
"$",
"route",
"->",
"requiresAuth",
"(",
")",
")",
"{",
"return",
"new",
"ProtectedResource",
"(",
"$",
"route",
"->",
"authConstraint",
"(",
")",
",",
"$",
"this",
"->",
"resolveResource",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
",",
"$",
"this",
"->",
"injector",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolveResource",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
";",
"}"
]
| creates a processable route for given route
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\Route $route
@return \stubbles\webapp\routing\UriResource | [
"creates",
"a",
"processable",
"route",
"for",
"given",
"route"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L254-L265 |
16,488 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.resolveResource | private function resolveResource(CalledUri $calledUri, Route $route): ResolvingResource
{
return new ResolvingResource(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri, $route),
$this->supportedMimeTypes($route),
$route
);
} | php | private function resolveResource(CalledUri $calledUri, Route $route): ResolvingResource
{
return new ResolvingResource(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri, $route),
$this->supportedMimeTypes($route),
$route
);
} | [
"private",
"function",
"resolveResource",
"(",
"CalledUri",
"$",
"calledUri",
",",
"Route",
"$",
"route",
")",
":",
"ResolvingResource",
"{",
"return",
"new",
"ResolvingResource",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
",",
"$",
"route",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
"$",
"route",
")",
",",
"$",
"route",
")",
";",
"}"
]
| creates matching route
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\Route $route
@return \stubbles\webapp\routing\ResolvingResource | [
"creates",
"matching",
"route"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L274-L283 |
16,489 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.handleNonMethodMatchingRoutes | private function handleNonMethodMatchingRoutes(
CalledUri $calledUri,
MatchingRoutes $matchingRoutes
): UriResource {
if ($calledUri->methodEquals('OPTIONS')) {
return new ResourceOptions(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes
);
}
return new MethodNotAllowed(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes->allowedMethods()
);
} | php | private function handleNonMethodMatchingRoutes(
CalledUri $calledUri,
MatchingRoutes $matchingRoutes
): UriResource {
if ($calledUri->methodEquals('OPTIONS')) {
return new ResourceOptions(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes
);
}
return new MethodNotAllowed(
$this->injector,
$calledUri,
$this->collectInterceptors($calledUri),
$this->supportedMimeTypes(),
$matchingRoutes->allowedMethods()
);
} | [
"private",
"function",
"handleNonMethodMatchingRoutes",
"(",
"CalledUri",
"$",
"calledUri",
",",
"MatchingRoutes",
"$",
"matchingRoutes",
")",
":",
"UriResource",
"{",
"if",
"(",
"$",
"calledUri",
"->",
"methodEquals",
"(",
"'OPTIONS'",
")",
")",
"{",
"return",
"new",
"ResourceOptions",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
")",
",",
"$",
"matchingRoutes",
")",
";",
"}",
"return",
"new",
"MethodNotAllowed",
"(",
"$",
"this",
"->",
"injector",
",",
"$",
"calledUri",
",",
"$",
"this",
"->",
"collectInterceptors",
"(",
"$",
"calledUri",
")",
",",
"$",
"this",
"->",
"supportedMimeTypes",
"(",
")",
",",
"$",
"matchingRoutes",
"->",
"allowedMethods",
"(",
")",
")",
";",
"}"
]
| creates a processable route when a route can be found regardless of request method
@param \stubbles\webapp\routing\CalledUri $calledUri
@param \stubbles\webapp\routing\MatchingRoutes $matchingRoutes
@return \stubbles\webapp\routing\UriResource | [
"creates",
"a",
"processable",
"route",
"when",
"a",
"route",
"can",
"be",
"found",
"regardless",
"of",
"request",
"method"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L292-L314 |
16,490 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.preInterceptOnGet | public function preInterceptOnGet($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'GET');
} | php | public function preInterceptOnGet($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'GET');
} | [
"public",
"function",
"preInterceptOnGet",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'GET'",
")",
";",
"}"
]
| pre intercept with given class or callable on all GET requests
@param string|callable|\stubbles\webapp\intercepto\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"GET",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L323-L326 |
16,491 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.preInterceptOnHead | public function preInterceptOnHead($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'HEAD');
} | php | public function preInterceptOnHead($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'HEAD');
} | [
"public",
"function",
"preInterceptOnHead",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'HEAD'",
")",
";",
"}"
]
| pre intercept with given class or callable on all HEAD requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"HEAD",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L335-L338 |
16,492 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.preInterceptOnPost | public function preInterceptOnPost($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'POST');
} | php | public function preInterceptOnPost($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'POST');
} | [
"public",
"function",
"preInterceptOnPost",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'POST'",
")",
";",
"}"
]
| pre intercept with given class or callable on all POST requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"POST",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L347-L350 |
16,493 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.preInterceptOnPut | public function preInterceptOnPut($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'PUT');
} | php | public function preInterceptOnPut($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'PUT');
} | [
"public",
"function",
"preInterceptOnPut",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'PUT'",
")",
";",
"}"
]
| pre intercept with given class or callable on all PUT requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"PUT",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L359-L362 |
16,494 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.preInterceptOnDelete | public function preInterceptOnDelete($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'DELETE');
} | php | public function preInterceptOnDelete($preInterceptor, string $path = null): RoutingConfigurator
{
return $this->preIntercept($preInterceptor, $path, 'DELETE');
} | [
"public",
"function",
"preInterceptOnDelete",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"$",
"path",
",",
"'DELETE'",
")",
";",
"}"
]
| pre intercept with given class or callable on all DELETE requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"DELETE",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L371-L374 |
16,495 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.preIntercept | public function preIntercept($preInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator
{
if (!is_callable($preInterceptor) && !($preInterceptor instanceof PreInterceptor) && !class_exists((string) $preInterceptor)) {
throw new \InvalidArgumentException(
'Given pre interceptor must be a callable, an instance of '
. PreInterceptor::class
. ' or a class name of an existing pre interceptor class'
);
}
$this->preInterceptors[] = [
'interceptor' => $preInterceptor,
'requestMethod' => $requestMethod,
'path' => $path
];
return $this;
} | php | public function preIntercept($preInterceptor, string $path = null, string $requestMethod = null): RoutingConfigurator
{
if (!is_callable($preInterceptor) && !($preInterceptor instanceof PreInterceptor) && !class_exists((string) $preInterceptor)) {
throw new \InvalidArgumentException(
'Given pre interceptor must be a callable, an instance of '
. PreInterceptor::class
. ' or a class name of an existing pre interceptor class'
);
}
$this->preInterceptors[] = [
'interceptor' => $preInterceptor,
'requestMethod' => $requestMethod,
'path' => $path
];
return $this;
} | [
"public",
"function",
"preIntercept",
"(",
"$",
"preInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
",",
"string",
"$",
"requestMethod",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"preInterceptor",
")",
"&&",
"!",
"(",
"$",
"preInterceptor",
"instanceof",
"PreInterceptor",
")",
"&&",
"!",
"class_exists",
"(",
"(",
"string",
")",
"$",
"preInterceptor",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Given pre interceptor must be a callable, an instance of '",
".",
"PreInterceptor",
"::",
"class",
".",
"' or a class name of an existing pre interceptor class'",
")",
";",
"}",
"$",
"this",
"->",
"preInterceptors",
"[",
"]",
"=",
"[",
"'interceptor'",
"=>",
"$",
"preInterceptor",
",",
"'requestMethod'",
"=>",
"$",
"requestMethod",
",",
"'path'",
"=>",
"$",
"path",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| pre intercept with given class or callable on all requests
@param string|callable|\stubbles\webapp\interceptor\PreInterceptor $preInterceptor pre interceptor to add
@param string $path optional path for which pre interceptor should be executed
@param string $requestMethod request method for which interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator
@throws \InvalidArgumentException | [
"pre",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L385-L401 |
16,496 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.postInterceptOnGet | public function postInterceptOnGet($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'GET');
} | php | public function postInterceptOnGet($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'GET');
} | [
"public",
"function",
"postInterceptOnGet",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'GET'",
")",
";",
"}"
]
| post intercept with given class or callable on all GET requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"GET",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L410-L413 |
16,497 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.postInterceptOnHead | public function postInterceptOnHead($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'HEAD');
} | php | public function postInterceptOnHead($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'HEAD');
} | [
"public",
"function",
"postInterceptOnHead",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'HEAD'",
")",
";",
"}"
]
| post intercept with given class or callable on all HEAD requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"HEAD",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L422-L425 |
16,498 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.postInterceptOnPost | public function postInterceptOnPost($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'POST');
} | php | public function postInterceptOnPost($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'POST');
} | [
"public",
"function",
"postInterceptOnPost",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'POST'",
")",
";",
"}"
]
| post intercept with given class or callable on all POST requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"POST",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L434-L437 |
16,499 | stubbles/stubbles-webapp-core | src/main/php/routing/Routing.php | Routing.postInterceptOnPut | public function postInterceptOnPut($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'PUT');
} | php | public function postInterceptOnPut($postInterceptor, string $path = null): RoutingConfigurator
{
return $this->postIntercept($postInterceptor, $path, 'PUT');
} | [
"public",
"function",
"postInterceptOnPut",
"(",
"$",
"postInterceptor",
",",
"string",
"$",
"path",
"=",
"null",
")",
":",
"RoutingConfigurator",
"{",
"return",
"$",
"this",
"->",
"postIntercept",
"(",
"$",
"postInterceptor",
",",
"$",
"path",
",",
"'PUT'",
")",
";",
"}"
]
| post intercept with given class or callable on all PUT requests
@param string|callable|\stubbles\webapp\interceptor\PostInterceptor $postInterceptor post interceptor to add
@param string $path optional path for which post interceptor should be executed
@return \stubbles\webapp\RoutingConfigurator | [
"post",
"intercept",
"with",
"given",
"class",
"or",
"callable",
"on",
"all",
"PUT",
"requests"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/Routing.php#L446-L449 |
Subsets and Splits