repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
PitonCMS/Session | src/SessionHandler.php | SessionHandler.setFlashData | public function setFlashData($newdata, $value = '')
{
if (is_string($newdata)) {
$newdata = [$newdata => $value];
}
if (!empty($newdata)) {
foreach ($newdata as $key => $val) {
$this->newFlashData[$key] = $val;
}
}
} | php | public function setFlashData($newdata, $value = '')
{
if (is_string($newdata)) {
$newdata = [$newdata => $value];
}
if (!empty($newdata)) {
foreach ($newdata as $key => $val) {
$this->newFlashData[$key] = $val;
}
}
} | [
"public",
"function",
"setFlashData",
"(",
"$",
"newdata",
",",
"$",
"value",
"=",
"''",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"newdata",
")",
")",
"{",
"$",
"newdata",
"=",
"[",
"$",
"newdata",
"=>",
"$",
"value",
"]",
";",
"}",
"if",
"(",... | Set Flash Data
Set flash data that will persist only until next request
@param mixed $newdata Flash data array or string (key)
@param string $value Value for single key | [
"Set",
"Flash",
"Data"
] | ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed | https://github.com/PitonCMS/Session/blob/ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed/src/SessionHandler.php#L240-L251 | train |
PitonCMS/Session | src/SessionHandler.php | SessionHandler.getFlashData | public function getFlashData($key = null)
{
if ($key === null) {
return $this->lastFlashData;
}
return isset($this->lastFlashData[$key]) ? $this->lastFlashData[$key] : null;
} | php | public function getFlashData($key = null)
{
if ($key === null) {
return $this->lastFlashData;
}
return isset($this->lastFlashData[$key]) ? $this->lastFlashData[$key] : null;
} | [
"public",
"function",
"getFlashData",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"lastFlashData",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"lastFlashData",
"[",
"$"... | Get Flash Data
Returns flash data
@param string $key Flash data array key
@return mixed Value or array | [
"Get",
"Flash",
"Data"
] | ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed | https://github.com/PitonCMS/Session/blob/ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed/src/SessionHandler.php#L260-L267 | train |
PitonCMS/Session | src/SessionHandler.php | SessionHandler.write | private function write()
{
$sessionData['data'] = $this->data;
$sessionData['flash'] = $this->newFlashData;
// Write session data to database
$stmt = $this->db->prepare("UPDATE {$this->tableName} SET data = ? WHERE session_id = ?");
$stmt->execute([json_encode($sessionData),... | php | private function write()
{
$sessionData['data'] = $this->data;
$sessionData['flash'] = $this->newFlashData;
// Write session data to database
$stmt = $this->db->prepare("UPDATE {$this->tableName} SET data = ? WHERE session_id = ?");
$stmt->execute([json_encode($sessionData),... | [
"private",
"function",
"write",
"(",
")",
"{",
"$",
"sessionData",
"[",
"'data'",
"]",
"=",
"$",
"this",
"->",
"data",
";",
"$",
"sessionData",
"[",
"'flash'",
"]",
"=",
"$",
"this",
"->",
"newFlashData",
";",
"// Write session data to database",
"$",
"stm... | Write Session Data
Writes session data to the database.
@return void | [
"Write",
"Session",
"Data"
] | ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed | https://github.com/PitonCMS/Session/blob/ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed/src/SessionHandler.php#L377-L385 | train |
PitonCMS/Session | src/SessionHandler.php | SessionHandler.cleanExpired | private function cleanExpired()
{
// 10% chance to clean the database of expired sessions
if (mt_rand(1, 10) == 1) {
$expiredTime = $this->now - $this->secondsUntilExpiration;
$stmt = $this->db->prepare("DELETE FROM {$this->tableName} WHERE time_updated < {$expiredTime}");
... | php | private function cleanExpired()
{
// 10% chance to clean the database of expired sessions
if (mt_rand(1, 10) == 1) {
$expiredTime = $this->now - $this->secondsUntilExpiration;
$stmt = $this->db->prepare("DELETE FROM {$this->tableName} WHERE time_updated < {$expiredTime}");
... | [
"private",
"function",
"cleanExpired",
"(",
")",
"{",
"// 10% chance to clean the database of expired sessions",
"if",
"(",
"mt_rand",
"(",
"1",
",",
"10",
")",
"==",
"1",
")",
"{",
"$",
"expiredTime",
"=",
"$",
"this",
"->",
"now",
"-",
"$",
"this",
"->",
... | Clean Old Sessions
Removes expired sessions from the database
@return void | [
"Clean",
"Old",
"Sessions"
] | ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed | https://github.com/PitonCMS/Session/blob/ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed/src/SessionHandler.php#L412-L420 | train |
PitonCMS/Session | src/SessionHandler.php | SessionHandler.generateId | private function generateId()
{
$randomNumber = mt_rand(0, mt_getrandmax());
$ipAddressFragment = md5(substr($this->ipAddress, 0, 5));
$timestamp = md5(microtime(true) . $this->now);
return hash('sha256', $randomNumber . $ipAddressFragment . $this->salt . $timestamp);
} | php | private function generateId()
{
$randomNumber = mt_rand(0, mt_getrandmax());
$ipAddressFragment = md5(substr($this->ipAddress, 0, 5));
$timestamp = md5(microtime(true) . $this->now);
return hash('sha256', $randomNumber . $ipAddressFragment . $this->salt . $timestamp);
} | [
"private",
"function",
"generateId",
"(",
")",
"{",
"$",
"randomNumber",
"=",
"mt_rand",
"(",
"0",
",",
"mt_getrandmax",
"(",
")",
")",
";",
"$",
"ipAddressFragment",
"=",
"md5",
"(",
"substr",
"(",
"$",
"this",
"->",
"ipAddress",
",",
"0",
",",
"5",
... | Generate New Session ID
Create a unique session ID
@return string | [
"Generate",
"New",
"Session",
"ID"
] | ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed | https://github.com/PitonCMS/Session/blob/ac7fdb75e9fab92941ee28cff5ae29952a7ca5ed/src/SessionHandler.php#L428-L435 | train |
froq/froq-collection | src/Collection.php | Collection.hasValue | public function hasValue($value, bool $strict = false): bool
{
return in_array($value, $this->data, $strict);
} | php | public function hasValue($value, bool $strict = false): bool
{
return in_array($value, $this->data, $strict);
} | [
"public",
"function",
"hasValue",
"(",
"$",
"value",
",",
"bool",
"$",
"strict",
"=",
"false",
")",
":",
"bool",
"{",
"return",
"in_array",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"data",
",",
"$",
"strict",
")",
";",
"}"
] | Has value.
@param any $value
@param bool $strict
@return bool | [
"Has",
"value",
"."
] | 0d5e89a820d805af69835d3269d3ec45ad02716e | https://github.com/froq/froq-collection/blob/0d5e89a820d805af69835d3269d3ec45ad02716e/src/Collection.php#L250-L253 | train |
froq/froq-collection | src/Collection.php | Collection.pullAll | public function pullAll(array $keys, $valueDefault = null): array
{
return Arrays::pullAll($this->data, $keys, $valueDefault);
} | php | public function pullAll(array $keys, $valueDefault = null): array
{
return Arrays::pullAll($this->data, $keys, $valueDefault);
} | [
"public",
"function",
"pullAll",
"(",
"array",
"$",
"keys",
",",
"$",
"valueDefault",
"=",
"null",
")",
":",
"array",
"{",
"return",
"Arrays",
"::",
"pullAll",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"keys",
",",
"$",
"valueDefault",
")",
";",
"}"
... | Pull all.
@param array $keys
@param any $valueDefault
@return any
@since 3.0 | [
"Pull",
"all",
"."
] | 0d5e89a820d805af69835d3269d3ec45ad02716e | https://github.com/froq/froq-collection/blob/0d5e89a820d805af69835d3269d3ec45ad02716e/src/Collection.php#L274-L277 | train |
frameworkwtf/auth | src/Auth/Middleware/RBAC.php | RBAC.isAllowed | protected function isAllowed(ServerRequestInterface $request, string $role): bool
{
$route = $request->getAttribute('route');
// Get config string like 'routes./home.second.rbac.anonymous' to get rbac config for route with name "second" in route group "home"
$config = 'routes.'.$route->getGr... | php | protected function isAllowed(ServerRequestInterface $request, string $role): bool
{
$route = $request->getAttribute('route');
// Get config string like 'routes./home.second.rbac.anonymous' to get rbac config for route with name "second" in route group "home"
$config = 'routes.'.$route->getGr... | [
"protected",
"function",
"isAllowed",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"string",
"$",
"role",
")",
":",
"bool",
"{",
"$",
"route",
"=",
"$",
"request",
"->",
"getAttribute",
"(",
"'route'",
")",
";",
"// Get config string like 'routes./home.seco... | Check if request allowed for current user.
@param ServerRequestInterface $request
@param string $role
@return bool | [
"Check",
"if",
"request",
"allowed",
"for",
"current",
"user",
"."
] | 2535d19ee326d1b491e36a341fe06d00bcc0731e | https://github.com/frameworkwtf/auth/blob/2535d19ee326d1b491e36a341fe06d00bcc0731e/src/Auth/Middleware/RBAC.php#L57-L67 | train |
prolic/HumusMvc | src/HumusMvc/Service/FrontControllerFactory.php | FrontControllerFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$frontController = FrontController::getInstance();
// handle injections
$frontController->setDispatcher($serviceLocator->get('Dispatcher'));
$frontController->setRequest($serviceLocator->get('Request'));
... | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$frontController = FrontController::getInstance();
// handle injections
$frontController->setDispatcher($serviceLocator->get('Dispatcher'));
$frontController->setRequest($serviceLocator->get('Request'));
... | [
"public",
"function",
"createService",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
")",
"{",
"$",
"frontController",
"=",
"FrontController",
"::",
"getInstance",
"(",
")",
";",
"// handle injections",
"$",
"frontController",
"->",
"setDispatcher",
"(",
"$",... | Create front controller service
@param ServiceLocatorInterface $serviceLocator
@return FrontController | [
"Create",
"front",
"controller",
"service"
] | 09e8c6422d84b57745cc643047e10761be2a21a7 | https://github.com/prolic/HumusMvc/blob/09e8c6422d84b57745cc643047e10761be2a21a7/src/HumusMvc/Service/FrontControllerFactory.php#L61-L117 | train |
WellCommerce/PageBundle | Controller/Front/PageController.php | PageController.findOr404 | protected function findOr404(Request $request, array $criteria = [])
{
// check whether request contains ID attribute
if (!$request->attributes->has('id')) {
throw new \LogicException('Request does not have "id" attribute set.');
}
$criteria['id'] = $request->attributes-... | php | protected function findOr404(Request $request, array $criteria = [])
{
// check whether request contains ID attribute
if (!$request->attributes->has('id')) {
throw new \LogicException('Request does not have "id" attribute set.');
}
$criteria['id'] = $request->attributes-... | [
"protected",
"function",
"findOr404",
"(",
"Request",
"$",
"request",
",",
"array",
"$",
"criteria",
"=",
"[",
"]",
")",
"{",
"// check whether request contains ID attribute",
"if",
"(",
"!",
"$",
"request",
"->",
"attributes",
"->",
"has",
"(",
"'id'",
")",
... | Returns resource by ID parameter
@param Request $request
@param array $criteria
@return mixed | [
"Returns",
"resource",
"by",
"ID",
"parameter"
] | c9a1e8c8c52177e3b82f246fd38a4598214aa222 | https://github.com/WellCommerce/PageBundle/blob/c9a1e8c8c52177e3b82f246fd38a4598214aa222/Controller/Front/PageController.php#L59-L73 | train |
theomessin/ts-framework | src/Node/Client.php | Client.iconDownload | public function iconDownload()
{
if ($this->iconIsLocal("client_icon_id") || $this["client_icon_id"] == 0) {
return;
}
$download = $this->getParent()->transferInitDownload(
rand(0x0000, 0xFFFF),
0,
$this->iconGetName("client_icon_id")
... | php | public function iconDownload()
{
if ($this->iconIsLocal("client_icon_id") || $this["client_icon_id"] == 0) {
return;
}
$download = $this->getParent()->transferInitDownload(
rand(0x0000, 0xFFFF),
0,
$this->iconGetName("client_icon_id")
... | [
"public",
"function",
"iconDownload",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"iconIsLocal",
"(",
"\"client_icon_id\"",
")",
"||",
"$",
"this",
"[",
"\"client_icon_id\"",
"]",
"==",
"0",
")",
"{",
"return",
";",
"}",
"$",
"download",
"=",
"$",
"th... | Downloads and returns the clients icon file content.
@return TeamSpeak3_Helper_String | [
"Downloads",
"and",
"returns",
"the",
"clients",
"icon",
"file",
"content",
"."
] | d60e36553241db05cb05ef19e749866cc977437c | https://github.com/theomessin/ts-framework/blob/d60e36553241db05cb05ef19e749866cc977437c/src/Node/Client.php#L350-L364 | train |
congraphcms/core | Helpers/FileHelper.php | FileHelper.uploadsUrl | public static function uploadsUrl($url = ''){
$url = Config::get('congraph::congraph.uploads_url') . '/' . $url;
$rtrim = !empty($url);
$url = url(self::normalizeUrl($url, $rtrim));
return $url;
} | php | public static function uploadsUrl($url = ''){
$url = Config::get('congraph::congraph.uploads_url') . '/' . $url;
$rtrim = !empty($url);
$url = url(self::normalizeUrl($url, $rtrim));
return $url;
} | [
"public",
"static",
"function",
"uploadsUrl",
"(",
"$",
"url",
"=",
"''",
")",
"{",
"$",
"url",
"=",
"Config",
"::",
"get",
"(",
"'congraph::congraph.uploads_url'",
")",
".",
"'/'",
".",
"$",
"url",
";",
"$",
"rtrim",
"=",
"!",
"empty",
"(",
"$",
"ur... | Get uploads url from config and optionally concatonates
given url to uploads url
@param string $url - optional url
@return string | [
"Get",
"uploads",
"url",
"from",
"config",
"and",
"optionally",
"concatonates",
"given",
"url",
"to",
"uploads",
"url"
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Helpers/FileHelper.php#L38-L44 | train |
congraphcms/core | Helpers/FileHelper.php | FileHelper.normalizePath | public static function normalizePath($path, $rtrim = true){
$path = trim($path);
// replace every back slash with forward slash
$path = str_replace('\\', '/', $path);
// replace all double slashes with single
$path = preg_replace( '/\/+/', '==DS==', $path );
// trim slashes on begining
$segments = explod... | php | public static function normalizePath($path, $rtrim = true){
$path = trim($path);
// replace every back slash with forward slash
$path = str_replace('\\', '/', $path);
// replace all double slashes with single
$path = preg_replace( '/\/+/', '==DS==', $path );
// trim slashes on begining
$segments = explod... | [
"public",
"static",
"function",
"normalizePath",
"(",
"$",
"path",
",",
"$",
"rtrim",
"=",
"true",
")",
"{",
"$",
"path",
"=",
"trim",
"(",
"$",
"path",
")",
";",
"// replace every back slash with forward slash",
"$",
"path",
"=",
"str_replace",
"(",
"'\\\\'... | Normalizes path slashes when mixed between path and url conversion
It takes string with mixed or doubled slashes and converts them
to single slashes dependent on system beacose of use of DIRECTORY_SEPARATOR const,
and optionally trims right slash.
There are two parameters,
string that will be normalized and optional ... | [
"Normalizes",
"path",
"slashes",
"when",
"mixed",
"between",
"path",
"and",
"url",
"conversion"
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Helpers/FileHelper.php#L79-L95 | train |
congraphcms/core | Helpers/FileHelper.php | FileHelper.normalizeUrl | public static function normalizeUrl($url, $rtrim = true){
$url = trim($url);
// replace every back slash with forward slash
$url = str_replace('\\', '/', $url);
// replace all double slashes with single
$url = preg_replace( '/\/+/', '==DS==', $url );
// trim slashes on begining
$segments = explode('==DS=... | php | public static function normalizeUrl($url, $rtrim = true){
$url = trim($url);
// replace every back slash with forward slash
$url = str_replace('\\', '/', $url);
// replace all double slashes with single
$url = preg_replace( '/\/+/', '==DS==', $url );
// trim slashes on begining
$segments = explode('==DS=... | [
"public",
"static",
"function",
"normalizeUrl",
"(",
"$",
"url",
",",
"$",
"rtrim",
"=",
"true",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"url",
")",
";",
"// replace every back slash with forward slash",
"$",
"url",
"=",
"str_replace",
"(",
"'\\\\'",
... | Normalizes url slashes when mixed between path and url conversion
It takes string with mixed or doubled slashes and converts them
to single forward slashes, and optionally trims right slash
There are two parameters,
string that will be normalized and optional rtrim flag
@param string $url - string to be normalized
@... | [
"Normalizes",
"url",
"slashes",
"when",
"mixed",
"between",
"path",
"and",
"url",
"conversion"
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Helpers/FileHelper.php#L110-L124 | train |
congraphcms/core | Helpers/FileHelper.php | FileHelper.uniqueFilename | public static function uniqueFilename($path) {
// get directory
$dir = self::getDirectory($path);
// get filename
$filename = self::getFileName($path);
// sanitize the file name before we begin processing
$filename = self::sanitizeFileName($filename);
// separate the filename into a name and extension
... | php | public static function uniqueFilename($path) {
// get directory
$dir = self::getDirectory($path);
// get filename
$filename = self::getFileName($path);
// sanitize the file name before we begin processing
$filename = self::sanitizeFileName($filename);
// separate the filename into a name and extension
... | [
"public",
"static",
"function",
"uniqueFilename",
"(",
"$",
"path",
")",
"{",
"// get directory",
"$",
"dir",
"=",
"self",
"::",
"getDirectory",
"(",
"$",
"path",
")",
";",
"// get filename",
"$",
"filename",
"=",
"self",
"::",
"getFileName",
"(",
"$",
"pa... | Get a filename that is sanitized and unique for the given directory.
If the filename is not unique, then a number will be added to the filename
before the extension, and will continue adding numbers until the filename is
unique.
@param string $path
@return string | [
"Get",
"a",
"filename",
"that",
"is",
"sanitized",
"and",
"unique",
"for",
"the",
"given",
"directory",
"."
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Helpers/FileHelper.php#L166-L207 | train |
congraphcms/core | Helpers/FileHelper.php | FileHelper.sanitizeFileName | public static function sanitizeFileName( $filename ) {
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
$filename = str_replace($special_chars, '', $filename);
$filename = preg_replace('/[\s-]+/', '-', $f... | php | public static function sanitizeFileName( $filename ) {
$special_chars = array("?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", "~", "`", "!", "{", "}", chr(0));
$filename = str_replace($special_chars, '', $filename);
$filename = preg_replace('/[\s-]+/', '-', $f... | [
"public",
"static",
"function",
"sanitizeFileName",
"(",
"$",
"filename",
")",
"{",
"$",
"special_chars",
"=",
"array",
"(",
"\"?\"",
",",
"\"[\"",
",",
"\"]\"",
",",
"\"/\"",
",",
"\"\\\\\"",
",",
"\"=\"",
",",
"\"<\"",
",",
"\">\"",
",",
"\":\"",
",",
... | Sanitizes a filename replacing whitespace with dashes
Removes special characters that are illegal in filenames on certain
operating systems and special characters requiring special escaping
to manipulate at the command line. Replaces spaces and consecutive
dashes with a single dash. Trim period, dash and underscore fr... | [
"Sanitizes",
"a",
"filename",
"replacing",
"whitespace",
"with",
"dashes"
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Helpers/FileHelper.php#L222-L230 | train |
congraphcms/core | Helpers/FileHelper.php | FileHelper.getFileName | public static function getFileName( $path, $includeExtension = true )
{
$option = ($includeExtension)?PATHINFO_BASENAME:PATHINFO_FILENAME;
return pathinfo($path, $option);
} | php | public static function getFileName( $path, $includeExtension = true )
{
$option = ($includeExtension)?PATHINFO_BASENAME:PATHINFO_FILENAME;
return pathinfo($path, $option);
} | [
"public",
"static",
"function",
"getFileName",
"(",
"$",
"path",
",",
"$",
"includeExtension",
"=",
"true",
")",
"{",
"$",
"option",
"=",
"(",
"$",
"includeExtension",
")",
"?",
"PATHINFO_BASENAME",
":",
"PATHINFO_FILENAME",
";",
"return",
"pathinfo",
"(",
"... | Extracts filename from path, with or without extension
You can optionally specify if you want extensino to be included
Defaults to extension included
@param string $path from wich filename will be extracted
@param boolean $includeExtension flag for including extension
@return string extracted filename | [
"Extracts",
"filename",
"from",
"path",
"with",
"or",
"without",
"extension"
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Helpers/FileHelper.php#L242-L246 | train |
ingro/Rest | src/Ingruz/Rest/Controllers/RestIlluminateController.php | AbstractIlluminateApiController.index | public function index()
{
$options = $this->getQueryHelperOptions();
$items = $this->repo->allPaged($options);
if ( ! $items)
{
return $this->respondNotFound('Unable to fetch the selected resources');
}
$response = [
'data' => [],
... | php | public function index()
{
$options = $this->getQueryHelperOptions();
$items = $this->repo->allPaged($options);
if ( ! $items)
{
return $this->respondNotFound('Unable to fetch the selected resources');
}
$response = [
'data' => [],
... | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getQueryHelperOptions",
"(",
")",
";",
"$",
"items",
"=",
"$",
"this",
"->",
"repo",
"->",
"allPaged",
"(",
"$",
"options",
")",
";",
"if",
"(",
"!",
"$",
"items... | Return items in a paged way
@return mixed | [
"Return",
"items",
"in",
"a",
"paged",
"way"
] | 922bed071b8ea41feb067d97a3e283f944a86cb8 | https://github.com/ingro/Rest/blob/922bed071b8ea41feb067d97a3e283f944a86cb8/src/Ingruz/Rest/Controllers/RestIlluminateController.php#L79-L112 | train |
ingro/Rest | src/Ingruz/Rest/Controllers/RestIlluminateController.php | AbstractIlluminateApiController.show | public function show($id)
{
$item = $this->repo->getById($id);
if ( ! $item)
{
return $this->respondNotFound();
}
$resource = new Fractal\Resource\Item($item, new $this->transformerClass);
return $this->fractal->createData($resource)->toArray();
} | php | public function show($id)
{
$item = $this->repo->getById($id);
if ( ! $item)
{
return $this->respondNotFound();
}
$resource = new Fractal\Resource\Item($item, new $this->transformerClass);
return $this->fractal->createData($resource)->toArray();
} | [
"public",
"function",
"show",
"(",
"$",
"id",
")",
"{",
"$",
"item",
"=",
"$",
"this",
"->",
"repo",
"->",
"getById",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"item",
")",
"{",
"return",
"$",
"this",
"->",
"respondNotFound",
"(",
")",
";"... | Return an item by it's id
@param $id
@return mixed | [
"Return",
"an",
"item",
"by",
"it",
"s",
"id"
] | 922bed071b8ea41feb067d97a3e283f944a86cb8 | https://github.com/ingro/Rest/blob/922bed071b8ea41feb067d97a3e283f944a86cb8/src/Ingruz/Rest/Controllers/RestIlluminateController.php#L120-L131 | train |
congraphcms/core | Repositories/Collection.php | Collection.setDefaultModel | public function setDefaultModel($model)
{
if(is_string($model))
{
$model = new ReflectionClass($model);
$model = $model->newInstanceWithoutConstructor();
}
if( $model instanceof Model)
{
$this->defaultModel = get_class($model);
return;
}
throw new \InvalidArgumentException('Collection defau... | php | public function setDefaultModel($model)
{
if(is_string($model))
{
$model = new ReflectionClass($model);
$model = $model->newInstanceWithoutConstructor();
}
if( $model instanceof Model)
{
$this->defaultModel = get_class($model);
return;
}
throw new \InvalidArgumentException('Collection defau... | [
"public",
"function",
"setDefaultModel",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"model",
")",
")",
"{",
"$",
"model",
"=",
"new",
"ReflectionClass",
"(",
"$",
"model",
")",
";",
"$",
"model",
"=",
"$",
"model",
"->",
"newInsta... | Set default model class
@param Congraph\Core\Repositories\Model|string $model
@throws \InvalidArgumentException | [
"Set",
"default",
"model",
"class"
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Repositories/Collection.php#L98-L113 | train |
congraphcms/core | Repositories/Collection.php | Collection.checkItems | protected function checkItems(array $data)
{
foreach ($data as &$item)
{
if( ! $item instanceof Model )
{
$item = new $this->defaultModel($item);
}
}
return $data;
} | php | protected function checkItems(array $data)
{
foreach ($data as &$item)
{
if( ! $item instanceof Model )
{
$item = new $this->defaultModel($item);
}
}
return $data;
} | [
"protected",
"function",
"checkItems",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"&",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"$",
"item",
"instanceof",
"Model",
")",
"{",
"$",
"item",
"=",
"new",
"$",
"this",
"->",
"... | Check if all items are instance of Model
if not, create new Model for each item
@param array $data
@return array | [
"Check",
"if",
"all",
"items",
"are",
"instance",
"of",
"Model",
"if",
"not",
"create",
"new",
"Model",
"for",
"each",
"item"
] | d017d3951b446fb2ac93b8fcee120549bb125b17 | https://github.com/congraphcms/core/blob/d017d3951b446fb2ac93b8fcee120549bb125b17/Repositories/Collection.php#L182-L193 | train |
phospr/DoubleEntryBundle | Model/JournalHandler.php | JournalHandler.findJournalForId | public function findJournalForId($id)
{
$dql = '
SELECT j,p
FROM %s j
LEFT JOIN j.postings p
WHERE j.id = :id
AND j.organization = :organization
';
return $this->em
->createQuery(sprintf($dql, $this->j... | php | public function findJournalForId($id)
{
$dql = '
SELECT j,p
FROM %s j
LEFT JOIN j.postings p
WHERE j.id = :id
AND j.organization = :organization
';
return $this->em
->createQuery(sprintf($dql, $this->j... | [
"public",
"function",
"findJournalForId",
"(",
"$",
"id",
")",
"{",
"$",
"dql",
"=",
"'\n SELECT j,p\n FROM %s j\n LEFT JOIN j.postings p\n WHERE j.id = :id\n AND j.organization = :organization\n '",
";",
"retu... | Find Journal for id
@author Tom Haskins-Vaughan <tom@tomhv.uk>
@since 0.8.0
@param int $id
@return Journal | [
"Find",
"Journal",
"for",
"id"
] | d9c421f30922b461483731983c59beb26047fb7f | https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/JournalHandler.php#L98-L114 | train |
phospr/DoubleEntryBundle | Model/JournalHandler.php | JournalHandler.createJournal | public function createJournal()
{
$journal = new $this->journalFqcn();
$journal->setOrganization($this->oh->getOrganization());
return $journal;
} | php | public function createJournal()
{
$journal = new $this->journalFqcn();
$journal->setOrganization($this->oh->getOrganization());
return $journal;
} | [
"public",
"function",
"createJournal",
"(",
")",
"{",
"$",
"journal",
"=",
"new",
"$",
"this",
"->",
"journalFqcn",
"(",
")",
";",
"$",
"journal",
"->",
"setOrganization",
"(",
"$",
"this",
"->",
"oh",
"->",
"getOrganization",
"(",
")",
")",
";",
"retu... | Create new Journal
@author Tom Haskins-Vaughan <tom@tomhv.uk>
@since 0.8.0
@return Journal | [
"Create",
"new",
"Journal"
] | d9c421f30922b461483731983c59beb26047fb7f | https://github.com/phospr/DoubleEntryBundle/blob/d9c421f30922b461483731983c59beb26047fb7f/Model/JournalHandler.php#L124-L130 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.addRoute | public function addRoute($expression, $route)
{
//Detect command expression
if (strpos($expression, '*') !== false) {
return $this->addRegexpRoute($expression, $route);
} else {
return $this->addSimpleRoute($expression, $route);
}
} | php | public function addRoute($expression, $route)
{
//Detect command expression
if (strpos($expression, '*') !== false) {
return $this->addRegexpRoute($expression, $route);
} else {
return $this->addSimpleRoute($expression, $route);
}
} | [
"public",
"function",
"addRoute",
"(",
"$",
"expression",
",",
"$",
"route",
")",
"{",
"//Detect command expression",
"if",
"(",
"strpos",
"(",
"$",
"expression",
",",
"'*'",
")",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"addRegexpRoute",
"("... | Add new route.
@param string $expression Either simple expression, or RegExp describing route.
@param string $route Route name.
@return bool True, if route has been set, false otherwise. | [
"Add",
"new",
"route",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L55-L63 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.addRegexpRoute | private function addRegexpRoute($expression, $route)
{
$expression = '|^'.str_replace(array('*', '\\'), array('.*', '\\\\'), $expression).'$|i';
if (array_key_exists($expression, $this->regexpRoutes) && $this->regexpRoutes[$expression] == $route) {
return false;
}
$this->... | php | private function addRegexpRoute($expression, $route)
{
$expression = '|^'.str_replace(array('*', '\\'), array('.*', '\\\\'), $expression).'$|i';
if (array_key_exists($expression, $this->regexpRoutes) && $this->regexpRoutes[$expression] == $route) {
return false;
}
$this->... | [
"private",
"function",
"addRegexpRoute",
"(",
"$",
"expression",
",",
"$",
"route",
")",
"{",
"$",
"expression",
"=",
"'|^'",
".",
"str_replace",
"(",
"array",
"(",
"'*'",
",",
"'\\\\'",
")",
",",
"array",
"(",
"'.*'",
",",
"'\\\\\\\\'",
")",
",",
"$",... | Add new regexp route.
@param string $expression RegExp describing route.
@param string $route Route name.
@return bool True, if route has been set, false otherwise. | [
"Add",
"new",
"regexp",
"route",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L73-L81 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.addSimpleRoute | private function addSimpleRoute($expression, $route)
{
if (array_key_exists($expression, $this->simpleRoutes) && $this->simpleRoutes[$expression] == $route) {
return false;
}
$this->simpleRoutes[$expression] = (string) $route;
return true;
} | php | private function addSimpleRoute($expression, $route)
{
if (array_key_exists($expression, $this->simpleRoutes) && $this->simpleRoutes[$expression] == $route) {
return false;
}
$this->simpleRoutes[$expression] = (string) $route;
return true;
} | [
"private",
"function",
"addSimpleRoute",
"(",
"$",
"expression",
",",
"$",
"route",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"expression",
",",
"$",
"this",
"->",
"simpleRoutes",
")",
"&&",
"$",
"this",
"->",
"simpleRoutes",
"[",
"$",
"expression... | Add new simple route.
@param string $expression Simple route expression.
@param string $route Route name.
@return bool True, if route has been set, false otherwise. | [
"Add",
"new",
"simple",
"route",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L91-L98 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.doDetect | private function doDetect($className, $performInterfaceDetection = true)
{
$detection = $this->doDetectByRoutes($className);
if ($detection) {
return $detection;
}
//Nothing is found so far. We will check all of the class interfaces and base classes.
//First - che... | php | private function doDetect($className, $performInterfaceDetection = true)
{
$detection = $this->doDetectByRoutes($className);
if ($detection) {
return $detection;
}
//Nothing is found so far. We will check all of the class interfaces and base classes.
//First - che... | [
"private",
"function",
"doDetect",
"(",
"$",
"className",
",",
"$",
"performInterfaceDetection",
"=",
"true",
")",
"{",
"$",
"detection",
"=",
"$",
"this",
"->",
"doDetectByRoutes",
"(",
"$",
"className",
")",
";",
"if",
"(",
"$",
"detection",
")",
"{",
... | Detect pool.
@param string $className
@param boolean $performInterfaceDetection
@return DetectionInterface | [
"Detect",
"pool",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L146-L170 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.doDetectByRoutes | private function doDetectByRoutes($className)
{
//If we have entry for a command class, we should always return it, as it is most specific.
if (!empty($this->simpleRoutes[$className])) {
return new ClassDetection($this->simpleRoutes[$className]);
}
//Now, we should check,... | php | private function doDetectByRoutes($className)
{
//If we have entry for a command class, we should always return it, as it is most specific.
if (!empty($this->simpleRoutes[$className])) {
return new ClassDetection($this->simpleRoutes[$className]);
}
//Now, we should check,... | [
"private",
"function",
"doDetectByRoutes",
"(",
"$",
"className",
")",
"{",
"//If we have entry for a command class, we should always return it, as it is most specific.",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"simpleRoutes",
"[",
"$",
"className",
"]",
")",
"... | Perform detection based on class name and routes registered for this class.
@param string $className
@return ClassDetection|null | [
"Perform",
"detection",
"based",
"on",
"class",
"name",
"and",
"routes",
"registered",
"for",
"this",
"class",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L179-L191 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.doDetectByInterfaces | private function doDetectByInterfaces($className)
{
$interfaces = $this->getOrderedInterfaces($className);
foreach ($interfaces as $interface) {
$candidate = $this->doDetectByRoutes($interface);
if ($candidate) {
return $candidate;
}
}
... | php | private function doDetectByInterfaces($className)
{
$interfaces = $this->getOrderedInterfaces($className);
foreach ($interfaces as $interface) {
$candidate = $this->doDetectByRoutes($interface);
if ($candidate) {
return $candidate;
}
}
... | [
"private",
"function",
"doDetectByInterfaces",
"(",
"$",
"className",
")",
"{",
"$",
"interfaces",
"=",
"$",
"this",
"->",
"getOrderedInterfaces",
"(",
"$",
"className",
")",
";",
"foreach",
"(",
"$",
"interfaces",
"as",
"$",
"interface",
")",
"{",
"$",
"c... | Perform detection based on class interfaces.
@param string $className
@return DetectionInterface|null | [
"Perform",
"detection",
"based",
"on",
"class",
"interfaces",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L200-L211 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.getOrderedInterfaces | private function getOrderedInterfaces($className)
{
$interfacesArr = $this->prepareClassTreeInterfaces($className);
$interfaces = array();
foreach ($interfacesArr as $classInterfaces) {
foreach ($classInterfaces as $interface) {
if (array_search($interface, $inter... | php | private function getOrderedInterfaces($className)
{
$interfacesArr = $this->prepareClassTreeInterfaces($className);
$interfaces = array();
foreach ($interfacesArr as $classInterfaces) {
foreach ($classInterfaces as $interface) {
if (array_search($interface, $inter... | [
"private",
"function",
"getOrderedInterfaces",
"(",
"$",
"className",
")",
"{",
"$",
"interfacesArr",
"=",
"$",
"this",
"->",
"prepareClassTreeInterfaces",
"(",
"$",
"className",
")",
";",
"$",
"interfaces",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
... | Get a list of class interfaces ordered by plase of interface declaration.
The list is ordered by place of interface declaration. Interfaces declared on most child class are first,
while those in base class(es) - last.
@param string $className
@return array | [
"Get",
"a",
"list",
"of",
"class",
"interfaces",
"ordered",
"by",
"plase",
"of",
"interface",
"declaration",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L223-L236 | train |
Gendoria/command-queue | src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php | RouteDetector.prepareClassTreeInterfaces | private function prepareClassTreeInterfaces($className)
{
$interfacesArr = array();
$reflection = new ReflectionClass($className);
$interfacesArr[] = $reflection->getInterfaceNames();
if (empty($interfacesArr[0])) {
return array();
}
$classParents = class_... | php | private function prepareClassTreeInterfaces($className)
{
$interfacesArr = array();
$reflection = new ReflectionClass($className);
$interfacesArr[] = $reflection->getInterfaceNames();
if (empty($interfacesArr[0])) {
return array();
}
$classParents = class_... | [
"private",
"function",
"prepareClassTreeInterfaces",
"(",
"$",
"className",
")",
"{",
"$",
"interfacesArr",
"=",
"array",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"interfacesArr",
"[",
"]",
"=",
... | Prepares all interfaces for given class and its parents.
@param string $className
@return array | [
"Prepares",
"all",
"interfaces",
"for",
"given",
"class",
"and",
"its",
"parents",
"."
] | 4e1094570705942f2ce3b2c976b5b251c3c84b40 | https://github.com/Gendoria/command-queue/blob/4e1094570705942f2ce3b2c976b5b251c3c84b40/src/Gendoria/CommandQueue/RouteDetection/Detector/RouteDetector.php#L244-L262 | train |
WellBloud/sovacore-core | src/model/AdminModule/repository/BaseRepository.php | BaseRepository.findAllTreeItems | public function findAllTreeItems($publishedOnly = false)
{
$filter = $publishedOnly ? ['published' => true] : [];
return $this->repository->findBy($filter, ['lft' => 'ASC']);
} | php | public function findAllTreeItems($publishedOnly = false)
{
$filter = $publishedOnly ? ['published' => true] : [];
return $this->repository->findBy($filter, ['lft' => 'ASC']);
} | [
"public",
"function",
"findAllTreeItems",
"(",
"$",
"publishedOnly",
"=",
"false",
")",
"{",
"$",
"filter",
"=",
"$",
"publishedOnly",
"?",
"[",
"'published'",
"=>",
"true",
"]",
":",
"[",
"]",
";",
"return",
"$",
"this",
"->",
"repository",
"->",
"findB... | Returns all items in tree structure
@param type $publishedOnly returns only published items
@return type | [
"Returns",
"all",
"items",
"in",
"tree",
"structure"
] | 1816a0d7cd3ec4a90d64e301fc2469d171ad217f | https://github.com/WellBloud/sovacore-core/blob/1816a0d7cd3ec4a90d64e301fc2469d171ad217f/src/model/AdminModule/repository/BaseRepository.php#L26-L30 | train |
WellBloud/sovacore-core | src/model/AdminModule/repository/BaseRepository.php | BaseRepository.getUniqueAlias | public function getUniqueAlias($entity,
string $titleProperty = 'title',
string $titleValue = null,
string $aliasColumn = 'seoTitle'): string
{
$alias = Strings::webalize($titleValue ?? $entity->{$titleProperty});
$id = $entity->id ?? null;
while (!$this->seoTitleIsUn... | php | public function getUniqueAlias($entity,
string $titleProperty = 'title',
string $titleValue = null,
string $aliasColumn = 'seoTitle'): string
{
$alias = Strings::webalize($titleValue ?? $entity->{$titleProperty});
$id = $entity->id ?? null;
while (!$this->seoTitleIsUn... | [
"public",
"function",
"getUniqueAlias",
"(",
"$",
"entity",
",",
"string",
"$",
"titleProperty",
"=",
"'title'",
",",
"string",
"$",
"titleValue",
"=",
"null",
",",
"string",
"$",
"aliasColumn",
"=",
"'seoTitle'",
")",
":",
"string",
"{",
"$",
"alias",
"="... | Returns unique seo alias for entity
@param entity $entity
@param string $titleProperty
@param string $titleValue
@param string $aliasColumn
@return string entity seo title | [
"Returns",
"unique",
"seo",
"alias",
"for",
"entity"
] | 1816a0d7cd3ec4a90d64e301fc2469d171ad217f | https://github.com/WellBloud/sovacore-core/blob/1816a0d7cd3ec4a90d64e301fc2469d171ad217f/src/model/AdminModule/repository/BaseRepository.php#L80-L99 | train |
WellBloud/sovacore-core | src/model/AdminModule/repository/BaseRepository.php | BaseRepository.seoTitleIsUnique | private function seoTitleIsUnique($id,
string $generatedAlias,
string $aliasColumn = 'seoTitle'): bool
{
$alias = Strings::webalize($generatedAlias);
if ($id === null) {
$results = $this->repository->findBy([$aliasColumn => $alias]);
} else {
$results ... | php | private function seoTitleIsUnique($id,
string $generatedAlias,
string $aliasColumn = 'seoTitle'): bool
{
$alias = Strings::webalize($generatedAlias);
if ($id === null) {
$results = $this->repository->findBy([$aliasColumn => $alias]);
} else {
$results ... | [
"private",
"function",
"seoTitleIsUnique",
"(",
"$",
"id",
",",
"string",
"$",
"generatedAlias",
",",
"string",
"$",
"aliasColumn",
"=",
"'seoTitle'",
")",
":",
"bool",
"{",
"$",
"alias",
"=",
"Strings",
"::",
"webalize",
"(",
"$",
"generatedAlias",
")",
"... | Checks if seo title is unique.
@param int|NULL $id
@param string $generatedAlias
@param string $aliasColumn
@return boolean | [
"Checks",
"if",
"seo",
"title",
"is",
"unique",
"."
] | 1816a0d7cd3ec4a90d64e301fc2469d171ad217f | https://github.com/WellBloud/sovacore-core/blob/1816a0d7cd3ec4a90d64e301fc2469d171ad217f/src/model/AdminModule/repository/BaseRepository.php#L108-L119 | train |
WellBloud/sovacore-core | src/model/AdminModule/repository/BaseRepository.php | BaseRepository.removeImage | public function removeImage($entityId)
{
if (!$entityId) {
return false;
}
$delete = '
UPDATE ' . $this->repository->getClassName() . ' a
SET a.image = NULL
WHERE a.id = ' . $entityId . '
';
$q = $this->query($delete);
$q->execute(... | php | public function removeImage($entityId)
{
if (!$entityId) {
return false;
}
$delete = '
UPDATE ' . $this->repository->getClassName() . ' a
SET a.image = NULL
WHERE a.id = ' . $entityId . '
';
$q = $this->query($delete);
$q->execute(... | [
"public",
"function",
"removeImage",
"(",
"$",
"entityId",
")",
"{",
"if",
"(",
"!",
"$",
"entityId",
")",
"{",
"return",
"false",
";",
"}",
"$",
"delete",
"=",
"'\n UPDATE '",
".",
"$",
"this",
"->",
"repository",
"->",
"getClassName",
"(",
")",
... | Sets image to NULL
@param string $entityId | [
"Sets",
"image",
"to",
"NULL"
] | 1816a0d7cd3ec4a90d64e301fc2469d171ad217f | https://github.com/WellBloud/sovacore-core/blob/1816a0d7cd3ec4a90d64e301fc2469d171ad217f/src/model/AdminModule/repository/BaseRepository.php#L125-L138 | train |
WellBloud/sovacore-core | src/model/AdminModule/repository/BaseRepository.php | BaseRepository.getNewMaxId | public function getNewMaxId($entityClassname): int
{
$maxId = $this->em->createQueryBuilder()
->select('MAX(e.id) + 1')
->from($entityClassname, 'e')
->getQuery()
->getSingleScalarResult();
return (int) $maxId;
} | php | public function getNewMaxId($entityClassname): int
{
$maxId = $this->em->createQueryBuilder()
->select('MAX(e.id) + 1')
->from($entityClassname, 'e')
->getQuery()
->getSingleScalarResult();
return (int) $maxId;
} | [
"public",
"function",
"getNewMaxId",
"(",
"$",
"entityClassname",
")",
":",
"int",
"{",
"$",
"maxId",
"=",
"$",
"this",
"->",
"em",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'MAX(e.id) + 1'",
")",
"->",
"from",
"(",
"$",
"entityClassname"... | Returns new MAX ID for entity
@param string $entityClassname
@return int | [
"Returns",
"new",
"MAX",
"ID",
"for",
"entity"
] | 1816a0d7cd3ec4a90d64e301fc2469d171ad217f | https://github.com/WellBloud/sovacore-core/blob/1816a0d7cd3ec4a90d64e301fc2469d171ad217f/src/model/AdminModule/repository/BaseRepository.php#L145-L153 | train |
WellBloud/sovacore-core | src/model/AdminModule/repository/BaseRepository.php | BaseRepository.rebuildTree | public function rebuildTree($entityClass = '',
$parentEntity)
{
if ($entityClass === '') {
throw new Exception('messages.error.classNameNotProvided');
}
if ($parentEntity === null) {
throw new Exception('messages.error.cantRemakeTree');
}
$dqlL... | php | public function rebuildTree($entityClass = '',
$parentEntity)
{
if ($entityClass === '') {
throw new Exception('messages.error.classNameNotProvided');
}
if ($parentEntity === null) {
throw new Exception('messages.error.cantRemakeTree');
}
$dqlL... | [
"public",
"function",
"rebuildTree",
"(",
"$",
"entityClass",
"=",
"''",
",",
"$",
"parentEntity",
")",
"{",
"if",
"(",
"$",
"entityClass",
"===",
"''",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'messages.error.classNameNotProvided'",
")",
";",
"}",
"if",... | Rebuilds a tree structure by setting lft and rgt values across the rest of the tree
@param type $entityClass Class with defined entity
@param type $parentEntity Entity object
@throws Exception | [
"Rebuilds",
"a",
"tree",
"structure",
"by",
"setting",
"lft",
"and",
"rgt",
"values",
"across",
"the",
"rest",
"of",
"the",
"tree"
] | 1816a0d7cd3ec4a90d64e301fc2469d171ad217f | https://github.com/WellBloud/sovacore-core/blob/1816a0d7cd3ec4a90d64e301fc2469d171ad217f/src/model/AdminModule/repository/BaseRepository.php#L196-L220 | train |
WellBloud/sovacore-core | src/model/AdminModule/repository/BaseRepository.php | BaseRepository.deleteTreeItem | public function deleteTreeItem($entityClass = '',
$id)
{
if ($entityClass === '') {
throw new Exception('messages.error.classNameNotProvided');
}
$entity = $this->findById($id);
$difference = $entity->rgt - $entity->lft + 1;
$deleteTree = '
... | php | public function deleteTreeItem($entityClass = '',
$id)
{
if ($entityClass === '') {
throw new Exception('messages.error.classNameNotProvided');
}
$entity = $this->findById($id);
$difference = $entity->rgt - $entity->lft + 1;
$deleteTree = '
... | [
"public",
"function",
"deleteTreeItem",
"(",
"$",
"entityClass",
"=",
"''",
",",
"$",
"id",
")",
"{",
"if",
"(",
"$",
"entityClass",
"===",
"''",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'messages.error.classNameNotProvided'",
")",
";",
"}",
"$",
"enti... | Deletes a tree node and updates rest of the tree
@param type $entityClass Class with defined entity
@param type $id | [
"Deletes",
"a",
"tree",
"node",
"and",
"updates",
"rest",
"of",
"the",
"tree"
] | 1816a0d7cd3ec4a90d64e301fc2469d171ad217f | https://github.com/WellBloud/sovacore-core/blob/1816a0d7cd3ec4a90d64e301fc2469d171ad217f/src/model/AdminModule/repository/BaseRepository.php#L227-L259 | train |
aztech-labs/skwal | src/Query/Select.php | Select.deriveColumn | public function deriveColumn($index)
{
$this->validateColumnIndex($index);
$column = new DerivedColumn($this->columns[$index]->getAlias());
return $column->setTable($this);
} | php | public function deriveColumn($index)
{
$this->validateColumnIndex($index);
$column = new DerivedColumn($this->columns[$index]->getAlias());
return $column->setTable($this);
} | [
"public",
"function",
"deriveColumn",
"(",
"$",
"index",
")",
"{",
"$",
"this",
"->",
"validateColumnIndex",
"(",
"$",
"index",
")",
";",
"$",
"column",
"=",
"new",
"DerivedColumn",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"index",
"]",
"->",
"getA... | Derives an expression in the query's select clause as a column of the query's associated resultset.
@param int $index
@throws \OutOfRangeException
@return multitype:\Aztech\Skwal\Expression\AliasExpression | [
"Derives",
"an",
"expression",
"in",
"the",
"query",
"s",
"select",
"clause",
"as",
"a",
"column",
"of",
"the",
"query",
"s",
"associated",
"resultset",
"."
] | cf637c5ddb69f6579ba28a61af9c39639081dc16 | https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Query/Select.php#L196-L203 | train |
aztech-labs/skwal | src/Query/Select.php | Select.deriveColumns | public function deriveColumns()
{
$derived = array();
for ($i = 0; $i < count($this->columns); $i ++) {
$derived[] = $this->deriveColumn($i);
}
return $derived;
} | php | public function deriveColumns()
{
$derived = array();
for ($i = 0; $i < count($this->columns); $i ++) {
$derived[] = $this->deriveColumn($i);
}
return $derived;
} | [
"public",
"function",
"deriveColumns",
"(",
")",
"{",
"$",
"derived",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"columns",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"deriv... | Derives all expressions in the query's select clause as columns of the query's associated resultset.
@return multitype:Ambigous <\Aztech\Skwal\Query\multitype:\Aztech\Skwal\Expression\AliasExpression, \Aztech\Skwal\Expression\DerivedColumn> | [
"Derives",
"all",
"expressions",
"in",
"the",
"query",
"s",
"select",
"clause",
"as",
"columns",
"of",
"the",
"query",
"s",
"associated",
"resultset",
"."
] | cf637c5ddb69f6579ba28a61af9c39639081dc16 | https://github.com/aztech-labs/skwal/blob/cf637c5ddb69f6579ba28a61af9c39639081dc16/src/Query/Select.php#L210-L219 | train |
valu-digital/valusetup | src/ValuSetup/Setup/SetupUtilsOptions.php | SetupUtilsOptions.setModuleDirs | public function setModuleDirs($dirs) {
if(!is_array($dirs) && !($dirs instanceof \Traversable)){
throw new \InvalidArgumentException('Invalid argument $dirs; array or instance of Traversable expected');
}
$this->moduleDirs = array();
foreach($dirs as $dir){
if(!is_dir($... | php | public function setModuleDirs($dirs) {
if(!is_array($dirs) && !($dirs instanceof \Traversable)){
throw new \InvalidArgumentException('Invalid argument $dirs; array or instance of Traversable expected');
}
$this->moduleDirs = array();
foreach($dirs as $dir){
if(!is_dir($... | [
"public",
"function",
"setModuleDirs",
"(",
"$",
"dirs",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"dirs",
")",
"&&",
"!",
"(",
"$",
"dirs",
"instanceof",
"\\",
"Traversable",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
... | Set module directories
@param array $moduleDirs | [
"Set",
"module",
"directories"
] | db1a0bfe1262d555eb11cd0d99625b9ee43d6744 | https://github.com/valu-digital/valusetup/blob/db1a0bfe1262d555eb11cd0d99625b9ee43d6744/src/ValuSetup/Setup/SetupUtilsOptions.php#L56-L71 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.isValidFieldOccurrence | public static function isValidFieldOccurrence ($arg)
{
if ($arg === null || ctype_digit($arg)) {
$arg = (int)$arg;
}
return is_int($arg) && $arg >= 0 && $arg < 100;
} | php | public static function isValidFieldOccurrence ($arg)
{
if ($arg === null || ctype_digit($arg)) {
$arg = (int)$arg;
}
return is_int($arg) && $arg >= 0 && $arg < 100;
} | [
"public",
"static",
"function",
"isValidFieldOccurrence",
"(",
"$",
"arg",
")",
"{",
"if",
"(",
"$",
"arg",
"===",
"null",
"||",
"ctype_digit",
"(",
"$",
"arg",
")",
")",
"{",
"$",
"arg",
"=",
"(",
"int",
")",
"$",
"arg",
";",
"}",
"return",
"is_in... | Return TRUE if argument is a valid field occurrence.
Argument is casted to int iff it is either null or a numeric string.
@param mixed $arg Variable to check
@return boolean TRUE if argument is a valid field occurrence | [
"Return",
"TRUE",
"if",
"argument",
"is",
"a",
"valid",
"field",
"occurrence",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L60-L66 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.match | public static function match ($reBody)
{
if (strpos($reBody, '#') !== false) {
$reBody = str_replace('#', '\#', $reBody);
}
$regexp = "#{$reBody}#D";
return function (Field $field) use ($regexp) {
return (bool)preg_match($regexp, $field->getShorthand());
... | php | public static function match ($reBody)
{
if (strpos($reBody, '#') !== false) {
$reBody = str_replace('#', '\#', $reBody);
}
$regexp = "#{$reBody}#D";
return function (Field $field) use ($regexp) {
return (bool)preg_match($regexp, $field->getShorthand());
... | [
"public",
"static",
"function",
"match",
"(",
"$",
"reBody",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"reBody",
",",
"'#'",
")",
"!==",
"false",
")",
"{",
"$",
"reBody",
"=",
"str_replace",
"(",
"'#'",
",",
"'\\#'",
",",
"$",
"reBody",
")",
";",
... | Return predicate that matches a field shorthand against a regular
expression.
@param string $reBody Body of regular expression
@return callback Predicate | [
"Return",
"predicate",
"that",
"matches",
"a",
"field",
"shorthand",
"against",
"a",
"regular",
"expression",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L75-L84 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.factory | public static function factory (array $field)
{
foreach (array('tag', 'occurrence', 'subfields') as $index) {
if (!array_key_exists($index, $field)) {
throw new InvalidArgumentException("Missing '{$index}' index in field array");
}
}
return new Field(... | php | public static function factory (array $field)
{
foreach (array('tag', 'occurrence', 'subfields') as $index) {
if (!array_key_exists($index, $field)) {
throw new InvalidArgumentException("Missing '{$index}' index in field array");
}
}
return new Field(... | [
"public",
"static",
"function",
"factory",
"(",
"array",
"$",
"field",
")",
"{",
"foreach",
"(",
"array",
"(",
"'tag'",
",",
"'occurrence'",
",",
"'subfields'",
")",
"as",
"$",
"index",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"index",
"... | Return a new field based on its array representation.
@throws InvalidArgumentException Missing `tag', `occurrene', or `subfields' index
@param array $field Array representation of a field
@return \HAB\Pica\Record\Field A shiny new field | [
"Return",
"a",
"new",
"field",
"based",
"on",
"its",
"array",
"representation",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L93-L103 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.setSubfields | public function setSubfields (array $subfields)
{
$this->_subfields = array();
foreach ($subfields as $subfield) {
$this->addSubfield($subfield);
}
} | php | public function setSubfields (array $subfields)
{
$this->_subfields = array();
foreach ($subfields as $subfield) {
$this->addSubfield($subfield);
}
} | [
"public",
"function",
"setSubfields",
"(",
"array",
"$",
"subfields",
")",
"{",
"$",
"this",
"->",
"_subfields",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"subfields",
"as",
"$",
"subfield",
")",
"{",
"$",
"this",
"->",
"addSubfield",
"(",
"$",... | Set the field subfields.
Replaces the subfield list with subfields in argument.
@param array $subfields Subfields
@return void | [
"Set",
"the",
"field",
"subfields",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L174-L180 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.addSubfield | public function addSubfield (\HAB\Pica\Record\Subfield $subfield)
{
if (in_array($subfield, $this->getSubfields(), true)) {
throw new InvalidArgumentException("Cannot add subfield: Subfield already part of the subfield list");
}
$this->_subfields []= $subfield;
} | php | public function addSubfield (\HAB\Pica\Record\Subfield $subfield)
{
if (in_array($subfield, $this->getSubfields(), true)) {
throw new InvalidArgumentException("Cannot add subfield: Subfield already part of the subfield list");
}
$this->_subfields []= $subfield;
} | [
"public",
"function",
"addSubfield",
"(",
"\\",
"HAB",
"\\",
"Pica",
"\\",
"Record",
"\\",
"Subfield",
"$",
"subfield",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"subfield",
",",
"$",
"this",
"->",
"getSubfields",
"(",
")",
",",
"true",
")",
")",
"{... | Add a subfield to the end of the subfield list.
@throws InvalidArgumentException Subfield already present in subfield list
@param \HAB\Pica\Record\Subfield $subfield Subfield to add
@return void | [
"Add",
"a",
"subfield",
"to",
"the",
"end",
"of",
"the",
"subfield",
"list",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L189-L195 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.removeSubfield | public function removeSubfield (\HAB\Pica\Record\Subfield $subfield)
{
$index = array_search($subfield, $this->_subfields, true);
if ($index === false) {
throw new InvalidArgumentException("Cannot remove subfield: Subfield not part of the subfield list");
}
unset($this->... | php | public function removeSubfield (\HAB\Pica\Record\Subfield $subfield)
{
$index = array_search($subfield, $this->_subfields, true);
if ($index === false) {
throw new InvalidArgumentException("Cannot remove subfield: Subfield not part of the subfield list");
}
unset($this->... | [
"public",
"function",
"removeSubfield",
"(",
"\\",
"HAB",
"\\",
"Pica",
"\\",
"Record",
"\\",
"Subfield",
"$",
"subfield",
")",
"{",
"$",
"index",
"=",
"array_search",
"(",
"$",
"subfield",
",",
"$",
"this",
"->",
"_subfields",
",",
"true",
")",
";",
"... | Remove a subfield.
@throws InvalidArgumentException Subfield is not part of the subfield list
@param \HAB\Pica\Record\Subfield $subfield Subfield to delete
@return void | [
"Remove",
"a",
"subfield",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L204-L211 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.getSubfields | public function getSubfields ()
{
if (func_num_args() === 0) {
return $this->_subfields;
} else {
$selected = array();
$codes = array();
$subfields = $this->getSubfields();
array_walk($subfields, function ($value, $index) use (&$codes) { $... | php | public function getSubfields ()
{
if (func_num_args() === 0) {
return $this->_subfields;
} else {
$selected = array();
$codes = array();
$subfields = $this->getSubfields();
array_walk($subfields, function ($value, $index) use (&$codes) { $... | [
"public",
"function",
"getSubfields",
"(",
")",
"{",
"if",
"(",
"func_num_args",
"(",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"_subfields",
";",
"}",
"else",
"{",
"$",
"selected",
"=",
"array",
"(",
")",
";",
"$",
"codes",
"=",
"arr... | Return the field's subfields.
Returns all subfields when called with no arguments.
Otherwise the returned array is constructed as follows:
Each argument is interpreted as a subfield code. The nth element of the
returned array maps to the nth argument in the function call and contains
NULL if the field does not have ... | [
"Return",
"the",
"field",
"s",
"subfields",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L228-L248 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.getNthSubfield | public function getNthSubfield ($code, $n)
{
$count = 0;
foreach ($this->getSubfields() as $subfield) {
if ($subfield->getCode() == $code) {
if ($count == $n) {
return $subfield;
}
$count++;
}
}
... | php | public function getNthSubfield ($code, $n)
{
$count = 0;
foreach ($this->getSubfields() as $subfield) {
if ($subfield->getCode() == $code) {
if ($count == $n) {
return $subfield;
}
$count++;
}
}
... | [
"public",
"function",
"getNthSubfield",
"(",
"$",
"code",
",",
"$",
"n",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getSubfields",
"(",
")",
"as",
"$",
"subfield",
")",
"{",
"if",
"(",
"$",
"subfield",
"->",
"getCode... | Return the nth occurrence of a subfield with specified code.
@param string $code Subfield code
@param integer $n Zero-based subfield index
@return \HAB\Pica\record\Subfield|null The requested subfield or NULL if
none exists | [
"Return",
"the",
"nth",
"occurrence",
"of",
"a",
"subfield",
"with",
"specified",
"code",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L258-L270 | train |
dmj/PicaRecord | src/HAB/Pica/Record/Field.php | Field.getSubfieldsWithCode | public function getSubfieldsWithCode ($code)
{
return array_filter($this->_subfields, function (Subfield $s) use ($code) { return $s->getCode() == $code; });
} | php | public function getSubfieldsWithCode ($code)
{
return array_filter($this->_subfields, function (Subfield $s) use ($code) { return $s->getCode() == $code; });
} | [
"public",
"function",
"getSubfieldsWithCode",
"(",
"$",
"code",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"_subfields",
",",
"function",
"(",
"Subfield",
"$",
"s",
")",
"use",
"(",
"$",
"code",
")",
"{",
"return",
"$",
"s",
"->",
"get... | Return all subfields with the specified code.
@param string $code Subfield code
@return array | [
"Return",
"all",
"subfields",
"with",
"the",
"specified",
"code",
"."
] | bd5577b9a4333aa6156398b94cc870a9377061b8 | https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/Field.php#L293-L296 | train |
fridge-project/dbal | src/Fridge/DBAL/Schema/Check.php | Check.setDefinition | public function setDefinition($definition)
{
if ($definition instanceof Expression) {
$definition = (string) $definition;
}
$this->definition = $definition;
} | php | public function setDefinition($definition)
{
if ($definition instanceof Expression) {
$definition = (string) $definition;
}
$this->definition = $definition;
} | [
"public",
"function",
"setDefinition",
"(",
"$",
"definition",
")",
"{",
"if",
"(",
"$",
"definition",
"instanceof",
"Expression",
")",
"{",
"$",
"definition",
"=",
"(",
"string",
")",
"$",
"definition",
";",
"}",
"$",
"this",
"->",
"definition",
"=",
"$... | Set the definition.
@param string|\Fridge\DBAL\Query\Expression\Expression $definition The definition. | [
"Set",
"the",
"definition",
"."
] | d0b8c3551922d696836487aa0eb1bd74014edcd4 | https://github.com/fridge-project/dbal/blob/d0b8c3551922d696836487aa0eb1bd74014edcd4/src/Fridge/DBAL/Schema/Check.php#L58-L65 | train |
horntell/php-sdk | lib/guzzle/GuzzleHttp/Client.php | Client.getDefaultAdapter | private function getDefaultAdapter()
{
if (extension_loaded('curl')) {
$this->parallelAdapter = new MultiAdapter($this->messageFactory);
$this->adapter = function_exists('curl_reset')
? new CurlAdapter($this->messageFactory)
: $this->parallelAdapter;
... | php | private function getDefaultAdapter()
{
if (extension_loaded('curl')) {
$this->parallelAdapter = new MultiAdapter($this->messageFactory);
$this->adapter = function_exists('curl_reset')
? new CurlAdapter($this->messageFactory)
: $this->parallelAdapter;
... | [
"private",
"function",
"getDefaultAdapter",
"(",
")",
"{",
"if",
"(",
"extension_loaded",
"(",
"'curl'",
")",
")",
"{",
"$",
"this",
"->",
"parallelAdapter",
"=",
"new",
"MultiAdapter",
"(",
"$",
"this",
"->",
"messageFactory",
")",
";",
"$",
"this",
"->",... | Create a default adapter to use based on the environment
@throws \RuntimeException | [
"Create",
"a",
"default",
"adapter",
"to",
"use",
"based",
"on",
"the",
"environment"
] | e5205e9396a21b754d5651a8aa5898da5922a1b7 | https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Client.php#L292-L311 | train |
horntell/php-sdk | lib/guzzle/GuzzleHttp/Client.php | Client.mergeDefaults | private function mergeDefaults(&$options)
{
// Merging optimization for when no headers are present
if (!isset($options['headers'])
|| !isset($this->defaults['headers'])) {
$options = array_replace_recursive($this->defaults, $options);
return null;
}
... | php | private function mergeDefaults(&$options)
{
// Merging optimization for when no headers are present
if (!isset($options['headers'])
|| !isset($this->defaults['headers'])) {
$options = array_replace_recursive($this->defaults, $options);
return null;
}
... | [
"private",
"function",
"mergeDefaults",
"(",
"&",
"$",
"options",
")",
"{",
"// Merging optimization for when no headers are present",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'headers'",
"]",
")",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"defaul... | Merges default options into the array passed by reference and returns
an array of headers that need to be merged in after the request is
created.
@param array $options Options to modify by reference
@return array|null | [
"Merges",
"default",
"options",
"into",
"the",
"array",
"passed",
"by",
"reference",
"and",
"returns",
"an",
"array",
"of",
"headers",
"that",
"need",
"to",
"be",
"merged",
"in",
"after",
"the",
"request",
"is",
"created",
"."
] | e5205e9396a21b754d5651a8aa5898da5922a1b7 | https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Client.php#L382-L396 | train |
mrbase/Smesg | src/Smesg/Adapter/PhpStreamAdapter.php | PhpStreamAdapter.build | protected function build()
{
$content = '';
if (isset($this->parameters) && is_array($this->parameters)) {
$content = http_build_query($this->parameters);
}
if (isset($this->body)) {
$content = $this->body;
}
$content_type = 'application/x-www... | php | protected function build()
{
$content = '';
if (isset($this->parameters) && is_array($this->parameters)) {
$content = http_build_query($this->parameters);
}
if (isset($this->body)) {
$content = $this->body;
}
$content_type = 'application/x-www... | [
"protected",
"function",
"build",
"(",
")",
"{",
"$",
"content",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameters",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"parameters",
")",
")",
"{",
"$",
"content",
"=",
"http_build_qu... | Ready the request for transport
@return PhpStreamAdapter | [
"Ready",
"the",
"request",
"for",
"transport"
] | e9692ed5915f5a9cd4dca0df875935a2c528e128 | https://github.com/mrbase/Smesg/blob/e9692ed5915f5a9cd4dca0df875935a2c528e128/src/Smesg/Adapter/PhpStreamAdapter.php#L159-L186 | train |
mrbase/Smesg | src/Smesg/Adapter/PhpStreamAdapter.php | PhpStreamAdapter.sendRequest | protected function sendRequest()
{
$context = stream_context_create($this->request);
$response = trim(file_get_contents($this->endpoint, FALSE, $context));
$this->response = new Response($http_response_header, $response, $this->request);
return $this->response;
} | php | protected function sendRequest()
{
$context = stream_context_create($this->request);
$response = trim(file_get_contents($this->endpoint, FALSE, $context));
$this->response = new Response($http_response_header, $response, $this->request);
return $this->response;
} | [
"protected",
"function",
"sendRequest",
"(",
")",
"{",
"$",
"context",
"=",
"stream_context_create",
"(",
"$",
"this",
"->",
"request",
")",
";",
"$",
"response",
"=",
"trim",
"(",
"file_get_contents",
"(",
"$",
"this",
"->",
"endpoint",
",",
"FALSE",
",",... | Sends the actual request and returns the response.
@param array $request The stream_wraper options from wich to build the request
@return mixed | [
"Sends",
"the",
"actual",
"request",
"and",
"returns",
"the",
"response",
"."
] | e9692ed5915f5a9cd4dca0df875935a2c528e128 | https://github.com/mrbase/Smesg/blob/e9692ed5915f5a9cd4dca0df875935a2c528e128/src/Smesg/Adapter/PhpStreamAdapter.php#L195-L202 | train |
geoffadams/bedrest-core | library/BedRest/Resource/Mapping/ResourceMetadata.php | ResourceMetadata.setSubResources | public function setSubResources(array $subResources)
{
foreach ($subResources as $name => $mapping) {
if (!is_string($name) || !is_array($mapping)) {
throw Exception::invalidSubResources($this->className);
}
if (!isset($mapping['fieldName'])) {
... | php | public function setSubResources(array $subResources)
{
foreach ($subResources as $name => $mapping) {
if (!is_string($name) || !is_array($mapping)) {
throw Exception::invalidSubResources($this->className);
}
if (!isset($mapping['fieldName'])) {
... | [
"public",
"function",
"setSubResources",
"(",
"array",
"$",
"subResources",
")",
"{",
"foreach",
"(",
"$",
"subResources",
"as",
"$",
"name",
"=>",
"$",
"mapping",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
"||",
"!",
"is_array",
"("... | Sets the set of allowable sub-resources.
@param array $subResources
@throws \BedRest\Resource\Mapping\Exception | [
"Sets",
"the",
"set",
"of",
"allowable",
"sub",
"-",
"resources",
"."
] | a77bf8b7492dfbfb720b201f7ec91a4f03417b5c | https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Resource/Mapping/ResourceMetadata.php#L131-L148 | train |
attogram/shared-media-orm | src/Attogram/SharedMedia/Orm/MediaQuery.php | MediaQuery.format | public function format(array $response)
{
$car = '<br />';
$format = '';
foreach ($response as $media) {
$format .= '<div class="media">'
. '<img src="' . $media->getThumburl() . '"'
. ' width="' . $media->getThumbwidth() . '"'
. ' height="' . ... | php | public function format(array $response)
{
$car = '<br />';
$format = '';
foreach ($response as $media) {
$format .= '<div class="media">'
. '<img src="' . $media->getThumburl() . '"'
. ' width="' . $media->getThumbwidth() . '"'
. ' height="' . ... | [
"public",
"function",
"format",
"(",
"array",
"$",
"response",
")",
"{",
"$",
"car",
"=",
"'<br />'",
";",
"$",
"format",
"=",
"''",
";",
"foreach",
"(",
"$",
"response",
"as",
"$",
"media",
")",
"{",
"$",
"format",
".=",
"'<div class=\"media\">'",
"."... | format a media response as an HTML string
@param array $response
@return string | [
"format",
"a",
"media",
"response",
"as",
"an",
"HTML",
"string"
] | 81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8 | https://github.com/attogram/shared-media-orm/blob/81b5ef7d749b1e50f51e95747ce24cf8ce6f21d8/src/Attogram/SharedMedia/Orm/MediaQuery.php#L109-L124 | train |
ZFrapid/zfrapid-core | src/Task/AbstractTask.php | AbstractTask.filterCamelCaseToUnderscore | public function filterCamelCaseToUnderscore($text)
{
$text = StaticFilter::execute($text, 'Word\CamelCaseToUnderscore');
$text = StaticFilter::execute($text, 'StringToLower');
return $text;
} | php | public function filterCamelCaseToUnderscore($text)
{
$text = StaticFilter::execute($text, 'Word\CamelCaseToUnderscore');
$text = StaticFilter::execute($text, 'StringToLower');
return $text;
} | [
"public",
"function",
"filterCamelCaseToUnderscore",
"(",
"$",
"text",
")",
"{",
"$",
"text",
"=",
"StaticFilter",
"::",
"execute",
"(",
"$",
"text",
",",
"'Word\\CamelCaseToUnderscore'",
")",
";",
"$",
"text",
"=",
"StaticFilter",
"::",
"execute",
"(",
"$",
... | Filter camel case to underscore
@param string $text
@return string | [
"Filter",
"camel",
"case",
"to",
"underscore"
] | 8be56b82f9f5a687619a2b2175fcaa66ad3d2233 | https://github.com/ZFrapid/zfrapid-core/blob/8be56b82f9f5a687619a2b2175fcaa66ad3d2233/src/Task/AbstractTask.php#L86-L92 | train |
zarathustra323/modlr-data | src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php | AbstractDoctrineDriver.doLoadClassMetadata | protected function doLoadClassMetadata($type)
{
if (false === $this->classMetadataExists($type)) {
return null;
}
$className = $this->getClassNameForType($type);
return $this->mf->getMetadataFor($className);
} | php | protected function doLoadClassMetadata($type)
{
if (false === $this->classMetadataExists($type)) {
return null;
}
$className = $this->getClassNameForType($type);
return $this->mf->getMetadataFor($className);
} | [
"protected",
"function",
"doLoadClassMetadata",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"classMetadataExists",
"(",
"$",
"type",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"className",
"=",
"$",
"this",
"->",
"get... | Loads Doctrine ClassMetadata for an entity type.
@param string $type
@return ClassMetadata|null | [
"Loads",
"Doctrine",
"ClassMetadata",
"for",
"an",
"entity",
"type",
"."
] | 7c2c767216055f75abf8cf22e2200f11998ed24e | https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php#L64-L72 | train |
zarathustra323/modlr-data | src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php | AbstractDoctrineDriver.classMetadataExists | protected function classMetadataExists($type)
{
$className = $this->getClassNameForType($type);
try {
$metadata = $this->mf->getMetadataFor($className);
return true;
} catch (MappingException $e) {
return false;
}
return false === $this->sh... | php | protected function classMetadataExists($type)
{
$className = $this->getClassNameForType($type);
try {
$metadata = $this->mf->getMetadataFor($className);
return true;
} catch (MappingException $e) {
return false;
}
return false === $this->sh... | [
"protected",
"function",
"classMetadataExists",
"(",
"$",
"type",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"getClassNameForType",
"(",
"$",
"type",
")",
";",
"try",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"mf",
"->",
"getMetadataFor",
"(... | Determines if Doctrine ClassMetadata exists for an entity type.
@param string $type
@return bool | [
"Determines",
"if",
"Doctrine",
"ClassMetadata",
"exists",
"for",
"an",
"entity",
"type",
"."
] | 7c2c767216055f75abf8cf22e2200f11998ed24e | https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php#L80-L90 | train |
zarathustra323/modlr-data | src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php | AbstractDoctrineDriver.getTypeForClassName | protected function getTypeForClassName($className)
{
if (empty($this->rootNamespace)) {
return $className;
}
return $this->stripNamespace($this->rootNamespace, $className);
} | php | protected function getTypeForClassName($className)
{
if (empty($this->rootNamespace)) {
return $className;
}
return $this->stripNamespace($this->rootNamespace, $className);
} | [
"protected",
"function",
"getTypeForClassName",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"rootNamespace",
")",
")",
"{",
"return",
"$",
"className",
";",
"}",
"return",
"$",
"this",
"->",
"stripNamespace",
"(",
"$",
"t... | Gets the entity type from a Doctrine class name.
@param string $className
@return string | [
"Gets",
"the",
"entity",
"type",
"from",
"a",
"Doctrine",
"class",
"name",
"."
] | 7c2c767216055f75abf8cf22e2200f11998ed24e | https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php#L142-L148 | train |
zarathustra323/modlr-data | src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php | AbstractDoctrineDriver.getClassNameForType | protected function getClassNameForType($type)
{
if (!empty($this->rootNamespace) && strstr($type, $this->rootNamespace)) {
$type = $this->stripNamespace($this->rootNamespace, $type);
}
if (!empty($this->rootNamespace)) {
return sprintf('%s\\%s', $this->rootNamespace, ... | php | protected function getClassNameForType($type)
{
if (!empty($this->rootNamespace) && strstr($type, $this->rootNamespace)) {
$type = $this->stripNamespace($this->rootNamespace, $type);
}
if (!empty($this->rootNamespace)) {
return sprintf('%s\\%s', $this->rootNamespace, ... | [
"protected",
"function",
"getClassNameForType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"rootNamespace",
")",
"&&",
"strstr",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"rootNamespace",
")",
")",
"{",
"$",
"type",
... | Gets the Doctrine class name from an entity type.
@param string $type
@return string | [
"Gets",
"the",
"Doctrine",
"class",
"name",
"from",
"an",
"entity",
"type",
"."
] | 7c2c767216055f75abf8cf22e2200f11998ed24e | https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/AbstractDoctrineDriver.php#L161-L170 | train |
AnonymPHP/Anonym-Route | ActionDispatcher.php | ActionDispatcher.dispatch | public function dispatch($action = [], $group = null)
{
// convert string type to array
if (is_string($action)) {
$action = [
'_controller' => $action
];
}
// find and register route group
$this->registerGroup($group, $action);
... | php | public function dispatch($action = [], $group = null)
{
// convert string type to array
if (is_string($action)) {
$action = [
'_controller' => $action
];
}
// find and register route group
$this->registerGroup($group, $action);
... | [
"public",
"function",
"dispatch",
"(",
"$",
"action",
"=",
"[",
"]",
",",
"$",
"group",
"=",
"null",
")",
"{",
"// convert string type to array",
"if",
"(",
"is_string",
"(",
"$",
"action",
")",
")",
"{",
"$",
"action",
"=",
"[",
"'_controller'",
"=>",
... | Dispatch a action from array
@param array|string $action
@param array|null $group
@return mixed | [
"Dispatch",
"a",
"action",
"from",
"array"
] | bb7f8004fbbd2998af8b0061f404f026f11466ab | https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/ActionDispatcher.php#L85-L123 | train |
AnonymPHP/Anonym-Route | ActionDispatcher.php | ActionDispatcher.findMiddleware | protected function findMiddleware($action)
{
if (is_array($action) && isset($action['_middleware'])) {
return $action['_middleware'];
} elseif (isset($this->group['_middleware'])) {
return $this->group['_middleware'];
}
return false;
} | php | protected function findMiddleware($action)
{
if (is_array($action) && isset($action['_middleware'])) {
return $action['_middleware'];
} elseif (isset($this->group['_middleware'])) {
return $this->group['_middleware'];
}
return false;
} | [
"protected",
"function",
"findMiddleware",
"(",
"$",
"action",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"action",
")",
"&&",
"isset",
"(",
"$",
"action",
"[",
"'_middleware'",
"]",
")",
")",
"{",
"return",
"$",
"action",
"[",
"'_middleware'",
"]",
";... | find and return middleware
@param array $action
@return mixed | [
"find",
"and",
"return",
"middleware"
] | bb7f8004fbbd2998af8b0061f404f026f11466ab | https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/ActionDispatcher.php#L131-L140 | train |
AnonymPHP/Anonym-Route | ActionDispatcher.php | ActionDispatcher.findControllerAndMethod | protected function findControllerAndMethod(array $action)
{
if (isset($action['_controller']) || $action['uses']) {
$controller = isset($action['_controller']) ? $action['_controller'] : $action['uses'];
if (strstr($controller, ':')) {
list($controller, $method) = ex... | php | protected function findControllerAndMethod(array $action)
{
if (isset($action['_controller']) || $action['uses']) {
$controller = isset($action['_controller']) ? $action['_controller'] : $action['uses'];
if (strstr($controller, ':')) {
list($controller, $method) = ex... | [
"protected",
"function",
"findControllerAndMethod",
"(",
"array",
"$",
"action",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"action",
"[",
"'_controller'",
"]",
")",
"||",
"$",
"action",
"[",
"'uses'",
"]",
")",
"{",
"$",
"controller",
"=",
"isset",
"(",
... | find controller, method and namespace in action variable
@param array $action
@return array
@throws ControllerException | [
"find",
"controller",
"method",
"and",
"namespace",
"in",
"action",
"variable"
] | bb7f8004fbbd2998af8b0061f404f026f11466ab | https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/ActionDispatcher.php#L160-L179 | train |
AnonymPHP/Anonym-Route | ActionDispatcher.php | ActionDispatcher.findNamespaceInController | protected function findNamespaceInController(&$controller)
{
if (strstr($controller, '\\')) {
$namespace = explode('\\', $controller);
$controller = end($namespace);
$namespace = rtrim(join('\\', array_slice($namespace, 0, count($namespace) - 1)), '\\');
} else {
... | php | protected function findNamespaceInController(&$controller)
{
if (strstr($controller, '\\')) {
$namespace = explode('\\', $controller);
$controller = end($namespace);
$namespace = rtrim(join('\\', array_slice($namespace, 0, count($namespace) - 1)), '\\');
} else {
... | [
"protected",
"function",
"findNamespaceInController",
"(",
"&",
"$",
"controller",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"controller",
",",
"'\\\\'",
")",
")",
"{",
"$",
"namespace",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"controller",
")",
";",
"$"... | find namespace in controller
@param string $controller
@return array|string | [
"find",
"namespace",
"in",
"controller"
] | bb7f8004fbbd2998af8b0061f404f026f11466ab | https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/ActionDispatcher.php#L187-L198 | train |
AnonymPHP/Anonym-Route | ActionDispatcher.php | ActionDispatcher.handleResponse | private function handleResponse($response)
{
if ($response instanceof View) {
$content = $response->render();
} elseif ($response instanceof Response) {
$content = $response->getContent();
} elseif ($response instanceof Request) {
$content = $response->ge... | php | private function handleResponse($response)
{
if ($response instanceof View) {
$content = $response->render();
} elseif ($response instanceof Response) {
$content = $response->getContent();
} elseif ($response instanceof Request) {
$content = $response->ge... | [
"private",
"function",
"handleResponse",
"(",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"instanceof",
"View",
")",
"{",
"$",
"content",
"=",
"$",
"response",
"->",
"render",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"response",
"instanceof",
... | Handler the controller returned value
@param ViewExecuteInterface|Response|Request|string $response
@return string|bool | [
"Handler",
"the",
"controller",
"returned",
"value"
] | bb7f8004fbbd2998af8b0061f404f026f11466ab | https://github.com/AnonymPHP/Anonym-Route/blob/bb7f8004fbbd2998af8b0061f404f026f11466ab/ActionDispatcher.php#L206-L222 | train |
itkg/core | src/Itkg/Core/Command/DatabaseUpdateCommand.php | DatabaseUpdateCommand.setup | protected function setup(InputInterface $input)
{
return $this->setup
->setForcedRollback($input->getOption('force-rollback'))
->setExecuteQueries($input->getOption('execute'))
->setRollbackedFirst($input->getOption('rollback-first'))
->run();
} | php | protected function setup(InputInterface $input)
{
return $this->setup
->setForcedRollback($input->getOption('force-rollback'))
->setExecuteQueries($input->getOption('execute'))
->setRollbackedFirst($input->getOption('rollback-first'))
->run();
} | [
"protected",
"function",
"setup",
"(",
"InputInterface",
"$",
"input",
")",
"{",
"return",
"$",
"this",
"->",
"setup",
"->",
"setForcedRollback",
"(",
"$",
"input",
"->",
"getOption",
"(",
"'force-rollback'",
")",
")",
"->",
"setExecuteQueries",
"(",
"$",
"i... | Start migration setup
@param \Symfony\Component\Console\Input\InputInterface $input
@return array | [
"Start",
"migration",
"setup"
] | e5e4efb05feb4d23b0df41f2b21fd095103e593b | https://github.com/itkg/core/blob/e5e4efb05feb4d23b0df41f2b21fd095103e593b/src/Itkg/Core/Command/DatabaseUpdateCommand.php#L141-L148 | train |
stellaqua/Waltz.Stagehand | src/Waltz/Stagehand/ClassUtility/MethodObject/PhpMethodObject.php | PhpMethodObject.getDocComment | public function getDocComment ( $withCommentMark = false ) {
$docComment = $this->_reflectionMethod->getDocComment();
if ( $withCommentMark === true ) {
$docComment = PhpDocCommentObject::ltrim($docComment);
} else {
$docComment = PhpDocCommentObject::stripCommentMarks($d... | php | public function getDocComment ( $withCommentMark = false ) {
$docComment = $this->_reflectionMethod->getDocComment();
if ( $withCommentMark === true ) {
$docComment = PhpDocCommentObject::ltrim($docComment);
} else {
$docComment = PhpDocCommentObject::stripCommentMarks($d... | [
"public",
"function",
"getDocComment",
"(",
"$",
"withCommentMark",
"=",
"false",
")",
"{",
"$",
"docComment",
"=",
"$",
"this",
"->",
"_reflectionMethod",
"->",
"getDocComment",
"(",
")",
";",
"if",
"(",
"$",
"withCommentMark",
"===",
"true",
")",
"{",
"$... | Get DocComment of method
@param bool $withCommentMark
@return string DocComment | [
"Get",
"DocComment",
"of",
"method"
] | 01df286751f5b9a5c90c47138dca3709e5bc383b | https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/ClassUtility/MethodObject/PhpMethodObject.php#L72-L80 | train |
koolkode/view-express | src/Tree/ExpressionNode.php | ExpressionNode.compile | public function compile(ExpressCompiler $compiler, $flags = 0)
{
try
{
if($flags & self::FLAG_RAW)
{
$compiler->write($this->expression->compile($compiler->getExpressionContextFactory(), false, '$this->exp'));
}
else
{
$compiler->write("\t\ttry {\n");
if($this->stringify)
{
... | php | public function compile(ExpressCompiler $compiler, $flags = 0)
{
try
{
if($flags & self::FLAG_RAW)
{
$compiler->write($this->expression->compile($compiler->getExpressionContextFactory(), false, '$this->exp'));
}
else
{
$compiler->write("\t\ttry {\n");
if($this->stringify)
{
... | [
"public",
"function",
"compile",
"(",
"ExpressCompiler",
"$",
"compiler",
",",
"$",
"flags",
"=",
"0",
")",
"{",
"try",
"{",
"if",
"(",
"$",
"flags",
"&",
"self",
"::",
"FLAG_RAW",
")",
"{",
"$",
"compiler",
"->",
"write",
"(",
"$",
"this",
"->",
"... | Compiles an expression into PHP code.
@param ExpressCompiler $compiler
@param integer $flags Raw mode is active when an element is morphed from a TagBuilder. | [
"Compiles",
"an",
"expression",
"into",
"PHP",
"code",
"."
] | a8ebe6f373b6bfe8b8818d6264535e8fe063a596 | https://github.com/koolkode/view-express/blob/a8ebe6f373b6bfe8b8818d6264535e8fe063a596/src/Tree/ExpressionNode.php#L76-L122 | train |
Linkvalue-Interne/MajoraFrameworkExtraBundle | src/Majora/Framework/Inflector/Inflector.php | Inflector.normalize | public function normalize(&$data, $format)
{
if (!is_array($data)) {
return $this->$format($data);
}
foreach ($data as $key => $value) {
// already formatted ?
if ($key != ($normalizedKey = $this->$format($key))) {
if (array_key_exists($no... | php | public function normalize(&$data, $format)
{
if (!is_array($data)) {
return $this->$format($data);
}
foreach ($data as $key => $value) {
// already formatted ?
if ($key != ($normalizedKey = $this->$format($key))) {
if (array_key_exists($no... | [
"public",
"function",
"normalize",
"(",
"&",
"$",
"data",
",",
"$",
"format",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"format",
"(",
"$",
"data",
")",
";",
"}",
"foreach",
"(",
"$... | Normalize given data
If an array is given, normalize keys, according to given method
@param string|array &$data
@param string $format
@return string|array
@see for inspiration https://github.com/FriendsOfSymfony/FOSRestBundle/blob/master/Normalizer/CamelKeysNormalizer.php | [
"Normalize",
"given",
"data",
"If",
"an",
"array",
"is",
"given",
"normalize",
"keys",
"according",
"to",
"given",
"method"
] | 6f368380cfc39d27fafb0844e9a53b4d86d7c034 | https://github.com/Linkvalue-Interne/MajoraFrameworkExtraBundle/blob/6f368380cfc39d27fafb0844e9a53b4d86d7c034/src/Majora/Framework/Inflector/Inflector.php#L163-L190 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.fromCurrent | public static function fromCurrent($key = null, $default = null) {
switch(static :: getMethod()) {
case 'get' : $data = $_GET; break;
case 'post' : $data = $_POST; break;
default : $data = null;
}
return static :: from(static :: getMethod(), $key, $default, $data);
} | php | public static function fromCurrent($key = null, $default = null) {
switch(static :: getMethod()) {
case 'get' : $data = $_GET; break;
case 'post' : $data = $_POST; break;
default : $data = null;
}
return static :: from(static :: getMethod(), $key, $default, $data);
} | [
"public",
"static",
"function",
"fromCurrent",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"switch",
"(",
"static",
"::",
"getMethod",
"(",
")",
")",
"{",
"case",
"'get'",
":",
"$",
"data",
"=",
"$",
"_GET",
";",
"brea... | Get variable from the current HTTP method
@param mixed $key
@param mixed $default
@return mixed | [
"Get",
"variable",
"from",
"the",
"current",
"HTTP",
"method"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L169-L179 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.getHeader | public static function getHeader($header) {
$headers = static :: getHeaders();
if(true === isset($headers[$header])) {
return $headers[$header];
}
return null;
} | php | public static function getHeader($header) {
$headers = static :: getHeaders();
if(true === isset($headers[$header])) {
return $headers[$header];
}
return null;
} | [
"public",
"static",
"function",
"getHeader",
"(",
"$",
"header",
")",
"{",
"$",
"headers",
"=",
"static",
"::",
"getHeaders",
"(",
")",
";",
"if",
"(",
"true",
"===",
"isset",
"(",
"$",
"headers",
"[",
"$",
"header",
"]",
")",
")",
"{",
"return",
"... | Get request header by key
@param string $header
@return string | [
"Get",
"request",
"header",
"by",
"key"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L367-L376 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.all | public static function all() {
if(true === isset(static :: $method['data'])) {
return static :: $method['data'];
}
parse_str(static :: getBody(), $vars);
return [
'get' => $_GET,
'post' => $_POST,
'put' => static :: isMethod('put') ? $vars : [],
'delete' => static :: ... | php | public static function all() {
if(true === isset(static :: $method['data'])) {
return static :: $method['data'];
}
parse_str(static :: getBody(), $vars);
return [
'get' => $_GET,
'post' => $_POST,
'put' => static :: isMethod('put') ? $vars : [],
'delete' => static :: ... | [
"public",
"static",
"function",
"all",
"(",
")",
"{",
"if",
"(",
"true",
"===",
"isset",
"(",
"static",
"::",
"$",
"method",
"[",
"'data'",
"]",
")",
")",
"{",
"return",
"static",
"::",
"$",
"method",
"[",
"'data'",
"]",
";",
"}",
"parse_str",
"(",... | Return all the data from get, post, put, delete, patch, connect, head, options and trace
@return array | [
"Return",
"all",
"the",
"data",
"from",
"get",
"post",
"put",
"delete",
"patch",
"connect",
"head",
"options",
"and",
"trace"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L396-L416 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.getIp | public static function getIp() {
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if(isset($_SERVER['HTTP-X-FORWARDED-FOR'])) {
return $_SERVER['HTTP-X-FORWARDED-FOR'];
}
if(isset($_SERVER['HTTP_VIA'])) {
return $_SERVER['HTTP_VIA'];
}
... | php | public static function getIp() {
if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
return $_SERVER['HTTP_X_FORWARDED_FOR'];
}
if(isset($_SERVER['HTTP-X-FORWARDED-FOR'])) {
return $_SERVER['HTTP-X-FORWARDED-FOR'];
}
if(isset($_SERVER['HTTP_VIA'])) {
return $_SERVER['HTTP_VIA'];
}
... | [
"public",
"static",
"function",
"getIp",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
")",
")",
"{",
"return",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_... | Returns the request IP address
@return string | [
"Returns",
"the",
"request",
"IP",
"address"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L579-L596 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.parseUrl | public static function parseUrl($key = null) {
if(null !== $key && false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
$url = [];
$types = [
'host' => 'HTTP_HOST',
... | php | public static function parseUrl($key = null) {
if(null !== $key && false === is_string($key)) {
return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($key)), E_USER_ERROR);
}
$url = [];
$types = [
'host' => 'HTTP_HOST',
... | [
"public",
"static",
"function",
"parseUrl",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"key",
"&&",
"false",
"===",
"is_string",
"(",
"$",
"key",
")",
")",
"{",
"return",
"trigger_error",
"(",
"sprintf",
"(",
"'Argument 1 pa... | Returns parsed url by giving an option key for only the value of that key to return
@param string $key
@return array|string|null | [
"Returns",
"parsed",
"url",
"by",
"giving",
"an",
"option",
"key",
"for",
"only",
"the",
"value",
"of",
"that",
"key",
"to",
"return"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L604-L640 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.get | private static function get($key = null, $default = null) {
if(null !== $key && isset(static :: $method['method'], static :: $method['data'])) {
if(static :: isMethod(static :: $method['method'])) {
$helper = new StringToArray();
$data = $helper -> execute($key, $default, static :: $method['da... | php | private static function get($key = null, $default = null) {
if(null !== $key && isset(static :: $method['method'], static :: $method['data'])) {
if(static :: isMethod(static :: $method['method'])) {
$helper = new StringToArray();
$data = $helper -> execute($key, $default, static :: $method['da... | [
"private",
"static",
"function",
"get",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"key",
"&&",
"isset",
"(",
"static",
"::",
"$",
"method",
"[",
"'method'",
"]",
",",
"static",
"::",
... | Returns variable from source while converting an array from string
@param mixed $key
@param mixed $default
@return mixed | [
"Returns",
"variable",
"from",
"source",
"while",
"converting",
"an",
"array",
"from",
"string"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L649-L689 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.from | private static function from($type, $key, $default, &$source = null) {
if(null === $source) {
if(static :: isMethod($type)) {
$source = [];
static :: parseRawHttpRequest($source);
}
}
static :: $method = ['method' => $type, 'data' => &$source];
if(null !==... | php | private static function from($type, $key, $default, &$source = null) {
if(null === $source) {
if(static :: isMethod($type)) {
$source = [];
static :: parseRawHttpRequest($source);
}
}
static :: $method = ['method' => $type, 'data' => &$source];
if(null !==... | [
"private",
"static",
"function",
"from",
"(",
"$",
"type",
",",
"$",
"key",
",",
"$",
"default",
",",
"&",
"$",
"source",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"source",
")",
"{",
"if",
"(",
"static",
"::",
"isMethod",
"(",
"$",
... | Get variable from variable source
@param string $type
@param mixed $key
@param mixed $default
@param array $source
@return mixed | [
"Get",
"variable",
"from",
"variable",
"source"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L700-L718 | train |
Kris-Kuiper/sFire-Framework | src/HTTP/Request.php | Request.parseRawHttpRequest | private static function parseRawHttpRequest(array &$data) {
if(false === isset($_SERVER['CONTENT_TYPE'])) {
$_SERVER['CONTENT_TYPE'] = '';
}
$input = static :: getBody();
preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches);
if(0 === count($matches)) {
$json = @js... | php | private static function parseRawHttpRequest(array &$data) {
if(false === isset($_SERVER['CONTENT_TYPE'])) {
$_SERVER['CONTENT_TYPE'] = '';
}
$input = static :: getBody();
preg_match('/boundary=(.*)$/', $_SERVER['CONTENT_TYPE'], $matches);
if(0 === count($matches)) {
$json = @js... | [
"private",
"static",
"function",
"parseRawHttpRequest",
"(",
"array",
"&",
"$",
"data",
")",
"{",
"if",
"(",
"false",
"===",
"isset",
"(",
"$",
"_SERVER",
"[",
"'CONTENT_TYPE'",
"]",
")",
")",
"{",
"$",
"_SERVER",
"[",
"'CONTENT_TYPE'",
"]",
"=",
"''",
... | Parses raw HTTP request string
@param array $data | [
"Parses",
"raw",
"HTTP",
"request",
"string"
] | deefe1d9d2b40e7326381e8dcd4f01f9aa61885c | https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/HTTP/Request.php#L725-L771 | train |
melisplatform/melis-calendar | src/Controller/CalendarController.php | CalendarController.renderCalendarLeftmenuAction | public function renderCalendarLeftmenuAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | php | public function renderCalendarLeftmenuAction()
{
$melisKey = $this->params()->fromRoute('melisKey', '');
$view = new ViewModel();
$view->melisKey = $melisKey;
return $view;
} | [
"public",
"function",
"renderCalendarLeftmenuAction",
"(",
")",
"{",
"$",
"melisKey",
"=",
"$",
"this",
"->",
"params",
"(",
")",
"->",
"fromRoute",
"(",
"'melisKey'",
",",
"''",
")",
";",
"$",
"view",
"=",
"new",
"ViewModel",
"(",
")",
";",
"$",
"view... | Render the leftmenu | [
"Render",
"the",
"leftmenu"
] | 1e6df34adc14f03dfdcc6e4ac05d4fa08cb7d223 | https://github.com/melisplatform/melis-calendar/blob/1e6df34adc14f03dfdcc6e4ac05d4fa08cb7d223/src/Controller/CalendarController.php#L21-L27 | train |
eureka-framework/component-http | src/Http/Session.php | Session.set | public function set($name, $value)
{
parent::set($name, $value);
$_SESSION[$name] = $value;
return $this;
} | php | public function set($name, $value)
{
parent::set($name, $value);
$_SESSION[$name] = $value;
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"parent",
"::",
"set",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"$",
"_SESSION",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}"
] | Set value in session.
@param string $name
@param mixed $value
@return self | [
"Set",
"value",
"in",
"session",
"."
] | 698c3b73581a9703a9c932890c57e50f8774607a | https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Session.php#L86-L93 | train |
pixelpolishers/resolver-php-server | src/PixelPolishers/Resolver/Server/Router/Router.php | Router.find | public function find($url)
{
if (!array_key_exists($url, $this->controllerMap)) {
return null;
}
return $this->controllerMap[$url];
} | php | public function find($url)
{
if (!array_key_exists($url, $this->controllerMap)) {
return null;
}
return $this->controllerMap[$url];
} | [
"public",
"function",
"find",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"url",
",",
"$",
"this",
"->",
"controllerMap",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"controllerMap",
"[",
"$",
... | Finds the controller for the given url.
@param string $url The url to parse.
@return ControllerInterface | [
"Finds",
"the",
"controller",
"for",
"the",
"given",
"url",
"."
] | c07505a768b32b30c7c300b3fb7e41d1776cb6e9 | https://github.com/pixelpolishers/resolver-php-server/blob/c07505a768b32b30c7c300b3fb7e41d1776cb6e9/src/PixelPolishers/Resolver/Server/Router/Router.php#L60-L67 | train |
translationexchange/tml-php-clientsdk | library/Tr8n/Tokens/PipedToken.php | PipedToken.parse | public function parse() {
$name_without_parens = preg_replace('/[{}]/', '', $this->full_name);
$parts = explode('|', $name_without_parens);
$name_without_pipes = trim($parts[0]);
$parts = explode('::', $name_without_pipes);
$name_without_case_keys = trim($parts[0]);
arr... | php | public function parse() {
$name_without_parens = preg_replace('/[{}]/', '', $this->full_name);
$parts = explode('|', $name_without_parens);
$name_without_pipes = trim($parts[0]);
$parts = explode('::', $name_without_pipes);
$name_without_case_keys = trim($parts[0]);
arr... | [
"public",
"function",
"parse",
"(",
")",
"{",
"$",
"name_without_parens",
"=",
"preg_replace",
"(",
"'/[{}]/'",
",",
"''",
",",
"$",
"this",
"->",
"full_name",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'|'",
",",
"$",
"name_without_parens",
")",
";",... | Parses token elements | [
"Parses",
"token",
"elements"
] | fe51473824e62cfd883c6aa0c6a3783a16ce8425 | https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Tokens/PipedToken.php#L83-L109 | train |
mossphp/moss-storage | Moss/Storage/Query/AbstractRelational.php | AbstractRelational.with | public function with($relation)
{
foreach ((array) $relation as $node) {
$instance = $this->factory->build($this->model(), $node);
$this->relations[$instance->name()] = $instance;
}
return $this;
} | php | public function with($relation)
{
foreach ((array) $relation as $node) {
$instance = $this->factory->build($this->model(), $node);
$this->relations[$instance->name()] = $instance;
}
return $this;
} | [
"public",
"function",
"with",
"(",
"$",
"relation",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"relation",
"as",
"$",
"node",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"factory",
"->",
"build",
"(",
"$",
"this",
"->",
"model",
"(",
... | Adds relation to query
@param string|array $relation
@return $this
@throws QueryException | [
"Adds",
"relation",
"to",
"query"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/AbstractRelational.php#L51-L59 | train |
mossphp/moss-storage | Moss/Storage/Query/AbstractRelational.php | AbstractRelational.relation | public function relation($relation)
{
list($name, $furtherRelations) = $this->factory->splitRelationName($relation);
if (!isset($this->relations[$name])) {
throw new QueryException(sprintf('Unable to retrieve relation "%s" query, relation does not exists in query "%s"', $name, $this->mo... | php | public function relation($relation)
{
list($name, $furtherRelations) = $this->factory->splitRelationName($relation);
if (!isset($this->relations[$name])) {
throw new QueryException(sprintf('Unable to retrieve relation "%s" query, relation does not exists in query "%s"', $name, $this->mo... | [
"public",
"function",
"relation",
"(",
"$",
"relation",
")",
"{",
"list",
"(",
"$",
"name",
",",
"$",
"furtherRelations",
")",
"=",
"$",
"this",
"->",
"factory",
"->",
"splitRelationName",
"(",
"$",
"relation",
")",
";",
"if",
"(",
"!",
"isset",
"(",
... | Returns relation instance
@param string $relation
@return RelationInterface
@throws QueryException | [
"Returns",
"relation",
"instance"
] | 0d123e7ae6bbfce1e2a18e73bf70997277b430c1 | https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/AbstractRelational.php#L69-L82 | train |
Stinger-Soft/PlatformBundle | Entity/User.php | User.getRealName | public function getRealName() {
if($this->firstname || $this->surname) {
return trim($this->getFirstname() . ' ' . $this->getSurname());
}
return null;
} | php | public function getRealName() {
if($this->firstname || $this->surname) {
return trim($this->getFirstname() . ' ' . $this->getSurname());
}
return null;
} | [
"public",
"function",
"getRealName",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"firstname",
"||",
"$",
"this",
"->",
"surname",
")",
"{",
"return",
"trim",
"(",
"$",
"this",
"->",
"getFirstname",
"(",
")",
".",
"' '",
".",
"$",
"this",
"->",
"ge... | Get realname "Firstname Surname"
@return string | [
"Get",
"realname",
"Firstname",
"Surname"
] | 922b9405e5ddc474f288b6be84af2de9a335ac28 | https://github.com/Stinger-Soft/PlatformBundle/blob/922b9405e5ddc474f288b6be84af2de9a335ac28/Entity/User.php#L91-L96 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/caching/interfaces/TemplateCache.php | TemplateCache.putTemplate | public function putTemplate($cacheKey, Template $template)
{
if ($template->getCacheTime() == null && !is_numeric($template->getCacheTime()))
$template->setCacheTime($this->defaultCacheTime);
$this->put($cacheKey, $template, (int)$template->getCacheTime());
return true;
} | php | public function putTemplate($cacheKey, Template $template)
{
if ($template->getCacheTime() == null && !is_numeric($template->getCacheTime()))
$template->setCacheTime($this->defaultCacheTime);
$this->put($cacheKey, $template, (int)$template->getCacheTime());
return true;
} | [
"public",
"function",
"putTemplate",
"(",
"$",
"cacheKey",
",",
"Template",
"$",
"template",
")",
"{",
"if",
"(",
"$",
"template",
"->",
"getCacheTime",
"(",
")",
"==",
"null",
"&&",
"!",
"is_numeric",
"(",
"$",
"template",
"->",
"getCacheTime",
"(",
")"... | Stores the specified template to cache using the cacheKey specified.
@param string $cacheKey The cacheKey for the Template
@param Template $template The template to store in the cache
@return true | [
"Stores",
"the",
"specified",
"template",
"to",
"cache",
"using",
"the",
"cacheKey",
"specified",
"."
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/caching/interfaces/TemplateCache.php#L169-L177 | train |
wb-crowdfusion/crowdfusion | system/core/classes/libraries/caching/interfaces/TemplateCache.php | TemplateCache.getTemplateCacheKey | public function getTemplateCacheKey(Template $template, $globals)
{
$locals = $template->getLocals();
$cachekey = '';
if($template->isTopTemplate())
$cachekey .= $this->Request->getAdjustedRequestURI();
else
$cachekey .= $template->getContentType().$template... | php | public function getTemplateCacheKey(Template $template, $globals)
{
$locals = $template->getLocals();
$cachekey = '';
if($template->isTopTemplate())
$cachekey .= $this->Request->getAdjustedRequestURI();
else
$cachekey .= $template->getContentType().$template... | [
"public",
"function",
"getTemplateCacheKey",
"(",
"Template",
"$",
"template",
",",
"$",
"globals",
")",
"{",
"$",
"locals",
"=",
"$",
"template",
"->",
"getLocals",
"(",
")",
";",
"$",
"cachekey",
"=",
"''",
";",
"if",
"(",
"$",
"template",
"->",
"isT... | Returns a cacheKey for the specified Template
@param Template $template The template to generate the cacheKey for
@param array $globals An array of globals set on this template
@return string The cache key | [
"Returns",
"a",
"cacheKey",
"for",
"the",
"specified",
"Template"
] | 8cad7988f046a6fefbed07d026cb4ae6706c1217 | https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/caching/interfaces/TemplateCache.php#L187-L229 | train |
siriusSupreme/sirius-support | src/Traits/InteractsWithConfig.php | InteractsWithConfig.ensureRepository | protected function ensureRepository( $repository ) {
if ( $repository === null ) {
return new Repository();
}
if ( $repository instanceof RepostoryContract ) {
return $repository;
}
if ( is_array( $repository ) ) {
return new Repository( $repository );
}
throw new \Logic... | php | protected function ensureRepository( $repository ) {
if ( $repository === null ) {
return new Repository();
}
if ( $repository instanceof RepostoryContract ) {
return $repository;
}
if ( is_array( $repository ) ) {
return new Repository( $repository );
}
throw new \Logic... | [
"protected",
"function",
"ensureRepository",
"(",
"$",
"repository",
")",
"{",
"if",
"(",
"$",
"repository",
"===",
"null",
")",
"{",
"return",
"new",
"Repository",
"(",
")",
";",
"}",
"if",
"(",
"$",
"repository",
"instanceof",
"RepostoryContract",
")",
"... | Ensure a Repository instance.
@param null|array|Repository $repository
@return Repository repository instance
@throw LogicException | [
"Ensure",
"a",
"Repository",
"instance",
"."
] | 80436cf8ae7b95d96bb34cd7297be00c77fc1033 | https://github.com/siriusSupreme/sirius-support/blob/80436cf8ae7b95d96bb34cd7297be00c77fc1033/src/Traits/InteractsWithConfig.php#L60-L74 | train |
Wedeto/DB | src/Query/ConstantValue.php | ConstantValue.toSQL | public function toSQL(Parameters $params, bool $inner_clause)
{
if ($key = $this->getKey())
{
try
{
$params->get($key);
}
catch (\OutOfRangeException $e)
{
$key = null;
}
}
if ($k... | php | public function toSQL(Parameters $params, bool $inner_clause)
{
if ($key = $this->getKey())
{
try
{
$params->get($key);
}
catch (\OutOfRangeException $e)
{
$key = null;
}
}
if ($k... | [
"public",
"function",
"toSQL",
"(",
"Parameters",
"$",
"params",
",",
"bool",
"$",
"inner_clause",
")",
"{",
"if",
"(",
"$",
"key",
"=",
"$",
"this",
"->",
"getKey",
"(",
")",
")",
"{",
"try",
"{",
"$",
"params",
"->",
"get",
"(",
"$",
"key",
")"... | Write a constant as SQL query syntax
@param Parameters $params The query parameters: tables and placeholder values
@return string The generated SQL | [
"Write",
"a",
"constant",
"as",
"SQL",
"query",
"syntax"
] | 715f8f2e3ae6b53c511c40b620921cb9c87e6f62 | https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/ConstantValue.php#L111-L135 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgAttribute.php | PgAttribute.getChildren | public function getChildren()
{
$output = new BaseContainer();
foreach( $this->getRelation()->getChildren() as $childRelation ) {
$childAttribute = $childRelation->getAttributeByName($this->name);
$output->add(
$childAttribute,
$childAttribut... | php | public function getChildren()
{
$output = new BaseContainer();
foreach( $this->getRelation()->getChildren() as $childRelation ) {
$childAttribute = $childRelation->getAttributeByName($this->name);
$output->add(
$childAttribute,
$childAttribut... | [
"public",
"function",
"getChildren",
"(",
")",
"{",
"$",
"output",
"=",
"new",
"BaseContainer",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getRelation",
"(",
")",
"->",
"getChildren",
"(",
")",
"as",
"$",
"childRelation",
")",
"{",
"$",
"childA... | Get all inherited Attributes
@return Container | [
"Get",
"all",
"inherited",
"Attributes"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgAttribute.php#L111-L126 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgAttribute.php | PgAttribute.isInherited | public function isInherited( &$originalColumn = null )
{
$inhcount = $this->attinhcount;
if( $inhcount == 0 ) {
$originalColumn = null;
return false;
}
// short cut to prevent the work of finding the original column
if( func_num_args() === 0 ) {
... | php | public function isInherited( &$originalColumn = null )
{
$inhcount = $this->attinhcount;
if( $inhcount == 0 ) {
$originalColumn = null;
return false;
}
// short cut to prevent the work of finding the original column
if( func_num_args() === 0 ) {
... | [
"public",
"function",
"isInherited",
"(",
"&",
"$",
"originalColumn",
"=",
"null",
")",
"{",
"$",
"inhcount",
"=",
"$",
"this",
"->",
"attinhcount",
";",
"if",
"(",
"$",
"inhcount",
"==",
"0",
")",
"{",
"$",
"originalColumn",
"=",
"null",
";",
"return"... | Is this column inheritied from another relation
@param Column The original inherited column.
@return bool | [
"Is",
"this",
"column",
"inheritied",
"from",
"another",
"relation"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgAttribute.php#L150-L174 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgAttribute.php | PgAttribute.addReference | public function addReference( PgAttribute $primaryKey, $includeChildTables = true )
{
$this->references->add( $primaryKey );
$primaryKey->isReferencedBy->add( $this );
if( $includeChildTables || true ) {
foreach( $primaryKey->getRelation()->getChildren() as $child ) {
... | php | public function addReference( PgAttribute $primaryKey, $includeChildTables = true )
{
$this->references->add( $primaryKey );
$primaryKey->isReferencedBy->add( $this );
if( $includeChildTables || true ) {
foreach( $primaryKey->getRelation()->getChildren() as $child ) {
... | [
"public",
"function",
"addReference",
"(",
"PgAttribute",
"$",
"primaryKey",
",",
"$",
"includeChildTables",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"references",
"->",
"add",
"(",
"$",
"primaryKey",
")",
";",
"$",
"primaryKey",
"->",
"isReferencedBy",
"->... | Add a reference to this attribute
@param Attribute $primaryKey The attribute we're referencing | [
"Add",
"a",
"reference",
"to",
"this",
"attribute"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgAttribute.php#L180-L203 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgAttribute.php | PgAttribute.getSequence | public function getSequence()
{
if( preg_match( "/^nextval\\('([^']+)'::regclass\\)$/", $this->default, $matches ) ) {
return $this->catalog->pgClasses->findOneByName($matches[1]);
}
return null;
} | php | public function getSequence()
{
if( preg_match( "/^nextval\\('([^']+)'::regclass\\)$/", $this->default, $matches ) ) {
return $this->catalog->pgClasses->findOneByName($matches[1]);
}
return null;
} | [
"public",
"function",
"getSequence",
"(",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"/^nextval\\\\('([^']+)'::regclass\\\\)$/\"",
",",
"$",
"this",
"->",
"default",
",",
"$",
"matches",
")",
")",
"{",
"return",
"$",
"this",
"->",
"catalog",
"->",
"pgClasses",
... | Is this column a sequence
@return Sequence|null | [
"Is",
"this",
"column",
"a",
"sequence"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgAttribute.php#L209-L215 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgAttribute.php | PgAttribute.getEntity | public function getEntity()
{
// primary key only
$references = $this->getReferences();
// debug // print_r( $references->map(function($e){ return $e->get('fullyQualifiedName');}) );
foreach( $references as $reference ) {
// only manage references where the reference c... | php | public function getEntity()
{
// primary key only
$references = $this->getReferences();
// debug // print_r( $references->map(function($e){ return $e->get('fullyQualifiedName');}) );
foreach( $references as $reference ) {
// only manage references where the reference c... | [
"public",
"function",
"getEntity",
"(",
")",
"{",
"// primary key only",
"$",
"references",
"=",
"$",
"this",
"->",
"getReferences",
"(",
")",
";",
"// debug // print_r( $references->map(function($e){ return $e->get('fullyQualifiedName');}) );",
"foreach",
"(",
"$",
"refere... | Return a reference to the entity
@return string | [
"Return",
"a",
"reference",
"to",
"the",
"entity"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgAttribute.php#L221-L290 | train |
squareproton/Bond | src/Bond/Pg/Catalog/PgAttribute.php | PgAttribute.isZombie | public function isZombie()
{
$ref = $this->getReferences();
if( $this->isPrimaryKey() and !$ref->isEmpty() ) {
return true;
}
if( $this->notNull and !$ref->isEmpty() ) {
return true;
}
// comment
// if( \Bond\extract_tags( $this->get... | php | public function isZombie()
{
$ref = $this->getReferences();
if( $this->isPrimaryKey() and !$ref->isEmpty() ) {
return true;
}
if( $this->notNull and !$ref->isEmpty() ) {
return true;
}
// comment
// if( \Bond\extract_tags( $this->get... | [
"public",
"function",
"isZombie",
"(",
")",
"{",
"$",
"ref",
"=",
"$",
"this",
"->",
"getReferences",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isPrimaryKey",
"(",
")",
"and",
"!",
"$",
"ref",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"t... | Is this column a zombie-column candidate?
Happens when at least one of the following is true,
1. A column is a primary key fragment and references something else. [Pete. This is essentially the same as 2. because primary key fragments have to be not null]
2. A column references something and is not null
TODO 3. A colu... | [
"Is",
"this",
"column",
"a",
"zombie",
"-",
"column",
"candidate?",
"Happens",
"when",
"at",
"least",
"one",
"of",
"the",
"following",
"is",
"true"
] | a04ad9dd1a35adeaec98237716c2a41ce02b4f1a | https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Catalog/PgAttribute.php#L302-L317 | train |
andela-doladosu/liteorm | src/Helpers/BaseModelHelper.php | BaseModelHelper.getTableFields | protected function getTableFields()
{
$connection = Connection::connect();
$driver = getenv('P_DRIVER');
if ($driver == 'pgsql') {
$describe = '\d ';
}
$describe = 'describe ';
$q = $connection->prepare($describe.$this->getTableName($this->cl... | php | protected function getTableFields()
{
$connection = Connection::connect();
$driver = getenv('P_DRIVER');
if ($driver == 'pgsql') {
$describe = '\d ';
}
$describe = 'describe ';
$q = $connection->prepare($describe.$this->getTableName($this->cl... | [
"protected",
"function",
"getTableFields",
"(",
")",
"{",
"$",
"connection",
"=",
"Connection",
"::",
"connect",
"(",
")",
";",
"$",
"driver",
"=",
"getenv",
"(",
"'P_DRIVER'",
")",
";",
"if",
"(",
"$",
"driver",
"==",
"'pgsql'",
")",
"{",
"$",
"descri... | Get all the column names in a table
@return array | [
"Get",
"all",
"the",
"column",
"names",
"in",
"a",
"table"
] | e97f69e20be4ce0c078a0c25a9a777307d85e9e4 | https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Helpers/BaseModelHelper.php#L18-L33 | train |
andela-doladosu/liteorm | src/Helpers/BaseModelHelper.php | BaseModelHelper.getAssignedValues | protected function getAssignedValues()
{
$tableFields = $this->getTableFields();
$newPropertiesArray = get_object_vars($this);
$columns = $values = $tableData = [];
foreach ($newPropertiesArray as $index => $value) {
if (in_array($index, $tableFields)) {
... | php | protected function getAssignedValues()
{
$tableFields = $this->getTableFields();
$newPropertiesArray = get_object_vars($this);
$columns = $values = $tableData = [];
foreach ($newPropertiesArray as $index => $value) {
if (in_array($index, $tableFields)) {
... | [
"protected",
"function",
"getAssignedValues",
"(",
")",
"{",
"$",
"tableFields",
"=",
"$",
"this",
"->",
"getTableFields",
"(",
")",
";",
"$",
"newPropertiesArray",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"$",
"columns",
"=",
"$",
"values",
"="... | Get user assigned column values
@return array | [
"Get",
"user",
"assigned",
"column",
"values"
] | e97f69e20be4ce0c078a0c25a9a777307d85e9e4 | https://github.com/andela-doladosu/liteorm/blob/e97f69e20be4ce0c078a0c25a9a777307d85e9e4/src/Helpers/BaseModelHelper.php#L65-L83 | train |
g4code/utility | src/Tools.php | Tools.getSpinnerCombinations | public static function getSpinnerCombinations($text)
{
$matches = self::getSpinnerMatches($text);
foreach ($matches as $row) {
if(!preg_match('/[{}]/', $row)) {
$all[] = explode('|', $row);
}
}
$combinations = call_user_func_array(__CLASS__ .... | php | public static function getSpinnerCombinations($text)
{
$matches = self::getSpinnerMatches($text);
foreach ($matches as $row) {
if(!preg_match('/[{}]/', $row)) {
$all[] = explode('|', $row);
}
}
$combinations = call_user_func_array(__CLASS__ .... | [
"public",
"static",
"function",
"getSpinnerCombinations",
"(",
"$",
"text",
")",
"{",
"$",
"matches",
"=",
"self",
"::",
"getSpinnerMatches",
"(",
"$",
"text",
")",
";",
"foreach",
"(",
"$",
"matches",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"!",
"preg_... | Get all combinations for spinner sentence
@param string $text
@return array | [
"Get",
"all",
"combinations",
"for",
"spinner",
"sentence"
] | e0c9138aab61a53d88f32bb66201b075f3f44f1d | https://github.com/g4code/utility/blob/e0c9138aab61a53d88f32bb66201b075f3f44f1d/src/Tools.php#L57-L73 | train |
g4code/utility | src/Tools.php | Tools.arrayCartesian | public static function arrayCartesian() {
$args = func_get_args();
if(count($args) == 0) {
return [[]]; // array with empty array is expected "empty" result
}
$work = array_shift($args);
$cartesian = call_user_func_array(__METHOD__, $args);
$result =... | php | public static function arrayCartesian() {
$args = func_get_args();
if(count($args) == 0) {
return [[]]; // array with empty array is expected "empty" result
}
$work = array_shift($args);
$cartesian = call_user_func_array(__METHOD__, $args);
$result =... | [
"public",
"static",
"function",
"arrayCartesian",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"args",
")",
"==",
"0",
")",
"{",
"return",
"[",
"[",
"]",
"]",
";",
"// array with empty array is expected \... | Calculate cartesian product of multiple arrays
@return multitype:multitype: | [
"Calculate",
"cartesian",
"product",
"of",
"multiple",
"arrays"
] | e0c9138aab61a53d88f32bb66201b075f3f44f1d | https://github.com/g4code/utility/blob/e0c9138aab61a53d88f32bb66201b075f3f44f1d/src/Tools.php#L79-L97 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.