id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
237,900 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/login/driver.php | Auth_Login_Driver.groups | public function groups($driver = null)
{
$result = array();
if ($driver === null)
{
foreach (\Auth::group(true) as $group)
{
method_exists($group, 'groups') and $result = \Arr::merge($result, $group->groups());
}
}
else
{
$result = \Auth::group($driver)->groups();
}
return $result;
} | php | public function groups($driver = null)
{
$result = array();
if ($driver === null)
{
foreach (\Auth::group(true) as $group)
{
method_exists($group, 'groups') and $result = \Arr::merge($result, $group->groups());
}
}
else
{
$result = \Auth::group($driver)->groups();
}
return $result;
} | [
"public",
"function",
"groups",
"(",
"$",
"driver",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"driver",
"===",
"null",
")",
"{",
"foreach",
"(",
"\\",
"Auth",
"::",
"group",
"(",
"true",
")",
"as",
"$",
... | Returns the list of defined groups
@return array | [
"Returns",
"the",
"list",
"of",
"defined",
"groups"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/driver.php#L202-L219 |
237,901 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/login/driver.php | Auth_Login_Driver.roles | public function roles($driver = null)
{
$result = array();
if ($driver === null)
{
foreach (\Auth::acl(true) as $acl)
{
method_exists($acl, 'roles') and $result = \Arr::merge($result, $acl->roles());
}
}
else
{
$result = \Auth::acl($driver)->roles();
}
return $result;
} | php | public function roles($driver = null)
{
$result = array();
if ($driver === null)
{
foreach (\Auth::acl(true) as $acl)
{
method_exists($acl, 'roles') and $result = \Arr::merge($result, $acl->roles());
}
}
else
{
$result = \Auth::acl($driver)->roles();
}
return $result;
} | [
"public",
"function",
"roles",
"(",
"$",
"driver",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"driver",
"===",
"null",
")",
"{",
"foreach",
"(",
"\\",
"Auth",
"::",
"acl",
"(",
"true",
")",
"as",
"$",
"ac... | Returns the list of defined roles
@return array | [
"Returns",
"the",
"list",
"of",
"defined",
"roles"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/driver.php#L226-L243 |
237,902 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/login/driver.php | Auth_Login_Driver.remember_me | public function remember_me($user_id = null)
{
// if no user-id is given, get the current user's id
if ($user_id === null and isset($this->user['id']))
{
$user_id = $this->user['id'];
}
// if we have a session and an id, set it
if (static::$remember_me and $user_id)
{
static::$remember_me->set('user_id', $user_id);
return true;
}
// remember-me not enabled, or no user id available
return false;
} | php | public function remember_me($user_id = null)
{
// if no user-id is given, get the current user's id
if ($user_id === null and isset($this->user['id']))
{
$user_id = $this->user['id'];
}
// if we have a session and an id, set it
if (static::$remember_me and $user_id)
{
static::$remember_me->set('user_id', $user_id);
return true;
}
// remember-me not enabled, or no user id available
return false;
} | [
"public",
"function",
"remember_me",
"(",
"$",
"user_id",
"=",
"null",
")",
"{",
"// if no user-id is given, get the current user's id",
"if",
"(",
"$",
"user_id",
"===",
"null",
"and",
"isset",
"(",
"$",
"this",
"->",
"user",
"[",
"'id'",
"]",
")",
")",
"{"... | Set a remember-me cookie for the passed user id, or for the current
logged-in user if no id was given
@return bool wether or not the cookie was set | [
"Set",
"a",
"remember",
"-",
"me",
"cookie",
"for",
"the",
"passed",
"user",
"id",
"or",
"for",
"the",
"current",
"logged",
"-",
"in",
"user",
"if",
"no",
"id",
"was",
"given"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/login/driver.php#L253-L270 |
237,903 | jmarcher/fluent-curl-wrapper | src/JMarcher/FluentCurl/FluentCurl.php | FluentCurl.doPostRequest | public function doPostRequest(
string $url,
array $data,
array $headers = [],
bool $closeConnection = true
) {
$this->setUrl($url)
->setPostMethod()
->setPostFields($data)
->setMustReturnTransfer()
->setHttpHeader($headers)
->execute(true, $closeConnection);
$this->_call($this->callback ?? function (FluentCurl $instance) {
}, $this);
return $this;
} | php | public function doPostRequest(
string $url,
array $data,
array $headers = [],
bool $closeConnection = true
) {
$this->setUrl($url)
->setPostMethod()
->setPostFields($data)
->setMustReturnTransfer()
->setHttpHeader($headers)
->execute(true, $closeConnection);
$this->_call($this->callback ?? function (FluentCurl $instance) {
}, $this);
return $this;
} | [
"public",
"function",
"doPostRequest",
"(",
"string",
"$",
"url",
",",
"array",
"$",
"data",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"bool",
"$",
"closeConnection",
"=",
"true",
")",
"{",
"$",
"this",
"->",
"setUrl",
"(",
"$",
"url",
")",
... | Wraps all the post functionality into a single method.
@param string $url
@param array $data
@param array $headers | [
"Wraps",
"all",
"the",
"post",
"functionality",
"into",
"a",
"single",
"method",
"."
] | d01989939032f981c825defb773d3bb33703ca22 | https://github.com/jmarcher/fluent-curl-wrapper/blob/d01989939032f981c825defb773d3bb33703ca22/src/JMarcher/FluentCurl/FluentCurl.php#L221-L237 |
237,904 | agalbourdin/agl-core | src/Mvc/Controller/Router.php | Router._checkAcl | private function _checkAcl()
{
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '#' . $this->_view . '#action#' . $this->_action . '/acl');
if ($aclConfig === NULL) {
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '#' . $this->_view . '/acl');
}
if ($aclConfig === NULL) {
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '/acl');
}
if ($aclConfig !== NULL) {
$auth = Agl::getAuth();
$acl = Agl::getSingleton(Agl::AGL_CORE_POOL . '/auth/acl');
if (! $acl->isAllowed($auth->getRole(), $aclConfig)) {
$acl->requestLogin();
}
}
return true;
} | php | private function _checkAcl()
{
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '#' . $this->_view . '#action#' . $this->_action . '/acl');
if ($aclConfig === NULL) {
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '#' . $this->_view . '/acl');
}
if ($aclConfig === NULL) {
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '/acl');
}
if ($aclConfig !== NULL) {
$auth = Agl::getAuth();
$acl = Agl::getSingleton(Agl::AGL_CORE_POOL . '/auth/acl');
if (! $acl->isAllowed($auth->getRole(), $aclConfig)) {
$acl->requestLogin();
}
}
return true;
} | [
"private",
"function",
"_checkAcl",
"(",
")",
"{",
"$",
"aclConfig",
"=",
"Agl",
"::",
"app",
"(",
")",
"->",
"getConfig",
"(",
"'core-layout/modules/'",
".",
"$",
"this",
"->",
"_module",
".",
"'#'",
".",
"$",
"this",
"->",
"_view",
".",
"'#action#'",
... | Check if the current user can trigger the action with its Acl
configuration.
@return bool | [
"Check",
"if",
"the",
"current",
"user",
"can",
"trigger",
"the",
"action",
"with",
"its",
"Acl",
"configuration",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mvc/Controller/Router.php#L104-L125 |
237,905 | agalbourdin/agl-core | src/Mvc/Controller/Router.php | Router.route | public function route()
{
$content = $this->_controller->{$this->_actionMethod}();
if ($this->_controller->isJson()) {
Request::setHeader(Request::HEADER_JSON);
echo json_encode($content);
} else {
echo $content;
}
} | php | public function route()
{
$content = $this->_controller->{$this->_actionMethod}();
if ($this->_controller->isJson()) {
Request::setHeader(Request::HEADER_JSON);
echo json_encode($content);
} else {
echo $content;
}
} | [
"public",
"function",
"route",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"_controller",
"->",
"{",
"$",
"this",
"->",
"_actionMethod",
"}",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_controller",
"->",
"isJson",
"(",
")",
")",
"{",... | Route the request by invoking the corresponding controller and method. | [
"Route",
"the",
"request",
"by",
"invoking",
"the",
"corresponding",
"controller",
"and",
"method",
"."
] | 1db556f9a49488aa9fab6887fefb7141a79ad97d | https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mvc/Controller/Router.php#L130-L140 |
237,906 | na-ji/t411-api | src/Naji/T411/Client.php | Client.sendRequest | private function sendRequest($url, $params, $post = 1, $headers = array('Accept: application/json, text/javascript, */*; q=0.01', 'Content-Type=application/x-www-form-urlencoded'))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (null !== $params)
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params, null, '&'));
curl_setopt($ch, CURLOPT_POST, $post);
curl_setopt($ch, CURLOPT_HEADER, 1);
if (isset($this->token))
{
$headers[] = 'Authorization: '.$this->token;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cacheFolder."/cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cacheFolder."/cookies.txt");
// Fake user agent to simulate a real browser
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36");
curl_setopt($ch, CURLOPT_REFERER, $this->baseUrl);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$info = curl_getinfo($ch);
curl_close($ch);
return array('body' => $body, 'header' => $header, 'url' => $last_url);
} | php | private function sendRequest($url, $params, $post = 1, $headers = array('Accept: application/json, text/javascript, */*; q=0.01', 'Content-Type=application/x-www-form-urlencoded'))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (null !== $params)
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params, null, '&'));
curl_setopt($ch, CURLOPT_POST, $post);
curl_setopt($ch, CURLOPT_HEADER, 1);
if (isset($this->token))
{
$headers[] = 'Authorization: '.$this->token;
}
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_VERBOSE, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cacheFolder."/cookies.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cacheFolder."/cookies.txt");
// Fake user agent to simulate a real browser
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/41.0.2272.76 Chrome/41.0.2272.76 Safari/537.36");
curl_setopt($ch, CURLOPT_REFERER, $this->baseUrl);
$response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$header = substr($response, 0, $header_size);
$body = substr($response, $header_size);
$last_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
$info = curl_getinfo($ch);
curl_close($ch);
return array('body' => $body, 'header' => $header, 'url' => $last_url);
} | [
"private",
"function",
"sendRequest",
"(",
"$",
"url",
",",
"$",
"params",
",",
"$",
"post",
"=",
"1",
",",
"$",
"headers",
"=",
"array",
"(",
"'Accept: application/json, text/javascript, */*; q=0.01'",
",",
"'Content-Type=application/x-www-form-urlencoded'",
")",
")"... | Send a request using cURL
@param string $url URL of the request
@param string $params Post parameters to send
@param string $post Boolean whether it is a post request or not
@return array | [
"Send",
"a",
"request",
"using",
"cURL"
] | 58e04ed18b314a0ebd2169d9ca5fdf75871191b4 | https://github.com/na-ji/t411-api/blob/58e04ed18b314a0ebd2169d9ca5fdf75871191b4/src/Naji/T411/Client.php#L71-L104 |
237,907 | na-ji/t411-api | src/Naji/T411/Client.php | Client.queryString | private function queryString($params)
{
$querystring = '?';
foreach($params as $k => $v) {
$querystring .= $k.'='.urlencode($v).'&';
}
return substr($querystring, 0, -1);
} | php | private function queryString($params)
{
$querystring = '?';
foreach($params as $k => $v) {
$querystring .= $k.'='.urlencode($v).'&';
}
return substr($querystring, 0, -1);
} | [
"private",
"function",
"queryString",
"(",
"$",
"params",
")",
"{",
"$",
"querystring",
"=",
"'?'",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"querystring",
".=",
"$",
"k",
".",
"'='",
".",
"urlencode",
"(",... | Convert an associative array into get parameters
@param array $params Get parameters to convert
@return string | [
"Convert",
"an",
"associative",
"array",
"into",
"get",
"parameters"
] | 58e04ed18b314a0ebd2169d9ca5fdf75871191b4 | https://github.com/na-ji/t411-api/blob/58e04ed18b314a0ebd2169d9ca5fdf75871191b4/src/Naji/T411/Client.php#L112-L119 |
237,908 | na-ji/t411-api | src/Naji/T411/Client.php | Client.saveToken | private function saveToken()
{
$fd = fopen($this->cacheFolder."/token.txt", 'w');
fwrite($fd, $this->token);
fclose($fd);
} | php | private function saveToken()
{
$fd = fopen($this->cacheFolder."/token.txt", 'w');
fwrite($fd, $this->token);
fclose($fd);
} | [
"private",
"function",
"saveToken",
"(",
")",
"{",
"$",
"fd",
"=",
"fopen",
"(",
"$",
"this",
"->",
"cacheFolder",
".",
"\"/token.txt\"",
",",
"'w'",
")",
";",
"fwrite",
"(",
"$",
"fd",
",",
"$",
"this",
"->",
"token",
")",
";",
"fclose",
"(",
"$",... | Save token into a file | [
"Save",
"token",
"into",
"a",
"file"
] | 58e04ed18b314a0ebd2169d9ca5fdf75871191b4 | https://github.com/na-ji/t411-api/blob/58e04ed18b314a0ebd2169d9ca5fdf75871191b4/src/Naji/T411/Client.php#L124-L129 |
237,909 | na-ji/t411-api | src/Naji/T411/Client.php | Client.loadToken | private function loadToken()
{
if (file_exists($this->cacheFolder."/token.txt"))
{
$fd = fopen($this->cacheFolder."/token.txt", 'r');
$this->token = fgets($fd);
fclose($fd);
} else {
$this->connect();
}
} | php | private function loadToken()
{
if (file_exists($this->cacheFolder."/token.txt"))
{
$fd = fopen($this->cacheFolder."/token.txt", 'r');
$this->token = fgets($fd);
fclose($fd);
} else {
$this->connect();
}
} | [
"private",
"function",
"loadToken",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"cacheFolder",
".",
"\"/token.txt\"",
")",
")",
"{",
"$",
"fd",
"=",
"fopen",
"(",
"$",
"this",
"->",
"cacheFolder",
".",
"\"/token.txt\"",
",",
"'r'",
... | Load token from a file | [
"Load",
"token",
"from",
"a",
"file"
] | 58e04ed18b314a0ebd2169d9ca5fdf75871191b4 | https://github.com/na-ji/t411-api/blob/58e04ed18b314a0ebd2169d9ca5fdf75871191b4/src/Naji/T411/Client.php#L134-L144 |
237,910 | na-ji/t411-api | src/Naji/T411/Client.php | Client.connect | public function connect()
{
$request = $this->sendRequest($this->baseUrl."/auth", array('username' => $this->login, 'password' => $this->password), 2);
$response = json_decode($request['body'], true);
if (array_key_exists('error', $response))
{
throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
} else {
$this->token = $response['token'];
$this->saveToken();
}
} | php | public function connect()
{
$request = $this->sendRequest($this->baseUrl."/auth", array('username' => $this->login, 'password' => $this->password), 2);
$response = json_decode($request['body'], true);
if (array_key_exists('error', $response))
{
throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
} else {
$this->token = $response['token'];
$this->saveToken();
}
} | [
"public",
"function",
"connect",
"(",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"this",
"->",
"baseUrl",
".",
"\"/auth\"",
",",
"array",
"(",
"'username'",
"=>",
"$",
"this",
"->",
"login",
",",
"'password'",
"=>",
"$",... | Connect to the T411 website to save the token key | [
"Connect",
"to",
"the",
"T411",
"website",
"to",
"save",
"the",
"token",
"key"
] | 58e04ed18b314a0ebd2169d9ca5fdf75871191b4 | https://github.com/na-ji/t411-api/blob/58e04ed18b314a0ebd2169d9ca5fdf75871191b4/src/Naji/T411/Client.php#L149-L161 |
237,911 | na-ji/t411-api | src/Naji/T411/Client.php | Client.search | public function search($query, $params = array())
{
// Set default category to "Série TV"
if (!isset($params['cid']))
$params['cid'] = '433';
if (!isset($params['offset']))
$params['offset'] = '0';
if (!isset($params['limit']))
$params['limit'] = '200';
$request = $this->sendRequest($this->baseUrl."/torrents/search/".urlencode($query.'*').$this->queryString($params), null, 0);
$response = json_decode($request['body'], true);
if (array_key_exists('error', $response))
{
if ($response['code'] == 201 || $response['code'] == 202) {
$this->connect();
return $this->search($query, $params);
}
throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
} else {
$torrents = array();
if (intval($response['total']) > 0)
{
foreach ($response['torrents'] as $torrent){
$torrents[] = array_merge($torrent, array(
'url' => 'http://www.t411.in/torrents/'.$torrent['rewritename'],
'id' => intval($torrent['id']),
'seeders' => intval($torrent['seeders']),
'leechers' => intval($torrent['leechers']),
'comments' => intval($torrent['comments']),
'size' => intval($torrent['size']),
'times_completed' => intval($torrent['times_completed']),
'owner' => intval($torrent['owner']),
'isVerified' => (boolean) intval($torrent['isVerified']),
));
}
}
return $torrents;
}
} | php | public function search($query, $params = array())
{
// Set default category to "Série TV"
if (!isset($params['cid']))
$params['cid'] = '433';
if (!isset($params['offset']))
$params['offset'] = '0';
if (!isset($params['limit']))
$params['limit'] = '200';
$request = $this->sendRequest($this->baseUrl."/torrents/search/".urlencode($query.'*').$this->queryString($params), null, 0);
$response = json_decode($request['body'], true);
if (array_key_exists('error', $response))
{
if ($response['code'] == 201 || $response['code'] == 202) {
$this->connect();
return $this->search($query, $params);
}
throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
} else {
$torrents = array();
if (intval($response['total']) > 0)
{
foreach ($response['torrents'] as $torrent){
$torrents[] = array_merge($torrent, array(
'url' => 'http://www.t411.in/torrents/'.$torrent['rewritename'],
'id' => intval($torrent['id']),
'seeders' => intval($torrent['seeders']),
'leechers' => intval($torrent['leechers']),
'comments' => intval($torrent['comments']),
'size' => intval($torrent['size']),
'times_completed' => intval($torrent['times_completed']),
'owner' => intval($torrent['owner']),
'isVerified' => (boolean) intval($torrent['isVerified']),
));
}
}
return $torrents;
}
} | [
"public",
"function",
"search",
"(",
"$",
"query",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"// Set default category to \"Série TV\"",
"if",
"(",
"!",
"isset",
"(",
"$",
"params",
"[",
"'cid'",
"]",
")",
")",
"$",
"params",
"[",
"'cid'",
"... | Perform a search on T411 website
@param string $params GET parameters to send (filters)
@return array | [
"Perform",
"a",
"search",
"on",
"T411",
"website"
] | 58e04ed18b314a0ebd2169d9ca5fdf75871191b4 | https://github.com/na-ji/t411-api/blob/58e04ed18b314a0ebd2169d9ca5fdf75871191b4/src/Naji/T411/Client.php#L169-L210 |
237,912 | na-ji/t411-api | src/Naji/T411/Client.php | Client.downloadTorrent | public function downloadTorrent($id, $path = '')
{
$request = $this->sendRequest($this->baseUrl."/torrents/download/".$id, null, 0);
$response = json_decode($request['body'], true);
if (NULL === $response)
{
preg_match('/filename="(.*?)"/i', $request['header'], $filename);
$file = fopen($path.'/'.$filename[1], 'w+');
fwrite($file, $request['body']);
fclose($file);
} else {
if (array_key_exists('error', $response))
{
if ($response['code'] == 201 || $response['code'] == 202) {
$this->connect();
return $this->downloadTorrent($id, $path);
}
throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
}
}
} | php | public function downloadTorrent($id, $path = '')
{
$request = $this->sendRequest($this->baseUrl."/torrents/download/".$id, null, 0);
$response = json_decode($request['body'], true);
if (NULL === $response)
{
preg_match('/filename="(.*?)"/i', $request['header'], $filename);
$file = fopen($path.'/'.$filename[1], 'w+');
fwrite($file, $request['body']);
fclose($file);
} else {
if (array_key_exists('error', $response))
{
if ($response['code'] == 201 || $response['code'] == 202) {
$this->connect();
return $this->downloadTorrent($id, $path);
}
throw new \Exception('Erreur '.$response['code'].' : '.$response['error']);
}
}
} | [
"public",
"function",
"downloadTorrent",
"(",
"$",
"id",
",",
"$",
"path",
"=",
"''",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"sendRequest",
"(",
"$",
"this",
"->",
"baseUrl",
".",
"\"/torrents/download/\"",
".",
"$",
"id",
",",
"null",
",",
... | Download the .torrent from ID
@param string $id The id of the torrent to download
@param string $path The path to save the .torrent | [
"Download",
"the",
".",
"torrent",
"from",
"ID"
] | 58e04ed18b314a0ebd2169d9ca5fdf75871191b4 | https://github.com/na-ji/t411-api/blob/58e04ed18b314a0ebd2169d9ca5fdf75871191b4/src/Naji/T411/Client.php#L218-L240 |
237,913 | las93/apollina2 | Apollina/Template/Functions/ConfigLoad.php | ConfigLoad._constructVar | private function _constructVar($sContent, $aConfVars, $sVarTemplate)
{
foreach ($aConfVars as $mKey => $mOne) {
if (is_array($mOne)) {
$sContent .= $sVarTemplate.'[\''.$mKey.'\'] = array(); ';
$sContent = $this->_constructVar($sContent, $mOne, $sVarTemplate.'[\''.$mKey.'\']');
}
else {
$sContent .= $sVarTemplate.'[\''.$mKey.'\'] = "'.$mOne.'"; ';
}
}
return $sContent;
} | php | private function _constructVar($sContent, $aConfVars, $sVarTemplate)
{
foreach ($aConfVars as $mKey => $mOne) {
if (is_array($mOne)) {
$sContent .= $sVarTemplate.'[\''.$mKey.'\'] = array(); ';
$sContent = $this->_constructVar($sContent, $mOne, $sVarTemplate.'[\''.$mKey.'\']');
}
else {
$sContent .= $sVarTemplate.'[\''.$mKey.'\'] = "'.$mOne.'"; ';
}
}
return $sContent;
} | [
"private",
"function",
"_constructVar",
"(",
"$",
"sContent",
",",
"$",
"aConfVars",
",",
"$",
"sVarTemplate",
")",
"{",
"foreach",
"(",
"$",
"aConfVars",
"as",
"$",
"mKey",
"=>",
"$",
"mOne",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"mOne",
")",
"... | constructor of var on recursive mode
@access private
@param string $sContent content to return
@param array $aConfVars var to parse
@return unknown | [
"constructor",
"of",
"var",
"on",
"recursive",
"mode"
] | 7567e35573d8b3133d49f98816d9f3314a1aaf6a | https://github.com/las93/apollina2/blob/7567e35573d8b3133d49f98816d9f3314a1aaf6a/Apollina/Template/Functions/ConfigLoad.php#L66-L82 |
237,914 | cyberspectrum/i18n-xliff | src/XliffTranslationValue.php | XliffTranslationValue.getSourceElement | protected function getSourceElement(): ?XmlElement
{
$list = $this->node->getElementsByTagNameNS(XliffFile::XLIFF_NS, 'source');
if ($list->length && $element = $list->item(0)) {
/** @var XmlElement $element */
return $element;
}
return null;
} | php | protected function getSourceElement(): ?XmlElement
{
$list = $this->node->getElementsByTagNameNS(XliffFile::XLIFF_NS, 'source');
if ($list->length && $element = $list->item(0)) {
/** @var XmlElement $element */
return $element;
}
return null;
} | [
"protected",
"function",
"getSourceElement",
"(",
")",
":",
"?",
"XmlElement",
"{",
"$",
"list",
"=",
"$",
"this",
"->",
"node",
"->",
"getElementsByTagNameNS",
"(",
"XliffFile",
"::",
"XLIFF_NS",
",",
"'source'",
")",
";",
"if",
"(",
"$",
"list",
"->",
... | Fetch the target element.
@return XmlElement|null | [
"Fetch",
"the",
"target",
"element",
"."
] | 9d03f85a33c8f6fc9acd99770f23800679f130b3 | https://github.com/cyberspectrum/i18n-xliff/blob/9d03f85a33c8f6fc9acd99770f23800679f130b3/src/XliffTranslationValue.php#L112-L121 |
237,915 | drmvc/helpers | src/Helpers/Json.php | Json.isJson | public static function isJson($input): bool
{
$test = json_decode($input);
return ($test instanceof \stdClass || \is_array($test));
} | php | public static function isJson($input): bool
{
$test = json_decode($input);
return ($test instanceof \stdClass || \is_array($test));
} | [
"public",
"static",
"function",
"isJson",
"(",
"$",
"input",
")",
":",
"bool",
"{",
"$",
"test",
"=",
"json_decode",
"(",
"$",
"input",
")",
";",
"return",
"(",
"$",
"test",
"instanceof",
"\\",
"stdClass",
"||",
"\\",
"is_array",
"(",
"$",
"test",
")... | Check if input value is valid JSON
@param mixed $input
@return bool | [
"Check",
"if",
"input",
"value",
"is",
"valid",
"JSON"
] | 1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b | https://github.com/drmvc/helpers/blob/1a9a3f8d4c655b48ddbd61a81eb15688ad207d7b/src/Helpers/Json.php#L17-L21 |
237,916 | RudyMas/manipulator | src/Manipulator/BBCode.php | BBCode.processText | public function processText(string $text): string
{
$text = str_replace("<br>", "", $text);
$text = str_replace("<br/>", "", $text);
$text = str_replace("<br />", "", $text);
$text = str_replace("\n", "<br>", $text);
$text = str_replace("\t", " ", $text);
return preg_replace($this->pattern, $this->replace, $text);
} | php | public function processText(string $text): string
{
$text = str_replace("<br>", "", $text);
$text = str_replace("<br/>", "", $text);
$text = str_replace("<br />", "", $text);
$text = str_replace("\n", "<br>", $text);
$text = str_replace("\t", " ", $text);
return preg_replace($this->pattern, $this->replace, $text);
} | [
"public",
"function",
"processText",
"(",
"string",
"$",
"text",
")",
":",
"string",
"{",
"$",
"text",
"=",
"str_replace",
"(",
"\"<br>\"",
",",
"\"\"",
",",
"$",
"text",
")",
";",
"$",
"text",
"=",
"str_replace",
"(",
"\"<br/>\"",
",",
"\"\"",
",",
... | Process text -> convert BBCode to HTML
@param string $text
@return string | [
"Process",
"text",
"-",
">",
"convert",
"BBCode",
"to",
"HTML"
] | a71c59d2ea5525793118d8a09a243b763029ff2f | https://github.com/RudyMas/manipulator/blob/a71c59d2ea5525793118d8a09a243b763029ff2f/src/Manipulator/BBCode.php#L71-L80 |
237,917 | jlaso/tradukoj-connector | src/ClientSocketApi.php | ClientSocketApi.serverSocketRequest | protected function serverSocketRequest()
{
$base = function_exists('lzf_compress') ? self::REQUEST_SOCKET_LZF : self::REQUEST_SOCKET_NON_LZF;
$url = sprintf("%s%s/%d", $this->clientApiConfig->getEndpoint(), $base, $this->clientApiConfig->getProjectId());
$data = array(
'key' => $this->clientApiConfig->getKey(),
'secret' => $this->clientApiConfig->getSecret(),
);
return $this->postClient->call($url, $data);
} | php | protected function serverSocketRequest()
{
$base = function_exists('lzf_compress') ? self::REQUEST_SOCKET_LZF : self::REQUEST_SOCKET_NON_LZF;
$url = sprintf("%s%s/%d", $this->clientApiConfig->getEndpoint(), $base, $this->clientApiConfig->getProjectId());
$data = array(
'key' => $this->clientApiConfig->getKey(),
'secret' => $this->clientApiConfig->getSecret(),
);
return $this->postClient->call($url, $data);
} | [
"protected",
"function",
"serverSocketRequest",
"(",
")",
"{",
"$",
"base",
"=",
"function_exists",
"(",
"'lzf_compress'",
")",
"?",
"self",
"::",
"REQUEST_SOCKET_LZF",
":",
"self",
"::",
"REQUEST_SOCKET_NON_LZF",
";",
"$",
"url",
"=",
"sprintf",
"(",
"\"%s%s/%d... | Request to server a socket, if okay server returns with the url and port opened.
@return mixed
@throws CreateSocketException | [
"Request",
"to",
"server",
"a",
"socket",
"if",
"okay",
"server",
"returns",
"with",
"the",
"url",
"and",
"port",
"opened",
"."
] | cfaa51ae36bf590bb53e373a3daee2f2c2fd646f | https://github.com/jlaso/tradukoj-connector/blob/cfaa51ae36bf590bb53e373a3daee2f2c2fd646f/src/ClientSocketApi.php#L137-L147 |
237,918 | jlaso/tradukoj-connector | src/ClientSocketApi.php | ClientSocketApi.send | protected function send($msg)
{
$msg .= PHP_EOL;
return $this->socket->write($msg, strlen($msg));
} | php | protected function send($msg)
{
$msg .= PHP_EOL;
return $this->socket->write($msg, strlen($msg));
} | [
"protected",
"function",
"send",
"(",
"$",
"msg",
")",
"{",
"$",
"msg",
".=",
"PHP_EOL",
";",
"return",
"$",
"this",
"->",
"socket",
"->",
"write",
"(",
"$",
"msg",
",",
"strlen",
"(",
"$",
"msg",
")",
")",
";",
"}"
] | Atomic send of a string trough the socket.
@param $msg
@return int | [
"Atomic",
"send",
"of",
"a",
"string",
"trough",
"the",
"socket",
"."
] | cfaa51ae36bf590bb53e373a3daee2f2c2fd646f | https://github.com/jlaso/tradukoj-connector/blob/cfaa51ae36bf590bb53e373a3daee2f2c2fd646f/src/ClientSocketApi.php#L224-L229 |
237,919 | dazarobbo/Cola | src/Functions/Object.php | Object.copy | public static function copy($value){
if(\is_object($value)){
if(\is_callable($value)){
return \Closure::bind($value, null);
}
return clone $value;
}
return $value;
} | php | public static function copy($value){
if(\is_object($value)){
if(\is_callable($value)){
return \Closure::bind($value, null);
}
return clone $value;
}
return $value;
} | [
"public",
"static",
"function",
"copy",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"\\",
"is_callable",
"(",
"$",
"value",
")",
")",
"{",
"return",
"\\",
"Closure",
"::",
"bind",
"(",
"... | Makes a deep copy of any given value
@param mixed $value
@return mixed | [
"Makes",
"a",
"deep",
"copy",
"of",
"any",
"given",
"value"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/Functions/Object.php#L20-L34 |
237,920 | dazarobbo/Cola | src/Functions/Object.php | Object.propertiesExist | public static function propertiesExist($obj /*, $prop1, $prop2, etc... */){
for($i = 1, $l = \func_num_args() - 1; $i <= $l; ++$i){
if(!\property_exists($obj, \func_get_arg($i))){
return false;
}
}
return true;
} | php | public static function propertiesExist($obj /*, $prop1, $prop2, etc... */){
for($i = 1, $l = \func_num_args() - 1; $i <= $l; ++$i){
if(!\property_exists($obj, \func_get_arg($i))){
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"propertiesExist",
"(",
"$",
"obj",
"/*, $prop1, $prop2, etc... */",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"1",
",",
"$",
"l",
"=",
"\\",
"func_num_args",
"(",
")",
"-",
"1",
";",
"$",
"i",
"<=",
"$",
"l",
";",
"++",
... | Checks if the given properties exists in the specified object
@param mixed $obj The object to check
@param string $prop1 to check for
@return boolean true if all properties are found, otherwise false | [
"Checks",
"if",
"the",
"given",
"properties",
"exists",
"in",
"the",
"specified",
"object"
] | b101b73ebeb8a571345a303cbc75168f60d0e64f | https://github.com/dazarobbo/Cola/blob/b101b73ebeb8a571345a303cbc75168f60d0e64f/src/Functions/Object.php#L43-L53 |
237,921 | asika32764/joomla-framework-console | Command/HelpCommand.php | HelpCommand.getDescribedCommand | protected function getDescribedCommand($args)
{
$this->describedCommand = $command = $this->getParent();
foreach ($args as $arg)
{
$command = $command->getChild($arg);
if (!$command)
{
throw new CommandNotFoundException(sprintf('Command: "%s" not found.', implode(' ', $args)), $this->describedCommand, $arg);
}
// Set current to describedCommand that we can use it auto complete wrong args.
$this->describedCommand = $command;
}
return $command;
} | php | protected function getDescribedCommand($args)
{
$this->describedCommand = $command = $this->getParent();
foreach ($args as $arg)
{
$command = $command->getChild($arg);
if (!$command)
{
throw new CommandNotFoundException(sprintf('Command: "%s" not found.', implode(' ', $args)), $this->describedCommand, $arg);
}
// Set current to describedCommand that we can use it auto complete wrong args.
$this->describedCommand = $command;
}
return $command;
} | [
"protected",
"function",
"getDescribedCommand",
"(",
"$",
"args",
")",
"{",
"$",
"this",
"->",
"describedCommand",
"=",
"$",
"command",
"=",
"$",
"this",
"->",
"getParent",
"(",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"$",
... | Get the command we want to describe.
@param array $args Arguments of this execute.
@return AbstractCommand|null
@since 1.0
@throws CommandNotFoundException | [
"Get",
"the",
"command",
"we",
"want",
"to",
"describe",
"."
] | fe28cf9e1c694049e015121e2bd041268e814249 | https://github.com/asika32764/joomla-framework-console/blob/fe28cf9e1c694049e015121e2bd041268e814249/Command/HelpCommand.php#L102-L120 |
237,922 | harpya/ufw-base | src/ufw/utils/BackgroundProcess.php | BackgroundProcess.doProcess | public function doProcess(){
$command = 'nohup '.$this->command.' > /dev/null 2>&1 & echo $!';
exec($command ,$pross);
$this->pid = (int)$pross[0];
} | php | public function doProcess(){
$command = 'nohup '.$this->command.' > /dev/null 2>&1 & echo $!';
exec($command ,$pross);
$this->pid = (int)$pross[0];
} | [
"public",
"function",
"doProcess",
"(",
")",
"{",
"$",
"command",
"=",
"'nohup '",
".",
"$",
"this",
"->",
"command",
".",
"' > /dev/null 2>&1 & echo $!'",
";",
"exec",
"(",
"$",
"command",
",",
"$",
"pross",
")",
";",
"$",
"this",
"->",
"pid",
"=",
"(... | do the process in background | [
"do",
"the",
"process",
"in",
"background"
] | 9e2db1d9625f4b875783f98830e0410cf4fd125b | https://github.com/harpya/ufw-base/blob/9e2db1d9625f4b875783f98830e0410cf4fd125b/src/ufw/utils/BackgroundProcess.php#L62-L66 |
237,923 | plansys/yard | src/Lib/HSerializer.php | HSerializer.getValue | private function getValue($value)
{
if ($this->isBoolean($value)) {
return (strtolower($value) === 'true');
} elseif ($this->isInteger($value)) {
return (int)$value;
} elseif ($this->isNumber($value)) {
return (float)$value;
}
return $value;
} | php | private function getValue($value)
{
if ($this->isBoolean($value)) {
return (strtolower($value) === 'true');
} elseif ($this->isInteger($value)) {
return (int)$value;
} elseif ($this->isNumber($value)) {
return (float)$value;
}
return $value;
} | [
"private",
"function",
"getValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isBoolean",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"strtolower",
"(",
"$",
"value",
")",
"===",
"'true'",
")",
";",
"}",
"elseif",
"(",
"$",
... | Get value prepared for Json data structure
@param mixed $value
@return mixed | [
"Get",
"value",
"prepared",
"for",
"Json",
"data",
"structure"
] | eba88264b53402d3465e7b6625e9a21b7dae6926 | https://github.com/plansys/yard/blob/eba88264b53402d3465e7b6625e9a21b7dae6926/src/Lib/HSerializer.php#L153-L163 |
237,924 | mtoolkit/mtoolkit-model | src/sql/MSqlField.php | MSqlField.clear | public function clear(): void
{
$this->value = null;
$this->defaultValue = null;
$this->lenght = -1;
$this->type = MDataType::UNKNOWN;
$this->name = null;
} | php | public function clear(): void
{
$this->value = null;
$this->defaultValue = null;
$this->lenght = -1;
$this->type = MDataType::UNKNOWN;
$this->name = null;
} | [
"public",
"function",
"clear",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"value",
"=",
"null",
";",
"$",
"this",
"->",
"defaultValue",
"=",
"null",
";",
"$",
"this",
"->",
"lenght",
"=",
"-",
"1",
";",
"$",
"this",
"->",
"type",
"=",
"MDataT... | Clears the value of the field and sets it to NULL. | [
"Clears",
"the",
"value",
"of",
"the",
"field",
"and",
"sets",
"it",
"to",
"NULL",
"."
] | 7836bc1d32b30c14273c7636dc7388ecd347953d | https://github.com/mtoolkit/mtoolkit-model/blob/7836bc1d32b30c14273c7636dc7388ecd347953d/src/sql/MSqlField.php#L58-L65 |
237,925 | znframework/package-payment | Nestpay/Response.php | Response.isValidHash | public function isValidHash() : Bool
{
$hash = $_POST['HASHPARAMS'];
$hashEx = explode(':', $hash);
$real = NULL;
foreach( $hashEx as $part )
{
if( ! empty($_POST[$part]) )
{
$real .= $_POST[$part];
}
}
return $real === $_POST['HASHPARAMSVAL'] && $_POST['HASH'] === base64_encode(pack('H*',sha1($real . $_POST['storeKey'])));
} | php | public function isValidHash() : Bool
{
$hash = $_POST['HASHPARAMS'];
$hashEx = explode(':', $hash);
$real = NULL;
foreach( $hashEx as $part )
{
if( ! empty($_POST[$part]) )
{
$real .= $_POST[$part];
}
}
return $real === $_POST['HASHPARAMSVAL'] && $_POST['HASH'] === base64_encode(pack('H*',sha1($real . $_POST['storeKey'])));
} | [
"public",
"function",
"isValidHash",
"(",
")",
":",
"Bool",
"{",
"$",
"hash",
"=",
"$",
"_POST",
"[",
"'HASHPARAMS'",
"]",
";",
"$",
"hashEx",
"=",
"explode",
"(",
"':'",
",",
"$",
"hash",
")",
";",
"$",
"real",
"=",
"NULL",
";",
"foreach",
"(",
... | Is valid hash
@param string $storeKey
@return bool | [
"Is",
"valid",
"hash"
] | 6864a8510947fb19a50668bdd14840d1d0988d19 | https://github.com/znframework/package-payment/blob/6864a8510947fb19a50668bdd14840d1d0988d19/Nestpay/Response.php#L31-L46 |
237,926 | ekyna/UserBundle | Controller/AccountController.php | AccountController.homeAction | public function homeAction(Request $request)
{
// TODO check if AuthenticationCredentialsNotFoundException is raised without a cookie.
if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$request->getSession()->set('_ekyna.login_success.target_path', 'fos_user_profile_show');
return $this->redirect($this->generateUrl('fos_user_security_login'));
}
return $this->redirect($this->generateUrl('fos_user_profile_show'));
} | php | public function homeAction(Request $request)
{
// TODO check if AuthenticationCredentialsNotFoundException is raised without a cookie.
if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$request->getSession()->set('_ekyna.login_success.target_path', 'fos_user_profile_show');
return $this->redirect($this->generateUrl('fos_user_security_login'));
}
return $this->redirect($this->generateUrl('fos_user_profile_show'));
} | [
"public",
"function",
"homeAction",
"(",
"Request",
"$",
"request",
")",
"{",
"// TODO check if AuthenticationCredentialsNotFoundException is raised without a cookie.",
"if",
"(",
"!",
"$",
"this",
"->",
"get",
"(",
"'security.authorization_checker'",
")",
"->",
"isGranted"... | Home action.
@param Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse | [
"Home",
"action",
"."
] | e38d56aee978148a312a923b9e70bdaad1a381bf | https://github.com/ekyna/UserBundle/blob/e38d56aee978148a312a923b9e70bdaad1a381bf/Controller/AccountController.php#L21-L29 |
237,927 | arvici/framework | src/Arvici/Component/Router.php | Router.group | public static function group($group, \Closure $closure)
{
self::$group = $group;
call_user_func($closure, self::getInstance());
self::$group = null;
} | php | public static function group($group, \Closure $closure)
{
self::$group = $group;
call_user_func($closure, self::getInstance());
self::$group = null;
} | [
"public",
"static",
"function",
"group",
"(",
"$",
"group",
",",
"\\",
"Closure",
"$",
"closure",
")",
"{",
"self",
"::",
"$",
"group",
"=",
"$",
"group",
";",
"call_user_func",
"(",
"$",
"closure",
",",
"self",
"::",
"getInstance",
"(",
")",
")",
";... | Appending route entries to group.
@param string $group
@param \Closure $closure | [
"Appending",
"route",
"entries",
"to",
"group",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Component/Router.php#L62-L67 |
237,928 | arvici/framework | src/Arvici/Component/Router.php | Router.api | public function api($match, $apiController, $kwargs = [], $methods = null)
{
if (is_string($methods)) {
$methods = array($methods);
}
if (! is_array($kwargs)) { // @codeCoverageIgnore
$kwargs = []; // @codeCoverageIgnore
}
if ($methods === null) {
$methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
}
$methods = array_map('strtoupper', $methods);
if ($match === '') { // @codeCoverageIgnore
throw new RouterException('Your API route must contain a first match field when registering!'); // @codeCoverageIgnore
}
if (substr($match, 0, 1) !== '/') {
$match = '/' . $match;
}
foreach ($methods as $method) {
switch ($method)
{
case 'GET':
$this->get($match, $apiController, array_merge($kwargs, ['api_method' => 'list']));
$this->get($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'retrieve']));
break;
case 'POST':
$this->post($match, $apiController, array_merge($kwargs, ['api_method' => 'create']));
break;
case 'PUT':
$this->put($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'update']));
break;
case 'PATCH':
$this->patch($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'partialUpdate']));
break;
case 'DELETE':
$this->delete($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'destroy']));
break;
}
}
} | php | public function api($match, $apiController, $kwargs = [], $methods = null)
{
if (is_string($methods)) {
$methods = array($methods);
}
if (! is_array($kwargs)) { // @codeCoverageIgnore
$kwargs = []; // @codeCoverageIgnore
}
if ($methods === null) {
$methods = ['GET', 'POST', 'PUT', 'DELETE', 'PATCH'];
}
$methods = array_map('strtoupper', $methods);
if ($match === '') { // @codeCoverageIgnore
throw new RouterException('Your API route must contain a first match field when registering!'); // @codeCoverageIgnore
}
if (substr($match, 0, 1) !== '/') {
$match = '/' . $match;
}
foreach ($methods as $method) {
switch ($method)
{
case 'GET':
$this->get($match, $apiController, array_merge($kwargs, ['api_method' => 'list']));
$this->get($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'retrieve']));
break;
case 'POST':
$this->post($match, $apiController, array_merge($kwargs, ['api_method' => 'create']));
break;
case 'PUT':
$this->put($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'update']));
break;
case 'PATCH':
$this->patch($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'partialUpdate']));
break;
case 'DELETE':
$this->delete($match . '/(!?)', $apiController, array_merge($kwargs, ['api_method' => 'destroy']));
break;
}
}
} | [
"public",
"function",
"api",
"(",
"$",
"match",
",",
"$",
"apiController",
",",
"$",
"kwargs",
"=",
"[",
"]",
",",
"$",
"methods",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"methods",
")",
")",
"{",
"$",
"methods",
"=",
"array",
"(... | Register an API entity class with a base match.
@param string $match The base match for the list and create routes. The other routes will contain this as prefix.
@param string $apiController Api Controller class name, with full namespace notation.
@param array $kwargs Any optional kwargs that will be passed to the controller (via route).
@param array|null $methods Methods to generate. Null for all. Example: ['GET'] or ['GET', 'POST'].
@throws RouterException | [
"Register",
"an",
"API",
"entity",
"class",
"with",
"a",
"base",
"match",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Component/Router.php#L79-L121 |
237,929 | arvici/framework | src/Arvici/Component/Router.php | Router.get | public function get($match, $callback, $kwargs = [])
{
$this->addRoute(new Route($match, 'GET', $callback, self::$group, $kwargs));
} | php | public function get($match, $callback, $kwargs = [])
{
$this->addRoute(new Route($match, 'GET', $callback, self::$group, $kwargs));
} | [
"public",
"function",
"get",
"(",
"$",
"match",
",",
"$",
"callback",
",",
"$",
"kwargs",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"addRoute",
"(",
"new",
"Route",
"(",
"$",
"match",
",",
"'GET'",
",",
"$",
"callback",
",",
"self",
"::",
"$",
... | Add route for GET method.
@param string $match
@param string|callable $callback
@param array $kwargs Any optional kwargs that will be passed to the controller (via route).
@codeCoverageIgnore | [
"Add",
"route",
"for",
"GET",
"method",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Component/Router.php#L132-L135 |
237,930 | arvici/framework | src/Arvici/Component/Router.php | Router.before | public function before($callback, $group = null, $methods = array())
{
$methods = array_map('strtoupper', $methods);
if ($group === null) {
if (self::$group !== null) {
$group = self::$group;
} else {
$group = 'global';
}
}
$this->addMiddleware(new Middleware($callback, 'before', $methods, $group));
} | php | public function before($callback, $group = null, $methods = array())
{
$methods = array_map('strtoupper', $methods);
if ($group === null) {
if (self::$group !== null) {
$group = self::$group;
} else {
$group = 'global';
}
}
$this->addMiddleware(new Middleware($callback, 'before', $methods, $group));
} | [
"public",
"function",
"before",
"(",
"$",
"callback",
",",
"$",
"group",
"=",
"null",
",",
"$",
"methods",
"=",
"array",
"(",
")",
")",
"{",
"$",
"methods",
"=",
"array_map",
"(",
"'strtoupper'",
",",
"$",
"methods",
")",
";",
"if",
"(",
"$",
"grou... | Add before middleware.
@param string|callable $callback
@param string $group Optional group. leave empty for global. When in group define it will be filled with the active group name!
@param array $methods Array of methods, leave undefined for all methods, 'GET'/'POST'/'PUT'/'DELETE'. | [
"Add",
"before",
"middleware",
"."
] | 4d0933912fef8f9edc756ef1ace009e96d9fc4b1 | https://github.com/arvici/framework/blob/4d0933912fef8f9edc756ef1ace009e96d9fc4b1/src/Arvici/Component/Router.php#L214-L226 |
237,931 | novuso/common | src/Application/Mail/Message/Message.php | Message.addFrom | public function addFrom(string $address, ?string $name = null): Message
{
$this->from[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | public function addFrom(string $address, ?string $name = null): Message
{
$this->from[] = [
'address' => $address,
'name' => $name
];
return $this;
} | [
"public",
"function",
"addFrom",
"(",
"string",
"$",
"address",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Message",
"{",
"$",
"this",
"->",
"from",
"[",
"]",
"=",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'name'",
"=>",
"$",
"nam... | Adds a From address
@param string $address The address
@param string|null $name The name
@return Message | [
"Adds",
"a",
"From",
"address"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L186-L194 |
237,932 | novuso/common | src/Application/Mail/Message/Message.php | Message.addTo | public function addTo(string $address, ?string $name = null): Message
{
$this->to[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | public function addTo(string $address, ?string $name = null): Message
{
$this->to[] = [
'address' => $address,
'name' => $name
];
return $this;
} | [
"public",
"function",
"addTo",
"(",
"string",
"$",
"address",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Message",
"{",
"$",
"this",
"->",
"to",
"[",
"]",
"=",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'name'",
"=>",
"$",
"name",
... | Adds a To address
@param string $address The address
@param string|null $name The name
@return Message | [
"Adds",
"a",
"To",
"address"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L219-L227 |
237,933 | novuso/common | src/Application/Mail/Message/Message.php | Message.addReplyTo | public function addReplyTo(string $address, ?string $name = null): Message
{
$this->replyTo[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | public function addReplyTo(string $address, ?string $name = null): Message
{
$this->replyTo[] = [
'address' => $address,
'name' => $name
];
return $this;
} | [
"public",
"function",
"addReplyTo",
"(",
"string",
"$",
"address",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Message",
"{",
"$",
"this",
"->",
"replyTo",
"[",
"]",
"=",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'name'",
"=>",
"$",
... | Adds a Reply-To address
@param string $address The address
@param string|null $name The name
@return Message | [
"Adds",
"a",
"Reply",
"-",
"To",
"address"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L252-L260 |
237,934 | novuso/common | src/Application/Mail/Message/Message.php | Message.addCc | public function addCc(string $address, ?string $name = null): Message
{
$this->cc[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | public function addCc(string $address, ?string $name = null): Message
{
$this->cc[] = [
'address' => $address,
'name' => $name
];
return $this;
} | [
"public",
"function",
"addCc",
"(",
"string",
"$",
"address",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Message",
"{",
"$",
"this",
"->",
"cc",
"[",
"]",
"=",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'name'",
"=>",
"$",
"name",
... | Adds a CC address
@param string $address The address
@param string|null $name The name
@return Message | [
"Adds",
"a",
"CC",
"address"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L285-L293 |
237,935 | novuso/common | src/Application/Mail/Message/Message.php | Message.addBcc | public function addBcc(string $address, ?string $name = null): Message
{
$this->bcc[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | public function addBcc(string $address, ?string $name = null): Message
{
$this->bcc[] = [
'address' => $address,
'name' => $name
];
return $this;
} | [
"public",
"function",
"addBcc",
"(",
"string",
"$",
"address",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Message",
"{",
"$",
"this",
"->",
"bcc",
"[",
"]",
"=",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'name'",
"=>",
"$",
"name"... | Adds a BCC address
@param string $address The address
@param string|null $name The name
@return Message | [
"Adds",
"a",
"BCC",
"address"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L318-L326 |
237,936 | novuso/common | src/Application/Mail/Message/Message.php | Message.addContent | public function addContent(string $content, string $contentType, ?string $charset = null): Message
{
$charset = $charset ?: $this->getCharset();
$this->content[] = [
'content' => $content,
'content_type' => $contentType,
'charset' => $charset
];
return $this;
} | php | public function addContent(string $content, string $contentType, ?string $charset = null): Message
{
$charset = $charset ?: $this->getCharset();
$this->content[] = [
'content' => $content,
'content_type' => $contentType,
'charset' => $charset
];
return $this;
} | [
"public",
"function",
"addContent",
"(",
"string",
"$",
"content",
",",
"string",
"$",
"contentType",
",",
"?",
"string",
"$",
"charset",
"=",
"null",
")",
":",
"Message",
"{",
"$",
"charset",
"=",
"$",
"charset",
"?",
":",
"$",
"this",
"->",
"getChars... | Adds a content part
Example content type: "text/plain" or "text/html"
@param string $content The content
@param string $contentType The content type
@param string|null $charset The character set
@return Message | [
"Adds",
"a",
"content",
"part"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L354-L365 |
237,937 | novuso/common | src/Application/Mail/Message/Message.php | Message.setSender | public function setSender(string $address, ?string $name = null): Message
{
$this->sender = [
'address' => $address,
'name' => $name
];
return $this;
} | php | public function setSender(string $address, ?string $name = null): Message
{
$this->sender = [
'address' => $address,
'name' => $name
];
return $this;
} | [
"public",
"function",
"setSender",
"(",
"string",
"$",
"address",
",",
"?",
"string",
"$",
"name",
"=",
"null",
")",
":",
"Message",
"{",
"$",
"this",
"->",
"sender",
"=",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'name'",
"=>",
"$",
"name",
"]",... | Sets the sender
If set, this has a higher precedence than a from address.
@param string $address The address
@param string|null $name The name
@return Message | [
"Sets",
"the",
"sender"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L393-L401 |
237,938 | novuso/common | src/Application/Mail/Message/Message.php | Message.setMaxLineLength | public function setMaxLineLength(int $maxLineLength): Message
{
// Each line of characters MUST be no more than 998 characters,
// and SHOULD be no more than 78 characters, excluding the CRLF.
// https://tools.ietf.org/html/rfc5322#section-2.1.1
$maxLineLength = (int) abs($maxLineLength);
if ($maxLineLength > 998) {
$maxLineLength = 998;
}
$this->maxLineLength = $maxLineLength;
return $this;
} | php | public function setMaxLineLength(int $maxLineLength): Message
{
// Each line of characters MUST be no more than 998 characters,
// and SHOULD be no more than 78 characters, excluding the CRLF.
// https://tools.ietf.org/html/rfc5322#section-2.1.1
$maxLineLength = (int) abs($maxLineLength);
if ($maxLineLength > 998) {
$maxLineLength = 998;
}
$this->maxLineLength = $maxLineLength;
return $this;
} | [
"public",
"function",
"setMaxLineLength",
"(",
"int",
"$",
"maxLineLength",
")",
":",
"Message",
"{",
"// Each line of characters MUST be no more than 998 characters,",
"// and SHOULD be no more than 78 characters, excluding the CRLF.",
"// https://tools.ietf.org/html/rfc5322#section-2.1.1... | Sets the max line length
Max line length should be a positive integer less than 998.
@param int $maxLineLength The max line length
@return Message | [
"Sets",
"the",
"max",
"line",
"length"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Mail/Message/Message.php#L525-L539 |
237,939 | FiveLab/Resource | src/Resource/Action/Method.php | Method.getPossibleValues | public static function getPossibleValues(): array
{
return [
self::POST,
self::PUT,
self::PATCH,
self::DELETE,
self::GET,
];
} | php | public static function getPossibleValues(): array
{
return [
self::POST,
self::PUT,
self::PATCH,
self::DELETE,
self::GET,
];
} | [
"public",
"static",
"function",
"getPossibleValues",
"(",
")",
":",
"array",
"{",
"return",
"[",
"self",
"::",
"POST",
",",
"self",
"::",
"PUT",
",",
"self",
"::",
"PATCH",
",",
"self",
"::",
"DELETE",
",",
"self",
"::",
"GET",
",",
"]",
";",
"}"
] | Get the possible values of action method
@return array | [
"Get",
"the",
"possible",
"values",
"of",
"action",
"method"
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Resource/Action/Method.php#L119-L128 |
237,940 | serlo/athene2-common | src/Common/src/Common/Guard/NumericGuardTrait.php | NumericGuardTrait.guardAgainstString | protected function guardAgainstString(
$data,
$dataName = 'Argument',
$exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException'
) {
if (!is_numeric($data)) {
$message = sprintf(
"%s must be a numeric, [%s] given",
$dataName,
is_object($data) ? get_class($data) : gettype($data)
);
throw new $exceptionClass($message);
}
} | php | protected function guardAgainstString(
$data,
$dataName = 'Argument',
$exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException'
) {
if (!is_numeric($data)) {
$message = sprintf(
"%s must be a numeric, [%s] given",
$dataName,
is_object($data) ? get_class($data) : gettype($data)
);
throw new $exceptionClass($message);
}
} | [
"protected",
"function",
"guardAgainstString",
"(",
"$",
"data",
",",
"$",
"dataName",
"=",
"'Argument'",
",",
"$",
"exceptionClass",
"=",
"'Zend\\Stdlib\\Exception\\InvalidArgumentException'",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"data",
")",
")",
... | Verify that the data is an int
@param mixed $data the data to verify
@param string $dataName the data name
@param string $exceptionClass FQCN for the exception
@throws \Exception | [
"Verify",
"that",
"the",
"data",
"is",
"an",
"int"
] | b7c4c9a127d9884b26bc7d288b2fe3aee6a9119c | https://github.com/serlo/athene2-common/blob/b7c4c9a127d9884b26bc7d288b2fe3aee6a9119c/src/Common/src/Common/Guard/NumericGuardTrait.php#L17-L30 |
237,941 | spiral/validation | src/Checker/MixedChecker.php | MixedChecker.cardNumber | public function cardNumber($value): bool
{
if (!is_string($value) || strlen($value) < 12) {
return false;
}
$result = 0;
$odd = strlen($value) % 2;
preg_replace('/[^0-9]+/', '', $value);
for ($i = 0; $i < strlen($value); ++$i) {
$result += $odd
? $value[$i]
: (($value[$i] * 2 > 9) ? $value[$i] * 2 - 9 : $value[$i] * 2);
$odd = !$odd;
}
// Check validity.
return ($result % 10 == 0) ? true : false;
} | php | public function cardNumber($value): bool
{
if (!is_string($value) || strlen($value) < 12) {
return false;
}
$result = 0;
$odd = strlen($value) % 2;
preg_replace('/[^0-9]+/', '', $value);
for ($i = 0; $i < strlen($value); ++$i) {
$result += $odd
? $value[$i]
: (($value[$i] * 2 > 9) ? $value[$i] * 2 - 9 : $value[$i] * 2);
$odd = !$odd;
}
// Check validity.
return ($result % 10 == 0) ? true : false;
} | [
"public",
"function",
"cardNumber",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
"||",
"strlen",
"(",
"$",
"value",
")",
"<",
"12",
")",
"{",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"0",
... | Check credit card passed by Luhn algorithm.
@link http://en.wikipedia.org/wiki/Luhn_algorithm
@param string $value
@return bool | [
"Check",
"credit",
"card",
"passed",
"by",
"Luhn",
"algorithm",
"."
] | aa8977dfe93904acfcce354e000d7d384579e2e3 | https://github.com/spiral/validation/blob/aa8977dfe93904acfcce354e000d7d384579e2e3/src/Checker/MixedChecker.php#L37-L57 |
237,942 | spiral/validation | src/Checker/MixedChecker.php | MixedChecker.match | public function match($value, string $field, bool $strict = false): bool
{
if ($strict) {
return $value === $this->getValidator()->getValue($field, null);
}
return $value == $this->getValidator()->getValue($field, null);
} | php | public function match($value, string $field, bool $strict = false): bool
{
if ($strict) {
return $value === $this->getValidator()->getValue($field, null);
}
return $value == $this->getValidator()->getValue($field, null);
} | [
"public",
"function",
"match",
"(",
"$",
"value",
",",
"string",
"$",
"field",
",",
"bool",
"$",
"strict",
"=",
"false",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"value",
"===",
"$",
"this",
"->",
"getValidator",
"(... | Check if value matches value from another field.
@param mixed $value
@param string $field
@param bool $strict
@return bool | [
"Check",
"if",
"value",
"matches",
"value",
"from",
"another",
"field",
"."
] | aa8977dfe93904acfcce354e000d7d384579e2e3 | https://github.com/spiral/validation/blob/aa8977dfe93904acfcce354e000d7d384579e2e3/src/Checker/MixedChecker.php#L68-L75 |
237,943 | synapsestudios/synapse-base | src/Synapse/Controller/AbstractController.php | AbstractController.createErrorResponse | protected function createErrorResponse($content = 'Unknown Error', $code = 500)
{
$data = [
'message' => $content
];
$response = $this->createJsonResponse($data, $code);
return $response;
} | php | protected function createErrorResponse($content = 'Unknown Error', $code = 500)
{
$data = [
'message' => $content
];
$response = $this->createJsonResponse($data, $code);
return $response;
} | [
"protected",
"function",
"createErrorResponse",
"(",
"$",
"content",
"=",
"'Unknown Error'",
",",
"$",
"code",
"=",
"500",
")",
"{",
"$",
"data",
"=",
"[",
"'message'",
"=>",
"$",
"content",
"]",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"createJsonR... | Create and return an error response with a standard format
Response will be formatted as a JSON object with the format:
{
"message" : "text"
}
@param string $content Response content
@param integer $code HTTP response code
@return Response | [
"Create",
"and",
"return",
"an",
"error",
"response",
"with",
"a",
"standard",
"format"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Controller/AbstractController.php#L60-L68 |
237,944 | synapsestudios/synapse-base | src/Synapse/Controller/AbstractController.php | AbstractController.createSimpleResponse | protected function createSimpleResponse($code = 500, $content = 'Unknown error')
{
$response = new Response;
$response->setStatusCode($code)
->setContent($content);
return $response;
} | php | protected function createSimpleResponse($code = 500, $content = 'Unknown error')
{
$response = new Response;
$response->setStatusCode($code)
->setContent($content);
return $response;
} | [
"protected",
"function",
"createSimpleResponse",
"(",
"$",
"code",
"=",
"500",
",",
"$",
"content",
"=",
"'Unknown error'",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
";",
"$",
"response",
"->",
"setStatusCode",
"(",
"$",
"code",
")",
"->",
"setCon... | Create and return an error response object
@param integer $code HTTP response code
@param string $content Response content
@return Response | [
"Create",
"and",
"return",
"an",
"error",
"response",
"object"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Controller/AbstractController.php#L77-L84 |
237,945 | synapsestudios/synapse-base | src/Synapse/Controller/AbstractController.php | AbstractController.createConstraintViolationResponse | protected function createConstraintViolationResponse(ConstraintViolationListInterface $violationList)
{
$errors = $this->validationErrorFormatter->groupViolationsByField($violationList);
return $this->createJsonResponse(
['errors' => $errors],
422
);
} | php | protected function createConstraintViolationResponse(ConstraintViolationListInterface $violationList)
{
$errors = $this->validationErrorFormatter->groupViolationsByField($violationList);
return $this->createJsonResponse(
['errors' => $errors],
422
);
} | [
"protected",
"function",
"createConstraintViolationResponse",
"(",
"ConstraintViolationListInterface",
"$",
"violationList",
")",
"{",
"$",
"errors",
"=",
"$",
"this",
"->",
"validationErrorFormatter",
"->",
"groupViolationsByField",
"(",
"$",
"violationList",
")",
";",
... | Create a response for constraint violations
@param ConstraintViolationListInterface $violationList
@return JsonResponse | [
"Create",
"a",
"response",
"for",
"constraint",
"violations"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Controller/AbstractController.php#L118-L126 |
237,946 | opsbears/coverage-reporter | src/CloverProject.php | CloverProject.getTotalCodeCoverage | public function getTotalCodeCoverage() {
$totalStatements = 0;
$totalCoveredStatements = 0;
foreach ($this->getFiles() as $file) {
$totalStatements += $file->getStatements();
$totalCoveredStatements += $file->getCoveredStatements();
}
foreach ($this->getPackages() as $package) {
foreach ($package->getFiles() as $file) {
$totalStatements += $file->getStatements();
$totalCoveredStatements += $file->getCoveredStatements();
}
}
return ($totalCoveredStatements==0?0:\round(($totalCoveredStatements/$totalStatements)*100));
} | php | public function getTotalCodeCoverage() {
$totalStatements = 0;
$totalCoveredStatements = 0;
foreach ($this->getFiles() as $file) {
$totalStatements += $file->getStatements();
$totalCoveredStatements += $file->getCoveredStatements();
}
foreach ($this->getPackages() as $package) {
foreach ($package->getFiles() as $file) {
$totalStatements += $file->getStatements();
$totalCoveredStatements += $file->getCoveredStatements();
}
}
return ($totalCoveredStatements==0?0:\round(($totalCoveredStatements/$totalStatements)*100));
} | [
"public",
"function",
"getTotalCodeCoverage",
"(",
")",
"{",
"$",
"totalStatements",
"=",
"0",
";",
"$",
"totalCoveredStatements",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFiles",
"(",
")",
"as",
"$",
"file",
")",
"{",
"$",
"totalStatements",
... | Return total code coverage in percent.
@return int | [
"Return",
"total",
"code",
"coverage",
"in",
"percent",
"."
] | ac0413e16746f942cdb411a212b5aa2f80ca53f9 | https://github.com/opsbears/coverage-reporter/blob/ac0413e16746f942cdb411a212b5aa2f80ca53f9/src/CloverProject.php#L86-L101 |
237,947 | opsbears/coverage-reporter | src/CloverProject.php | CloverProject.getMaximumCRAPIndex | public function getMaximumCRAPIndex() {
$maximumCRAP = 0;
foreach ($this->getFiles() as $file) {
foreach ($file->getLines() as $line) {
if ($line->getType() == CloverLine::TYPE_METHOD) {
if ($line->getCrap() > $maximumCRAP) {
$maximumCRAP = $line->getCRAP();
}
}
}
}
foreach ($this->getPackages() as $package) {
foreach ($package->getFiles() as $file) {
foreach ($file->getLines() as $line) {
if ($line->getType() == CloverLine::TYPE_METHOD) {
if ($line->getCrap() > $maximumCRAP) {
$maximumCRAP = $line->getCRAP();
}
}
}
}
}
return $maximumCRAP;
} | php | public function getMaximumCRAPIndex() {
$maximumCRAP = 0;
foreach ($this->getFiles() as $file) {
foreach ($file->getLines() as $line) {
if ($line->getType() == CloverLine::TYPE_METHOD) {
if ($line->getCrap() > $maximumCRAP) {
$maximumCRAP = $line->getCRAP();
}
}
}
}
foreach ($this->getPackages() as $package) {
foreach ($package->getFiles() as $file) {
foreach ($file->getLines() as $line) {
if ($line->getType() == CloverLine::TYPE_METHOD) {
if ($line->getCrap() > $maximumCRAP) {
$maximumCRAP = $line->getCRAP();
}
}
}
}
}
return $maximumCRAP;
} | [
"public",
"function",
"getMaximumCRAPIndex",
"(",
")",
"{",
"$",
"maximumCRAP",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"getFiles",
"(",
")",
"as",
"$",
"file",
")",
"{",
"foreach",
"(",
"$",
"file",
"->",
"getLines",
"(",
")",
"as",
"$",
... | Return the maximum C.R.A.P. index
@return int | [
"Return",
"the",
"maximum",
"C",
".",
"R",
".",
"A",
".",
"P",
".",
"index"
] | ac0413e16746f942cdb411a212b5aa2f80ca53f9 | https://github.com/opsbears/coverage-reporter/blob/ac0413e16746f942cdb411a212b5aa2f80ca53f9/src/CloverProject.php#L108-L132 |
237,948 | flywheel2/extensions | twig/traits/RequestDataSetTrait.php | RequestDataSetTrait.existRequestData | public function existRequestData ($name) {
return Request::IsPostMethod() ? $this->existFormData($name) : $this->existParameter($name);
} | php | public function existRequestData ($name) {
return Request::IsPostMethod() ? $this->existFormData($name) : $this->existParameter($name);
} | [
"public",
"function",
"existRequestData",
"(",
"$",
"name",
")",
"{",
"return",
"Request",
"::",
"IsPostMethod",
"(",
")",
"?",
"$",
"this",
"->",
"existFormData",
"(",
"$",
"name",
")",
":",
"$",
"this",
"->",
"existParameter",
"(",
"$",
"name",
")",
... | CURRENT REQUEST data | [
"CURRENT",
"REQUEST",
"data"
] | 8a875363716c7921c33c5eea9fd1aff1a3cd3fde | https://github.com/flywheel2/extensions/blob/8a875363716c7921c33c5eea9fd1aff1a3cd3fde/twig/traits/RequestDataSetTrait.php#L57-L59 |
237,949 | xloit/xloit-collection | src/AbstractCollection.php | AbstractCollection.exchangeArray | public function exchangeArray($collection)
{
if (!is_array($collection) && !($collection instanceof Traversable)) {
throw new Exception\InvalidArgumentException(
sprintf(
'Expected argument "array" or "Traversable"; "%s" given',
gettype($collection) . (is_object($collection) ? '(' . get_class($collection) . ')' : '')
)
);
}
if ($collection instanceof Traversable) {
$collection = ArrayUtils::iteratorToArray($collection);
}
foreach ($collection as $key => $value) {
$this->set($key, $value);
}
} | php | public function exchangeArray($collection)
{
if (!is_array($collection) && !($collection instanceof Traversable)) {
throw new Exception\InvalidArgumentException(
sprintf(
'Expected argument "array" or "Traversable"; "%s" given',
gettype($collection) . (is_object($collection) ? '(' . get_class($collection) . ')' : '')
)
);
}
if ($collection instanceof Traversable) {
$collection = ArrayUtils::iteratorToArray($collection);
}
foreach ($collection as $key => $value) {
$this->set($key, $value);
}
} | [
"public",
"function",
"exchangeArray",
"(",
"$",
"collection",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"collection",
")",
"&&",
"!",
"(",
"$",
"collection",
"instanceof",
"Traversable",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgu... | Sets a whole new array replacement.
@param array|Traversable $collection
@return void
@throws \Xloit\Collection\Exception\InvalidArgumentException
@throws \Zend\Stdlib\Exception\InvalidArgumentException | [
"Sets",
"a",
"whole",
"new",
"array",
"replacement",
"."
] | 751edaf424abd94c2c4c4a2073fbfb1e2247b989 | https://github.com/xloit/xloit-collection/blob/751edaf424abd94c2c4c4a2073fbfb1e2247b989/src/AbstractCollection.php#L66-L84 |
237,950 | xloit/xloit-collection | src/AbstractCollection.php | AbstractCollection.get | public function get($index)
{
if (null === $index) {
throw new Exception\InvalidArgumentException('The specified key name is null');
}
if (!$this->has($index)) {
throw new Exception\OutOfBoundsException(sprintf('Index "%s" is out of bounds', $index));
}
return $this->collections[$index];
} | php | public function get($index)
{
if (null === $index) {
throw new Exception\InvalidArgumentException('The specified key name is null');
}
if (!$this->has($index)) {
throw new Exception\OutOfBoundsException(sprintf('Index "%s" is out of bounds', $index));
}
return $this->collections[$index];
} | [
"public",
"function",
"get",
"(",
"$",
"index",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"index",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The specified key name is null'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
... | Returns the element at the specified key name in this class.
@param string|int $index
@return mixed
@throws \Xloit\Collection\Exception\InvalidArgumentException
@throws \Xloit\Collection\Exception\OutOfBoundsException | [
"Returns",
"the",
"element",
"at",
"the",
"specified",
"key",
"name",
"in",
"this",
"class",
"."
] | 751edaf424abd94c2c4c4a2073fbfb1e2247b989 | https://github.com/xloit/xloit-collection/blob/751edaf424abd94c2c4c4a2073fbfb1e2247b989/src/AbstractCollection.php#L190-L201 |
237,951 | xloit/xloit-collection | src/AbstractCollection.php | AbstractCollection.has | public function has($key)
{
if (null === $key) {
throw new Exception\InvalidArgumentException('The specified key name is null');
}
if (!is_scalar($key)) {
throw new Exception\InvalidArgumentException('The specified key name must be a scalar');
}
return array_key_exists($key, $this->collections);
} | php | public function has($key)
{
if (null === $key) {
throw new Exception\InvalidArgumentException('The specified key name is null');
}
if (!is_scalar($key)) {
throw new Exception\InvalidArgumentException('The specified key name must be a scalar');
}
return array_key_exists($key, $this->collections);
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"key",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'The specified key name is null'",
")",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",... | Whether this contains the given name. More formally, returns true if and only if this contains at least
one element.
@param string|int $key
@return bool
@throws \Xloit\Collection\Exception\InvalidArgumentException | [
"Whether",
"this",
"contains",
"the",
"given",
"name",
".",
"More",
"formally",
"returns",
"true",
"if",
"and",
"only",
"if",
"this",
"contains",
"at",
"least",
"one",
"element",
"."
] | 751edaf424abd94c2c4c4a2073fbfb1e2247b989 | https://github.com/xloit/xloit-collection/blob/751edaf424abd94c2c4c4a2073fbfb1e2247b989/src/AbstractCollection.php#L212-L223 |
237,952 | xloit/xloit-collection | src/AbstractCollection.php | AbstractCollection.exists | public function exists(Closure $predicate)
{
foreach ($this->collections as $key => $element) {
if ($predicate($key, $element)) {
return true;
}
}
return false;
} | php | public function exists(Closure $predicate)
{
foreach ($this->collections as $key => $element) {
if ($predicate($key, $element)) {
return true;
}
}
return false;
} | [
"public",
"function",
"exists",
"(",
"Closure",
"$",
"predicate",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"collections",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"predicate",
"(",
"$",
"key",
",",
"$",
"element",
")",
... | Tests for the existence of an element that satisfies the given predicate.
@param Closure $predicate The predicate.
@return bool TRUE if the predicate is TRUE for at least one element, FALSE otherwise. | [
"Tests",
"for",
"the",
"existence",
"of",
"an",
"element",
"that",
"satisfies",
"the",
"given",
"predicate",
"."
] | 751edaf424abd94c2c4c4a2073fbfb1e2247b989 | https://github.com/xloit/xloit-collection/blob/751edaf424abd94c2c4c4a2073fbfb1e2247b989/src/AbstractCollection.php#L477-L486 |
237,953 | xloit/xloit-collection | src/AbstractCollection.php | AbstractCollection.merge | public function merge($collection)
{
if (!is_array($collection) && !($collection instanceof Traversable)) {
throw new Exception\InvalidArgumentException(
sprintf(
'Expected argument "array" or "Traversable"; "%s" given',
gettype($collection) . (is_object($collection) ? '(' . get_class($collection) . ')' : '')
)
);
}
foreach ($collection as $key => $value) {
if ($this->has($key)) {
if (is_int($key)) {
$this->append($value);
} else {
if ($value instanceof CollectionInterface) {
$value = $value->toArray();
if ($this->collections[$key] instanceof CollectionInterface) {
$value = $this->collections[$key]->merge($value);
} else {
$value = new static($value);
}
}
$this->set($key, $value);
}
} else {
if ($value instanceof CollectionInterface) {
$value = new static($value->toArray());
}
$this->set($key, $value);
}
}
return $this;
} | php | public function merge($collection)
{
if (!is_array($collection) && !($collection instanceof Traversable)) {
throw new Exception\InvalidArgumentException(
sprintf(
'Expected argument "array" or "Traversable"; "%s" given',
gettype($collection) . (is_object($collection) ? '(' . get_class($collection) . ')' : '')
)
);
}
foreach ($collection as $key => $value) {
if ($this->has($key)) {
if (is_int($key)) {
$this->append($value);
} else {
if ($value instanceof CollectionInterface) {
$value = $value->toArray();
if ($this->collections[$key] instanceof CollectionInterface) {
$value = $this->collections[$key]->merge($value);
} else {
$value = new static($value);
}
}
$this->set($key, $value);
}
} else {
if ($value instanceof CollectionInterface) {
$value = new static($value->toArray());
}
$this->set($key, $value);
}
}
return $this;
} | [
"public",
"function",
"merge",
"(",
"$",
"collection",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"collection",
")",
"&&",
"!",
"(",
"$",
"collection",
"instanceof",
"Traversable",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentExce... | Merge another Collection with this one.
For duplicate keys, the following will be performed:
- Nested Configs will be recursively merged.
- Items in $merge with INTEGER keys will be appended.
- Items in $merge with STRING keys will overwrite current values.
@param array|Traversable $collection
@return $this
@throws \Xloit\Collection\Exception\InvalidArgumentException
@throws \Zend\Stdlib\Exception\InvalidArgumentException | [
"Merge",
"another",
"Collection",
"with",
"this",
"one",
"."
] | 751edaf424abd94c2c4c4a2073fbfb1e2247b989 | https://github.com/xloit/xloit-collection/blob/751edaf424abd94c2c4c4a2073fbfb1e2247b989/src/AbstractCollection.php#L707-L745 |
237,954 | xloit/xloit-collection | src/AbstractCollection.php | AbstractCollection.toArray | public function toArray($recursive = true)
{
$results = [];
$collections = $this->collections;
if ($recursive) {
foreach ($collections as $key => $value) {
if ($value instanceof CollectionInterface) {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$results[$key] = $value->toArray($recursive);
} else {
$results[$key] = $value;
}
}
} else {
foreach ($collections as $key => $value) {
$results[$key] = $value;
}
}
return $results;
} | php | public function toArray($recursive = true)
{
$results = [];
$collections = $this->collections;
if ($recursive) {
foreach ($collections as $key => $value) {
if ($value instanceof CollectionInterface) {
/** @noinspection PhpMethodParametersCountMismatchInspection */
$results[$key] = $value->toArray($recursive);
} else {
$results[$key] = $value;
}
}
} else {
foreach ($collections as $key => $value) {
$results[$key] = $value;
}
}
return $results;
} | [
"public",
"function",
"toArray",
"(",
"$",
"recursive",
"=",
"true",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"$",
"collections",
"=",
"$",
"this",
"->",
"collections",
";",
"if",
"(",
"$",
"recursive",
")",
"{",
"foreach",
"(",
"$",
"collection... | Get the array representation of this object.
@param bool $recursive
@return array | [
"Get",
"the",
"array",
"representation",
"of",
"this",
"object",
"."
] | 751edaf424abd94c2c4c4a2073fbfb1e2247b989 | https://github.com/xloit/xloit-collection/blob/751edaf424abd94c2c4c4a2073fbfb1e2247b989/src/AbstractCollection.php#L782-L803 |
237,955 | AdamB7586/Config | src/Config.php | Config.update | public function update($setting, $value){
if($this->db->update($this->table_config, array('value' => $value), array('setting' => $setting))){
$this->set($setting, $value);
}
return $this;
} | php | public function update($setting, $value){
if($this->db->update($this->table_config, array('value' => $value), array('setting' => $setting))){
$this->set($setting, $value);
}
return $this;
} | [
"public",
"function",
"update",
"(",
"$",
"setting",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"db",
"->",
"update",
"(",
"$",
"this",
"->",
"table_config",
",",
"array",
"(",
"'value'",
"=>",
"$",
"value",
")",
",",
"array",
"(",
... | Set a setting in the database
@param string $setting This should be the setting name
@param mixed $value The new value for the setting should be added here
@return $this | [
"Set",
"a",
"setting",
"in",
"the",
"database"
] | 8889d847d0c7269c85ce7b28f4580888dc8f52b2 | https://github.com/AdamB7586/Config/blob/8889d847d0c7269c85ce7b28f4580888dc8f52b2/src/Config.php#L76-L81 |
237,956 | spartan/html | src/Helper/Render.php | Render.options | public static function options($options, $selected = []): string
{
$html = '';
$selected = array_flip($selected);
foreach ($options as $value => $name) {
$html .= is_array($name)
? self::tag('optgroup', ['label' => $value], self::options($name, $selected))
: self::tag('option', ['value' => $value] + (isset($selected[$value]) ? ['selected' => 'selected'] : []), $name);
}
return $html;
} | php | public static function options($options, $selected = []): string
{
$html = '';
$selected = array_flip($selected);
foreach ($options as $value => $name) {
$html .= is_array($name)
? self::tag('optgroup', ['label' => $value], self::options($name, $selected))
: self::tag('option', ['value' => $value] + (isset($selected[$value]) ? ['selected' => 'selected'] : []), $name);
}
return $html;
} | [
"public",
"static",
"function",
"options",
"(",
"$",
"options",
",",
"$",
"selected",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"selected",
"=",
"array_flip",
"(",
"$",
"selected",
")",
";",
"foreach",
"(",
"$",
"opt... | Render select options
@param array $options Options array
@param mixed $selected Selected values ex: [value => !NULL]
@return string | [
"Render",
"select",
"options"
] | 674ada8a6fce748e5cb541124b6b1fed5361677a | https://github.com/spartan/html/blob/674ada8a6fce748e5cb541124b6b1fed5361677a/src/Helper/Render.php#L107-L119 |
237,957 | CatLabInteractive/Neuron | src/Neuron/Tracking/Tracker.php | Tracker.updatePeakMemoryUsage | private function updatePeakMemoryUsage ()
{
$memory = memory_get_peak_usage ();
if ($memory > $this->peakMemoryUsage)
{
$this->peakMemoryUsage = $memory;
$this->setParameter ('Memory/PeakMemoryUsage', $memory);
if (extension_loaded ('newrelic'))
{
newrelic_custom_metric ('Custom/PeakMemoryUsage', $memory);
}
}
} | php | private function updatePeakMemoryUsage ()
{
$memory = memory_get_peak_usage ();
if ($memory > $this->peakMemoryUsage)
{
$this->peakMemoryUsage = $memory;
$this->setParameter ('Memory/PeakMemoryUsage', $memory);
if (extension_loaded ('newrelic'))
{
newrelic_custom_metric ('Custom/PeakMemoryUsage', $memory);
}
}
} | [
"private",
"function",
"updatePeakMemoryUsage",
"(",
")",
"{",
"$",
"memory",
"=",
"memory_get_peak_usage",
"(",
")",
";",
"if",
"(",
"$",
"memory",
">",
"$",
"this",
"->",
"peakMemoryUsage",
")",
"{",
"$",
"this",
"->",
"peakMemoryUsage",
"=",
"$",
"memor... | Check if this transaction generated a bigger peak usage
then the previous transaction. If so, report it. | [
"Check",
"if",
"this",
"transaction",
"generated",
"a",
"bigger",
"peak",
"usage",
"then",
"the",
"previous",
"transaction",
".",
"If",
"so",
"report",
"it",
"."
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Tracking/Tracker.php#L51-L64 |
237,958 | equip/command | src/OptionsRequiredTrait.php | OptionsRequiredTrait.checkRequired | private function checkRequired(array $options, array $keys)
{
$missing = array_keys(array_diff_key(array_flip($keys), $options));
if (!empty($missing)) {
throw CommandException::missingOptions($missing);
}
} | php | private function checkRequired(array $options, array $keys)
{
$missing = array_keys(array_diff_key(array_flip($keys), $options));
if (!empty($missing)) {
throw CommandException::missingOptions($missing);
}
} | [
"private",
"function",
"checkRequired",
"(",
"array",
"$",
"options",
",",
"array",
"$",
"keys",
")",
"{",
"$",
"missing",
"=",
"array_keys",
"(",
"array_diff_key",
"(",
"array_flip",
"(",
"$",
"keys",
")",
",",
"$",
"options",
")",
")",
";",
"if",
"("... | Check that the given options contain all required keys.
@param array $options
@param array $keys
@return void
@throws CommandException
If any required options are missing. | [
"Check",
"that",
"the",
"given",
"options",
"contain",
"all",
"required",
"keys",
"."
] | b8a3647ccd002316775d99efbb16ee87ca81142f | https://github.com/equip/command/blob/b8a3647ccd002316775d99efbb16ee87ca81142f/src/OptionsRequiredTrait.php#L21-L28 |
237,959 | tekkla/core-html | Core/Html/Form/Select.php | Select.& | public function &createOption($optgroup = ''): Option
{
$option = $this->factory->create('Form\Option');
$this->addOption($option, $optgroup);
return $option;
} | php | public function &createOption($optgroup = ''): Option
{
$option = $this->factory->create('Form\Option');
$this->addOption($option, $optgroup);
return $option;
} | [
"public",
"function",
"&",
"createOption",
"(",
"$",
"optgroup",
"=",
"''",
")",
":",
"Option",
"{",
"$",
"option",
"=",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"'Form\\Option'",
")",
";",
"$",
"this",
"->",
"addOption",
"(",
"$",
"option",
... | Creates an Option object and returns it
@return Option | [
"Creates",
"an",
"Option",
"object",
"and",
"returns",
"it"
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Form/Select.php#L36-L43 |
237,960 | tekkla/core-html | Core/Html/Form/Select.php | Select.& | public function &newOption($value = null, $inner = null, bool $selected = false, string $optgroup = ''): Option
{
/* @var $option \Core\Html\Form\Option */
$option = $this->factory->create('Form\Option');
if (isset($value)) {
$option->setValue($value);
}
if (isset($inner)) {
$option->setInner($inner);
}
if ($selected == true) {
$option->isSelected();
}
$this->addOption($option, $optgroup);
return $option;
} | php | public function &newOption($value = null, $inner = null, bool $selected = false, string $optgroup = ''): Option
{
/* @var $option \Core\Html\Form\Option */
$option = $this->factory->create('Form\Option');
if (isset($value)) {
$option->setValue($value);
}
if (isset($inner)) {
$option->setInner($inner);
}
if ($selected == true) {
$option->isSelected();
}
$this->addOption($option, $optgroup);
return $option;
} | [
"public",
"function",
"&",
"newOption",
"(",
"$",
"value",
"=",
"null",
",",
"$",
"inner",
"=",
"null",
",",
"bool",
"$",
"selected",
"=",
"false",
",",
"string",
"$",
"optgroup",
"=",
"''",
")",
":",
"Option",
"{",
"/* @var $option \\Core\\Html\\Form\\Opt... | Add an Option object to the options array
Use parameters to predefine the objects settings.
If inner parameter is not set, the value is the inner
content of option and has no value attribute.
@param string|int $value
Option value
@param
string|int Optional $inner
Option inner content
@param bool $selected
Selected flag
@param string $optgroup
Related optgroup
@return Option | [
"Add",
"an",
"Option",
"object",
"to",
"the",
"options",
"array"
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Form/Select.php#L64-L84 |
237,961 | tekkla/core-html | Core/Html/Form/Select.php | Select.addOption | public function addOption(Option $option, string $optgroup = ''): Select
{
if (empty($optgroup)) {
$this->options[] = $option;
}
else {
$this->options[$optgroup][] = $option;
}
return $this;
} | php | public function addOption(Option $option, string $optgroup = ''): Select
{
if (empty($optgroup)) {
$this->options[] = $option;
}
else {
$this->options[$optgroup][] = $option;
}
return $this;
} | [
"public",
"function",
"addOption",
"(",
"Option",
"$",
"option",
",",
"string",
"$",
"optgroup",
"=",
"''",
")",
":",
"Select",
"{",
"if",
"(",
"empty",
"(",
"$",
"optgroup",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"]",
"=",
"$",
"option"... | Add an html option object to the optionlist
@param Option $option
@param string $optgroup
Related optgroup
@return Select | [
"Add",
"an",
"html",
"option",
"object",
"to",
"the",
"optionlist"
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Form/Select.php#L95-L105 |
237,962 | tekkla/core-html | Core/Html/Form/Select.php | Select.buildOption | private function buildOption(Option $option): string
{
// Select unselected options when the options value is in selects value array
if (!$option->getSelected() && in_array($option->getValue(), $this->value)) {
$option->isSelected();
}
return $option->build();
} | php | private function buildOption(Option $option): string
{
// Select unselected options when the options value is in selects value array
if (!$option->getSelected() && in_array($option->getValue(), $this->value)) {
$option->isSelected();
}
return $option->build();
} | [
"private",
"function",
"buildOption",
"(",
"Option",
"$",
"option",
")",
":",
"string",
"{",
"// Select unselected options when the options value is in selects value array",
"if",
"(",
"!",
"$",
"option",
"->",
"getSelected",
"(",
")",
"&&",
"in_array",
"(",
"$",
"o... | Builds otion element
@param Option $option
@return string | [
"Builds",
"otion",
"element"
] | 00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3 | https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Form/Select.php#L124-L133 |
237,963 | phlexible/elastica-bundle | DependencyInjection/PhlexibleElasticaExtension.php | PhlexibleElasticaExtension.loadClients | private function loadClients(array $clients, ContainerBuilder $container)
{
foreach ($clients as $name => $clientConfig) {
$clientId = sprintf('phlexible_elastica.client.%s', $name);
$clientDef = new DefinitionDecorator('phlexible_elastica.client_prototype');
$clientDef->replaceArgument(0, $clientConfig);
$logger = $clientConfig['connections'][0]['logger'];
if (false !== $logger) {
$clientDef->addMethodCall('setLogger', array(new Reference($logger)));
}
$clientDef->addTag('phlexible_elastica.client');
$container->setDefinition($clientId, $clientDef);
$this->clients[$name] = array(
'id' => $clientId,
'reference' => new Reference($clientId),
);
}
} | php | private function loadClients(array $clients, ContainerBuilder $container)
{
foreach ($clients as $name => $clientConfig) {
$clientId = sprintf('phlexible_elastica.client.%s', $name);
$clientDef = new DefinitionDecorator('phlexible_elastica.client_prototype');
$clientDef->replaceArgument(0, $clientConfig);
$logger = $clientConfig['connections'][0]['logger'];
if (false !== $logger) {
$clientDef->addMethodCall('setLogger', array(new Reference($logger)));
}
$clientDef->addTag('phlexible_elastica.client');
$container->setDefinition($clientId, $clientDef);
$this->clients[$name] = array(
'id' => $clientId,
'reference' => new Reference($clientId),
);
}
} | [
"private",
"function",
"loadClients",
"(",
"array",
"$",
"clients",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"clients",
"as",
"$",
"name",
"=>",
"$",
"clientConfig",
")",
"{",
"$",
"clientId",
"=",
"sprintf",
"(",
"'phlexib... | Loads the configured clients.
@param array $clients An array of clients configurations
@param ContainerBuilder $container A ContainerBuilder instance
@return array | [
"Loads",
"the",
"configured",
"clients",
"."
] | d05a60440f864ae492eb7fc5b62fcfc06bac46d4 | https://github.com/phlexible/elastica-bundle/blob/d05a60440f864ae492eb7fc5b62fcfc06bac46d4/DependencyInjection/PhlexibleElasticaExtension.php#L97-L114 |
237,964 | phlexible/elastica-bundle | DependencyInjection/PhlexibleElasticaExtension.php | PhlexibleElasticaExtension.loadIndexes | private function loadIndexes(array $indexes, ContainerBuilder $container)
{
foreach ($indexes as $name => $index) {
$indexId = sprintf('phlexible_elastica.index.%s', $name);
$indexName = isset($index['index_name']) ? $index['index_name'] : $name;
$indexDef = new DefinitionDecorator('phlexible_elastica.index_prototype');
$indexDef->replaceArgument(0, $indexName);
$indexDef->addTag('phlexible_elastica.index', array(
'name' => $name,
));
if (method_exists($indexDef, 'setFactory')) {
$indexDef->setFactory(array(new Reference('phlexible_elastica.client'), 'getIndex'));
} else {
// To be removed when dependency on Symfony DependencyInjection is bumped to 2.6
$indexDef->setFactoryService('phlexible_elastica.client');
$indexDef->setFactoryMethod('getIndex');
}
if (isset($index['client'])) {
$client = $this->getClient($index['client']);
if (method_exists($indexDef, 'setFactory')) {
$indexDef->setFactory(array($client, 'getIndex'));
} else {
// To be removed when dependency on Symfony DependencyInjection is bumped to 2.6
$indexDef->setFactoryService('phlexible_elastica.client');
$indexDef->setFactoryMethod('getIndex');
}
}
$container->setDefinition($indexId, $indexDef);
$reference = new Reference($indexId);
$this->indexConfigs[$name] = array(
'elasticsearch_name' => $indexName,
'reference' => $reference,
'name' => $name,
'settings' => $index['settings'],
'type_prototype' => isset($index['type_prototype']) ? $index['type_prototype'] : array(),
'use_alias' => $index['use_alias'],
);
}
} | php | private function loadIndexes(array $indexes, ContainerBuilder $container)
{
foreach ($indexes as $name => $index) {
$indexId = sprintf('phlexible_elastica.index.%s', $name);
$indexName = isset($index['index_name']) ? $index['index_name'] : $name;
$indexDef = new DefinitionDecorator('phlexible_elastica.index_prototype');
$indexDef->replaceArgument(0, $indexName);
$indexDef->addTag('phlexible_elastica.index', array(
'name' => $name,
));
if (method_exists($indexDef, 'setFactory')) {
$indexDef->setFactory(array(new Reference('phlexible_elastica.client'), 'getIndex'));
} else {
// To be removed when dependency on Symfony DependencyInjection is bumped to 2.6
$indexDef->setFactoryService('phlexible_elastica.client');
$indexDef->setFactoryMethod('getIndex');
}
if (isset($index['client'])) {
$client = $this->getClient($index['client']);
if (method_exists($indexDef, 'setFactory')) {
$indexDef->setFactory(array($client, 'getIndex'));
} else {
// To be removed when dependency on Symfony DependencyInjection is bumped to 2.6
$indexDef->setFactoryService('phlexible_elastica.client');
$indexDef->setFactoryMethod('getIndex');
}
}
$container->setDefinition($indexId, $indexDef);
$reference = new Reference($indexId);
$this->indexConfigs[$name] = array(
'elasticsearch_name' => $indexName,
'reference' => $reference,
'name' => $name,
'settings' => $index['settings'],
'type_prototype' => isset($index['type_prototype']) ? $index['type_prototype'] : array(),
'use_alias' => $index['use_alias'],
);
}
} | [
"private",
"function",
"loadIndexes",
"(",
"array",
"$",
"indexes",
",",
"ContainerBuilder",
"$",
"container",
")",
"{",
"foreach",
"(",
"$",
"indexes",
"as",
"$",
"name",
"=>",
"$",
"index",
")",
"{",
"$",
"indexId",
"=",
"sprintf",
"(",
"'phlexible_elast... | Loads the configured indexes.
@param array $indexes An array of indexes configurations
@param ContainerBuilder $container A ContainerBuilder instance
@throws InvalidArgumentException
@return array | [
"Loads",
"the",
"configured",
"indexes",
"."
] | d05a60440f864ae492eb7fc5b62fcfc06bac46d4 | https://github.com/phlexible/elastica-bundle/blob/d05a60440f864ae492eb7fc5b62fcfc06bac46d4/DependencyInjection/PhlexibleElasticaExtension.php#L126-L164 |
237,965 | phlexible/elastica-bundle | DependencyInjection/PhlexibleElasticaExtension.php | PhlexibleElasticaExtension.getClient | private function getClient($clientName)
{
if (!array_key_exists($clientName, $this->clients)) {
throw new InvalidArgumentException(sprintf('The elastica client with name "%s" is not defined', $clientName));
}
return $this->clients[$clientName]['reference'];
} | php | private function getClient($clientName)
{
if (!array_key_exists($clientName, $this->clients)) {
throw new InvalidArgumentException(sprintf('The elastica client with name "%s" is not defined', $clientName));
}
return $this->clients[$clientName]['reference'];
} | [
"private",
"function",
"getClient",
"(",
"$",
"clientName",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"clientName",
",",
"$",
"this",
"->",
"clients",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The elastic... | Returns a reference to a client given its configured name.
@param string $clientName
@return Reference
@throws InvalidArgumentException | [
"Returns",
"a",
"reference",
"to",
"a",
"client",
"given",
"its",
"configured",
"name",
"."
] | d05a60440f864ae492eb7fc5b62fcfc06bac46d4 | https://github.com/phlexible/elastica-bundle/blob/d05a60440f864ae492eb7fc5b62fcfc06bac46d4/DependencyInjection/PhlexibleElasticaExtension.php#L175-L182 |
237,966 | tonjoo/tiga-framework | src/Router/RouteCollector.php | RouteCollector.addRoute | public function addRoute($httpMethod, $route, $handler)
{
parent::addRoute($httpMethod, $route, $handler);
// Route ended with slash , redirect non slash to slash
if (substr($route, -1) === '/') {
parent::addRoute($httpMethod, substr($route, 0, -1),
new RouteHandler(
function () {
$url = tiga_url($this->request->getPathInfo().'/');
$response = \Tiga\Framework\Response\ResponseFactory::redirect($url);
$response->sendHeaders();
die();
})
);
}
// Route ended with no slash , redirect slash to no slash
else {
$route .= '/';
parent::addRoute($httpMethod, $route,
new RouteHandler(
function () {
$url = rtrim(tiga_url($this->request->getPathInfo()), '/');
$response = \Tiga\Framework\Response\ResponseFactory::redirect($url);
$response->sendHeaders();
die();
})
);
}
} | php | public function addRoute($httpMethod, $route, $handler)
{
parent::addRoute($httpMethod, $route, $handler);
// Route ended with slash , redirect non slash to slash
if (substr($route, -1) === '/') {
parent::addRoute($httpMethod, substr($route, 0, -1),
new RouteHandler(
function () {
$url = tiga_url($this->request->getPathInfo().'/');
$response = \Tiga\Framework\Response\ResponseFactory::redirect($url);
$response->sendHeaders();
die();
})
);
}
// Route ended with no slash , redirect slash to no slash
else {
$route .= '/';
parent::addRoute($httpMethod, $route,
new RouteHandler(
function () {
$url = rtrim(tiga_url($this->request->getPathInfo()), '/');
$response = \Tiga\Framework\Response\ResponseFactory::redirect($url);
$response->sendHeaders();
die();
})
);
}
} | [
"public",
"function",
"addRoute",
"(",
"$",
"httpMethod",
",",
"$",
"route",
",",
"$",
"handler",
")",
"{",
"parent",
"::",
"addRoute",
"(",
"$",
"httpMethod",
",",
"$",
"route",
",",
"$",
"handler",
")",
";",
"// Route ended with slash , redirect non slash to... | Add trailing slash route or add route without trailing slash so both work.
@param string $httpMethod
@param string $route
@param RouteHandler $handler | [
"Add",
"trailing",
"slash",
"route",
"or",
"add",
"route",
"without",
"trailing",
"slash",
"so",
"both",
"work",
"."
] | 3c2eebd3bc616106fa1bba3e43f1791aff75eec5 | https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Router/RouteCollector.php#L31-L65 |
237,967 | studyportals/Utils | src/Vector.php | Vector.cosineSimilarity | public static function cosineSimilarity(array $vector_a, array $vector_b,
$length_a = null, $length_b = null){
$sum = 0;
$sum_a_sq = ($length_a === null ? 0.0 : (float) $length_a);
$sum_b_sq = ($length_b === null ? 0.0 : (float) $length_b);
foreach($vector_a as $key => $value){
if(isset($vector_b[$key])) $sum += ($value * $vector_b[$key]);
if($length_a === null) $sum_a_sq += pow($value, 2);
}
if($length_a === null) $sum_a_sq = sqrt($sum_a_sq);
if($length_b === null){
foreach($vector_b as $key => $value){
$sum_b_sq += pow($value, 2);
}
$sum_b_sq = sqrt($sum_b_sq);
}
$division = $sum_b_sq * $sum_a_sq;
if($division == 0){
return 0;
}
else{
$result = $sum / $division;
return $result;
}
} | php | public static function cosineSimilarity(array $vector_a, array $vector_b,
$length_a = null, $length_b = null){
$sum = 0;
$sum_a_sq = ($length_a === null ? 0.0 : (float) $length_a);
$sum_b_sq = ($length_b === null ? 0.0 : (float) $length_b);
foreach($vector_a as $key => $value){
if(isset($vector_b[$key])) $sum += ($value * $vector_b[$key]);
if($length_a === null) $sum_a_sq += pow($value, 2);
}
if($length_a === null) $sum_a_sq = sqrt($sum_a_sq);
if($length_b === null){
foreach($vector_b as $key => $value){
$sum_b_sq += pow($value, 2);
}
$sum_b_sq = sqrt($sum_b_sq);
}
$division = $sum_b_sq * $sum_a_sq;
if($division == 0){
return 0;
}
else{
$result = $sum / $division;
return $result;
}
} | [
"public",
"static",
"function",
"cosineSimilarity",
"(",
"array",
"$",
"vector_a",
",",
"array",
"$",
"vector_b",
",",
"$",
"length_a",
"=",
"null",
",",
"$",
"length_b",
"=",
"null",
")",
"{",
"$",
"sum",
"=",
"0",
";",
"$",
"sum_a_sq",
"=",
"(",
"$... | Compute similarity between two vectors.
<p>Uses a vector-space model with cosine similarity to determine the
similarity between two vectors of floating point values.</p>
<p>The parameter {@link $length_a} and {@link $length_b} can be pre-
computed to further speed-up the calculation. When not provided, they
are calculated on the fly.<br>
Both parameters should be provided as the square-root of the sum of the
squares of all elements of the vector (c.q. the length of the vector).
</p>
@param array $vector_a
@param array $vector_b
@param float $length_a
@param float $length_b
@return float | [
"Compute",
"similarity",
"between",
"two",
"vectors",
"."
] | eab69ca10ce3261480164cf8108ae7020459c847 | https://github.com/studyportals/Utils/blob/eab69ca10ce3261480164cf8108ae7020459c847/src/Vector.php#L43-L81 |
237,968 | vitodtagliente/pure-orm | Model.php | Model.save | public function save()
{
if($this->exists())
{
// update
$query = new Query(static::table());
$query->update($this->getData(), $this->getIdentifyCondition());
return $query->execute();
}
else
{
// insert
$query = new Query(static::table());
$query->insert($this->getData());
if($query->execute())
$this->from_db = true;
return $query->success();
}
} | php | public function save()
{
if($this->exists())
{
// update
$query = new Query(static::table());
$query->update($this->getData(), $this->getIdentifyCondition());
return $query->execute();
}
else
{
// insert
$query = new Query(static::table());
$query->insert($this->getData());
if($query->execute())
$this->from_db = true;
return $query->success();
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
")",
")",
"{",
"// update",
"$",
"query",
"=",
"new",
"Query",
"(",
"static",
"::",
"table",
"(",
")",
")",
";",
"$",
"query",
"->",
"update",
"(",
"$",
"... | altrimenti la update | [
"altrimenti",
"la",
"update"
] | 04d80106430f45f82f922cc9da25de3d278dbb94 | https://github.com/vitodtagliente/pure-orm/blob/04d80106430f45f82f922cc9da25de3d278dbb94/Model.php#L104-L122 |
237,969 | vitodtagliente/pure-orm | Model.php | Model.erase | public function erase(){
if($this->exists())
{
$query = new Query(static::table());
$query->delete()->where($this->getIdentifyCondition());
if($query->execute())
$this->clear();
return $query->success();
}
return false;
} | php | public function erase(){
if($this->exists())
{
$query = new Query(static::table());
$query->delete()->where($this->getIdentifyCondition());
if($query->execute())
$this->clear();
return $query->success();
}
return false;
} | [
"public",
"function",
"erase",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"query",
"=",
"new",
"Query",
"(",
"static",
"::",
"table",
"(",
")",
")",
";",
"$",
"query",
"->",
"delete",
"(",
")",
"->",
"where"... | esegue la rimozione dell'elemento dal db | [
"esegue",
"la",
"rimozione",
"dell",
"elemento",
"dal",
"db"
] | 04d80106430f45f82f922cc9da25de3d278dbb94 | https://github.com/vitodtagliente/pure-orm/blob/04d80106430f45f82f922cc9da25de3d278dbb94/Model.php#L125-L135 |
237,970 | vitodtagliente/pure-orm | Model.php | Model.schema | public static function schema(){
$classname = get_called_class();
if(!array_key_exists($classname, self::$schemas)){
$schema = new SchemaBuilder(static::table());
static::define($schema);
self::$schemas[$classname] = $schema;
}
return self::$schemas[$classname];
} | php | public static function schema(){
$classname = get_called_class();
if(!array_key_exists($classname, self::$schemas)){
$schema = new SchemaBuilder(static::table());
static::define($schema);
self::$schemas[$classname] = $schema;
}
return self::$schemas[$classname];
} | [
"public",
"static",
"function",
"schema",
"(",
")",
"{",
"$",
"classname",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"classname",
",",
"self",
"::",
"$",
"schemas",
")",
")",
"{",
"$",
"schema",
"=",
"new",
... | produce lo schema del modello | [
"produce",
"lo",
"schema",
"del",
"modello"
] | 04d80106430f45f82f922cc9da25de3d278dbb94 | https://github.com/vitodtagliente/pure-orm/blob/04d80106430f45f82f922cc9da25de3d278dbb94/Model.php#L201-L209 |
237,971 | novuso/common | src/Application/Messaging/Command/CommandPipeline.php | CommandPipeline.pipe | public function pipe(CommandMessage $message): void
{
/** @var CommandFilter $filter */
$filter = $this->stack->pop();
$filter->process($message, [$this, 'pipe']);
} | php | public function pipe(CommandMessage $message): void
{
/** @var CommandFilter $filter */
$filter = $this->stack->pop();
$filter->process($message, [$this, 'pipe']);
} | [
"public",
"function",
"pipe",
"(",
"CommandMessage",
"$",
"message",
")",
":",
"void",
"{",
"/** @var CommandFilter $filter */",
"$",
"filter",
"=",
"$",
"this",
"->",
"stack",
"->",
"pop",
"(",
")",
";",
"$",
"filter",
"->",
"process",
"(",
"$",
"message"... | Pipes command message to the next filter
@param CommandMessage $message The command message
@return void | [
"Pipes",
"command",
"message",
"to",
"the",
"next",
"filter"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Application/Messaging/Command/CommandPipeline.php#L98-L103 |
237,972 | pablodip/PablodipModuleBundle | Module/Module.php | Module.setRoutePrefixes | public function setRoutePrefixes($routeNamePrefix, $routePatternPrefix)
{
$this->setRouteNamePrefix($routeNamePrefix);
$this->setRoutePatternPrefix($routePatternPrefix);
return $this;
} | php | public function setRoutePrefixes($routeNamePrefix, $routePatternPrefix)
{
$this->setRouteNamePrefix($routeNamePrefix);
$this->setRoutePatternPrefix($routePatternPrefix);
return $this;
} | [
"public",
"function",
"setRoutePrefixes",
"(",
"$",
"routeNamePrefix",
",",
"$",
"routePatternPrefix",
")",
"{",
"$",
"this",
"->",
"setRouteNamePrefix",
"(",
"$",
"routeNamePrefix",
")",
";",
"$",
"this",
"->",
"setRoutePatternPrefix",
"(",
"$",
"routePatternPref... | Sets the route name and pattern prefixes.
@param string $routeNamePrefix The route name prefix.
@param string $routePatternPrefix The route pattern prefix.
@return ModuleInterface The module (fluent interface). | [
"Sets",
"the",
"route",
"name",
"and",
"pattern",
"prefixes",
"."
] | 6d26df909fa4c57b8b3337d58f8cbecd7781c6ef | https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Module/Module.php#L205-L211 |
237,973 | pablodip/PablodipModuleBundle | Module/Module.php | Module.setActionOption | public function setActionOption($actionName, $optionName, $optionValue)
{
$this->getAction($actionName)->setOption($optionName, $optionValue);
return $this;
} | php | public function setActionOption($actionName, $optionName, $optionValue)
{
$this->getAction($actionName)->setOption($optionName, $optionValue);
return $this;
} | [
"public",
"function",
"setActionOption",
"(",
"$",
"actionName",
",",
"$",
"optionName",
",",
"$",
"optionValue",
")",
"{",
"$",
"this",
"->",
"getAction",
"(",
"$",
"actionName",
")",
"->",
"setOption",
"(",
"$",
"optionName",
",",
"$",
"optionValue",
")"... | Shortcut for setting options to actions.
@param string $actionName The action name.
@param string $optionName The option name.
@param mixed $optionValue The option value.
@return ModuleInterface The module (fluent interface). | [
"Shortcut",
"for",
"setting",
"options",
"to",
"actions",
"."
] | 6d26df909fa4c57b8b3337d58f8cbecd7781c6ef | https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Module/Module.php#L453-L458 |
237,974 | railsphp/framework | src/Rails/Application/Config/Loader.php | Loader.getDatabaseConfig | protected function getDatabaseConfig()
{
if ($this->app->config()['use_cache']) {
$key = 'rails.ar.dbconfig';
if ($dbConfig = $this->app->getService('rails.cache')->read($key)) {
return $dbConfig;
}
}
$connections = $this->getDatabaseConnections();
if (!$connections) {
return [[], null, null];
}
$config = $this->app->config();
if ($config['active_record']['allow_profiler'] === null) {
$allowProfiler = ($config['environment'] == 'production' || $config['environment'] == 'test');
} else {
$allowProfiler = (bool)$config['active_record']['allow_profiler'];
}
$options = [
'allowProfiler' => $allowProfiler
];
if (isset($connections[$config['environment']])) {
$defaultConnction = $config['environment'];
} elseif (isset($connections['default'])) {
$defaultConnction = 'default';
} else {
$defaultConnction = key($connections);
}
$dbConfig = [
$connections,
$defaultConnction,
$options
];
if ($this->app->config()['use_cache']) {
$this->app->getService('rails.cache')->write($key, $dbConfig);
}
return $dbConfig;
} | php | protected function getDatabaseConfig()
{
if ($this->app->config()['use_cache']) {
$key = 'rails.ar.dbconfig';
if ($dbConfig = $this->app->getService('rails.cache')->read($key)) {
return $dbConfig;
}
}
$connections = $this->getDatabaseConnections();
if (!$connections) {
return [[], null, null];
}
$config = $this->app->config();
if ($config['active_record']['allow_profiler'] === null) {
$allowProfiler = ($config['environment'] == 'production' || $config['environment'] == 'test');
} else {
$allowProfiler = (bool)$config['active_record']['allow_profiler'];
}
$options = [
'allowProfiler' => $allowProfiler
];
if (isset($connections[$config['environment']])) {
$defaultConnction = $config['environment'];
} elseif (isset($connections['default'])) {
$defaultConnction = 'default';
} else {
$defaultConnction = key($connections);
}
$dbConfig = [
$connections,
$defaultConnction,
$options
];
if ($this->app->config()['use_cache']) {
$this->app->getService('rails.cache')->write($key, $dbConfig);
}
return $dbConfig;
} | [
"protected",
"function",
"getDatabaseConfig",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"app",
"->",
"config",
"(",
")",
"[",
"'use_cache'",
"]",
")",
"{",
"$",
"key",
"=",
"'rails.ar.dbconfig'",
";",
"if",
"(",
"$",
"dbConfig",
"=",
"$",
"this",
... | Get database configuration
@return array | [
"Get",
"database",
"configuration"
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/Application/Config/Loader.php#L257-L302 |
237,975 | railsphp/framework | src/Rails/Application/Config/Loader.php | Loader.getDatabaseConnections | protected function getDatabaseConnections()
{
$configFile = $this->findDatabaseFile();
if (!$configFile) {
return false;
}
switch (substr($configFile, -3)) {
case 'php':
$connections = require $configFile;
break;
case 'yml':
$connections = Yaml::readFile($configFile);
break;
}
return $connections;
} | php | protected function getDatabaseConnections()
{
$configFile = $this->findDatabaseFile();
if (!$configFile) {
return false;
}
switch (substr($configFile, -3)) {
case 'php':
$connections = require $configFile;
break;
case 'yml':
$connections = Yaml::readFile($configFile);
break;
}
return $connections;
} | [
"protected",
"function",
"getDatabaseConnections",
"(",
")",
"{",
"$",
"configFile",
"=",
"$",
"this",
"->",
"findDatabaseFile",
"(",
")",
";",
"if",
"(",
"!",
"$",
"configFile",
")",
"{",
"return",
"false",
";",
"}",
"switch",
"(",
"substr",
"(",
"$",
... | Get database connections
Gets the configuration from the database file.
@return array|bool | [
"Get",
"database",
"connections",
"Gets",
"the",
"configuration",
"from",
"the",
"database",
"file",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/Application/Config/Loader.php#L310-L329 |
237,976 | ARCANESOFT/Tracker | src/Support/DateRange.php | DateRange.getCurrentMonthDaysRange | public static function getCurrentMonthDaysRange($keyFormat = 'Y-m-d', $interval = '1 day')
{
$start = Carbon::now()->subMonth(1)->setTime(0, 0);
$end = Carbon::now()->setTime(23, 59, 59);
$range = new Collection;
/** @var \Carbon\Carbon $period */
foreach (new DatePeriod($start, DateInterval::createFromDateString($interval), $end) as $period) {
$range->put($period->format($keyFormat), $period);
}
return compact('start', 'end', 'range');
} | php | public static function getCurrentMonthDaysRange($keyFormat = 'Y-m-d', $interval = '1 day')
{
$start = Carbon::now()->subMonth(1)->setTime(0, 0);
$end = Carbon::now()->setTime(23, 59, 59);
$range = new Collection;
/** @var \Carbon\Carbon $period */
foreach (new DatePeriod($start, DateInterval::createFromDateString($interval), $end) as $period) {
$range->put($period->format($keyFormat), $period);
}
return compact('start', 'end', 'range');
} | [
"public",
"static",
"function",
"getCurrentMonthDaysRange",
"(",
"$",
"keyFormat",
"=",
"'Y-m-d'",
",",
"$",
"interval",
"=",
"'1 day'",
")",
"{",
"$",
"start",
"=",
"Carbon",
"::",
"now",
"(",
")",
"->",
"subMonth",
"(",
"1",
")",
"->",
"setTime",
"(",
... | Get current month's days range.
@param string $keyFormat
@param string $interval
@return array | [
"Get",
"current",
"month",
"s",
"days",
"range",
"."
] | d106209b32ddbb192066715f0ef99afccfc22dcb | https://github.com/ARCANESOFT/Tracker/blob/d106209b32ddbb192066715f0ef99afccfc22dcb/src/Support/DateRange.php#L29-L42 |
237,977 | zugoripls/laravel-framework | src/Illuminate/Routing/Route.php | Route.runWithCustomDispatcher | protected function runWithCustomDispatcher(Request $request)
{
list($class, $method) = explode('@', $this->action['uses']);
$dispatcher = $this->container->make('illuminate.route.dispatcher');
return $dispatcher->dispatch($this, $request, $class, $method);
} | php | protected function runWithCustomDispatcher(Request $request)
{
list($class, $method) = explode('@', $this->action['uses']);
$dispatcher = $this->container->make('illuminate.route.dispatcher');
return $dispatcher->dispatch($this, $request, $class, $method);
} | [
"protected",
"function",
"runWithCustomDispatcher",
"(",
"Request",
"$",
"request",
")",
"{",
"list",
"(",
"$",
"class",
",",
"$",
"method",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"this",
"->",
"action",
"[",
"'uses'",
"]",
")",
";",
"$",
"dispatch... | Send the request and route to a custom dispatcher for handling.
@param \Illuminate\Http\Request $request
@return mixed | [
"Send",
"the",
"request",
"and",
"route",
"to",
"a",
"custom",
"dispatcher",
"for",
"handling",
"."
] | 90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655 | https://github.com/zugoripls/laravel-framework/blob/90fa2b0e7a9b7786a6f02a9f10aba6a21ac03655/src/Illuminate/Routing/Route.php#L198-L205 |
237,978 | yii2lab/yii2-init | src/console/controllers/EnvironmentsController.php | EnvironmentsController.actionIndex | public function actionIndex($option = null)
{
$option = Question::displayWithQuit('Select operation', ['Update', 'Delete'], $option);
$project = env('project');
if($option == 'u') {
//Question::confirm('Do are you sure update?', 1);
$projectInput = Question::displayWithQuit('Select project', ['common', $project]);
$project = $projectInput == 'c' ? 'common' : $project;
$result = Environments::update($project);
Output::arr($result, 'Result');
} elseif($option == 'd') {
//Question::confirm('Do are you sure delete?', 1);
$projectInput = Question::displayWithQuit('Select project', ['common', $project]);
$project = $projectInput == 'c' ? 'common' : $project;
$result = Environments::delete($project);
Output::arr($result, 'Result');
}
} | php | public function actionIndex($option = null)
{
$option = Question::displayWithQuit('Select operation', ['Update', 'Delete'], $option);
$project = env('project');
if($option == 'u') {
//Question::confirm('Do are you sure update?', 1);
$projectInput = Question::displayWithQuit('Select project', ['common', $project]);
$project = $projectInput == 'c' ? 'common' : $project;
$result = Environments::update($project);
Output::arr($result, 'Result');
} elseif($option == 'd') {
//Question::confirm('Do are you sure delete?', 1);
$projectInput = Question::displayWithQuit('Select project', ['common', $project]);
$project = $projectInput == 'c' ? 'common' : $project;
$result = Environments::delete($project);
Output::arr($result, 'Result');
}
} | [
"public",
"function",
"actionIndex",
"(",
"$",
"option",
"=",
"null",
")",
"{",
"$",
"option",
"=",
"Question",
"::",
"displayWithQuit",
"(",
"'Select operation'",
",",
"[",
"'Update'",
",",
"'Delete'",
"]",
",",
"$",
"option",
")",
";",
"$",
"project",
... | Manage project initialization files | [
"Manage",
"project",
"initialization",
"files"
] | 42c9dff331b9380f3bce61b9b9d5df02b79dda76 | https://github.com/yii2lab/yii2-init/blob/42c9dff331b9380f3bce61b9b9d5df02b79dda76/src/console/controllers/EnvironmentsController.php#L16-L33 |
237,979 | diatem-net/jin-context | src/Context/DeviceDetect.php | DeviceDetect.detectDevice | protected static function detectDevice()
{
$detect = new MobileDetect();
self::$detectCode = array();
self::$detectCode['tablet'] = $detect->isTablet();
self::$detectCode['mobile'] = $detect->isMobile() && !$detect->isTablet();
self::$detectCode['desktop'] = !self::$detectCode['tablet'] && !self::$detectCode['mobile'];
self::$detectCode['device'] = 'desktop';
foreach ($detect->getRules() as $name => $regex) {
if ($detect->{'is' . $name}()) {
self::$detectCode['device'] = $name;
break;
}
}
} | php | protected static function detectDevice()
{
$detect = new MobileDetect();
self::$detectCode = array();
self::$detectCode['tablet'] = $detect->isTablet();
self::$detectCode['mobile'] = $detect->isMobile() && !$detect->isTablet();
self::$detectCode['desktop'] = !self::$detectCode['tablet'] && !self::$detectCode['mobile'];
self::$detectCode['device'] = 'desktop';
foreach ($detect->getRules() as $name => $regex) {
if ($detect->{'is' . $name}()) {
self::$detectCode['device'] = $name;
break;
}
}
} | [
"protected",
"static",
"function",
"detectDevice",
"(",
")",
"{",
"$",
"detect",
"=",
"new",
"MobileDetect",
"(",
")",
";",
"self",
"::",
"$",
"detectCode",
"=",
"array",
"(",
")",
";",
"self",
"::",
"$",
"detectCode",
"[",
"'tablet'",
"]",
"=",
"$",
... | Permet l'identification de la plate-forme | [
"Permet",
"l",
"identification",
"de",
"la",
"plate",
"-",
"forme"
] | 359ef4882b28d874036b09174f5b134de176fe1d | https://github.com/diatem-net/jin-context/blob/359ef4882b28d874036b09174f5b134de176fe1d/src/Context/DeviceDetect.php#L80-L94 |
237,980 | lutsen/property-slug | src/Slug.php | Slug.uniqueSlug | private function uniqueSlug($bean, $property_name, $slug) {
$other = \R::findOne($bean->getMeta('type'), $property_name . ' = ? ', [ $slug ] );
if ($other) {
if ($other->id == $bean->id) {
return true;
} else {
return false;
}
} else {
return true;
}
} | php | private function uniqueSlug($bean, $property_name, $slug) {
$other = \R::findOne($bean->getMeta('type'), $property_name . ' = ? ', [ $slug ] );
if ($other) {
if ($other->id == $bean->id) {
return true;
} else {
return false;
}
} else {
return true;
}
} | [
"private",
"function",
"uniqueSlug",
"(",
"$",
"bean",
",",
"$",
"property_name",
",",
"$",
"slug",
")",
"{",
"$",
"other",
"=",
"\\",
"R",
"::",
"findOne",
"(",
"$",
"bean",
"->",
"getMeta",
"(",
"'type'",
")",
",",
"$",
"property_name",
".",
"' = ?... | Checks if the slug of a bean is unique
@param bean $bean The bean to check the slug for.
@param string $property_name The name of the property to check the slug for.
@param string $slug The slug to check.
@return boolean Returns true if the slug is unique, false otherwise. | [
"Checks",
"if",
"the",
"slug",
"of",
"a",
"bean",
"is",
"unique"
] | cc3238acdfac513bec0557b51a1e4167ef1fb635 | https://github.com/lutsen/property-slug/blob/cc3238acdfac513bec0557b51a1e4167ef1fb635/src/Slug.php#L64-L75 |
237,981 | lutsen/property-slug | src/Slug.php | Slug.makeSlug | private function makeSlug($bean, $property_name, $slug_string) {
$string = $this->neatTrim( $slug_string, 100 ); // Maximum of 100 characters with complete words
$slug = $this->slugify( $string );
if ( $this->uniqueSlug( $bean, $property_name, $slug ) ) {
return $slug;
} else {
// Create slug with uniqid() and check again
return $this->makeSlug( $bean, $property_name, $slug . '-' . uniqid() );
}
} | php | private function makeSlug($bean, $property_name, $slug_string) {
$string = $this->neatTrim( $slug_string, 100 ); // Maximum of 100 characters with complete words
$slug = $this->slugify( $string );
if ( $this->uniqueSlug( $bean, $property_name, $slug ) ) {
return $slug;
} else {
// Create slug with uniqid() and check again
return $this->makeSlug( $bean, $property_name, $slug . '-' . uniqid() );
}
} | [
"private",
"function",
"makeSlug",
"(",
"$",
"bean",
",",
"$",
"property_name",
",",
"$",
"slug_string",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"neatTrim",
"(",
"$",
"slug_string",
",",
"100",
")",
";",
"// Maximum of 100 characters with complete wor... | Returns a unique slug for a bean with a maximum of 100 characters with complete words.
@param bean $bean The bean to create the slug for.
@param string $property_name The property name to create the slug for.
@param string $slug_string The input string for the slug.
@return string The slug. | [
"Returns",
"a",
"unique",
"slug",
"for",
"a",
"bean",
"with",
"a",
"maximum",
"of",
"100",
"characters",
"with",
"complete",
"words",
"."
] | cc3238acdfac513bec0557b51a1e4167ef1fb635 | https://github.com/lutsen/property-slug/blob/cc3238acdfac513bec0557b51a1e4167ef1fb635/src/Slug.php#L121-L130 |
237,982 | tarsana/filesystem | src/Adapters/Memory.php | Memory.realpath | public function realpath($path)
{
$path = str_replace('\\', '/', rtrim($path, '/'));
if ($path[0] != '/' && (strlen($path) < 2 || $path[1] != ':')) {
$path = getcwd() . '/' . $path;
}
$parts = explode('/', $path);
$path = [];
foreach ($parts as $part) {
if ($part == '..') {
array_pop($path);
} else if ($part != '.') {
array_push($path, $part);
}
}
return implode('/', $path);
} | php | public function realpath($path)
{
$path = str_replace('\\', '/', rtrim($path, '/'));
if ($path[0] != '/' && (strlen($path) < 2 || $path[1] != ':')) {
$path = getcwd() . '/' . $path;
}
$parts = explode('/', $path);
$path = [];
foreach ($parts as $part) {
if ($part == '..') {
array_pop($path);
} else if ($part != '.') {
array_push($path, $part);
}
}
return implode('/', $path);
} | [
"public",
"function",
"realpath",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
")",
";",
"if",
"(",
"$",
"path",
"[",
"0",
"]",
"!=",
"'/'",
"&&",
"(",
... | Makes the path absolute and removes '.'
and '..' directories from it.
@param string $path
@return string | [
"Makes",
"the",
"path",
"absolute",
"and",
"removes",
".",
"and",
"..",
"directories",
"from",
"it",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L79-L95 |
237,983 | tarsana/filesystem | src/Adapters/Memory.php | Memory.glob | public function glob($pattern)
{
$matched = [];
$pattern = $this->realpath($pattern);
$pattern = '@^' . str_replace(['\*', '\?'], ['[^\\\/]*', '.'], preg_quote($pattern)) .'$@';
foreach (array_keys($this->files) as $path) {
if (preg_match($pattern, $path))
$matched[] = $path;
}
return $matched;
} | php | public function glob($pattern)
{
$matched = [];
$pattern = $this->realpath($pattern);
$pattern = '@^' . str_replace(['\*', '\?'], ['[^\\\/]*', '.'], preg_quote($pattern)) .'$@';
foreach (array_keys($this->files) as $path) {
if (preg_match($pattern, $path))
$matched[] = $path;
}
return $matched;
} | [
"public",
"function",
"glob",
"(",
"$",
"pattern",
")",
"{",
"$",
"matched",
"=",
"[",
"]",
";",
"$",
"pattern",
"=",
"$",
"this",
"->",
"realpath",
"(",
"$",
"pattern",
")",
";",
"$",
"pattern",
"=",
"'@^'",
".",
"str_replace",
"(",
"[",
"'\\*'",
... | Equivalent to PHP `glob` function.
@param string $pattern
@return array | [
"Equivalent",
"to",
"PHP",
"glob",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L103-L113 |
237,984 | tarsana/filesystem | src/Adapters/Memory.php | Memory.isFile | public function isFile($path)
{
$node = $this->at($path);
return null !== $node && 'file' === $node->type;
} | php | public function isFile($path)
{
$node = $this->at($path);
return null !== $node && 'file' === $node->type;
} | [
"public",
"function",
"isFile",
"(",
"$",
"path",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
";",
"return",
"null",
"!==",
"$",
"node",
"&&",
"'file'",
"===",
"$",
"node",
"->",
"type",
";",
"}"
] | Equivalent to PHP `is_file` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"is_file",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L121-L125 |
237,985 | tarsana/filesystem | src/Adapters/Memory.php | Memory.isDir | public function isDir($path)
{
$node = $this->at($path);
return null !== $node && 'dir' === $node->type;
} | php | public function isDir($path)
{
$node = $this->at($path);
return null !== $node && 'dir' === $node->type;
} | [
"public",
"function",
"isDir",
"(",
"$",
"path",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
";",
"return",
"null",
"!==",
"$",
"node",
"&&",
"'dir'",
"===",
"$",
"node",
"->",
"type",
";",
"}"
] | Equivalent to PHP `is_dir` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"is_dir",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L133-L137 |
237,986 | tarsana/filesystem | src/Adapters/Memory.php | Memory.md5File | public function md5File($path)
{
if (! $this->isFile($path))
return false;
return md5($this->at($path)->content);
} | php | public function md5File($path)
{
if (! $this->isFile($path))
return false;
return md5($this->at($path)->content);
} | [
"public",
"function",
"md5File",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
")",
")",
"return",
"false",
";",
"return",
"md5",
"(",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
"->",
"content",
... | Equivalent to PHP `md5_file` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"md5_file",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L156-L161 |
237,987 | tarsana/filesystem | src/Adapters/Memory.php | Memory.fileGetContents | public function fileGetContents($path)
{
if (! $this->isFile($path))
return false;
return $this->at($path)->content;
} | php | public function fileGetContents($path)
{
if (! $this->isFile($path))
return false;
return $this->at($path)->content;
} | [
"public",
"function",
"fileGetContents",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
")",
")",
"return",
"false",
";",
"return",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
"->",
"content",
";",
... | Equivalent to PHP `file_get_contents` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"file_get_contents",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L169-L174 |
237,988 | tarsana/filesystem | src/Adapters/Memory.php | Memory.filePutContents | public function filePutContents($path, $content, $flags = 0)
{
if (! $this->isFile($path) && !$this->createFile($path))
return false;
if (($flags & FILE_APPEND) == FILE_APPEND)
$this->at($path)->content .= $content;
else
$this->at($path)->content = $content;
return true;
} | php | public function filePutContents($path, $content, $flags = 0)
{
if (! $this->isFile($path) && !$this->createFile($path))
return false;
if (($flags & FILE_APPEND) == FILE_APPEND)
$this->at($path)->content .= $content;
else
$this->at($path)->content = $content;
return true;
} | [
"public",
"function",
"filePutContents",
"(",
"$",
"path",
",",
"$",
"content",
",",
"$",
"flags",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFile",
"(",
"$",
"path",
")",
"&&",
"!",
"$",
"this",
"->",
"createFile",
"(",
"$",
"path... | Equivalent to PHP `file_put_contents` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"file_put_contents",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L182-L191 |
237,989 | tarsana/filesystem | src/Adapters/Memory.php | Memory.isReadable | public function isReadable($path)
{
$node = $this->at($path);
return null !== $node && (0x0100 & $node->perms);
} | php | public function isReadable($path)
{
$node = $this->at($path);
return null !== $node && (0x0100 & $node->perms);
} | [
"public",
"function",
"isReadable",
"(",
"$",
"path",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
";",
"return",
"null",
"!==",
"$",
"node",
"&&",
"(",
"0x0100",
"&",
"$",
"node",
"->",
"perms",
")",
";",
"}"
] | Equivalent to PHP `is_readable` function.
Assumes that the user is the file owner.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"is_readable",
"function",
".",
"Assumes",
"that",
"the",
"user",
"is",
"the",
"file",
"owner",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L200-L204 |
237,990 | tarsana/filesystem | src/Adapters/Memory.php | Memory.isWritable | public function isWritable($path)
{
$node = $this->at($path);
return null !== $node && (0x0080 & $node->perms);
} | php | public function isWritable($path)
{
$node = $this->at($path);
return null !== $node && (0x0080 & $node->perms);
} | [
"public",
"function",
"isWritable",
"(",
"$",
"path",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
";",
"return",
"null",
"!==",
"$",
"node",
"&&",
"(",
"0x0080",
"&",
"$",
"node",
"->",
"perms",
")",
";",
"}"
] | Equivalent to PHP `is_writable` function.
Assumes that the user is the file owner.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"is_writable",
"function",
".",
"Assumes",
"that",
"the",
"user",
"is",
"the",
"file",
"owner",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L213-L217 |
237,991 | tarsana/filesystem | src/Adapters/Memory.php | Memory.isExecutable | public function isExecutable($path)
{
$node = $this->at($path);
return null !== $node
&& (0x0040 & $node->perms)
&& !(0x0800 & $node->perms);
} | php | public function isExecutable($path)
{
$node = $this->at($path);
return null !== $node
&& (0x0040 & $node->perms)
&& !(0x0800 & $node->perms);
} | [
"public",
"function",
"isExecutable",
"(",
"$",
"path",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
";",
"return",
"null",
"!==",
"$",
"node",
"&&",
"(",
"0x0040",
"&",
"$",
"node",
"->",
"perms",
")",
"&&",
"!",
... | Equivalent to PHP `is_executable` function.
Assumes that the user is the file owner.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"is_executable",
"function",
".",
"Assumes",
"that",
"the",
"user",
"is",
"the",
"file",
"owner",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L226-L232 |
237,992 | tarsana/filesystem | src/Adapters/Memory.php | Memory.rmdir | public function rmdir($path)
{
$path = $this->realpath($path) . '/';
$length = strlen($path);
foreach (array_keys($this->files) as $filename) {
if (substr($filename, 0, $length) === $path) {
return false;
}
}
$this->at($path, null);
return true;
} | php | public function rmdir($path)
{
$path = $this->realpath($path) . '/';
$length = strlen($path);
foreach (array_keys($this->files) as $filename) {
if (substr($filename, 0, $length) === $path) {
return false;
}
}
$this->at($path, null);
return true;
} | [
"public",
"function",
"rmdir",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"realpath",
"(",
"$",
"path",
")",
".",
"'/'",
";",
"$",
"length",
"=",
"strlen",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
... | Equivalent to PHP `rmdir` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"rmdir",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L252-L263 |
237,993 | tarsana/filesystem | src/Adapters/Memory.php | Memory.rename | public function rename($oldPath, $newPath)
{
$old = $this->at($oldPath);
$new = $this->at($newPath);
if (null === $old || (null !== $new && 'dir' === $new->type))
return false;
if ('file' === $old->type) {
$this->at($newPath, $old);
} else {
if (! $this->mkdir($newPath, $old->perms)) {
return false;
}
$oldPath = $this->realpath($oldPath) . '/';
$newPath = $this->realpath($newPath) . '/';
$length = strlen($oldPath);
foreach (array_keys($this->files) as $childPath) {
if (substr($childPath, 0, $length) === $oldPath) {
$newChildPath = $newPath . substr($childPath, $length);
$this->at($newChildPath, $this->at($childPath));
$this->at($childPath, null);
}
}
}
$this->at($oldPath, null);
return true;
} | php | public function rename($oldPath, $newPath)
{
$old = $this->at($oldPath);
$new = $this->at($newPath);
if (null === $old || (null !== $new && 'dir' === $new->type))
return false;
if ('file' === $old->type) {
$this->at($newPath, $old);
} else {
if (! $this->mkdir($newPath, $old->perms)) {
return false;
}
$oldPath = $this->realpath($oldPath) . '/';
$newPath = $this->realpath($newPath) . '/';
$length = strlen($oldPath);
foreach (array_keys($this->files) as $childPath) {
if (substr($childPath, 0, $length) === $oldPath) {
$newChildPath = $newPath . substr($childPath, $length);
$this->at($newChildPath, $this->at($childPath));
$this->at($childPath, null);
}
}
}
$this->at($oldPath, null);
return true;
} | [
"public",
"function",
"rename",
"(",
"$",
"oldPath",
",",
"$",
"newPath",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"oldPath",
")",
";",
"$",
"new",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"newPath",
")",
";",
"if",
"(",
"... | Equivalent to PHP `rename` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"rename",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L271-L298 |
237,994 | tarsana/filesystem | src/Adapters/Memory.php | Memory.fileperms | public function fileperms($path)
{
$node = $this->at($path);
if (null === $node) {
return false;
}
return $node->perms;
} | php | public function fileperms($path)
{
$node = $this->at($path);
if (null === $node) {
return false;
}
return $node->perms;
} | [
"public",
"function",
"fileperms",
"(",
"$",
"path",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
";",
"if",
"(",
"null",
"===",
"$",
"node",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"node",
"->",
"pe... | Equivalent to PHP `fileperms` function.
@param string $path
@return int | [
"Equivalent",
"to",
"PHP",
"fileperms",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L306-L313 |
237,995 | tarsana/filesystem | src/Adapters/Memory.php | Memory.chmod | public function chmod($path, $value)
{
$node = $this->at($path);
if (null === $node || !is_numeric($value)) {
return false;
}
$node->perms = $value;
return true;
} | php | public function chmod($path, $value)
{
$node = $this->at($path);
if (null === $node || !is_numeric($value)) {
return false;
}
$node->perms = $value;
return true;
} | [
"public",
"function",
"chmod",
"(",
"$",
"path",
",",
"$",
"value",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
";",
"if",
"(",
"null",
"===",
"$",
"node",
"||",
"!",
"is_numeric",
"(",
"$",
"value",
")",
")",
... | Equivalent to PHP `chmod` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"chmod",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L321-L329 |
237,996 | tarsana/filesystem | src/Adapters/Memory.php | Memory.mkdir | public function mkdir($path, $mode = 0777, $recursive = false)
{
if (null !== $this->at($path)) {
trigger_error("mkdir(): File exists");
return false;
}
$parts = explode('/', $this->realpath($path));
$filesCount = 0;
$missing = [];
$item = array_shift($parts);
foreach ($parts as $part) {
$item .= "/{$part}";
$node = $this->at($item);
if ($node === null) {
$missing[] = $item;
} else if ($node->type == 'file') {
$filesCount ++;
}
}
if ($filesCount > 0) {
trigger_error("mkdir(): Not a directory");
return false;
}
if (count($missing) > 1 && !$recursive) {
trigger_error("mkdir(): No such file or directory");
return false;
}
foreach ($missing as $path) {
$this->at($path, (object) [
'type' => 'dir',
'perms' => $mode
]);
}
return true;
} | php | public function mkdir($path, $mode = 0777, $recursive = false)
{
if (null !== $this->at($path)) {
trigger_error("mkdir(): File exists");
return false;
}
$parts = explode('/', $this->realpath($path));
$filesCount = 0;
$missing = [];
$item = array_shift($parts);
foreach ($parts as $part) {
$item .= "/{$part}";
$node = $this->at($item);
if ($node === null) {
$missing[] = $item;
} else if ($node->type == 'file') {
$filesCount ++;
}
}
if ($filesCount > 0) {
trigger_error("mkdir(): Not a directory");
return false;
}
if (count($missing) > 1 && !$recursive) {
trigger_error("mkdir(): No such file or directory");
return false;
}
foreach ($missing as $path) {
$this->at($path, (object) [
'type' => 'dir',
'perms' => $mode
]);
}
return true;
} | [
"public",
"function",
"mkdir",
"(",
"$",
"path",
",",
"$",
"mode",
"=",
"0777",
",",
"$",
"recursive",
"=",
"false",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"at",
"(",
"$",
"path",
")",
")",
"{",
"trigger_error",
"(",
"\"mkdir(): Fil... | Equivalent to PHP `mkdir` function.
@param string $path
@return boolean | [
"Equivalent",
"to",
"PHP",
"mkdir",
"function",
"."
] | db6c8f040af38dfb01066e382645aff6c72530fa | https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Adapters/Memory.php#L348-L387 |
237,997 | weew/app-error-handler-black-hole | src/Weew/App/ErrorHandler/BlackHole/BlackHoleErrorHandler.php | BlackHoleErrorHandler.enable | public function enable() {
// suppress all errors
$this->errorHandler->addErrorHandler(function() {return true;});
$this->errorHandler->addExceptionHandler(function(Exception $ex) {return true;});
} | php | public function enable() {
// suppress all errors
$this->errorHandler->addErrorHandler(function() {return true;});
$this->errorHandler->addExceptionHandler(function(Exception $ex) {return true;});
} | [
"public",
"function",
"enable",
"(",
")",
"{",
"// suppress all errors",
"$",
"this",
"->",
"errorHandler",
"->",
"addErrorHandler",
"(",
"function",
"(",
")",
"{",
"return",
"true",
";",
"}",
")",
";",
"$",
"this",
"->",
"errorHandler",
"->",
"addExceptionH... | Enable suppressing of errors. | [
"Enable",
"suppressing",
"of",
"errors",
"."
] | 45a06fcf5dcf925d62ed070a49393687f473fdfa | https://github.com/weew/app-error-handler-black-hole/blob/45a06fcf5dcf925d62ed070a49393687f473fdfa/src/Weew/App/ErrorHandler/BlackHole/BlackHoleErrorHandler.php#L26-L30 |
237,998 | praxisnetau/silverware-google | src/Extensions/GoogleConfig.php | GoogleConfig.getBodyAttributes | public function getBodyAttributes()
{
$attributes = [];
$api = GoogleAPI::singleton();
if ($key = $api->getAPIKey()) {
$attributes['data-google-api-key'] = $key;
}
if ($lang = $api->getAPILanguage()) {
$attributes['data-google-api-lang'] = $lang;
}
if ($api->isAnalyticsEnabled()) {
$attributes['data-google-tracking-id'] = $api->getAnalyticsTrackingID();
}
return $attributes;
} | php | public function getBodyAttributes()
{
$attributes = [];
$api = GoogleAPI::singleton();
if ($key = $api->getAPIKey()) {
$attributes['data-google-api-key'] = $key;
}
if ($lang = $api->getAPILanguage()) {
$attributes['data-google-api-lang'] = $lang;
}
if ($api->isAnalyticsEnabled()) {
$attributes['data-google-tracking-id'] = $api->getAnalyticsTrackingID();
}
return $attributes;
} | [
"public",
"function",
"getBodyAttributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"$",
"api",
"=",
"GoogleAPI",
"::",
"singleton",
"(",
")",
";",
"if",
"(",
"$",
"key",
"=",
"$",
"api",
"->",
"getAPIKey",
"(",
")",
")",
"{",
"$",
"... | Answers the HTML tag attributes for the body as an array.
@return array | [
"Answers",
"the",
"HTML",
"tag",
"attributes",
"for",
"the",
"body",
"as",
"an",
"array",
"."
] | 573632d33fe99c9d943fec8733fa5bbce57586f5 | https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/Extensions/GoogleConfig.php#L172-L191 |
237,999 | praxisnetau/silverware-google | src/Extensions/GoogleConfig.php | GoogleConfig.getVerificationCode | protected function getVerificationCode($code)
{
// Trim Code:
$code = trim($code);
// Detect HTML:
if (stripos($code, '<meta') === 0) {
// Extract Verification Code:
preg_match('/content="(.+)"/', $code, $matches);
// Update or Nullify:
$code = isset($matches[1]) ? $matches[1] : null;
}
// Answer Code:
return $code;
} | php | protected function getVerificationCode($code)
{
// Trim Code:
$code = trim($code);
// Detect HTML:
if (stripos($code, '<meta') === 0) {
// Extract Verification Code:
preg_match('/content="(.+)"/', $code, $matches);
// Update or Nullify:
$code = isset($matches[1]) ? $matches[1] : null;
}
// Answer Code:
return $code;
} | [
"protected",
"function",
"getVerificationCode",
"(",
"$",
"code",
")",
"{",
"// Trim Code:",
"$",
"code",
"=",
"trim",
"(",
"$",
"code",
")",
";",
"// Detect HTML:",
"if",
"(",
"stripos",
"(",
"$",
"code",
",",
"'<meta'",
")",
"===",
"0",
")",
"{",
"//... | Removes any HTML present in the pasted value and answers the verification code.
@param string $code
@return string | [
"Removes",
"any",
"HTML",
"present",
"in",
"the",
"pasted",
"value",
"and",
"answers",
"the",
"verification",
"code",
"."
] | 573632d33fe99c9d943fec8733fa5bbce57586f5 | https://github.com/praxisnetau/silverware-google/blob/573632d33fe99c9d943fec8733fa5bbce57586f5/src/Extensions/GoogleConfig.php#L227-L250 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.