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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
239,000
|
BapCat/Services
|
src/ServiceContainer.php
|
ServiceContainer.boot
|
public function boot(): void {
if(count($this->queue) !== 0) {
throw new ServiceDependenciesNotRegisteredException($this->queue);
}
foreach($this->services as $service) {
$service->boot();
}
}
|
php
|
public function boot(): void {
if(count($this->queue) !== 0) {
throw new ServiceDependenciesNotRegisteredException($this->queue);
}
foreach($this->services as $service) {
$service->boot();
}
}
|
[
"public",
"function",
"boot",
"(",
")",
":",
"void",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"queue",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"ServiceDependenciesNotRegisteredException",
"(",
"$",
"this",
"->",
"queue",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"services",
"as",
"$",
"service",
")",
"{",
"$",
"service",
"->",
"boot",
"(",
")",
";",
"}",
"}"
] |
Boot all Service Providers
@throws ServiceDependenciesNotRegisteredException If any service provider's dependencies have not been registered
|
[
"Boot",
"all",
"Service",
"Providers"
] |
7318092a316f8f8f2ce9f09598fb5e750119dd30
|
https://github.com/BapCat/Services/blob/7318092a316f8f8f2ce9f09598fb5e750119dd30/src/ServiceContainer.php#L94-L102
|
239,001
|
thecmsthread/core-admin
|
src/Controller/Auth.php
|
Auth.handleLogin
|
public function handleLogin(array $request = [])
{
$validator = new \Valitron\Validator($request);
$validator->rule('required', ['username', 'password']);
$validator->rule(function ($field, $value, array $params, array $fields) {
return is_string($value);
}, ['username', 'password'])->message("Invalid username or password");
$validator->rule('lengthBetween', 'username', 6, 200);
$validator->rule('lengthBetween', 'password', 8, 80);
if ($validator->validate() === false) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
return $this->templates->render("Auth::Login", [
"messages" => [
'error' => 'Incorrect username and/or password',
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
}
$response = $this->core->api('User/login/' . $request['username'], 'POST')->run($request);
if (headers_sent() === false) {
foreach ($response["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
if ($response["headers"][0][2] === 422) {
return $this->templates->render("Auth::Login", [
"messages" => [
'error' => 'Incorrect username and/or password',
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
} elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
$this->core->auth()->validate($response["response"]);
$_SERVER['REQUEST_URI'] = 'GET';
$this->router->map('GET', '/', "User@showProfile", 'home-page');
return $this->redirect();
} else {
return $this->templates->render("500", [
"error" => $response['response'],
"result" => ''
]);
}
}
|
php
|
public function handleLogin(array $request = [])
{
$validator = new \Valitron\Validator($request);
$validator->rule('required', ['username', 'password']);
$validator->rule(function ($field, $value, array $params, array $fields) {
return is_string($value);
}, ['username', 'password'])->message("Invalid username or password");
$validator->rule('lengthBetween', 'username', 6, 200);
$validator->rule('lengthBetween', 'password', 8, 80);
if ($validator->validate() === false) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
return $this->templates->render("Auth::Login", [
"messages" => [
'error' => 'Incorrect username and/or password',
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
}
$response = $this->core->api('User/login/' . $request['username'], 'POST')->run($request);
if (headers_sent() === false) {
foreach ($response["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
if ($response["headers"][0][2] === 422) {
return $this->templates->render("Auth::Login", [
"messages" => [
'error' => 'Incorrect username and/or password',
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
} elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
$this->core->auth()->validate($response["response"]);
$_SERVER['REQUEST_URI'] = 'GET';
$this->router->map('GET', '/', "User@showProfile", 'home-page');
return $this->redirect();
} else {
return $this->templates->render("500", [
"error" => $response['response'],
"result" => ''
]);
}
}
|
[
"public",
"function",
"handleLogin",
"(",
"array",
"$",
"request",
"=",
"[",
"]",
")",
"{",
"$",
"validator",
"=",
"new",
"\\",
"Valitron",
"\\",
"Validator",
"(",
"$",
"request",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'required'",
",",
"[",
"'username'",
",",
"'password'",
"]",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"function",
"(",
"$",
"field",
",",
"$",
"value",
",",
"array",
"$",
"params",
",",
"array",
"$",
"fields",
")",
"{",
"return",
"is_string",
"(",
"$",
"value",
")",
";",
"}",
",",
"[",
"'username'",
",",
"'password'",
"]",
")",
"->",
"message",
"(",
"\"Invalid username or password\"",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'lengthBetween'",
",",
"'username'",
",",
"6",
",",
"200",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'lengthBetween'",
",",
"'password'",
",",
"8",
",",
"80",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"validate",
"(",
")",
"===",
"false",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
"===",
"false",
")",
"{",
"header",
"(",
"'X-PHP-Response-Code: 422'",
",",
"true",
",",
"422",
")",
";",
"}",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"Auth::Login\"",
",",
"[",
"\"messages\"",
"=>",
"[",
"'error'",
"=>",
"'Incorrect username and/or password'",
",",
"'info'",
"=>",
"''",
",",
"'success'",
"=>",
"''",
",",
"'warning'",
"=>",
"''",
"]",
",",
"\"username\"",
"=>",
"$",
"request",
"[",
"'username'",
"]",
"]",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"core",
"->",
"api",
"(",
"'User/login/'",
".",
"$",
"request",
"[",
"'username'",
"]",
",",
"'POST'",
")",
"->",
"run",
"(",
"$",
"request",
")",
";",
"if",
"(",
"headers_sent",
"(",
")",
"===",
"false",
")",
"{",
"foreach",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"as",
"$",
"header",
")",
"{",
"header",
"(",
"$",
"header",
"[",
"0",
"]",
",",
"$",
"header",
"[",
"1",
"]",
",",
"$",
"header",
"[",
"2",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"===",
"422",
")",
"{",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"Auth::Login\"",
",",
"[",
"\"messages\"",
"=>",
"[",
"'error'",
"=>",
"'Incorrect username and/or password'",
",",
"'info'",
"=>",
"''",
",",
"'success'",
"=>",
"''",
",",
"'warning'",
"=>",
"''",
"]",
",",
"\"username\"",
"=>",
"$",
"request",
"[",
"'username'",
"]",
"]",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"-",
"200",
")",
"*",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"-",
"299",
")",
"<=",
"0",
")",
"{",
"$",
"this",
"->",
"core",
"->",
"auth",
"(",
")",
"->",
"validate",
"(",
"$",
"response",
"[",
"\"response\"",
"]",
")",
";",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
"=",
"'GET'",
";",
"$",
"this",
"->",
"router",
"->",
"map",
"(",
"'GET'",
",",
"'/'",
",",
"\"User@showProfile\"",
",",
"'home-page'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"500\"",
",",
"[",
"\"error\"",
"=>",
"$",
"response",
"[",
"'response'",
"]",
",",
"\"result\"",
"=>",
"''",
"]",
")",
";",
"}",
"}"
] |
Handle the login page submission
|
[
"Handle",
"the",
"login",
"page",
"submission"
] |
020595646e2dd521683e5352e6d9dbad420c06fb
|
https://github.com/thecmsthread/core-admin/blob/020595646e2dd521683e5352e6d9dbad420c06fb/src/Controller/Auth.php#L147-L198
|
239,002
|
thecmsthread/core-admin
|
src/Controller/Auth.php
|
Auth.handleRegister
|
public function handleRegister(array $request = [])
{
$validator = new \Valitron\Validator($request);
$validator->rule('required', ['username', 'password', 'confirm_password']);
$validator->rule(function ($field, $value, array $params, array $fields) {
return is_string($value);
}, ['username', 'password', 'confirm_password'])->message("{field} must be a string");
$validator->rule('equals', 'confirm_password', 'password');
$validator->rule('lengthBetween', 'username', 6, 200);
$validator->rule('lengthBetween', 'password', 8, 80);
if ($validator->validate() === false) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
return $this->templates->render("Auth::Register", [
"messages" => [
'error' => $validator->errors(),
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
}
$response = $this->core->api('User/', 'POST')->run($request);
if (headers_sent() === false) {
foreach ($response["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
if ($response["headers"][0][2] === 422) {
return $this->templates->render("Auth::Register", [
"messages" => [
'error' => $response['response'],
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
} elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=1");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=1";
}
} else {
return $this->templates->render("500", [
"error" => $response['response'],
"result" => ''
]);
}
}
|
php
|
public function handleRegister(array $request = [])
{
$validator = new \Valitron\Validator($request);
$validator->rule('required', ['username', 'password', 'confirm_password']);
$validator->rule(function ($field, $value, array $params, array $fields) {
return is_string($value);
}, ['username', 'password', 'confirm_password'])->message("{field} must be a string");
$validator->rule('equals', 'confirm_password', 'password');
$validator->rule('lengthBetween', 'username', 6, 200);
$validator->rule('lengthBetween', 'password', 8, 80);
if ($validator->validate() === false) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
return $this->templates->render("Auth::Register", [
"messages" => [
'error' => $validator->errors(),
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
}
$response = $this->core->api('User/', 'POST')->run($request);
if (headers_sent() === false) {
foreach ($response["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
if ($response["headers"][0][2] === 422) {
return $this->templates->render("Auth::Register", [
"messages" => [
'error' => $response['response'],
'info' => '',
'success' => '',
'warning' => ''
],
"username" => $request['username']
]);
} elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=1");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=1";
}
} else {
return $this->templates->render("500", [
"error" => $response['response'],
"result" => ''
]);
}
}
|
[
"public",
"function",
"handleRegister",
"(",
"array",
"$",
"request",
"=",
"[",
"]",
")",
"{",
"$",
"validator",
"=",
"new",
"\\",
"Valitron",
"\\",
"Validator",
"(",
"$",
"request",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'required'",
",",
"[",
"'username'",
",",
"'password'",
",",
"'confirm_password'",
"]",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"function",
"(",
"$",
"field",
",",
"$",
"value",
",",
"array",
"$",
"params",
",",
"array",
"$",
"fields",
")",
"{",
"return",
"is_string",
"(",
"$",
"value",
")",
";",
"}",
",",
"[",
"'username'",
",",
"'password'",
",",
"'confirm_password'",
"]",
")",
"->",
"message",
"(",
"\"{field} must be a string\"",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'equals'",
",",
"'confirm_password'",
",",
"'password'",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'lengthBetween'",
",",
"'username'",
",",
"6",
",",
"200",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'lengthBetween'",
",",
"'password'",
",",
"8",
",",
"80",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"validate",
"(",
")",
"===",
"false",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
"===",
"false",
")",
"{",
"header",
"(",
"'X-PHP-Response-Code: 422'",
",",
"true",
",",
"422",
")",
";",
"}",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"Auth::Register\"",
",",
"[",
"\"messages\"",
"=>",
"[",
"'error'",
"=>",
"$",
"validator",
"->",
"errors",
"(",
")",
",",
"'info'",
"=>",
"''",
",",
"'success'",
"=>",
"''",
",",
"'warning'",
"=>",
"''",
"]",
",",
"\"username\"",
"=>",
"$",
"request",
"[",
"'username'",
"]",
"]",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"core",
"->",
"api",
"(",
"'User/'",
",",
"'POST'",
")",
"->",
"run",
"(",
"$",
"request",
")",
";",
"if",
"(",
"headers_sent",
"(",
")",
"===",
"false",
")",
"{",
"foreach",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"as",
"$",
"header",
")",
"{",
"header",
"(",
"$",
"header",
"[",
"0",
"]",
",",
"$",
"header",
"[",
"1",
"]",
",",
"$",
"header",
"[",
"2",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"===",
"422",
")",
"{",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"Auth::Register\"",
",",
"[",
"\"messages\"",
"=>",
"[",
"'error'",
"=>",
"$",
"response",
"[",
"'response'",
"]",
",",
"'info'",
"=>",
"''",
",",
"'success'",
"=>",
"''",
",",
"'warning'",
"=>",
"''",
"]",
",",
"\"username\"",
"=>",
"$",
"request",
"[",
"'username'",
"]",
"]",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"-",
"200",
")",
"*",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"-",
"299",
")",
"<=",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'template'",
"]",
")",
"===",
"false",
")",
"{",
"return",
"redirect",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=1\"",
")",
";",
"}",
"else",
"{",
"return",
"'Redirect: '",
".",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=1\"",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"500\"",
",",
"[",
"\"error\"",
"=>",
"$",
"response",
"[",
"'response'",
"]",
",",
"\"result\"",
"=>",
"''",
"]",
")",
";",
"}",
"}"
] |
Handle the registration page submission
|
[
"Handle",
"the",
"registration",
"page",
"submission"
] |
020595646e2dd521683e5352e6d9dbad420c06fb
|
https://github.com/thecmsthread/core-admin/blob/020595646e2dd521683e5352e6d9dbad420c06fb/src/Controller/Auth.php#L219-L272
|
239,003
|
thecmsthread/core-admin
|
src/Controller/Auth.php
|
Auth.handleForgot
|
public function handleForgot(array $request = [])
{
$validator = new \Valitron\Validator($request);
$validator->rule('required', 'email');
$validator->rule('email', 'email');
if ($validator->validate() === false) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
return $this->templates->render("Auth::Forgot", [
"messages" => [
'error' => $validator->errors(),
'info' => '',
'success' => '',
'warning' => ''
],
"email" => $request['email']
]);
}
$response = $this->core->api('User/forgot/' . $request['email'], 'POST')->run($request);
if (headers_sent() === false) {
foreach ($response["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
if ($response["headers"][0][2] === 422) {
return $this->templates->render("Auth::Forgot", [
"messages" => [
'error' => $response['response'],
'info' => '',
'success' => '',
'warning' => ''
],
"email" => $request['email']
]);
} elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=2");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=2";
}
} else {
return $this->templates->render("500", [
"error" => $response['response'],
"result" => ''
]);
}
}
|
php
|
public function handleForgot(array $request = [])
{
$validator = new \Valitron\Validator($request);
$validator->rule('required', 'email');
$validator->rule('email', 'email');
if ($validator->validate() === false) {
if (headers_sent() === false) {
header('X-PHP-Response-Code: 422', true, 422);
}
return $this->templates->render("Auth::Forgot", [
"messages" => [
'error' => $validator->errors(),
'info' => '',
'success' => '',
'warning' => ''
],
"email" => $request['email']
]);
}
$response = $this->core->api('User/forgot/' . $request['email'], 'POST')->run($request);
if (headers_sent() === false) {
foreach ($response["headers"] as $header) {
header($header[0], $header[1], $header[2]);
}
}
if ($response["headers"][0][2] === 422) {
return $this->templates->render("Auth::Forgot", [
"messages" => [
'error' => $response['response'],
'info' => '',
'success' => '',
'warning' => ''
],
"email" => $request['email']
]);
} elseif (($response["headers"][0][2] - 200) * ($response["headers"][0][2] - 299) <= 0) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=2");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=2";
}
} else {
return $this->templates->render("500", [
"error" => $response['response'],
"result" => ''
]);
}
}
|
[
"public",
"function",
"handleForgot",
"(",
"array",
"$",
"request",
"=",
"[",
"]",
")",
"{",
"$",
"validator",
"=",
"new",
"\\",
"Valitron",
"\\",
"Validator",
"(",
"$",
"request",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'required'",
",",
"'email'",
")",
";",
"$",
"validator",
"->",
"rule",
"(",
"'email'",
",",
"'email'",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"validate",
"(",
")",
"===",
"false",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
"===",
"false",
")",
"{",
"header",
"(",
"'X-PHP-Response-Code: 422'",
",",
"true",
",",
"422",
")",
";",
"}",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"Auth::Forgot\"",
",",
"[",
"\"messages\"",
"=>",
"[",
"'error'",
"=>",
"$",
"validator",
"->",
"errors",
"(",
")",
",",
"'info'",
"=>",
"''",
",",
"'success'",
"=>",
"''",
",",
"'warning'",
"=>",
"''",
"]",
",",
"\"email\"",
"=>",
"$",
"request",
"[",
"'email'",
"]",
"]",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"core",
"->",
"api",
"(",
"'User/forgot/'",
".",
"$",
"request",
"[",
"'email'",
"]",
",",
"'POST'",
")",
"->",
"run",
"(",
"$",
"request",
")",
";",
"if",
"(",
"headers_sent",
"(",
")",
"===",
"false",
")",
"{",
"foreach",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"as",
"$",
"header",
")",
"{",
"header",
"(",
"$",
"header",
"[",
"0",
"]",
",",
"$",
"header",
"[",
"1",
"]",
",",
"$",
"header",
"[",
"2",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"===",
"422",
")",
"{",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"Auth::Forgot\"",
",",
"[",
"\"messages\"",
"=>",
"[",
"'error'",
"=>",
"$",
"response",
"[",
"'response'",
"]",
",",
"'info'",
"=>",
"''",
",",
"'success'",
"=>",
"''",
",",
"'warning'",
"=>",
"''",
"]",
",",
"\"email\"",
"=>",
"$",
"request",
"[",
"'email'",
"]",
"]",
")",
";",
"}",
"elseif",
"(",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"-",
"200",
")",
"*",
"(",
"$",
"response",
"[",
"\"headers\"",
"]",
"[",
"0",
"]",
"[",
"2",
"]",
"-",
"299",
")",
"<=",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'template'",
"]",
")",
"===",
"false",
")",
"{",
"return",
"redirect",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=2\"",
")",
";",
"}",
"else",
"{",
"return",
"'Redirect: '",
".",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=2\"",
";",
"}",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"500\"",
",",
"[",
"\"error\"",
"=>",
"$",
"response",
"[",
"'response'",
"]",
",",
"\"result\"",
"=>",
"''",
"]",
")",
";",
"}",
"}"
] |
Handle the forgot password page submission
|
[
"Handle",
"the",
"forgot",
"password",
"page",
"submission"
] |
020595646e2dd521683e5352e6d9dbad420c06fb
|
https://github.com/thecmsthread/core-admin/blob/020595646e2dd521683e5352e6d9dbad420c06fb/src/Controller/Auth.php#L292-L340
|
239,004
|
thecmsthread/core-admin
|
src/Controller/Auth.php
|
Auth.showReset
|
public function showReset(string $reset_code = null)
{
if ($reset_code === null) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=3");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=3";
}
}
$user = Model\User::where("reset_code", $reset_code)->first();
if ($user === null) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=3");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=3";
}
}
return $this->templates->render("Auth::Reset", [
"messages" => [
'error' => '',
'info' => '',
'success' => '',
'warning' => ''
]
]);
}
|
php
|
public function showReset(string $reset_code = null)
{
if ($reset_code === null) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=3");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=3";
}
}
$user = Model\User::where("reset_code", $reset_code)->first();
if ($user === null) {
if (isset($_GET['template']) === false) {
return redirect($this->router->generate('login-page') . "?m=3");
} else {
return 'Redirect: ' . $this->router->generate('login-page') . "?m=3";
}
}
return $this->templates->render("Auth::Reset", [
"messages" => [
'error' => '',
'info' => '',
'success' => '',
'warning' => ''
]
]);
}
|
[
"public",
"function",
"showReset",
"(",
"string",
"$",
"reset_code",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"reset_code",
"===",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'template'",
"]",
")",
"===",
"false",
")",
"{",
"return",
"redirect",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=3\"",
")",
";",
"}",
"else",
"{",
"return",
"'Redirect: '",
".",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=3\"",
";",
"}",
"}",
"$",
"user",
"=",
"Model",
"\\",
"User",
"::",
"where",
"(",
"\"reset_code\"",
",",
"$",
"reset_code",
")",
"->",
"first",
"(",
")",
";",
"if",
"(",
"$",
"user",
"===",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'template'",
"]",
")",
"===",
"false",
")",
"{",
"return",
"redirect",
"(",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=3\"",
")",
";",
"}",
"else",
"{",
"return",
"'Redirect: '",
".",
"$",
"this",
"->",
"router",
"->",
"generate",
"(",
"'login-page'",
")",
".",
"\"?m=3\"",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"templates",
"->",
"render",
"(",
"\"Auth::Reset\"",
",",
"[",
"\"messages\"",
"=>",
"[",
"'error'",
"=>",
"''",
",",
"'info'",
"=>",
"''",
",",
"'success'",
"=>",
"''",
",",
"'warning'",
"=>",
"''",
"]",
"]",
")",
";",
"}"
] |
Show the password reset page
|
[
"Show",
"the",
"password",
"reset",
"page"
] |
020595646e2dd521683e5352e6d9dbad420c06fb
|
https://github.com/thecmsthread/core-admin/blob/020595646e2dd521683e5352e6d9dbad420c06fb/src/Controller/Auth.php#L345-L371
|
239,005
|
TAMULib/Pipit
|
Core/Classes/Data/DBObject.php
|
DBObject.executeUpdate
|
protected function executeUpdate($sql,$bindparams=NULL) {
$result = $this->db->handle->prepare($sql);
$result->execute($bindparams);
if ($result->errorCode() == '00000') {
return true;
}
$this->logStatementError($result->errorInfo(),$sql);
return false;
}
|
php
|
protected function executeUpdate($sql,$bindparams=NULL) {
$result = $this->db->handle->prepare($sql);
$result->execute($bindparams);
if ($result->errorCode() == '00000') {
return true;
}
$this->logStatementError($result->errorInfo(),$sql);
return false;
}
|
[
"protected",
"function",
"executeUpdate",
"(",
"$",
"sql",
",",
"$",
"bindparams",
"=",
"NULL",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"db",
"->",
"handle",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"$",
"result",
"->",
"execute",
"(",
"$",
"bindparams",
")",
";",
"if",
"(",
"$",
"result",
"->",
"errorCode",
"(",
")",
"==",
"'00000'",
")",
"{",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"logStatementError",
"(",
"$",
"result",
"->",
"errorInfo",
"(",
")",
",",
"$",
"sql",
")",
";",
"return",
"false",
";",
"}"
] |
Execute an update query
@param string $sql The SQL query
@param mixed[] $bindparams An array of values to be binded by PDO to any query parameters
@return boolean True on success, false on anything else
|
[
"Execute",
"an",
"update",
"query"
] |
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
|
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/DBObject.php#L110-L118
|
239,006
|
TAMULib/Pipit
|
Core/Classes/Data/DBObject.php
|
DBObject.queryWithIndex
|
protected function queryWithIndex($sql,$index,$findex=NULL,$bindparams=NULL) {
if ($result = $this->executeQuery($sql,$bindparams)) {
$temp = array();
if ($findex) {
foreach ($result as $row) {
$temp[$row[$findex]][$row[$index]] = $row;
}
} else {
foreach ($result as $row) {
$temp[$row[$index]] = $row;
}
}
return $temp;
}
return false;
}
|
php
|
protected function queryWithIndex($sql,$index,$findex=NULL,$bindparams=NULL) {
if ($result = $this->executeQuery($sql,$bindparams)) {
$temp = array();
if ($findex) {
foreach ($result as $row) {
$temp[$row[$findex]][$row[$index]] = $row;
}
} else {
foreach ($result as $row) {
$temp[$row[$index]] = $row;
}
}
return $temp;
}
return false;
}
|
[
"protected",
"function",
"queryWithIndex",
"(",
"$",
"sql",
",",
"$",
"index",
",",
"$",
"findex",
"=",
"NULL",
",",
"$",
"bindparams",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"executeQuery",
"(",
"$",
"sql",
",",
"$",
"bindparams",
")",
")",
"{",
"$",
"temp",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"findex",
")",
"{",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"$",
"temp",
"[",
"$",
"row",
"[",
"$",
"findex",
"]",
"]",
"[",
"$",
"row",
"[",
"$",
"index",
"]",
"]",
"=",
"$",
"row",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"result",
"as",
"$",
"row",
")",
"{",
"$",
"temp",
"[",
"$",
"row",
"[",
"$",
"index",
"]",
"]",
"=",
"$",
"row",
";",
"}",
"}",
"return",
"$",
"temp",
";",
"}",
"return",
"false",
";",
"}"
] |
Query the DB and return the rows as a 1 or 2 dimensional indexed array
@param string $sql The query string
@param string $index The table's primary key
@param string $findex An optional foreign key from the table (when used, returns a 2 dimensional array, indexed first by $index, second by $findex)
@param mixed[] $bindparams An array of values to be binded by PDO to any query parameters
@return array[]|false $results A two dimensional array representing the resulting rows: array(array("id"=>1,"field"=>"value1"),array("id"=>2","field"=>"value2")), false on failure
|
[
"Query",
"the",
"DB",
"and",
"return",
"the",
"rows",
"as",
"a",
"1",
"or",
"2",
"dimensional",
"indexed",
"array"
] |
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
|
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/DBObject.php#L138-L153
|
239,007
|
TAMULib/Pipit
|
Core/Classes/Data/DBObject.php
|
DBObject.buildIn
|
protected function buildIn($ar,&$bindparams,$varprefix = 'v') {
$x=1;
foreach ($ar as $value) {
$sql .= ":{$varprefix}{$x},";
$bindparams[":{$varprefix}{$x}"] = $value;
$x++;
}
return 'IN ('.rtrim($sql,',').')';
}
|
php
|
protected function buildIn($ar,&$bindparams,$varprefix = 'v') {
$x=1;
foreach ($ar as $value) {
$sql .= ":{$varprefix}{$x},";
$bindparams[":{$varprefix}{$x}"] = $value;
$x++;
}
return 'IN ('.rtrim($sql,',').')';
}
|
[
"protected",
"function",
"buildIn",
"(",
"$",
"ar",
",",
"&",
"$",
"bindparams",
",",
"$",
"varprefix",
"=",
"'v'",
")",
"{",
"$",
"x",
"=",
"1",
";",
"foreach",
"(",
"$",
"ar",
"as",
"$",
"value",
")",
"{",
"$",
"sql",
".=",
"\":{$varprefix}{$x},\"",
";",
"$",
"bindparams",
"[",
"\":{$varprefix}{$x}\"",
"]",
"=",
"$",
"value",
";",
"$",
"x",
"++",
";",
"}",
"return",
"'IN ('",
".",
"rtrim",
"(",
"$",
"sql",
",",
"','",
")",
".",
"')'",
";",
"}"
] |
Returns a parametrized IN clause for use in a prepared statement
@param mixed[] $ar An array of values representing the contents of the IN clause
@param mixed[] $bindparams A reference to the caller's array of binded parameters
@param string $varprefix Can be used to avoid bind parameter naming collisions when calling multiple times within 1 statement
@return string The resulting IN clause
|
[
"Returns",
"a",
"parametrized",
"IN",
"clause",
"for",
"use",
"in",
"a",
"prepared",
"statement"
] |
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
|
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/DBObject.php#L178-L186
|
239,008
|
TAMULib/Pipit
|
Core/Classes/Data/DBObject.php
|
DBObject.buildInsertStatement
|
protected function buildInsertStatement($data,$table=null) {
if (!$table) {
$table = $this->primaryTable;
}
$bindparams = array();
$sql_fields = NULL;
$sql_values = NULL;
foreach ($data as $field=>$value) {
$sql_fields .= "{$field},";
$sql_values .= ":{$field},";
$bindparams[":{$field}"] = $value;
}
$sql_fields = rtrim($sql_fields,',');
$sql_values = rtrim($sql_values,',');
$sql = "INSERT INTO {$table} ({$sql_fields}) VALUES ({$sql_values})";
if ($this->executeUpdate($sql,$bindparams)) {
return $this->getLastInsertId();
}
return false;
}
|
php
|
protected function buildInsertStatement($data,$table=null) {
if (!$table) {
$table = $this->primaryTable;
}
$bindparams = array();
$sql_fields = NULL;
$sql_values = NULL;
foreach ($data as $field=>$value) {
$sql_fields .= "{$field},";
$sql_values .= ":{$field},";
$bindparams[":{$field}"] = $value;
}
$sql_fields = rtrim($sql_fields,',');
$sql_values = rtrim($sql_values,',');
$sql = "INSERT INTO {$table} ({$sql_fields}) VALUES ({$sql_values})";
if ($this->executeUpdate($sql,$bindparams)) {
return $this->getLastInsertId();
}
return false;
}
|
[
"protected",
"function",
"buildInsertStatement",
"(",
"$",
"data",
",",
"$",
"table",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"table",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"primaryTable",
";",
"}",
"$",
"bindparams",
"=",
"array",
"(",
")",
";",
"$",
"sql_fields",
"=",
"NULL",
";",
"$",
"sql_values",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"sql_fields",
".=",
"\"{$field},\"",
";",
"$",
"sql_values",
".=",
"\":{$field},\"",
";",
"$",
"bindparams",
"[",
"\":{$field}\"",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"sql_fields",
"=",
"rtrim",
"(",
"$",
"sql_fields",
",",
"','",
")",
";",
"$",
"sql_values",
"=",
"rtrim",
"(",
"$",
"sql_values",
",",
"','",
")",
";",
"$",
"sql",
"=",
"\"INSERT INTO {$table} ({$sql_fields}) VALUES ({$sql_values})\"",
";",
"if",
"(",
"$",
"this",
"->",
"executeUpdate",
"(",
"$",
"sql",
",",
"$",
"bindparams",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getLastInsertId",
"(",
")",
";",
"}",
"return",
"false",
";",
"}"
] |
Builds and executes an insert statement
@param mixed[] $data An associative array (ColumnName->Value) of data representing the new DB record
@param string $table Optional - The table to insert the new record into. Defaults to $primaryTable
@return int/false Returns the ID of the new record on success, false on failure
|
[
"Builds",
"and",
"executes",
"an",
"insert",
"statement"
] |
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
|
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/DBObject.php#L194-L213
|
239,009
|
TAMULib/Pipit
|
Core/Classes/Data/DBObject.php
|
DBObject.buildMultiRowInsertStatement
|
protected function buildMultiRowInsertStatement($rows,$table=null) {
if (!$table) {
$table = $this->primaryTable;
}
$bindparams = array();
$sqlRows = NULL;
$sqlFields = implode(',',array_keys(current($rows)));
$x = 1;
foreach ($rows as $data) {
$sqlValues = NULL;
foreach ($data as $field=>$value) {
$sqlValues .= ":{$field}{$x},";
$bindparams[":{$field}{$x}"] = $value;
}
$sqlValues = rtrim($sqlValues,',');
$sqlRows .= "({$sqlValues}),";
$x++;
}
$sql = "INSERT INTO {$table} ({$sqlFields}) VALUES ".rtrim($sqlRows,',');
return $this->executeUpdate($sql,$bindparams);
}
|
php
|
protected function buildMultiRowInsertStatement($rows,$table=null) {
if (!$table) {
$table = $this->primaryTable;
}
$bindparams = array();
$sqlRows = NULL;
$sqlFields = implode(',',array_keys(current($rows)));
$x = 1;
foreach ($rows as $data) {
$sqlValues = NULL;
foreach ($data as $field=>$value) {
$sqlValues .= ":{$field}{$x},";
$bindparams[":{$field}{$x}"] = $value;
}
$sqlValues = rtrim($sqlValues,',');
$sqlRows .= "({$sqlValues}),";
$x++;
}
$sql = "INSERT INTO {$table} ({$sqlFields}) VALUES ".rtrim($sqlRows,',');
return $this->executeUpdate($sql,$bindparams);
}
|
[
"protected",
"function",
"buildMultiRowInsertStatement",
"(",
"$",
"rows",
",",
"$",
"table",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"table",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"primaryTable",
";",
"}",
"$",
"bindparams",
"=",
"array",
"(",
")",
";",
"$",
"sqlRows",
"=",
"NULL",
";",
"$",
"sqlFields",
"=",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"current",
"(",
"$",
"rows",
")",
")",
")",
";",
"$",
"x",
"=",
"1",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"data",
")",
"{",
"$",
"sqlValues",
"=",
"NULL",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"sqlValues",
".=",
"\":{$field}{$x},\"",
";",
"$",
"bindparams",
"[",
"\":{$field}{$x}\"",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"sqlValues",
"=",
"rtrim",
"(",
"$",
"sqlValues",
",",
"','",
")",
";",
"$",
"sqlRows",
".=",
"\"({$sqlValues}),\"",
";",
"$",
"x",
"++",
";",
"}",
"$",
"sql",
"=",
"\"INSERT INTO {$table} ({$sqlFields}) VALUES \"",
".",
"rtrim",
"(",
"$",
"sqlRows",
",",
"','",
")",
";",
"return",
"$",
"this",
"->",
"executeUpdate",
"(",
"$",
"sql",
",",
"$",
"bindparams",
")",
";",
"}"
] |
Builds and executes a single insert statement that inserts multiple new records
@param mixed[][] $rows An array of associative arrays (ColumnName->Value) of data representing the new DB records
@param string $table Optional - The table to insert the new records into. Defaults to $primaryTable
@return boolean True on success, false on failure
|
[
"Builds",
"and",
"executes",
"a",
"single",
"insert",
"statement",
"that",
"inserts",
"multiple",
"new",
"records"
] |
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
|
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/DBObject.php#L221-L241
|
239,010
|
TAMULib/Pipit
|
Core/Classes/Data/DBObject.php
|
DBObject.buildUpdateStatement
|
protected function buildUpdateStatement($id,$data,$table=null) {
if (!$table) {
$table = $this->primaryTable;
}
$sql = "UPDATE {$table} SET ";
foreach ($data as $field=>$value) {
$sql .= "{$field}=:{$field},";
$bindparams[":{$field}"] = $value;
}
$sql = rtrim($sql,',')." WHERE id=:id";
$bindparams[":id"] = $id;
if ($this->executeUpdate($sql,$bindparams)) {
return true;
}
return false;
}
|
php
|
protected function buildUpdateStatement($id,$data,$table=null) {
if (!$table) {
$table = $this->primaryTable;
}
$sql = "UPDATE {$table} SET ";
foreach ($data as $field=>$value) {
$sql .= "{$field}=:{$field},";
$bindparams[":{$field}"] = $value;
}
$sql = rtrim($sql,',')." WHERE id=:id";
$bindparams[":id"] = $id;
if ($this->executeUpdate($sql,$bindparams)) {
return true;
}
return false;
}
|
[
"protected",
"function",
"buildUpdateStatement",
"(",
"$",
"id",
",",
"$",
"data",
",",
"$",
"table",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"table",
")",
"{",
"$",
"table",
"=",
"$",
"this",
"->",
"primaryTable",
";",
"}",
"$",
"sql",
"=",
"\"UPDATE {$table} SET \"",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"field",
"=>",
"$",
"value",
")",
"{",
"$",
"sql",
".=",
"\"{$field}=:{$field},\"",
";",
"$",
"bindparams",
"[",
"\":{$field}\"",
"]",
"=",
"$",
"value",
";",
"}",
"$",
"sql",
"=",
"rtrim",
"(",
"$",
"sql",
",",
"','",
")",
".",
"\" WHERE id=:id\"",
";",
"$",
"bindparams",
"[",
"\":id\"",
"]",
"=",
"$",
"id",
";",
"if",
"(",
"$",
"this",
"->",
"executeUpdate",
"(",
"$",
"sql",
",",
"$",
"bindparams",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Builds and executes an update statement
@param int $id The id of the record to be updated
@param mixed[] $data An associative array (ColumnName->Value) of data representing the updated data
@param string $table Optional - The table to insert the new record into. Defaults to $primaryTable
@return boolean True on success, false on failure
|
[
"Builds",
"and",
"executes",
"an",
"update",
"statement"
] |
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
|
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/DBObject.php#L250-L266
|
239,011
|
TAMULib/Pipit
|
Core/Classes/Data/DBObject.php
|
DBObject.logStatementError
|
protected function logStatementError($error,$sql=null) {
if (!empty($GLOBALS['config']['DB_DEBUG'])) {
$message = "Error with query - CODE: {$error[1]}";
if ($sql) {
$message .= " QUERY: {$sql}";
}
$this->getLogger()->error($message);
}
}
|
php
|
protected function logStatementError($error,$sql=null) {
if (!empty($GLOBALS['config']['DB_DEBUG'])) {
$message = "Error with query - CODE: {$error[1]}";
if ($sql) {
$message .= " QUERY: {$sql}";
}
$this->getLogger()->error($message);
}
}
|
[
"protected",
"function",
"logStatementError",
"(",
"$",
"error",
",",
"$",
"sql",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"GLOBALS",
"[",
"'config'",
"]",
"[",
"'DB_DEBUG'",
"]",
")",
")",
"{",
"$",
"message",
"=",
"\"Error with query - CODE: {$error[1]}\"",
";",
"if",
"(",
"$",
"sql",
")",
"{",
"$",
"message",
".=",
"\" QUERY: {$sql}\"",
";",
"}",
"$",
"this",
"->",
"getLogger",
"(",
")",
"->",
"error",
"(",
"$",
"message",
")",
";",
"}",
"}"
] |
Logs SQL errors to the logger
@param array $error A PDO::errorInfo() error
@param string $sql The SQL query that triggered the error
|
[
"Logs",
"SQL",
"errors",
"to",
"the",
"logger"
] |
dcf90237d9ad8b4ebf47662daa3e8b419ef177ed
|
https://github.com/TAMULib/Pipit/blob/dcf90237d9ad8b4ebf47662daa3e8b419ef177ed/Core/Classes/Data/DBObject.php#L273-L281
|
239,012
|
themichaelhall/bluemvc-core
|
src/Base/AbstractResponse.php
|
AbstractResponse.setCookieValue
|
public function setCookieValue(string $name, string $value, ?\DateTimeInterface $expiry = null, ?UrlPathInterface $path = null, ?HostInterface $domain = null, bool $isSecure = false, bool $isHttpOnly = false): void
{
$this->cookies->set($name, new ResponseCookie($value, $expiry, $path, $domain, $isSecure, $isHttpOnly));
}
|
php
|
public function setCookieValue(string $name, string $value, ?\DateTimeInterface $expiry = null, ?UrlPathInterface $path = null, ?HostInterface $domain = null, bool $isSecure = false, bool $isHttpOnly = false): void
{
$this->cookies->set($name, new ResponseCookie($value, $expiry, $path, $domain, $isSecure, $isHttpOnly));
}
|
[
"public",
"function",
"setCookieValue",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
",",
"?",
"\\",
"DateTimeInterface",
"$",
"expiry",
"=",
"null",
",",
"?",
"UrlPathInterface",
"$",
"path",
"=",
"null",
",",
"?",
"HostInterface",
"$",
"domain",
"=",
"null",
",",
"bool",
"$",
"isSecure",
"=",
"false",
",",
"bool",
"$",
"isHttpOnly",
"=",
"false",
")",
":",
"void",
"{",
"$",
"this",
"->",
"cookies",
"->",
"set",
"(",
"$",
"name",
",",
"new",
"ResponseCookie",
"(",
"$",
"value",
",",
"$",
"expiry",
",",
"$",
"path",
",",
"$",
"domain",
",",
"$",
"isSecure",
",",
"$",
"isHttpOnly",
")",
")",
";",
"}"
] |
Sets a cookie value.
@since 1.1.0
@param string $name The name.
@param string $value The value.
@param \DateTimeInterface|null $expiry The expiry time or null if no expiry time.
@param UrlPathInterface|null $path The path or null if no path.
@param HostInterface|null $domain The domain or null if no domain.
@param bool $isSecure True if cookie is secure, false otherwise.
@param bool $isHttpOnly True if cookie is http only, false otherwise.
@throws InvalidResponseCookiePathException If the path is not a directory or an absolute path.
|
[
"Sets",
"a",
"cookie",
"value",
"."
] |
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
|
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Base/AbstractResponse.php#L172-L175
|
239,013
|
themichaelhall/bluemvc-core
|
src/Base/AbstractResponse.php
|
AbstractResponse.setExpiry
|
public function setExpiry(?\DateTimeImmutable $expiry = null): void
{
$date = new \DateTimeImmutable();
$expiry = $expiry ?: $date;
$this->setHeader('Date', $date->setTimezone(new \DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T'));
$this->setHeader('Expires', $expiry->setTimezone(new \DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T'));
if ($expiry <= $date) {
$this->setHeader('Cache-Control', 'no-cache, no-store, must-revalidate, max-age=0');
return;
}
$maxAge = $expiry->getTimestamp() - $date->getTimestamp();
$this->setHeader('Cache-Control', 'public, max-age=' . $maxAge);
}
|
php
|
public function setExpiry(?\DateTimeImmutable $expiry = null): void
{
$date = new \DateTimeImmutable();
$expiry = $expiry ?: $date;
$this->setHeader('Date', $date->setTimezone(new \DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T'));
$this->setHeader('Expires', $expiry->setTimezone(new \DateTimeZone('UTC'))->format('D, d M Y H:i:s \G\M\T'));
if ($expiry <= $date) {
$this->setHeader('Cache-Control', 'no-cache, no-store, must-revalidate, max-age=0');
return;
}
$maxAge = $expiry->getTimestamp() - $date->getTimestamp();
$this->setHeader('Cache-Control', 'public, max-age=' . $maxAge);
}
|
[
"public",
"function",
"setExpiry",
"(",
"?",
"\\",
"DateTimeImmutable",
"$",
"expiry",
"=",
"null",
")",
":",
"void",
"{",
"$",
"date",
"=",
"new",
"\\",
"DateTimeImmutable",
"(",
")",
";",
"$",
"expiry",
"=",
"$",
"expiry",
"?",
":",
"$",
"date",
";",
"$",
"this",
"->",
"setHeader",
"(",
"'Date'",
",",
"$",
"date",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
"->",
"format",
"(",
"'D, d M Y H:i:s \\G\\M\\T'",
")",
")",
";",
"$",
"this",
"->",
"setHeader",
"(",
"'Expires'",
",",
"$",
"expiry",
"->",
"setTimezone",
"(",
"new",
"\\",
"DateTimeZone",
"(",
"'UTC'",
")",
")",
"->",
"format",
"(",
"'D, d M Y H:i:s \\G\\M\\T'",
")",
")",
";",
"if",
"(",
"$",
"expiry",
"<=",
"$",
"date",
")",
"{",
"$",
"this",
"->",
"setHeader",
"(",
"'Cache-Control'",
",",
"'no-cache, no-store, must-revalidate, max-age=0'",
")",
";",
"return",
";",
"}",
"$",
"maxAge",
"=",
"$",
"expiry",
"->",
"getTimestamp",
"(",
")",
"-",
"$",
"date",
"->",
"getTimestamp",
"(",
")",
";",
"$",
"this",
"->",
"setHeader",
"(",
"'Cache-Control'",
",",
"'public, max-age='",
".",
"$",
"maxAge",
")",
";",
"}"
] |
Sets the expiry time.
@since 1.0.0
@param \DateTimeImmutable|null $expiry The expiry time or null for immediate expiry.
|
[
"Sets",
"the",
"expiry",
"time",
"."
] |
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
|
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Base/AbstractResponse.php#L184-L200
|
239,014
|
tarsana/filesystem
|
src/Resource/Buffer.php
|
Buffer.readUntil
|
public function readUntil($end)
{
if (empty($end)) {
throw new ResourceException("Empty string given to Reader::readUntil()");
}
fseek($this->resource, $this->readPosition);
// Reading the first character (maybe blocking)
$buffer = stream_get_contents($this->resource, 1);
// saving the blocking mode
$mode = $this->blocking();
$size = strlen($end);
$this->blocking(false);
while (strlen($buffer) < $size || substr($buffer, -$size) != $end) {
$c = stream_get_contents($this->resource, 1);
if (empty($c)) {
break;
}
$buffer .= $c;
}
$this->blocking($mode);
$this->readPosition = ftell($this->resource);
return (substr($buffer, -$size) == $end)
? substr($buffer, 0, strlen($buffer) - $size)
: $buffer;
}
|
php
|
public function readUntil($end)
{
if (empty($end)) {
throw new ResourceException("Empty string given to Reader::readUntil()");
}
fseek($this->resource, $this->readPosition);
// Reading the first character (maybe blocking)
$buffer = stream_get_contents($this->resource, 1);
// saving the blocking mode
$mode = $this->blocking();
$size = strlen($end);
$this->blocking(false);
while (strlen($buffer) < $size || substr($buffer, -$size) != $end) {
$c = stream_get_contents($this->resource, 1);
if (empty($c)) {
break;
}
$buffer .= $c;
}
$this->blocking($mode);
$this->readPosition = ftell($this->resource);
return (substr($buffer, -$size) == $end)
? substr($buffer, 0, strlen($buffer) - $size)
: $buffer;
}
|
[
"public",
"function",
"readUntil",
"(",
"$",
"end",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"end",
")",
")",
"{",
"throw",
"new",
"ResourceException",
"(",
"\"Empty string given to Reader::readUntil()\"",
")",
";",
"}",
"fseek",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"this",
"->",
"readPosition",
")",
";",
"// Reading the first character (maybe blocking)",
"$",
"buffer",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"resource",
",",
"1",
")",
";",
"// saving the blocking mode",
"$",
"mode",
"=",
"$",
"this",
"->",
"blocking",
"(",
")",
";",
"$",
"size",
"=",
"strlen",
"(",
"$",
"end",
")",
";",
"$",
"this",
"->",
"blocking",
"(",
"false",
")",
";",
"while",
"(",
"strlen",
"(",
"$",
"buffer",
")",
"<",
"$",
"size",
"||",
"substr",
"(",
"$",
"buffer",
",",
"-",
"$",
"size",
")",
"!=",
"$",
"end",
")",
"{",
"$",
"c",
"=",
"stream_get_contents",
"(",
"$",
"this",
"->",
"resource",
",",
"1",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"c",
")",
")",
"{",
"break",
";",
"}",
"$",
"buffer",
".=",
"$",
"c",
";",
"}",
"$",
"this",
"->",
"blocking",
"(",
"$",
"mode",
")",
";",
"$",
"this",
"->",
"readPosition",
"=",
"ftell",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"return",
"(",
"substr",
"(",
"$",
"buffer",
",",
"-",
"$",
"size",
")",
"==",
"$",
"end",
")",
"?",
"substr",
"(",
"$",
"buffer",
",",
"0",
",",
"strlen",
"(",
"$",
"buffer",
")",
"-",
"$",
"size",
")",
":",
"$",
"buffer",
";",
"}"
] |
Reads until the given string or the end of contents.
Returns the read string without the ending string.
@param string $end
@return string
@throws ResourceException if the given $end is empty
|
[
"Reads",
"until",
"the",
"given",
"string",
"or",
"the",
"end",
"of",
"contents",
".",
"Returns",
"the",
"read",
"string",
"without",
"the",
"ending",
"string",
"."
] |
db6c8f040af38dfb01066e382645aff6c72530fa
|
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Resource/Buffer.php#L78-L102
|
239,015
|
tarsana/filesystem
|
src/Resource/Buffer.php
|
Buffer.write
|
public function write($content)
{
fseek($this->resource, $this->writePosition);
if(false === fwrite($this->resource, $content))
throw new ResourceException("Unable to write content to resource");
$this->writePosition = ftell($this->resource);
return $this;
}
|
php
|
public function write($content)
{
fseek($this->resource, $this->writePosition);
if(false === fwrite($this->resource, $content))
throw new ResourceException("Unable to write content to resource");
$this->writePosition = ftell($this->resource);
return $this;
}
|
[
"public",
"function",
"write",
"(",
"$",
"content",
")",
"{",
"fseek",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"this",
"->",
"writePosition",
")",
";",
"if",
"(",
"false",
"===",
"fwrite",
"(",
"$",
"this",
"->",
"resource",
",",
"$",
"content",
")",
")",
"throw",
"new",
"ResourceException",
"(",
"\"Unable to write content to resource\"",
")",
";",
"$",
"this",
"->",
"writePosition",
"=",
"ftell",
"(",
"$",
"this",
"->",
"resource",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Writes content.
@return self
|
[
"Writes",
"content",
"."
] |
db6c8f040af38dfb01066e382645aff6c72530fa
|
https://github.com/tarsana/filesystem/blob/db6c8f040af38dfb01066e382645aff6c72530fa/src/Resource/Buffer.php#L109-L116
|
239,016
|
PublisherHub/Publisher
|
src/Publisher/Manager/Publisher.php
|
Publisher.initialiseMonitoring
|
protected function initialiseMonitoring()
{
for ($i = 0; $i < count($this->entries); $i++) {
$this->monitor->monitor($this->entries[$i]['entry']);
}
}
|
php
|
protected function initialiseMonitoring()
{
for ($i = 0; $i < count($this->entries); $i++) {
$this->monitor->monitor($this->entries[$i]['entry']);
}
}
|
[
"protected",
"function",
"initialiseMonitoring",
"(",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"this",
"->",
"entries",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"this",
"->",
"monitor",
"->",
"monitor",
"(",
"$",
"this",
"->",
"entries",
"[",
"$",
"i",
"]",
"[",
"'entry'",
"]",
")",
";",
"}",
"}"
] |
Registers all entries at the monitor as 'not executed'.
@return void
|
[
"Registers",
"all",
"entries",
"at",
"the",
"monitor",
"as",
"not",
"executed",
"."
] |
954e05118be9956e0c8631e44958af4ba42606b3
|
https://github.com/PublisherHub/Publisher/blob/954e05118be9956e0c8631e44958af4ba42606b3/src/Publisher/Manager/Publisher.php#L112-L117
|
239,017
|
PublisherHub/Publisher
|
src/Publisher/Manager/Publisher.php
|
Publisher.publishEntry
|
protected function publishEntry(
string $entryId,
array $parameters,
array $content
) {
$entry = $this->entryFactory->getEntry($entryId, $parameters);
$entry->setBody($content);
$response = $this->publish($entry);
$this->setStatus($entryId, $entry, $response);
}
|
php
|
protected function publishEntry(
string $entryId,
array $parameters,
array $content
) {
$entry = $this->entryFactory->getEntry($entryId, $parameters);
$entry->setBody($content);
$response = $this->publish($entry);
$this->setStatus($entryId, $entry, $response);
}
|
[
"protected",
"function",
"publishEntry",
"(",
"string",
"$",
"entryId",
",",
"array",
"$",
"parameters",
",",
"array",
"$",
"content",
")",
"{",
"$",
"entry",
"=",
"$",
"this",
"->",
"entryFactory",
"->",
"getEntry",
"(",
"$",
"entryId",
",",
"$",
"parameters",
")",
";",
"$",
"entry",
"->",
"setBody",
"(",
"$",
"content",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"publish",
"(",
"$",
"entry",
")",
";",
"$",
"this",
"->",
"setStatus",
"(",
"$",
"entryId",
",",
"$",
"entry",
",",
"$",
"response",
")",
";",
"}"
] |
Creates the entry, gets the request, executes it
and sets the status of the request as successful or failed.
@return void;
|
[
"Creates",
"the",
"entry",
"gets",
"the",
"request",
"executes",
"it",
"and",
"sets",
"the",
"status",
"of",
"the",
"request",
"as",
"successful",
"or",
"failed",
"."
] |
954e05118be9956e0c8631e44958af4ba42606b3
|
https://github.com/PublisherHub/Publisher/blob/954e05118be9956e0c8631e44958af4ba42606b3/src/Publisher/Manager/Publisher.php#L125-L136
|
239,018
|
wp-pluginner/framework
|
src/Support/PluginOptions.php
|
PluginOptions.update
|
public function update( $options = [] )
{
if ( is_null( $this->row ) ) {
return $this->reset();
}
$mergeOptions = array_replace_recursive( $this->_value, $options );
$result = WpOption::updateOrCreate(
['option_name' => $this->optionsName],
['option_value' => json_encode( $mergeOptions )]
);
$this->_value = (array) $mergeOptions;
return $result;
}
|
php
|
public function update( $options = [] )
{
if ( is_null( $this->row ) ) {
return $this->reset();
}
$mergeOptions = array_replace_recursive( $this->_value, $options );
$result = WpOption::updateOrCreate(
['option_name' => $this->optionsName],
['option_value' => json_encode( $mergeOptions )]
);
$this->_value = (array) $mergeOptions;
return $result;
}
|
[
"public",
"function",
"update",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"row",
")",
")",
"{",
"return",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"}",
"$",
"mergeOptions",
"=",
"array_replace_recursive",
"(",
"$",
"this",
"->",
"_value",
",",
"$",
"options",
")",
";",
"$",
"result",
"=",
"WpOption",
"::",
"updateOrCreate",
"(",
"[",
"'option_name'",
"=>",
"$",
"this",
"->",
"optionsName",
"]",
",",
"[",
"'option_value'",
"=>",
"json_encode",
"(",
"$",
"mergeOptions",
")",
"]",
")",
";",
"$",
"this",
"->",
"_value",
"=",
"(",
"array",
")",
"$",
"mergeOptions",
";",
"return",
"$",
"result",
";",
"}"
] |
Update a branch of options.
@param array $options
@return false|int
|
[
"Update",
"a",
"branch",
"of",
"options",
"."
] |
557d62674acf6ca43b2523f8d4a0aa0dbf8e674d
|
https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Support/PluginOptions.php#L215-L234
|
239,019
|
wp-pluginner/framework
|
src/Support/PluginOptions.php
|
PluginOptions.delta
|
public function delta()
{
$mergeOptions = $this->__delta( $this->optionsData, $this->_value );
$result = WpOption::updateOrCreate(
['option_name' => $this->optionsName],
['option_value' => json_encode( $mergeOptions )]
);
$this->_value = (array) $mergeOptions;
return $result;
}
|
php
|
public function delta()
{
$mergeOptions = $this->__delta( $this->optionsData, $this->_value );
$result = WpOption::updateOrCreate(
['option_name' => $this->optionsName],
['option_value' => json_encode( $mergeOptions )]
);
$this->_value = (array) $mergeOptions;
return $result;
}
|
[
"public",
"function",
"delta",
"(",
")",
"{",
"$",
"mergeOptions",
"=",
"$",
"this",
"->",
"__delta",
"(",
"$",
"this",
"->",
"optionsData",
",",
"$",
"this",
"->",
"_value",
")",
";",
"$",
"result",
"=",
"WpOption",
"::",
"updateOrCreate",
"(",
"[",
"'option_name'",
"=>",
"$",
"this",
"->",
"optionsName",
"]",
",",
"[",
"'option_value'",
"=>",
"json_encode",
"(",
"$",
"mergeOptions",
")",
"]",
")",
";",
"$",
"this",
"->",
"_value",
"=",
"(",
"array",
")",
"$",
"mergeOptions",
";",
"return",
"$",
"result",
";",
"}"
] |
Execute a delta from the current version of the options and the previous version stored in the database.
@return false|int
|
[
"Execute",
"a",
"delta",
"from",
"the",
"current",
"version",
"of",
"the",
"options",
"and",
"the",
"previous",
"version",
"stored",
"in",
"the",
"database",
"."
] |
557d62674acf6ca43b2523f8d4a0aa0dbf8e674d
|
https://github.com/wp-pluginner/framework/blob/557d62674acf6ca43b2523f8d4a0aa0dbf8e674d/src/Support/PluginOptions.php#L241-L257
|
239,020
|
Koudela/eArc-payload-container
|
src/Traits/PayloadContainerTrait.php
|
PayloadContainerTrait.set
|
public function set(string $name, $item): void
{
$this->payloadContainerItems->set($name, $item);
}
|
php
|
public function set(string $name, $item): void
{
$this->payloadContainerItems->set($name, $item);
}
|
[
"public",
"function",
"set",
"(",
"string",
"$",
"name",
",",
"$",
"item",
")",
":",
"void",
"{",
"$",
"this",
"->",
"payloadContainerItems",
"->",
"set",
"(",
"$",
"name",
",",
"$",
"item",
")",
";",
"}"
] |
Add a specific item to the container.
@param string $name
@param mixed $item
@throws ItemOverwriteException
|
[
"Add",
"a",
"specific",
"item",
"to",
"the",
"container",
"."
] |
d085ccaf2041441a2b55cf8a500b8a849b8ac5a4
|
https://github.com/Koudela/eArc-payload-container/blob/d085ccaf2041441a2b55cf8a500b8a849b8ac5a4/src/Traits/PayloadContainerTrait.php#L88-L91
|
239,021
|
alanly/picnik
|
src/Picnik/Requests/Word/AbstractWordRequest.php
|
AbstractWordRequest.checkResponseErrors
|
protected function checkResponseErrors(ResponseInterface $response)
{
$status = intval($response->getStatusCode());
if ($status === 200) return;
switch ($status) {
case 401:
throw new AuthorizationException($response);
default:
throw new RequestException($response);
}
}
|
php
|
protected function checkResponseErrors(ResponseInterface $response)
{
$status = intval($response->getStatusCode());
if ($status === 200) return;
switch ($status) {
case 401:
throw new AuthorizationException($response);
default:
throw new RequestException($response);
}
}
|
[
"protected",
"function",
"checkResponseErrors",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"status",
"=",
"intval",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
";",
"if",
"(",
"$",
"status",
"===",
"200",
")",
"return",
";",
"switch",
"(",
"$",
"status",
")",
"{",
"case",
"401",
":",
"throw",
"new",
"AuthorizationException",
"(",
"$",
"response",
")",
";",
"default",
":",
"throw",
"new",
"RequestException",
"(",
"$",
"response",
")",
";",
"}",
"}"
] |
Checks the given response for error codes, throwing the appropriate
exceptions if needed.
@param ResponseInterface $response
|
[
"Checks",
"the",
"given",
"response",
"for",
"error",
"codes",
"throwing",
"the",
"appropriate",
"exceptions",
"if",
"needed",
"."
] |
17cf7afa43141f217b68ef181401f18b12ae2def
|
https://github.com/alanly/picnik/blob/17cf7afa43141f217b68ef181401f18b12ae2def/src/Picnik/Requests/Word/AbstractWordRequest.php#L81-L93
|
239,022
|
bd808/moar-log
|
src/Moar/Log/Monolog/LoggerFactory.php
|
LoggerFactory.getDafaultLogger
|
public function getDafaultLogger () {
if (null === $this->root) {
$this->root = new HierarchialLogger(null);
}
return $this->root;
}
|
php
|
public function getDafaultLogger () {
if (null === $this->root) {
$this->root = new HierarchialLogger(null);
}
return $this->root;
}
|
[
"public",
"function",
"getDafaultLogger",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"this",
"->",
"root",
"=",
"new",
"HierarchialLogger",
"(",
"null",
")",
";",
"}",
"return",
"$",
"this",
"->",
"root",
";",
"}"
] |
Get the default logger.
Must return the same logger instance on each call.
@return LoggerInterface
|
[
"Get",
"the",
"default",
"logger",
"."
] |
01f44c46fef9a612cef6209c3bd69c97f3475064
|
https://github.com/bd808/moar-log/blob/01f44c46fef9a612cef6209c3bd69c97f3475064/src/Moar/Log/Monolog/LoggerFactory.php#L32-L37
|
239,023
|
bd808/moar-log
|
src/Moar/Log/Monolog/LoggerFactory.php
|
LoggerFactory.newLogger
|
protected function newLogger ($name, LoggerInterface $parent) {
$logger = $parent;
if ($parent instanceof HierarchialLogger) {
$logger = new HierarchialLogger($name);
$logger->setParent($parent);
}
return $logger;
}
|
php
|
protected function newLogger ($name, LoggerInterface $parent) {
$logger = $parent;
if ($parent instanceof HierarchialLogger) {
$logger = new HierarchialLogger($name);
$logger->setParent($parent);
}
return $logger;
}
|
[
"protected",
"function",
"newLogger",
"(",
"$",
"name",
",",
"LoggerInterface",
"$",
"parent",
")",
"{",
"$",
"logger",
"=",
"$",
"parent",
";",
"if",
"(",
"$",
"parent",
"instanceof",
"HierarchialLogger",
")",
"{",
"$",
"logger",
"=",
"new",
"HierarchialLogger",
"(",
"$",
"name",
")",
";",
"$",
"logger",
"->",
"setParent",
"(",
"$",
"parent",
")",
";",
"}",
"return",
"$",
"logger",
";",
"}"
] |
Create a new LoggerInterface instance.
@param string $name Name of new logger
@param LoggerInterface $parent Closest known ancestor logger
@return LoggerInterface Logger
|
[
"Create",
"a",
"new",
"LoggerInterface",
"instance",
"."
] |
01f44c46fef9a612cef6209c3bd69c97f3475064
|
https://github.com/bd808/moar-log/blob/01f44c46fef9a612cef6209c3bd69c97f3475064/src/Moar/Log/Monolog/LoggerFactory.php#L46-L53
|
239,024
|
mtoolkit/mtoolkit-core
|
src/MList.php
|
MList.removeOne
|
public function removeOne($value): bool
{
if ($this->isValidType($value) === false) {
throw new MWrongTypeException("\$value", $this->getType(), $value);
}
$result = array_search($value, $this->list);
if ($result === false) {
throw new \OutOfBoundsException();
}
unset($this->list[$result]);
return true;
}
|
php
|
public function removeOne($value): bool
{
if ($this->isValidType($value) === false) {
throw new MWrongTypeException("\$value", $this->getType(), $value);
}
$result = array_search($value, $this->list);
if ($result === false) {
throw new \OutOfBoundsException();
}
unset($this->list[$result]);
return true;
}
|
[
"public",
"function",
"removeOne",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidType",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"MWrongTypeException",
"(",
"\"\\$value\"",
",",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"$",
"value",
")",
";",
"}",
"$",
"result",
"=",
"array_search",
"(",
"$",
"value",
",",
"$",
"this",
"->",
"list",
")",
";",
"if",
"(",
"$",
"result",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
")",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"result",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
Removes the first occurrence of value in the list and returns true on success;
otherwise returns false.
@param $value mixed
@return bool
|
[
"Removes",
"the",
"first",
"occurrence",
"of",
"value",
"in",
"the",
"list",
"and",
"returns",
"true",
"on",
"success",
";",
"otherwise",
"returns",
"false",
"."
] |
66c53273288a8652ff38240e063bdcffdf7c30aa
|
https://github.com/mtoolkit/mtoolkit-core/blob/66c53273288a8652ff38240e063bdcffdf7c30aa/src/MList.php#L476-L491
|
239,025
|
mtoolkit/mtoolkit-core
|
src/MList.php
|
MList.startsWith
|
public function startsWith($value): bool
{
if ($this->isValidType($value) === false) {
throw new MWrongTypeException("\$value", $this->getType(), $value);
}
if ($this->count() <= 0) {
return false;
}
$lastValue = $this->list[0];
return ($lastValue == $value);
}
|
php
|
public function startsWith($value): bool
{
if ($this->isValidType($value) === false) {
throw new MWrongTypeException("\$value", $this->getType(), $value);
}
if ($this->count() <= 0) {
return false;
}
$lastValue = $this->list[0];
return ($lastValue == $value);
}
|
[
"public",
"function",
"startsWith",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"isValidType",
"(",
"$",
"value",
")",
"===",
"false",
")",
"{",
"throw",
"new",
"MWrongTypeException",
"(",
"\"\\$value\"",
",",
"$",
"this",
"->",
"getType",
"(",
")",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"count",
"(",
")",
"<=",
"0",
")",
"{",
"return",
"false",
";",
"}",
"$",
"lastValue",
"=",
"$",
"this",
"->",
"list",
"[",
"0",
"]",
";",
"return",
"(",
"$",
"lastValue",
"==",
"$",
"value",
")",
";",
"}"
] |
Returns true if this list is not empty and its first item is equal
to value; otherwise returns false.
@param mixed $value
@return bool
|
[
"Returns",
"true",
"if",
"this",
"list",
"is",
"not",
"empty",
"and",
"its",
"first",
"item",
"is",
"equal",
"to",
"value",
";",
"otherwise",
"returns",
"false",
"."
] |
66c53273288a8652ff38240e063bdcffdf7c30aa
|
https://github.com/mtoolkit/mtoolkit-core/blob/66c53273288a8652ff38240e063bdcffdf7c30aa/src/MList.php#L526-L539
|
239,026
|
mtoolkit/mtoolkit-core
|
src/MList.php
|
MList.offsetExists
|
public function offsetExists($offset): bool
{
MDataType::mustBe(array(MDataType::INT));
return (array_key_exists($offset, $this->list) === true);
}
|
php
|
public function offsetExists($offset): bool
{
MDataType::mustBe(array(MDataType::INT));
return (array_key_exists($offset, $this->list) === true);
}
|
[
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
":",
"bool",
"{",
"MDataType",
"::",
"mustBe",
"(",
"array",
"(",
"MDataType",
"::",
"INT",
")",
")",
";",
"return",
"(",
"array_key_exists",
"(",
"$",
"offset",
",",
"$",
"this",
"->",
"list",
")",
"===",
"true",
")",
";",
"}"
] |
Return if a key exists.
@param int $offset
@return bool
|
[
"Return",
"if",
"a",
"key",
"exists",
"."
] |
66c53273288a8652ff38240e063bdcffdf7c30aa
|
https://github.com/mtoolkit/mtoolkit-core/blob/66c53273288a8652ff38240e063bdcffdf7c30aa/src/MList.php#L653-L658
|
239,027
|
bishopb/vanilla
|
library/core/class.pluggable.php
|
Gdn_Pluggable.FireAs
|
public function FireAs($Options) {
if (!is_array($Options))
$Options = array('FireClass' => $Options);
if (array_key_exists('FireClass', $Options))
$this->FireAs = GetValue('FireClass', $Options);
return $this;
}
|
php
|
public function FireAs($Options) {
if (!is_array($Options))
$Options = array('FireClass' => $Options);
if (array_key_exists('FireClass', $Options))
$this->FireAs = GetValue('FireClass', $Options);
return $this;
}
|
[
"public",
"function",
"FireAs",
"(",
"$",
"Options",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"Options",
")",
")",
"$",
"Options",
"=",
"array",
"(",
"'FireClass'",
"=>",
"$",
"Options",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'FireClass'",
",",
"$",
"Options",
")",
")",
"$",
"this",
"->",
"FireAs",
"=",
"GetValue",
"(",
"'FireClass'",
",",
"$",
"Options",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Fire the next event off a custom parent class
@param mixed $Options Either the parent class, or an option array
|
[
"Fire",
"the",
"next",
"event",
"off",
"a",
"custom",
"parent",
"class"
] |
8494eb4a4ad61603479015a8054d23ff488364e8
|
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/library/core/class.pluggable.php#L111-L119
|
239,028
|
dzentota/zoya-coin
|
src/Zoya/Coin/Generic.php
|
Generic.flip
|
public function flip()
{
$this->counter++;
unset($this->isLucky);
$this->currentSide = $this->isLucky()? $this->expectedSide : $this->getOppositeSide($this->expectedSide);
return $this->currentSide;
}
|
php
|
public function flip()
{
$this->counter++;
unset($this->isLucky);
$this->currentSide = $this->isLucky()? $this->expectedSide : $this->getOppositeSide($this->expectedSide);
return $this->currentSide;
}
|
[
"public",
"function",
"flip",
"(",
")",
"{",
"$",
"this",
"->",
"counter",
"++",
";",
"unset",
"(",
"$",
"this",
"->",
"isLucky",
")",
";",
"$",
"this",
"->",
"currentSide",
"=",
"$",
"this",
"->",
"isLucky",
"(",
")",
"?",
"$",
"this",
"->",
"expectedSide",
":",
"$",
"this",
"->",
"getOppositeSide",
"(",
"$",
"this",
"->",
"expectedSide",
")",
";",
"return",
"$",
"this",
"->",
"currentSide",
";",
"}"
] |
Flips the coin and returns its side
@return string
|
[
"Flips",
"the",
"coin",
"and",
"returns",
"its",
"side"
] |
92ef80f767f0313f0723b10b868842bb11ef4b3c
|
https://github.com/dzentota/zoya-coin/blob/92ef80f767f0313f0723b10b868842bb11ef4b3c/src/Zoya/Coin/Generic.php#L61-L67
|
239,029
|
dzentota/zoya-coin
|
src/Zoya/Coin/Generic.php
|
Generic.isLucky
|
public function isLucky()
{
if (isset($this->isLucky)) {
return $this->isLucky;
}
$this->isLucky = $this->checkLuck();
return $this->isLucky;
}
|
php
|
public function isLucky()
{
if (isset($this->isLucky)) {
return $this->isLucky;
}
$this->isLucky = $this->checkLuck();
return $this->isLucky;
}
|
[
"public",
"function",
"isLucky",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"isLucky",
")",
")",
"{",
"return",
"$",
"this",
"->",
"isLucky",
";",
"}",
"$",
"this",
"->",
"isLucky",
"=",
"$",
"this",
"->",
"checkLuck",
"(",
")",
";",
"return",
"$",
"this",
"->",
"isLucky",
";",
"}"
] |
Returns true if you are lucky
@return bool
|
[
"Returns",
"true",
"if",
"you",
"are",
"lucky"
] |
92ef80f767f0313f0723b10b868842bb11ef4b3c
|
https://github.com/dzentota/zoya-coin/blob/92ef80f767f0313f0723b10b868842bb11ef4b3c/src/Zoya/Coin/Generic.php#L73-L80
|
239,030
|
patrikx3/resume-php-common
|
src/Analytics.php
|
Analytics.createCookie
|
private function createCookie()
{
$rand_id = rand(10000000, 99999999);
$random = rand(1000000000, 2147483647);
$var = '-';
$time = time();
$cookie = '';
$cookie .= '__utma=' . $rand_id . '.' . $random . '.' . $time . '.' . $time . '.' . $time . '.2;+';
$cookie .= '__utmb=' . $rand_id . ';+';
$cookie .= '__utmc=' . $rand_id . ';+';
$cookie .= '__utmz=' . $rand_id . '.' . $time . '.2.2.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none);+';
$cookie .= '__utmv=' . $rand_id . '.' . $var . ';';
return $cookie;
}
|
php
|
private function createCookie()
{
$rand_id = rand(10000000, 99999999);
$random = rand(1000000000, 2147483647);
$var = '-';
$time = time();
$cookie = '';
$cookie .= '__utma=' . $rand_id . '.' . $random . '.' . $time . '.' . $time . '.' . $time . '.2;+';
$cookie .= '__utmb=' . $rand_id . ';+';
$cookie .= '__utmc=' . $rand_id . ';+';
$cookie .= '__utmz=' . $rand_id . '.' . $time . '.2.2.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none);+';
$cookie .= '__utmv=' . $rand_id . '.' . $var . ';';
return $cookie;
}
|
[
"private",
"function",
"createCookie",
"(",
")",
"{",
"$",
"rand_id",
"=",
"rand",
"(",
"10000000",
",",
"99999999",
")",
";",
"$",
"random",
"=",
"rand",
"(",
"1000000000",
",",
"2147483647",
")",
";",
"$",
"var",
"=",
"'-'",
";",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"cookie",
"=",
"''",
";",
"$",
"cookie",
".=",
"'__utma='",
".",
"$",
"rand_id",
".",
"'.'",
".",
"$",
"random",
".",
"'.'",
".",
"$",
"time",
".",
"'.'",
".",
"$",
"time",
".",
"'.'",
".",
"$",
"time",
".",
"'.2;+'",
";",
"$",
"cookie",
".=",
"'__utmb='",
".",
"$",
"rand_id",
".",
"';+'",
";",
"$",
"cookie",
".=",
"'__utmc='",
".",
"$",
"rand_id",
".",
"';+'",
";",
"$",
"cookie",
".=",
"'__utmz='",
".",
"$",
"rand_id",
".",
"'.'",
".",
"$",
"time",
".",
"'.2.2.utmccn=(direct)|utmcsr=(direct)|utmcmd=(none);+'",
";",
"$",
"cookie",
".=",
"'__utmv='",
".",
"$",
"rand_id",
".",
"'.'",
".",
"$",
"var",
".",
"';'",
";",
"return",
"$",
"cookie",
";",
"}"
] |
Create unique cookie
@return string
|
[
"Create",
"unique",
"cookie"
] |
1e58ebc830cbd2becaf99c11147f086669d86025
|
https://github.com/patrikx3/resume-php-common/blob/1e58ebc830cbd2becaf99c11147f086669d86025/src/Analytics.php#L91-L104
|
239,031
|
patrikx3/resume-php-common
|
src/Analytics.php
|
Analytics.createGif
|
public function createGif()
{
$data = array();
foreach ($this->data as $key => $item) {
if ($item !== null) {
$data[$key] = $item;
}
}
return $this->tracking = self::GA_URL . '?' . http_build_query($data);
}
|
php
|
public function createGif()
{
$data = array();
foreach ($this->data as $key => $item) {
if ($item !== null) {
$data[$key] = $item;
}
}
return $this->tracking = self::GA_URL . '?' . http_build_query($data);
}
|
[
"public",
"function",
"createGif",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"!==",
"null",
")",
"{",
"$",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"item",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"tracking",
"=",
"self",
"::",
"GA_URL",
".",
"'?'",
".",
"http_build_query",
"(",
"$",
"data",
")",
";",
"}"
] |
Create the GA callback url, aka the gif
@return string
|
[
"Create",
"the",
"GA",
"callback",
"url",
"aka",
"the",
"gif"
] |
1e58ebc830cbd2becaf99c11147f086669d86025
|
https://github.com/patrikx3/resume-php-common/blob/1e58ebc830cbd2becaf99c11147f086669d86025/src/Analytics.php#L155-L164
|
239,032
|
patrikx3/resume-php-common
|
src/Analytics.php
|
Analytics.remoteCall
|
private function remoteCall()
{
if (function_exists(
'wp_remote_head'
)) { // Check if this is being used with WordPress, if so use it's excellent HTTP class
$response = wp_remote_head($this->tracking);
return $response;
} elseif (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->tracking);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //@nczz Fixed HTTPS GET method
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_exec($ch);
curl_close($ch);
} else {
$handle = fopen($this->tracking, "r");
fclose($handle);
}
return;
}
|
php
|
private function remoteCall()
{
if (function_exists(
'wp_remote_head'
)) { // Check if this is being used with WordPress, if so use it's excellent HTTP class
$response = wp_remote_head($this->tracking);
return $response;
} elseif (function_exists('curl_init')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->tracking);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); //@nczz Fixed HTTPS GET method
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_exec($ch);
curl_close($ch);
} else {
$handle = fopen($this->tracking, "r");
fclose($handle);
}
return;
}
|
[
"private",
"function",
"remoteCall",
"(",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'wp_remote_head'",
")",
")",
"{",
"// Check if this is being used with WordPress, if so use it's excellent HTTP class",
"$",
"response",
"=",
"wp_remote_head",
"(",
"$",
"this",
"->",
"tracking",
")",
";",
"return",
"$",
"response",
";",
"}",
"elseif",
"(",
"function_exists",
"(",
"'curl_init'",
")",
")",
"{",
"$",
"ch",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_URL",
",",
"$",
"this",
"->",
"tracking",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_HEADER",
",",
"false",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_RETURNTRANSFER",
",",
"true",
")",
";",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_SSL_VERIFYPEER",
",",
"false",
")",
";",
"//@nczz Fixed HTTPS GET method",
"curl_setopt",
"(",
"$",
"ch",
",",
"CURLOPT_TIMEOUT",
",",
"10",
")",
";",
"curl_exec",
"(",
"$",
"ch",
")",
";",
"curl_close",
"(",
"$",
"ch",
")",
";",
"}",
"else",
"{",
"$",
"handle",
"=",
"fopen",
"(",
"$",
"this",
"->",
"tracking",
",",
"\"r\"",
")",
";",
"fclose",
"(",
"$",
"handle",
")",
";",
"}",
"return",
";",
"}"
] |
Use WP's HTTP class or CURL or fopen
@return array|null|void
|
[
"Use",
"WP",
"s",
"HTTP",
"class",
"or",
"CURL",
"or",
"fopen"
] |
1e58ebc830cbd2becaf99c11147f086669d86025
|
https://github.com/patrikx3/resume-php-common/blob/1e58ebc830cbd2becaf99c11147f086669d86025/src/Analytics.php#L171-L195
|
239,033
|
patrikx3/resume-php-common
|
src/Analytics.php
|
Analytics.sendTransaction
|
public function sendTransaction($transaction_id, $affiliation, $total, $tax, $shipping, $city, $region, $country)
{
$this->data['utmvw'] = '5.6.4dc';
$this->data['utms'] = ++self::$RequestsForThisSession;
$this->data['utmt'] = 'tran';
$this->data['utmtid'] = $transaction_id;
$this->data['utmtst'] = $affiliation;
$this->data['utmtto'] = $total;
$this->data['utmttx'] = $tax;
$this->data['utmtsp'] = $shipping;
$this->data['utmtci'] = $city;
$this->data['utmtrg'] = $region;
$this->data['utmtco'] = $country;
$this->data['utmcs'] = 'UTF-8';
$this->send();
$this->reset();
return $this;
}
|
php
|
public function sendTransaction($transaction_id, $affiliation, $total, $tax, $shipping, $city, $region, $country)
{
$this->data['utmvw'] = '5.6.4dc';
$this->data['utms'] = ++self::$RequestsForThisSession;
$this->data['utmt'] = 'tran';
$this->data['utmtid'] = $transaction_id;
$this->data['utmtst'] = $affiliation;
$this->data['utmtto'] = $total;
$this->data['utmttx'] = $tax;
$this->data['utmtsp'] = $shipping;
$this->data['utmtci'] = $city;
$this->data['utmtrg'] = $region;
$this->data['utmtco'] = $country;
$this->data['utmcs'] = 'UTF-8';
$this->send();
$this->reset();
return $this;
}
|
[
"public",
"function",
"sendTransaction",
"(",
"$",
"transaction_id",
",",
"$",
"affiliation",
",",
"$",
"total",
",",
"$",
"tax",
",",
"$",
"shipping",
",",
"$",
"city",
",",
"$",
"region",
",",
"$",
"country",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"'utmvw'",
"]",
"=",
"'5.6.4dc'",
";",
"$",
"this",
"->",
"data",
"[",
"'utms'",
"]",
"=",
"++",
"self",
"::",
"$",
"RequestsForThisSession",
";",
"$",
"this",
"->",
"data",
"[",
"'utmt'",
"]",
"=",
"'tran'",
";",
"$",
"this",
"->",
"data",
"[",
"'utmtid'",
"]",
"=",
"$",
"transaction_id",
";",
"$",
"this",
"->",
"data",
"[",
"'utmtst'",
"]",
"=",
"$",
"affiliation",
";",
"$",
"this",
"->",
"data",
"[",
"'utmtto'",
"]",
"=",
"$",
"total",
";",
"$",
"this",
"->",
"data",
"[",
"'utmttx'",
"]",
"=",
"$",
"tax",
";",
"$",
"this",
"->",
"data",
"[",
"'utmtsp'",
"]",
"=",
"$",
"shipping",
";",
"$",
"this",
"->",
"data",
"[",
"'utmtci'",
"]",
"=",
"$",
"city",
";",
"$",
"this",
"->",
"data",
"[",
"'utmtrg'",
"]",
"=",
"$",
"region",
";",
"$",
"this",
"->",
"data",
"[",
"'utmtco'",
"]",
"=",
"$",
"country",
";",
"$",
"this",
"->",
"data",
"[",
"'utmcs'",
"]",
"=",
"'UTF-8'",
";",
"$",
"this",
"->",
"send",
"(",
")",
";",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Create and send a transaction object
Parameter order from https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingEcommerce
@param $transaction_id
@param $affiliation
@param $total
@param $tax
@param $shipping
@param $city
@param $region
@param $country
@return $this
|
[
"Create",
"and",
"send",
"a",
"transaction",
"object"
] |
1e58ebc830cbd2becaf99c11147f086669d86025
|
https://github.com/patrikx3/resume-php-common/blob/1e58ebc830cbd2becaf99c11147f086669d86025/src/Analytics.php#L489-L508
|
239,034
|
slickframework/template
|
src/Utils/Text.php
|
Text.truncate
|
public static function truncate(
$value, $length = 80, $terminator = "\n", $preserve = false
) {
$length = $preserve
? static::preserveBreakpoint($value, $length)
: $length;
if (mb_strlen($value) > $length) {
$value = rtrim(mb_substr($value, 0, $length)).
$terminator;
}
return $value;
}
|
php
|
public static function truncate(
$value, $length = 80, $terminator = "\n", $preserve = false
) {
$length = $preserve
? static::preserveBreakpoint($value, $length)
: $length;
if (mb_strlen($value) > $length) {
$value = rtrim(mb_substr($value, 0, $length)).
$terminator;
}
return $value;
}
|
[
"public",
"static",
"function",
"truncate",
"(",
"$",
"value",
",",
"$",
"length",
"=",
"80",
",",
"$",
"terminator",
"=",
"\"\\n\"",
",",
"$",
"preserve",
"=",
"false",
")",
"{",
"$",
"length",
"=",
"$",
"preserve",
"?",
"static",
"::",
"preserveBreakpoint",
"(",
"$",
"value",
",",
"$",
"length",
")",
":",
"$",
"length",
";",
"if",
"(",
"mb_strlen",
"(",
"$",
"value",
")",
">",
"$",
"length",
")",
"{",
"$",
"value",
"=",
"rtrim",
"(",
"mb_substr",
"(",
"$",
"value",
",",
"0",
",",
"$",
"length",
")",
")",
".",
"$",
"terminator",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Truncates the value string with the provided length
If the string length is lower the the desired truncate length
the value is returned intact.
If the string is bigger then the provided length then it will
be cut and the a terminator will be added to the end of the string.
If you specify $preserve arg as true the world will be preserved
when cutting the string and the cut will occur on the next available
space character counting from the provided length.
@param string $value
@param int $length
@param string $terminator
@param bool $preserve
@return string The truncate string
|
[
"Truncates",
"the",
"value",
"string",
"with",
"the",
"provided",
"length"
] |
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
|
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Utils/Text.php#L40-L51
|
239,035
|
slickframework/template
|
src/Utils/Text.php
|
Text.preserveBreakpoint
|
private static function preserveBreakpoint($value, $length)
{
if (strlen($value) <= $length) {
return $length;
}
$breakpoint = mb_strpos($value, ' ', $length);
$length = $breakpoint;
if (false === $breakpoint) {
$length = mb_strlen($value);
}
return $length;
}
|
php
|
private static function preserveBreakpoint($value, $length)
{
if (strlen($value) <= $length) {
return $length;
}
$breakpoint = mb_strpos($value, ' ', $length);
$length = $breakpoint;
if (false === $breakpoint) {
$length = mb_strlen($value);
}
return $length;
}
|
[
"private",
"static",
"function",
"preserveBreakpoint",
"(",
"$",
"value",
",",
"$",
"length",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
"<=",
"$",
"length",
")",
"{",
"return",
"$",
"length",
";",
"}",
"$",
"breakpoint",
"=",
"mb_strpos",
"(",
"$",
"value",
",",
"' '",
",",
"$",
"length",
")",
";",
"$",
"length",
"=",
"$",
"breakpoint",
";",
"if",
"(",
"false",
"===",
"$",
"breakpoint",
")",
"{",
"$",
"length",
"=",
"mb_strlen",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"length",
";",
"}"
] |
Check truncate length to avoid split a word
@param string $value
@param int $length
@return int
|
[
"Check",
"truncate",
"length",
"to",
"avoid",
"split",
"a",
"word"
] |
d31abe9608acb30cfb8a6abd9cdf9d334f682fef
|
https://github.com/slickframework/template/blob/d31abe9608acb30cfb8a6abd9cdf9d334f682fef/src/Utils/Text.php#L85-L96
|
239,036
|
spiral/validation
|
src/Validator.php
|
Validator.validate
|
protected function validate()
{
if (!empty($this->errors)) {
// already validated
return;
}
$this->errors = [];
foreach ($this->rules as $field => $rules) {
$value = $this->getValue($field);
foreach ($this->provider->getRules($rules) as $rule) {
if ($rule->ignoreEmpty($value) && empty($rule->hasConditions())) {
continue;
}
foreach ($rule->getConditions() as $condition) {
if (!$condition->isMet($this, $field, $value)) {
// condition is not met, skipping validation
continue 2;
}
}
if (!$rule->validate($this, $field, $value)) {
// got error, jump to next field
$this->errors[$field] = $rule->getMessage($field, $value);
break;
}
}
}
}
|
php
|
protected function validate()
{
if (!empty($this->errors)) {
// already validated
return;
}
$this->errors = [];
foreach ($this->rules as $field => $rules) {
$value = $this->getValue($field);
foreach ($this->provider->getRules($rules) as $rule) {
if ($rule->ignoreEmpty($value) && empty($rule->hasConditions())) {
continue;
}
foreach ($rule->getConditions() as $condition) {
if (!$condition->isMet($this, $field, $value)) {
// condition is not met, skipping validation
continue 2;
}
}
if (!$rule->validate($this, $field, $value)) {
// got error, jump to next field
$this->errors[$field] = $rule->getMessage($field, $value);
break;
}
}
}
}
|
[
"protected",
"function",
"validate",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"errors",
")",
")",
"{",
"// already validated",
"return",
";",
"}",
"$",
"this",
"->",
"errors",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"as",
"$",
"field",
"=>",
"$",
"rules",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getValue",
"(",
"$",
"field",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"provider",
"->",
"getRules",
"(",
"$",
"rules",
")",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"rule",
"->",
"ignoreEmpty",
"(",
"$",
"value",
")",
"&&",
"empty",
"(",
"$",
"rule",
"->",
"hasConditions",
"(",
")",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"rule",
"->",
"getConditions",
"(",
")",
"as",
"$",
"condition",
")",
"{",
"if",
"(",
"!",
"$",
"condition",
"->",
"isMet",
"(",
"$",
"this",
",",
"$",
"field",
",",
"$",
"value",
")",
")",
"{",
"// condition is not met, skipping validation",
"continue",
"2",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"rule",
"->",
"validate",
"(",
"$",
"this",
",",
"$",
"field",
",",
"$",
"value",
")",
")",
"{",
"// got error, jump to next field",
"$",
"this",
"->",
"errors",
"[",
"$",
"field",
"]",
"=",
"$",
"rule",
"->",
"getMessage",
"(",
"$",
"field",
",",
"$",
"value",
")",
";",
"break",
";",
"}",
"}",
"}",
"}"
] |
Validate data over given rules and context.
@throws \Spiral\Validation\Exception\ValidationException
|
[
"Validate",
"data",
"over",
"given",
"rules",
"and",
"context",
"."
] |
aa8977dfe93904acfcce354e000d7d384579e2e3
|
https://github.com/spiral/validation/blob/aa8977dfe93904acfcce354e000d7d384579e2e3/src/Validator.php#L111-L143
|
239,037
|
davewwww/TaggedServices
|
src/Dwo/TaggedServices/DependencyInjection/Compiler/TaggedServicesPass.php
|
TaggedServicesPass.getDefinitionForServiceId
|
private function getDefinitionForServiceId($serviceId, ServiceConfig $serviceConfig)
{
if ($serviceConfig->has(ServiceConfig::LAZY) && !$serviceConfig->get(ServiceConfig::LAZY)) {
return new Reference($serviceId);
} else {
return new Definition($this->invokeClass, array(new Reference('service_container'), $serviceId));
}
}
|
php
|
private function getDefinitionForServiceId($serviceId, ServiceConfig $serviceConfig)
{
if ($serviceConfig->has(ServiceConfig::LAZY) && !$serviceConfig->get(ServiceConfig::LAZY)) {
return new Reference($serviceId);
} else {
return new Definition($this->invokeClass, array(new Reference('service_container'), $serviceId));
}
}
|
[
"private",
"function",
"getDefinitionForServiceId",
"(",
"$",
"serviceId",
",",
"ServiceConfig",
"$",
"serviceConfig",
")",
"{",
"if",
"(",
"$",
"serviceConfig",
"->",
"has",
"(",
"ServiceConfig",
"::",
"LAZY",
")",
"&&",
"!",
"$",
"serviceConfig",
"->",
"get",
"(",
"ServiceConfig",
"::",
"LAZY",
")",
")",
"{",
"return",
"new",
"Reference",
"(",
"$",
"serviceId",
")",
";",
"}",
"else",
"{",
"return",
"new",
"Definition",
"(",
"$",
"this",
"->",
"invokeClass",
",",
"array",
"(",
"new",
"Reference",
"(",
"'service_container'",
")",
",",
"$",
"serviceId",
")",
")",
";",
"}",
"}"
] |
return a InvokeClass for lazyLoading or a reference of the service
@param string $serviceId
@param ServiceConfig $serviceConfig
@return object|Definition
|
[
"return",
"a",
"InvokeClass",
"for",
"lazyLoading",
"or",
"a",
"reference",
"of",
"the",
"service"
] |
ca1f864c56616c47ff94f3651cd879628c3e07d5
|
https://github.com/davewwww/TaggedServices/blob/ca1f864c56616c47ff94f3651cd879628c3e07d5/src/Dwo/TaggedServices/DependencyInjection/Compiler/TaggedServicesPass.php#L128-L136
|
239,038
|
SlabPHP/display
|
src/Template.php
|
Template.load
|
protected function load($filename, $data = array(), $return = false)
{
$template = $this->createSubTemplate();
try {
return $template->renderTemplate($filename, $data, $return);
} catch (\Exception $exception) {
if (!empty($this->log))
{
$this->log->error("Failed to render template " . $filename, $exception);
}
return '';
}
}
|
php
|
protected function load($filename, $data = array(), $return = false)
{
$template = $this->createSubTemplate();
try {
return $template->renderTemplate($filename, $data, $return);
} catch (\Exception $exception) {
if (!empty($this->log))
{
$this->log->error("Failed to render template " . $filename, $exception);
}
return '';
}
}
|
[
"protected",
"function",
"load",
"(",
"$",
"filename",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"return",
"=",
"false",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"createSubTemplate",
"(",
")",
";",
"try",
"{",
"return",
"$",
"template",
"->",
"renderTemplate",
"(",
"$",
"filename",
",",
"$",
"data",
",",
"$",
"return",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"log",
")",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"error",
"(",
"\"Failed to render template \"",
".",
"$",
"filename",
",",
"$",
"exception",
")",
";",
"}",
"return",
"''",
";",
"}",
"}"
] |
Build a template
@param string $filename
@param mixed $data
@param boolean $return
@return string
|
[
"Build",
"a",
"template"
] |
aa2c61cf4066f0373b1b5dd0a7aba52e93d158b4
|
https://github.com/SlabPHP/display/blob/aa2c61cf4066f0373b1b5dd0a7aba52e93d158b4/src/Template.php#L137-L150
|
239,039
|
SlabPHP/display
|
src/Template.php
|
Template.parseTemplate
|
private function parseTemplate($filename, $data)
{
if (is_array($data)) {
$this->_templateData = $data;
} else if (is_object($data)) {
if (method_exists($data, 'getTemplateData')) {
$this->_templateData = $data->getTemplateData();
} else {
$this->_templateData = (array)$data;
}
} else {
$this->_templateData = array('variable' => $data);
}
$this->allowRecursion = (!empty($this->_templateData['_allowRecursion']) ? true : false);
$filename = $this->locateViewFile($filename);
if ($filename) {
$this->setCurrentTemplate($filename);
ob_start();
include $filename;
$info = ob_get_contents();
ob_end_clean();
return $info;
}
return false;
}
|
php
|
private function parseTemplate($filename, $data)
{
if (is_array($data)) {
$this->_templateData = $data;
} else if (is_object($data)) {
if (method_exists($data, 'getTemplateData')) {
$this->_templateData = $data->getTemplateData();
} else {
$this->_templateData = (array)$data;
}
} else {
$this->_templateData = array('variable' => $data);
}
$this->allowRecursion = (!empty($this->_templateData['_allowRecursion']) ? true : false);
$filename = $this->locateViewFile($filename);
if ($filename) {
$this->setCurrentTemplate($filename);
ob_start();
include $filename;
$info = ob_get_contents();
ob_end_clean();
return $info;
}
return false;
}
|
[
"private",
"function",
"parseTemplate",
"(",
"$",
"filename",
",",
"$",
"data",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"_templateData",
"=",
"$",
"data",
";",
"}",
"else",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"if",
"(",
"method_exists",
"(",
"$",
"data",
",",
"'getTemplateData'",
")",
")",
"{",
"$",
"this",
"->",
"_templateData",
"=",
"$",
"data",
"->",
"getTemplateData",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_templateData",
"=",
"(",
"array",
")",
"$",
"data",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"_templateData",
"=",
"array",
"(",
"'variable'",
"=>",
"$",
"data",
")",
";",
"}",
"$",
"this",
"->",
"allowRecursion",
"=",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"_templateData",
"[",
"'_allowRecursion'",
"]",
")",
"?",
"true",
":",
"false",
")",
";",
"$",
"filename",
"=",
"$",
"this",
"->",
"locateViewFile",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"filename",
")",
"{",
"$",
"this",
"->",
"setCurrentTemplate",
"(",
"$",
"filename",
")",
";",
"ob_start",
"(",
")",
";",
"include",
"$",
"filename",
";",
"$",
"info",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"info",
";",
"}",
"return",
"false",
";",
"}"
] |
Parse a specific filename with data
@param string $filename
@param array $data
@return bool|string
|
[
"Parse",
"a",
"specific",
"filename",
"with",
"data"
] |
aa2c61cf4066f0373b1b5dd0a7aba52e93d158b4
|
https://github.com/SlabPHP/display/blob/aa2c61cf4066f0373b1b5dd0a7aba52e93d158b4/src/Template.php#L185-L215
|
239,040
|
SlabPHP/display
|
src/Template.php
|
Template.locateViewFile
|
public function locateViewFile($filename, $requiredNamespace = '')
{
foreach ($this->templateSearchDirectories as $namespace => $location) {
if (!empty($requiredNamespace) && ($namespace != $requiredNamespace)) {
continue;
}
$fullFilename = $location . DIRECTORY_SEPARATOR . str_replace('..', '', $filename);
if (!$this->allowRecursion && ($fullFilename == $this->parentTemplate)) {
if (!empty($this->log))
{
$this->log->error("Disallowed template recursion found in filename " . $filename . ". To allow recursion, send _allowRecursion=true into the template data.");
}
return '';
}
if (is_file($fullFilename)) {
return $fullFilename;
}
}
if (!empty($this->log))
{
$this->log->error("Invalid template filename specified " . $filename);
}
return '';
}
|
php
|
public function locateViewFile($filename, $requiredNamespace = '')
{
foreach ($this->templateSearchDirectories as $namespace => $location) {
if (!empty($requiredNamespace) && ($namespace != $requiredNamespace)) {
continue;
}
$fullFilename = $location . DIRECTORY_SEPARATOR . str_replace('..', '', $filename);
if (!$this->allowRecursion && ($fullFilename == $this->parentTemplate)) {
if (!empty($this->log))
{
$this->log->error("Disallowed template recursion found in filename " . $filename . ". To allow recursion, send _allowRecursion=true into the template data.");
}
return '';
}
if (is_file($fullFilename)) {
return $fullFilename;
}
}
if (!empty($this->log))
{
$this->log->error("Invalid template filename specified " . $filename);
}
return '';
}
|
[
"public",
"function",
"locateViewFile",
"(",
"$",
"filename",
",",
"$",
"requiredNamespace",
"=",
"''",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"templateSearchDirectories",
"as",
"$",
"namespace",
"=>",
"$",
"location",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"requiredNamespace",
")",
"&&",
"(",
"$",
"namespace",
"!=",
"$",
"requiredNamespace",
")",
")",
"{",
"continue",
";",
"}",
"$",
"fullFilename",
"=",
"$",
"location",
".",
"DIRECTORY_SEPARATOR",
".",
"str_replace",
"(",
"'..'",
",",
"''",
",",
"$",
"filename",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"allowRecursion",
"&&",
"(",
"$",
"fullFilename",
"==",
"$",
"this",
"->",
"parentTemplate",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"log",
")",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"error",
"(",
"\"Disallowed template recursion found in filename \"",
".",
"$",
"filename",
".",
"\". To allow recursion, send _allowRecursion=true into the template data.\"",
")",
";",
"}",
"return",
"''",
";",
"}",
"if",
"(",
"is_file",
"(",
"$",
"fullFilename",
")",
")",
"{",
"return",
"$",
"fullFilename",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"log",
")",
")",
"{",
"$",
"this",
"->",
"log",
"->",
"error",
"(",
"\"Invalid template filename specified \"",
".",
"$",
"filename",
")",
";",
"}",
"return",
"''",
";",
"}"
] |
Locate a desired view file
@param string $filename
@param string $requiredNamespace
@return string
|
[
"Locate",
"a",
"desired",
"view",
"file"
] |
aa2c61cf4066f0373b1b5dd0a7aba52e93d158b4
|
https://github.com/SlabPHP/display/blob/aa2c61cf4066f0373b1b5dd0a7aba52e93d158b4/src/Template.php#L224-L252
|
239,041
|
nullivex/lib-xport
|
LSS/Xport/Common.php
|
Common.humanize
|
public function humanize(){
$this->stream->setCompression(Stream::COMPRESS_OFF);
$this->stream->setEncryption(Stream::CRYPT_OFF);
$this->setEncoding(Common::ENC_XML);
return $this;
}
|
php
|
public function humanize(){
$this->stream->setCompression(Stream::COMPRESS_OFF);
$this->stream->setEncryption(Stream::CRYPT_OFF);
$this->setEncoding(Common::ENC_XML);
return $this;
}
|
[
"public",
"function",
"humanize",
"(",
")",
"{",
"$",
"this",
"->",
"stream",
"->",
"setCompression",
"(",
"Stream",
"::",
"COMPRESS_OFF",
")",
";",
"$",
"this",
"->",
"stream",
"->",
"setEncryption",
"(",
"Stream",
"::",
"CRYPT_OFF",
")",
";",
"$",
"this",
"->",
"setEncoding",
"(",
"Common",
"::",
"ENC_XML",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
good for debugging, bad for security, size, flexibility
|
[
"good",
"for",
"debugging",
"bad",
"for",
"security",
"size",
"flexibility"
] |
87a2156d9d15a8eecbcab3e5a00326dc24b9e97e
|
https://github.com/nullivex/lib-xport/blob/87a2156d9d15a8eecbcab3e5a00326dc24b9e97e/LSS/Xport/Common.php#L39-L44
|
239,042
|
kiler129/CherryHttp
|
src/Http/Response/ResponseFactory.php
|
ResponseFactory.getResponse
|
public function getResponse($code = ResponseCode::NO_CONTENT, $content = null, $headers = [])
{
$response = clone $this->baseResponse;
if ($code !== false) {
$response->setStatus($code);
}
if ($content !== false) {
$response->setBody($content);
}
if ($this->headersMode === self::HEADERS_MODE_ADD) {
foreach ($headers as $name => $value) {
$response->addHeader($name, $value);
}
} else {
foreach ($headers as $name => $value) {
$response->setHeader($name, $value);
}
}
return $response;
}
|
php
|
public function getResponse($code = ResponseCode::NO_CONTENT, $content = null, $headers = [])
{
$response = clone $this->baseResponse;
if ($code !== false) {
$response->setStatus($code);
}
if ($content !== false) {
$response->setBody($content);
}
if ($this->headersMode === self::HEADERS_MODE_ADD) {
foreach ($headers as $name => $value) {
$response->addHeader($name, $value);
}
} else {
foreach ($headers as $name => $value) {
$response->setHeader($name, $value);
}
}
return $response;
}
|
[
"public",
"function",
"getResponse",
"(",
"$",
"code",
"=",
"ResponseCode",
"::",
"NO_CONTENT",
",",
"$",
"content",
"=",
"null",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"clone",
"$",
"this",
"->",
"baseResponse",
";",
"if",
"(",
"$",
"code",
"!==",
"false",
")",
"{",
"$",
"response",
"->",
"setStatus",
"(",
"$",
"code",
")",
";",
"}",
"if",
"(",
"$",
"content",
"!==",
"false",
")",
"{",
"$",
"response",
"->",
"setBody",
"(",
"$",
"content",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"headersMode",
"===",
"self",
"::",
"HEADERS_MODE_ADD",
")",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"response",
"->",
"addHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"response",
"->",
"setHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"response",
";",
"}"
] |
Produces response with default values.
@param int|false $code Code to use. If you pass false code will be derived from base response.
@param null|false $content Content to use in new response. If you pass false content from default response will
be used.
@param array|false $headers Additional headers to add to new response.
@return ResponseInterface
|
[
"Produces",
"response",
"with",
"default",
"values",
"."
] |
05927f26183cbd6fd5ccb0853befecdea279308d
|
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/Http/Response/ResponseFactory.php#L107-L131
|
239,043
|
nano7/Foundation
|
src/Discover/PackageManifest.php
|
PackageManifest.providers
|
public function providers()
{
return collect($this->getManifest())->flatMap(function ($configuration) {
return (array) ($configuration['providers'] ? $configuration['providers'] : []);
})->filter()->all();
}
|
php
|
public function providers()
{
return collect($this->getManifest())->flatMap(function ($configuration) {
return (array) ($configuration['providers'] ? $configuration['providers'] : []);
})->filter()->all();
}
|
[
"public",
"function",
"providers",
"(",
")",
"{",
"return",
"collect",
"(",
"$",
"this",
"->",
"getManifest",
"(",
")",
")",
"->",
"flatMap",
"(",
"function",
"(",
"$",
"configuration",
")",
"{",
"return",
"(",
"array",
")",
"(",
"$",
"configuration",
"[",
"'providers'",
"]",
"?",
"$",
"configuration",
"[",
"'providers'",
"]",
":",
"[",
"]",
")",
";",
"}",
")",
"->",
"filter",
"(",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
Get all of the service provider class names for all packages.
@return array
|
[
"Get",
"all",
"of",
"the",
"service",
"provider",
"class",
"names",
"for",
"all",
"packages",
"."
] |
8328423f81c69b8fabc04b4f6b1f3ba712695374
|
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Discover/PackageManifest.php#L64-L69
|
239,044
|
nano7/Foundation
|
src/Discover/PackageManifest.php
|
PackageManifest.aliases
|
public function aliases()
{
return collect($this->getManifest())->flatMap(function ($configuration) {
return (array) ($configuration['aliases'] ? $configuration['aliases'] : []);
})->filter()->all();
}
|
php
|
public function aliases()
{
return collect($this->getManifest())->flatMap(function ($configuration) {
return (array) ($configuration['aliases'] ? $configuration['aliases'] : []);
})->filter()->all();
}
|
[
"public",
"function",
"aliases",
"(",
")",
"{",
"return",
"collect",
"(",
"$",
"this",
"->",
"getManifest",
"(",
")",
")",
"->",
"flatMap",
"(",
"function",
"(",
"$",
"configuration",
")",
"{",
"return",
"(",
"array",
")",
"(",
"$",
"configuration",
"[",
"'aliases'",
"]",
"?",
"$",
"configuration",
"[",
"'aliases'",
"]",
":",
"[",
"]",
")",
";",
"}",
")",
"->",
"filter",
"(",
")",
"->",
"all",
"(",
")",
";",
"}"
] |
Get all of the aliases for all packages.
@return array
|
[
"Get",
"all",
"of",
"the",
"aliases",
"for",
"all",
"packages",
"."
] |
8328423f81c69b8fabc04b4f6b1f3ba712695374
|
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Discover/PackageManifest.php#L76-L81
|
239,045
|
nano7/Foundation
|
src/Discover/PackageManifest.php
|
PackageManifest.build
|
public function build()
{
$packages = [];
if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) {
$packages = json_decode($this->files->get($path), true);
}
$ignoreAll = in_array('*', $ignore = $this->packagesToIgnore());
$this->write($keys = collect($packages)->mapWithKeys(function ($package) {
return [$this->format($package['name']) => $package['extra']['nano7'] ? $package['extra']['nano7'] : []];
})->each(function ($configuration) use (&$ignore) {
$ignore = array_merge($ignore, $configuration['dont-discover'] ? $configuration['dont-discover'] : []);
})->reject(function ($configuration, $package) use ($ignore, $ignoreAll) {
return $ignoreAll || in_array($package, $ignore);
})->filter()->all());
return $keys;
}
|
php
|
public function build()
{
$packages = [];
if ($this->files->exists($path = $this->vendorPath.'/composer/installed.json')) {
$packages = json_decode($this->files->get($path), true);
}
$ignoreAll = in_array('*', $ignore = $this->packagesToIgnore());
$this->write($keys = collect($packages)->mapWithKeys(function ($package) {
return [$this->format($package['name']) => $package['extra']['nano7'] ? $package['extra']['nano7'] : []];
})->each(function ($configuration) use (&$ignore) {
$ignore = array_merge($ignore, $configuration['dont-discover'] ? $configuration['dont-discover'] : []);
})->reject(function ($configuration, $package) use ($ignore, $ignoreAll) {
return $ignoreAll || in_array($package, $ignore);
})->filter()->all());
return $keys;
}
|
[
"public",
"function",
"build",
"(",
")",
"{",
"$",
"packages",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"path",
"=",
"$",
"this",
"->",
"vendorPath",
".",
"'/composer/installed.json'",
")",
")",
"{",
"$",
"packages",
"=",
"json_decode",
"(",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"$",
"path",
")",
",",
"true",
")",
";",
"}",
"$",
"ignoreAll",
"=",
"in_array",
"(",
"'*'",
",",
"$",
"ignore",
"=",
"$",
"this",
"->",
"packagesToIgnore",
"(",
")",
")",
";",
"$",
"this",
"->",
"write",
"(",
"$",
"keys",
"=",
"collect",
"(",
"$",
"packages",
")",
"->",
"mapWithKeys",
"(",
"function",
"(",
"$",
"package",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"format",
"(",
"$",
"package",
"[",
"'name'",
"]",
")",
"=>",
"$",
"package",
"[",
"'extra'",
"]",
"[",
"'nano7'",
"]",
"?",
"$",
"package",
"[",
"'extra'",
"]",
"[",
"'nano7'",
"]",
":",
"[",
"]",
"]",
";",
"}",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"configuration",
")",
"use",
"(",
"&",
"$",
"ignore",
")",
"{",
"$",
"ignore",
"=",
"array_merge",
"(",
"$",
"ignore",
",",
"$",
"configuration",
"[",
"'dont-discover'",
"]",
"?",
"$",
"configuration",
"[",
"'dont-discover'",
"]",
":",
"[",
"]",
")",
";",
"}",
")",
"->",
"reject",
"(",
"function",
"(",
"$",
"configuration",
",",
"$",
"package",
")",
"use",
"(",
"$",
"ignore",
",",
"$",
"ignoreAll",
")",
"{",
"return",
"$",
"ignoreAll",
"||",
"in_array",
"(",
"$",
"package",
",",
"$",
"ignore",
")",
";",
"}",
")",
"->",
"filter",
"(",
")",
"->",
"all",
"(",
")",
")",
";",
"return",
"$",
"keys",
";",
"}"
] |
Build the manifest and write it to disk.
@return array
|
[
"Build",
"the",
"manifest",
"and",
"write",
"it",
"to",
"disk",
"."
] |
8328423f81c69b8fabc04b4f6b1f3ba712695374
|
https://github.com/nano7/Foundation/blob/8328423f81c69b8fabc04b4f6b1f3ba712695374/src/Discover/PackageManifest.php#L107-L126
|
239,046
|
marando/phpSOFA
|
src/Marando/IAU/iauTaitt.php
|
iauTaitt.Taitt
|
public static function Taitt($tai1, $tai2, &$tt1, &$tt2) {
/* TT minus TAI (days). */
$dtat = TTMTAI / DAYSEC;
/* Result, safeguarding precision. */
if ($tai1 > $tai2) {
$tt1 = $tai1;
$tt2 = $tai2 + $dtat;
}
else {
$tt1 = $tai1 + $dtat;
$tt2 = $tai2;
}
/* Status (always OK). */
return 0;
}
|
php
|
public static function Taitt($tai1, $tai2, &$tt1, &$tt2) {
/* TT minus TAI (days). */
$dtat = TTMTAI / DAYSEC;
/* Result, safeguarding precision. */
if ($tai1 > $tai2) {
$tt1 = $tai1;
$tt2 = $tai2 + $dtat;
}
else {
$tt1 = $tai1 + $dtat;
$tt2 = $tai2;
}
/* Status (always OK). */
return 0;
}
|
[
"public",
"static",
"function",
"Taitt",
"(",
"$",
"tai1",
",",
"$",
"tai2",
",",
"&",
"$",
"tt1",
",",
"&",
"$",
"tt2",
")",
"{",
"/* TT minus TAI (days). */",
"$",
"dtat",
"=",
"TTMTAI",
"/",
"DAYSEC",
";",
"/* Result, safeguarding precision. */",
"if",
"(",
"$",
"tai1",
">",
"$",
"tai2",
")",
"{",
"$",
"tt1",
"=",
"$",
"tai1",
";",
"$",
"tt2",
"=",
"$",
"tai2",
"+",
"$",
"dtat",
";",
"}",
"else",
"{",
"$",
"tt1",
"=",
"$",
"tai1",
"+",
"$",
"dtat",
";",
"$",
"tt2",
"=",
"$",
"tai2",
";",
"}",
"/* Status (always OK). */",
"return",
"0",
";",
"}"
] |
- - - - - - - - -
i a u T a i t t
- - - - - - - - -
Time scale transformation: International Atomic Time, TAI, to
Terrestrial Time, TT.
This function is part of the International Astronomical Union's
SOFA (Standards of Fundamental Astronomy) software collection.
Status: canonical.
Given:
tai1,tai2 double TAI as a 2-part Julian Date
Returned:
tt1,tt2 double TT as a 2-part Julian Date
Returned (function value):
int status: 0 = OK
Note:
tai1+tai2 is Julian Date, apportioned in any convenient way
between the two arguments, for example where tai1 is the Julian
Day Number and tai2 is the fraction of a day. The returned
tt1,tt2 follow suit.
References:
McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
IERS Technical Note No. 32, BKG (2004)
Explanatory Supplement to the Astronomical Almanac,
P. Kenneth Seidelmann (ed), University Science Books (1992)
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end.
|
[
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"T",
"a",
"i",
"t",
"t",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] |
757fa49fe335ae1210eaa7735473fd4388b13f07
|
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauTaitt.php#L50-L66
|
239,047
|
maestrano/maestrano-php
|
lib/Api/Util.php
|
Maestrano_Api_Util.convertToMaestranoObject
|
public static function convertToMaestranoObject($resp, $preset)
{
$types = array(
'account_bill' => 'Maestrano_Account_Bill',
'account_recurring_bill' => 'Maestrano_Account_RecurringBill',
'account_group' => 'Maestrano_Account_Group',
'account_user' => 'Maestrano_Account_User',
'account_reseller' => 'Maestrano_Account_Reseller',
);
if (self::isList($resp)) {
$mapped = array();
foreach ($resp as $i)
array_push($mapped, self::convertToMaestranoObject($i, $preset));
return $mapped;
} else if (is_array($resp)) {
if (isset($resp['object'])
&& is_string($resp['object'])
&& isset($types[$resp['object']])) {
$class = $types[$resp['object']];
} else {
$class = 'Maestrano_Api_Object';
}
return Maestrano_Api_Object::scopedConstructFrom($class, $resp, $preset);
} else {
// Automatically convert dates
if (preg_match('/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/', $resp)) {
return new DateTime($resp);
} else {
return $resp;
}
}
}
|
php
|
public static function convertToMaestranoObject($resp, $preset)
{
$types = array(
'account_bill' => 'Maestrano_Account_Bill',
'account_recurring_bill' => 'Maestrano_Account_RecurringBill',
'account_group' => 'Maestrano_Account_Group',
'account_user' => 'Maestrano_Account_User',
'account_reseller' => 'Maestrano_Account_Reseller',
);
if (self::isList($resp)) {
$mapped = array();
foreach ($resp as $i)
array_push($mapped, self::convertToMaestranoObject($i, $preset));
return $mapped;
} else if (is_array($resp)) {
if (isset($resp['object'])
&& is_string($resp['object'])
&& isset($types[$resp['object']])) {
$class = $types[$resp['object']];
} else {
$class = 'Maestrano_Api_Object';
}
return Maestrano_Api_Object::scopedConstructFrom($class, $resp, $preset);
} else {
// Automatically convert dates
if (preg_match('/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/', $resp)) {
return new DateTime($resp);
} else {
return $resp;
}
}
}
|
[
"public",
"static",
"function",
"convertToMaestranoObject",
"(",
"$",
"resp",
",",
"$",
"preset",
")",
"{",
"$",
"types",
"=",
"array",
"(",
"'account_bill'",
"=>",
"'Maestrano_Account_Bill'",
",",
"'account_recurring_bill'",
"=>",
"'Maestrano_Account_RecurringBill'",
",",
"'account_group'",
"=>",
"'Maestrano_Account_Group'",
",",
"'account_user'",
"=>",
"'Maestrano_Account_User'",
",",
"'account_reseller'",
"=>",
"'Maestrano_Account_Reseller'",
",",
")",
";",
"if",
"(",
"self",
"::",
"isList",
"(",
"$",
"resp",
")",
")",
"{",
"$",
"mapped",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"resp",
"as",
"$",
"i",
")",
"array_push",
"(",
"$",
"mapped",
",",
"self",
"::",
"convertToMaestranoObject",
"(",
"$",
"i",
",",
"$",
"preset",
")",
")",
";",
"return",
"$",
"mapped",
";",
"}",
"else",
"if",
"(",
"is_array",
"(",
"$",
"resp",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"resp",
"[",
"'object'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"resp",
"[",
"'object'",
"]",
")",
"&&",
"isset",
"(",
"$",
"types",
"[",
"$",
"resp",
"[",
"'object'",
"]",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"types",
"[",
"$",
"resp",
"[",
"'object'",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"'Maestrano_Api_Object'",
";",
"}",
"return",
"Maestrano_Api_Object",
"::",
"scopedConstructFrom",
"(",
"$",
"class",
",",
"$",
"resp",
",",
"$",
"preset",
")",
";",
"}",
"else",
"{",
"// Automatically convert dates",
"if",
"(",
"preg_match",
"(",
"'/\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}/'",
",",
"$",
"resp",
")",
")",
"{",
"return",
"new",
"DateTime",
"(",
"$",
"resp",
")",
";",
"}",
"else",
"{",
"return",
"$",
"resp",
";",
"}",
"}",
"}"
] |
Converts a response from the Maestrano API to the corresponding PHP object.
@param array $resp The response from the Maestrano API.
@param string $apiToken
@return Maestrano_Api_Object|array
|
[
"Converts",
"a",
"response",
"from",
"the",
"Maestrano",
"API",
"to",
"the",
"corresponding",
"PHP",
"object",
"."
] |
757cbefb0f0bf07cb35ea7442041d9bfdcce1558
|
https://github.com/maestrano/maestrano-php/blob/757cbefb0f0bf07cb35ea7442041d9bfdcce1558/lib/Api/Util.php#L66-L100
|
239,048
|
emhar/SearchDoctrineBundle
|
Mapping/ItemMetaDataFactory.php
|
ItemMetaDataFactory.doLoad
|
protected function doLoad($itemClass)
{
$itemMetaData = $this->newItemMetaDataInstance($itemClass);
$entityDefinitions = $this->annotationDriver->loadEntityDefinitions($itemClass);
$itemMetaData->mapEntities($entityDefinitions);
$hitDefinitions = $this->annotationDriver->loadHitDefinitions($itemClass);
$itemMetaData->mapHits($hitDefinitions);
return $itemMetaData;
}
|
php
|
protected function doLoad($itemClass)
{
$itemMetaData = $this->newItemMetaDataInstance($itemClass);
$entityDefinitions = $this->annotationDriver->loadEntityDefinitions($itemClass);
$itemMetaData->mapEntities($entityDefinitions);
$hitDefinitions = $this->annotationDriver->loadHitDefinitions($itemClass);
$itemMetaData->mapHits($hitDefinitions);
return $itemMetaData;
}
|
[
"protected",
"function",
"doLoad",
"(",
"$",
"itemClass",
")",
"{",
"$",
"itemMetaData",
"=",
"$",
"this",
"->",
"newItemMetaDataInstance",
"(",
"$",
"itemClass",
")",
";",
"$",
"entityDefinitions",
"=",
"$",
"this",
"->",
"annotationDriver",
"->",
"loadEntityDefinitions",
"(",
"$",
"itemClass",
")",
";",
"$",
"itemMetaData",
"->",
"mapEntities",
"(",
"$",
"entityDefinitions",
")",
";",
"$",
"hitDefinitions",
"=",
"$",
"this",
"->",
"annotationDriver",
"->",
"loadHitDefinitions",
"(",
"$",
"itemClass",
")",
";",
"$",
"itemMetaData",
"->",
"mapHits",
"(",
"$",
"hitDefinitions",
")",
";",
"return",
"$",
"itemMetaData",
";",
"}"
] |
Loads the itemMetaData of the item class
@param string $itemClass The name of the item class for which the itemMetaData should get loaded.
@param null $datas unused
@return ItemMetaData
|
[
"Loads",
"the",
"itemMetaData",
"of",
"the",
"item",
"class"
] |
0844cda4a6972dd71c04c0b38dba1ebf9b15c238
|
https://github.com/emhar/SearchDoctrineBundle/blob/0844cda4a6972dd71c04c0b38dba1ebf9b15c238/Mapping/ItemMetaDataFactory.php#L55-L63
|
239,049
|
indigophp-archive/codeception-fuel-module
|
fuel/fuel/packages/email/classes/email.php
|
Email.forge
|
public static function forge($setup = null, array $config = array())
{
empty($setup) and $setup = \Config::get('email.default_setup', 'default');
is_string($setup) and $setup = \Config::get('email.setups.'.$setup, array());
$setup = \Arr::merge(static::$_defaults, $setup);
$config = \Arr::merge($setup, $config);
$driver = '\\Email_Driver_'.ucfirst(strtolower($config['driver']));
if( ! class_exists($driver, true))
{
throw new \FuelException('Could not find Email driver: '.$config['driver']. ' ('.$driver.')');
}
$driver = new $driver($config);
return $driver;
}
|
php
|
public static function forge($setup = null, array $config = array())
{
empty($setup) and $setup = \Config::get('email.default_setup', 'default');
is_string($setup) and $setup = \Config::get('email.setups.'.$setup, array());
$setup = \Arr::merge(static::$_defaults, $setup);
$config = \Arr::merge($setup, $config);
$driver = '\\Email_Driver_'.ucfirst(strtolower($config['driver']));
if( ! class_exists($driver, true))
{
throw new \FuelException('Could not find Email driver: '.$config['driver']. ' ('.$driver.')');
}
$driver = new $driver($config);
return $driver;
}
|
[
"public",
"static",
"function",
"forge",
"(",
"$",
"setup",
"=",
"null",
",",
"array",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"empty",
"(",
"$",
"setup",
")",
"and",
"$",
"setup",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'email.default_setup'",
",",
"'default'",
")",
";",
"is_string",
"(",
"$",
"setup",
")",
"and",
"$",
"setup",
"=",
"\\",
"Config",
"::",
"get",
"(",
"'email.setups.'",
".",
"$",
"setup",
",",
"array",
"(",
")",
")",
";",
"$",
"setup",
"=",
"\\",
"Arr",
"::",
"merge",
"(",
"static",
"::",
"$",
"_defaults",
",",
"$",
"setup",
")",
";",
"$",
"config",
"=",
"\\",
"Arr",
"::",
"merge",
"(",
"$",
"setup",
",",
"$",
"config",
")",
";",
"$",
"driver",
"=",
"'\\\\Email_Driver_'",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"config",
"[",
"'driver'",
"]",
")",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"driver",
",",
"true",
")",
")",
"{",
"throw",
"new",
"\\",
"FuelException",
"(",
"'Could not find Email driver: '",
".",
"$",
"config",
"[",
"'driver'",
"]",
".",
"' ('",
".",
"$",
"driver",
".",
"')'",
")",
";",
"}",
"$",
"driver",
"=",
"new",
"$",
"driver",
"(",
"$",
"config",
")",
";",
"return",
"$",
"driver",
";",
"}"
] |
Email driver forge.
@param string|array $setup setup key for array defined in email.setups config or config array
@param array $config extra config array
@throws \FuelException Could not find Email driver
@return Email_Driver one of the email drivers
|
[
"Email",
"driver",
"forge",
"."
] |
0973b7cbd540a0e89cc5bb7af94627f77f09bf49
|
https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/email/classes/email.php#L59-L77
|
239,050
|
klaravel/settings
|
src/SettingHelper.php
|
SettingHelper.get
|
public function get($key)
{
if (!$this->has($key)) {
return null;
}
return (new SettingModel)
->cached()
->where('key', $key)
->first()
->value;
}
|
php
|
public function get($key)
{
if (!$this->has($key)) {
return null;
}
return (new SettingModel)
->cached()
->where('key', $key)
->first()
->value;
}
|
[
"public",
"function",
"get",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"(",
"new",
"SettingModel",
")",
"->",
"cached",
"(",
")",
"->",
"where",
"(",
"'key'",
",",
"$",
"key",
")",
"->",
"first",
"(",
")",
"->",
"value",
";",
"}"
] |
Get value if key exists else it will return null
@param string $key
@return string|null
|
[
"Get",
"value",
"if",
"key",
"exists",
"else",
"it",
"will",
"return",
"null"
] |
00bf02b38286b2ef9a2a9399455c74019176466a
|
https://github.com/klaravel/settings/blob/00bf02b38286b2ef9a2a9399455c74019176466a/src/SettingHelper.php#L34-L45
|
239,051
|
klaravel/settings
|
src/SettingHelper.php
|
SettingHelper.put
|
public function put($key, $value)
{
// if key exits then override
if ($this::has($key)) {
$setting = (new SettingModel)
->cached()
->where('key', $key)
->first();
$setting->value = $value;
return $setting->save();
}
return SettingModel::create([
'key' => $key,
'value' => $value,
]);
}
|
php
|
public function put($key, $value)
{
// if key exits then override
if ($this::has($key)) {
$setting = (new SettingModel)
->cached()
->where('key', $key)
->first();
$setting->value = $value;
return $setting->save();
}
return SettingModel::create([
'key' => $key,
'value' => $value,
]);
}
|
[
"public",
"function",
"put",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"// if key exits then override",
"if",
"(",
"$",
"this",
"::",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"setting",
"=",
"(",
"new",
"SettingModel",
")",
"->",
"cached",
"(",
")",
"->",
"where",
"(",
"'key'",
",",
"$",
"key",
")",
"->",
"first",
"(",
")",
";",
"$",
"setting",
"->",
"value",
"=",
"$",
"value",
";",
"return",
"$",
"setting",
"->",
"save",
"(",
")",
";",
"}",
"return",
"SettingModel",
"::",
"create",
"(",
"[",
"'key'",
"=>",
"$",
"key",
",",
"'value'",
"=>",
"$",
"value",
",",
"]",
")",
";",
"}"
] |
Store new key and value in settings if it's already
exits then override.
@param string $key
@param string $value
@return null
|
[
"Store",
"new",
"key",
"and",
"value",
"in",
"settings",
"if",
"it",
"s",
"already",
"exits",
"then",
"override",
"."
] |
00bf02b38286b2ef9a2a9399455c74019176466a
|
https://github.com/klaravel/settings/blob/00bf02b38286b2ef9a2a9399455c74019176466a/src/SettingHelper.php#L55-L73
|
239,052
|
klaravel/settings
|
src/SettingHelper.php
|
SettingHelper.forget
|
public function forget($key)
{
$isDeleted = SettingModel::where('key', $key)
->delete();
// if delete record then delete cache
if ($isDeleted) {
Cache::forget('Klaravel\Settings\Setting');
}
return $isDeleted;
}
|
php
|
public function forget($key)
{
$isDeleted = SettingModel::where('key', $key)
->delete();
// if delete record then delete cache
if ($isDeleted) {
Cache::forget('Klaravel\Settings\Setting');
}
return $isDeleted;
}
|
[
"public",
"function",
"forget",
"(",
"$",
"key",
")",
"{",
"$",
"isDeleted",
"=",
"SettingModel",
"::",
"where",
"(",
"'key'",
",",
"$",
"key",
")",
"->",
"delete",
"(",
")",
";",
"// if delete record then delete cache",
"if",
"(",
"$",
"isDeleted",
")",
"{",
"Cache",
"::",
"forget",
"(",
"'Klaravel\\Settings\\Setting'",
")",
";",
"}",
"return",
"$",
"isDeleted",
";",
"}"
] |
Delete setting data from databasse
@param string $key
@return boolean
|
[
"Delete",
"setting",
"data",
"from",
"databasse"
] |
00bf02b38286b2ef9a2a9399455c74019176466a
|
https://github.com/klaravel/settings/blob/00bf02b38286b2ef9a2a9399455c74019176466a/src/SettingHelper.php#L94-L105
|
239,053
|
gbprod/elastica-extra-bundle
|
src/ElasticaExtraBundle/Command/ElasticaAwareCommand.php
|
ElasticaAwareCommand.getClient
|
protected function getClient($clientName)
{
$clientName = $clientName ?: 'gbprod.elastica_extra.default_client';
$client = $this->getContainer()
->get(
$clientName,
ContainerInterface::NULL_ON_INVALID_REFERENCE
)
;
$this->validateClient($client, $clientName);
return $client;
}
|
php
|
protected function getClient($clientName)
{
$clientName = $clientName ?: 'gbprod.elastica_extra.default_client';
$client = $this->getContainer()
->get(
$clientName,
ContainerInterface::NULL_ON_INVALID_REFERENCE
)
;
$this->validateClient($client, $clientName);
return $client;
}
|
[
"protected",
"function",
"getClient",
"(",
"$",
"clientName",
")",
"{",
"$",
"clientName",
"=",
"$",
"clientName",
"?",
":",
"'gbprod.elastica_extra.default_client'",
";",
"$",
"client",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"$",
"clientName",
",",
"ContainerInterface",
"::",
"NULL_ON_INVALID_REFERENCE",
")",
";",
"$",
"this",
"->",
"validateClient",
"(",
"$",
"client",
",",
"$",
"clientName",
")",
";",
"return",
"$",
"client",
";",
"}"
] |
Get elasticsearch client from his name
@param string $clientName
@return Client
|
[
"Get",
"elasticsearch",
"client",
"from",
"his",
"name"
] |
7a3d925c79903a328a3d07fefe998c0056be7e59
|
https://github.com/gbprod/elastica-extra-bundle/blob/7a3d925c79903a328a3d07fefe998c0056be7e59/src/ElasticaExtraBundle/Command/ElasticaAwareCommand.php#L23-L37
|
239,054
|
redreams/class-finder
|
src/ClassFinder.php
|
ClassFinder.find
|
public static function find(string $source): ?string
{
$class = false;
$namespace = false;
$tokens = token_get_all($source);
if (1 === count($tokens) && T_INLINE_HTML === $tokens[0][0]) {
return null;
}
for ($i = 0; isset($tokens[$i]); ++$i) {
$token = $tokens[$i];
if (!isset($token[1])) {
continue;
}
if (true === $class && T_STRING === $token[0]) {
return $namespace.'\\'.$token[1];
}
if (true === $namespace && T_STRING === $token[0]) {
$namespace = $token[1];
while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING], true)) {
$namespace .= $tokens[$i][1];
}
$token = $tokens[$i];
}
if (T_CLASS === $token[0]) {
// Skip usage of ::class constant and anonymous classes
$skipClassToken = false;
for ($j = $i - 1; $j > 0; --$j) {
if (!isset($tokens[$j][1])
|| !in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT], true)
) {
break;
}
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
$skipClassToken = true;
break;
}
}
if (!$skipClassToken) {
$class = true;
}
}
if (T_NAMESPACE === $token[0]) {
$namespace = true;
}
}
return null;
}
|
php
|
public static function find(string $source): ?string
{
$class = false;
$namespace = false;
$tokens = token_get_all($source);
if (1 === count($tokens) && T_INLINE_HTML === $tokens[0][0]) {
return null;
}
for ($i = 0; isset($tokens[$i]); ++$i) {
$token = $tokens[$i];
if (!isset($token[1])) {
continue;
}
if (true === $class && T_STRING === $token[0]) {
return $namespace.'\\'.$token[1];
}
if (true === $namespace && T_STRING === $token[0]) {
$namespace = $token[1];
while (isset($tokens[++$i][1]) && in_array($tokens[$i][0], [T_NS_SEPARATOR, T_STRING], true)) {
$namespace .= $tokens[$i][1];
}
$token = $tokens[$i];
}
if (T_CLASS === $token[0]) {
// Skip usage of ::class constant and anonymous classes
$skipClassToken = false;
for ($j = $i - 1; $j > 0; --$j) {
if (!isset($tokens[$j][1])
|| !in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT], true)
) {
break;
}
if (T_DOUBLE_COLON === $tokens[$j][0] || T_NEW === $tokens[$j][0]) {
$skipClassToken = true;
break;
}
}
if (!$skipClassToken) {
$class = true;
}
}
if (T_NAMESPACE === $token[0]) {
$namespace = true;
}
}
return null;
}
|
[
"public",
"static",
"function",
"find",
"(",
"string",
"$",
"source",
")",
":",
"?",
"string",
"{",
"$",
"class",
"=",
"false",
";",
"$",
"namespace",
"=",
"false",
";",
"$",
"tokens",
"=",
"token_get_all",
"(",
"$",
"source",
")",
";",
"if",
"(",
"1",
"===",
"count",
"(",
"$",
"tokens",
")",
"&&",
"T_INLINE_HTML",
"===",
"$",
"tokens",
"[",
"0",
"]",
"[",
"0",
"]",
")",
"{",
"return",
"null",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
")",
";",
"++",
"$",
"i",
")",
"{",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"token",
"[",
"1",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"class",
"&&",
"T_STRING",
"===",
"$",
"token",
"[",
"0",
"]",
")",
"{",
"return",
"$",
"namespace",
".",
"'\\\\'",
".",
"$",
"token",
"[",
"1",
"]",
";",
"}",
"if",
"(",
"true",
"===",
"$",
"namespace",
"&&",
"T_STRING",
"===",
"$",
"token",
"[",
"0",
"]",
")",
"{",
"$",
"namespace",
"=",
"$",
"token",
"[",
"1",
"]",
";",
"while",
"(",
"isset",
"(",
"$",
"tokens",
"[",
"++",
"$",
"i",
"]",
"[",
"1",
"]",
")",
"&&",
"in_array",
"(",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"0",
"]",
",",
"[",
"T_NS_SEPARATOR",
",",
"T_STRING",
"]",
",",
"true",
")",
")",
"{",
"$",
"namespace",
".=",
"$",
"tokens",
"[",
"$",
"i",
"]",
"[",
"1",
"]",
";",
"}",
"$",
"token",
"=",
"$",
"tokens",
"[",
"$",
"i",
"]",
";",
"}",
"if",
"(",
"T_CLASS",
"===",
"$",
"token",
"[",
"0",
"]",
")",
"{",
"// Skip usage of ::class constant and anonymous classes",
"$",
"skipClassToken",
"=",
"false",
";",
"for",
"(",
"$",
"j",
"=",
"$",
"i",
"-",
"1",
";",
"$",
"j",
">",
"0",
";",
"--",
"$",
"j",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"tokens",
"[",
"$",
"j",
"]",
"[",
"1",
"]",
")",
"||",
"!",
"in_array",
"(",
"$",
"tokens",
"[",
"$",
"j",
"]",
"[",
"0",
"]",
",",
"[",
"T_WHITESPACE",
",",
"T_DOC_COMMENT",
",",
"T_COMMENT",
"]",
",",
"true",
")",
")",
"{",
"break",
";",
"}",
"if",
"(",
"T_DOUBLE_COLON",
"===",
"$",
"tokens",
"[",
"$",
"j",
"]",
"[",
"0",
"]",
"||",
"T_NEW",
"===",
"$",
"tokens",
"[",
"$",
"j",
"]",
"[",
"0",
"]",
")",
"{",
"$",
"skipClassToken",
"=",
"true",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"skipClassToken",
")",
"{",
"$",
"class",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"T_NAMESPACE",
"===",
"$",
"token",
"[",
"0",
"]",
")",
"{",
"$",
"namespace",
"=",
"true",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Find class and return fully qualified name in the source
@param string $source PHP source code
@return string|null Fully qualified class name if found, null otherwise
|
[
"Find",
"class",
"and",
"return",
"fully",
"qualified",
"name",
"in",
"the",
"source"
] |
86dafd757d3d00783dce5edbd9767b3af5ab1462
|
https://github.com/redreams/class-finder/blob/86dafd757d3d00783dce5edbd9767b3af5ab1462/src/ClassFinder.php#L29-L76
|
239,055
|
vphantom/pyritephp
|
src/Pyrite/Templating.php
|
Templating.shutdown
|
public static function shutdown()
{
global $PPHP;
$req = grab('request');
if (!$req['binary']) {
$body = ob_get_contents();
ob_end_clean();
try {
array_merge_assoc(
self::$_stash,
array(
'body' => self::$_safeBody,
'stdout' => $body,
'config' => $PPHP['config'],
'session' => $_SESSION,
'req' => grab('request')
)
);
self::$_template->displayBlock('body', self::$_stash);
} catch (\Exception $e) {
echo $e->getMessage();
};
};
}
|
php
|
public static function shutdown()
{
global $PPHP;
$req = grab('request');
if (!$req['binary']) {
$body = ob_get_contents();
ob_end_clean();
try {
array_merge_assoc(
self::$_stash,
array(
'body' => self::$_safeBody,
'stdout' => $body,
'config' => $PPHP['config'],
'session' => $_SESSION,
'req' => grab('request')
)
);
self::$_template->displayBlock('body', self::$_stash);
} catch (\Exception $e) {
echo $e->getMessage();
};
};
}
|
[
"public",
"static",
"function",
"shutdown",
"(",
")",
"{",
"global",
"$",
"PPHP",
";",
"$",
"req",
"=",
"grab",
"(",
"'request'",
")",
";",
"if",
"(",
"!",
"$",
"req",
"[",
"'binary'",
"]",
")",
"{",
"$",
"body",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"try",
"{",
"array_merge_assoc",
"(",
"self",
"::",
"$",
"_stash",
",",
"array",
"(",
"'body'",
"=>",
"self",
"::",
"$",
"_safeBody",
",",
"'stdout'",
"=>",
"$",
"body",
",",
"'config'",
"=>",
"$",
"PPHP",
"[",
"'config'",
"]",
",",
"'session'",
"=>",
"$",
"_SESSION",
",",
"'req'",
"=>",
"grab",
"(",
"'request'",
")",
")",
")",
";",
"self",
"::",
"$",
"_template",
"->",
"displayBlock",
"(",
"'body'",
",",
"self",
"::",
"$",
"_stash",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
";",
"}",
";",
"}"
] |
Clean up content capture and display main template
@return null
|
[
"Clean",
"up",
"content",
"capture",
"and",
"display",
"main",
"template"
] |
e609daa714298a254bf5a945a1d6985c9d4d539d
|
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Templating.php#L293-L317
|
239,056
|
vphantom/pyritephp
|
src/Pyrite/Templating.php
|
Templating.gettext
|
function gettext($string)
{
global $PPHP;
$req = grab('request');
$default = $PPHP['config']['global']['default_lang'];
$current = $req['lang'];
$res = $string;
try {
if (self::$_gettext !== null) {
$res = self::$_gettext->gettext($string);
};
} catch (\Exception $e) {
echo $e->getMessage();
};
return $res;
}
|
php
|
function gettext($string)
{
global $PPHP;
$req = grab('request');
$default = $PPHP['config']['global']['default_lang'];
$current = $req['lang'];
$res = $string;
try {
if (self::$_gettext !== null) {
$res = self::$_gettext->gettext($string);
};
} catch (\Exception $e) {
echo $e->getMessage();
};
return $res;
}
|
[
"function",
"gettext",
"(",
"$",
"string",
")",
"{",
"global",
"$",
"PPHP",
";",
"$",
"req",
"=",
"grab",
"(",
"'request'",
")",
";",
"$",
"default",
"=",
"$",
"PPHP",
"[",
"'config'",
"]",
"[",
"'global'",
"]",
"[",
"'default_lang'",
"]",
";",
"$",
"current",
"=",
"$",
"req",
"[",
"'lang'",
"]",
";",
"$",
"res",
"=",
"$",
"string",
";",
"try",
"{",
"if",
"(",
"self",
"::",
"$",
"_gettext",
"!==",
"null",
")",
"{",
"$",
"res",
"=",
"self",
"::",
"$",
"_gettext",
"->",
"gettext",
"(",
"$",
"string",
")",
";",
"}",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
";",
"return",
"$",
"res",
";",
"}"
] |
Simple no-plurals translation lookup in config.ini
@param string $string String
@return string Translated string in current locale
|
[
"Simple",
"no",
"-",
"plurals",
"translation",
"lookup",
"in",
"config",
".",
"ini"
] |
e609daa714298a254bf5a945a1d6985c9d4d539d
|
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Templating.php#L338-L355
|
239,057
|
vphantom/pyritephp
|
src/Pyrite/Templating.php
|
Templating.title
|
public static function title($prepend, $sep = ' - ')
{
self::$_stash['title'] = $prepend
. (
isset(self::$_stash['title'])
? ($sep . self::$_stash['title'])
: ''
);
}
|
php
|
public static function title($prepend, $sep = ' - ')
{
self::$_stash['title'] = $prepend
. (
isset(self::$_stash['title'])
? ($sep . self::$_stash['title'])
: ''
);
}
|
[
"public",
"static",
"function",
"title",
"(",
"$",
"prepend",
",",
"$",
"sep",
"=",
"' - '",
")",
"{",
"self",
"::",
"$",
"_stash",
"[",
"'title'",
"]",
"=",
"$",
"prepend",
".",
"(",
"isset",
"(",
"self",
"::",
"$",
"_stash",
"[",
"'title'",
"]",
")",
"?",
"(",
"$",
"sep",
".",
"self",
"::",
"$",
"_stash",
"[",
"'title'",
"]",
")",
":",
"''",
")",
";",
"}"
] |
Prepend new section to page title
@param string $prepend New section of title text
@param string $sep Separator with current title
@return null
|
[
"Prepend",
"new",
"section",
"to",
"page",
"title"
] |
e609daa714298a254bf5a945a1d6985c9d4d539d
|
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Templating.php#L392-L400
|
239,058
|
vphantom/pyritephp
|
src/Pyrite/Templating.php
|
Templating.renderBlocks
|
public static function renderBlocks($name, $args = array())
{
global $PPHP, $_SESSION;
array_merge_assoc(
self::$_stash,
$args,
array(
'config' => $PPHP['config'],
'session' => $_SESSION,
'req' => grab('request')
)
);
try {
$template = self::$_twig->loadTemplate($name);
$blockNames = $template->getBlockNames(self::$_stash);
$results = array();
foreach ($blockNames as $blockName) {
$results[$blockName] = $template->renderBlock($blockName, self::$_stash);
};
} catch (\Exception $e) {
echo $e->getMessage();
};
return $results;
}
|
php
|
public static function renderBlocks($name, $args = array())
{
global $PPHP, $_SESSION;
array_merge_assoc(
self::$_stash,
$args,
array(
'config' => $PPHP['config'],
'session' => $_SESSION,
'req' => grab('request')
)
);
try {
$template = self::$_twig->loadTemplate($name);
$blockNames = $template->getBlockNames(self::$_stash);
$results = array();
foreach ($blockNames as $blockName) {
$results[$blockName] = $template->renderBlock($blockName, self::$_stash);
};
} catch (\Exception $e) {
echo $e->getMessage();
};
return $results;
}
|
[
"public",
"static",
"function",
"renderBlocks",
"(",
"$",
"name",
",",
"$",
"args",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"PPHP",
",",
"$",
"_SESSION",
";",
"array_merge_assoc",
"(",
"self",
"::",
"$",
"_stash",
",",
"$",
"args",
",",
"array",
"(",
"'config'",
"=>",
"$",
"PPHP",
"[",
"'config'",
"]",
",",
"'session'",
"=>",
"$",
"_SESSION",
",",
"'req'",
"=>",
"grab",
"(",
"'request'",
")",
")",
")",
";",
"try",
"{",
"$",
"template",
"=",
"self",
"::",
"$",
"_twig",
"->",
"loadTemplate",
"(",
"$",
"name",
")",
";",
"$",
"blockNames",
"=",
"$",
"template",
"->",
"getBlockNames",
"(",
"self",
"::",
"$",
"_stash",
")",
";",
"$",
"results",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"blockNames",
"as",
"$",
"blockName",
")",
"{",
"$",
"results",
"[",
"$",
"blockName",
"]",
"=",
"$",
"template",
"->",
"renderBlock",
"(",
"$",
"blockName",
",",
"self",
"::",
"$",
"_stash",
")",
";",
"}",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"echo",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"}",
";",
"return",
"$",
"results",
";",
"}"
] |
Render all blocks from a template
@param string $name File name from within templates/
@param array $args Associative array of variables to pass along
@return array Associative array of all blocks rendered from the template
|
[
"Render",
"all",
"blocks",
"from",
"a",
"template"
] |
e609daa714298a254bf5a945a1d6985c9d4d539d
|
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/Templating.php#L438-L462
|
239,059
|
vutran/wpmvc-core
|
src/Repository/CommentRepository.php
|
CommentRepository.convertAndReturn
|
protected function convertAndReturn($comments)
{
// Create the return value
$retval = false;
if ($comments && is_array($comments) && count($comments)) {
// Create the array
$retval = array();
foreach ($comments as $theComment) {
// Create a new instance
$commentInstance = new $this->className($theComment);
// Append the instance to the return value
array_push($retval, $commentInstance);
}
}
return $retval;
}
|
php
|
protected function convertAndReturn($comments)
{
// Create the return value
$retval = false;
if ($comments && is_array($comments) && count($comments)) {
// Create the array
$retval = array();
foreach ($comments as $theComment) {
// Create a new instance
$commentInstance = new $this->className($theComment);
// Append the instance to the return value
array_push($retval, $commentInstance);
}
}
return $retval;
}
|
[
"protected",
"function",
"convertAndReturn",
"(",
"$",
"comments",
")",
"{",
"// Create the return value",
"$",
"retval",
"=",
"false",
";",
"if",
"(",
"$",
"comments",
"&&",
"is_array",
"(",
"$",
"comments",
")",
"&&",
"count",
"(",
"$",
"comments",
")",
")",
"{",
"// Create the array",
"$",
"retval",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"comments",
"as",
"$",
"theComment",
")",
"{",
"// Create a new instance",
"$",
"commentInstance",
"=",
"new",
"$",
"this",
"->",
"className",
"(",
"$",
"theComment",
")",
";",
"// Append the instance to the return value",
"array_push",
"(",
"$",
"retval",
",",
"$",
"commentInstance",
")",
";",
"}",
"}",
"return",
"$",
"retval",
";",
"}"
] |
Converts an array of standard object instances to Comment model instances
@access protected
@param array $comments
@return array
|
[
"Converts",
"an",
"array",
"of",
"standard",
"object",
"instances",
"to",
"Comment",
"model",
"instances"
] |
4081be36116ae8e79abfd182d783d28d0fb42219
|
https://github.com/vutran/wpmvc-core/blob/4081be36116ae8e79abfd182d783d28d0fb42219/src/Repository/CommentRepository.php#L29-L44
|
239,060
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.concat
|
public static function concat()
{
$args = func_get_arg();
$string = '';
foreach ($args as $arg) {
$string .= $arg;
}
return $string;
}
|
php
|
public static function concat()
{
$args = func_get_arg();
$string = '';
foreach ($args as $arg) {
$string .= $arg;
}
return $string;
}
|
[
"public",
"static",
"function",
"concat",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_arg",
"(",
")",
";",
"$",
"string",
"=",
"''",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"arg",
")",
"{",
"$",
"string",
".=",
"$",
"arg",
";",
"}",
"return",
"$",
"string",
";",
"}"
] |
Concat strings as many as args.
@param param[]
@return string
|
[
"Concat",
"strings",
"as",
"many",
"as",
"args",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L95-L105
|
239,061
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.compare
|
public static function compare($str1, $str2, $ignoreCase = true)
{
if ($ignoreCase) {
if (strcasecmp($str1, $str2) == 0) {
return true;
}
} else {
if (strcmp($str1, $str2) == 0) {
return true;
}
}
return false;
}
|
php
|
public static function compare($str1, $str2, $ignoreCase = true)
{
if ($ignoreCase) {
if (strcasecmp($str1, $str2) == 0) {
return true;
}
} else {
if (strcmp($str1, $str2) == 0) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"compare",
"(",
"$",
"str1",
",",
"$",
"str2",
",",
"$",
"ignoreCase",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"ignoreCase",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"str1",
",",
"$",
"str2",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"strcmp",
"(",
"$",
"str1",
",",
"$",
"str2",
")",
"==",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Compare between two strings.
@param string $str1
@param string $str2
@param bool $ignoreCase
@return bool
|
[
"Compare",
"between",
"two",
"strings",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L116-L129
|
239,062
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.join
|
public static function join($strings, $separator, $start = 0, $count = -1)
{
$string = '';
$end = $count == -1 ? Collection::count($strings) : $count;
for ($i = $start; $i < $end; $i++) {
$string .= $strings[$i].$separator;
if ($i == ($end - 1)) {
$string .= $separator;
}
}
return $string;
}
|
php
|
public static function join($strings, $separator, $start = 0, $count = -1)
{
$string = '';
$end = $count == -1 ? Collection::count($strings) : $count;
for ($i = $start; $i < $end; $i++) {
$string .= $strings[$i].$separator;
if ($i == ($end - 1)) {
$string .= $separator;
}
}
return $string;
}
|
[
"public",
"static",
"function",
"join",
"(",
"$",
"strings",
",",
"$",
"separator",
",",
"$",
"start",
"=",
"0",
",",
"$",
"count",
"=",
"-",
"1",
")",
"{",
"$",
"string",
"=",
"''",
";",
"$",
"end",
"=",
"$",
"count",
"==",
"-",
"1",
"?",
"Collection",
"::",
"count",
"(",
"$",
"strings",
")",
":",
"$",
"count",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"start",
";",
"$",
"i",
"<",
"$",
"end",
";",
"$",
"i",
"++",
")",
"{",
"$",
"string",
".=",
"$",
"strings",
"[",
"$",
"i",
"]",
".",
"$",
"separator",
";",
"if",
"(",
"$",
"i",
"==",
"(",
"$",
"end",
"-",
"1",
")",
")",
"{",
"$",
"string",
".=",
"$",
"separator",
";",
"}",
"}",
"return",
"$",
"string",
";",
"}"
] |
Join array element to string.
@param array $strings
@param string $separator
@param int $start
@param int $count
@return simplexml_load_string
|
[
"Join",
"array",
"element",
"to",
"string",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L141-L156
|
239,063
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.at
|
public static function at($string, $index)
{
if (self::length($string) >= ($index + 1)) {
return $string[$index];
}
exception(StringOutIndexException::class);
}
|
php
|
public static function at($string, $index)
{
if (self::length($string) >= ($index + 1)) {
return $string[$index];
}
exception(StringOutIndexException::class);
}
|
[
"public",
"static",
"function",
"at",
"(",
"$",
"string",
",",
"$",
"index",
")",
"{",
"if",
"(",
"self",
"::",
"length",
"(",
"$",
"string",
")",
">=",
"(",
"$",
"index",
"+",
"1",
")",
")",
"{",
"return",
"$",
"string",
"[",
"$",
"index",
"]",
";",
"}",
"exception",
"(",
"StringOutIndexException",
"::",
"class",
")",
";",
"}"
] |
Get the char at an index from a given string.
@param string $string
@param int $index
@return string | bool
|
[
"Get",
"the",
"char",
"at",
"an",
"index",
"from",
"a",
"given",
"string",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L197-L204
|
239,064
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.insert
|
public static function insert($string, $substring, $index)
{
exception_if(!self::checkIndex($string, $index), StringOutIndexException::class);
$str = '';
for ($i = 0; $i < static::length($string); $i++) {
if ($i == $index) {
$str .= $substring;
}
$str .= $string[$i];
}
return $str;
}
|
php
|
public static function insert($string, $substring, $index)
{
exception_if(!self::checkIndex($string, $index), StringOutIndexException::class);
$str = '';
for ($i = 0; $i < static::length($string); $i++) {
if ($i == $index) {
$str .= $substring;
}
$str .= $string[$i];
}
return $str;
}
|
[
"public",
"static",
"function",
"insert",
"(",
"$",
"string",
",",
"$",
"substring",
",",
"$",
"index",
")",
"{",
"exception_if",
"(",
"!",
"self",
"::",
"checkIndex",
"(",
"$",
"string",
",",
"$",
"index",
")",
",",
"StringOutIndexException",
"::",
"class",
")",
";",
"$",
"str",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"static",
"::",
"length",
"(",
"$",
"string",
")",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"i",
"==",
"$",
"index",
")",
"{",
"$",
"str",
".=",
"$",
"substring",
";",
"}",
"$",
"str",
".=",
"$",
"string",
"[",
"$",
"i",
"]",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Insert a substring inside another string.
@param string $string
@param string $substring
@return string
|
[
"Insert",
"a",
"substring",
"inside",
"another",
"string",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L214-L229
|
239,065
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.trim
|
public static function trim($string, $side = self::TRIM_BOTH, $chars = null)
{
if ($side == self::TRIM_START) {
return ltrim($string, $chars);
} elseif ($side == self::TRIM_END) {
return rtrim($string, $chars);
} elseif ($side == self::TRIM_BOTH) {
return trim($string, $chars);
}
}
|
php
|
public static function trim($string, $side = self::TRIM_BOTH, $chars = null)
{
if ($side == self::TRIM_START) {
return ltrim($string, $chars);
} elseif ($side == self::TRIM_END) {
return rtrim($string, $chars);
} elseif ($side == self::TRIM_BOTH) {
return trim($string, $chars);
}
}
|
[
"public",
"static",
"function",
"trim",
"(",
"$",
"string",
",",
"$",
"side",
"=",
"self",
"::",
"TRIM_BOTH",
",",
"$",
"chars",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"side",
"==",
"self",
"::",
"TRIM_START",
")",
"{",
"return",
"ltrim",
"(",
"$",
"string",
",",
"$",
"chars",
")",
";",
"}",
"elseif",
"(",
"$",
"side",
"==",
"self",
"::",
"TRIM_END",
")",
"{",
"return",
"rtrim",
"(",
"$",
"string",
",",
"$",
"chars",
")",
";",
"}",
"elseif",
"(",
"$",
"side",
"==",
"self",
"::",
"TRIM_BOTH",
")",
"{",
"return",
"trim",
"(",
"$",
"string",
",",
"$",
"chars",
")",
";",
"}",
"}"
] |
Trim a string.
@param string $string
@param string $chars
@param string side
@return string
|
[
"Trim",
"a",
"string",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L271-L280
|
239,066
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.startsWith
|
public static function startsWith($string, $substrings)
{
if (is_array($substrings)) {
foreach ((array) $substrings as $substring) {
if ($substring != '' && mb_strpos($string, $substring) === 0) {
return true;
}
}
} elseif (is_string($substrings)) {
if ($substrings != '' && mb_strpos($string, $substrings) === 0) {
return true;
}
}
return false;
}
|
php
|
public static function startsWith($string, $substrings)
{
if (is_array($substrings)) {
foreach ((array) $substrings as $substring) {
if ($substring != '' && mb_strpos($string, $substring) === 0) {
return true;
}
}
} elseif (is_string($substrings)) {
if ($substrings != '' && mb_strpos($string, $substrings) === 0) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"startsWith",
"(",
"$",
"string",
",",
"$",
"substrings",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"substrings",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"substrings",
"as",
"$",
"substring",
")",
"{",
"if",
"(",
"$",
"substring",
"!=",
"''",
"&&",
"mb_strpos",
"(",
"$",
"string",
",",
"$",
"substring",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"substrings",
")",
")",
"{",
"if",
"(",
"$",
"substrings",
"!=",
"''",
"&&",
"mb_strpos",
"(",
"$",
"string",
",",
"$",
"substrings",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check if string starts with another string of collection of strings.
@param string $string
@param string|array $substring
@return bool
|
[
"Check",
"if",
"string",
"starts",
"with",
"another",
"string",
"of",
"collection",
"of",
"strings",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L338-L353
|
239,067
|
vinala/kernel
|
src/Strings/Strings.php
|
Strings.endsWith
|
public static function endsWith($string, $substrings)
{
if (is_array($substrings)) {
foreach ((array) $substrings as $substring) {
if ((string) $substring === static::subString($string, -static::length($substring))) {
return true;
}
}
} elseif (is_string($substrings)) {
if ((string) $substring === static::subString($string, -static::length($substring))) {
return true;
}
}
return false;
}
|
php
|
public static function endsWith($string, $substrings)
{
if (is_array($substrings)) {
foreach ((array) $substrings as $substring) {
if ((string) $substring === static::subString($string, -static::length($substring))) {
return true;
}
}
} elseif (is_string($substrings)) {
if ((string) $substring === static::subString($string, -static::length($substring))) {
return true;
}
}
return false;
}
|
[
"public",
"static",
"function",
"endsWith",
"(",
"$",
"string",
",",
"$",
"substrings",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"substrings",
")",
")",
"{",
"foreach",
"(",
"(",
"array",
")",
"$",
"substrings",
"as",
"$",
"substring",
")",
"{",
"if",
"(",
"(",
"string",
")",
"$",
"substring",
"===",
"static",
"::",
"subString",
"(",
"$",
"string",
",",
"-",
"static",
"::",
"length",
"(",
"$",
"substring",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"substrings",
")",
")",
"{",
"if",
"(",
"(",
"string",
")",
"$",
"substring",
"===",
"static",
"::",
"subString",
"(",
"$",
"string",
",",
"-",
"static",
"::",
"length",
"(",
"$",
"substring",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Check ifstring ends with another string of collection of strings.
@param string $string
@param string|array $substring
@return bool
|
[
"Check",
"ifstring",
"ends",
"with",
"another",
"string",
"of",
"collection",
"of",
"strings",
"."
] |
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
|
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Strings/Strings.php#L363-L378
|
239,068
|
uthando-cms/uthando-navigation
|
src/UthandoNavigation/Service/SiteMapService.php
|
SiteMapService.getSiteMap
|
public function getSiteMap()
{
$sitemap = $this->getCacheItem('site-map');
if (null === $sitemap) {
/* @var $menuService MenuService */
$menuService = $this->getService(MenuService::class);
$navigation = $menuService->getPages();
$argv = $this->prepareEventArguments(compact('navigation'));
$this->getEventManager()->trigger('uthando.site-map', $this, $argv);
$sitemap = $this->getService('ViewHelperManager')
->get(Navigation::class)
->setRole('guest')
->sitemap($navigation)
->render();
$this->setCacheItem('site-map', $sitemap);
}
return $sitemap;
}
|
php
|
public function getSiteMap()
{
$sitemap = $this->getCacheItem('site-map');
if (null === $sitemap) {
/* @var $menuService MenuService */
$menuService = $this->getService(MenuService::class);
$navigation = $menuService->getPages();
$argv = $this->prepareEventArguments(compact('navigation'));
$this->getEventManager()->trigger('uthando.site-map', $this, $argv);
$sitemap = $this->getService('ViewHelperManager')
->get(Navigation::class)
->setRole('guest')
->sitemap($navigation)
->render();
$this->setCacheItem('site-map', $sitemap);
}
return $sitemap;
}
|
[
"public",
"function",
"getSiteMap",
"(",
")",
"{",
"$",
"sitemap",
"=",
"$",
"this",
"->",
"getCacheItem",
"(",
"'site-map'",
")",
";",
"if",
"(",
"null",
"===",
"$",
"sitemap",
")",
"{",
"/* @var $menuService MenuService */",
"$",
"menuService",
"=",
"$",
"this",
"->",
"getService",
"(",
"MenuService",
"::",
"class",
")",
";",
"$",
"navigation",
"=",
"$",
"menuService",
"->",
"getPages",
"(",
")",
";",
"$",
"argv",
"=",
"$",
"this",
"->",
"prepareEventArguments",
"(",
"compact",
"(",
"'navigation'",
")",
")",
";",
"$",
"this",
"->",
"getEventManager",
"(",
")",
"->",
"trigger",
"(",
"'uthando.site-map'",
",",
"$",
"this",
",",
"$",
"argv",
")",
";",
"$",
"sitemap",
"=",
"$",
"this",
"->",
"getService",
"(",
"'ViewHelperManager'",
")",
"->",
"get",
"(",
"Navigation",
"::",
"class",
")",
"->",
"setRole",
"(",
"'guest'",
")",
"->",
"sitemap",
"(",
"$",
"navigation",
")",
"->",
"render",
"(",
")",
";",
"$",
"this",
"->",
"setCacheItem",
"(",
"'site-map'",
",",
"$",
"sitemap",
")",
";",
"}",
"return",
"$",
"sitemap",
";",
"}"
] |
Returns a formatted xml sitemap string
@return string
|
[
"Returns",
"a",
"formatted",
"xml",
"sitemap",
"string"
] |
3aeb687697c3cc94710113246f517745964ac281
|
https://github.com/uthando-cms/uthando-navigation/blob/3aeb687697c3cc94710113246f517745964ac281/src/UthandoNavigation/Service/SiteMapService.php#L33-L56
|
239,069
|
calgamo/config
|
src/ConfigUtil.php
|
ConfigUtil.includeConfigFile
|
private static function includeConfigFile(array &$config, $config_file, File $base_dir, ConfigReader $reader)
{
// try relative path
$file = new File($config_file, $base_dir);
if ( $file->exists() ){
$included = self::loadConfigFileByFormat( $file, $reader );
$config = array_merge_recursive($config, $included);
return;
}
// try full path
$file = new File($config_file);
if ( $file->exists() ){
$included = self::loadConfigFileByFormat( $file, $reader );
$config = array_merge_recursive($config, $included);
return;
}
throw new IncludeConfigFileNotFoundException($config_file);
}
|
php
|
private static function includeConfigFile(array &$config, $config_file, File $base_dir, ConfigReader $reader)
{
// try relative path
$file = new File($config_file, $base_dir);
if ( $file->exists() ){
$included = self::loadConfigFileByFormat( $file, $reader );
$config = array_merge_recursive($config, $included);
return;
}
// try full path
$file = new File($config_file);
if ( $file->exists() ){
$included = self::loadConfigFileByFormat( $file, $reader );
$config = array_merge_recursive($config, $included);
return;
}
throw new IncludeConfigFileNotFoundException($config_file);
}
|
[
"private",
"static",
"function",
"includeConfigFile",
"(",
"array",
"&",
"$",
"config",
",",
"$",
"config_file",
",",
"File",
"$",
"base_dir",
",",
"ConfigReader",
"$",
"reader",
")",
"{",
"// try relative path",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"config_file",
",",
"$",
"base_dir",
")",
";",
"if",
"(",
"$",
"file",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"included",
"=",
"self",
"::",
"loadConfigFileByFormat",
"(",
"$",
"file",
",",
"$",
"reader",
")",
";",
"$",
"config",
"=",
"array_merge_recursive",
"(",
"$",
"config",
",",
"$",
"included",
")",
";",
"return",
";",
"}",
"// try full path",
"$",
"file",
"=",
"new",
"File",
"(",
"$",
"config_file",
")",
";",
"if",
"(",
"$",
"file",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"included",
"=",
"self",
"::",
"loadConfigFileByFormat",
"(",
"$",
"file",
",",
"$",
"reader",
")",
";",
"$",
"config",
"=",
"array_merge_recursive",
"(",
"$",
"config",
",",
"$",
"included",
")",
";",
"return",
";",
"}",
"throw",
"new",
"IncludeConfigFileNotFoundException",
"(",
"$",
"config_file",
")",
";",
"}"
] |
Include other config file
@param array $config
@param string $config_file
@param File $base_dir
@param ConfigReader $reader
@throws IncludeConfigFileNotFoundException
@throws UnsupportedConfigFileFormatException
|
[
"Include",
"other",
"config",
"file"
] |
315c87f0ab1283a805a24db3a6220eda281d49e8
|
https://github.com/calgamo/config/blob/315c87f0ab1283a805a24db3a6220eda281d49e8/src/ConfigUtil.php#L62-L83
|
239,070
|
shakahl/hups-util-htmlcompressor
|
src/Hups/Util/HTMLCompressor.php
|
HTMLCompressor.replaceAbsoluteUrls
|
public function replaceAbsoluteUrls($currentHost = true)
{
$hosts = array();
if ($currentHost === true)
{
$hosts[] = $_SERVER["HTTP_HOST"];
}
elseif (is_array($currentHost))
{
foreach ($currentHost as $h)
{
$hosts[] = $h;
}
}
foreach ($hosts as $h)
{
$this->filteredHtml = preg_replace("/=([\"'])((http[s]?:\/\/)?".$h.")/usi", '=$1', $this->filteredHtml);
}
return $this;
}
|
php
|
public function replaceAbsoluteUrls($currentHost = true)
{
$hosts = array();
if ($currentHost === true)
{
$hosts[] = $_SERVER["HTTP_HOST"];
}
elseif (is_array($currentHost))
{
foreach ($currentHost as $h)
{
$hosts[] = $h;
}
}
foreach ($hosts as $h)
{
$this->filteredHtml = preg_replace("/=([\"'])((http[s]?:\/\/)?".$h.")/usi", '=$1', $this->filteredHtml);
}
return $this;
}
|
[
"public",
"function",
"replaceAbsoluteUrls",
"(",
"$",
"currentHost",
"=",
"true",
")",
"{",
"$",
"hosts",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"currentHost",
"===",
"true",
")",
"{",
"$",
"hosts",
"[",
"]",
"=",
"$",
"_SERVER",
"[",
"\"HTTP_HOST\"",
"]",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"currentHost",
")",
")",
"{",
"foreach",
"(",
"$",
"currentHost",
"as",
"$",
"h",
")",
"{",
"$",
"hosts",
"[",
"]",
"=",
"$",
"h",
";",
"}",
"}",
"foreach",
"(",
"$",
"hosts",
"as",
"$",
"h",
")",
"{",
"$",
"this",
"->",
"filteredHtml",
"=",
"preg_replace",
"(",
"\"/=([\\\"'])((http[s]?:\\/\\/)?\"",
".",
"$",
"h",
".",
"\")/usi\"",
",",
"'=$1'",
",",
"$",
"this",
"->",
"filteredHtml",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Replace absolute urls with relative path
@return Hups\Util\HTMLCompressor
|
[
"Replace",
"absolute",
"urls",
"with",
"relative",
"path"
] |
2b659d2f35aa54c89f2294557dbbd718235183ab
|
https://github.com/shakahl/hups-util-htmlcompressor/blob/2b659d2f35aa54c89f2294557dbbd718235183ab/src/Hups/Util/HTMLCompressor.php#L93-L115
|
239,071
|
fkooman/php-lib-oauth
|
src/fkooman/OAuth/Scope.php
|
Scope.hasScope
|
public function hasScope(Scope $scope)
{
foreach ($scope->toArray() as $scopeToken) {
if (!$this->hasScopeToken($scopeToken)) {
return false;
}
}
return true;
}
|
php
|
public function hasScope(Scope $scope)
{
foreach ($scope->toArray() as $scopeToken) {
if (!$this->hasScopeToken($scopeToken)) {
return false;
}
}
return true;
}
|
[
"public",
"function",
"hasScope",
"(",
"Scope",
"$",
"scope",
")",
"{",
"foreach",
"(",
"$",
"scope",
"->",
"toArray",
"(",
")",
"as",
"$",
"scopeToken",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasScopeToken",
"(",
"$",
"scopeToken",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] |
Check if all scope tokens from the provided scope are in this object's
scope tokens.
@param Scope $scope the scope object to check
@return bool
|
[
"Check",
"if",
"all",
"scope",
"tokens",
"from",
"the",
"provided",
"scope",
"are",
"in",
"this",
"object",
"s",
"scope",
"tokens",
"."
] |
537c0f1b003fe562175ec85fd3ae6cc0ca0ed4ca
|
https://github.com/fkooman/php-lib-oauth/blob/537c0f1b003fe562175ec85fd3ae6cc0ca0ed4ca/src/fkooman/OAuth/Scope.php#L74-L83
|
239,072
|
phlexible/phlexible
|
src/Phlexible/Bundle/GuiBundle/Controller/PollController.php
|
PollController.indexAction
|
public function indexAction(Request $request)
{
$messages = [];
$data = [];
foreach ($this->get('phlexible_dashboard.portlets') as $portlet) {
$data[$portlet->getId()] = $portlet->getData();
}
$message = new \stdClass();
$message->type = 'start';
$message->event = 'update';
$message->uid = $this->getUser()->getId();
$message->msg = null;
$message->data = $data;
$message->objectID = null;
$message->ts = date('Y-m-d H:i:s');
$messages[] = (array) $message;
$request->getSession()->set('lastPoll', date('Y-m-d H:i:s'));
/*
$lastMessages = MWF_Core_Messages_Message_Query::getByFilter(
array(
array(
array(
'key' => MWF_Core_Messages_Filter::CRITERIUM_START_DATE,
'value' => $pollSession->lastPoll
)
)
),
$this->getSecurityContext()->getUser()->getId(),
5
);
foreach ($lastMessages as $lastMessage) {
try {
$user = MWF_Core_Users_User_Peer::getByUserID($lastMessage['create_uid']);
} catch (\Exception $e) {
$user = MWF_Core_Users_User_Peer::getSystemUser();
}
$message = new MWF_Core_Messages_Frontend_Message();
$message->type = 'message';
$message->event = 'message';
$message->uid = $lastMessage['create_uid'];
$message->msg = $lastMessage['subject'] . ' [' . $user->getUsername() . ']';
$message->data = array();
$message->objectID = null;
$message->ts = $lastMessage['created_at'];
if ($lastMessage['created_at'] > $pollSession->lastPoll) {
$pollSession->lastPoll = $lastMessage['created_at'];
}
$messages[] = $message;
}
*/
return new JsonResponse($messages);
}
|
php
|
public function indexAction(Request $request)
{
$messages = [];
$data = [];
foreach ($this->get('phlexible_dashboard.portlets') as $portlet) {
$data[$portlet->getId()] = $portlet->getData();
}
$message = new \stdClass();
$message->type = 'start';
$message->event = 'update';
$message->uid = $this->getUser()->getId();
$message->msg = null;
$message->data = $data;
$message->objectID = null;
$message->ts = date('Y-m-d H:i:s');
$messages[] = (array) $message;
$request->getSession()->set('lastPoll', date('Y-m-d H:i:s'));
/*
$lastMessages = MWF_Core_Messages_Message_Query::getByFilter(
array(
array(
array(
'key' => MWF_Core_Messages_Filter::CRITERIUM_START_DATE,
'value' => $pollSession->lastPoll
)
)
),
$this->getSecurityContext()->getUser()->getId(),
5
);
foreach ($lastMessages as $lastMessage) {
try {
$user = MWF_Core_Users_User_Peer::getByUserID($lastMessage['create_uid']);
} catch (\Exception $e) {
$user = MWF_Core_Users_User_Peer::getSystemUser();
}
$message = new MWF_Core_Messages_Frontend_Message();
$message->type = 'message';
$message->event = 'message';
$message->uid = $lastMessage['create_uid'];
$message->msg = $lastMessage['subject'] . ' [' . $user->getUsername() . ']';
$message->data = array();
$message->objectID = null;
$message->ts = $lastMessage['created_at'];
if ($lastMessage['created_at'] > $pollSession->lastPoll) {
$pollSession->lastPoll = $lastMessage['created_at'];
}
$messages[] = $message;
}
*/
return new JsonResponse($messages);
}
|
[
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"messages",
"=",
"[",
"]",
";",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"get",
"(",
"'phlexible_dashboard.portlets'",
")",
"as",
"$",
"portlet",
")",
"{",
"$",
"data",
"[",
"$",
"portlet",
"->",
"getId",
"(",
")",
"]",
"=",
"$",
"portlet",
"->",
"getData",
"(",
")",
";",
"}",
"$",
"message",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"$",
"message",
"->",
"type",
"=",
"'start'",
";",
"$",
"message",
"->",
"event",
"=",
"'update'",
";",
"$",
"message",
"->",
"uid",
"=",
"$",
"this",
"->",
"getUser",
"(",
")",
"->",
"getId",
"(",
")",
";",
"$",
"message",
"->",
"msg",
"=",
"null",
";",
"$",
"message",
"->",
"data",
"=",
"$",
"data",
";",
"$",
"message",
"->",
"objectID",
"=",
"null",
";",
"$",
"message",
"->",
"ts",
"=",
"date",
"(",
"'Y-m-d H:i:s'",
")",
";",
"$",
"messages",
"[",
"]",
"=",
"(",
"array",
")",
"$",
"message",
";",
"$",
"request",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"'lastPoll'",
",",
"date",
"(",
"'Y-m-d H:i:s'",
")",
")",
";",
"/*\n $lastMessages = MWF_Core_Messages_Message_Query::getByFilter(\n array(\n array(\n array(\n 'key' => MWF_Core_Messages_Filter::CRITERIUM_START_DATE,\n 'value' => $pollSession->lastPoll\n )\n )\n ),\n $this->getSecurityContext()->getUser()->getId(),\n 5\n );\n\n foreach ($lastMessages as $lastMessage) {\n try {\n $user = MWF_Core_Users_User_Peer::getByUserID($lastMessage['create_uid']);\n } catch (\\Exception $e) {\n $user = MWF_Core_Users_User_Peer::getSystemUser();\n }\n\n $message = new MWF_Core_Messages_Frontend_Message();\n $message->type = 'message';\n $message->event = 'message';\n $message->uid = $lastMessage['create_uid'];\n $message->msg = $lastMessage['subject'] . ' [' . $user->getUsername() . ']';\n $message->data = array();\n $message->objectID = null;\n $message->ts = $lastMessage['created_at'];\n\n if ($lastMessage['created_at'] > $pollSession->lastPoll) {\n $pollSession->lastPoll = $lastMessage['created_at'];\n }\n\n $messages[] = $message;\n }\n */",
"return",
"new",
"JsonResponse",
"(",
"$",
"messages",
")",
";",
"}"
] |
Poll Action.
@param Request $request
@return JsonResponse
@Route("", name="gui_poll")
|
[
"Poll",
"Action",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/PollController.php#L35-L96
|
239,073
|
sebardo/ecommerce
|
EcommerceBundle/Controller/SubcategoryController.php
|
SubcategoryController.indexAction
|
public function indexAction($categoryId)
{
$em = $this->getDoctrine()->getManager();
/** @var Category $entity */
$entity = $em->getRepository('EcommerceBundle:Category')->find($categoryId);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Category entity.');
}
return array(
'category' => $entity,
);
}
|
php
|
public function indexAction($categoryId)
{
$em = $this->getDoctrine()->getManager();
/** @var Category $entity */
$entity = $em->getRepository('EcommerceBundle:Category')->find($categoryId);
if (!$entity) {
throw $this->createNotFoundException('Unable to find Category entity.');
}
return array(
'category' => $entity,
);
}
|
[
"public",
"function",
"indexAction",
"(",
"$",
"categoryId",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"/** @var Category $entity */",
"$",
"entity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'EcommerceBundle:Category'",
")",
"->",
"find",
"(",
"$",
"categoryId",
")",
";",
"if",
"(",
"!",
"$",
"entity",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Category entity.'",
")",
";",
"}",
"return",
"array",
"(",
"'category'",
"=>",
"$",
"entity",
",",
")",
";",
"}"
] |
Lists all subcategories from a Category entity.
@param int $categoryId The category id
@throws NotFoundHttpException
@return array
@Route("/")
@Method("GET")
@Template("EcommerceBundle:Subcategory:index.html.twig")
|
[
"Lists",
"all",
"subcategories",
"from",
"a",
"Category",
"entity",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/SubcategoryController.php#L37-L51
|
239,074
|
sebardo/ecommerce
|
EcommerceBundle/Controller/SubcategoryController.php
|
SubcategoryController.createAction
|
public function createAction(Request $request, $categoryId)
{
$em = $this->getDoctrine()->getManager();
/** @var Category $category */
$category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);
if (!$category) {
throw $this->createNotFoundException('Unable to find Category entity.');
}
$entity = new Category();
$form = $this->createForm(new SubcategoryType(), $entity);
$entity->setParentCategory($category);
$form->bind($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->get('session')->getFlashBag()->add('success', 'category.created');
return $this->redirect($this->generateUrl('ecommerce_category_show', array('id' => $entity->getId())));
}
return array(
'entity' => $entity,
'category' => $category,
'form' => $form->createView(),
);
}
|
php
|
public function createAction(Request $request, $categoryId)
{
$em = $this->getDoctrine()->getManager();
/** @var Category $category */
$category = $em->getRepository('EcommerceBundle:Category')->find($categoryId);
if (!$category) {
throw $this->createNotFoundException('Unable to find Category entity.');
}
$entity = new Category();
$form = $this->createForm(new SubcategoryType(), $entity);
$entity->setParentCategory($category);
$form->bind($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();
$this->get('session')->getFlashBag()->add('success', 'category.created');
return $this->redirect($this->generateUrl('ecommerce_category_show', array('id' => $entity->getId())));
}
return array(
'entity' => $entity,
'category' => $category,
'form' => $form->createView(),
);
}
|
[
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
",",
"$",
"categoryId",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"/** @var Category $category */",
"$",
"category",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'EcommerceBundle:Category'",
")",
"->",
"find",
"(",
"$",
"categoryId",
")",
";",
"if",
"(",
"!",
"$",
"category",
")",
"{",
"throw",
"$",
"this",
"->",
"createNotFoundException",
"(",
"'Unable to find Category entity.'",
")",
";",
"}",
"$",
"entity",
"=",
"new",
"Category",
"(",
")",
";",
"$",
"form",
"=",
"$",
"this",
"->",
"createForm",
"(",
"new",
"SubcategoryType",
"(",
")",
",",
"$",
"entity",
")",
";",
"$",
"entity",
"->",
"setParentCategory",
"(",
"$",
"category",
")",
";",
"$",
"form",
"->",
"bind",
"(",
"$",
"request",
")",
";",
"if",
"(",
"$",
"form",
"->",
"isValid",
"(",
")",
")",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"getDoctrine",
"(",
")",
"->",
"getManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"$",
"this",
"->",
"get",
"(",
"'session'",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"'success'",
",",
"'category.created'",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"generateUrl",
"(",
"'ecommerce_category_show'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"entity",
"->",
"getId",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"array",
"(",
"'entity'",
"=>",
"$",
"entity",
",",
"'category'",
"=>",
"$",
"category",
",",
"'form'",
"=>",
"$",
"form",
"->",
"createView",
"(",
")",
",",
")",
";",
"}"
] |
Creates a new Category entity.
@param Request $request The request
@param int $categoryId The category id
@throws NotFoundHttpException
@return array|RedirectResponse
@Route("/")
@Method("POST")
@Template("EcommerceBundle:Category:new.html.twig")
|
[
"Creates",
"a",
"new",
"Category",
"entity",
"."
] |
3e17545e69993f10a1df17f9887810c7378fc7f9
|
https://github.com/sebardo/ecommerce/blob/3e17545e69993f10a1df17f9887810c7378fc7f9/EcommerceBundle/Controller/SubcategoryController.php#L90-L122
|
239,075
|
lyrixx/lifestream
|
Lifestream/LifestreamFactory.php
|
LifestreamFactory.createLifestream
|
public function createLifestream($serviceName, array $arguments = array(), array $filters = array(), array $formatters = array())
{
if (!array_key_exists($serviceName, $this->services)) {
throw new \InvalidArgumentException(sprintf(
'Service "%s" not Found. Services supported: "%s"',
$serviceName,
implode('", "', $this->getSupportedServices())
));
}
$reflect = new \ReflectionClass($this->services[$serviceName]);
$service = $reflect->newInstanceArgs($arguments);
$service->setClient($this->client);
$lifestream = new Lifestream($service, $filters, $formatters);
return $lifestream;
}
|
php
|
public function createLifestream($serviceName, array $arguments = array(), array $filters = array(), array $formatters = array())
{
if (!array_key_exists($serviceName, $this->services)) {
throw new \InvalidArgumentException(sprintf(
'Service "%s" not Found. Services supported: "%s"',
$serviceName,
implode('", "', $this->getSupportedServices())
));
}
$reflect = new \ReflectionClass($this->services[$serviceName]);
$service = $reflect->newInstanceArgs($arguments);
$service->setClient($this->client);
$lifestream = new Lifestream($service, $filters, $formatters);
return $lifestream;
}
|
[
"public",
"function",
"createLifestream",
"(",
"$",
"serviceName",
",",
"array",
"$",
"arguments",
"=",
"array",
"(",
")",
",",
"array",
"$",
"filters",
"=",
"array",
"(",
")",
",",
"array",
"$",
"formatters",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"serviceName",
",",
"$",
"this",
"->",
"services",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Service \"%s\" not Found. Services supported: \"%s\"'",
",",
"$",
"serviceName",
",",
"implode",
"(",
"'\", \"'",
",",
"$",
"this",
"->",
"getSupportedServices",
"(",
")",
")",
")",
")",
";",
"}",
"$",
"reflect",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
"->",
"services",
"[",
"$",
"serviceName",
"]",
")",
";",
"$",
"service",
"=",
"$",
"reflect",
"->",
"newInstanceArgs",
"(",
"$",
"arguments",
")",
";",
"$",
"service",
"->",
"setClient",
"(",
"$",
"this",
"->",
"client",
")",
";",
"$",
"lifestream",
"=",
"new",
"Lifestream",
"(",
"$",
"service",
",",
"$",
"filters",
",",
"$",
"formatters",
")",
";",
"return",
"$",
"lifestream",
";",
"}"
] |
Create a Lifestream with a nammed service
@param string $serviceName A service among LifestreamFactory::getSupportedServices
@param string[] $arguments Arguments to give to service constructor
@param FormatterInterface[] $filters A collection of FormatterInterface
@param FormatterInterface[] $formatters A collection of FormatterInterface
@return Lifestream A lifestream
|
[
"Create",
"a",
"Lifestream",
"with",
"a",
"nammed",
"service"
] |
2cf959b08b0ae0a2ff4938a227018a00f00dfc0f
|
https://github.com/lyrixx/lifestream/blob/2cf959b08b0ae0a2ff4938a227018a00f00dfc0f/Lifestream/LifestreamFactory.php#L50-L67
|
239,076
|
MacFJA/Symfony-Console-Filechooser
|
lib/FileFilter.php
|
FileFilter.finderWrapperInject
|
protected function finderWrapperInject($finder)
{
foreach ($this->wrappedMethodHistory as $row) {
call_user_func_array(array($finder, $row['method']), $row['args']);
}
}
|
php
|
protected function finderWrapperInject($finder)
{
foreach ($this->wrappedMethodHistory as $row) {
call_user_func_array(array($finder, $row['method']), $row['args']);
}
}
|
[
"protected",
"function",
"finderWrapperInject",
"(",
"$",
"finder",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"wrappedMethodHistory",
"as",
"$",
"row",
")",
"{",
"call_user_func_array",
"(",
"array",
"(",
"$",
"finder",
",",
"$",
"row",
"[",
"'method'",
"]",
")",
",",
"$",
"row",
"[",
"'args'",
"]",
")",
";",
"}",
"}"
] |
Configure a Symfony Finder
@param Finder $finder
|
[
"Configure",
"a",
"Symfony",
"Finder"
] |
f27248a6993718fcc469d442e305e1d83f5e1eb5
|
https://github.com/MacFJA/Symfony-Console-Filechooser/blob/f27248a6993718fcc469d442e305e1d83f5e1eb5/lib/FileFilter.php#L210-L215
|
239,077
|
joegreen88/zf1-component-http
|
src/Zend/Http/Client/Adapter/Socket.php
|
Zend_Http_Client_Adapter_Socket.setConfig
|
public function setConfig($config = array())
{
if ($config instanceof Zend_Config) {
$config = $config->toArray();
} elseif (! is_array($config)) {
throw new Zend_Http_Client_Adapter_Exception(
'Array or Zend_Config object expected, got ' . gettype($config)
);
}
foreach ($config as $k => $v) {
$this->config[strtolower($k)] = $v;
}
}
|
php
|
public function setConfig($config = array())
{
if ($config instanceof Zend_Config) {
$config = $config->toArray();
} elseif (! is_array($config)) {
throw new Zend_Http_Client_Adapter_Exception(
'Array or Zend_Config object expected, got ' . gettype($config)
);
}
foreach ($config as $k => $v) {
$this->config[strtolower($k)] = $v;
}
}
|
[
"public",
"function",
"setConfig",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"config",
"instanceof",
"Zend_Config",
")",
"{",
"$",
"config",
"=",
"$",
"config",
"->",
"toArray",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"'Array or Zend_Config object expected, got '",
".",
"gettype",
"(",
"$",
"config",
")",
")",
";",
"}",
"foreach",
"(",
"$",
"config",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"this",
"->",
"config",
"[",
"strtolower",
"(",
"$",
"k",
")",
"]",
"=",
"$",
"v",
";",
"}",
"}"
] |
Set the configuration array for the adapter
@param Zend_Config | array $config
|
[
"Set",
"the",
"configuration",
"array",
"for",
"the",
"adapter"
] |
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
|
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/Client/Adapter/Socket.php#L109-L124
|
239,078
|
joegreen88/zf1-component-http
|
src/Zend/Http/Client/Adapter/Socket.php
|
Zend_Http_Client_Adapter_Socket.setStreamContext
|
public function setStreamContext($context)
{
if (is_resource($context) && get_resource_type($context) == 'stream-context') {
$this->_context = $context;
} elseif (is_array($context)) {
$this->_context = stream_context_create($context);
} else {
// Invalid parameter
throw new Zend_Http_Client_Adapter_Exception(
"Expecting either a stream context resource or array, got " . gettype($context)
);
}
return $this;
}
|
php
|
public function setStreamContext($context)
{
if (is_resource($context) && get_resource_type($context) == 'stream-context') {
$this->_context = $context;
} elseif (is_array($context)) {
$this->_context = stream_context_create($context);
} else {
// Invalid parameter
throw new Zend_Http_Client_Adapter_Exception(
"Expecting either a stream context resource or array, got " . gettype($context)
);
}
return $this;
}
|
[
"public",
"function",
"setStreamContext",
"(",
"$",
"context",
")",
"{",
"if",
"(",
"is_resource",
"(",
"$",
"context",
")",
"&&",
"get_resource_type",
"(",
"$",
"context",
")",
"==",
"'stream-context'",
")",
"{",
"$",
"this",
"->",
"_context",
"=",
"$",
"context",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"context",
")",
")",
"{",
"$",
"this",
"->",
"_context",
"=",
"stream_context_create",
"(",
"$",
"context",
")",
";",
"}",
"else",
"{",
"// Invalid parameter",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Expecting either a stream context resource or array, got \"",
".",
"gettype",
"(",
"$",
"context",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the stream context for the TCP connection to the server
Can accept either a pre-existing stream context resource, or an array
of stream options, similar to the options array passed to the
stream_context_create() PHP function. In such case a new stream context
will be created using the passed options.
@since Zend Framework 1.9
@param mixed $context Stream context or array of context options
@return Zend_Http_Client_Adapter_Socket
|
[
"Set",
"the",
"stream",
"context",
"for",
"the",
"TCP",
"connection",
"to",
"the",
"server"
] |
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
|
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/Client/Adapter/Socket.php#L149-L166
|
239,079
|
joegreen88/zf1-component-http
|
src/Zend/Http/Client/Adapter/Socket.php
|
Zend_Http_Client_Adapter_Socket._checkSocketReadTimeout
|
protected function _checkSocketReadTimeout()
{
if ($this->socket) {
$info = stream_get_meta_data($this->socket);
$timedout = $info['timed_out'];
if ($timedout) {
$this->close();
throw new Zend_Http_Client_Adapter_Exception(
"Read timed out after {$this->config['timeout']} seconds",
Zend_Http_Client_Adapter_Exception::READ_TIMEOUT
);
}
}
}
|
php
|
protected function _checkSocketReadTimeout()
{
if ($this->socket) {
$info = stream_get_meta_data($this->socket);
$timedout = $info['timed_out'];
if ($timedout) {
$this->close();
throw new Zend_Http_Client_Adapter_Exception(
"Read timed out after {$this->config['timeout']} seconds",
Zend_Http_Client_Adapter_Exception::READ_TIMEOUT
);
}
}
}
|
[
"protected",
"function",
"_checkSocketReadTimeout",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"socket",
")",
"{",
"$",
"info",
"=",
"stream_get_meta_data",
"(",
"$",
"this",
"->",
"socket",
")",
";",
"$",
"timedout",
"=",
"$",
"info",
"[",
"'timed_out'",
"]",
";",
"if",
"(",
"$",
"timedout",
")",
"{",
"$",
"this",
"->",
"close",
"(",
")",
";",
"throw",
"new",
"Zend_Http_Client_Adapter_Exception",
"(",
"\"Read timed out after {$this->config['timeout']} seconds\"",
",",
"Zend_Http_Client_Adapter_Exception",
"::",
"READ_TIMEOUT",
")",
";",
"}",
"}",
"}"
] |
Check if the socket has timed out - if so close connection and throw
an exception
@throws Zend_Http_Client_Adapter_Exception with READ_TIMEOUT code
|
[
"Check",
"if",
"the",
"socket",
"has",
"timed",
"out",
"-",
"if",
"so",
"close",
"connection",
"and",
"throw",
"an",
"exception"
] |
39e834e8f0393cf4223d099a0acaab5fa05e9ad4
|
https://github.com/joegreen88/zf1-component-http/blob/39e834e8f0393cf4223d099a0acaab5fa05e9ad4/src/Zend/Http/Client/Adapter/Socket.php#L502-L516
|
239,080
|
tekkla/core-html
|
Core/Html/Bootstrap/Buttongroups/ButtonGroup.php
|
ButtonGroup.&
|
public function &createButton($button_class='Bootstrap\Button\Button')
{
$button = $this->factory->create($button_class);
$this->addButton($button);
return $button;
}
|
php
|
public function &createButton($button_class='Bootstrap\Button\Button')
{
$button = $this->factory->create($button_class);
$this->addButton($button);
return $button;
}
|
[
"public",
"function",
"&",
"createButton",
"(",
"$",
"button_class",
"=",
"'Bootstrap\\Button\\Button'",
")",
"{",
"$",
"button",
"=",
"$",
"this",
"->",
"factory",
"->",
"create",
"(",
"$",
"button_class",
")",
";",
"$",
"this",
"->",
"addButton",
"(",
"$",
"button",
")",
";",
"return",
"$",
"button",
";",
"}"
] |
Creates a Bootstrap button element and adds it to the buttonlist
@return Button
|
[
"Creates",
"a",
"Bootstrap",
"button",
"element",
"and",
"adds",
"it",
"to",
"the",
"buttonlist"
] |
00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3
|
https://github.com/tekkla/core-html/blob/00bf3fa8e060e8aadf1c341f6e3c548c7a76cfd3/Core/Html/Bootstrap/Buttongroups/ButtonGroup.php#L37-L44
|
239,081
|
zoopcommerce/gateway-module
|
src/Zoop/GatewayModule/Controller/AuthenticatedUserController.php
|
AuthenticatedUserController.create
|
public function create($data)
{
$authService = $this->options->getAuthenticationService();
if ($authService->hasIdentity()) {
$authService->logout();
}
$result = $authService->login(
$data[$this->options->getDataUsernameKey()],
$data[$this->options->getDataPasswordKey()],
isset($data[$this->options->getDataRememberMeKey()]) ? $data[$this->options->getDataRememberMeKey()]: false
);
if (!$result->isValid()) {
throw new Exception\LoginFailedException(implode('. ', $result->getMessages()));
}
$this->response->getHeaders()->addHeader(
Location::fromString(
'Location: ' . $this->request->getUri()->getPath()
)
);
return $this->model->setVariables($this->options->getSerializer()->toArray($result->getIdentity()));
}
|
php
|
public function create($data)
{
$authService = $this->options->getAuthenticationService();
if ($authService->hasIdentity()) {
$authService->logout();
}
$result = $authService->login(
$data[$this->options->getDataUsernameKey()],
$data[$this->options->getDataPasswordKey()],
isset($data[$this->options->getDataRememberMeKey()]) ? $data[$this->options->getDataRememberMeKey()]: false
);
if (!$result->isValid()) {
throw new Exception\LoginFailedException(implode('. ', $result->getMessages()));
}
$this->response->getHeaders()->addHeader(
Location::fromString(
'Location: ' . $this->request->getUri()->getPath()
)
);
return $this->model->setVariables($this->options->getSerializer()->toArray($result->getIdentity()));
}
|
[
"public",
"function",
"create",
"(",
"$",
"data",
")",
"{",
"$",
"authService",
"=",
"$",
"this",
"->",
"options",
"->",
"getAuthenticationService",
"(",
")",
";",
"if",
"(",
"$",
"authService",
"->",
"hasIdentity",
"(",
")",
")",
"{",
"$",
"authService",
"->",
"logout",
"(",
")",
";",
"}",
"$",
"result",
"=",
"$",
"authService",
"->",
"login",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"options",
"->",
"getDataUsernameKey",
"(",
")",
"]",
",",
"$",
"data",
"[",
"$",
"this",
"->",
"options",
"->",
"getDataPasswordKey",
"(",
")",
"]",
",",
"isset",
"(",
"$",
"data",
"[",
"$",
"this",
"->",
"options",
"->",
"getDataRememberMeKey",
"(",
")",
"]",
")",
"?",
"$",
"data",
"[",
"$",
"this",
"->",
"options",
"->",
"getDataRememberMeKey",
"(",
")",
"]",
":",
"false",
")",
";",
"if",
"(",
"!",
"$",
"result",
"->",
"isValid",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"LoginFailedException",
"(",
"implode",
"(",
"'. '",
",",
"$",
"result",
"->",
"getMessages",
"(",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"response",
"->",
"getHeaders",
"(",
")",
"->",
"addHeader",
"(",
"Location",
"::",
"fromString",
"(",
"'Location: '",
".",
"$",
"this",
"->",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"model",
"->",
"setVariables",
"(",
"$",
"this",
"->",
"options",
"->",
"getSerializer",
"(",
")",
"->",
"toArray",
"(",
"$",
"result",
"->",
"getIdentity",
"(",
")",
")",
")",
";",
"}"
] |
Checks the provided username and password against the AuthenticationService and
returns the active user
@param type $data
@return type
@throws Exception\LoginFailedException
|
[
"Checks",
"the",
"provided",
"username",
"and",
"password",
"against",
"the",
"AuthenticationService",
"and",
"returns",
"the",
"active",
"user"
] |
ea8770512d16f3d0099da380e4829aedec01a0e8
|
https://github.com/zoopcommerce/gateway-module/blob/ea8770512d16f3d0099da380e4829aedec01a0e8/src/Zoop/GatewayModule/Controller/AuthenticatedUserController.php#L91-L115
|
239,082
|
slickframework/mvc
|
src/Console/MetaDataGenerator/Composer.php
|
Composer.setComposerFile
|
protected function setComposerFile($file)
{
if (null != $file && !is_file($file)) {
throw new FileNotFoundException(
"The file {$file} was not found."
);
}
$this->composerFile = $file;
}
|
php
|
protected function setComposerFile($file)
{
if (null != $file && !is_file($file)) {
throw new FileNotFoundException(
"The file {$file} was not found."
);
}
$this->composerFile = $file;
}
|
[
"protected",
"function",
"setComposerFile",
"(",
"$",
"file",
")",
"{",
"if",
"(",
"null",
"!=",
"$",
"file",
"&&",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"The file {$file} was not found.\"",
")",
";",
"}",
"$",
"this",
"->",
"composerFile",
"=",
"$",
"file",
";",
"}"
] |
Sets the composer file to parse
@param $file
|
[
"Sets",
"the",
"composer",
"file",
"to",
"parse"
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Console/MetaDataGenerator/Composer.php#L78-L87
|
239,083
|
slickframework/mvc
|
src/Console/MetaDataGenerator/Composer.php
|
Composer.getComposerData
|
protected function getComposerData()
{
if (null == $this->composerData) {
$json = file_get_contents($this->getComposerFile());
$this->composerData = json_decode($json);
if (null === $this->composerData) {
throw new ComposerParseException(
"Error parsing file {$this->getComposerFile()}"
);
}
}
return $this->composerData;
}
|
php
|
protected function getComposerData()
{
if (null == $this->composerData) {
$json = file_get_contents($this->getComposerFile());
$this->composerData = json_decode($json);
if (null === $this->composerData) {
throw new ComposerParseException(
"Error parsing file {$this->getComposerFile()}"
);
}
}
return $this->composerData;
}
|
[
"protected",
"function",
"getComposerData",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"composerData",
")",
"{",
"$",
"json",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"getComposerFile",
"(",
")",
")",
";",
"$",
"this",
"->",
"composerData",
"=",
"json_decode",
"(",
"$",
"json",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"composerData",
")",
"{",
"throw",
"new",
"ComposerParseException",
"(",
"\"Error parsing file {$this->getComposerFile()}\"",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"composerData",
";",
"}"
] |
Gets the data object from json file
@return mixed|Object
|
[
"Gets",
"the",
"data",
"object",
"from",
"json",
"file"
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Console/MetaDataGenerator/Composer.php#L94-L108
|
239,084
|
slickframework/mvc
|
src/Console/MetaDataGenerator/Composer.php
|
Composer.getAuthor
|
protected function getAuthor()
{
if (
!isset($this->getComposerData()->authors) ||
count($this->getComposerData()->authors) != 1
) {
return $this->requestAuthor();
}
return [
'authorName' => $this->getComposerData()->authors[0]->name,
'authorEmail' => $this->getComposerData()->authors[0]->email
];
}
|
php
|
protected function getAuthor()
{
if (
!isset($this->getComposerData()->authors) ||
count($this->getComposerData()->authors) != 1
) {
return $this->requestAuthor();
}
return [
'authorName' => $this->getComposerData()->authors[0]->name,
'authorEmail' => $this->getComposerData()->authors[0]->email
];
}
|
[
"protected",
"function",
"getAuthor",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"getComposerData",
"(",
")",
"->",
"authors",
")",
"||",
"count",
"(",
"$",
"this",
"->",
"getComposerData",
"(",
")",
"->",
"authors",
")",
"!=",
"1",
")",
"{",
"return",
"$",
"this",
"->",
"requestAuthor",
"(",
")",
";",
"}",
"return",
"[",
"'authorName'",
"=>",
"$",
"this",
"->",
"getComposerData",
"(",
")",
"->",
"authors",
"[",
"0",
"]",
"->",
"name",
",",
"'authorEmail'",
"=>",
"$",
"this",
"->",
"getComposerData",
"(",
")",
"->",
"authors",
"[",
"0",
"]",
"->",
"email",
"]",
";",
"}"
] |
Gets the author name and e-mail
@return array
|
[
"Gets",
"the",
"author",
"name",
"and",
"e",
"-",
"mail"
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Console/MetaDataGenerator/Composer.php#L141-L154
|
239,085
|
slickframework/mvc
|
src/Console/MetaDataGenerator/Composer.php
|
Composer.requestAuthor
|
protected function requestAuthor()
{
if (!empty($this->getComposerData()->authors)) {
return $this->selectAuthors();
}
$nameQuestion = new Question('Please enter your name: ');
$emailQuestion = new Question('Please enter your e-mail address: ');
$this->getOutput()->writeln('');
$this->getOutput()->writeln(
'<info>Cannot determine the developer name ' .
'from project\'s composer.json file.</info>'
);
$this->getOutput()->writeln(
"<comment>To automatically set the developer's " .
"name and e-mail and avoid entering it on every generate:* " .
"commands set the authors entry on your project's " .
"composer.json file.</comment>"
);
$authorName = $this->getQuestionHelper()->ask(
$this->getInput(),
$this->getOutput(),
$nameQuestion
);
$authorEmail = $this->getQuestionHelper()->ask(
$this->getInput(),
$this->getOutput(),
$emailQuestion
);
return compact('authorName', 'authorEmail');
}
|
php
|
protected function requestAuthor()
{
if (!empty($this->getComposerData()->authors)) {
return $this->selectAuthors();
}
$nameQuestion = new Question('Please enter your name: ');
$emailQuestion = new Question('Please enter your e-mail address: ');
$this->getOutput()->writeln('');
$this->getOutput()->writeln(
'<info>Cannot determine the developer name ' .
'from project\'s composer.json file.</info>'
);
$this->getOutput()->writeln(
"<comment>To automatically set the developer's " .
"name and e-mail and avoid entering it on every generate:* " .
"commands set the authors entry on your project's " .
"composer.json file.</comment>"
);
$authorName = $this->getQuestionHelper()->ask(
$this->getInput(),
$this->getOutput(),
$nameQuestion
);
$authorEmail = $this->getQuestionHelper()->ask(
$this->getInput(),
$this->getOutput(),
$emailQuestion
);
return compact('authorName', 'authorEmail');
}
|
[
"protected",
"function",
"requestAuthor",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"getComposerData",
"(",
")",
"->",
"authors",
")",
")",
"{",
"return",
"$",
"this",
"->",
"selectAuthors",
"(",
")",
";",
"}",
"$",
"nameQuestion",
"=",
"new",
"Question",
"(",
"'Please enter your name: '",
")",
";",
"$",
"emailQuestion",
"=",
"new",
"Question",
"(",
"'Please enter your e-mail address: '",
")",
";",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"''",
")",
";",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"'<info>Cannot determine the developer name '",
".",
"'from project\\'s composer.json file.</info>'",
")",
";",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"\"<comment>To automatically set the developer's \"",
".",
"\"name and e-mail and avoid entering it on every generate:* \"",
".",
"\"commands set the authors entry on your project's \"",
".",
"\"composer.json file.</comment>\"",
")",
";",
"$",
"authorName",
"=",
"$",
"this",
"->",
"getQuestionHelper",
"(",
")",
"->",
"ask",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
",",
"$",
"this",
"->",
"getOutput",
"(",
")",
",",
"$",
"nameQuestion",
")",
";",
"$",
"authorEmail",
"=",
"$",
"this",
"->",
"getQuestionHelper",
"(",
")",
"->",
"ask",
"(",
"$",
"this",
"->",
"getInput",
"(",
")",
",",
"$",
"this",
"->",
"getOutput",
"(",
")",
",",
"$",
"emailQuestion",
")",
";",
"return",
"compact",
"(",
"'authorName'",
",",
"'authorEmail'",
")",
";",
"}"
] |
Asks the author name and e-mail and returns them
@return array
|
[
"Asks",
"the",
"author",
"name",
"and",
"e",
"-",
"mail",
"and",
"returns",
"them"
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Console/MetaDataGenerator/Composer.php#L161-L191
|
239,086
|
slickframework/mvc
|
src/Console/MetaDataGenerator/Composer.php
|
Composer.selectAuthors
|
protected function selectAuthors()
{
$options = $this->getAuthorsAsOptions();
$this->getOutput()->writeln('');
$this->getOutput()->writeln(
'<info>Multiple authors found on ' .
'project\'s composer.json file.</info>'
);
$question = new ChoiceQuestion(
'Please select the author from the list above:',
$options,
0
);
$question->setErrorMessage('The choice %s is invalid.');
$selected = $this->getQuestionHelper()
->ask($this->input, $this->output, $question);
$parts = explode('<', $selected);
return [
'authorName' => trim($parts[0]),
'authorEmail' => trim($parts[1], '>'),
];
}
|
php
|
protected function selectAuthors()
{
$options = $this->getAuthorsAsOptions();
$this->getOutput()->writeln('');
$this->getOutput()->writeln(
'<info>Multiple authors found on ' .
'project\'s composer.json file.</info>'
);
$question = new ChoiceQuestion(
'Please select the author from the list above:',
$options,
0
);
$question->setErrorMessage('The choice %s is invalid.');
$selected = $this->getQuestionHelper()
->ask($this->input, $this->output, $question);
$parts = explode('<', $selected);
return [
'authorName' => trim($parts[0]),
'authorEmail' => trim($parts[1], '>'),
];
}
|
[
"protected",
"function",
"selectAuthors",
"(",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getAuthorsAsOptions",
"(",
")",
";",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"''",
")",
";",
"$",
"this",
"->",
"getOutput",
"(",
")",
"->",
"writeln",
"(",
"'<info>Multiple authors found on '",
".",
"'project\\'s composer.json file.</info>'",
")",
";",
"$",
"question",
"=",
"new",
"ChoiceQuestion",
"(",
"'Please select the author from the list above:'",
",",
"$",
"options",
",",
"0",
")",
";",
"$",
"question",
"->",
"setErrorMessage",
"(",
"'The choice %s is invalid.'",
")",
";",
"$",
"selected",
"=",
"$",
"this",
"->",
"getQuestionHelper",
"(",
")",
"->",
"ask",
"(",
"$",
"this",
"->",
"input",
",",
"$",
"this",
"->",
"output",
",",
"$",
"question",
")",
";",
"$",
"parts",
"=",
"explode",
"(",
"'<'",
",",
"$",
"selected",
")",
";",
"return",
"[",
"'authorName'",
"=>",
"trim",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
",",
"'authorEmail'",
"=>",
"trim",
"(",
"$",
"parts",
"[",
"1",
"]",
",",
"'>'",
")",
",",
"]",
";",
"}"
] |
Requests user to select author form a list of composer authors
and returns them.
@return array
|
[
"Requests",
"user",
"to",
"select",
"author",
"form",
"a",
"list",
"of",
"composer",
"authors",
"and",
"returns",
"them",
"."
] |
91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab
|
https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Console/MetaDataGenerator/Composer.php#L199-L220
|
239,087
|
treffynnon/command-wrap
|
src/Runners/Passthru.php
|
Passthru.run
|
public function run(RunnableInterface $command, callable $func = null)
{
if ($func) {
throw new \Exception('You cannot process passthru with a callable. Use another Runner instead.');
}
$command = (string) $command->getCommandAssembler();
passthru($command, $status);
return $this->getResponseClass($command, $status, '');
}
|
php
|
public function run(RunnableInterface $command, callable $func = null)
{
if ($func) {
throw new \Exception('You cannot process passthru with a callable. Use another Runner instead.');
}
$command = (string) $command->getCommandAssembler();
passthru($command, $status);
return $this->getResponseClass($command, $status, '');
}
|
[
"public",
"function",
"run",
"(",
"RunnableInterface",
"$",
"command",
",",
"callable",
"$",
"func",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"func",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'You cannot process passthru with a callable. Use another Runner instead.'",
")",
";",
"}",
"$",
"command",
"=",
"(",
"string",
")",
"$",
"command",
"->",
"getCommandAssembler",
"(",
")",
";",
"passthru",
"(",
"$",
"command",
",",
"$",
"status",
")",
";",
"return",
"$",
"this",
"->",
"getResponseClass",
"(",
"$",
"command",
",",
"$",
"status",
",",
"''",
")",
";",
"}"
] |
Passes through result of the command so no output is set
@link http://php.net/passthru
@param RunnableInterface $command
|
[
"Passes",
"through",
"result",
"of",
"the",
"command",
"so",
"no",
"output",
"is",
"set"
] |
381f1a7d1bd76e2b7d0898f51e3dd5caffbf5e4b
|
https://github.com/treffynnon/command-wrap/blob/381f1a7d1bd76e2b7d0898f51e3dd5caffbf5e4b/src/Runners/Passthru.php#L15-L24
|
239,088
|
InnoGr/FivePercent-Api
|
src/Server/JsonRpc/JsonRpcServer.php
|
JsonRpcServer.processApiMethod
|
private function processApiMethod(SfRequest $request)
{
// Try parse JSON
$content = $request->getContent();
if (!$content) {
throw new MissingHttpContentException('Missing HTTP content.');
}
$query = @json_decode($content, true);
if (false === $query) {
throw JsonParseException::create(json_last_error());
}
return $this->processApiQuery($query);
}
|
php
|
private function processApiMethod(SfRequest $request)
{
// Try parse JSON
$content = $request->getContent();
if (!$content) {
throw new MissingHttpContentException('Missing HTTP content.');
}
$query = @json_decode($content, true);
if (false === $query) {
throw JsonParseException::create(json_last_error());
}
return $this->processApiQuery($query);
}
|
[
"private",
"function",
"processApiMethod",
"(",
"SfRequest",
"$",
"request",
")",
"{",
"// Try parse JSON",
"$",
"content",
"=",
"$",
"request",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"!",
"$",
"content",
")",
"{",
"throw",
"new",
"MissingHttpContentException",
"(",
"'Missing HTTP content.'",
")",
";",
"}",
"$",
"query",
"=",
"@",
"json_decode",
"(",
"$",
"content",
",",
"true",
")",
";",
"if",
"(",
"false",
"===",
"$",
"query",
")",
"{",
"throw",
"JsonParseException",
"::",
"create",
"(",
"json_last_error",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"processApiQuery",
"(",
"$",
"query",
")",
";",
"}"
] |
Process API method
@param SfRequest $request
@return JsonResponse
@throws \Exception
|
[
"Process",
"API",
"method"
] |
57b78ddc3c9d91a7139c276711e5792824ceab9c
|
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Server/JsonRpc/JsonRpcServer.php#L200-L216
|
239,089
|
InnoGr/FivePercent-Api
|
src/Server/JsonRpc/JsonRpcServer.php
|
JsonRpcServer.processApiQuery
|
private function processApiQuery(array $query)
{
$query += array(
'params' => array(),
'id' => null
);
if (empty($query['method'])) {
throw new MissingMethodException('Missing "method" parameter in query.');
}
if ($query['id'] !== null && !is_scalar($query['id'])) {
throw new InvalidIdException('The "id" parameter must be a scalar.');
}
if (!is_scalar($query['method'])) {
throw new InvalidMethodException('The "method" parameter must be a scalar.');
}
if (!is_array($query['params'])) {
throw new InvalidParametersException('Input parameters must be a array.');
}
$this->requestId = $query['id'];
$apiResponse = $this->handler->handle($query['method'], $query['params']);
if ($apiResponse instanceof EmptyResponseInterface) {
if ($apiResponse instanceof ResponseInterface) {
return new SfResponse('', $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
} else {
return new SfResponse('');
}
}
$data = array(
'jsonrpc' => self::JSON_RPC_VERSION,
'result' => $apiResponse->getData(),
'id' => $query['id']
);
return new JsonResponse($data, $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
}
|
php
|
private function processApiQuery(array $query)
{
$query += array(
'params' => array(),
'id' => null
);
if (empty($query['method'])) {
throw new MissingMethodException('Missing "method" parameter in query.');
}
if ($query['id'] !== null && !is_scalar($query['id'])) {
throw new InvalidIdException('The "id" parameter must be a scalar.');
}
if (!is_scalar($query['method'])) {
throw new InvalidMethodException('The "method" parameter must be a scalar.');
}
if (!is_array($query['params'])) {
throw new InvalidParametersException('Input parameters must be a array.');
}
$this->requestId = $query['id'];
$apiResponse = $this->handler->handle($query['method'], $query['params']);
if ($apiResponse instanceof EmptyResponseInterface) {
if ($apiResponse instanceof ResponseInterface) {
return new SfResponse('', $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
} else {
return new SfResponse('');
}
}
$data = array(
'jsonrpc' => self::JSON_RPC_VERSION,
'result' => $apiResponse->getData(),
'id' => $query['id']
);
return new JsonResponse($data, $apiResponse->getHttpStatusCode(), $apiResponse->getHeaders()->all());
}
|
[
"private",
"function",
"processApiQuery",
"(",
"array",
"$",
"query",
")",
"{",
"$",
"query",
"+=",
"array",
"(",
"'params'",
"=>",
"array",
"(",
")",
",",
"'id'",
"=>",
"null",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"query",
"[",
"'method'",
"]",
")",
")",
"{",
"throw",
"new",
"MissingMethodException",
"(",
"'Missing \"method\" parameter in query.'",
")",
";",
"}",
"if",
"(",
"$",
"query",
"[",
"'id'",
"]",
"!==",
"null",
"&&",
"!",
"is_scalar",
"(",
"$",
"query",
"[",
"'id'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidIdException",
"(",
"'The \"id\" parameter must be a scalar.'",
")",
";",
"}",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"query",
"[",
"'method'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidMethodException",
"(",
"'The \"method\" parameter must be a scalar.'",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"query",
"[",
"'params'",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidParametersException",
"(",
"'Input parameters must be a array.'",
")",
";",
"}",
"$",
"this",
"->",
"requestId",
"=",
"$",
"query",
"[",
"'id'",
"]",
";",
"$",
"apiResponse",
"=",
"$",
"this",
"->",
"handler",
"->",
"handle",
"(",
"$",
"query",
"[",
"'method'",
"]",
",",
"$",
"query",
"[",
"'params'",
"]",
")",
";",
"if",
"(",
"$",
"apiResponse",
"instanceof",
"EmptyResponseInterface",
")",
"{",
"if",
"(",
"$",
"apiResponse",
"instanceof",
"ResponseInterface",
")",
"{",
"return",
"new",
"SfResponse",
"(",
"''",
",",
"$",
"apiResponse",
"->",
"getHttpStatusCode",
"(",
")",
",",
"$",
"apiResponse",
"->",
"getHeaders",
"(",
")",
"->",
"all",
"(",
")",
")",
";",
"}",
"else",
"{",
"return",
"new",
"SfResponse",
"(",
"''",
")",
";",
"}",
"}",
"$",
"data",
"=",
"array",
"(",
"'jsonrpc'",
"=>",
"self",
"::",
"JSON_RPC_VERSION",
",",
"'result'",
"=>",
"$",
"apiResponse",
"->",
"getData",
"(",
")",
",",
"'id'",
"=>",
"$",
"query",
"[",
"'id'",
"]",
")",
";",
"return",
"new",
"JsonResponse",
"(",
"$",
"data",
",",
"$",
"apiResponse",
"->",
"getHttpStatusCode",
"(",
")",
",",
"$",
"apiResponse",
"->",
"getHeaders",
"(",
")",
"->",
"all",
"(",
")",
")",
";",
"}"
] |
Process api query
@param array $query
@return JsonResponse
@throws \Exception
|
[
"Process",
"api",
"query"
] |
57b78ddc3c9d91a7139c276711e5792824ceab9c
|
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Server/JsonRpc/JsonRpcServer.php#L227-L269
|
239,090
|
InnoGr/FivePercent-Api
|
src/Server/JsonRpc/JsonRpcServer.php
|
JsonRpcServer.createErrorResponse
|
private function createErrorResponse($code, $message = null, array $data = [])
{
if (!$message) {
$messages = $this->handler->getErrors()->getErrors();
$message = isset($messages[$code]) ? $messages[$code] : 'Error';
}
$json = [
'jsonrpc' => self::JSON_RPC_VERSION,
'error' => [
'code' => $code,
'message' => $message
],
'id' => $this->requestId
];
if ($data) {
$json['error']['data'] = $data;
}
return new JsonResponse($json, 200);
}
|
php
|
private function createErrorResponse($code, $message = null, array $data = [])
{
if (!$message) {
$messages = $this->handler->getErrors()->getErrors();
$message = isset($messages[$code]) ? $messages[$code] : 'Error';
}
$json = [
'jsonrpc' => self::JSON_RPC_VERSION,
'error' => [
'code' => $code,
'message' => $message
],
'id' => $this->requestId
];
if ($data) {
$json['error']['data'] = $data;
}
return new JsonResponse($json, 200);
}
|
[
"private",
"function",
"createErrorResponse",
"(",
"$",
"code",
",",
"$",
"message",
"=",
"null",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"message",
")",
"{",
"$",
"messages",
"=",
"$",
"this",
"->",
"handler",
"->",
"getErrors",
"(",
")",
"->",
"getErrors",
"(",
")",
";",
"$",
"message",
"=",
"isset",
"(",
"$",
"messages",
"[",
"$",
"code",
"]",
")",
"?",
"$",
"messages",
"[",
"$",
"code",
"]",
":",
"'Error'",
";",
"}",
"$",
"json",
"=",
"[",
"'jsonrpc'",
"=>",
"self",
"::",
"JSON_RPC_VERSION",
",",
"'error'",
"=>",
"[",
"'code'",
"=>",
"$",
"code",
",",
"'message'",
"=>",
"$",
"message",
"]",
",",
"'id'",
"=>",
"$",
"this",
"->",
"requestId",
"]",
";",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"json",
"[",
"'error'",
"]",
"[",
"'data'",
"]",
"=",
"$",
"data",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"$",
"json",
",",
"200",
")",
";",
"}"
] |
Create error response
@param integer $code
@param string $message
@param array $data
@return JsonResponse
|
[
"Create",
"error",
"response"
] |
57b78ddc3c9d91a7139c276711e5792824ceab9c
|
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Server/JsonRpc/JsonRpcServer.php#L280-L301
|
239,091
|
InnoGr/FivePercent-Api
|
src/Server/JsonRpc/JsonRpcServer.php
|
JsonRpcServer.createViolationErrorResponse
|
public function createViolationErrorResponse(ViolationListException $exception)
{
$errorData = [];
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
foreach ($exception->getViolationList() as $violation) {
$errorData[$violation->getPropertyPath()] = $violation->getMessage();
}
// Try get code from errors storage via exception
$errors = $this->handler->getErrors();
$code = $errors->hasException($exception) ? $errors->getExceptionCode($exception) : 0;
return $this->createErrorResponse($code, null, $errorData);
}
|
php
|
public function createViolationErrorResponse(ViolationListException $exception)
{
$errorData = [];
/** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
foreach ($exception->getViolationList() as $violation) {
$errorData[$violation->getPropertyPath()] = $violation->getMessage();
}
// Try get code from errors storage via exception
$errors = $this->handler->getErrors();
$code = $errors->hasException($exception) ? $errors->getExceptionCode($exception) : 0;
return $this->createErrorResponse($code, null, $errorData);
}
|
[
"public",
"function",
"createViolationErrorResponse",
"(",
"ViolationListException",
"$",
"exception",
")",
"{",
"$",
"errorData",
"=",
"[",
"]",
";",
"/** @var \\Symfony\\Component\\Validator\\ConstraintViolationInterface $violation */",
"foreach",
"(",
"$",
"exception",
"->",
"getViolationList",
"(",
")",
"as",
"$",
"violation",
")",
"{",
"$",
"errorData",
"[",
"$",
"violation",
"->",
"getPropertyPath",
"(",
")",
"]",
"=",
"$",
"violation",
"->",
"getMessage",
"(",
")",
";",
"}",
"// Try get code from errors storage via exception",
"$",
"errors",
"=",
"$",
"this",
"->",
"handler",
"->",
"getErrors",
"(",
")",
";",
"$",
"code",
"=",
"$",
"errors",
"->",
"hasException",
"(",
"$",
"exception",
")",
"?",
"$",
"errors",
"->",
"getExceptionCode",
"(",
"$",
"exception",
")",
":",
"0",
";",
"return",
"$",
"this",
"->",
"createErrorResponse",
"(",
"$",
"code",
",",
"null",
",",
"$",
"errorData",
")",
";",
"}"
] |
Create violation error response
@param ViolationListException $exception
@return JsonResponse
|
[
"Create",
"violation",
"error",
"response"
] |
57b78ddc3c9d91a7139c276711e5792824ceab9c
|
https://github.com/InnoGr/FivePercent-Api/blob/57b78ddc3c9d91a7139c276711e5792824ceab9c/src/Server/JsonRpc/JsonRpcServer.php#L310-L324
|
239,092
|
mpoiriert/draw-test-helper-bundle
|
Helper/RequestHelper.php
|
RequestHelper.head
|
public function head($uri = null, $expectedStatus = null)
{
$this->setMethod('HEAD');
$this->setUri($uri);
if (!is_null($expectedStatus)) {
$this->expectingStatusCode($expectedStatus);
}
return $this;
}
|
php
|
public function head($uri = null, $expectedStatus = null)
{
$this->setMethod('HEAD');
$this->setUri($uri);
if (!is_null($expectedStatus)) {
$this->expectingStatusCode($expectedStatus);
}
return $this;
}
|
[
"public",
"function",
"head",
"(",
"$",
"uri",
"=",
"null",
",",
"$",
"expectedStatus",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"setMethod",
"(",
"'HEAD'",
")",
";",
"$",
"this",
"->",
"setUri",
"(",
"$",
"uri",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"expectedStatus",
")",
")",
"{",
"$",
"this",
"->",
"expectingStatusCode",
"(",
"$",
"expectedStatus",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Set the HTTP method to HEAD and the uri if any.
Return $this for a fluent interface.
@param string|null $uri
@param integer|null $expectedStatus
@return $this
|
[
"Set",
"the",
"HTTP",
"method",
"to",
"HEAD",
"and",
"the",
"uri",
"if",
"any",
"."
] |
cd8bb9cb38f2ee0b333ba1a68152fb20d7d70889
|
https://github.com/mpoiriert/draw-test-helper-bundle/blob/cd8bb9cb38f2ee0b333ba1a68152fb20d7d70889/Helper/RequestHelper.php#L180-L189
|
239,093
|
agentmedia/phine-news
|
src/News/Modules/Backend/ArticleList.php
|
ArticleList.InitCategoryArticles
|
private function InitCategoryArticles()
{
$tblArticle = Article::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblArticle->Field('Created')));
$this->articles = Article::Schema()->FetchByCategory(false, $this->category, $orderBy, null, $this->ArticleOffset(), $this->perPage);
$this->articlesTotal = Article::Schema()->CountByCategory(false, $this->category);
}
|
php
|
private function InitCategoryArticles()
{
$tblArticle = Article::Schema()->Table();
$sql = Access::SqlBuilder();
$orderBy = $sql->OrderList($sql->OrderDesc($tblArticle->Field('Created')));
$this->articles = Article::Schema()->FetchByCategory(false, $this->category, $orderBy, null, $this->ArticleOffset(), $this->perPage);
$this->articlesTotal = Article::Schema()->CountByCategory(false, $this->category);
}
|
[
"private",
"function",
"InitCategoryArticles",
"(",
")",
"{",
"$",
"tblArticle",
"=",
"Article",
"::",
"Schema",
"(",
")",
"->",
"Table",
"(",
")",
";",
"$",
"sql",
"=",
"Access",
"::",
"SqlBuilder",
"(",
")",
";",
"$",
"orderBy",
"=",
"$",
"sql",
"->",
"OrderList",
"(",
"$",
"sql",
"->",
"OrderDesc",
"(",
"$",
"tblArticle",
"->",
"Field",
"(",
"'Created'",
")",
")",
")",
";",
"$",
"this",
"->",
"articles",
"=",
"Article",
"::",
"Schema",
"(",
")",
"->",
"FetchByCategory",
"(",
"false",
",",
"$",
"this",
"->",
"category",
",",
"$",
"orderBy",
",",
"null",
",",
"$",
"this",
"->",
"ArticleOffset",
"(",
")",
",",
"$",
"this",
"->",
"perPage",
")",
";",
"$",
"this",
"->",
"articlesTotal",
"=",
"Article",
"::",
"Schema",
"(",
")",
"->",
"CountByCategory",
"(",
"false",
",",
"$",
"this",
"->",
"category",
")",
";",
"}"
] |
Initializes the article array by category
|
[
"Initializes",
"the",
"article",
"array",
"by",
"category"
] |
51abc830fecd1325f0b7d28391ecd924cdc7c945
|
https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleList.php#L101-L108
|
239,094
|
agentmedia/phine-news
|
src/News/Modules/Backend/ArticleList.php
|
ArticleList.RemovalObject
|
protected function RemovalObject()
{
$id = Request::PostData('delete');
return $id ? Article::Schema()->ByID($id) : null;
}
|
php
|
protected function RemovalObject()
{
$id = Request::PostData('delete');
return $id ? Article::Schema()->ByID($id) : null;
}
|
[
"protected",
"function",
"RemovalObject",
"(",
")",
"{",
"$",
"id",
"=",
"Request",
"::",
"PostData",
"(",
"'delete'",
")",
";",
"return",
"$",
"id",
"?",
"Article",
"::",
"Schema",
"(",
")",
"->",
"ByID",
"(",
"$",
"id",
")",
":",
"null",
";",
"}"
] |
Gets the object to remove in case there is any
@return Article Returns the article to remove or null if none is requested
|
[
"Gets",
"the",
"object",
"to",
"remove",
"in",
"case",
"there",
"is",
"any"
] |
51abc830fecd1325f0b7d28391ecd924cdc7c945
|
https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleList.php#L124-L128
|
239,095
|
agentmedia/phine-news
|
src/News/Modules/Backend/ArticleList.php
|
ArticleList.BackLink
|
protected function BackLink()
{
if ($this->category) {
return BackendRouter::ModuleUrl(new CategoryList(), array('archive'=>$this->archive->GetID()));
}
else {
return BackendRouter::ModuleUrl(new ArchiveList());
}
}
|
php
|
protected function BackLink()
{
if ($this->category) {
return BackendRouter::ModuleUrl(new CategoryList(), array('archive'=>$this->archive->GetID()));
}
else {
return BackendRouter::ModuleUrl(new ArchiveList());
}
}
|
[
"protected",
"function",
"BackLink",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"category",
")",
"{",
"return",
"BackendRouter",
"::",
"ModuleUrl",
"(",
"new",
"CategoryList",
"(",
")",
",",
"array",
"(",
"'archive'",
"=>",
"$",
"this",
"->",
"archive",
"->",
"GetID",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"return",
"BackendRouter",
"::",
"ModuleUrl",
"(",
"new",
"ArchiveList",
"(",
")",
")",
";",
"}",
"}"
] |
The backlink; either links to the category list or the archive list
@return string Returns the link for the back button
|
[
"The",
"backlink",
";",
"either",
"links",
"to",
"the",
"category",
"list",
"or",
"the",
"archive",
"list"
] |
51abc830fecd1325f0b7d28391ecd924cdc7c945
|
https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleList.php#L134-L142
|
239,096
|
mszewcz/php-light-framework
|
src/Filesystem/AbstractFilesystem.php
|
AbstractFilesystem.setNewDirectoryMode
|
public static function setNewDirectoryMode(string $mode = '740'): void
{
static::init();
static::$newDirectoryMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
}
|
php
|
public static function setNewDirectoryMode(string $mode = '740'): void
{
static::init();
static::$newDirectoryMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
}
|
[
"public",
"static",
"function",
"setNewDirectoryMode",
"(",
"string",
"$",
"mode",
"=",
"'740'",
")",
":",
"void",
"{",
"static",
"::",
"init",
"(",
")",
";",
"static",
"::",
"$",
"newDirectoryMode",
"=",
"\\",
"preg_match",
"(",
"'/^[0-7]{3}$/'",
",",
"$",
"mode",
")",
"?",
"\\",
"intval",
"(",
"$",
"mode",
",",
"8",
")",
":",
"0740",
";",
"}"
] |
Sets default mode for newly created directories
@param string $mode
|
[
"Sets",
"default",
"mode",
"for",
"newly",
"created",
"directories"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Filesystem/AbstractFilesystem.php#L91-L95
|
239,097
|
mszewcz/php-light-framework
|
src/Filesystem/AbstractFilesystem.php
|
AbstractFilesystem.setNewFileMode
|
public static function setNewFileMode(string $mode = '740'): void
{
static::init();
static::$newFileMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
}
|
php
|
public static function setNewFileMode(string $mode = '740'): void
{
static::init();
static::$newFileMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
}
|
[
"public",
"static",
"function",
"setNewFileMode",
"(",
"string",
"$",
"mode",
"=",
"'740'",
")",
":",
"void",
"{",
"static",
"::",
"init",
"(",
")",
";",
"static",
"::",
"$",
"newFileMode",
"=",
"\\",
"preg_match",
"(",
"'/^[0-7]{3}$/'",
",",
"$",
"mode",
")",
"?",
"\\",
"intval",
"(",
"$",
"mode",
",",
"8",
")",
":",
"0740",
";",
"}"
] |
Sets default mode for newly created files
@param string $mode
|
[
"Sets",
"default",
"mode",
"for",
"newly",
"created",
"files"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Filesystem/AbstractFilesystem.php#L113-L117
|
239,098
|
mszewcz/php-light-framework
|
src/Filesystem/AbstractFilesystem.php
|
AbstractFilesystem.setNewSymbolicLinkMode
|
public static function setNewSymbolicLinkMode(string $mode = '740'): void
{
static::init();
static::$newSymlinkMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
}
|
php
|
public static function setNewSymbolicLinkMode(string $mode = '740'): void
{
static::init();
static::$newSymlinkMode = \preg_match('/^[0-7]{3}$/', $mode) ? \intval($mode, 8) : 0740;
}
|
[
"public",
"static",
"function",
"setNewSymbolicLinkMode",
"(",
"string",
"$",
"mode",
"=",
"'740'",
")",
":",
"void",
"{",
"static",
"::",
"init",
"(",
")",
";",
"static",
"::",
"$",
"newSymlinkMode",
"=",
"\\",
"preg_match",
"(",
"'/^[0-7]{3}$/'",
",",
"$",
"mode",
")",
"?",
"\\",
"intval",
"(",
"$",
"mode",
",",
"8",
")",
":",
"0740",
";",
"}"
] |
Sets default mode for newly created symbolic links
@param string $mode
|
[
"Sets",
"default",
"mode",
"for",
"newly",
"created",
"symbolic",
"links"
] |
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
|
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Filesystem/AbstractFilesystem.php#L135-L139
|
239,099
|
unyx/console
|
output/formatting/Formatter.php
|
Formatter.createDefaultStyles
|
protected function createDefaultStyles() : styles\Map
{
return new styles\Map([
'error' => new Style('white', 'red'),
'info' => new Style('green'),
'comment' => new Style('cyan'),
'important' => new Style('red'),
'header' => new Style('black', 'cyan')
]);
}
|
php
|
protected function createDefaultStyles() : styles\Map
{
return new styles\Map([
'error' => new Style('white', 'red'),
'info' => new Style('green'),
'comment' => new Style('cyan'),
'important' => new Style('red'),
'header' => new Style('black', 'cyan')
]);
}
|
[
"protected",
"function",
"createDefaultStyles",
"(",
")",
":",
"styles",
"\\",
"Map",
"{",
"return",
"new",
"styles",
"\\",
"Map",
"(",
"[",
"'error'",
"=>",
"new",
"Style",
"(",
"'white'",
",",
"'red'",
")",
",",
"'info'",
"=>",
"new",
"Style",
"(",
"'green'",
")",
",",
"'comment'",
"=>",
"new",
"Style",
"(",
"'cyan'",
")",
",",
"'important'",
"=>",
"new",
"Style",
"(",
"'red'",
")",
",",
"'header'",
"=>",
"new",
"Style",
"(",
"'black'",
",",
"'cyan'",
")",
"]",
")",
";",
"}"
] |
Creates a default Map of Styles to be used by this Formatter.
@return styles\Map
|
[
"Creates",
"a",
"default",
"Map",
"of",
"Styles",
"to",
"be",
"used",
"by",
"this",
"Formatter",
"."
] |
b4a76e08bbb5428b0349c0ec4259a914f81a2957
|
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/output/formatting/Formatter.php#L129-L138
|
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.