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,300
|
codger-php/generate
|
src/Bootstrap.php
|
Bootstrap.arguments
|
public static function arguments(array $args) : array
{
putenv("CODGER_DRY=1");
foreach ($args as $key => $value) {
if ($value === '-w') {
putenv("CODGER_DRY=0");
unset($args[$key]);
}
if ($value === '-o') {
putenv("CODGER_OVERWRITE=1");
putenv("CODGER_DRY=0");
unset($args[$key]);
}
if ($value === '-d') {
putenv("CODGER_OVERWRITE=0");
putenv("CODGER_DUMP=1");
putenv("CODGER_DRY=0");
unset($args[$key]);
}
if ($value === '-s') {
putenv("CODGER_OVERWRITE=0");
putenv("CODGER_SKIP=1");
putenv("CODGER_DRY=0");
unset($args[$key]);
}
}
return array_values($args);
}
|
php
|
public static function arguments(array $args) : array
{
putenv("CODGER_DRY=1");
foreach ($args as $key => $value) {
if ($value === '-w') {
putenv("CODGER_DRY=0");
unset($args[$key]);
}
if ($value === '-o') {
putenv("CODGER_OVERWRITE=1");
putenv("CODGER_DRY=0");
unset($args[$key]);
}
if ($value === '-d') {
putenv("CODGER_OVERWRITE=0");
putenv("CODGER_DUMP=1");
putenv("CODGER_DRY=0");
unset($args[$key]);
}
if ($value === '-s') {
putenv("CODGER_OVERWRITE=0");
putenv("CODGER_SKIP=1");
putenv("CODGER_DRY=0");
unset($args[$key]);
}
}
return array_values($args);
}
|
[
"public",
"static",
"function",
"arguments",
"(",
"array",
"$",
"args",
")",
":",
"array",
"{",
"putenv",
"(",
"\"CODGER_DRY=1\"",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"'-w'",
")",
"{",
"putenv",
"(",
"\"CODGER_DRY=0\"",
")",
";",
"unset",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"'-o'",
")",
"{",
"putenv",
"(",
"\"CODGER_OVERWRITE=1\"",
")",
";",
"putenv",
"(",
"\"CODGER_DRY=0\"",
")",
";",
"unset",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"'-d'",
")",
"{",
"putenv",
"(",
"\"CODGER_OVERWRITE=0\"",
")",
";",
"putenv",
"(",
"\"CODGER_DUMP=1\"",
")",
";",
"putenv",
"(",
"\"CODGER_DRY=0\"",
")",
";",
"unset",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"'-s'",
")",
"{",
"putenv",
"(",
"\"CODGER_OVERWRITE=0\"",
")",
";",
"putenv",
"(",
"\"CODGER_SKIP=1\"",
")",
";",
"putenv",
"(",
"\"CODGER_DRY=0\"",
")",
";",
"unset",
"(",
"$",
"args",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}",
"return",
"array_values",
"(",
"$",
"args",
")",
";",
"}"
] |
Helper to return cleaned passed arguments.
@param array $args
@return array
|
[
"Helper",
"to",
"return",
"cleaned",
"passed",
"arguments",
"."
] |
89dd3bd074cef53cf85b1470c0b96b4167825416
|
https://github.com/codger-php/generate/blob/89dd3bd074cef53cf85b1470c0b96b4167825416/src/Bootstrap.php#L105-L132
|
239,301
|
codger-php/generate
|
src/Bootstrap.php
|
Bootstrap.setOptions
|
public function setOptions(array $options) : void
{
self::$options = array_unique(array_merge(self::$options, $options));
}
|
php
|
public function setOptions(array $options) : void
{
self::$options = array_unique(array_merge(self::$options, $options));
}
|
[
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
")",
":",
"void",
"{",
"self",
"::",
"$",
"options",
"=",
"array_unique",
"(",
"array_merge",
"(",
"self",
"::",
"$",
"options",
",",
"$",
"options",
")",
")",
";",
"}"
] |
Set options programmatically. Mostly used internally.
@param array $options
@return void
|
[
"Set",
"options",
"programmatically",
".",
"Mostly",
"used",
"internally",
"."
] |
89dd3bd074cef53cf85b1470c0b96b4167825416
|
https://github.com/codger-php/generate/blob/89dd3bd074cef53cf85b1470c0b96b4167825416/src/Bootstrap.php#L178-L181
|
239,302
|
gbv/jskos-http
|
src/Server.php
|
Server.sendResponse
|
public static function sendResponse(ResponseInterface $response)
{
$code = $response->getStatusCode();
$reason = $response->getReasonPhrase();
header(
sprintf('HTTP/%s %s %s', $response->getProtocolVersion(), $code, $reason),
true, $code
);
foreach ($response->getHeaders() as $header => $values) {
foreach ($values as $value) {
header("$header: $value", false);
}
}
echo $response->getBody();
}
|
php
|
public static function sendResponse(ResponseInterface $response)
{
$code = $response->getStatusCode();
$reason = $response->getReasonPhrase();
header(
sprintf('HTTP/%s %s %s', $response->getProtocolVersion(), $code, $reason),
true, $code
);
foreach ($response->getHeaders() as $header => $values) {
foreach ($values as $value) {
header("$header: $value", false);
}
}
echo $response->getBody();
}
|
[
"public",
"static",
"function",
"sendResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"code",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"$",
"reason",
"=",
"$",
"response",
"->",
"getReasonPhrase",
"(",
")",
";",
"header",
"(",
"sprintf",
"(",
"'HTTP/%s %s %s'",
",",
"$",
"response",
"->",
"getProtocolVersion",
"(",
")",
",",
"$",
"code",
",",
"$",
"reason",
")",
",",
"true",
",",
"$",
"code",
")",
";",
"foreach",
"(",
"$",
"response",
"->",
"getHeaders",
"(",
")",
"as",
"$",
"header",
"=>",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"header",
"(",
"\"$header: $value\"",
",",
"false",
")",
";",
"}",
"}",
"echo",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"}"
] |
Utility function to emit a Response without additional framework.
|
[
"Utility",
"function",
"to",
"emit",
"a",
"Response",
"without",
"additional",
"framework",
"."
] |
3a9e82d875bed409c129401b4bee9285562db265
|
https://github.com/gbv/jskos-http/blob/3a9e82d875bed409c129401b4bee9285562db265/src/Server.php#L168-L184
|
239,303
|
PowerOnSystem/HelperService
|
src/UrlHelper.php
|
UrlHelper.configure
|
public function configure(array $config = []) {
$this->_config = [
'request_path' => filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING),
'request_queries' => filter_input(INPUT_SERVER, 'QUERY_STRINGS', FILTER_SANITIZE_STRING),
'request_controller' => FALSE,
'request_action' => FALSE,
'root_dir' => NULL,
'default_controller' => 'index',
'default_action' => 'index'
] + $config;
if ( $this->_config['request_controller'] === FALSE || $this->_config['request_action'] === FALSE) {
$url = explode('/', $this->_config['request_path']);
$this->_config['request_controller'] = array_shift($url);
$this->_config['request_action'] = array_shift($url);
}
}
|
php
|
public function configure(array $config = []) {
$this->_config = [
'request_path' => filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_STRING),
'request_queries' => filter_input(INPUT_SERVER, 'QUERY_STRINGS', FILTER_SANITIZE_STRING),
'request_controller' => FALSE,
'request_action' => FALSE,
'root_dir' => NULL,
'default_controller' => 'index',
'default_action' => 'index'
] + $config;
if ( $this->_config['request_controller'] === FALSE || $this->_config['request_action'] === FALSE) {
$url = explode('/', $this->_config['request_path']);
$this->_config['request_controller'] = array_shift($url);
$this->_config['request_action'] = array_shift($url);
}
}
|
[
"public",
"function",
"configure",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"_config",
"=",
"[",
"'request_path'",
"=>",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'REQUEST_URI'",
",",
"FILTER_SANITIZE_STRING",
")",
",",
"'request_queries'",
"=>",
"filter_input",
"(",
"INPUT_SERVER",
",",
"'QUERY_STRINGS'",
",",
"FILTER_SANITIZE_STRING",
")",
",",
"'request_controller'",
"=>",
"FALSE",
",",
"'request_action'",
"=>",
"FALSE",
",",
"'root_dir'",
"=>",
"NULL",
",",
"'default_controller'",
"=>",
"'index'",
",",
"'default_action'",
"=>",
"'index'",
"]",
"+",
"$",
"config",
";",
"if",
"(",
"$",
"this",
"->",
"_config",
"[",
"'request_controller'",
"]",
"===",
"FALSE",
"||",
"$",
"this",
"->",
"_config",
"[",
"'request_action'",
"]",
"===",
"FALSE",
")",
"{",
"$",
"url",
"=",
"explode",
"(",
"'/'",
",",
"$",
"this",
"->",
"_config",
"[",
"'request_path'",
"]",
")",
";",
"$",
"this",
"->",
"_config",
"[",
"'request_controller'",
"]",
"=",
"array_shift",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"_config",
"[",
"'request_action'",
"]",
"=",
"array_shift",
"(",
"$",
"url",
")",
";",
"}",
"}"
] |
Configura el helper actual
@param array $config
|
[
"Configura",
"el",
"helper",
"actual"
] |
6d300764d7b3a090dd674b25415ce5088156ce8b
|
https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/UrlHelper.php#L34-L50
|
239,304
|
PowerOnSystem/HelperService
|
src/UrlHelper.php
|
UrlHelper.push
|
public function push(array $push = array()) {
$query = array();
if ( key_exists('query', $push) ) {
$query = \CNCService\Core\CNCServiceArrayTrim($push, 'query');
array_walk($query, function(&$v, $k, $path) {
$v = $k . '=' . ($k == 'return' ? base64_encode($path) : $v);
}, $this->_request->full_path);
}
$path = substr($this->_request->path, -1) == '/' ?
substr($this->_request->path, 0, strlen($this->_request->path) - 1) :
$this->_request->path;
return ($this->_config['root_dir'] ? '/' . $this->_config['root_dir'] : '') . '/' . $path . '/' . implode('/', $push) .
( $query ? '/?' . implode('&', $query) : '' );
}
|
php
|
public function push(array $push = array()) {
$query = array();
if ( key_exists('query', $push) ) {
$query = \CNCService\Core\CNCServiceArrayTrim($push, 'query');
array_walk($query, function(&$v, $k, $path) {
$v = $k . '=' . ($k == 'return' ? base64_encode($path) : $v);
}, $this->_request->full_path);
}
$path = substr($this->_request->path, -1) == '/' ?
substr($this->_request->path, 0, strlen($this->_request->path) - 1) :
$this->_request->path;
return ($this->_config['root_dir'] ? '/' . $this->_config['root_dir'] : '') . '/' . $path . '/' . implode('/', $push) .
( $query ? '/?' . implode('&', $query) : '' );
}
|
[
"public",
"function",
"push",
"(",
"array",
"$",
"push",
"=",
"array",
"(",
")",
")",
"{",
"$",
"query",
"=",
"array",
"(",
")",
";",
"if",
"(",
"key_exists",
"(",
"'query'",
",",
"$",
"push",
")",
")",
"{",
"$",
"query",
"=",
"\\",
"CNCService",
"\\",
"Core",
"\\",
"CNCServiceArrayTrim",
"(",
"$",
"push",
",",
"'query'",
")",
";",
"array_walk",
"(",
"$",
"query",
",",
"function",
"(",
"&",
"$",
"v",
",",
"$",
"k",
",",
"$",
"path",
")",
"{",
"$",
"v",
"=",
"$",
"k",
".",
"'='",
".",
"(",
"$",
"k",
"==",
"'return'",
"?",
"base64_encode",
"(",
"$",
"path",
")",
":",
"$",
"v",
")",
";",
"}",
",",
"$",
"this",
"->",
"_request",
"->",
"full_path",
")",
";",
"}",
"$",
"path",
"=",
"substr",
"(",
"$",
"this",
"->",
"_request",
"->",
"path",
",",
"-",
"1",
")",
"==",
"'/'",
"?",
"substr",
"(",
"$",
"this",
"->",
"_request",
"->",
"path",
",",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"_request",
"->",
"path",
")",
"-",
"1",
")",
":",
"$",
"this",
"->",
"_request",
"->",
"path",
";",
"return",
"(",
"$",
"this",
"->",
"_config",
"[",
"'root_dir'",
"]",
"?",
"'/'",
".",
"$",
"this",
"->",
"_config",
"[",
"'root_dir'",
"]",
":",
"''",
")",
".",
"'/'",
".",
"$",
"path",
".",
"'/'",
".",
"implode",
"(",
"'/'",
",",
"$",
"push",
")",
".",
"(",
"$",
"query",
"?",
"'/?'",
".",
"implode",
"(",
"'&'",
",",
"$",
"query",
")",
":",
"''",
")",
";",
"}"
] |
Agrega un valor al final de la url
@param array $push la URL a agregar al final
@return string
|
[
"Agrega",
"un",
"valor",
"al",
"final",
"de",
"la",
"url"
] |
6d300764d7b3a090dd674b25415ce5088156ce8b
|
https://github.com/PowerOnSystem/HelperService/blob/6d300764d7b3a090dd674b25415ce5088156ce8b/src/UrlHelper.php#L148-L161
|
239,305
|
sellerlabs/nucleus
|
src/SellerLabs/Nucleus/Hashing/HmacHasher.php
|
HmacHasher.hash
|
public function hash($content, $privateKey)
{
Arguments::define(Boa::string(), Boa::string())
->check($content, $privateKey);
return hash_hmac($this->algorithm, $content, $privateKey);
}
|
php
|
public function hash($content, $privateKey)
{
Arguments::define(Boa::string(), Boa::string())
->check($content, $privateKey);
return hash_hmac($this->algorithm, $content, $privateKey);
}
|
[
"public",
"function",
"hash",
"(",
"$",
"content",
",",
"$",
"privateKey",
")",
"{",
"Arguments",
"::",
"define",
"(",
"Boa",
"::",
"string",
"(",
")",
",",
"Boa",
"::",
"string",
"(",
")",
")",
"->",
"check",
"(",
"$",
"content",
",",
"$",
"privateKey",
")",
";",
"return",
"hash_hmac",
"(",
"$",
"this",
"->",
"algorithm",
",",
"$",
"content",
",",
"$",
"privateKey",
")",
";",
"}"
] |
Generate a hash of the content using the provided private key.
@param string $content
@param string $privateKey
@return string
|
[
"Generate",
"a",
"hash",
"of",
"the",
"content",
"using",
"the",
"provided",
"private",
"key",
"."
] |
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
|
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Hashing/HmacHasher.php#L63-L69
|
239,306
|
BlueBearGaming/BaseBundle
|
Behavior/ControllerTrait.php
|
ControllerTrait.redirect
|
public function redirect($url, $parameters = [], $status = 302)
{
if (substr($url, 0, 1) == '@') {
$route = substr($url, 1);
$url = $this->generateUrl($route, $parameters);
}
return new RedirectResponse($url, $status);
}
|
php
|
public function redirect($url, $parameters = [], $status = 302)
{
if (substr($url, 0, 1) == '@') {
$route = substr($url, 1);
$url = $this->generateUrl($route, $parameters);
}
return new RedirectResponse($url, $status);
}
|
[
"public",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"parameters",
"=",
"[",
"]",
",",
"$",
"status",
"=",
"302",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"1",
")",
"==",
"'@'",
")",
"{",
"$",
"route",
"=",
"substr",
"(",
"$",
"url",
",",
"1",
")",
";",
"$",
"url",
"=",
"$",
"this",
"->",
"generateUrl",
"(",
"$",
"route",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"new",
"RedirectResponse",
"(",
"$",
"url",
",",
"$",
"status",
")",
";",
"}"
] |
Redirect response to an url or a route
@param string $url
@param array $parameters
@param int $status
@return RedirectResponse
|
[
"Redirect",
"response",
"to",
"an",
"url",
"or",
"a",
"route"
] |
a835a217fecb53fa6d12ae3e068d12649e8d04c4
|
https://github.com/BlueBearGaming/BaseBundle/blob/a835a217fecb53fa6d12ae3e068d12649e8d04c4/Behavior/ControllerTrait.php#L65-L72
|
239,307
|
BlueBearGaming/BaseBundle
|
Behavior/ControllerTrait.php
|
ControllerTrait.setMessage
|
public function setMessage($message, $type = 'info', $parameters = [])
{
$this->getSession()->getFlashBag()->add($type, $this->translate($message, $parameters));
}
|
php
|
public function setMessage($message, $type = 'info', $parameters = [])
{
$this->getSession()->getFlashBag()->add($type, $this->translate($message, $parameters));
}
|
[
"public",
"function",
"setMessage",
"(",
"$",
"message",
",",
"$",
"type",
"=",
"'info'",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"getFlashBag",
"(",
")",
"->",
"add",
"(",
"$",
"type",
",",
"$",
"this",
"->",
"translate",
"(",
"$",
"message",
",",
"$",
"parameters",
")",
")",
";",
"}"
] |
Set a flash notice in session for next request. The message is translated
@param $message
@param string $type
@param array $parameters
|
[
"Set",
"a",
"flash",
"notice",
"in",
"session",
"for",
"next",
"request",
".",
"The",
"message",
"is",
"translated"
] |
a835a217fecb53fa6d12ae3e068d12649e8d04c4
|
https://github.com/BlueBearGaming/BaseBundle/blob/a835a217fecb53fa6d12ae3e068d12649e8d04c4/Behavior/ControllerTrait.php#L81-L84
|
239,308
|
Rockbeat-Sky/framework
|
src/core/Loader.php
|
Loader.getClass
|
static function getClass($namespace = '',$config = [],$new = false){
if($namespace == ''){
return self::$instance;
}
if($new === false && isset(self::$instance[$namespace])){
return self::$instance[$namespace];
}
$ns = self::getName($namespace);
self::$instance[$namespace] = new $ns->namespace($config);
return self::$instance[$namespace] ;
}
|
php
|
static function getClass($namespace = '',$config = [],$new = false){
if($namespace == ''){
return self::$instance;
}
if($new === false && isset(self::$instance[$namespace])){
return self::$instance[$namespace];
}
$ns = self::getName($namespace);
self::$instance[$namespace] = new $ns->namespace($config);
return self::$instance[$namespace] ;
}
|
[
"static",
"function",
"getClass",
"(",
"$",
"namespace",
"=",
"''",
",",
"$",
"config",
"=",
"[",
"]",
",",
"$",
"new",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"namespace",
"==",
"''",
")",
"{",
"return",
"self",
"::",
"$",
"instance",
";",
"}",
"if",
"(",
"$",
"new",
"===",
"false",
"&&",
"isset",
"(",
"self",
"::",
"$",
"instance",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"instance",
"[",
"$",
"namespace",
"]",
";",
"}",
"$",
"ns",
"=",
"self",
"::",
"getName",
"(",
"$",
"namespace",
")",
";",
"self",
"::",
"$",
"instance",
"[",
"$",
"namespace",
"]",
"=",
"new",
"$",
"ns",
"->",
"namespace",
"(",
"$",
"config",
")",
";",
"return",
"self",
"::",
"$",
"instance",
"[",
"$",
"namespace",
"]",
";",
"}"
] |
create or get Class
@param string
@param array
@param string
@return mix
|
[
"create",
"or",
"get",
"Class"
] |
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
|
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Loader.php#L52-L67
|
239,309
|
Rockbeat-Sky/framework
|
src/core/Loader.php
|
Loader.setEnvironment
|
static function setEnvironment($data = []){
if($data && is_array($data)){
self::$env = $data;
return;
}
// Check environment is set?
if(count(self::$env ) == 0){
self::$env = (require APP_PATH.'config' . DS . 'Environment.php');
}
}
|
php
|
static function setEnvironment($data = []){
if($data && is_array($data)){
self::$env = $data;
return;
}
// Check environment is set?
if(count(self::$env ) == 0){
self::$env = (require APP_PATH.'config' . DS . 'Environment.php');
}
}
|
[
"static",
"function",
"setEnvironment",
"(",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"data",
"&&",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"self",
"::",
"$",
"env",
"=",
"$",
"data",
";",
"return",
";",
"}",
"// Check environment is set?",
"if",
"(",
"count",
"(",
"self",
"::",
"$",
"env",
")",
"==",
"0",
")",
"{",
"self",
"::",
"$",
"env",
"=",
"(",
"require",
"APP_PATH",
".",
"'config'",
".",
"DS",
".",
"'Environment.php'",
")",
";",
"}",
"}"
] |
set environment path
if param not set or environment not set it will load from config Environment.php
@param array
@return void
|
[
"set",
"environment",
"path",
"if",
"param",
"not",
"set",
"or",
"environment",
"not",
"set",
"it",
"will",
"load",
"from",
"config",
"Environment",
".",
"php"
] |
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
|
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Loader.php#L75-L86
|
239,310
|
Rockbeat-Sky/framework
|
src/core/Loader.php
|
Loader.getName
|
static function getName($namespace,$folder = ''){
// is namespace empty?
if($namespace == ''){
user_error('No Namespace');
exit;
}
self::setEnvironment();
// check environment have data?
if(count(self::$env) == 0){
user_error('Environment Registry is empty');
exit;
}
$segments = preg_split('/(\.|\\\\)/',$namespace);
$appname = $segments[0];
if($folder !== ''){
array_splice($segments,1,0,[$folder]);
}
$path = VENDOR_PATH;
if(isset(self::$env[$appname])){
$path = self::$env[$appname];
}
// remove first array
array_shift($segments);
$p = implode(DS,$segments);
$name = (object)[
'app' => $appname,
'namespace' => '\\'.$appname.'\\'.str_replace('/','\\',$p),
'class' => end($segments),
'path' => $path . $p. '.php',
'segments' => $segments
];
return $name;
}
|
php
|
static function getName($namespace,$folder = ''){
// is namespace empty?
if($namespace == ''){
user_error('No Namespace');
exit;
}
self::setEnvironment();
// check environment have data?
if(count(self::$env) == 0){
user_error('Environment Registry is empty');
exit;
}
$segments = preg_split('/(\.|\\\\)/',$namespace);
$appname = $segments[0];
if($folder !== ''){
array_splice($segments,1,0,[$folder]);
}
$path = VENDOR_PATH;
if(isset(self::$env[$appname])){
$path = self::$env[$appname];
}
// remove first array
array_shift($segments);
$p = implode(DS,$segments);
$name = (object)[
'app' => $appname,
'namespace' => '\\'.$appname.'\\'.str_replace('/','\\',$p),
'class' => end($segments),
'path' => $path . $p. '.php',
'segments' => $segments
];
return $name;
}
|
[
"static",
"function",
"getName",
"(",
"$",
"namespace",
",",
"$",
"folder",
"=",
"''",
")",
"{",
"// is namespace empty?",
"if",
"(",
"$",
"namespace",
"==",
"''",
")",
"{",
"user_error",
"(",
"'No Namespace'",
")",
";",
"exit",
";",
"}",
"self",
"::",
"setEnvironment",
"(",
")",
";",
"// check environment have data?",
"if",
"(",
"count",
"(",
"self",
"::",
"$",
"env",
")",
"==",
"0",
")",
"{",
"user_error",
"(",
"'Environment Registry is empty'",
")",
";",
"exit",
";",
"}",
"$",
"segments",
"=",
"preg_split",
"(",
"'/(\\.|\\\\\\\\)/'",
",",
"$",
"namespace",
")",
";",
"$",
"appname",
"=",
"$",
"segments",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"folder",
"!==",
"''",
")",
"{",
"array_splice",
"(",
"$",
"segments",
",",
"1",
",",
"0",
",",
"[",
"$",
"folder",
"]",
")",
";",
"}",
"$",
"path",
"=",
"VENDOR_PATH",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"env",
"[",
"$",
"appname",
"]",
")",
")",
"{",
"$",
"path",
"=",
"self",
"::",
"$",
"env",
"[",
"$",
"appname",
"]",
";",
"}",
"// remove first array",
"array_shift",
"(",
"$",
"segments",
")",
";",
"$",
"p",
"=",
"implode",
"(",
"DS",
",",
"$",
"segments",
")",
";",
"$",
"name",
"=",
"(",
"object",
")",
"[",
"'app'",
"=>",
"$",
"appname",
",",
"'namespace'",
"=>",
"'\\\\'",
".",
"$",
"appname",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'/'",
",",
"'\\\\'",
",",
"$",
"p",
")",
",",
"'class'",
"=>",
"end",
"(",
"$",
"segments",
")",
",",
"'path'",
"=>",
"$",
"path",
".",
"$",
"p",
".",
"'.php'",
",",
"'segments'",
"=>",
"$",
"segments",
"]",
";",
"return",
"$",
"name",
";",
"}"
] |
parse name class
@param string
@param string
@return object
|
[
"parse",
"name",
"class"
] |
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
|
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Loader.php#L94-L135
|
239,311
|
Rockbeat-Sky/framework
|
src/core/Loader.php
|
Loader.addInstance
|
static function addInstance($object){
$name = str_replace(DS,'.',get_class($object));
self::$instance[$name] = $object;
}
|
php
|
static function addInstance($object){
$name = str_replace(DS,'.',get_class($object));
self::$instance[$name] = $object;
}
|
[
"static",
"function",
"addInstance",
"(",
"$",
"object",
")",
"{",
"$",
"name",
"=",
"str_replace",
"(",
"DS",
",",
"'.'",
",",
"get_class",
"(",
"$",
"object",
")",
")",
";",
"self",
"::",
"$",
"instance",
"[",
"$",
"name",
"]",
"=",
"$",
"object",
";",
"}"
] |
add push instance class
@param object class
@return void
|
[
"add",
"push",
"instance",
"class"
] |
e8ffd04f2fdc27a62b185b342f32bf58899ceda4
|
https://github.com/Rockbeat-Sky/framework/blob/e8ffd04f2fdc27a62b185b342f32bf58899ceda4/src/core/Loader.php#L142-L145
|
239,312
|
vyctory/attila-orm
|
Attila/core/Entity.php
|
Entity.remove
|
public function remove()
{
$mPrimaryKeyName = $this->_mPrimaryKeyName;
$bInsertMode = false;
if ($mPrimaryKeyName === false) {
throw new Exception('['.__FILE__.' (l.'.__LINE__.'] no primary key on this table!');
}
else if (is_string($mPrimaryKeyName)) {
$sMethodPrimaryKey = 'get_'.$this->_mPrimaryKeyNameWithoutMapping;
$aPrimaryKey = array($mPrimaryKeyName => $this->$sMethodPrimaryKey());
}
else {
$aPrimaryKey = array();
foreach($mPrimaryKeyName as $sKey => $sPrimaryKey) {
$sMethodPrimaryKey = 'get_'.$this->_mPrimaryKeyNameWithoutMapping[$sKey];
$aPrimaryKey[$sPrimaryKey] = $this->$sMethodPrimaryKey();
}
}
/**
* check if the virtual foreign key in this model is respected
*/
if (count($this->_aForeignKey) > 0) {
foreach ($this->_aForeignKey as $sName => $aForeignKey) {
if ($aForeignKey['has_one'] == 1 && isset($aForeignKey['foreign_key_options']['action'])
&& $aForeignKey['foreign_key_options']['action'] == self::CASCADE) {
$sMethodPrimaryKey = 'get_'.$aForeignKey['foreign_key'];
$mFIeld = $this->$sMethodPrimaryKey();
if ($mFIeld) {
$oOrm = new Orm;
$iResults = $oOrm->select(array('*'))
->from($aForeignKey['entity_join_name']);
$oWhere = new Where;
$oWhere->whereEqual($aForeignKey['primary_key_name'], $mFIeld);
$aResults = $oOrm->where($oWhere)
->load();
if (count($aResults) > 0) {
$oOrm = new Orm;
$oOrm->delete($aForeignKey['entity_join_name'])
->where($oWhere)
->save();
}
}
}
}
}
$oOrm = new Orm;
$oOrm->delete(preg_replace('/^.*\\\\([a-zA-Z0-9_]+)$/', '$1', get_called_class()))
->where($aPrimaryKey)
->save();
return $this;
}
|
php
|
public function remove()
{
$mPrimaryKeyName = $this->_mPrimaryKeyName;
$bInsertMode = false;
if ($mPrimaryKeyName === false) {
throw new Exception('['.__FILE__.' (l.'.__LINE__.'] no primary key on this table!');
}
else if (is_string($mPrimaryKeyName)) {
$sMethodPrimaryKey = 'get_'.$this->_mPrimaryKeyNameWithoutMapping;
$aPrimaryKey = array($mPrimaryKeyName => $this->$sMethodPrimaryKey());
}
else {
$aPrimaryKey = array();
foreach($mPrimaryKeyName as $sKey => $sPrimaryKey) {
$sMethodPrimaryKey = 'get_'.$this->_mPrimaryKeyNameWithoutMapping[$sKey];
$aPrimaryKey[$sPrimaryKey] = $this->$sMethodPrimaryKey();
}
}
/**
* check if the virtual foreign key in this model is respected
*/
if (count($this->_aForeignKey) > 0) {
foreach ($this->_aForeignKey as $sName => $aForeignKey) {
if ($aForeignKey['has_one'] == 1 && isset($aForeignKey['foreign_key_options']['action'])
&& $aForeignKey['foreign_key_options']['action'] == self::CASCADE) {
$sMethodPrimaryKey = 'get_'.$aForeignKey['foreign_key'];
$mFIeld = $this->$sMethodPrimaryKey();
if ($mFIeld) {
$oOrm = new Orm;
$iResults = $oOrm->select(array('*'))
->from($aForeignKey['entity_join_name']);
$oWhere = new Where;
$oWhere->whereEqual($aForeignKey['primary_key_name'], $mFIeld);
$aResults = $oOrm->where($oWhere)
->load();
if (count($aResults) > 0) {
$oOrm = new Orm;
$oOrm->delete($aForeignKey['entity_join_name'])
->where($oWhere)
->save();
}
}
}
}
}
$oOrm = new Orm;
$oOrm->delete(preg_replace('/^.*\\\\([a-zA-Z0-9_]+)$/', '$1', get_called_class()))
->where($aPrimaryKey)
->save();
return $this;
}
|
[
"public",
"function",
"remove",
"(",
")",
"{",
"$",
"mPrimaryKeyName",
"=",
"$",
"this",
"->",
"_mPrimaryKeyName",
";",
"$",
"bInsertMode",
"=",
"false",
";",
"if",
"(",
"$",
"mPrimaryKeyName",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'['",
".",
"__FILE__",
".",
"' (l.'",
".",
"__LINE__",
".",
"'] no primary key on this table!'",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"mPrimaryKeyName",
")",
")",
"{",
"$",
"sMethodPrimaryKey",
"=",
"'get_'",
".",
"$",
"this",
"->",
"_mPrimaryKeyNameWithoutMapping",
";",
"$",
"aPrimaryKey",
"=",
"array",
"(",
"$",
"mPrimaryKeyName",
"=>",
"$",
"this",
"->",
"$",
"sMethodPrimaryKey",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"aPrimaryKey",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"mPrimaryKeyName",
"as",
"$",
"sKey",
"=>",
"$",
"sPrimaryKey",
")",
"{",
"$",
"sMethodPrimaryKey",
"=",
"'get_'",
".",
"$",
"this",
"->",
"_mPrimaryKeyNameWithoutMapping",
"[",
"$",
"sKey",
"]",
";",
"$",
"aPrimaryKey",
"[",
"$",
"sPrimaryKey",
"]",
"=",
"$",
"this",
"->",
"$",
"sMethodPrimaryKey",
"(",
")",
";",
"}",
"}",
"/**\n * check if the virtual foreign key in this model is respected\n */",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"_aForeignKey",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_aForeignKey",
"as",
"$",
"sName",
"=>",
"$",
"aForeignKey",
")",
"{",
"if",
"(",
"$",
"aForeignKey",
"[",
"'has_one'",
"]",
"==",
"1",
"&&",
"isset",
"(",
"$",
"aForeignKey",
"[",
"'foreign_key_options'",
"]",
"[",
"'action'",
"]",
")",
"&&",
"$",
"aForeignKey",
"[",
"'foreign_key_options'",
"]",
"[",
"'action'",
"]",
"==",
"self",
"::",
"CASCADE",
")",
"{",
"$",
"sMethodPrimaryKey",
"=",
"'get_'",
".",
"$",
"aForeignKey",
"[",
"'foreign_key'",
"]",
";",
"$",
"mFIeld",
"=",
"$",
"this",
"->",
"$",
"sMethodPrimaryKey",
"(",
")",
";",
"if",
"(",
"$",
"mFIeld",
")",
"{",
"$",
"oOrm",
"=",
"new",
"Orm",
";",
"$",
"iResults",
"=",
"$",
"oOrm",
"->",
"select",
"(",
"array",
"(",
"'*'",
")",
")",
"->",
"from",
"(",
"$",
"aForeignKey",
"[",
"'entity_join_name'",
"]",
")",
";",
"$",
"oWhere",
"=",
"new",
"Where",
";",
"$",
"oWhere",
"->",
"whereEqual",
"(",
"$",
"aForeignKey",
"[",
"'primary_key_name'",
"]",
",",
"$",
"mFIeld",
")",
";",
"$",
"aResults",
"=",
"$",
"oOrm",
"->",
"where",
"(",
"$",
"oWhere",
")",
"->",
"load",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"aResults",
")",
">",
"0",
")",
"{",
"$",
"oOrm",
"=",
"new",
"Orm",
";",
"$",
"oOrm",
"->",
"delete",
"(",
"$",
"aForeignKey",
"[",
"'entity_join_name'",
"]",
")",
"->",
"where",
"(",
"$",
"oWhere",
")",
"->",
"save",
"(",
")",
";",
"}",
"}",
"}",
"}",
"}",
"$",
"oOrm",
"=",
"new",
"Orm",
";",
"$",
"oOrm",
"->",
"delete",
"(",
"preg_replace",
"(",
"'/^.*\\\\\\\\([a-zA-Z0-9_]+)$/'",
",",
"'$1'",
",",
"get_called_class",
"(",
")",
")",
")",
"->",
"where",
"(",
"$",
"aPrimaryKey",
")",
"->",
"save",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
You could remove this entity
@access public
@return object
|
[
"You",
"could",
"remove",
"this",
"entity"
] |
2cd28e0134d8a881cf8390a0a95c74314b7e71c6
|
https://github.com/vyctory/attila-orm/blob/2cd28e0134d8a881cf8390a0a95c74314b7e71c6/Attila/core/Entity.php#L329-L401
|
239,313
|
cjario/omniship-common
|
src/Common/CarrierFactory.php
|
CarrierFactory.create
|
public function create($class, ClientInterface $httpClient = null, HttpRequest $httpRequest = null)
{
$class = Helper::getCarrierClassName($class);
if (!class_exists($class)) {
throw new RuntimeException("Class '$class' not found");
}
return new $class($httpClient, $httpRequest);
}
|
php
|
public function create($class, ClientInterface $httpClient = null, HttpRequest $httpRequest = null)
{
$class = Helper::getCarrierClassName($class);
if (!class_exists($class)) {
throw new RuntimeException("Class '$class' not found");
}
return new $class($httpClient, $httpRequest);
}
|
[
"public",
"function",
"create",
"(",
"$",
"class",
",",
"ClientInterface",
"$",
"httpClient",
"=",
"null",
",",
"HttpRequest",
"$",
"httpRequest",
"=",
"null",
")",
"{",
"$",
"class",
"=",
"Helper",
"::",
"getCarrierClassName",
"(",
"$",
"class",
")",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Class '$class' not found\"",
")",
";",
"}",
"return",
"new",
"$",
"class",
"(",
"$",
"httpClient",
",",
"$",
"httpRequest",
")",
";",
"}"
] |
Create a new carrier instance
@param string $class Carrier name
@param ClientInterface|null $httpClient A HTTP Client implementation
@param HttpRequest|null $httpRequest A Symfony HTTP Request implementation
@throws RuntimeException If no such carrier is found
@return CarrierInterface An object of class $class is created and returned
|
[
"Create",
"a",
"new",
"carrier",
"instance"
] |
5b89655950bd058d6bc14e6b3ae0fbd2d6150d72
|
https://github.com/cjario/omniship-common/blob/5b89655950bd058d6bc14e6b3ae0fbd2d6150d72/src/Common/CarrierFactory.php#L81-L90
|
239,314
|
SocietyCMS/Core
|
Services/Composer.php
|
Composer.enableOutput
|
public function enableOutput($command)
{
$this->output = function ($type, $buffer) use ($command) {
if (Process::ERR === $type) {
$command->info(trim('[ERR] > '.$buffer));
} else {
$command->info(trim('> '.$buffer));
}
};
}
|
php
|
public function enableOutput($command)
{
$this->output = function ($type, $buffer) use ($command) {
if (Process::ERR === $type) {
$command->info(trim('[ERR] > '.$buffer));
} else {
$command->info(trim('> '.$buffer));
}
};
}
|
[
"public",
"function",
"enableOutput",
"(",
"$",
"command",
")",
"{",
"$",
"this",
"->",
"output",
"=",
"function",
"(",
"$",
"type",
",",
"$",
"buffer",
")",
"use",
"(",
"$",
"command",
")",
"{",
"if",
"(",
"Process",
"::",
"ERR",
"===",
"$",
"type",
")",
"{",
"$",
"command",
"->",
"info",
"(",
"trim",
"(",
"'[ERR] > '",
".",
"$",
"buffer",
")",
")",
";",
"}",
"else",
"{",
"$",
"command",
"->",
"info",
"(",
"trim",
"(",
"'> '",
".",
"$",
"buffer",
")",
")",
";",
"}",
"}",
";",
"}"
] |
Enable real time output of all commands.
@param $command
@return void
|
[
"Enable",
"real",
"time",
"output",
"of",
"all",
"commands",
"."
] |
fb6be1b1dd46c89a976c02feb998e9af01ddca54
|
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Services/Composer.php#L28-L37
|
239,315
|
SocietyCMS/Core
|
Services/Composer.php
|
Composer.update
|
public function update($package = null)
{
if (! is_null($package)) {
$package = '"'.$package.'"';
}
$process = $this->getProcess();
$process->setCommandLine(trim($this->findComposer().' update '.$package));
$process->run($this->output);
}
|
php
|
public function update($package = null)
{
if (! is_null($package)) {
$package = '"'.$package.'"';
}
$process = $this->getProcess();
$process->setCommandLine(trim($this->findComposer().' update '.$package));
$process->run($this->output);
}
|
[
"public",
"function",
"update",
"(",
"$",
"package",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"package",
")",
")",
"{",
"$",
"package",
"=",
"'\"'",
".",
"$",
"package",
".",
"'\"'",
";",
"}",
"$",
"process",
"=",
"$",
"this",
"->",
"getProcess",
"(",
")",
";",
"$",
"process",
"->",
"setCommandLine",
"(",
"trim",
"(",
"$",
"this",
"->",
"findComposer",
"(",
")",
".",
"' update '",
".",
"$",
"package",
")",
")",
";",
"$",
"process",
"->",
"run",
"(",
"$",
"this",
"->",
"output",
")",
";",
"}"
] |
Update all composer packages.
@param string $package
@return void
|
[
"Update",
"all",
"composer",
"packages",
"."
] |
fb6be1b1dd46c89a976c02feb998e9af01ddca54
|
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Services/Composer.php#L56-L64
|
239,316
|
SocietyCMS/Core
|
Services/Composer.php
|
Composer.install
|
public function install($package)
{
if (! is_null($package)) {
$package = '"'.$package.'"';
}
$process = $this->getProcess();
$process->setCommandLine(trim($this->findComposer().' require '.$package));
$process->run($this->output);
}
|
php
|
public function install($package)
{
if (! is_null($package)) {
$package = '"'.$package.'"';
}
$process = $this->getProcess();
$process->setCommandLine(trim($this->findComposer().' require '.$package));
$process->run($this->output);
}
|
[
"public",
"function",
"install",
"(",
"$",
"package",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"package",
")",
")",
"{",
"$",
"package",
"=",
"'\"'",
".",
"$",
"package",
".",
"'\"'",
";",
"}",
"$",
"process",
"=",
"$",
"this",
"->",
"getProcess",
"(",
")",
";",
"$",
"process",
"->",
"setCommandLine",
"(",
"trim",
"(",
"$",
"this",
"->",
"findComposer",
"(",
")",
".",
"' require '",
".",
"$",
"package",
")",
")",
";",
"$",
"process",
"->",
"run",
"(",
"$",
"this",
"->",
"output",
")",
";",
"}"
] |
Require a new composer package.
@param string $package
@return void
|
[
"Require",
"a",
"new",
"composer",
"package",
"."
] |
fb6be1b1dd46c89a976c02feb998e9af01ddca54
|
https://github.com/SocietyCMS/Core/blob/fb6be1b1dd46c89a976c02feb998e9af01ddca54/Services/Composer.php#L73-L81
|
239,317
|
gentry-php/gentry
|
src/ClassWrapper.php
|
ClassWrapper.__gentryConstruct
|
public function __gentryConstruct(...$args) : void
{
try {
if (method_exists(get_parent_class($this), '__construct')) {
parent::__construct(...$args);
}
} catch (Throwable $e) {
}
}
|
php
|
public function __gentryConstruct(...$args) : void
{
try {
if (method_exists(get_parent_class($this), '__construct')) {
parent::__construct(...$args);
}
} catch (Throwable $e) {
}
}
|
[
"public",
"function",
"__gentryConstruct",
"(",
"...",
"$",
"args",
")",
":",
"void",
"{",
"try",
"{",
"if",
"(",
"method_exists",
"(",
"get_parent_class",
"(",
"$",
"this",
")",
",",
"'__construct'",
")",
")",
"{",
"parent",
"::",
"__construct",
"(",
"...",
"$",
"args",
")",
";",
"}",
"}",
"catch",
"(",
"Throwable",
"$",
"e",
")",
"{",
"}",
"}"
] |
Constructor delegate.
@param mixed ...$args
@return void
|
[
"Constructor",
"delegate",
"."
] |
1e6a909f63cdf653e640540b116c92885c3329cf
|
https://github.com/gentry-php/gentry/blob/1e6a909f63cdf653e640540b116c92885c3329cf/src/ClassWrapper.php#L21-L29
|
239,318
|
gentry-php/gentry
|
src/ClassWrapper.php
|
ClassWrapper.__gentryLogMethodCall
|
public static function __gentryLogMethodCall(string $method, string $class = null, array $args = []) : void
{
if (!$class) {
$class = (new ReflectionClass(get_called_class()))
->getParentClass()
->name;
}
$logger = Logger::getInstance();
$reflection = new ReflectionMethod($class, $method);
$parameters = $reflection->getParameters();
array_walk($args, function (&$arg, $i) use ($reflection, $parameters) {
if (isset($parameters[$i])) {
$arg = $parameters[$i]->getNormalisedType($arg);
} else {
$j = $i;
$arg = 'unknown';
while ($j > 0) {
if (isset($parameters[--$j])) {
$arg = $parameters[$j]->getNormalisedType($arg);
break;
}
}
}
});
$logger->logFeature($class, $method, $args);
}
|
php
|
public static function __gentryLogMethodCall(string $method, string $class = null, array $args = []) : void
{
if (!$class) {
$class = (new ReflectionClass(get_called_class()))
->getParentClass()
->name;
}
$logger = Logger::getInstance();
$reflection = new ReflectionMethod($class, $method);
$parameters = $reflection->getParameters();
array_walk($args, function (&$arg, $i) use ($reflection, $parameters) {
if (isset($parameters[$i])) {
$arg = $parameters[$i]->getNormalisedType($arg);
} else {
$j = $i;
$arg = 'unknown';
while ($j > 0) {
if (isset($parameters[--$j])) {
$arg = $parameters[$j]->getNormalisedType($arg);
break;
}
}
}
});
$logger->logFeature($class, $method, $args);
}
|
[
"public",
"static",
"function",
"__gentryLogMethodCall",
"(",
"string",
"$",
"method",
",",
"string",
"$",
"class",
"=",
"null",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
":",
"void",
"{",
"if",
"(",
"!",
"$",
"class",
")",
"{",
"$",
"class",
"=",
"(",
"new",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
")",
"->",
"getParentClass",
"(",
")",
"->",
"name",
";",
"}",
"$",
"logger",
"=",
"Logger",
"::",
"getInstance",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"method",
")",
";",
"$",
"parameters",
"=",
"$",
"reflection",
"->",
"getParameters",
"(",
")",
";",
"array_walk",
"(",
"$",
"args",
",",
"function",
"(",
"&",
"$",
"arg",
",",
"$",
"i",
")",
"use",
"(",
"$",
"reflection",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"arg",
"=",
"$",
"parameters",
"[",
"$",
"i",
"]",
"->",
"getNormalisedType",
"(",
"$",
"arg",
")",
";",
"}",
"else",
"{",
"$",
"j",
"=",
"$",
"i",
";",
"$",
"arg",
"=",
"'unknown'",
";",
"while",
"(",
"$",
"j",
">",
"0",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"--",
"$",
"j",
"]",
")",
")",
"{",
"$",
"arg",
"=",
"$",
"parameters",
"[",
"$",
"j",
"]",
"->",
"getNormalisedType",
"(",
"$",
"arg",
")",
";",
"break",
";",
"}",
"}",
"}",
"}",
")",
";",
"$",
"logger",
"->",
"logFeature",
"(",
"$",
"class",
",",
"$",
"method",
",",
"$",
"args",
")",
";",
"}"
] |
Logs a method call so Gentry can determine untested methods. Mostly used
internally by gentry.
@param string $method Method name
@param string|null $class Optional classname. Default to the parent of
the current class.
@param array $args Optional array of arguments.
@return void
|
[
"Logs",
"a",
"method",
"call",
"so",
"Gentry",
"can",
"determine",
"untested",
"methods",
".",
"Mostly",
"used",
"internally",
"by",
"gentry",
"."
] |
1e6a909f63cdf653e640540b116c92885c3329cf
|
https://github.com/gentry-php/gentry/blob/1e6a909f63cdf653e640540b116c92885c3329cf/src/ClassWrapper.php#L41-L66
|
239,319
|
phlexible/phlexible
|
src/Phlexible/Component/Util/ArrayUtil.php
|
ArrayUtil.column
|
public function column(array $src, $column, $skip = false, $skipEmpty = false)
{
$result = array();
// process each row
foreach ($src as $key => $row) {
// if current row is an array and the specified column exists
// store column value otherwise null
if (is_array($row) && array_key_exists($column, $row)) {
if (!$skipEmpty || !empty($row[$column])) {
$result[$key] = $row[$column];
}
} else {
// skip not existing values ...
if (!$skip) {
// ... or add null
$result[$key] = null;
}
}
}
return $result;
}
|
php
|
public function column(array $src, $column, $skip = false, $skipEmpty = false)
{
$result = array();
// process each row
foreach ($src as $key => $row) {
// if current row is an array and the specified column exists
// store column value otherwise null
if (is_array($row) && array_key_exists($column, $row)) {
if (!$skipEmpty || !empty($row[$column])) {
$result[$key] = $row[$column];
}
} else {
// skip not existing values ...
if (!$skip) {
// ... or add null
$result[$key] = null;
}
}
}
return $result;
}
|
[
"public",
"function",
"column",
"(",
"array",
"$",
"src",
",",
"$",
"column",
",",
"$",
"skip",
"=",
"false",
",",
"$",
"skipEmpty",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"// process each row",
"foreach",
"(",
"$",
"src",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"// if current row is an array and the specified column exists",
"// store column value otherwise null",
"if",
"(",
"is_array",
"(",
"$",
"row",
")",
"&&",
"array_key_exists",
"(",
"$",
"column",
",",
"$",
"row",
")",
")",
"{",
"if",
"(",
"!",
"$",
"skipEmpty",
"||",
"!",
"empty",
"(",
"$",
"row",
"[",
"$",
"column",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"row",
"[",
"$",
"column",
"]",
";",
"}",
"}",
"else",
"{",
"// skip not existing values ...",
"if",
"(",
"!",
"$",
"skip",
")",
"{",
"// ... or add null",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Extract one column of an 2-dim array.
@param array $src 2-dim array
@param mixed $column name or index of column to extract
@param bool $skip (Optional) skip not existing values, default: add null
@param bool $skipEmpty (Optional) skip not empty values, default: add null
@return array
|
[
"Extract",
"one",
"column",
"of",
"an",
"2",
"-",
"dim",
"array",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/Util/ArrayUtil.php#L31-L53
|
239,320
|
phlexible/phlexible
|
src/Phlexible/Component/Util/ArrayUtil.php
|
ArrayUtil.groupBy
|
public function groupBy($array, $columns)
{
// ensure $columns parameter is array
$columns = (array) $columns;
// get first group-by column
$col = array_shift($columns);
$result = array();
foreach ($array as $row) {
$key = (string) is_object($row) ? $row->$col : $row[$col];
if (!isset($result[$key])) {
$result[$key] = array();
}
$result[$key][] = $row;
}
// do subsequent group by calls
if (count($columns)) {
foreach (array_keys($result) as $key) {
$result[$key] = $this->groupBy($result[$key], $columns);
}
}
return $result;
}
|
php
|
public function groupBy($array, $columns)
{
// ensure $columns parameter is array
$columns = (array) $columns;
// get first group-by column
$col = array_shift($columns);
$result = array();
foreach ($array as $row) {
$key = (string) is_object($row) ? $row->$col : $row[$col];
if (!isset($result[$key])) {
$result[$key] = array();
}
$result[$key][] = $row;
}
// do subsequent group by calls
if (count($columns)) {
foreach (array_keys($result) as $key) {
$result[$key] = $this->groupBy($result[$key], $columns);
}
}
return $result;
}
|
[
"public",
"function",
"groupBy",
"(",
"$",
"array",
",",
"$",
"columns",
")",
"{",
"// ensure $columns parameter is array",
"$",
"columns",
"=",
"(",
"array",
")",
"$",
"columns",
";",
"// get first group-by column",
"$",
"col",
"=",
"array_shift",
"(",
"$",
"columns",
")",
";",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"row",
")",
"{",
"$",
"key",
"=",
"(",
"string",
")",
"is_object",
"(",
"$",
"row",
")",
"?",
"$",
"row",
"->",
"$",
"col",
":",
"$",
"row",
"[",
"$",
"col",
"]",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"array",
"(",
")",
";",
"}",
"$",
"result",
"[",
"$",
"key",
"]",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"// do subsequent group by calls",
"if",
"(",
"count",
"(",
"$",
"columns",
")",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"$",
"result",
")",
"as",
"$",
"key",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"groupBy",
"(",
"$",
"result",
"[",
"$",
"key",
"]",
",",
"$",
"columns",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Group a 2-dim array by a set of columns.
@param array $array 2-dim array
@param int|string|array $columns index of the group-by column(s)
@return array
|
[
"Group",
"a",
"2",
"-",
"dim",
"array",
"by",
"a",
"set",
"of",
"columns",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/Util/ArrayUtil.php#L81-L107
|
239,321
|
phlexible/phlexible
|
src/Phlexible/Component/Util/ArrayUtil.php
|
ArrayUtil.multidimensionalSearch
|
public function multidimensionalSearch($parents, $searched)
{
if (empty($searched) || empty($parents)) {
return false;
}
foreach ($parents as $key => $value) {
$exists = true;
foreach ($searched as $skey => $svalue) {
$exists = $exists && isset($parents[$key][$skey]) && $parents[$key][$skey] === $svalue;
}
if ($exists) {
return true;
}
}
return false;
}
|
php
|
public function multidimensionalSearch($parents, $searched)
{
if (empty($searched) || empty($parents)) {
return false;
}
foreach ($parents as $key => $value) {
$exists = true;
foreach ($searched as $skey => $svalue) {
$exists = $exists && isset($parents[$key][$skey]) && $parents[$key][$skey] === $svalue;
}
if ($exists) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"multidimensionalSearch",
"(",
"$",
"parents",
",",
"$",
"searched",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"searched",
")",
"||",
"empty",
"(",
"$",
"parents",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"parents",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"exists",
"=",
"true",
";",
"foreach",
"(",
"$",
"searched",
"as",
"$",
"skey",
"=>",
"$",
"svalue",
")",
"{",
"$",
"exists",
"=",
"$",
"exists",
"&&",
"isset",
"(",
"$",
"parents",
"[",
"$",
"key",
"]",
"[",
"$",
"skey",
"]",
")",
"&&",
"$",
"parents",
"[",
"$",
"key",
"]",
"[",
"$",
"skey",
"]",
"===",
"$",
"svalue",
";",
"}",
"if",
"(",
"$",
"exists",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Search for a data in a multidimensional array.
Example:
$parents = array();
$parents[] = array('date'=>1320883200, 'uid'=>3);
$parents[] = array('date'=>1320883200, 'uid'=>5);
$parents[] = array('date'=>1318204800, 'uid'=>5);
echo multidimensionalSearch($parents, array('date'=>1320883200, 'uid'=>5)); // true
@param array $parents
@param string $searched
@return mixed
|
[
"Search",
"for",
"a",
"data",
"in",
"a",
"multidimensional",
"array",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/Util/ArrayUtil.php#L142-L160
|
239,322
|
phlexible/phlexible
|
src/Phlexible/Component/Util/ArrayUtil.php
|
ArrayUtil.arraySearch
|
public function arraySearch($needle, $haystack)
{
if (empty($needle) || empty($haystack)) {
return false;
}
foreach ($haystack as $key => $value) {
$exists = 0;
foreach ($needle as $nkey => $nvalue) {
if (!empty($value[$nkey]) && $value[$nkey] === $nvalue) {
$exists = 1;
} else {
$exists = 0;
}
}
if ($exists) {
return $key;
}
}
return false;
}
|
php
|
public function arraySearch($needle, $haystack)
{
if (empty($needle) || empty($haystack)) {
return false;
}
foreach ($haystack as $key => $value) {
$exists = 0;
foreach ($needle as $nkey => $nvalue) {
if (!empty($value[$nkey]) && $value[$nkey] === $nvalue) {
$exists = 1;
} else {
$exists = 0;
}
}
if ($exists) {
return $key;
}
}
return false;
}
|
[
"public",
"function",
"arraySearch",
"(",
"$",
"needle",
",",
"$",
"haystack",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"needle",
")",
"||",
"empty",
"(",
"$",
"haystack",
")",
")",
"{",
"return",
"false",
";",
"}",
"foreach",
"(",
"$",
"haystack",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"exists",
"=",
"0",
";",
"foreach",
"(",
"$",
"needle",
"as",
"$",
"nkey",
"=>",
"$",
"nvalue",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
"[",
"$",
"nkey",
"]",
")",
"&&",
"$",
"value",
"[",
"$",
"nkey",
"]",
"===",
"$",
"nvalue",
")",
"{",
"$",
"exists",
"=",
"1",
";",
"}",
"else",
"{",
"$",
"exists",
"=",
"0",
";",
"}",
"}",
"if",
"(",
"$",
"exists",
")",
"{",
"return",
"$",
"key",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Search in multidimensional array and return key.
@param array $needle the searched data
@param array $haystack the array to search in
@return bool|int
|
[
"Search",
"in",
"multidimensional",
"array",
"and",
"return",
"key",
"."
] |
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
|
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Component/Util/ArrayUtil.php#L170-L192
|
239,323
|
artscorestudio/layout-bundle
|
DependencyInjection/Configuration.php
|
Configuration.addJqueryParameterNode
|
protected function addJqueryParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('jquery');
$node
->treatTrueLike(array('path' => self::COMPONENTS_DIR.'/jquery/jquery.min.js'))
->treatFalseLike(array('path' => false))
->addDefaultsIfNotSet()
->children()
->scalarNode('path')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/jquery".')
->defaultValue(self::COMPONENTS_DIR.'/jquery/jquery.min.js')
->end()
->end()
;
return $node;
}
|
php
|
protected function addJqueryParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('jquery');
$node
->treatTrueLike(array('path' => self::COMPONENTS_DIR.'/jquery/jquery.min.js'))
->treatFalseLike(array('path' => false))
->addDefaultsIfNotSet()
->children()
->scalarNode('path')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/jquery".')
->defaultValue(self::COMPONENTS_DIR.'/jquery/jquery.min.js')
->end()
->end()
;
return $node;
}
|
[
"protected",
"function",
"addJqueryParameterNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'jquery'",
")",
";",
"$",
"node",
"->",
"treatTrueLike",
"(",
"array",
"(",
"'path'",
"=>",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/jquery/jquery.min.js'",
")",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
"'path'",
"=>",
"false",
")",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'path'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"info",
"(",
"'Fill this value if you do not use the package \"component/jquery\".'",
")",
"->",
"defaultValue",
"(",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/jquery/jquery.min.js'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Return jQuery configuration.
|
[
"Return",
"jQuery",
"configuration",
"."
] |
5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740
|
https://github.com/artscorestudio/layout-bundle/blob/5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740/DependencyInjection/Configuration.php#L74-L93
|
239,324
|
artscorestudio/layout-bundle
|
DependencyInjection/Configuration.php
|
Configuration.addTwitterBootstrapParameterNode
|
protected function addTwitterBootstrapParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('twbs');
$defaults = array(
'twbs_dir' => self::COMPONENTS_DIR.'/bootstrap',
'js' => array('js/bootstrap.min.js'),
'less' => array(
'less/bootstrap.less',
'less/theme.less',
),
'css' => array(),
'icon_prefix' => 'glyphicon',
'fonts_dir' => '%kernel.root_dir%/../web/fonts',
'icon_tag' => 'span',
'form_theme' => 'ASFLayoutBundle:form:fields.html.twig',
);
$node
->treatTrueLike($defaults)
->treatFalseLike(array(
'twbs_dir' => false,
))
->addDefaultsIfNotSet()
->children()
->scalarNode('twbs_dir')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/bootstrap".')
->defaultValue(self::COMPONENTS_DIR.'/bootstrap')
->end()
->arrayNode('js')
->treatNullLike(array())
->treatFalseLike(array())
->info('By default, the bundle search js files in folder fill in "asf_layout.assets.twbs.twbs_dir" parameter.')
->fixXmlConfig('js')
->prototype('scalar')->end()
->defaultValue(array(
'js/bootstrap.min.js',
))
->end()
->arrayNode('less')
->treatNullLike(array())
->treatFalseLike(array())
->info('By default, the bundle search less files in folder fill in "asf_layout.assets.twbs.twbs_dir" parameter.')
->fixXmlConfig('less')
->prototype('scalar')->end()
->defaultValue(array(
'less/bootstrap.less',
'less/theme.less',
))
->end()
->arrayNode('css')
->treatNullLike(array())
->treatFalseLike(array())
->info('By default, the bundle search css files in folder fill in "asf_layout.assets.twbs.twbs_dir" parameter.')
->fixXmlConfig('css')
->prototype('scalar')->end()
->end()
->scalarNode('icon_prefix')
->defaultValue('glyphicon')
->end()
->scalarNode('icon_tag')
->defaultValue('span')
->end()
->scalarNode('fonts_dir')
->defaultValue('%kernel.root_dir%/../web/fonts')
->end()
->scalarNode('form_theme')
->defaultValue('ASFLayoutBundle:form:fields.html.twig')
->end()
->arrayNode('customize')
->children()
->arrayNode('less')
->children()
->scalarNode('dest_dir')->end()
->arrayNode('files')
->fixXmlConfig('less_files')
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
->end()
->end()
;
return $node;
}
|
php
|
protected function addTwitterBootstrapParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('twbs');
$defaults = array(
'twbs_dir' => self::COMPONENTS_DIR.'/bootstrap',
'js' => array('js/bootstrap.min.js'),
'less' => array(
'less/bootstrap.less',
'less/theme.less',
),
'css' => array(),
'icon_prefix' => 'glyphicon',
'fonts_dir' => '%kernel.root_dir%/../web/fonts',
'icon_tag' => 'span',
'form_theme' => 'ASFLayoutBundle:form:fields.html.twig',
);
$node
->treatTrueLike($defaults)
->treatFalseLike(array(
'twbs_dir' => false,
))
->addDefaultsIfNotSet()
->children()
->scalarNode('twbs_dir')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/bootstrap".')
->defaultValue(self::COMPONENTS_DIR.'/bootstrap')
->end()
->arrayNode('js')
->treatNullLike(array())
->treatFalseLike(array())
->info('By default, the bundle search js files in folder fill in "asf_layout.assets.twbs.twbs_dir" parameter.')
->fixXmlConfig('js')
->prototype('scalar')->end()
->defaultValue(array(
'js/bootstrap.min.js',
))
->end()
->arrayNode('less')
->treatNullLike(array())
->treatFalseLike(array())
->info('By default, the bundle search less files in folder fill in "asf_layout.assets.twbs.twbs_dir" parameter.')
->fixXmlConfig('less')
->prototype('scalar')->end()
->defaultValue(array(
'less/bootstrap.less',
'less/theme.less',
))
->end()
->arrayNode('css')
->treatNullLike(array())
->treatFalseLike(array())
->info('By default, the bundle search css files in folder fill in "asf_layout.assets.twbs.twbs_dir" parameter.')
->fixXmlConfig('css')
->prototype('scalar')->end()
->end()
->scalarNode('icon_prefix')
->defaultValue('glyphicon')
->end()
->scalarNode('icon_tag')
->defaultValue('span')
->end()
->scalarNode('fonts_dir')
->defaultValue('%kernel.root_dir%/../web/fonts')
->end()
->scalarNode('form_theme')
->defaultValue('ASFLayoutBundle:form:fields.html.twig')
->end()
->arrayNode('customize')
->children()
->arrayNode('less')
->children()
->scalarNode('dest_dir')->end()
->arrayNode('files')
->fixXmlConfig('less_files')
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
->end()
->end()
;
return $node;
}
|
[
"protected",
"function",
"addTwitterBootstrapParameterNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'twbs'",
")",
";",
"$",
"defaults",
"=",
"array",
"(",
"'twbs_dir'",
"=>",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/bootstrap'",
",",
"'js'",
"=>",
"array",
"(",
"'js/bootstrap.min.js'",
")",
",",
"'less'",
"=>",
"array",
"(",
"'less/bootstrap.less'",
",",
"'less/theme.less'",
",",
")",
",",
"'css'",
"=>",
"array",
"(",
")",
",",
"'icon_prefix'",
"=>",
"'glyphicon'",
",",
"'fonts_dir'",
"=>",
"'%kernel.root_dir%/../web/fonts'",
",",
"'icon_tag'",
"=>",
"'span'",
",",
"'form_theme'",
"=>",
"'ASFLayoutBundle:form:fields.html.twig'",
",",
")",
";",
"$",
"node",
"->",
"treatTrueLike",
"(",
"$",
"defaults",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
"'twbs_dir'",
"=>",
"false",
",",
")",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'twbs_dir'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"info",
"(",
"'Fill this value if you do not use the package \"component/bootstrap\".'",
")",
"->",
"defaultValue",
"(",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/bootstrap'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'js'",
")",
"->",
"treatNullLike",
"(",
"array",
"(",
")",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
")",
")",
"->",
"info",
"(",
"'By default, the bundle search js files in folder fill in \"asf_layout.assets.twbs.twbs_dir\" parameter.'",
")",
"->",
"fixXmlConfig",
"(",
"'js'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"defaultValue",
"(",
"array",
"(",
"'js/bootstrap.min.js'",
",",
")",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'less'",
")",
"->",
"treatNullLike",
"(",
"array",
"(",
")",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
")",
")",
"->",
"info",
"(",
"'By default, the bundle search less files in folder fill in \"asf_layout.assets.twbs.twbs_dir\" parameter.'",
")",
"->",
"fixXmlConfig",
"(",
"'less'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"defaultValue",
"(",
"array",
"(",
"'less/bootstrap.less'",
",",
"'less/theme.less'",
",",
")",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'css'",
")",
"->",
"treatNullLike",
"(",
"array",
"(",
")",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
")",
")",
"->",
"info",
"(",
"'By default, the bundle search css files in folder fill in \"asf_layout.assets.twbs.twbs_dir\" parameter.'",
")",
"->",
"fixXmlConfig",
"(",
"'css'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'icon_prefix'",
")",
"->",
"defaultValue",
"(",
"'glyphicon'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'icon_tag'",
")",
"->",
"defaultValue",
"(",
"'span'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'fonts_dir'",
")",
"->",
"defaultValue",
"(",
"'%kernel.root_dir%/../web/fonts'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'form_theme'",
")",
"->",
"defaultValue",
"(",
"'ASFLayoutBundle:form:fields.html.twig'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'customize'",
")",
"->",
"children",
"(",
")",
"->",
"arrayNode",
"(",
"'less'",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'dest_dir'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'files'",
")",
"->",
"fixXmlConfig",
"(",
"'less_files'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Get Twitter Bootstrap Configuration.
|
[
"Get",
"Twitter",
"Bootstrap",
"Configuration",
"."
] |
5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740
|
https://github.com/artscorestudio/layout-bundle/blob/5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740/DependencyInjection/Configuration.php#L130-L218
|
239,325
|
artscorestudio/layout-bundle
|
DependencyInjection/Configuration.php
|
Configuration.addSelect2ParameterNode
|
protected function addSelect2ParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('select2');
$node
->treatFalseLike(array('js' => false, 'css' => false))
->treatNullLike(array('js' => false, 'css' => false))
->treatTrueLike(array(
'js' => '%kernel.root_dir%/../vendor/select2/select2/dist/js/select2.full.min.js',
'css' => '%kernel.root_dir%/../vendor/select2/select2/dist/css/select2.min.css',
))
->children()
->scalarNode('js')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/select2/select2/dist/js/select2.full.min.js')
->end()
->scalarNode('css')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/select2/select2/dist/css/select2.min.css')
->end()
->end()
;
return $node;
}
|
php
|
protected function addSelect2ParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('select2');
$node
->treatFalseLike(array('js' => false, 'css' => false))
->treatNullLike(array('js' => false, 'css' => false))
->treatTrueLike(array(
'js' => '%kernel.root_dir%/../vendor/select2/select2/dist/js/select2.full.min.js',
'css' => '%kernel.root_dir%/../vendor/select2/select2/dist/css/select2.min.css',
))
->children()
->scalarNode('js')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/select2/select2/dist/js/select2.full.min.js')
->end()
->scalarNode('css')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/select2/select2/dist/css/select2.min.css')
->end()
->end()
;
return $node;
}
|
[
"protected",
"function",
"addSelect2ParameterNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'select2'",
")",
";",
"$",
"node",
"->",
"treatFalseLike",
"(",
"array",
"(",
"'js'",
"=>",
"false",
",",
"'css'",
"=>",
"false",
")",
")",
"->",
"treatNullLike",
"(",
"array",
"(",
"'js'",
"=>",
"false",
",",
"'css'",
"=>",
"false",
")",
")",
"->",
"treatTrueLike",
"(",
"array",
"(",
"'js'",
"=>",
"'%kernel.root_dir%/../vendor/select2/select2/dist/js/select2.full.min.js'",
",",
"'css'",
"=>",
"'%kernel.root_dir%/../vendor/select2/select2/dist/css/select2.min.css'",
",",
")",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'js'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'%kernel.root_dir%/../vendor/select2/select2/dist/js/select2.full.min.js'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'css'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'%kernel.root_dir%/../vendor/select2/select2/dist/css/select2.min.css'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Get Select2 Configuration.
|
[
"Get",
"Select2",
"Configuration",
"."
] |
5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740
|
https://github.com/artscorestudio/layout-bundle/blob/5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740/DependencyInjection/Configuration.php#L223-L248
|
239,326
|
artscorestudio/layout-bundle
|
DependencyInjection/Configuration.php
|
Configuration.addSpeakingURLParameterNode
|
protected function addSpeakingURLParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('speakingurl');
$node
->treatTrueLike(array('path' => '%kernel.root_dir%/../vendor/pid/speakingurl/speakingurl.min.js'))
->treatFalseLike(array('path' => false))
->treatNullLike(array('path' => false))
->children()
->scalarNode('path')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/pid/speakingurl/speakingurl.min.js')
->end()
->end()
;
return $node;
}
|
php
|
protected function addSpeakingURLParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('speakingurl');
$node
->treatTrueLike(array('path' => '%kernel.root_dir%/../vendor/pid/speakingurl/speakingurl.min.js'))
->treatFalseLike(array('path' => false))
->treatNullLike(array('path' => false))
->children()
->scalarNode('path')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/pid/speakingurl/speakingurl.min.js')
->end()
->end()
;
return $node;
}
|
[
"protected",
"function",
"addSpeakingURLParameterNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'speakingurl'",
")",
";",
"$",
"node",
"->",
"treatTrueLike",
"(",
"array",
"(",
"'path'",
"=>",
"'%kernel.root_dir%/../vendor/pid/speakingurl/speakingurl.min.js'",
")",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
"'path'",
"=>",
"false",
")",
")",
"->",
"treatNullLike",
"(",
"array",
"(",
"'path'",
"=>",
"false",
")",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'path'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'%kernel.root_dir%/../vendor/pid/speakingurl/speakingurl.min.js'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Get Speaking URL Configuration.
|
[
"Get",
"Speaking",
"URL",
"Configuration",
"."
] |
5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740
|
https://github.com/artscorestudio/layout-bundle/blob/5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740/DependencyInjection/Configuration.php#L291-L309
|
239,327
|
artscorestudio/layout-bundle
|
DependencyInjection/Configuration.php
|
Configuration.addTinyMCEParameterNode
|
protected function addTinyMCEParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('tinymce');
$exclude_files = array('bower.json', 'changelog.txt', 'composer.json', 'license.txt', 'package.json', 'readme.md');
$defaults = array(
'tinymce_dir' => '%kernel.root_dir%/../vendor/tinymce/tinymce',
'js' => 'tinymce.min.js',
'config' => array(
'selector' => '.tinymce-content',
),
'customize' => array(
'dest_dir' => '%kernel.root_dir%/../web/js/tinymce',
'base_url' => '/js/tinymce',
'exclude_files' => $exclude_files,
),
);
$node
->treatTrueLike($defaults)
->treatNullLike($defaults)
->treatFalseLike(array(
'tinymce_dir' => false,
))
->children()
->scalarNode('tinymce_dir')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/tinymce/tinymce')
->end()
->scalarNode('js')
->CannotBeEmpty()
->defaultValue('tinymce.min.js')
->end()
->arrayNode('config')
->addDefaultsIfNotSet()
->children()
->scalarNode('selector')
->cannotBeEmpty()
->defaultValue('.tinymce-content')
->end()
->end()
->end()
->arrayNode('customize')
->addDefaultsIfNotSet()
->children()
->scalarNode('dest_dir')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../web/js/tinymce')
->end()
->scalarNode('base_url')
->cannotBeEmpty()
->defaultValue('/js/tinymce')
->end()
->arrayNode('exclude_files')
->fixXmlConfig('exclude_files')
->prototype('scalar')->end()
->defaultValue($exclude_files)
->end()
->end()
->end()
->end()
;
return $node;
}
|
php
|
protected function addTinyMCEParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('tinymce');
$exclude_files = array('bower.json', 'changelog.txt', 'composer.json', 'license.txt', 'package.json', 'readme.md');
$defaults = array(
'tinymce_dir' => '%kernel.root_dir%/../vendor/tinymce/tinymce',
'js' => 'tinymce.min.js',
'config' => array(
'selector' => '.tinymce-content',
),
'customize' => array(
'dest_dir' => '%kernel.root_dir%/../web/js/tinymce',
'base_url' => '/js/tinymce',
'exclude_files' => $exclude_files,
),
);
$node
->treatTrueLike($defaults)
->treatNullLike($defaults)
->treatFalseLike(array(
'tinymce_dir' => false,
))
->children()
->scalarNode('tinymce_dir')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../vendor/tinymce/tinymce')
->end()
->scalarNode('js')
->CannotBeEmpty()
->defaultValue('tinymce.min.js')
->end()
->arrayNode('config')
->addDefaultsIfNotSet()
->children()
->scalarNode('selector')
->cannotBeEmpty()
->defaultValue('.tinymce-content')
->end()
->end()
->end()
->arrayNode('customize')
->addDefaultsIfNotSet()
->children()
->scalarNode('dest_dir')
->cannotBeEmpty()
->defaultValue('%kernel.root_dir%/../web/js/tinymce')
->end()
->scalarNode('base_url')
->cannotBeEmpty()
->defaultValue('/js/tinymce')
->end()
->arrayNode('exclude_files')
->fixXmlConfig('exclude_files')
->prototype('scalar')->end()
->defaultValue($exclude_files)
->end()
->end()
->end()
->end()
;
return $node;
}
|
[
"protected",
"function",
"addTinyMCEParameterNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'tinymce'",
")",
";",
"$",
"exclude_files",
"=",
"array",
"(",
"'bower.json'",
",",
"'changelog.txt'",
",",
"'composer.json'",
",",
"'license.txt'",
",",
"'package.json'",
",",
"'readme.md'",
")",
";",
"$",
"defaults",
"=",
"array",
"(",
"'tinymce_dir'",
"=>",
"'%kernel.root_dir%/../vendor/tinymce/tinymce'",
",",
"'js'",
"=>",
"'tinymce.min.js'",
",",
"'config'",
"=>",
"array",
"(",
"'selector'",
"=>",
"'.tinymce-content'",
",",
")",
",",
"'customize'",
"=>",
"array",
"(",
"'dest_dir'",
"=>",
"'%kernel.root_dir%/../web/js/tinymce'",
",",
"'base_url'",
"=>",
"'/js/tinymce'",
",",
"'exclude_files'",
"=>",
"$",
"exclude_files",
",",
")",
",",
")",
";",
"$",
"node",
"->",
"treatTrueLike",
"(",
"$",
"defaults",
")",
"->",
"treatNullLike",
"(",
"$",
"defaults",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
"'tinymce_dir'",
"=>",
"false",
",",
")",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'tinymce_dir'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'%kernel.root_dir%/../vendor/tinymce/tinymce'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'js'",
")",
"->",
"CannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'tinymce.min.js'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'config'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'selector'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'.tinymce-content'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'customize'",
")",
"->",
"addDefaultsIfNotSet",
"(",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'dest_dir'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'%kernel.root_dir%/../web/js/tinymce'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'base_url'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"defaultValue",
"(",
"'/js/tinymce'",
")",
"->",
"end",
"(",
")",
"->",
"arrayNode",
"(",
"'exclude_files'",
")",
"->",
"fixXmlConfig",
"(",
"'exclude_files'",
")",
"->",
"prototype",
"(",
"'scalar'",
")",
"->",
"end",
"(",
")",
"->",
"defaultValue",
"(",
"$",
"exclude_files",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Get TinyMCE Configuration.
|
[
"Get",
"TinyMCE",
"Configuration",
"."
] |
5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740
|
https://github.com/artscorestudio/layout-bundle/blob/5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740/DependencyInjection/Configuration.php#L314-L380
|
239,328
|
artscorestudio/layout-bundle
|
DependencyInjection/Configuration.php
|
Configuration.addJqueryTagsInputParameterNode
|
protected function addJqueryTagsInputParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('jquery_tags_input');
$node
->treatTrueLike(array(
'js' => self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.js',
'css' => self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.css',
))
->treatFalseLike(array('js' => false, 'css' => false))
->treatNullLike(array('js' => false, 'css' => false))
->children()
->scalarNode('js')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/jquery-tags-inputs".')
->defaultValue(self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.js')
->end()
->scalarNode('css')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/jquery-tags-input".')
->defaultValue(self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.css')
->end()
->end()
;
return $node;
}
|
php
|
protected function addJqueryTagsInputParameterNode()
{
$builder = new TreeBuilder();
$node = $builder->root('jquery_tags_input');
$node
->treatTrueLike(array(
'js' => self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.js',
'css' => self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.css',
))
->treatFalseLike(array('js' => false, 'css' => false))
->treatNullLike(array('js' => false, 'css' => false))
->children()
->scalarNode('js')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/jquery-tags-inputs".')
->defaultValue(self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.js')
->end()
->scalarNode('css')
->cannotBeEmpty()
->info('Fill this value if you do not use the package "component/jquery-tags-input".')
->defaultValue(self::COMPONENTS_DIR.'/jquery-tags-input/dist/jquery.tagsinput.min.css')
->end()
->end()
;
return $node;
}
|
[
"protected",
"function",
"addJqueryTagsInputParameterNode",
"(",
")",
"{",
"$",
"builder",
"=",
"new",
"TreeBuilder",
"(",
")",
";",
"$",
"node",
"=",
"$",
"builder",
"->",
"root",
"(",
"'jquery_tags_input'",
")",
";",
"$",
"node",
"->",
"treatTrueLike",
"(",
"array",
"(",
"'js'",
"=>",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/jquery-tags-input/dist/jquery.tagsinput.min.js'",
",",
"'css'",
"=>",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/jquery-tags-input/dist/jquery.tagsinput.min.css'",
",",
")",
")",
"->",
"treatFalseLike",
"(",
"array",
"(",
"'js'",
"=>",
"false",
",",
"'css'",
"=>",
"false",
")",
")",
"->",
"treatNullLike",
"(",
"array",
"(",
"'js'",
"=>",
"false",
",",
"'css'",
"=>",
"false",
")",
")",
"->",
"children",
"(",
")",
"->",
"scalarNode",
"(",
"'js'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"info",
"(",
"'Fill this value if you do not use the package \"component/jquery-tags-inputs\".'",
")",
"->",
"defaultValue",
"(",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/jquery-tags-input/dist/jquery.tagsinput.min.js'",
")",
"->",
"end",
"(",
")",
"->",
"scalarNode",
"(",
"'css'",
")",
"->",
"cannotBeEmpty",
"(",
")",
"->",
"info",
"(",
"'Fill this value if you do not use the package \"component/jquery-tags-input\".'",
")",
"->",
"defaultValue",
"(",
"self",
"::",
"COMPONENTS_DIR",
".",
"'/jquery-tags-input/dist/jquery.tagsinput.min.css'",
")",
"->",
"end",
"(",
")",
"->",
"end",
"(",
")",
";",
"return",
"$",
"node",
";",
"}"
] |
Return jQuery Tags Input Plugin configuration.
|
[
"Return",
"jQuery",
"Tags",
"Input",
"Plugin",
"configuration",
"."
] |
5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740
|
https://github.com/artscorestudio/layout-bundle/blob/5ccd5f4a133e8af90fb2c46e1f68b6bcb4b66740/DependencyInjection/Configuration.php#L385-L412
|
239,329
|
cundd/test-flight
|
src/Bootstrap.php
|
Bootstrap.run
|
public function run(array $arguments): bool
{
$exception = null;
try {
$this->prepareConfigurationProvider($arguments);
$this->prepareCustomBootstrapAndAutoloading($this->configurationProvider->get('bootstrap'));
$this->printer->setVerbose($this->configurationProvider->get('verbose'));
$this->exceptionPrinter->setVerbose($this->configurationProvider->get('verbose'));
switch ($this->configurationProvider->get('command')) {
case 'list':
$commandClass = ListCommand::class;
break;
case 'run':
default:
$commandClass = RunCommand::class;
break;
}
/** @var CommandInterface $command */
$command = $this->objectManager->get(
$commandClass,
$this->configurationProvider,
$this->objectManager,
$this->classLoader,
$this->printer,
$this->exceptionPrinter
);
$result = $command->run();
$this->printFooter();
return $result;
} catch (ConfigurationException $exception) {
} catch (FileNotExistsException $exception) {
}
$this->error($exception->getMessage());
return false;
}
|
php
|
public function run(array $arguments): bool
{
$exception = null;
try {
$this->prepareConfigurationProvider($arguments);
$this->prepareCustomBootstrapAndAutoloading($this->configurationProvider->get('bootstrap'));
$this->printer->setVerbose($this->configurationProvider->get('verbose'));
$this->exceptionPrinter->setVerbose($this->configurationProvider->get('verbose'));
switch ($this->configurationProvider->get('command')) {
case 'list':
$commandClass = ListCommand::class;
break;
case 'run':
default:
$commandClass = RunCommand::class;
break;
}
/** @var CommandInterface $command */
$command = $this->objectManager->get(
$commandClass,
$this->configurationProvider,
$this->objectManager,
$this->classLoader,
$this->printer,
$this->exceptionPrinter
);
$result = $command->run();
$this->printFooter();
return $result;
} catch (ConfigurationException $exception) {
} catch (FileNotExistsException $exception) {
}
$this->error($exception->getMessage());
return false;
}
|
[
"public",
"function",
"run",
"(",
"array",
"$",
"arguments",
")",
":",
"bool",
"{",
"$",
"exception",
"=",
"null",
";",
"try",
"{",
"$",
"this",
"->",
"prepareConfigurationProvider",
"(",
"$",
"arguments",
")",
";",
"$",
"this",
"->",
"prepareCustomBootstrapAndAutoloading",
"(",
"$",
"this",
"->",
"configurationProvider",
"->",
"get",
"(",
"'bootstrap'",
")",
")",
";",
"$",
"this",
"->",
"printer",
"->",
"setVerbose",
"(",
"$",
"this",
"->",
"configurationProvider",
"->",
"get",
"(",
"'verbose'",
")",
")",
";",
"$",
"this",
"->",
"exceptionPrinter",
"->",
"setVerbose",
"(",
"$",
"this",
"->",
"configurationProvider",
"->",
"get",
"(",
"'verbose'",
")",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"configurationProvider",
"->",
"get",
"(",
"'command'",
")",
")",
"{",
"case",
"'list'",
":",
"$",
"commandClass",
"=",
"ListCommand",
"::",
"class",
";",
"break",
";",
"case",
"'run'",
":",
"default",
":",
"$",
"commandClass",
"=",
"RunCommand",
"::",
"class",
";",
"break",
";",
"}",
"/** @var CommandInterface $command */",
"$",
"command",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"$",
"commandClass",
",",
"$",
"this",
"->",
"configurationProvider",
",",
"$",
"this",
"->",
"objectManager",
",",
"$",
"this",
"->",
"classLoader",
",",
"$",
"this",
"->",
"printer",
",",
"$",
"this",
"->",
"exceptionPrinter",
")",
";",
"$",
"result",
"=",
"$",
"command",
"->",
"run",
"(",
")",
";",
"$",
"this",
"->",
"printFooter",
"(",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"ConfigurationException",
"$",
"exception",
")",
"{",
"}",
"catch",
"(",
"FileNotExistsException",
"$",
"exception",
")",
"{",
"}",
"$",
"this",
"->",
"error",
"(",
"$",
"exception",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
"false",
";",
"}"
] |
Find and run the tests
@param array $arguments
@return bool
|
[
"Find",
"and",
"run",
"the",
"tests"
] |
9d8424dfb586f823f9dad2dcb81ff3986e255d56
|
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Bootstrap.php#L102-L143
|
239,330
|
cundd/test-flight
|
src/Bootstrap.php
|
Bootstrap.error
|
private function error(string $message, $status = 1)
{
$this->printer->printError($message);
exit($status);
}
|
php
|
private function error(string $message, $status = 1)
{
$this->printer->printError($message);
exit($status);
}
|
[
"private",
"function",
"error",
"(",
"string",
"$",
"message",
",",
"$",
"status",
"=",
"1",
")",
"{",
"$",
"this",
"->",
"printer",
"->",
"printError",
"(",
"$",
"message",
")",
";",
"exit",
"(",
"$",
"status",
")",
";",
"}"
] |
Print a error message and exit
@param string $message
@param int $status
|
[
"Print",
"a",
"error",
"message",
"and",
"exit"
] |
9d8424dfb586f823f9dad2dcb81ff3986e255d56
|
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Bootstrap.php#L259-L263
|
239,331
|
cundd/test-flight
|
src/Bootstrap.php
|
Bootstrap.prepareCustomBootstrapAndAutoloading
|
private function prepareCustomBootstrapAndAutoloading(string $bootstrapFile)
{
/** @var Finder $autoloadFinder */
$autoloadFinder = $this->objectManager->get(Finder::class);
$projectAutoloaderPath = $autoloadFinder->find(getcwd());
if ($projectAutoloaderPath !== '') {
require_once $projectAutoloaderPath;
}
// The variable will be exported to the bootstrap file
$eventDispatcher = $this->eventDispatcher;
if ($bootstrapFile) {
require_once $bootstrapFile;
}
unset($eventDispatcher);
}
|
php
|
private function prepareCustomBootstrapAndAutoloading(string $bootstrapFile)
{
/** @var Finder $autoloadFinder */
$autoloadFinder = $this->objectManager->get(Finder::class);
$projectAutoloaderPath = $autoloadFinder->find(getcwd());
if ($projectAutoloaderPath !== '') {
require_once $projectAutoloaderPath;
}
// The variable will be exported to the bootstrap file
$eventDispatcher = $this->eventDispatcher;
if ($bootstrapFile) {
require_once $bootstrapFile;
}
unset($eventDispatcher);
}
|
[
"private",
"function",
"prepareCustomBootstrapAndAutoloading",
"(",
"string",
"$",
"bootstrapFile",
")",
"{",
"/** @var Finder $autoloadFinder */",
"$",
"autoloadFinder",
"=",
"$",
"this",
"->",
"objectManager",
"->",
"get",
"(",
"Finder",
"::",
"class",
")",
";",
"$",
"projectAutoloaderPath",
"=",
"$",
"autoloadFinder",
"->",
"find",
"(",
"getcwd",
"(",
")",
")",
";",
"if",
"(",
"$",
"projectAutoloaderPath",
"!==",
"''",
")",
"{",
"require_once",
"$",
"projectAutoloaderPath",
";",
"}",
"// The variable will be exported to the bootstrap file",
"$",
"eventDispatcher",
"=",
"$",
"this",
"->",
"eventDispatcher",
";",
"if",
"(",
"$",
"bootstrapFile",
")",
"{",
"require_once",
"$",
"bootstrapFile",
";",
"}",
"unset",
"(",
"$",
"eventDispatcher",
")",
";",
"}"
] |
Include the custom bootstrap file
@param string $bootstrapFile
|
[
"Include",
"the",
"custom",
"bootstrap",
"file"
] |
9d8424dfb586f823f9dad2dcb81ff3986e255d56
|
https://github.com/cundd/test-flight/blob/9d8424dfb586f823f9dad2dcb81ff3986e255d56/src/Bootstrap.php#L287-L302
|
239,332
|
movicon/movicon-http
|
src/http/request/RequestSession.php
|
RequestSession.get
|
public static function get($name, $options = [])
{
RequestSession::_start();
$default = isset($options["default"]) ? $options["default"] : null;
return isset($_SESSION[$name]) ? $_SESSION[$name] : $default;
}
|
php
|
public static function get($name, $options = [])
{
RequestSession::_start();
$default = isset($options["default"]) ? $options["default"] : null;
return isset($_SESSION[$name]) ? $_SESSION[$name] : $default;
}
|
[
"public",
"static",
"function",
"get",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"RequestSession",
"::",
"_start",
"(",
")",
";",
"$",
"default",
"=",
"isset",
"(",
"$",
"options",
"[",
"\"default\"",
"]",
")",
"?",
"$",
"options",
"[",
"\"default\"",
"]",
":",
"null",
";",
"return",
"isset",
"(",
"$",
"_SESSION",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"_SESSION",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
] |
Gets a session variable.
Example:
$token = RequestSession::get("token");
$username = RequestSession::get("username", ["default" => "root"]);
@param string $name Session variable name
@param array $options Options
@return mixed|null
|
[
"Gets",
"a",
"session",
"variable",
"."
] |
ae9e4aa763c52f272c628fef0ec4496478312355
|
https://github.com/movicon/movicon-http/blob/ae9e4aa763c52f272c628fef0ec4496478312355/src/http/request/RequestSession.php#L19-L26
|
239,333
|
bravesheep/dogmatist
|
src/Guesser/FieldNameGuesser.php
|
FieldNameGuesser.isPropertyAccessible
|
private function isPropertyAccessible($name, \ReflectionClass $class)
{
$camelized = $this->camelize($name);
$setter = 'set'.$camelized;
$getsetter = lcfirst($camelized); // jQuery style, e.g. read: last(), write: last($item)
$classHasProperty = $class->hasProperty($name);
if ($this->isMethodAccessible($class, $setter, 1)
|| $this->isMethodAccessible($class, $getsetter, 1)
|| $this->isMethodAccessible($class, '__set', 2)
|| ($classHasProperty && $class->getProperty($name)->isPublic())) {
return true;
}
$singulars = (array) StringUtil::singularify($camelized);
// Any of the two methods is required, but not yet known
if (null !== $this->findAdderAndRemover($class, $singulars)) {
return true;
}
return false;
}
|
php
|
private function isPropertyAccessible($name, \ReflectionClass $class)
{
$camelized = $this->camelize($name);
$setter = 'set'.$camelized;
$getsetter = lcfirst($camelized); // jQuery style, e.g. read: last(), write: last($item)
$classHasProperty = $class->hasProperty($name);
if ($this->isMethodAccessible($class, $setter, 1)
|| $this->isMethodAccessible($class, $getsetter, 1)
|| $this->isMethodAccessible($class, '__set', 2)
|| ($classHasProperty && $class->getProperty($name)->isPublic())) {
return true;
}
$singulars = (array) StringUtil::singularify($camelized);
// Any of the two methods is required, but not yet known
if (null !== $this->findAdderAndRemover($class, $singulars)) {
return true;
}
return false;
}
|
[
"private",
"function",
"isPropertyAccessible",
"(",
"$",
"name",
",",
"\\",
"ReflectionClass",
"$",
"class",
")",
"{",
"$",
"camelized",
"=",
"$",
"this",
"->",
"camelize",
"(",
"$",
"name",
")",
";",
"$",
"setter",
"=",
"'set'",
".",
"$",
"camelized",
";",
"$",
"getsetter",
"=",
"lcfirst",
"(",
"$",
"camelized",
")",
";",
"// jQuery style, e.g. read: last(), write: last($item)",
"$",
"classHasProperty",
"=",
"$",
"class",
"->",
"hasProperty",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isMethodAccessible",
"(",
"$",
"class",
",",
"$",
"setter",
",",
"1",
")",
"||",
"$",
"this",
"->",
"isMethodAccessible",
"(",
"$",
"class",
",",
"$",
"getsetter",
",",
"1",
")",
"||",
"$",
"this",
"->",
"isMethodAccessible",
"(",
"$",
"class",
",",
"'__set'",
",",
"2",
")",
"||",
"(",
"$",
"classHasProperty",
"&&",
"$",
"class",
"->",
"getProperty",
"(",
"$",
"name",
")",
"->",
"isPublic",
"(",
")",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"singulars",
"=",
"(",
"array",
")",
"StringUtil",
"::",
"singularify",
"(",
"$",
"camelized",
")",
";",
"// Any of the two methods is required, but not yet known",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"findAdderAndRemover",
"(",
"$",
"class",
",",
"$",
"singulars",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check whether or not a property is writable.
Part of the Symfony package. Symfony license applies.
@param string $name
@param \ReflectionClass $class
@return bool
|
[
"Check",
"whether",
"or",
"not",
"a",
"property",
"is",
"writable",
"."
] |
38c332e5ccff4e715b70e5f5ce153d96c745d695
|
https://github.com/bravesheep/dogmatist/blob/38c332e5ccff4e715b70e5f5ce153d96c745d695/src/Guesser/FieldNameGuesser.php#L94-L116
|
239,334
|
bravesheep/dogmatist
|
src/Guesser/FieldNameGuesser.php
|
FieldNameGuesser.findAdderAndRemover
|
private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars)
{
foreach ($singulars as $singular) {
$addMethod = 'add'.$singular;
$removeMethod = 'remove'.$singular;
$addMethodFound = $this->isMethodAccessible($reflClass, $addMethod, 1);
$removeMethodFound = $this->isMethodAccessible($reflClass, $removeMethod, 1);
if ($addMethodFound && $removeMethodFound) {
return array($addMethod, $removeMethod);
}
}
return null;
}
|
php
|
private function findAdderAndRemover(\ReflectionClass $reflClass, array $singulars)
{
foreach ($singulars as $singular) {
$addMethod = 'add'.$singular;
$removeMethod = 'remove'.$singular;
$addMethodFound = $this->isMethodAccessible($reflClass, $addMethod, 1);
$removeMethodFound = $this->isMethodAccessible($reflClass, $removeMethod, 1);
if ($addMethodFound && $removeMethodFound) {
return array($addMethod, $removeMethod);
}
}
return null;
}
|
[
"private",
"function",
"findAdderAndRemover",
"(",
"\\",
"ReflectionClass",
"$",
"reflClass",
",",
"array",
"$",
"singulars",
")",
"{",
"foreach",
"(",
"$",
"singulars",
"as",
"$",
"singular",
")",
"{",
"$",
"addMethod",
"=",
"'add'",
".",
"$",
"singular",
";",
"$",
"removeMethod",
"=",
"'remove'",
".",
"$",
"singular",
";",
"$",
"addMethodFound",
"=",
"$",
"this",
"->",
"isMethodAccessible",
"(",
"$",
"reflClass",
",",
"$",
"addMethod",
",",
"1",
")",
";",
"$",
"removeMethodFound",
"=",
"$",
"this",
"->",
"isMethodAccessible",
"(",
"$",
"reflClass",
",",
"$",
"removeMethod",
",",
"1",
")",
";",
"if",
"(",
"$",
"addMethodFound",
"&&",
"$",
"removeMethodFound",
")",
"{",
"return",
"array",
"(",
"$",
"addMethod",
",",
"$",
"removeMethod",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Searches for add and remove methods.
Part of the Symfony package. Symfony license applies.
@param \ReflectionClass $reflClass The reflection class for the given object
@param array $singulars The singular form of the property name or null
@return array|null An array containing the adder and remover when found, null otherwise
|
[
"Searches",
"for",
"add",
"and",
"remove",
"methods",
"."
] |
38c332e5ccff4e715b70e5f5ce153d96c745d695
|
https://github.com/bravesheep/dogmatist/blob/38c332e5ccff4e715b70e5f5ce153d96c745d695/src/Guesser/FieldNameGuesser.php#L128-L143
|
239,335
|
bravesheep/dogmatist
|
src/Guesser/FieldNameGuesser.php
|
FieldNameGuesser.isMethodAccessible
|
private function isMethodAccessible(\ReflectionClass $class, $methodName, $parameters)
{
if ($class->hasMethod($methodName)) {
$method = $class->getMethod($methodName);
if ($method->isPublic()
&& $method->getNumberOfRequiredParameters() <= $parameters
&& $method->getNumberOfParameters() >= $parameters) {
return true;
}
}
return false;
}
|
php
|
private function isMethodAccessible(\ReflectionClass $class, $methodName, $parameters)
{
if ($class->hasMethod($methodName)) {
$method = $class->getMethod($methodName);
if ($method->isPublic()
&& $method->getNumberOfRequiredParameters() <= $parameters
&& $method->getNumberOfParameters() >= $parameters) {
return true;
}
}
return false;
}
|
[
"private",
"function",
"isMethodAccessible",
"(",
"\\",
"ReflectionClass",
"$",
"class",
",",
"$",
"methodName",
",",
"$",
"parameters",
")",
"{",
"if",
"(",
"$",
"class",
"->",
"hasMethod",
"(",
"$",
"methodName",
")",
")",
"{",
"$",
"method",
"=",
"$",
"class",
"->",
"getMethod",
"(",
"$",
"methodName",
")",
";",
"if",
"(",
"$",
"method",
"->",
"isPublic",
"(",
")",
"&&",
"$",
"method",
"->",
"getNumberOfRequiredParameters",
"(",
")",
"<=",
"$",
"parameters",
"&&",
"$",
"method",
"->",
"getNumberOfParameters",
"(",
")",
">=",
"$",
"parameters",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns whether a method is public and has the number of required parameters.
Part of the Symfony package. Symfony license applies.
@param \ReflectionClass $class The class of the method
@param string $methodName The method name
@param int $parameters The number of parameters
@return bool Whether the method is public and has $parameters
required parameters
|
[
"Returns",
"whether",
"a",
"method",
"is",
"public",
"and",
"has",
"the",
"number",
"of",
"required",
"parameters",
"."
] |
38c332e5ccff4e715b70e5f5ce153d96c745d695
|
https://github.com/bravesheep/dogmatist/blob/38c332e5ccff4e715b70e5f5ce153d96c745d695/src/Guesser/FieldNameGuesser.php#L157-L170
|
239,336
|
railsphp/framework
|
src/Rails/ActionView/Helper/Methods/TagTrait.php
|
TagTrait.properTagSize
|
public function properTagSize(&$attrs)
{
if (isset($attrs['size']) && is_int(strpos($attrs['size'], 'x'))) {
list ($attrs['width'], $attrs['height']) = explode('x', $attrs['size']);
unset($attrs['size']);
}
}
|
php
|
public function properTagSize(&$attrs)
{
if (isset($attrs['size']) && is_int(strpos($attrs['size'], 'x'))) {
list ($attrs['width'], $attrs['height']) = explode('x', $attrs['size']);
unset($attrs['size']);
}
}
|
[
"public",
"function",
"properTagSize",
"(",
"&",
"$",
"attrs",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"attrs",
"[",
"'size'",
"]",
")",
"&&",
"is_int",
"(",
"strpos",
"(",
"$",
"attrs",
"[",
"'size'",
"]",
",",
"'x'",
")",
")",
")",
"{",
"list",
"(",
"$",
"attrs",
"[",
"'width'",
"]",
",",
"$",
"attrs",
"[",
"'height'",
"]",
")",
"=",
"explode",
"(",
"'x'",
",",
"$",
"attrs",
"[",
"'size'",
"]",
")",
";",
"unset",
"(",
"$",
"attrs",
"[",
"'size'",
"]",
")",
";",
"}",
"}"
] |
Proper tag size.
Converts a "size" attribute to width and height attributes
if it contains an "x", which is assumed to be like \d+x\d+.
|
[
"Proper",
"tag",
"size",
".",
"Converts",
"a",
"size",
"attribute",
"to",
"width",
"and",
"height",
"attributes",
"if",
"it",
"contains",
"an",
"x",
"which",
"is",
"assumed",
"to",
"be",
"like",
"\\",
"d",
"+",
"x",
"\\",
"d",
"+",
"."
] |
2ac9d3e493035dcc68f3c3812423327127327cd5
|
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActionView/Helper/Methods/TagTrait.php#L33-L39
|
239,337
|
milkyway-multimedia/ss-behaviours
|
src/Traits/Sluggable.php
|
Sluggable.generateSlugAndSave
|
protected function generateSlugAndSave()
{
if ($this->slugWorkingRecord->{$this->slugDbField}) {
return;
}
$this->generateSlug();
if ($this->slugWorkingRecord->{$this->slugDbField}) {
$this->slugWorkingRecord->write();
}
}
|
php
|
protected function generateSlugAndSave()
{
if ($this->slugWorkingRecord->{$this->slugDbField}) {
return;
}
$this->generateSlug();
if ($this->slugWorkingRecord->{$this->slugDbField}) {
$this->slugWorkingRecord->write();
}
}
|
[
"protected",
"function",
"generateSlugAndSave",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugDbField",
"}",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"generateSlug",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugDbField",
"}",
")",
"{",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"write",
"(",
")",
";",
"}",
"}"
] |
Generate hash and save if slug created
|
[
"Generate",
"hash",
"and",
"save",
"if",
"slug",
"created"
] |
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
|
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Sluggable.php#L83-L94
|
239,338
|
milkyway-multimedia/ss-behaviours
|
src/Traits/Sluggable.php
|
Sluggable.regenerateSlug
|
public function regenerateSlug()
{
$this->slugWorkingRecord->{$this->slugDbField} = $this->encrypt();
$salt = $this->slugSalt;
if ($this->mustBeUnique && !$this->hasUniqueSlug()) {
$generator = new RandomGenerator();
while (!$this->hasUniqueSlug()) {
$salt = $generator->randomToken();
$this->slugWorkingRecord->{$this->slugDbField} = $this->encrypt(null, $salt);
}
}
$this->slugWorkingRecord->{$this->slugDbFieldForSalt} = $salt;
}
|
php
|
public function regenerateSlug()
{
$this->slugWorkingRecord->{$this->slugDbField} = $this->encrypt();
$salt = $this->slugSalt;
if ($this->mustBeUnique && !$this->hasUniqueSlug()) {
$generator = new RandomGenerator();
while (!$this->hasUniqueSlug()) {
$salt = $generator->randomToken();
$this->slugWorkingRecord->{$this->slugDbField} = $this->encrypt(null, $salt);
}
}
$this->slugWorkingRecord->{$this->slugDbFieldForSalt} = $salt;
}
|
[
"public",
"function",
"regenerateSlug",
"(",
")",
"{",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugDbField",
"}",
"=",
"$",
"this",
"->",
"encrypt",
"(",
")",
";",
"$",
"salt",
"=",
"$",
"this",
"->",
"slugSalt",
";",
"if",
"(",
"$",
"this",
"->",
"mustBeUnique",
"&&",
"!",
"$",
"this",
"->",
"hasUniqueSlug",
"(",
")",
")",
"{",
"$",
"generator",
"=",
"new",
"RandomGenerator",
"(",
")",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"hasUniqueSlug",
"(",
")",
")",
"{",
"$",
"salt",
"=",
"$",
"generator",
"->",
"randomToken",
"(",
")",
";",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugDbField",
"}",
"=",
"$",
"this",
"->",
"encrypt",
"(",
"null",
",",
"$",
"salt",
")",
";",
"}",
"}",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugDbFieldForSalt",
"}",
"=",
"$",
"salt",
";",
"}"
] |
Regenerate a slug for this @DataObject
|
[
"Regenerate",
"a",
"slug",
"for",
"this"
] |
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
|
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Sluggable.php#L111-L126
|
239,339
|
milkyway-multimedia/ss-behaviours
|
src/Traits/Sluggable.php
|
Sluggable.hasUniqueSlug
|
public function hasUniqueSlug()
{
$hash = $this->slugWorkingRecord->{$this->slugDbField} ?: $this->encrypt();
$list = $this->slugWorkingRecord->get()->filter($this->slugDbField, $hash);
if($this->slugWorkingRecord->ID) {
$list = $list->exclude('ID', $this->slugWorkingRecord->ID);
}
else {
$list = $list->exclude('ID', 0);
}
return !($list->exists());
}
|
php
|
public function hasUniqueSlug()
{
$hash = $this->slugWorkingRecord->{$this->slugDbField} ?: $this->encrypt();
$list = $this->slugWorkingRecord->get()->filter($this->slugDbField, $hash);
if($this->slugWorkingRecord->ID) {
$list = $list->exclude('ID', $this->slugWorkingRecord->ID);
}
else {
$list = $list->exclude('ID', 0);
}
return !($list->exists());
}
|
[
"public",
"function",
"hasUniqueSlug",
"(",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugDbField",
"}",
"?",
":",
"$",
"this",
"->",
"encrypt",
"(",
")",
";",
"$",
"list",
"=",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"get",
"(",
")",
"->",
"filter",
"(",
"$",
"this",
"->",
"slugDbField",
",",
"$",
"hash",
")",
";",
"if",
"(",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"ID",
")",
"{",
"$",
"list",
"=",
"$",
"list",
"->",
"exclude",
"(",
"'ID'",
",",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"ID",
")",
";",
"}",
"else",
"{",
"$",
"list",
"=",
"$",
"list",
"->",
"exclude",
"(",
"'ID'",
",",
"0",
")",
";",
"}",
"return",
"!",
"(",
"$",
"list",
"->",
"exists",
"(",
")",
")",
";",
"}"
] |
Check if the slug for this object is unique
@return boolean
|
[
"Check",
"if",
"the",
"slug",
"for",
"this",
"object",
"is",
"unique"
] |
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
|
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Sluggable.php#L133-L146
|
239,340
|
milkyway-multimedia/ss-behaviours
|
src/Traits/Sluggable.php
|
Sluggable.encrypt
|
protected function encrypt($value = null, $salt = '')
{
return $this->hasher($salt)->encode($this->findValueToSlug($value));
}
|
php
|
protected function encrypt($value = null, $salt = '')
{
return $this->hasher($salt)->encode($this->findValueToSlug($value));
}
|
[
"protected",
"function",
"encrypt",
"(",
"$",
"value",
"=",
"null",
",",
"$",
"salt",
"=",
"''",
")",
"{",
"return",
"$",
"this",
"->",
"hasher",
"(",
"$",
"salt",
")",
"->",
"encode",
"(",
"$",
"this",
"->",
"findValueToSlug",
"(",
"$",
"value",
")",
")",
";",
"}"
] |
Encrypt the value
@param string|int $value
@param string $salt
@return string
|
[
"Encrypt",
"the",
"value"
] |
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
|
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Sluggable.php#L156-L159
|
239,341
|
milkyway-multimedia/ss-behaviours
|
src/Traits/Sluggable.php
|
Sluggable.findValueToSlug
|
protected function findValueToSlug($encryptUsing = null)
{
if (!$encryptUsing) {
if (is_array($this->slugEncryptUsing)) {
foreach ($this->slugEncryptUsing as $field) {
$encryptUsing .= $this->slugWorkingRecord->$field;
}
} else {
$encryptUsing = $this->slugWorkingRecord->{$this->slugEncryptUsing};
}
}
return is_numeric($encryptUsing) ? $encryptUsing : implode(array_map(function ($n) {
return sprintf('%03d', $n);
}, unpack('C*', $encryptUsing)));
}
|
php
|
protected function findValueToSlug($encryptUsing = null)
{
if (!$encryptUsing) {
if (is_array($this->slugEncryptUsing)) {
foreach ($this->slugEncryptUsing as $field) {
$encryptUsing .= $this->slugWorkingRecord->$field;
}
} else {
$encryptUsing = $this->slugWorkingRecord->{$this->slugEncryptUsing};
}
}
return is_numeric($encryptUsing) ? $encryptUsing : implode(array_map(function ($n) {
return sprintf('%03d', $n);
}, unpack('C*', $encryptUsing)));
}
|
[
"protected",
"function",
"findValueToSlug",
"(",
"$",
"encryptUsing",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"encryptUsing",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"slugEncryptUsing",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"slugEncryptUsing",
"as",
"$",
"field",
")",
"{",
"$",
"encryptUsing",
".=",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"$",
"field",
";",
"}",
"}",
"else",
"{",
"$",
"encryptUsing",
"=",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugEncryptUsing",
"}",
";",
"}",
"}",
"return",
"is_numeric",
"(",
"$",
"encryptUsing",
")",
"?",
"$",
"encryptUsing",
":",
"implode",
"(",
"array_map",
"(",
"function",
"(",
"$",
"n",
")",
"{",
"return",
"sprintf",
"(",
"'%03d'",
",",
"$",
"n",
")",
";",
"}",
",",
"unpack",
"(",
"'C*'",
",",
"$",
"encryptUsing",
")",
")",
")",
";",
"}"
] |
Return value to hash
@param array|string $encryptUsing
@return int|string
|
[
"Return",
"value",
"to",
"hash"
] |
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
|
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Sluggable.php#L187-L202
|
239,342
|
milkyway-multimedia/ss-behaviours
|
src/Traits/Sluggable.php
|
Sluggable.hasher
|
protected function hasher($salt = '')
{
$salt = $salt ?: $this->slugWorkingRecord->{$this->slugDbFieldForSalt} ?: $this->slugSalt;
if ($salt) {
return Object::create('Milkyway\SS\Behaviours\Contracts\Slugger', $salt, $this->slugLength);
}
if (!$this->slugHasher) {
$this->slugHasher = Object::create('Milkyway\SS\Behaviours\Contracts\Slugger', $salt, $this->slugLength);
}
return $this->slugHasher;
}
|
php
|
protected function hasher($salt = '')
{
$salt = $salt ?: $this->slugWorkingRecord->{$this->slugDbFieldForSalt} ?: $this->slugSalt;
if ($salt) {
return Object::create('Milkyway\SS\Behaviours\Contracts\Slugger', $salt, $this->slugLength);
}
if (!$this->slugHasher) {
$this->slugHasher = Object::create('Milkyway\SS\Behaviours\Contracts\Slugger', $salt, $this->slugLength);
}
return $this->slugHasher;
}
|
[
"protected",
"function",
"hasher",
"(",
"$",
"salt",
"=",
"''",
")",
"{",
"$",
"salt",
"=",
"$",
"salt",
"?",
":",
"$",
"this",
"->",
"slugWorkingRecord",
"->",
"{",
"$",
"this",
"->",
"slugDbFieldForSalt",
"}",
"?",
":",
"$",
"this",
"->",
"slugSalt",
";",
"if",
"(",
"$",
"salt",
")",
"{",
"return",
"Object",
"::",
"create",
"(",
"'Milkyway\\SS\\Behaviours\\Contracts\\Slugger'",
",",
"$",
"salt",
",",
"$",
"this",
"->",
"slugLength",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"slugHasher",
")",
"{",
"$",
"this",
"->",
"slugHasher",
"=",
"Object",
"::",
"create",
"(",
"'Milkyway\\SS\\Behaviours\\Contracts\\Slugger'",
",",
"$",
"salt",
",",
"$",
"this",
"->",
"slugLength",
")",
";",
"}",
"return",
"$",
"this",
"->",
"slugHasher",
";",
"}"
] |
Return the hasher service
@param string $salt
@return Slugger
|
[
"Return",
"the",
"hasher",
"service"
] |
79b7038cc5bbefbedb5eee97d8b10b5f88cbe595
|
https://github.com/milkyway-multimedia/ss-behaviours/blob/79b7038cc5bbefbedb5eee97d8b10b5f88cbe595/src/Traits/Sluggable.php#L211-L224
|
239,343
|
tekkla/core-di
|
Core/DI/DI.php
|
DI.getInstance
|
public static function getInstance(array $settings = []): DIInterface
{
if (! self::$instance) {
self::$instance = new DI($settings);
}
return self::$instance;
}
|
php
|
public static function getInstance(array $settings = []): DIInterface
{
if (! self::$instance) {
self::$instance = new DI($settings);
}
return self::$instance;
}
|
[
"public",
"static",
"function",
"getInstance",
"(",
"array",
"$",
"settings",
"=",
"[",
"]",
")",
":",
"DIInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"instance",
")",
"{",
"self",
"::",
"$",
"instance",
"=",
"new",
"DI",
"(",
"$",
"settings",
")",
";",
"}",
"return",
"self",
"::",
"$",
"instance",
";",
"}"
] |
Creates and returns singleton instance of DI service
@param array $settings
Optional settings array which is only needed once on instance creation
@return DIInterface
|
[
"Creates",
"and",
"returns",
"singleton",
"instance",
"of",
"DI",
"service"
] |
74c19125045aca19e28b3a184f4b6809052f22f8
|
https://github.com/tekkla/core-di/blob/74c19125045aca19e28b3a184f4b6809052f22f8/Core/DI/DI.php#L47-L54
|
239,344
|
Innmind/neo4j-onm
|
src/Persister/InsertPersister.php
|
InsertPersister.queryFor
|
private function queryFor(MapInterface $entities): Query
{
$query = new Query\Query;
$this->variables = new Stream('string');
$partitions = $entities->partition(function(Identity $identity, object $entity): bool {
$meta = ($this->metadata)(\get_class($entity));
return $meta instanceof Aggregate;
});
$query = $partitions
->get(true)
->reduce(
$query,
function(Query $carry, Identity $identity, object $entity): Query {
return $this->createAggregate($identity, $entity, $carry);
}
);
$query = $partitions
->get(false)
->reduce(
$query,
function(Query $carry, Identity $identity, object $entity): Query {
return $this->createRelationship($identity, $entity, $carry);
}
);
$this->variables = null;
return $query;
}
|
php
|
private function queryFor(MapInterface $entities): Query
{
$query = new Query\Query;
$this->variables = new Stream('string');
$partitions = $entities->partition(function(Identity $identity, object $entity): bool {
$meta = ($this->metadata)(\get_class($entity));
return $meta instanceof Aggregate;
});
$query = $partitions
->get(true)
->reduce(
$query,
function(Query $carry, Identity $identity, object $entity): Query {
return $this->createAggregate($identity, $entity, $carry);
}
);
$query = $partitions
->get(false)
->reduce(
$query,
function(Query $carry, Identity $identity, object $entity): Query {
return $this->createRelationship($identity, $entity, $carry);
}
);
$this->variables = null;
return $query;
}
|
[
"private",
"function",
"queryFor",
"(",
"MapInterface",
"$",
"entities",
")",
":",
"Query",
"{",
"$",
"query",
"=",
"new",
"Query",
"\\",
"Query",
";",
"$",
"this",
"->",
"variables",
"=",
"new",
"Stream",
"(",
"'string'",
")",
";",
"$",
"partitions",
"=",
"$",
"entities",
"->",
"partition",
"(",
"function",
"(",
"Identity",
"$",
"identity",
",",
"object",
"$",
"entity",
")",
":",
"bool",
"{",
"$",
"meta",
"=",
"(",
"$",
"this",
"->",
"metadata",
")",
"(",
"\\",
"get_class",
"(",
"$",
"entity",
")",
")",
";",
"return",
"$",
"meta",
"instanceof",
"Aggregate",
";",
"}",
")",
";",
"$",
"query",
"=",
"$",
"partitions",
"->",
"get",
"(",
"true",
")",
"->",
"reduce",
"(",
"$",
"query",
",",
"function",
"(",
"Query",
"$",
"carry",
",",
"Identity",
"$",
"identity",
",",
"object",
"$",
"entity",
")",
":",
"Query",
"{",
"return",
"$",
"this",
"->",
"createAggregate",
"(",
"$",
"identity",
",",
"$",
"entity",
",",
"$",
"carry",
")",
";",
"}",
")",
";",
"$",
"query",
"=",
"$",
"partitions",
"->",
"get",
"(",
"false",
")",
"->",
"reduce",
"(",
"$",
"query",
",",
"function",
"(",
"Query",
"$",
"carry",
",",
"Identity",
"$",
"identity",
",",
"object",
"$",
"entity",
")",
":",
"Query",
"{",
"return",
"$",
"this",
"->",
"createRelationship",
"(",
"$",
"identity",
",",
"$",
"entity",
",",
"$",
"carry",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"variables",
"=",
"null",
";",
"return",
"$",
"query",
";",
"}"
] |
Build the whole cypher query to insert at once all new nodes and relationships
@param MapInterface<Identity, object> $entities
|
[
"Build",
"the",
"whole",
"cypher",
"query",
"to",
"insert",
"at",
"once",
"all",
"new",
"nodes",
"and",
"relationships"
] |
816216802a9716bb5f20cc38336313b043bf764c
|
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/InsertPersister.php#L87-L116
|
239,345
|
Innmind/neo4j-onm
|
src/Persister/InsertPersister.php
|
InsertPersister.createAggregate
|
private function createAggregate(
Identity $identity,
object $entity,
Query $query
): Query {
$meta = ($this->metadata)(\get_class($entity));
$data = ($this->extract)($entity);
$varName = $this->name->sprintf(\md5($identity->value()));
$query = $query->create(
(string) $varName,
$meta->labels()->toPrimitive()
);
$paramKey = $varName->append('_props');
$properties = $this->buildProperties(
$meta->properties(),
$paramKey
);
$keysToKeep = $data->keys()->intersect($properties->keys());
$query = $query
->withProperty(
$meta->identity()->property(),
(string) $paramKey
->prepend('{')
->append('}.')
->append($meta->identity()->property())
)
->withProperties($properties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $paramKey,
$data
->filter(static function(string $key) use ($keysToKeep): bool {
return $keysToKeep->contains($key);
})
->put(
$meta->identity()->property(),
$identity->value()
)
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
);
$query = $meta
->children()
->reduce(
$query,
function(Query $carry, string $property, Child $child) use ($varName, $data): Query {
return $this->createAggregateChild(
$child,
$varName,
$data->get($property),
$carry
);
}
);
$this->variables = $this->variables->add((string) $varName);
return $query;
}
|
php
|
private function createAggregate(
Identity $identity,
object $entity,
Query $query
): Query {
$meta = ($this->metadata)(\get_class($entity));
$data = ($this->extract)($entity);
$varName = $this->name->sprintf(\md5($identity->value()));
$query = $query->create(
(string) $varName,
$meta->labels()->toPrimitive()
);
$paramKey = $varName->append('_props');
$properties = $this->buildProperties(
$meta->properties(),
$paramKey
);
$keysToKeep = $data->keys()->intersect($properties->keys());
$query = $query
->withProperty(
$meta->identity()->property(),
(string) $paramKey
->prepend('{')
->append('}.')
->append($meta->identity()->property())
)
->withProperties($properties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $paramKey,
$data
->filter(static function(string $key) use ($keysToKeep): bool {
return $keysToKeep->contains($key);
})
->put(
$meta->identity()->property(),
$identity->value()
)
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
);
$query = $meta
->children()
->reduce(
$query,
function(Query $carry, string $property, Child $child) use ($varName, $data): Query {
return $this->createAggregateChild(
$child,
$varName,
$data->get($property),
$carry
);
}
);
$this->variables = $this->variables->add((string) $varName);
return $query;
}
|
[
"private",
"function",
"createAggregate",
"(",
"Identity",
"$",
"identity",
",",
"object",
"$",
"entity",
",",
"Query",
"$",
"query",
")",
":",
"Query",
"{",
"$",
"meta",
"=",
"(",
"$",
"this",
"->",
"metadata",
")",
"(",
"\\",
"get_class",
"(",
"$",
"entity",
")",
")",
";",
"$",
"data",
"=",
"(",
"$",
"this",
"->",
"extract",
")",
"(",
"$",
"entity",
")",
";",
"$",
"varName",
"=",
"$",
"this",
"->",
"name",
"->",
"sprintf",
"(",
"\\",
"md5",
"(",
"$",
"identity",
"->",
"value",
"(",
")",
")",
")",
";",
"$",
"query",
"=",
"$",
"query",
"->",
"create",
"(",
"(",
"string",
")",
"$",
"varName",
",",
"$",
"meta",
"->",
"labels",
"(",
")",
"->",
"toPrimitive",
"(",
")",
")",
";",
"$",
"paramKey",
"=",
"$",
"varName",
"->",
"append",
"(",
"'_props'",
")",
";",
"$",
"properties",
"=",
"$",
"this",
"->",
"buildProperties",
"(",
"$",
"meta",
"->",
"properties",
"(",
")",
",",
"$",
"paramKey",
")",
";",
"$",
"keysToKeep",
"=",
"$",
"data",
"->",
"keys",
"(",
")",
"->",
"intersect",
"(",
"$",
"properties",
"->",
"keys",
"(",
")",
")",
";",
"$",
"query",
"=",
"$",
"query",
"->",
"withProperty",
"(",
"$",
"meta",
"->",
"identity",
"(",
")",
"->",
"property",
"(",
")",
",",
"(",
"string",
")",
"$",
"paramKey",
"->",
"prepend",
"(",
"'{'",
")",
"->",
"append",
"(",
"'}.'",
")",
"->",
"append",
"(",
"$",
"meta",
"->",
"identity",
"(",
")",
"->",
"property",
"(",
")",
")",
")",
"->",
"withProperties",
"(",
"$",
"properties",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"property",
",",
"string",
"$",
"cypher",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"property",
"]",
"=",
"$",
"cypher",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
"->",
"withParameter",
"(",
"(",
"string",
")",
"$",
"paramKey",
",",
"$",
"data",
"->",
"filter",
"(",
"static",
"function",
"(",
"string",
"$",
"key",
")",
"use",
"(",
"$",
"keysToKeep",
")",
":",
"bool",
"{",
"return",
"$",
"keysToKeep",
"->",
"contains",
"(",
"$",
"key",
")",
";",
"}",
")",
"->",
"put",
"(",
"$",
"meta",
"->",
"identity",
"(",
")",
"->",
"property",
"(",
")",
",",
"$",
"identity",
"->",
"value",
"(",
")",
")",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
";",
"$",
"query",
"=",
"$",
"meta",
"->",
"children",
"(",
")",
"->",
"reduce",
"(",
"$",
"query",
",",
"function",
"(",
"Query",
"$",
"carry",
",",
"string",
"$",
"property",
",",
"Child",
"$",
"child",
")",
"use",
"(",
"$",
"varName",
",",
"$",
"data",
")",
":",
"Query",
"{",
"return",
"$",
"this",
"->",
"createAggregateChild",
"(",
"$",
"child",
",",
"$",
"varName",
",",
"$",
"data",
"->",
"get",
"(",
"$",
"property",
")",
",",
"$",
"carry",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"variables",
"=",
"$",
"this",
"->",
"variables",
"->",
"add",
"(",
"(",
"string",
")",
"$",
"varName",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Add the cypher clause to create the node corresponding to the root of the aggregate
|
[
"Add",
"the",
"cypher",
"clause",
"to",
"create",
"the",
"node",
"corresponding",
"to",
"the",
"root",
"of",
"the",
"aggregate"
] |
816216802a9716bb5f20cc38336313b043bf764c
|
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/InsertPersister.php#L121-L193
|
239,346
|
Innmind/neo4j-onm
|
src/Persister/InsertPersister.php
|
InsertPersister.createAggregateChild
|
private function createAggregateChild(
Child $meta,
Str $nodeName,
MapInterface $data,
Query $query
): Query {
$relationshipName = $nodeName
->append('_')
->append($meta->relationship()->property());
$endNodeName = $relationshipName
->append('_')
->append($meta->relationship()->childProperty());
$endNodeProperties = $this->buildProperties(
$meta->properties(),
$endNodeParamKey = $endNodeName->append('_props')
);
$relationshipProperties = $this->buildProperties(
$meta->relationship()->properties(),
$relationshipParamKey = $relationshipName->append('_props')
);
return $query
->create((string) $nodeName)
->linkedTo(
(string) $endNodeName,
$meta->labels()->toPrimitive()
)
->withProperties($endNodeProperties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $endNodeParamKey,
$data
->get($meta->relationship()->childProperty())
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
)
->through(
(string) $meta->relationship()->type(),
(string) $relationshipName,
'left'
)
->withProperties($relationshipProperties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $relationshipParamKey,
$data
->remove($meta->relationship()->childProperty())
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
);
}
|
php
|
private function createAggregateChild(
Child $meta,
Str $nodeName,
MapInterface $data,
Query $query
): Query {
$relationshipName = $nodeName
->append('_')
->append($meta->relationship()->property());
$endNodeName = $relationshipName
->append('_')
->append($meta->relationship()->childProperty());
$endNodeProperties = $this->buildProperties(
$meta->properties(),
$endNodeParamKey = $endNodeName->append('_props')
);
$relationshipProperties = $this->buildProperties(
$meta->relationship()->properties(),
$relationshipParamKey = $relationshipName->append('_props')
);
return $query
->create((string) $nodeName)
->linkedTo(
(string) $endNodeName,
$meta->labels()->toPrimitive()
)
->withProperties($endNodeProperties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $endNodeParamKey,
$data
->get($meta->relationship()->childProperty())
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
)
->through(
(string) $meta->relationship()->type(),
(string) $relationshipName,
'left'
)
->withProperties($relationshipProperties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $relationshipParamKey,
$data
->remove($meta->relationship()->childProperty())
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
);
}
|
[
"private",
"function",
"createAggregateChild",
"(",
"Child",
"$",
"meta",
",",
"Str",
"$",
"nodeName",
",",
"MapInterface",
"$",
"data",
",",
"Query",
"$",
"query",
")",
":",
"Query",
"{",
"$",
"relationshipName",
"=",
"$",
"nodeName",
"->",
"append",
"(",
"'_'",
")",
"->",
"append",
"(",
"$",
"meta",
"->",
"relationship",
"(",
")",
"->",
"property",
"(",
")",
")",
";",
"$",
"endNodeName",
"=",
"$",
"relationshipName",
"->",
"append",
"(",
"'_'",
")",
"->",
"append",
"(",
"$",
"meta",
"->",
"relationship",
"(",
")",
"->",
"childProperty",
"(",
")",
")",
";",
"$",
"endNodeProperties",
"=",
"$",
"this",
"->",
"buildProperties",
"(",
"$",
"meta",
"->",
"properties",
"(",
")",
",",
"$",
"endNodeParamKey",
"=",
"$",
"endNodeName",
"->",
"append",
"(",
"'_props'",
")",
")",
";",
"$",
"relationshipProperties",
"=",
"$",
"this",
"->",
"buildProperties",
"(",
"$",
"meta",
"->",
"relationship",
"(",
")",
"->",
"properties",
"(",
")",
",",
"$",
"relationshipParamKey",
"=",
"$",
"relationshipName",
"->",
"append",
"(",
"'_props'",
")",
")",
";",
"return",
"$",
"query",
"->",
"create",
"(",
"(",
"string",
")",
"$",
"nodeName",
")",
"->",
"linkedTo",
"(",
"(",
"string",
")",
"$",
"endNodeName",
",",
"$",
"meta",
"->",
"labels",
"(",
")",
"->",
"toPrimitive",
"(",
")",
")",
"->",
"withProperties",
"(",
"$",
"endNodeProperties",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"property",
",",
"string",
"$",
"cypher",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"property",
"]",
"=",
"$",
"cypher",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
"->",
"withParameter",
"(",
"(",
"string",
")",
"$",
"endNodeParamKey",
",",
"$",
"data",
"->",
"get",
"(",
"$",
"meta",
"->",
"relationship",
"(",
")",
"->",
"childProperty",
"(",
")",
")",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
"->",
"through",
"(",
"(",
"string",
")",
"$",
"meta",
"->",
"relationship",
"(",
")",
"->",
"type",
"(",
")",
",",
"(",
"string",
")",
"$",
"relationshipName",
",",
"'left'",
")",
"->",
"withProperties",
"(",
"$",
"relationshipProperties",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"property",
",",
"string",
"$",
"cypher",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"property",
"]",
"=",
"$",
"cypher",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
"->",
"withParameter",
"(",
"(",
"string",
")",
"$",
"relationshipParamKey",
",",
"$",
"data",
"->",
"remove",
"(",
"$",
"meta",
"->",
"relationship",
"(",
")",
"->",
"childProperty",
"(",
")",
")",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
";",
"}"
] |
Add the cypher clause to build the relationship and the node corresponding
to a child of the aggregate
@param MapInterface<string, mixed> $data
|
[
"Add",
"the",
"cypher",
"clause",
"to",
"build",
"the",
"relationship",
"and",
"the",
"node",
"corresponding",
"to",
"a",
"child",
"of",
"the",
"aggregate"
] |
816216802a9716bb5f20cc38336313b043bf764c
|
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/InsertPersister.php#L201-L275
|
239,347
|
Innmind/neo4j-onm
|
src/Persister/InsertPersister.php
|
InsertPersister.buildProperties
|
private function buildProperties(
MapInterface $properties,
Str $name
): MapInterface {
$name = $name->prepend('{')->append('}.');
return $properties->reduce(
new Map('string', 'string'),
static function(MapInterface $carry, string $property) use ($name): MapInterface {
return $carry->put(
$property,
(string) $name->append($property)
);
}
);
}
|
php
|
private function buildProperties(
MapInterface $properties,
Str $name
): MapInterface {
$name = $name->prepend('{')->append('}.');
return $properties->reduce(
new Map('string', 'string'),
static function(MapInterface $carry, string $property) use ($name): MapInterface {
return $carry->put(
$property,
(string) $name->append($property)
);
}
);
}
|
[
"private",
"function",
"buildProperties",
"(",
"MapInterface",
"$",
"properties",
",",
"Str",
"$",
"name",
")",
":",
"MapInterface",
"{",
"$",
"name",
"=",
"$",
"name",
"->",
"prepend",
"(",
"'{'",
")",
"->",
"append",
"(",
"'}.'",
")",
";",
"return",
"$",
"properties",
"->",
"reduce",
"(",
"new",
"Map",
"(",
"'string'",
",",
"'string'",
")",
",",
"static",
"function",
"(",
"MapInterface",
"$",
"carry",
",",
"string",
"$",
"property",
")",
"use",
"(",
"$",
"name",
")",
":",
"MapInterface",
"{",
"return",
"$",
"carry",
"->",
"put",
"(",
"$",
"property",
",",
"(",
"string",
")",
"$",
"name",
"->",
"append",
"(",
"$",
"property",
")",
")",
";",
"}",
")",
";",
"}"
] |
Build the collection of properties to be injected in the query
@param MapInterface<string, Property> $properties
@return MapInterface<string, string>
|
[
"Build",
"the",
"collection",
"of",
"properties",
"to",
"be",
"injected",
"in",
"the",
"query"
] |
816216802a9716bb5f20cc38336313b043bf764c
|
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/InsertPersister.php#L284-L299
|
239,348
|
Innmind/neo4j-onm
|
src/Persister/InsertPersister.php
|
InsertPersister.createRelationship
|
private function createRelationship(
Identity $identity,
object $entity,
Query $query
): Query {
$meta = ($this->metadata)(\get_class($entity));
$data = ($this->extract)($entity);
$start = $data->get($meta->startNode()->property());
$end = $data->get($meta->endNode()->property());
$varName = $this->name->sprintf(\md5($identity->value()));
$startName = $this->name->sprintf(\md5($start));
$endName = $this->name->sprintf(\md5($end));
$paramKey = $varName->append('_props');
$properties = $this->buildProperties($meta->properties(), $paramKey);
$keysToKeep = $data->keys()->intersect($properties->keys());
return $this
->matchEdge(
$endName,
$meta->endNode(),
$end,
$this->matchEdge(
$startName,
$meta->startNode(),
$start,
$query
)
)
->create((string) $startName)
->linkedTo((string) $endName)
->through(
(string) $meta->type(),
(string) $varName,
'right'
)
->withProperty(
$meta->identity()->property(),
(string) $paramKey
->prepend('{')
->append('}.')
->append($meta->identity()->property())
)
->withProperties($properties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $paramKey,
$data
->filter(static function(string $key) use ($keysToKeep): bool {
return $keysToKeep->contains($key);
})
->put($meta->identity()->property(), $identity->value())
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
);
}
|
php
|
private function createRelationship(
Identity $identity,
object $entity,
Query $query
): Query {
$meta = ($this->metadata)(\get_class($entity));
$data = ($this->extract)($entity);
$start = $data->get($meta->startNode()->property());
$end = $data->get($meta->endNode()->property());
$varName = $this->name->sprintf(\md5($identity->value()));
$startName = $this->name->sprintf(\md5($start));
$endName = $this->name->sprintf(\md5($end));
$paramKey = $varName->append('_props');
$properties = $this->buildProperties($meta->properties(), $paramKey);
$keysToKeep = $data->keys()->intersect($properties->keys());
return $this
->matchEdge(
$endName,
$meta->endNode(),
$end,
$this->matchEdge(
$startName,
$meta->startNode(),
$start,
$query
)
)
->create((string) $startName)
->linkedTo((string) $endName)
->through(
(string) $meta->type(),
(string) $varName,
'right'
)
->withProperty(
$meta->identity()->property(),
(string) $paramKey
->prepend('{')
->append('}.')
->append($meta->identity()->property())
)
->withProperties($properties->reduce(
[],
static function(array $carry, string $property, string $cypher): array {
$carry[$property] = $cypher;
return $carry;
}
))
->withParameter(
(string) $paramKey,
$data
->filter(static function(string $key) use ($keysToKeep): bool {
return $keysToKeep->contains($key);
})
->put($meta->identity()->property(), $identity->value())
->reduce(
[],
static function(array $carry, string $key, $value): array {
$carry[$key] = $value;
return $carry;
}
)
);
}
|
[
"private",
"function",
"createRelationship",
"(",
"Identity",
"$",
"identity",
",",
"object",
"$",
"entity",
",",
"Query",
"$",
"query",
")",
":",
"Query",
"{",
"$",
"meta",
"=",
"(",
"$",
"this",
"->",
"metadata",
")",
"(",
"\\",
"get_class",
"(",
"$",
"entity",
")",
")",
";",
"$",
"data",
"=",
"(",
"$",
"this",
"->",
"extract",
")",
"(",
"$",
"entity",
")",
";",
"$",
"start",
"=",
"$",
"data",
"->",
"get",
"(",
"$",
"meta",
"->",
"startNode",
"(",
")",
"->",
"property",
"(",
")",
")",
";",
"$",
"end",
"=",
"$",
"data",
"->",
"get",
"(",
"$",
"meta",
"->",
"endNode",
"(",
")",
"->",
"property",
"(",
")",
")",
";",
"$",
"varName",
"=",
"$",
"this",
"->",
"name",
"->",
"sprintf",
"(",
"\\",
"md5",
"(",
"$",
"identity",
"->",
"value",
"(",
")",
")",
")",
";",
"$",
"startName",
"=",
"$",
"this",
"->",
"name",
"->",
"sprintf",
"(",
"\\",
"md5",
"(",
"$",
"start",
")",
")",
";",
"$",
"endName",
"=",
"$",
"this",
"->",
"name",
"->",
"sprintf",
"(",
"\\",
"md5",
"(",
"$",
"end",
")",
")",
";",
"$",
"paramKey",
"=",
"$",
"varName",
"->",
"append",
"(",
"'_props'",
")",
";",
"$",
"properties",
"=",
"$",
"this",
"->",
"buildProperties",
"(",
"$",
"meta",
"->",
"properties",
"(",
")",
",",
"$",
"paramKey",
")",
";",
"$",
"keysToKeep",
"=",
"$",
"data",
"->",
"keys",
"(",
")",
"->",
"intersect",
"(",
"$",
"properties",
"->",
"keys",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"matchEdge",
"(",
"$",
"endName",
",",
"$",
"meta",
"->",
"endNode",
"(",
")",
",",
"$",
"end",
",",
"$",
"this",
"->",
"matchEdge",
"(",
"$",
"startName",
",",
"$",
"meta",
"->",
"startNode",
"(",
")",
",",
"$",
"start",
",",
"$",
"query",
")",
")",
"->",
"create",
"(",
"(",
"string",
")",
"$",
"startName",
")",
"->",
"linkedTo",
"(",
"(",
"string",
")",
"$",
"endName",
")",
"->",
"through",
"(",
"(",
"string",
")",
"$",
"meta",
"->",
"type",
"(",
")",
",",
"(",
"string",
")",
"$",
"varName",
",",
"'right'",
")",
"->",
"withProperty",
"(",
"$",
"meta",
"->",
"identity",
"(",
")",
"->",
"property",
"(",
")",
",",
"(",
"string",
")",
"$",
"paramKey",
"->",
"prepend",
"(",
"'{'",
")",
"->",
"append",
"(",
"'}.'",
")",
"->",
"append",
"(",
"$",
"meta",
"->",
"identity",
"(",
")",
"->",
"property",
"(",
")",
")",
")",
"->",
"withProperties",
"(",
"$",
"properties",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"property",
",",
"string",
"$",
"cypher",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"property",
"]",
"=",
"$",
"cypher",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
"->",
"withParameter",
"(",
"(",
"string",
")",
"$",
"paramKey",
",",
"$",
"data",
"->",
"filter",
"(",
"static",
"function",
"(",
"string",
"$",
"key",
")",
"use",
"(",
"$",
"keysToKeep",
")",
":",
"bool",
"{",
"return",
"$",
"keysToKeep",
"->",
"contains",
"(",
"$",
"key",
")",
";",
"}",
")",
"->",
"put",
"(",
"$",
"meta",
"->",
"identity",
"(",
")",
"->",
"property",
"(",
")",
",",
"$",
"identity",
"->",
"value",
"(",
")",
")",
"->",
"reduce",
"(",
"[",
"]",
",",
"static",
"function",
"(",
"array",
"$",
"carry",
",",
"string",
"$",
"key",
",",
"$",
"value",
")",
":",
"array",
"{",
"$",
"carry",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"return",
"$",
"carry",
";",
"}",
")",
")",
";",
"}"
] |
Add the clause to create a relationship between nodes
|
[
"Add",
"the",
"clause",
"to",
"create",
"a",
"relationship",
"between",
"nodes"
] |
816216802a9716bb5f20cc38336313b043bf764c
|
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/InsertPersister.php#L304-L371
|
239,349
|
Innmind/neo4j-onm
|
src/Persister/InsertPersister.php
|
InsertPersister.matchEdge
|
private function matchEdge(
Str $name,
RelationshipEdge $meta,
$value,
Query $query
): Query {
if ($this->variables->contains((string) $name)) {
return $query;
}
if ($this->variables->size() > 0) {
$query = $query->with(...$this->variables->toPrimitive());
}
$this->variables = $this->variables->add((string) $name);
return $query
->match((string) $name)
->withProperty(
$meta->target(),
(string) $name
->prepend('{')
->append('_props}.')
->append($meta->target())
)
->withParameter(
(string) $name->append('_props'),
[
$meta->target() => $value,
]
);
}
|
php
|
private function matchEdge(
Str $name,
RelationshipEdge $meta,
$value,
Query $query
): Query {
if ($this->variables->contains((string) $name)) {
return $query;
}
if ($this->variables->size() > 0) {
$query = $query->with(...$this->variables->toPrimitive());
}
$this->variables = $this->variables->add((string) $name);
return $query
->match((string) $name)
->withProperty(
$meta->target(),
(string) $name
->prepend('{')
->append('_props}.')
->append($meta->target())
)
->withParameter(
(string) $name->append('_props'),
[
$meta->target() => $value,
]
);
}
|
[
"private",
"function",
"matchEdge",
"(",
"Str",
"$",
"name",
",",
"RelationshipEdge",
"$",
"meta",
",",
"$",
"value",
",",
"Query",
"$",
"query",
")",
":",
"Query",
"{",
"if",
"(",
"$",
"this",
"->",
"variables",
"->",
"contains",
"(",
"(",
"string",
")",
"$",
"name",
")",
")",
"{",
"return",
"$",
"query",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"variables",
"->",
"size",
"(",
")",
">",
"0",
")",
"{",
"$",
"query",
"=",
"$",
"query",
"->",
"with",
"(",
"...",
"$",
"this",
"->",
"variables",
"->",
"toPrimitive",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"variables",
"=",
"$",
"this",
"->",
"variables",
"->",
"add",
"(",
"(",
"string",
")",
"$",
"name",
")",
";",
"return",
"$",
"query",
"->",
"match",
"(",
"(",
"string",
")",
"$",
"name",
")",
"->",
"withProperty",
"(",
"$",
"meta",
"->",
"target",
"(",
")",
",",
"(",
"string",
")",
"$",
"name",
"->",
"prepend",
"(",
"'{'",
")",
"->",
"append",
"(",
"'_props}.'",
")",
"->",
"append",
"(",
"$",
"meta",
"->",
"target",
"(",
")",
")",
")",
"->",
"withParameter",
"(",
"(",
"string",
")",
"$",
"name",
"->",
"append",
"(",
"'_props'",
")",
",",
"[",
"$",
"meta",
"->",
"target",
"(",
")",
"=>",
"$",
"value",
",",
"]",
")",
";",
"}"
] |
Add the clause to match the target node in case it's node that is not
persisted via the current query
@param mixed $value
|
[
"Add",
"the",
"clause",
"to",
"match",
"the",
"target",
"node",
"in",
"case",
"it",
"s",
"node",
"that",
"is",
"not",
"persisted",
"via",
"the",
"current",
"query"
] |
816216802a9716bb5f20cc38336313b043bf764c
|
https://github.com/Innmind/neo4j-onm/blob/816216802a9716bb5f20cc38336313b043bf764c/src/Persister/InsertPersister.php#L379-L410
|
239,350
|
dave-redfern/somnambulist-collection
|
src/Utils/CollectionKeyWalker.php
|
CollectionKeyWalker.walk
|
public static function walk($collection, $key, $default = null)
{
if (is_null($key)) {
return $collection;
}
if (is_string($key) && mb_substr($key, 0, 1) == '@') {
if (Support::keyExists($collection, mb_substr($key, 1))) {
return $collection[mb_substr($key, 1)];
}
return Support::value($default);
}
$key = is_array($key) ? $key : explode('.', $key);
while (!is_null($segment = array_shift($key))) {
if ($segment === '*') {
if ($collection instanceof Collection) {
$collection = $collection->all();
} elseif (!is_array($collection)) {
return Support::value($default);
}
$result = static::extract($collection, $key, null, $default);
return in_array('*', $key) ? Support::flatten($result) : $result;
}
if (Support::isTraversable($collection) && Support::keyExists($collection, $segment)) {
$collection = $collection[$segment];
} elseif (is_object($collection) && isset($collection->{$segment})) {
$collection = $collection->{$segment};
} elseif (is_object($collection) && !($collection instanceof Collection) && method_exists($collection, $segment)) {
$collection = $collection->{$segment}();
} elseif (is_object($collection) && !($collection instanceof Collection) && method_exists($collection, 'get' . ucwords($segment))) {
$collection = $collection->{'get' . ucwords($segment)}();
} else {
return Support::value($default);
}
}
return $collection;
}
|
php
|
public static function walk($collection, $key, $default = null)
{
if (is_null($key)) {
return $collection;
}
if (is_string($key) && mb_substr($key, 0, 1) == '@') {
if (Support::keyExists($collection, mb_substr($key, 1))) {
return $collection[mb_substr($key, 1)];
}
return Support::value($default);
}
$key = is_array($key) ? $key : explode('.', $key);
while (!is_null($segment = array_shift($key))) {
if ($segment === '*') {
if ($collection instanceof Collection) {
$collection = $collection->all();
} elseif (!is_array($collection)) {
return Support::value($default);
}
$result = static::extract($collection, $key, null, $default);
return in_array('*', $key) ? Support::flatten($result) : $result;
}
if (Support::isTraversable($collection) && Support::keyExists($collection, $segment)) {
$collection = $collection[$segment];
} elseif (is_object($collection) && isset($collection->{$segment})) {
$collection = $collection->{$segment};
} elseif (is_object($collection) && !($collection instanceof Collection) && method_exists($collection, $segment)) {
$collection = $collection->{$segment}();
} elseif (is_object($collection) && !($collection instanceof Collection) && method_exists($collection, 'get' . ucwords($segment))) {
$collection = $collection->{'get' . ucwords($segment)}();
} else {
return Support::value($default);
}
}
return $collection;
}
|
[
"public",
"static",
"function",
"walk",
"(",
"$",
"collection",
",",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"collection",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"key",
")",
"&&",
"mb_substr",
"(",
"$",
"key",
",",
"0",
",",
"1",
")",
"==",
"'@'",
")",
"{",
"if",
"(",
"Support",
"::",
"keyExists",
"(",
"$",
"collection",
",",
"mb_substr",
"(",
"$",
"key",
",",
"1",
")",
")",
")",
"{",
"return",
"$",
"collection",
"[",
"mb_substr",
"(",
"$",
"key",
",",
"1",
")",
"]",
";",
"}",
"return",
"Support",
"::",
"value",
"(",
"$",
"default",
")",
";",
"}",
"$",
"key",
"=",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"while",
"(",
"!",
"is_null",
"(",
"$",
"segment",
"=",
"array_shift",
"(",
"$",
"key",
")",
")",
")",
"{",
"if",
"(",
"$",
"segment",
"===",
"'*'",
")",
"{",
"if",
"(",
"$",
"collection",
"instanceof",
"Collection",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"all",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"collection",
")",
")",
"{",
"return",
"Support",
"::",
"value",
"(",
"$",
"default",
")",
";",
"}",
"$",
"result",
"=",
"static",
"::",
"extract",
"(",
"$",
"collection",
",",
"$",
"key",
",",
"null",
",",
"$",
"default",
")",
";",
"return",
"in_array",
"(",
"'*'",
",",
"$",
"key",
")",
"?",
"Support",
"::",
"flatten",
"(",
"$",
"result",
")",
":",
"$",
"result",
";",
"}",
"if",
"(",
"Support",
"::",
"isTraversable",
"(",
"$",
"collection",
")",
"&&",
"Support",
"::",
"keyExists",
"(",
"$",
"collection",
",",
"$",
"segment",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"[",
"$",
"segment",
"]",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"collection",
")",
"&&",
"isset",
"(",
"$",
"collection",
"->",
"{",
"$",
"segment",
"}",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"{",
"$",
"segment",
"}",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"collection",
")",
"&&",
"!",
"(",
"$",
"collection",
"instanceof",
"Collection",
")",
"&&",
"method_exists",
"(",
"$",
"collection",
",",
"$",
"segment",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"{",
"$",
"segment",
"}",
"(",
")",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"collection",
")",
"&&",
"!",
"(",
"$",
"collection",
"instanceof",
"Collection",
")",
"&&",
"method_exists",
"(",
"$",
"collection",
",",
"'get'",
".",
"ucwords",
"(",
"$",
"segment",
")",
")",
")",
"{",
"$",
"collection",
"=",
"$",
"collection",
"->",
"{",
"'get'",
".",
"ucwords",
"(",
"$",
"segment",
")",
"}",
"(",
")",
";",
"}",
"else",
"{",
"return",
"Support",
"::",
"value",
"(",
"$",
"default",
")",
";",
"}",
"}",
"return",
"$",
"collection",
";",
"}"
] |
Walks the collection accessing nested members defined in the key by dot notation
@param Collection|array $collection
@param string $key
@param null|mixed $default
@return array|mixed
|
[
"Walks",
"the",
"collection",
"accessing",
"nested",
"members",
"defined",
"in",
"the",
"key",
"by",
"dot",
"notation"
] |
82cf33c333b00ff375c403fbc7f32e4b476ee0b1
|
https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Utils/CollectionKeyWalker.php#L44-L86
|
239,351
|
dave-redfern/somnambulist-collection
|
src/Utils/CollectionKeyWalker.php
|
CollectionKeyWalker.extract
|
public static function extract($collection, $value, $key = null, $default = null)
{
$results = [];
[$value, $key] = static::extractKeyValueParameters($value, $key);
foreach ($collection as $item) {
$itemValue = static::walk($item, $value, $default);
if (is_null($key)) {
$results[] = $itemValue;
} else {
$itemKey = static::walk($item, $key, $default);
$results[$itemKey] = $itemValue;
}
}
return $results;
}
|
php
|
public static function extract($collection, $value, $key = null, $default = null)
{
$results = [];
[$value, $key] = static::extractKeyValueParameters($value, $key);
foreach ($collection as $item) {
$itemValue = static::walk($item, $value, $default);
if (is_null($key)) {
$results[] = $itemValue;
} else {
$itemKey = static::walk($item, $key, $default);
$results[$itemKey] = $itemValue;
}
}
return $results;
}
|
[
"public",
"static",
"function",
"extract",
"(",
"$",
"collection",
",",
"$",
"value",
",",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"[",
"$",
"value",
",",
"$",
"key",
"]",
"=",
"static",
"::",
"extractKeyValueParameters",
"(",
"$",
"value",
",",
"$",
"key",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"item",
")",
"{",
"$",
"itemValue",
"=",
"static",
"::",
"walk",
"(",
"$",
"item",
",",
"$",
"value",
",",
"$",
"default",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"key",
")",
")",
"{",
"$",
"results",
"[",
"]",
"=",
"$",
"itemValue",
";",
"}",
"else",
"{",
"$",
"itemKey",
"=",
"static",
"::",
"walk",
"(",
"$",
"item",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"$",
"results",
"[",
"$",
"itemKey",
"]",
"=",
"$",
"itemValue",
";",
"}",
"}",
"return",
"$",
"results",
";",
"}"
] |
Extracts values from a Collection, array or set of objects
@param array|Collection $collection
@param string|array $value
@param string|array|null $key
@param mixed|null $default
@return array
|
[
"Extracts",
"values",
"from",
"a",
"Collection",
"array",
"or",
"set",
"of",
"objects"
] |
82cf33c333b00ff375c403fbc7f32e4b476ee0b1
|
https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Utils/CollectionKeyWalker.php#L98-L117
|
239,352
|
dave-redfern/somnambulist-collection
|
src/Utils/CollectionKeyWalker.php
|
CollectionKeyWalker.extractKeyValueParameters
|
protected static function extractKeyValueParameters($value, $key)
{
$value = is_string($value) ? explode('.', $value) : $value;
$key = is_null($key) || is_array($key) ? $key : explode('.', $key);
return [$value, $key];
}
|
php
|
protected static function extractKeyValueParameters($value, $key)
{
$value = is_string($value) ? explode('.', $value) : $value;
$key = is_null($key) || is_array($key) ? $key : explode('.', $key);
return [$value, $key];
}
|
[
"protected",
"static",
"function",
"extractKeyValueParameters",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"$",
"value",
"=",
"is_string",
"(",
"$",
"value",
")",
"?",
"explode",
"(",
"'.'",
",",
"$",
"value",
")",
":",
"$",
"value",
";",
"$",
"key",
"=",
"is_null",
"(",
"$",
"key",
")",
"||",
"is_array",
"(",
"$",
"key",
")",
"?",
"$",
"key",
":",
"explode",
"(",
"'.'",
",",
"$",
"key",
")",
";",
"return",
"[",
"$",
"value",
",",
"$",
"key",
"]",
";",
"}"
] |
Normalises the key and value to be used with extract
@param string|array $value
@param string|array|null $key
@return array
|
[
"Normalises",
"the",
"key",
"and",
"value",
"to",
"be",
"used",
"with",
"extract"
] |
82cf33c333b00ff375c403fbc7f32e4b476ee0b1
|
https://github.com/dave-redfern/somnambulist-collection/blob/82cf33c333b00ff375c403fbc7f32e4b476ee0b1/src/Utils/CollectionKeyWalker.php#L127-L133
|
239,353
|
chilimatic/datastructure-component
|
src/Graph/Collection.php
|
Collection.removeNode
|
public function removeNode(Node $node = null) : bool
{
if (!$node) {
return true;
}
// flag for GC
unset($this->list[$node->key], $this->keyList[$node->key], $this->idList[$node->id]);
return true;
}
|
php
|
public function removeNode(Node $node = null) : bool
{
if (!$node) {
return true;
}
// flag for GC
unset($this->list[$node->key], $this->keyList[$node->key], $this->idList[$node->id]);
return true;
}
|
[
"public",
"function",
"removeNode",
"(",
"Node",
"$",
"node",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"node",
")",
"{",
"return",
"true",
";",
"}",
"// flag for GC",
"unset",
"(",
"$",
"this",
"->",
"list",
"[",
"$",
"node",
"->",
"key",
"]",
",",
"$",
"this",
"->",
"keyList",
"[",
"$",
"node",
"->",
"key",
"]",
",",
"$",
"this",
"->",
"idList",
"[",
"$",
"node",
"->",
"id",
"]",
")",
";",
"return",
"true",
";",
"}"
] |
removes a specific node
@param Node $node
@return $this
|
[
"removes",
"a",
"specific",
"node"
] |
37832e5fab2a9520f9b025160b31a34c06bd71cd
|
https://github.com/chilimatic/datastructure-component/blob/37832e5fab2a9520f9b025160b31a34c06bd71cd/src/Graph/Collection.php#L293-L302
|
239,354
|
crater-framework/crater-php-framework
|
Orm/TableGateway.php
|
TableGateway.insert
|
public function insert(array $data)
{
$params = array();
$query = "INSERT INTO $this->_name (";
foreach ($data as $key => $value) {
$query .= "$key, ";
}
$query = substr($query, 0, -2);
$query .= ") VALUES (";
$iValue = 0;
foreach ($data as $key => $value) {
$query .= ":value$iValue, ";
$params[":value$iValue"] = $value;
$iValue++;
}
$query = substr($query, 0, -2);
$query .= ")";
return $this->_insert($query, $params);
}
|
php
|
public function insert(array $data)
{
$params = array();
$query = "INSERT INTO $this->_name (";
foreach ($data as $key => $value) {
$query .= "$key, ";
}
$query = substr($query, 0, -2);
$query .= ") VALUES (";
$iValue = 0;
foreach ($data as $key => $value) {
$query .= ":value$iValue, ";
$params[":value$iValue"] = $value;
$iValue++;
}
$query = substr($query, 0, -2);
$query .= ")";
return $this->_insert($query, $params);
}
|
[
"public",
"function",
"insert",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"query",
"=",
"\"INSERT INTO $this->_name (\"",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
".=",
"\"$key, \"",
";",
"}",
"$",
"query",
"=",
"substr",
"(",
"$",
"query",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"query",
".=",
"\") VALUES (\"",
";",
"$",
"iValue",
"=",
"0",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"query",
".=",
"\":value$iValue, \"",
";",
"$",
"params",
"[",
"\":value$iValue\"",
"]",
"=",
"$",
"value",
";",
"$",
"iValue",
"++",
";",
"}",
"$",
"query",
"=",
"substr",
"(",
"$",
"query",
",",
"0",
",",
"-",
"2",
")",
";",
"$",
"query",
".=",
"\")\"",
";",
"return",
"$",
"this",
"->",
"_insert",
"(",
"$",
"query",
",",
"$",
"params",
")",
";",
"}"
] |
Create new row
@param array $data Array with data ('column_name' => 'foo')
@return \Core\Orm\RowGateway | bool
|
[
"Create",
"new",
"row"
] |
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
|
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Orm/TableGateway.php#L22-L46
|
239,355
|
crater-framework/crater-php-framework
|
Orm/TableGateway.php
|
TableGateway.find
|
public function find($primaryKey)
{
$where = array(
$this->_primary => $primaryKey
);
$qp = $this->_fetch($where);
$row = $this->_fetchRow($qp['query'], $qp['params']);
$className = $this->_rowClass;
$class = new $className($this);
if (!$row) {
return false;
}
$class->setData($row);
return $class;
}
|
php
|
public function find($primaryKey)
{
$where = array(
$this->_primary => $primaryKey
);
$qp = $this->_fetch($where);
$row = $this->_fetchRow($qp['query'], $qp['params']);
$className = $this->_rowClass;
$class = new $className($this);
if (!$row) {
return false;
}
$class->setData($row);
return $class;
}
|
[
"public",
"function",
"find",
"(",
"$",
"primaryKey",
")",
"{",
"$",
"where",
"=",
"array",
"(",
"$",
"this",
"->",
"_primary",
"=>",
"$",
"primaryKey",
")",
";",
"$",
"qp",
"=",
"$",
"this",
"->",
"_fetch",
"(",
"$",
"where",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"_fetchRow",
"(",
"$",
"qp",
"[",
"'query'",
"]",
",",
"$",
"qp",
"[",
"'params'",
"]",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"_rowClass",
";",
"$",
"class",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
")",
";",
"if",
"(",
"!",
"$",
"row",
")",
"{",
"return",
"false",
";",
"}",
"$",
"class",
"->",
"setData",
"(",
"$",
"row",
")",
";",
"return",
"$",
"class",
";",
"}"
] |
Find a row by primary key
@param mixed $primaryKey Primary key value
@return \Core\Orm\RowGateway | bool
|
[
"Find",
"a",
"row",
"by",
"primary",
"key"
] |
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
|
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Orm/TableGateway.php#L54-L72
|
239,356
|
crater-framework/crater-php-framework
|
Orm/TableGateway.php
|
TableGateway.fetchRow
|
public function fetchRow(array $where = null, array $column = null, array $order = null)
{
$qp = $this->_fetch($where, $column, $order);
$row = $this->_fetchRow($qp['query'], $qp['params']);
$className = $this->_rowClass;
$class = new $className($this);
if (!$row) {
return false;
}
$class->setData($row);
return $class;
}
|
php
|
public function fetchRow(array $where = null, array $column = null, array $order = null)
{
$qp = $this->_fetch($where, $column, $order);
$row = $this->_fetchRow($qp['query'], $qp['params']);
$className = $this->_rowClass;
$class = new $className($this);
if (!$row) {
return false;
}
$class->setData($row);
return $class;
}
|
[
"public",
"function",
"fetchRow",
"(",
"array",
"$",
"where",
"=",
"null",
",",
"array",
"$",
"column",
"=",
"null",
",",
"array",
"$",
"order",
"=",
"null",
")",
"{",
"$",
"qp",
"=",
"$",
"this",
"->",
"_fetch",
"(",
"$",
"where",
",",
"$",
"column",
",",
"$",
"order",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"_fetchRow",
"(",
"$",
"qp",
"[",
"'query'",
"]",
",",
"$",
"qp",
"[",
"'params'",
"]",
")",
";",
"$",
"className",
"=",
"$",
"this",
"->",
"_rowClass",
";",
"$",
"class",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
")",
";",
"if",
"(",
"!",
"$",
"row",
")",
"{",
"return",
"false",
";",
"}",
"$",
"class",
"->",
"setData",
"(",
"$",
"row",
")",
";",
"return",
"$",
"class",
";",
"}"
] |
Fetch one row
@param array $where Where conditions array
@param array $column Array with columns that you want.
@param array $order Array with order condition ('first_name, last_name' => 'DESC')
@return \Core\Orm\RowGateway
|
[
"Fetch",
"one",
"row"
] |
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
|
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Orm/TableGateway.php#L82-L97
|
239,357
|
crater-framework/crater-php-framework
|
Orm/TableGateway.php
|
TableGateway.fetchAll
|
public function fetchAll(array $where = null, array $column = null, array $order = null, $limit = null, $lazy = false)
{
$qp = $this->_fetch($where, $column, $order, $limit);
$rows = $this->_fetchAll($qp['query'], $qp['params']);
if (!$rows) {
return false;
}
if (!$lazy) {
$hydratedRows = array();
foreach ($rows as $id => $row) {
$className = $this->_rowClass;
$class = new $className($this);
$class->setData($row);
$hydratedRows[$id] = $class;
}
return $hydratedRows;
}
return $rows;
}
|
php
|
public function fetchAll(array $where = null, array $column = null, array $order = null, $limit = null, $lazy = false)
{
$qp = $this->_fetch($where, $column, $order, $limit);
$rows = $this->_fetchAll($qp['query'], $qp['params']);
if (!$rows) {
return false;
}
if (!$lazy) {
$hydratedRows = array();
foreach ($rows as $id => $row) {
$className = $this->_rowClass;
$class = new $className($this);
$class->setData($row);
$hydratedRows[$id] = $class;
}
return $hydratedRows;
}
return $rows;
}
|
[
"public",
"function",
"fetchAll",
"(",
"array",
"$",
"where",
"=",
"null",
",",
"array",
"$",
"column",
"=",
"null",
",",
"array",
"$",
"order",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"lazy",
"=",
"false",
")",
"{",
"$",
"qp",
"=",
"$",
"this",
"->",
"_fetch",
"(",
"$",
"where",
",",
"$",
"column",
",",
"$",
"order",
",",
"$",
"limit",
")",
";",
"$",
"rows",
"=",
"$",
"this",
"->",
"_fetchAll",
"(",
"$",
"qp",
"[",
"'query'",
"]",
",",
"$",
"qp",
"[",
"'params'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"rows",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"lazy",
")",
"{",
"$",
"hydratedRows",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"rows",
"as",
"$",
"id",
"=>",
"$",
"row",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"_rowClass",
";",
"$",
"class",
"=",
"new",
"$",
"className",
"(",
"$",
"this",
")",
";",
"$",
"class",
"->",
"setData",
"(",
"$",
"row",
")",
";",
"$",
"hydratedRows",
"[",
"$",
"id",
"]",
"=",
"$",
"class",
";",
"}",
"return",
"$",
"hydratedRows",
";",
"}",
"return",
"$",
"rows",
";",
"}"
] |
Fetch all rows
@param array $where Where conditions array
@param array $column Array with columns that you want.
@param array $order Array with order condition ('first_name, last_name' => 'DESC')
@param string $limit String with limit value
@param bool $lazy Lazy return. If this is true, the response will be an array
@return array | bool
|
[
"Fetch",
"all",
"rows"
] |
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
|
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Orm/TableGateway.php#L109-L130
|
239,358
|
crater-framework/crater-php-framework
|
Orm/TableGateway.php
|
TableGateway.update
|
public function update(array $data, array $where)
{
if (!$where) {
die ('Where is required');
}
if (!$data) {
die ('Data is required');
}
return $this->_update($data, $where);
}
|
php
|
public function update(array $data, array $where)
{
if (!$where) {
die ('Where is required');
}
if (!$data) {
die ('Data is required');
}
return $this->_update($data, $where);
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"data",
",",
"array",
"$",
"where",
")",
"{",
"if",
"(",
"!",
"$",
"where",
")",
"{",
"die",
"(",
"'Where is required'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"data",
")",
"{",
"die",
"(",
"'Data is required'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_update",
"(",
"$",
"data",
",",
"$",
"where",
")",
";",
"}"
] |
Update a row or rowset
@param array $data Data array
@param array $where Where conditions array
@return bool
|
[
"Update",
"a",
"row",
"or",
"rowset"
] |
ff7a4f69f8ee7beb37adee348b67d1be84c51ff1
|
https://github.com/crater-framework/crater-php-framework/blob/ff7a4f69f8ee7beb37adee348b67d1be84c51ff1/Orm/TableGateway.php#L155-L166
|
239,359
|
helionogueir/foldercreator
|
core/folder/Create.class.php
|
Create.mkdir
|
public function mkdir(string $directory, int $mode = null): bool {
if (!empty($directory)) {
if ($folders = explode(DIRECTORY_SEPARATOR, Path::replaceOSSeparator($directory))) {
$fullpath = null;
if (empty($mode)) {
$mode = AccessMode::MOD_0777;
}
foreach ($folders as $folder) {
if (!empty($folder)) {
$fullpath .= DIRECTORY_SEPARATOR . $folder;
$this->createDirectory($fullpath, $mode);
}
}
}
}
return file_exists($directory);
}
|
php
|
public function mkdir(string $directory, int $mode = null): bool {
if (!empty($directory)) {
if ($folders = explode(DIRECTORY_SEPARATOR, Path::replaceOSSeparator($directory))) {
$fullpath = null;
if (empty($mode)) {
$mode = AccessMode::MOD_0777;
}
foreach ($folders as $folder) {
if (!empty($folder)) {
$fullpath .= DIRECTORY_SEPARATOR . $folder;
$this->createDirectory($fullpath, $mode);
}
}
}
}
return file_exists($directory);
}
|
[
"public",
"function",
"mkdir",
"(",
"string",
"$",
"directory",
",",
"int",
"$",
"mode",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"directory",
")",
")",
"{",
"if",
"(",
"$",
"folders",
"=",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"Path",
"::",
"replaceOSSeparator",
"(",
"$",
"directory",
")",
")",
")",
"{",
"$",
"fullpath",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"$",
"mode",
")",
")",
"{",
"$",
"mode",
"=",
"AccessMode",
"::",
"MOD_0777",
";",
"}",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"folder",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"fullpath",
".=",
"DIRECTORY_SEPARATOR",
".",
"$",
"folder",
";",
"$",
"this",
"->",
"createDirectory",
"(",
"$",
"fullpath",
",",
"$",
"mode",
")",
";",
"}",
"}",
"}",
"}",
"return",
"file_exists",
"(",
"$",
"directory",
")",
";",
"}"
] |
- Make directory and sub directory
@param string $directory Path of directory
@param int $mode Define chmod of path directory
@return bool Info if create the folder
|
[
"-",
"Make",
"directory",
"and",
"sub",
"directory"
] |
64bf53c924efec4e581d4acbe183e4a004cd4cae
|
https://github.com/helionogueir/foldercreator/blob/64bf53c924efec4e581d4acbe183e4a004cd4cae/core/folder/Create.class.php#L21-L37
|
239,360
|
helionogueir/foldercreator
|
core/folder/Create.class.php
|
Create.createDirectory
|
private function createDirectory(string $directory, int $mode): bool {
$auth = false;
if (is_dir($directory)) {
$auth = true;
} else {
@mkdir($directory, $mode, true);
}
@chmod($directory, $mode);
return is_dir($directory);
}
|
php
|
private function createDirectory(string $directory, int $mode): bool {
$auth = false;
if (is_dir($directory)) {
$auth = true;
} else {
@mkdir($directory, $mode, true);
}
@chmod($directory, $mode);
return is_dir($directory);
}
|
[
"private",
"function",
"createDirectory",
"(",
"string",
"$",
"directory",
",",
"int",
"$",
"mode",
")",
":",
"bool",
"{",
"$",
"auth",
"=",
"false",
";",
"if",
"(",
"is_dir",
"(",
"$",
"directory",
")",
")",
"{",
"$",
"auth",
"=",
"true",
";",
"}",
"else",
"{",
"@",
"mkdir",
"(",
"$",
"directory",
",",
"$",
"mode",
",",
"true",
")",
";",
"}",
"@",
"chmod",
"(",
"$",
"directory",
",",
"$",
"mode",
")",
";",
"return",
"is_dir",
"(",
"$",
"directory",
")",
";",
"}"
] |
- Make directory
@param string $directory Path of directory
@param int $mode Define chmod of path directory
@return bool Info if create the folder
|
[
"-",
"Make",
"directory"
] |
64bf53c924efec4e581d4acbe183e4a004cd4cae
|
https://github.com/helionogueir/foldercreator/blob/64bf53c924efec4e581d4acbe183e4a004cd4cae/core/folder/Create.class.php#L45-L54
|
239,361
|
xiewulong/yii2-components
|
ActiveRecord.php
|
ActiveRecord.uvRuleCheck
|
protected function uvRuleCheck() {
$expire = strtotime(date('Y-m-d', time() + 60 * 60 * 24));
$item = strtr(static::classname(), '\\', '_') . '_' . $this->id;
$session = \Yii::$app->session->get($this->statisticsParam);
if(!\Yii::$app->session->has($this->statisticsParam) || $session['expire'] != $expire) {
$session = [
'expire' => $expire,
'items' => [],
];
}
if(!isset($session['items'][$item])) {
$session['items'][$item] = true;
\Yii::$app->session->set($this->statisticsParam, $session);
return true;
}
return false;
}
|
php
|
protected function uvRuleCheck() {
$expire = strtotime(date('Y-m-d', time() + 60 * 60 * 24));
$item = strtr(static::classname(), '\\', '_') . '_' . $this->id;
$session = \Yii::$app->session->get($this->statisticsParam);
if(!\Yii::$app->session->has($this->statisticsParam) || $session['expire'] != $expire) {
$session = [
'expire' => $expire,
'items' => [],
];
}
if(!isset($session['items'][$item])) {
$session['items'][$item] = true;
\Yii::$app->session->set($this->statisticsParam, $session);
return true;
}
return false;
}
|
[
"protected",
"function",
"uvRuleCheck",
"(",
")",
"{",
"$",
"expire",
"=",
"strtotime",
"(",
"date",
"(",
"'Y-m-d'",
",",
"time",
"(",
")",
"+",
"60",
"*",
"60",
"*",
"24",
")",
")",
";",
"$",
"item",
"=",
"strtr",
"(",
"static",
"::",
"classname",
"(",
")",
",",
"'\\\\'",
",",
"'_'",
")",
".",
"'_'",
".",
"$",
"this",
"->",
"id",
";",
"$",
"session",
"=",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"statisticsParam",
")",
";",
"if",
"(",
"!",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"has",
"(",
"$",
"this",
"->",
"statisticsParam",
")",
"||",
"$",
"session",
"[",
"'expire'",
"]",
"!=",
"$",
"expire",
")",
"{",
"$",
"session",
"=",
"[",
"'expire'",
"=>",
"$",
"expire",
",",
"'items'",
"=>",
"[",
"]",
",",
"]",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"session",
"[",
"'items'",
"]",
"[",
"$",
"item",
"]",
")",
")",
"{",
"$",
"session",
"[",
"'items'",
"]",
"[",
"$",
"item",
"]",
"=",
"true",
";",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"session",
"->",
"set",
"(",
"$",
"this",
"->",
"statisticsParam",
",",
"$",
"session",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Check if it can increase unique visitor
@since 0.0.1
@return {boolean}
|
[
"Check",
"if",
"it",
"can",
"increase",
"unique",
"visitor"
] |
e295b2e6792fec8d0a35427e8e48dca293539315
|
https://github.com/xiewulong/yii2-components/blob/e295b2e6792fec8d0a35427e8e48dca293539315/ActiveRecord.php#L67-L87
|
239,362
|
xiewulong/yii2-components
|
ActiveRecord.php
|
ActiveRecord.accessedHandler
|
public function accessedHandler() {
if(!$this->statisticsEnable
|| $this->scenario != $this->statisticsParam
|| !$this->validate()) {
return false;
}
if($this->pvRuleCheck()) {
$this->pv++;
}
if($this->uvRuleCheck()) {
$this->uv++;
}
return $this->save(false);
}
|
php
|
public function accessedHandler() {
if(!$this->statisticsEnable
|| $this->scenario != $this->statisticsParam
|| !$this->validate()) {
return false;
}
if($this->pvRuleCheck()) {
$this->pv++;
}
if($this->uvRuleCheck()) {
$this->uv++;
}
return $this->save(false);
}
|
[
"public",
"function",
"accessedHandler",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"statisticsEnable",
"||",
"$",
"this",
"->",
"scenario",
"!=",
"$",
"this",
"->",
"statisticsParam",
"||",
"!",
"$",
"this",
"->",
"validate",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"pvRuleCheck",
"(",
")",
")",
"{",
"$",
"this",
"->",
"pv",
"++",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"uvRuleCheck",
"(",
")",
")",
"{",
"$",
"this",
"->",
"uv",
"++",
";",
"}",
"return",
"$",
"this",
"->",
"save",
"(",
"false",
")",
";",
"}"
] |
Add pv and uv when accessed
@since 0.0.1
@return {boolean}
|
[
"Add",
"pv",
"and",
"uv",
"when",
"accessed"
] |
e295b2e6792fec8d0a35427e8e48dca293539315
|
https://github.com/xiewulong/yii2-components/blob/e295b2e6792fec8d0a35427e8e48dca293539315/ActiveRecord.php#L95-L110
|
239,363
|
xiewulong/yii2-components
|
ActiveRecord.php
|
ActiveRecord.cacheAttributeItems
|
private function cacheAttributeItems($attribute) {
$nameItems = [];
$unsupportItems = [];
$_attribute = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute)))) . 'Items';
if($this->hasMethod($_attribute)) {
$attributeitems = $this->$_attribute();
$_defaultNameItems = $attributeitems[0];
if($_defaultNameItems && is_array($_defaultNameItems)) {
$_scenario = [];
foreach($this->getActiveValidators($attribute) as $validator) {
if($validator instanceof RangeValidator) {
$_scenario = ArrayHelper::merge($_scenario, ArrayHelper::filter($_defaultNameItems, $validator->range));
}
}
$nameItems[$this->scenario] = array_unique($_scenario);
$nameItems['_default'] = $_defaultNameItems;
}
if(isset($attributeitems[1]) && is_array($attributeitems[1])) {
$unsupportItems = $attributeitems[1];
}
}
$this->_attributeNameItemsList[$attribute] = $nameItems;
$this->_attributeUnsupportItemsList[$attribute] = $unsupportItems;
}
|
php
|
private function cacheAttributeItems($attribute) {
$nameItems = [];
$unsupportItems = [];
$_attribute = lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $attribute)))) . 'Items';
if($this->hasMethod($_attribute)) {
$attributeitems = $this->$_attribute();
$_defaultNameItems = $attributeitems[0];
if($_defaultNameItems && is_array($_defaultNameItems)) {
$_scenario = [];
foreach($this->getActiveValidators($attribute) as $validator) {
if($validator instanceof RangeValidator) {
$_scenario = ArrayHelper::merge($_scenario, ArrayHelper::filter($_defaultNameItems, $validator->range));
}
}
$nameItems[$this->scenario] = array_unique($_scenario);
$nameItems['_default'] = $_defaultNameItems;
}
if(isset($attributeitems[1]) && is_array($attributeitems[1])) {
$unsupportItems = $attributeitems[1];
}
}
$this->_attributeNameItemsList[$attribute] = $nameItems;
$this->_attributeUnsupportItemsList[$attribute] = $unsupportItems;
}
|
[
"private",
"function",
"cacheAttributeItems",
"(",
"$",
"attribute",
")",
"{",
"$",
"nameItems",
"=",
"[",
"]",
";",
"$",
"unsupportItems",
"=",
"[",
"]",
";",
"$",
"_attribute",
"=",
"lcfirst",
"(",
"str_replace",
"(",
"' '",
",",
"''",
",",
"ucwords",
"(",
"str_replace",
"(",
"'_'",
",",
"' '",
",",
"$",
"attribute",
")",
")",
")",
")",
".",
"'Items'",
";",
"if",
"(",
"$",
"this",
"->",
"hasMethod",
"(",
"$",
"_attribute",
")",
")",
"{",
"$",
"attributeitems",
"=",
"$",
"this",
"->",
"$",
"_attribute",
"(",
")",
";",
"$",
"_defaultNameItems",
"=",
"$",
"attributeitems",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"_defaultNameItems",
"&&",
"is_array",
"(",
"$",
"_defaultNameItems",
")",
")",
"{",
"$",
"_scenario",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"getActiveValidators",
"(",
"$",
"attribute",
")",
"as",
"$",
"validator",
")",
"{",
"if",
"(",
"$",
"validator",
"instanceof",
"RangeValidator",
")",
"{",
"$",
"_scenario",
"=",
"ArrayHelper",
"::",
"merge",
"(",
"$",
"_scenario",
",",
"ArrayHelper",
"::",
"filter",
"(",
"$",
"_defaultNameItems",
",",
"$",
"validator",
"->",
"range",
")",
")",
";",
"}",
"}",
"$",
"nameItems",
"[",
"$",
"this",
"->",
"scenario",
"]",
"=",
"array_unique",
"(",
"$",
"_scenario",
")",
";",
"$",
"nameItems",
"[",
"'_default'",
"]",
"=",
"$",
"_defaultNameItems",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"attributeitems",
"[",
"1",
"]",
")",
"&&",
"is_array",
"(",
"$",
"attributeitems",
"[",
"1",
"]",
")",
")",
"{",
"$",
"unsupportItems",
"=",
"$",
"attributeitems",
"[",
"1",
"]",
";",
"}",
"}",
"$",
"this",
"->",
"_attributeNameItemsList",
"[",
"$",
"attribute",
"]",
"=",
"$",
"nameItems",
";",
"$",
"this",
"->",
"_attributeUnsupportItemsList",
"[",
"$",
"attribute",
"]",
"=",
"$",
"unsupportItems",
";",
"}"
] |
Cache attribute items
@since 0.0.1
@param {string} $attribute
@return {none}
|
[
"Cache",
"attribute",
"items"
] |
e295b2e6792fec8d0a35427e8e48dca293539315
|
https://github.com/xiewulong/yii2-components/blob/e295b2e6792fec8d0a35427e8e48dca293539315/ActiveRecord.php#L135-L162
|
239,364
|
xiewulong/yii2-components
|
ActiveRecord.php
|
ActiveRecord.getAttributeText
|
public function getAttributeText($attribute) {
$items = $this->getAttributeItems($attribute, 0, false, true);
return isset($items[$this->$attribute]) ? $items[$this->$attribute] : null;
}
|
php
|
public function getAttributeText($attribute) {
$items = $this->getAttributeItems($attribute, 0, false, true);
return isset($items[$this->$attribute]) ? $items[$this->$attribute] : null;
}
|
[
"public",
"function",
"getAttributeText",
"(",
"$",
"attribute",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"getAttributeItems",
"(",
"$",
"attribute",
",",
"0",
",",
"false",
",",
"true",
")",
";",
"return",
"isset",
"(",
"$",
"items",
"[",
"$",
"this",
"->",
"$",
"attribute",
"]",
")",
"?",
"$",
"items",
"[",
"$",
"this",
"->",
"$",
"attribute",
"]",
":",
"null",
";",
"}"
] |
Return status text
@since 0.0.1
@param {string} $attribute
@return {string|null}
|
[
"Return",
"status",
"text"
] |
e295b2e6792fec8d0a35427e8e48dca293539315
|
https://github.com/xiewulong/yii2-components/blob/e295b2e6792fec8d0a35427e8e48dca293539315/ActiveRecord.php#L212-L216
|
239,365
|
xiewulong/yii2-components
|
ActiveRecord.php
|
ActiveRecord.isFirstErrorAttribute
|
public function isFirstErrorAttribute($attribute) {
if($this->_firstErrorAttribute === false) {
$errorAttributes = array_keys($this->firstErrors);
$this->_firstErrorAttribute = array_shift($errorAttributes);
}
return $attribute == $this->_firstErrorAttribute;
}
|
php
|
public function isFirstErrorAttribute($attribute) {
if($this->_firstErrorAttribute === false) {
$errorAttributes = array_keys($this->firstErrors);
$this->_firstErrorAttribute = array_shift($errorAttributes);
}
return $attribute == $this->_firstErrorAttribute;
}
|
[
"public",
"function",
"isFirstErrorAttribute",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_firstErrorAttribute",
"===",
"false",
")",
"{",
"$",
"errorAttributes",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"firstErrors",
")",
";",
"$",
"this",
"->",
"_firstErrorAttribute",
"=",
"array_shift",
"(",
"$",
"errorAttributes",
")",
";",
"}",
"return",
"$",
"attribute",
"==",
"$",
"this",
"->",
"_firstErrorAttribute",
";",
"}"
] |
Returns the first error's attribute name
@since 0.0.1
@param {string} $attribute
@return {string|null}
|
[
"Returns",
"the",
"first",
"error",
"s",
"attribute",
"name"
] |
e295b2e6792fec8d0a35427e8e48dca293539315
|
https://github.com/xiewulong/yii2-components/blob/e295b2e6792fec8d0a35427e8e48dca293539315/ActiveRecord.php#L225-L232
|
239,366
|
xiewulong/yii2-components
|
ActiveRecord.php
|
ActiveRecord.getAttributeForVue
|
public function getAttributeForVue($attribute) {
return [
'name' => Html::getInputName($this, $attribute),
'value' => $this->$attribute,
'id' => Html::getInputId($this, $attribute),
'label' => $this->getAttributeLabel($attribute),
'hint' => $this->getAttributeHint($attribute),
'error' => $this->isFirstErrorAttribute($attribute),
];
}
|
php
|
public function getAttributeForVue($attribute) {
return [
'name' => Html::getInputName($this, $attribute),
'value' => $this->$attribute,
'id' => Html::getInputId($this, $attribute),
'label' => $this->getAttributeLabel($attribute),
'hint' => $this->getAttributeHint($attribute),
'error' => $this->isFirstErrorAttribute($attribute),
];
}
|
[
"public",
"function",
"getAttributeForVue",
"(",
"$",
"attribute",
")",
"{",
"return",
"[",
"'name'",
"=>",
"Html",
"::",
"getInputName",
"(",
"$",
"this",
",",
"$",
"attribute",
")",
",",
"'value'",
"=>",
"$",
"this",
"->",
"$",
"attribute",
",",
"'id'",
"=>",
"Html",
"::",
"getInputId",
"(",
"$",
"this",
",",
"$",
"attribute",
")",
",",
"'label'",
"=>",
"$",
"this",
"->",
"getAttributeLabel",
"(",
"$",
"attribute",
")",
",",
"'hint'",
"=>",
"$",
"this",
"->",
"getAttributeHint",
"(",
"$",
"attribute",
")",
",",
"'error'",
"=>",
"$",
"this",
"->",
"isFirstErrorAttribute",
"(",
"$",
"attribute",
")",
",",
"]",
";",
"}"
] |
Returns attribute data for vue by json
@since 0.0.1
@param {string} $attribute
@return {string}
|
[
"Returns",
"attribute",
"data",
"for",
"vue",
"by",
"json"
] |
e295b2e6792fec8d0a35427e8e48dca293539315
|
https://github.com/xiewulong/yii2-components/blob/e295b2e6792fec8d0a35427e8e48dca293539315/ActiveRecord.php#L253-L262
|
239,367
|
webthinkgr/codesniffer
|
src/Webthink/Sniffs/Metrics/MethodPerClassLimitSniff.php
|
MethodPerClassLimitSniff.getClassMethods
|
private function getClassMethods(File $phpcsFile, $stackPtr)
{
$pointer = $stackPtr;
$methods = [];
while (($next = $phpcsFile->findNext(T_FUNCTION, $pointer + 1)) !== false) {
$modifier = $this->getModifier($phpcsFile, $next);
if ($this->isPublic($modifier) && !$this->isMagicFunction($phpcsFile->getDeclarationName($next))) {
$methods[] = $next;
}
$pointer = $next;
}
return $methods;
}
|
php
|
private function getClassMethods(File $phpcsFile, $stackPtr)
{
$pointer = $stackPtr;
$methods = [];
while (($next = $phpcsFile->findNext(T_FUNCTION, $pointer + 1)) !== false) {
$modifier = $this->getModifier($phpcsFile, $next);
if ($this->isPublic($modifier) && !$this->isMagicFunction($phpcsFile->getDeclarationName($next))) {
$methods[] = $next;
}
$pointer = $next;
}
return $methods;
}
|
[
"private",
"function",
"getClassMethods",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"$",
"pointer",
"=",
"$",
"stackPtr",
";",
"$",
"methods",
"=",
"[",
"]",
";",
"while",
"(",
"(",
"$",
"next",
"=",
"$",
"phpcsFile",
"->",
"findNext",
"(",
"T_FUNCTION",
",",
"$",
"pointer",
"+",
"1",
")",
")",
"!==",
"false",
")",
"{",
"$",
"modifier",
"=",
"$",
"this",
"->",
"getModifier",
"(",
"$",
"phpcsFile",
",",
"$",
"next",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isPublic",
"(",
"$",
"modifier",
")",
"&&",
"!",
"$",
"this",
"->",
"isMagicFunction",
"(",
"$",
"phpcsFile",
"->",
"getDeclarationName",
"(",
"$",
"next",
")",
")",
")",
"{",
"$",
"methods",
"[",
"]",
"=",
"$",
"next",
";",
"}",
"$",
"pointer",
"=",
"$",
"next",
";",
"}",
"return",
"$",
"methods",
";",
"}"
] |
Retrieve the list of class methods' pointers.
@param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned
@param int $stackPtr The position of the current token in the stack passed in $tokens.
@return array
@throws \PHP_CodeSniffer\Exceptions\RuntimeException
@throws \PHP_CodeSniffer\Exceptions\TokenizerException
|
[
"Retrieve",
"the",
"list",
"of",
"class",
"methods",
"pointers",
"."
] |
24715c92f9878676ea806df306da4e28561b8acb
|
https://github.com/webthinkgr/codesniffer/blob/24715c92f9878676ea806df306da4e28561b8acb/src/Webthink/Sniffs/Metrics/MethodPerClassLimitSniff.php#L118-L133
|
239,368
|
tux-rampage/rampage-php
|
library/rampage/core/resources/FileLocator.php
|
FileLocator.addLocation
|
public function addLocation($scope, $path)
{
if ($path instanceof SplFileInfo) {
$path = array('base' => $path->getPathname());
} else if (is_string($path)) {
if ($path == '') {
throw new InvalidArgumentException('Invalid resource path: path must not be empty.');
}
$path = array('base' => $path);
} else if (!is_array($path) && !($path instanceof \ArrayAccess)) {
throw new InvalidArgumentException('Invalid path');
}
foreach ($this->types as $type) {
if (isset($path[$type])) {
$this->locations[$scope][$type] = $path[$type];
if ($type != 'base') {
unset($path[$type]);
}
continue;
}
if (!isset($path['base'])) {
if (!isset($this->locations[$scope]['base'])) {
continue;
}
$path['base'] = $this->locations[$scope]['base'];
}
$this->locations[$scope][$type] = $path['base'] . '/' . $type;
}
unset($path['base']);
foreach ($path as $type => $extraPath) {
$this->locations[$scope][$type] = $extraPath;
}
return $this;
}
|
php
|
public function addLocation($scope, $path)
{
if ($path instanceof SplFileInfo) {
$path = array('base' => $path->getPathname());
} else if (is_string($path)) {
if ($path == '') {
throw new InvalidArgumentException('Invalid resource path: path must not be empty.');
}
$path = array('base' => $path);
} else if (!is_array($path) && !($path instanceof \ArrayAccess)) {
throw new InvalidArgumentException('Invalid path');
}
foreach ($this->types as $type) {
if (isset($path[$type])) {
$this->locations[$scope][$type] = $path[$type];
if ($type != 'base') {
unset($path[$type]);
}
continue;
}
if (!isset($path['base'])) {
if (!isset($this->locations[$scope]['base'])) {
continue;
}
$path['base'] = $this->locations[$scope]['base'];
}
$this->locations[$scope][$type] = $path['base'] . '/' . $type;
}
unset($path['base']);
foreach ($path as $type => $extraPath) {
$this->locations[$scope][$type] = $extraPath;
}
return $this;
}
|
[
"public",
"function",
"addLocation",
"(",
"$",
"scope",
",",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
"instanceof",
"SplFileInfo",
")",
"{",
"$",
"path",
"=",
"array",
"(",
"'base'",
"=>",
"$",
"path",
"->",
"getPathname",
"(",
")",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"if",
"(",
"$",
"path",
"==",
"''",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid resource path: path must not be empty.'",
")",
";",
"}",
"$",
"path",
"=",
"array",
"(",
"'base'",
"=>",
"$",
"path",
")",
";",
"}",
"else",
"if",
"(",
"!",
"is_array",
"(",
"$",
"path",
")",
"&&",
"!",
"(",
"$",
"path",
"instanceof",
"\\",
"ArrayAccess",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Invalid path'",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"types",
"as",
"$",
"type",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"path",
"[",
"$",
"type",
"]",
")",
")",
"{",
"$",
"this",
"->",
"locations",
"[",
"$",
"scope",
"]",
"[",
"$",
"type",
"]",
"=",
"$",
"path",
"[",
"$",
"type",
"]",
";",
"if",
"(",
"$",
"type",
"!=",
"'base'",
")",
"{",
"unset",
"(",
"$",
"path",
"[",
"$",
"type",
"]",
")",
";",
"}",
"continue",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"path",
"[",
"'base'",
"]",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"locations",
"[",
"$",
"scope",
"]",
"[",
"'base'",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"path",
"[",
"'base'",
"]",
"=",
"$",
"this",
"->",
"locations",
"[",
"$",
"scope",
"]",
"[",
"'base'",
"]",
";",
"}",
"$",
"this",
"->",
"locations",
"[",
"$",
"scope",
"]",
"[",
"$",
"type",
"]",
"=",
"$",
"path",
"[",
"'base'",
"]",
".",
"'/'",
".",
"$",
"type",
";",
"}",
"unset",
"(",
"$",
"path",
"[",
"'base'",
"]",
")",
";",
"foreach",
"(",
"$",
"path",
"as",
"$",
"type",
"=>",
"$",
"extraPath",
")",
"{",
"$",
"this",
"->",
"locations",
"[",
"$",
"scope",
"]",
"[",
"$",
"type",
"]",
"=",
"$",
"extraPath",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add a location
@param string $scope
@param string|array $path
|
[
"Add",
"a",
"location"
] |
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
|
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/resources/FileLocator.php#L85-L128
|
239,369
|
cityware/city-wmi
|
src/Query/Builder.php
|
Builder.where
|
public function where($column, $operator, $value = null)
{
if (count($this->wheres) > 0) {
$this->andWhere($column, $operator, $value);
}
$this->wheres[] = new Where($column, $operator, $value);
return $this;
}
|
php
|
public function where($column, $operator, $value = null)
{
if (count($this->wheres) > 0) {
$this->andWhere($column, $operator, $value);
}
$this->wheres[] = new Where($column, $operator, $value);
return $this;
}
|
[
"public",
"function",
"where",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"wheres",
")",
">",
"0",
")",
"{",
"$",
"this",
"->",
"andWhere",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"}",
"$",
"this",
"->",
"wheres",
"[",
"]",
"=",
"new",
"Where",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a where expression to the current query.
@param string $column
@param string $operator
@param mixed $value
@return $this
|
[
"Adds",
"a",
"where",
"expression",
"to",
"the",
"current",
"query",
"."
] |
c7296e6855b6719f537ff5c2dc19d521ce1415d8
|
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Query/Builder.php#L110-L119
|
239,370
|
cityware/city-wmi
|
src/Query/Builder.php
|
Builder.andWhere
|
public function andWhere($column, $operator, $value = null)
{
$this->andWheres[] = new Where($column, $operator, $value, 'AND');
return $this;
}
|
php
|
public function andWhere($column, $operator, $value = null)
{
$this->andWheres[] = new Where($column, $operator, $value, 'AND');
return $this;
}
|
[
"public",
"function",
"andWhere",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"andWheres",
"[",
"]",
"=",
"new",
"Where",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
",",
"'AND'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds an and where expression to the current query.
@param string $column
@param string $operator
@param mixed $value
@return $this
|
[
"Adds",
"an",
"and",
"where",
"expression",
"to",
"the",
"current",
"query",
"."
] |
c7296e6855b6719f537ff5c2dc19d521ce1415d8
|
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Query/Builder.php#L130-L135
|
239,371
|
cityware/city-wmi
|
src/Query/Builder.php
|
Builder.orWhere
|
public function orWhere($column, $operator, $value = null)
{
$this->orWheres[] = new Where($column, $operator, $value, 'OR');
return $this;
}
|
php
|
public function orWhere($column, $operator, $value = null)
{
$this->orWheres[] = new Where($column, $operator, $value, 'OR');
return $this;
}
|
[
"public",
"function",
"orWhere",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"orWheres",
"[",
"]",
"=",
"new",
"Where",
"(",
"$",
"column",
",",
"$",
"operator",
",",
"$",
"value",
",",
"'OR'",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds a or where statement to the current query.
@param $column
@param $operator
@param mixed $value
@return $this
|
[
"Adds",
"a",
"or",
"where",
"statement",
"to",
"the",
"current",
"query",
"."
] |
c7296e6855b6719f537ff5c2dc19d521ce1415d8
|
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Query/Builder.php#L146-L151
|
239,372
|
cityware/city-wmi
|
src/Query/Builder.php
|
Builder.buildQuery
|
private function buildQuery()
{
$select = $this->buildSelect();
$from = $this->buildFrom();
$within = $this->buildWithin();
$wheres = $this->buildWheres();
$query = sprintf('%s %s %s %s', $select, $from, $within, $wheres);
return trim($query);
}
|
php
|
private function buildQuery()
{
$select = $this->buildSelect();
$from = $this->buildFrom();
$within = $this->buildWithin();
$wheres = $this->buildWheres();
$query = sprintf('%s %s %s %s', $select, $from, $within, $wheres);
return trim($query);
}
|
[
"private",
"function",
"buildQuery",
"(",
")",
"{",
"$",
"select",
"=",
"$",
"this",
"->",
"buildSelect",
"(",
")",
";",
"$",
"from",
"=",
"$",
"this",
"->",
"buildFrom",
"(",
")",
";",
"$",
"within",
"=",
"$",
"this",
"->",
"buildWithin",
"(",
")",
";",
"$",
"wheres",
"=",
"$",
"this",
"->",
"buildWheres",
"(",
")",
";",
"$",
"query",
"=",
"sprintf",
"(",
"'%s %s %s %s'",
",",
"$",
"select",
",",
"$",
"from",
",",
"$",
"within",
",",
"$",
"wheres",
")",
";",
"return",
"trim",
"(",
"$",
"query",
")",
";",
"}"
] |
Builds the query and returns the query string.
@return string
|
[
"Builds",
"the",
"query",
"and",
"returns",
"the",
"query",
"string",
"."
] |
c7296e6855b6719f537ff5c2dc19d521ce1415d8
|
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Query/Builder.php#L255-L268
|
239,373
|
cityware/city-wmi
|
src/Query/Builder.php
|
Builder.buildFrom
|
private function buildFrom()
{
if ($this->from instanceof From) {
return $this->from->build();
}
$message = 'No from statement exists. You need to supply one to retrieve results.';
throw new InvalidFromStatement($message);
}
|
php
|
private function buildFrom()
{
if ($this->from instanceof From) {
return $this->from->build();
}
$message = 'No from statement exists. You need to supply one to retrieve results.';
throw new InvalidFromStatement($message);
}
|
[
"private",
"function",
"buildFrom",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"from",
"instanceof",
"From",
")",
"{",
"return",
"$",
"this",
"->",
"from",
"->",
"build",
"(",
")",
";",
"}",
"$",
"message",
"=",
"'No from statement exists. You need to supply one to retrieve results.'",
";",
"throw",
"new",
"InvalidFromStatement",
"(",
"$",
"message",
")",
";",
"}"
] |
Builds the from statement on the current query.
@return string
@throws InvalidFromStatement
|
[
"Builds",
"the",
"from",
"statement",
"on",
"the",
"current",
"query",
"."
] |
c7296e6855b6719f537ff5c2dc19d521ce1415d8
|
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Query/Builder.php#L291-L300
|
239,374
|
cityware/city-wmi
|
src/Query/Builder.php
|
Builder.buildWheres
|
private function buildWheres()
{
$statement = '';
foreach ($this->wheres as $where) {
$statement = $where->build();
}
foreach ($this->andWheres as $andWhere) {
$statement .= $andWhere->build();
}
foreach ($this->orWheres as $orWhere) {
$statement .= $orWhere->build();
}
return $statement;
}
|
php
|
private function buildWheres()
{
$statement = '';
foreach ($this->wheres as $where) {
$statement = $where->build();
}
foreach ($this->andWheres as $andWhere) {
$statement .= $andWhere->build();
}
foreach ($this->orWheres as $orWhere) {
$statement .= $orWhere->build();
}
return $statement;
}
|
[
"private",
"function",
"buildWheres",
"(",
")",
"{",
"$",
"statement",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"wheres",
"as",
"$",
"where",
")",
"{",
"$",
"statement",
"=",
"$",
"where",
"->",
"build",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"andWheres",
"as",
"$",
"andWhere",
")",
"{",
"$",
"statement",
".=",
"$",
"andWhere",
"->",
"build",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"orWheres",
"as",
"$",
"orWhere",
")",
"{",
"$",
"statement",
".=",
"$",
"orWhere",
"->",
"build",
"(",
")",
";",
"}",
"return",
"$",
"statement",
";",
"}"
] |
Builds the wheres on the current query
and returns the result query string.
@return string
|
[
"Builds",
"the",
"wheres",
"on",
"the",
"current",
"query",
"and",
"returns",
"the",
"result",
"query",
"string",
"."
] |
c7296e6855b6719f537ff5c2dc19d521ce1415d8
|
https://github.com/cityware/city-wmi/blob/c7296e6855b6719f537ff5c2dc19d521ce1415d8/src/Query/Builder.php#L308-L325
|
239,375
|
Niirrty/Niirrty.Gps
|
src/Latitude.php
|
Latitude.equals
|
public function equals( $value ) : bool
{
// First the value must be converted to an Latitude instance.
$lng = null;
if ( ! self::TryParse( $value, $lng ) )
{
// Value is of a type that can not be used as latitude
return false;
}
return ( (string) $lng ) === ( (string) $this );
}
|
php
|
public function equals( $value ) : bool
{
// First the value must be converted to an Latitude instance.
$lng = null;
if ( ! self::TryParse( $value, $lng ) )
{
// Value is of a type that can not be used as latitude
return false;
}
return ( (string) $lng ) === ( (string) $this );
}
|
[
"public",
"function",
"equals",
"(",
"$",
"value",
")",
":",
"bool",
"{",
"// First the value must be converted to an Latitude instance.",
"$",
"lng",
"=",
"null",
";",
"if",
"(",
"!",
"self",
"::",
"TryParse",
"(",
"$",
"value",
",",
"$",
"lng",
")",
")",
"{",
"// Value is of a type that can not be used as latitude",
"return",
"false",
";",
"}",
"return",
"(",
"(",
"string",
")",
"$",
"lng",
")",
"===",
"(",
"(",
"string",
")",
"$",
"this",
")",
";",
"}"
] |
Equals the current instance with the defined value.
The value can use the following formats:
- string: A GPS coordinate latitude string in any known valid format.
- double|float: A GPS coordinate latitude as an floating point number.
- \SimpleXMLElement: A GPS coordinate latitude as SimpleXMLElement. It can be defined as 'latitude' attribute.
In this case, it must be defined as attribute value as an floating point number. Otherwise it also works if
the attributes 'direction' (char), 'degrees' (integer), 'minutes' (integer|double) and 'seconds' (integer)
are defined.
- {@see \Niirrty\Gps\Latitude}: ...
- {@see \Niirrty\Gps\Coordinate}: A coordinate that defines an Latitude
@param string|double|float|\Niirrty\Gps\Latitude|\Niirrty\Gps\Coordinate $value
@return boolean Returns TRUE if $value is equal to current latitude, FALSE otherwise.
|
[
"Equals",
"the",
"current",
"instance",
"with",
"the",
"defined",
"value",
"."
] |
a1ea4ac064defc53a5ffc54e29f3fa412c977398
|
https://github.com/Niirrty/Niirrty.Gps/blob/a1ea4ac064defc53a5ffc54e29f3fa412c977398/src/Latitude.php#L82-L95
|
239,376
|
Puzzlout/FrameworkMvcLegacy
|
src/Core/PopUpResourceManager.php
|
PopUpResourceManager.getTooltipMsgForAttribute
|
public function getTooltipMsgForAttribute($param) {
$param_arr = json_decode($param, true);
$msg_array = array();
foreach ($this->xmlContent as $msg) {
if ($msg->getAttribute('uicomponent') == 'tooltip' &&
$msg->getAttribute('targetcontroller') == $param_arr['targetcontroller'] &&
$msg->getAttribute('targetaction') == $param_arr['targetaction'] &&
in_array($msg->getAttribute('targetattr'), $param_arr['targetattr'])
) {
//Check if delay exists as an attribute
$delayshow = $msg->getAttribute('delayshow');
if ($delayshow != '') {
//Check if delayhide exists in xml, then use it, else use 0 by default
$delayhide = ($msg->getAttribute('delayhide') != '') ? $msg->getAttribute('delayhide') : 0;
$msgconfig_arr = array('value' => $msg->getAttribute('value'), 'targetattr' => $msg->getAttribute('targetattr'), 'placement' => $msg->getAttribute('placement'), 'delayshow' => $delayshow, 'delayhide' => $delayhide);
} else {
$msgconfig_arr = array('value' => $msg->getAttribute('value'), 'targetattr' => $msg->getAttribute('targetattr'), 'placement' => $msg->getAttribute('placement'));
}
array_push($msg_array, array('tooltipmsg' => $msgconfig_arr));
}
}
return $msg_array;
}
|
php
|
public function getTooltipMsgForAttribute($param) {
$param_arr = json_decode($param, true);
$msg_array = array();
foreach ($this->xmlContent as $msg) {
if ($msg->getAttribute('uicomponent') == 'tooltip' &&
$msg->getAttribute('targetcontroller') == $param_arr['targetcontroller'] &&
$msg->getAttribute('targetaction') == $param_arr['targetaction'] &&
in_array($msg->getAttribute('targetattr'), $param_arr['targetattr'])
) {
//Check if delay exists as an attribute
$delayshow = $msg->getAttribute('delayshow');
if ($delayshow != '') {
//Check if delayhide exists in xml, then use it, else use 0 by default
$delayhide = ($msg->getAttribute('delayhide') != '') ? $msg->getAttribute('delayhide') : 0;
$msgconfig_arr = array('value' => $msg->getAttribute('value'), 'targetattr' => $msg->getAttribute('targetattr'), 'placement' => $msg->getAttribute('placement'), 'delayshow' => $delayshow, 'delayhide' => $delayhide);
} else {
$msgconfig_arr = array('value' => $msg->getAttribute('value'), 'targetattr' => $msg->getAttribute('targetattr'), 'placement' => $msg->getAttribute('placement'));
}
array_push($msg_array, array('tooltipmsg' => $msgconfig_arr));
}
}
return $msg_array;
}
|
[
"public",
"function",
"getTooltipMsgForAttribute",
"(",
"$",
"param",
")",
"{",
"$",
"param_arr",
"=",
"json_decode",
"(",
"$",
"param",
",",
"true",
")",
";",
"$",
"msg_array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"xmlContent",
"as",
"$",
"msg",
")",
"{",
"if",
"(",
"$",
"msg",
"->",
"getAttribute",
"(",
"'uicomponent'",
")",
"==",
"'tooltip'",
"&&",
"$",
"msg",
"->",
"getAttribute",
"(",
"'targetcontroller'",
")",
"==",
"$",
"param_arr",
"[",
"'targetcontroller'",
"]",
"&&",
"$",
"msg",
"->",
"getAttribute",
"(",
"'targetaction'",
")",
"==",
"$",
"param_arr",
"[",
"'targetaction'",
"]",
"&&",
"in_array",
"(",
"$",
"msg",
"->",
"getAttribute",
"(",
"'targetattr'",
")",
",",
"$",
"param_arr",
"[",
"'targetattr'",
"]",
")",
")",
"{",
"//Check if delay exists as an attribute",
"$",
"delayshow",
"=",
"$",
"msg",
"->",
"getAttribute",
"(",
"'delayshow'",
")",
";",
"if",
"(",
"$",
"delayshow",
"!=",
"''",
")",
"{",
"//Check if delayhide exists in xml, then use it, else use 0 by default",
"$",
"delayhide",
"=",
"(",
"$",
"msg",
"->",
"getAttribute",
"(",
"'delayhide'",
")",
"!=",
"''",
")",
"?",
"$",
"msg",
"->",
"getAttribute",
"(",
"'delayhide'",
")",
":",
"0",
";",
"$",
"msgconfig_arr",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'value'",
")",
",",
"'targetattr'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'targetattr'",
")",
",",
"'placement'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'placement'",
")",
",",
"'delayshow'",
"=>",
"$",
"delayshow",
",",
"'delayhide'",
"=>",
"$",
"delayhide",
")",
";",
"}",
"else",
"{",
"$",
"msgconfig_arr",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'value'",
")",
",",
"'targetattr'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'targetattr'",
")",
",",
"'placement'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'placement'",
")",
")",
";",
"}",
"array_push",
"(",
"$",
"msg_array",
",",
"array",
"(",
"'tooltipmsg'",
"=>",
"$",
"msgconfig_arr",
")",
")",
";",
"}",
"}",
"return",
"$",
"msg_array",
";",
"}"
] |
Fetches all messages associated with a particular
attribute passed through the JSON var param.
|
[
"Fetches",
"all",
"messages",
"associated",
"with",
"a",
"particular",
"attribute",
"passed",
"through",
"the",
"JSON",
"var",
"param",
"."
] |
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
|
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Core/PopUpResourceManager.php#L40-L64
|
239,377
|
Puzzlout/FrameworkMvcLegacy
|
src/Core/PopUpResourceManager.php
|
PopUpResourceManager.getTooltipEllipsisSettings
|
public function getTooltipEllipsisSettings($param) {
$param_arr = json_decode($param, true);
$msg_array = array();
foreach ($this->xmlContent as $msg) {
if ($msg->getAttribute('uicomponent') == 'tooltip_ellipsis' &&
$msg->getAttribute('targetcontroller') == $param_arr['targetcontroller'] &&
$msg->getAttribute('targetaction') == $param_arr['targetaction']
) {
$msg_array = array('charlimit' => $msg->getAttribute('charlimit'), 'placement' => $msg->getAttribute('placement'));
}
}
return $msg_array;
}
|
php
|
public function getTooltipEllipsisSettings($param) {
$param_arr = json_decode($param, true);
$msg_array = array();
foreach ($this->xmlContent as $msg) {
if ($msg->getAttribute('uicomponent') == 'tooltip_ellipsis' &&
$msg->getAttribute('targetcontroller') == $param_arr['targetcontroller'] &&
$msg->getAttribute('targetaction') == $param_arr['targetaction']
) {
$msg_array = array('charlimit' => $msg->getAttribute('charlimit'), 'placement' => $msg->getAttribute('placement'));
}
}
return $msg_array;
}
|
[
"public",
"function",
"getTooltipEllipsisSettings",
"(",
"$",
"param",
")",
"{",
"$",
"param_arr",
"=",
"json_decode",
"(",
"$",
"param",
",",
"true",
")",
";",
"$",
"msg_array",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"xmlContent",
"as",
"$",
"msg",
")",
"{",
"if",
"(",
"$",
"msg",
"->",
"getAttribute",
"(",
"'uicomponent'",
")",
"==",
"'tooltip_ellipsis'",
"&&",
"$",
"msg",
"->",
"getAttribute",
"(",
"'targetcontroller'",
")",
"==",
"$",
"param_arr",
"[",
"'targetcontroller'",
"]",
"&&",
"$",
"msg",
"->",
"getAttribute",
"(",
"'targetaction'",
")",
"==",
"$",
"param_arr",
"[",
"'targetaction'",
"]",
")",
"{",
"$",
"msg_array",
"=",
"array",
"(",
"'charlimit'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'charlimit'",
")",
",",
"'placement'",
"=>",
"$",
"msg",
"->",
"getAttribute",
"(",
"'placement'",
")",
")",
";",
"}",
"}",
"return",
"$",
"msg_array",
";",
"}"
] |
Gets the settings for a module on the basis of which a
tooltip would be shown where the text is truncated due
to insufficient space
|
[
"Gets",
"the",
"settings",
"for",
"a",
"module",
"on",
"the",
"basis",
"of",
"which",
"a",
"tooltip",
"would",
"be",
"shown",
"where",
"the",
"text",
"is",
"truncated",
"due",
"to",
"insufficient",
"space"
] |
14e0fc5b16978cbd209f552ee9c649f66a0dfc6e
|
https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Core/PopUpResourceManager.php#L113-L126
|
239,378
|
BlueBearGaming/BaseBundle
|
Twig/UtilsExtension.php
|
UtilsExtension.appendToQueryString
|
public function appendToQueryString(Request $request, $name, $value)
{
$queryString = '?';
$query = $request->query->all();
$query[$name] = $value;
$parametersCount = count($query);
$count = 1;
foreach ($query as $parameterName => $parameterValue) {
$queryString .= $parameterName . '=' . $parameterValue;
if ($count != $parametersCount) {
$queryString .= '&';
}
$count++;
}
return $queryString;
}
|
php
|
public function appendToQueryString(Request $request, $name, $value)
{
$queryString = '?';
$query = $request->query->all();
$query[$name] = $value;
$parametersCount = count($query);
$count = 1;
foreach ($query as $parameterName => $parameterValue) {
$queryString .= $parameterName . '=' . $parameterValue;
if ($count != $parametersCount) {
$queryString .= '&';
}
$count++;
}
return $queryString;
}
|
[
"public",
"function",
"appendToQueryString",
"(",
"Request",
"$",
"request",
",",
"$",
"name",
",",
"$",
"value",
")",
"{",
"$",
"queryString",
"=",
"'?'",
";",
"$",
"query",
"=",
"$",
"request",
"->",
"query",
"->",
"all",
"(",
")",
";",
"$",
"query",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"$",
"parametersCount",
"=",
"count",
"(",
"$",
"query",
")",
";",
"$",
"count",
"=",
"1",
";",
"foreach",
"(",
"$",
"query",
"as",
"$",
"parameterName",
"=>",
"$",
"parameterValue",
")",
"{",
"$",
"queryString",
".=",
"$",
"parameterName",
".",
"'='",
".",
"$",
"parameterValue",
";",
"if",
"(",
"$",
"count",
"!=",
"$",
"parametersCount",
")",
"{",
"$",
"queryString",
".=",
"'&'",
";",
"}",
"$",
"count",
"++",
";",
"}",
"return",
"$",
"queryString",
";",
"}"
] |
Append a named value in request query string
@param Request $request
@param $name
@param $value
@return string
|
[
"Append",
"a",
"named",
"value",
"in",
"request",
"query",
"string"
] |
a835a217fecb53fa6d12ae3e068d12649e8d04c4
|
https://github.com/BlueBearGaming/BaseBundle/blob/a835a217fecb53fa6d12ae3e068d12649e8d04c4/Twig/UtilsExtension.php#L72-L89
|
239,379
|
tasoftch/skyline-security
|
src/Encoder/HttpDigestResponseEncoder.php
|
HttpDigestResponseEncoder.isPasswordValid
|
public function isPasswordValid(string $plain, string $encoded, array $options = []): bool
{
if($this->getExpectsPlainUserCredentials())
$plain = parent::encodePassword($plain, $options);
$response = $this->encodePassword($plain, $options);
return $this->comparePasswords($encoded, $response);
}
|
php
|
public function isPasswordValid(string $plain, string $encoded, array $options = []): bool
{
if($this->getExpectsPlainUserCredentials())
$plain = parent::encodePassword($plain, $options);
$response = $this->encodePassword($plain, $options);
return $this->comparePasswords($encoded, $response);
}
|
[
"public",
"function",
"isPasswordValid",
"(",
"string",
"$",
"plain",
",",
"string",
"$",
"encoded",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"getExpectsPlainUserCredentials",
"(",
")",
")",
"$",
"plain",
"=",
"parent",
"::",
"encodePassword",
"(",
"$",
"plain",
",",
"$",
"options",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"encodePassword",
"(",
"$",
"plain",
",",
"$",
"options",
")",
";",
"return",
"$",
"this",
"->",
"comparePasswords",
"(",
"$",
"encoded",
",",
"$",
"response",
")",
";",
"}"
] |
The Digest encoder is switched because the authorization sent by the browser contains an encoded response hash.
The encoden needs to encode the stored users credential to compare the response.
That's why the arguments in this method are switched
@param string $plain The persistent user's password. If getExpectsPlainUserCredentials() is false, it assumes the credentials as A1
@param string $encoded
@param array $options
@return bool
|
[
"The",
"Digest",
"encoder",
"is",
"switched",
"because",
"the",
"authorization",
"sent",
"by",
"the",
"browser",
"contains",
"an",
"encoded",
"response",
"hash",
".",
"The",
"encoden",
"needs",
"to",
"encode",
"the",
"stored",
"users",
"credential",
"to",
"compare",
"the",
"response",
".",
"That",
"s",
"why",
"the",
"arguments",
"in",
"this",
"method",
"are",
"switched"
] |
4944ad319baec84812b30f6a6428e75b27520a34
|
https://github.com/tasoftch/skyline-security/blob/4944ad319baec84812b30f6a6428e75b27520a34/src/Encoder/HttpDigestResponseEncoder.php#L51-L57
|
239,380
|
dmeikle/pesedget
|
src/Gossamer/Pesedget/Database/ColumnMappings.php
|
ColumnMappings.getColumnMappingsFromConfig
|
protected function getColumnMappingsFromConfig($tableName) {
$filename = "$tableName.conf";
$configManager = new ConfigManager();
$config = $configManager->getConfiguration($filename);
if (is_null($config)) {
$result = $this->dbConnection->query('SHOW COLUMNS FROM ' . $tableName);
if (is_null($result)) {
throw new TableNotFoundException('table ' . $tableName . ' not found');
}
$columnNames = array();
foreach ($result as $object => $values) {
//array_push($columnNames, array($values['Field'] => $values));
$columnNames[$values['Field']] = $values;
}
$config = new Config($columnNames);
$configManager->saveConfiguration($filename, $config);
}
return $config->toArray();
}
|
php
|
protected function getColumnMappingsFromConfig($tableName) {
$filename = "$tableName.conf";
$configManager = new ConfigManager();
$config = $configManager->getConfiguration($filename);
if (is_null($config)) {
$result = $this->dbConnection->query('SHOW COLUMNS FROM ' . $tableName);
if (is_null($result)) {
throw new TableNotFoundException('table ' . $tableName . ' not found');
}
$columnNames = array();
foreach ($result as $object => $values) {
//array_push($columnNames, array($values['Field'] => $values));
$columnNames[$values['Field']] = $values;
}
$config = new Config($columnNames);
$configManager->saveConfiguration($filename, $config);
}
return $config->toArray();
}
|
[
"protected",
"function",
"getColumnMappingsFromConfig",
"(",
"$",
"tableName",
")",
"{",
"$",
"filename",
"=",
"\"$tableName.conf\"",
";",
"$",
"configManager",
"=",
"new",
"ConfigManager",
"(",
")",
";",
"$",
"config",
"=",
"$",
"configManager",
"->",
"getConfiguration",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"config",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"dbConnection",
"->",
"query",
"(",
"'SHOW COLUMNS FROM '",
".",
"$",
"tableName",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"result",
")",
")",
"{",
"throw",
"new",
"TableNotFoundException",
"(",
"'table '",
".",
"$",
"tableName",
".",
"' not found'",
")",
";",
"}",
"$",
"columnNames",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"result",
"as",
"$",
"object",
"=>",
"$",
"values",
")",
"{",
"//array_push($columnNames, array($values['Field'] => $values));",
"$",
"columnNames",
"[",
"$",
"values",
"[",
"'Field'",
"]",
"]",
"=",
"$",
"values",
";",
"}",
"$",
"config",
"=",
"new",
"Config",
"(",
"$",
"columnNames",
")",
";",
"$",
"configManager",
"->",
"saveConfiguration",
"(",
"$",
"filename",
",",
"$",
"config",
")",
";",
"}",
"return",
"$",
"config",
"->",
"toArray",
"(",
")",
";",
"}"
] |
getColumnMappingsFromConfig retrieves serialized column list specific to a table
@param string tablename
@return array list of columns
|
[
"getColumnMappingsFromConfig",
"retrieves",
"serialized",
"column",
"list",
"specific",
"to",
"a",
"table"
] |
bcfca25569d1f47c073f08906a710ed895f77b4d
|
https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Database/ColumnMappings.php#L77-L103
|
239,381
|
unyx/console
|
terminals/Windows.php
|
Windows.getDimensionsFromAnsicon
|
protected function getDimensionsFromAnsicon() : ?array
{
if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
return [
'width' => (int) $matches[1],
'height' => (int) ($matches[4] ?? $matches[2])
];
}
return null;
}
|
php
|
protected function getDimensionsFromAnsicon() : ?array
{
if (preg_match('/^(\d+)x(\d+)(?: \((\d+)x(\d+)\))?$/', trim(getenv('ANSICON')), $matches)) {
return [
'width' => (int) $matches[1],
'height' => (int) ($matches[4] ?? $matches[2])
];
}
return null;
}
|
[
"protected",
"function",
"getDimensionsFromAnsicon",
"(",
")",
":",
"?",
"array",
"{",
"if",
"(",
"preg_match",
"(",
"'/^(\\d+)x(\\d+)(?: \\((\\d+)x(\\d+)\\))?$/'",
",",
"trim",
"(",
"getenv",
"(",
"'ANSICON'",
")",
")",
",",
"$",
"matches",
")",
")",
"{",
"return",
"[",
"'width'",
"=>",
"(",
"int",
")",
"$",
"matches",
"[",
"1",
"]",
",",
"'height'",
"=>",
"(",
"int",
")",
"(",
"$",
"matches",
"[",
"4",
"]",
"??",
"$",
"matches",
"[",
"2",
"]",
")",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Attempts to determine the Terminal's dimensions based on the 'ANSICON' environmental variables.
@return array Either an array containing two keys - 'width' and 'height' or null if the data couldn't
be parsed to retrieve anything useful.
|
[
"Attempts",
"to",
"determine",
"the",
"Terminal",
"s",
"dimensions",
"based",
"on",
"the",
"ANSICON",
"environmental",
"variables",
"."
] |
b4a76e08bbb5428b0349c0ec4259a914f81a2957
|
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/terminals/Windows.php#L41-L51
|
239,382
|
unyx/console
|
terminals/Windows.php
|
Windows.getDimensionsFromMode
|
protected function getDimensionsFromMode() : ?array
{
if (empty($output = $this->execute('mode CON'))) {
return null;
}
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $output, $matches)) {
return [
'width' => (int) $matches[2],
'height'=> (int) $matches[1]
];
}
return null;
}
|
php
|
protected function getDimensionsFromMode() : ?array
{
if (empty($output = $this->execute('mode CON'))) {
return null;
}
if (preg_match('/--------+\r?\n.+?(\d+)\r?\n.+?(\d+)\r?\n/', $output, $matches)) {
return [
'width' => (int) $matches[2],
'height'=> (int) $matches[1]
];
}
return null;
}
|
[
"protected",
"function",
"getDimensionsFromMode",
"(",
")",
":",
"?",
"array",
"{",
"if",
"(",
"empty",
"(",
"$",
"output",
"=",
"$",
"this",
"->",
"execute",
"(",
"'mode CON'",
")",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/--------+\\r?\\n.+?(\\d+)\\r?\\n.+?(\\d+)\\r?\\n/'",
",",
"$",
"output",
",",
"$",
"matches",
")",
")",
"{",
"return",
"[",
"'width'",
"=>",
"(",
"int",
")",
"$",
"matches",
"[",
"2",
"]",
",",
"'height'",
"=>",
"(",
"int",
")",
"$",
"matches",
"[",
"1",
"]",
"]",
";",
"}",
"return",
"null",
";",
"}"
] |
Attempts to determine the Terminal's dimensions based on the result of a 'mode CON' system call.
@return array Either an array containing two keys - 'width' and 'height' or null if the data couldn't
be parsed to retrieve anything useful.
|
[
"Attempts",
"to",
"determine",
"the",
"Terminal",
"s",
"dimensions",
"based",
"on",
"the",
"result",
"of",
"a",
"mode",
"CON",
"system",
"call",
"."
] |
b4a76e08bbb5428b0349c0ec4259a914f81a2957
|
https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/terminals/Windows.php#L59-L73
|
239,383
|
zepi/turbo-base
|
Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php
|
AbstractDoctrineDataSource.find
|
public function find(DataRequest $dataRequest)
{
try {
$dataRequest->setSelectedFields(array('*'));
$queryBuilder = $this->entityManager->getQueryBuilder();
$this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $this->getEntityClass(), 'e');
$entities = $queryBuilder->getQuery()->getResult();
if ($entities == null) {
return array();
}
return $entities;
} catch (\Exception $e) {
throw new Exception('Cannot load the entities for the given data request.', 0, $e);
}
}
|
php
|
public function find(DataRequest $dataRequest)
{
try {
$dataRequest->setSelectedFields(array('*'));
$queryBuilder = $this->entityManager->getQueryBuilder();
$this->entityManager->buildDataRequestQuery($dataRequest, $queryBuilder, $this->getEntityClass(), 'e');
$entities = $queryBuilder->getQuery()->getResult();
if ($entities == null) {
return array();
}
return $entities;
} catch (\Exception $e) {
throw new Exception('Cannot load the entities for the given data request.', 0, $e);
}
}
|
[
"public",
"function",
"find",
"(",
"DataRequest",
"$",
"dataRequest",
")",
"{",
"try",
"{",
"$",
"dataRequest",
"->",
"setSelectedFields",
"(",
"array",
"(",
"'*'",
")",
")",
";",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getQueryBuilder",
"(",
")",
";",
"$",
"this",
"->",
"entityManager",
"->",
"buildDataRequestQuery",
"(",
"$",
"dataRequest",
",",
"$",
"queryBuilder",
",",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
",",
"'e'",
")",
";",
"$",
"entities",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"if",
"(",
"$",
"entities",
"==",
"null",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"return",
"$",
"entities",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot load the entities for the given data request.'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns an array with all found entities for the given DataRequest
object.
@param \Zepi\Core\Utils\DataRequest $dataRequest
@return array
@throws \Zepi\DataSource\Doctrine\Exception Cannot load the entities for the given data request.
|
[
"Returns",
"an",
"array",
"with",
"all",
"found",
"entities",
"for",
"the",
"given",
"DataRequest",
"object",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php#L74-L91
|
239,384
|
zepi/turbo-base
|
Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php
|
AbstractDoctrineDataSource.has
|
public function has($id)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($this->getEntityClass())->findOneBy(array(
'id' => $id,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an entity for the given id "' . $id . '".', 0, $e);
}
}
|
php
|
public function has($id)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$data = $em->getRepository($this->getEntityClass())->findOneBy(array(
'id' => $id,
));
if ($data !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is an entity for the given id "' . $id . '".', 0, $e);
}
}
|
[
"public",
"function",
"has",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"data",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
")",
")",
";",
"if",
"(",
"$",
"data",
"!==",
"null",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot check if there is an entity for the given id \"'",
".",
"$",
"id",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns true if there is an entity for the given id
@access public
@param integer $id
@return boolean
@throws \Zepi\DataSource\Doctrine\Exception Cannot check if there is an entity for the given id "{id}".
|
[
"Returns",
"true",
"if",
"there",
"is",
"an",
"entity",
"for",
"the",
"given",
"id"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php#L137-L153
|
239,385
|
zepi/turbo-base
|
Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php
|
AbstractDoctrineDataSource.get
|
public function get($id)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($this->getEntityClass())->findOneBy(array(
'id' => $id,
));
if ($accessEntity !== null) {
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the entity from the database for the given id "' . $id . '".', 0, $e);
}
}
|
php
|
public function get($id)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$accessEntity = $em->getRepository($this->getEntityClass())->findOneBy(array(
'id' => $id,
));
if ($accessEntity !== null) {
return $accessEntity;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot load the entity from the database for the given id "' . $id . '".', 0, $e);
}
}
|
[
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"accessEntity",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
"->",
"findOneBy",
"(",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
")",
")",
";",
"if",
"(",
"$",
"accessEntity",
"!==",
"null",
")",
"{",
"return",
"$",
"accessEntity",
";",
"}",
"return",
"false",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot load the entity from the database for the given id \"'",
".",
"$",
"id",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Returns the entity object for the given id
@param integer $id
@return false|mixed
@throws \Zepi\DataSource\Doctrine\Exception Cannot load the entity from the database for the given id "{id}".
|
[
"Returns",
"the",
"entity",
"object",
"for",
"the",
"given",
"id"
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php#L163-L179
|
239,386
|
zepi/turbo-base
|
Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php
|
AbstractDoctrineDataSource.add
|
public function add(EntityInterface $entity)
{
if (!is_a($entity, $this->getEntityClass())) {
throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.');
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->persist($entity);
$em->flush();
return $entity->getId();
} catch (\Exception $e) {
throw new Exception('Cannot add the entity "' . $entity . '".', 0, $e);
}
}
|
php
|
public function add(EntityInterface $entity)
{
if (!is_a($entity, $this->getEntityClass())) {
throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.');
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->persist($entity);
$em->flush();
return $entity->getId();
} catch (\Exception $e) {
throw new Exception('Cannot add the entity "' . $entity . '".', 0, $e);
}
}
|
[
"public",
"function",
"add",
"(",
"EntityInterface",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"entity",
",",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The given entity ('",
".",
"get_class",
"(",
"$",
"entity",
")",
".",
"') is not compatible with this data source ('",
".",
"self",
"::",
"class",
".",
"'.'",
")",
";",
"}",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"em",
"->",
"persist",
"(",
"$",
"entity",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"$",
"entity",
"->",
"getId",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot add the entity \"'",
".",
"$",
"entity",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Adds an entity. Returns the id of the entity
or false, if the entity can not inserted.
@param \Zepi\DataSource\Core\Entity\EntityInterface $entity
@return \Zepi\DataSource\Core\Entity\EntityInterface|false
@throws \Zepi\DataSource\Doctrine\Exception The given entity is not compatible with this data source.
@throws \Zepi\DataSource\Doctrine\Exception Cannot add the entity "{entity}".
|
[
"Adds",
"an",
"entity",
".",
"Returns",
"the",
"id",
"of",
"the",
"entity",
"or",
"false",
"if",
"the",
"entity",
"can",
"not",
"inserted",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php#L191-L206
|
239,387
|
zepi/turbo-base
|
Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php
|
AbstractDoctrineDataSource.update
|
public function update(EntityInterface $entity)
{
if (!is_a($entity, $this->getEntityClass())) {
throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.');
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->flush();
return true;
} catch (\Exception $e) {
throw new Exception('Cannot update the entity"' . $entity . '".', 0, $e);
}
}
|
php
|
public function update(EntityInterface $entity)
{
if (!is_a($entity, $this->getEntityClass())) {
throw new Exception('The given entity (' . get_class($entity) . ') is not compatible with this data source (' . self::class . '.');
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$em->flush();
return true;
} catch (\Exception $e) {
throw new Exception('Cannot update the entity"' . $entity . '".', 0, $e);
}
}
|
[
"public",
"function",
"update",
"(",
"EntityInterface",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"entity",
",",
"$",
"this",
"->",
"getEntityClass",
"(",
")",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The given entity ('",
".",
"get_class",
"(",
"$",
"entity",
")",
".",
"') is not compatible with this data source ('",
".",
"self",
"::",
"class",
".",
"'.'",
")",
";",
"}",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"em",
"->",
"flush",
"(",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot update the entity\"'",
".",
"$",
"entity",
".",
"'\".'",
",",
"0",
",",
"$",
"e",
")",
";",
"}",
"}"
] |
Updates the entity. Returns true if everything worked as excepted or
false if the update didn't worked.
@param \Zepi\DataSource\Core\Entity\EntityInterface $entity
@return boolean
@throws \Zepi\DataSource\Doctrine\Exception The given entity is not compatible with this data source.
@throws \Zepi\DataSource\Doctrine\Exception Cannot update the entity "{entity}".
|
[
"Updates",
"the",
"entity",
".",
"Returns",
"true",
"if",
"everything",
"worked",
"as",
"excepted",
"or",
"false",
"if",
"the",
"update",
"didn",
"t",
"worked",
"."
] |
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
|
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Doctrine/src/DataSource/AbstractDoctrineDataSource.php#L218-L232
|
239,388
|
Opifer/ContentBundle
|
Block/Service/NavigationBlockService.php
|
NavigationBlockService.buildTree
|
protected function buildTree(array $simpleTree, $tree = [])
{
foreach ($simpleTree as $item) {
if (!isset($this->collection[$item['id']])) {
continue;
}
$content = $this->collection[$item['id']];
unset($this->collection[$item['id']]); // TODO Fix multi-usage of single item
if (isset($item['__children']) && count($item['__children'])) {
$content['__children'] = $this->buildTree($item['__children']);
} else {
$content['__children'] = [];
}
$tree[] = $content;
}
return $tree;
}
|
php
|
protected function buildTree(array $simpleTree, $tree = [])
{
foreach ($simpleTree as $item) {
if (!isset($this->collection[$item['id']])) {
continue;
}
$content = $this->collection[$item['id']];
unset($this->collection[$item['id']]); // TODO Fix multi-usage of single item
if (isset($item['__children']) && count($item['__children'])) {
$content['__children'] = $this->buildTree($item['__children']);
} else {
$content['__children'] = [];
}
$tree[] = $content;
}
return $tree;
}
|
[
"protected",
"function",
"buildTree",
"(",
"array",
"$",
"simpleTree",
",",
"$",
"tree",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"simpleTree",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"item",
"[",
"'id'",
"]",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"content",
"=",
"$",
"this",
"->",
"collection",
"[",
"$",
"item",
"[",
"'id'",
"]",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"collection",
"[",
"$",
"item",
"[",
"'id'",
"]",
"]",
")",
";",
"// TODO Fix multi-usage of single item",
"if",
"(",
"isset",
"(",
"$",
"item",
"[",
"'__children'",
"]",
")",
"&&",
"count",
"(",
"$",
"item",
"[",
"'__children'",
"]",
")",
")",
"{",
"$",
"content",
"[",
"'__children'",
"]",
"=",
"$",
"this",
"->",
"buildTree",
"(",
"$",
"item",
"[",
"'__children'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"content",
"[",
"'__children'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"tree",
"[",
"]",
"=",
"$",
"content",
";",
"}",
"return",
"$",
"tree",
";",
"}"
] |
Build the tree from the simpletree and the collection
@param array $simpleTree
@param array $tree
@return array
|
[
"Build",
"the",
"tree",
"from",
"the",
"simpletree",
"and",
"the",
"collection"
] |
df44ef36b81a839ce87ea9a92f7728618111541f
|
https://github.com/Opifer/ContentBundle/blob/df44ef36b81a839ce87ea9a92f7728618111541f/Block/Service/NavigationBlockService.php#L127-L148
|
239,389
|
vincenttouzet/BaseBundle
|
Command/GenerateCommand.php
|
GenerateCommand.execute
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
if (!$this->metadata) {
try {
$this->metadata = $this->retrieveMetadatas($input->getArgument('name'));
} catch (\Exception $e) {
$io->error($e->getMessage());
return;
}
}
$metadatas = $this->metadata->getMetadata();
$namespace = str_replace('\\Entity', '', $this->metadata->getNamespace());
$path = $this->metadata->getPath();
$basePath = sprintf(
'%s/%s',
$path,
str_replace('\\', '/', $namespace)
);
$appDir = $this->getContainer()->getParameter('kernel.root_dir');
$adminGenerator = new AdminGenerator($appDir);
$managerGenerator = new ManagerGenerator($appDir);
$adminCtlGenerator = new AdminControllerGenerator($appDir);
$servicesGenerator = new ServicesGenerator($appDir);
$transGenerator = new TranslationsGenerator($appDir);
foreach ($metadatas as $metadata) {
$entityName = $this->getEntityNameFromMetadata($metadata);
$output->writeln('');
$output->writeln(sprintf('Generate files for entity %s', $entityName));
// generate Admin class
$output->writeln($adminGenerator->generate($namespace, $basePath, $metadata));
// generate Manager class
$output->writeln($managerGenerator->generate($namespace, $basePath, $metadata));
// generate AdminController class
$output->writeln($adminCtlGenerator->generate($namespace, $basePath, $metadata));
// update translations
$transGenerator->setBundleName($this->getBundleNameFromEntity($metadata->rootEntityName));
$output->writeln($transGenerator->generate($namespace, $basePath, $metadata));
// update services.yml
$servicesGenerator->setBundleName($this->getBundleNameFromEntity($metadata->rootEntityName));
$output->writeln($servicesGenerator->generate($namespace, $basePath, $metadata));
}
}
|
php
|
protected function execute(InputInterface $input, OutputInterface $output)
{
$io = new SymfonyStyle($input, $output);
if (!$this->metadata) {
try {
$this->metadata = $this->retrieveMetadatas($input->getArgument('name'));
} catch (\Exception $e) {
$io->error($e->getMessage());
return;
}
}
$metadatas = $this->metadata->getMetadata();
$namespace = str_replace('\\Entity', '', $this->metadata->getNamespace());
$path = $this->metadata->getPath();
$basePath = sprintf(
'%s/%s',
$path,
str_replace('\\', '/', $namespace)
);
$appDir = $this->getContainer()->getParameter('kernel.root_dir');
$adminGenerator = new AdminGenerator($appDir);
$managerGenerator = new ManagerGenerator($appDir);
$adminCtlGenerator = new AdminControllerGenerator($appDir);
$servicesGenerator = new ServicesGenerator($appDir);
$transGenerator = new TranslationsGenerator($appDir);
foreach ($metadatas as $metadata) {
$entityName = $this->getEntityNameFromMetadata($metadata);
$output->writeln('');
$output->writeln(sprintf('Generate files for entity %s', $entityName));
// generate Admin class
$output->writeln($adminGenerator->generate($namespace, $basePath, $metadata));
// generate Manager class
$output->writeln($managerGenerator->generate($namespace, $basePath, $metadata));
// generate AdminController class
$output->writeln($adminCtlGenerator->generate($namespace, $basePath, $metadata));
// update translations
$transGenerator->setBundleName($this->getBundleNameFromEntity($metadata->rootEntityName));
$output->writeln($transGenerator->generate($namespace, $basePath, $metadata));
// update services.yml
$servicesGenerator->setBundleName($this->getBundleNameFromEntity($metadata->rootEntityName));
$output->writeln($servicesGenerator->generate($namespace, $basePath, $metadata));
}
}
|
[
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"io",
"=",
"new",
"SymfonyStyle",
"(",
"$",
"input",
",",
"$",
"output",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"metadata",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"metadata",
"=",
"$",
"this",
"->",
"retrieveMetadatas",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'name'",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"io",
"->",
"error",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"return",
";",
"}",
"}",
"$",
"metadatas",
"=",
"$",
"this",
"->",
"metadata",
"->",
"getMetadata",
"(",
")",
";",
"$",
"namespace",
"=",
"str_replace",
"(",
"'\\\\Entity'",
",",
"''",
",",
"$",
"this",
"->",
"metadata",
"->",
"getNamespace",
"(",
")",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"metadata",
"->",
"getPath",
"(",
")",
";",
"$",
"basePath",
"=",
"sprintf",
"(",
"'%s/%s'",
",",
"$",
"path",
",",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"namespace",
")",
")",
";",
"$",
"appDir",
"=",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"getParameter",
"(",
"'kernel.root_dir'",
")",
";",
"$",
"adminGenerator",
"=",
"new",
"AdminGenerator",
"(",
"$",
"appDir",
")",
";",
"$",
"managerGenerator",
"=",
"new",
"ManagerGenerator",
"(",
"$",
"appDir",
")",
";",
"$",
"adminCtlGenerator",
"=",
"new",
"AdminControllerGenerator",
"(",
"$",
"appDir",
")",
";",
"$",
"servicesGenerator",
"=",
"new",
"ServicesGenerator",
"(",
"$",
"appDir",
")",
";",
"$",
"transGenerator",
"=",
"new",
"TranslationsGenerator",
"(",
"$",
"appDir",
")",
";",
"foreach",
"(",
"$",
"metadatas",
"as",
"$",
"metadata",
")",
"{",
"$",
"entityName",
"=",
"$",
"this",
"->",
"getEntityNameFromMetadata",
"(",
"$",
"metadata",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"''",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"sprintf",
"(",
"'Generate files for entity %s'",
",",
"$",
"entityName",
")",
")",
";",
"// generate Admin class",
"$",
"output",
"->",
"writeln",
"(",
"$",
"adminGenerator",
"->",
"generate",
"(",
"$",
"namespace",
",",
"$",
"basePath",
",",
"$",
"metadata",
")",
")",
";",
"// generate Manager class",
"$",
"output",
"->",
"writeln",
"(",
"$",
"managerGenerator",
"->",
"generate",
"(",
"$",
"namespace",
",",
"$",
"basePath",
",",
"$",
"metadata",
")",
")",
";",
"// generate AdminController class",
"$",
"output",
"->",
"writeln",
"(",
"$",
"adminCtlGenerator",
"->",
"generate",
"(",
"$",
"namespace",
",",
"$",
"basePath",
",",
"$",
"metadata",
")",
")",
";",
"// update translations",
"$",
"transGenerator",
"->",
"setBundleName",
"(",
"$",
"this",
"->",
"getBundleNameFromEntity",
"(",
"$",
"metadata",
"->",
"rootEntityName",
")",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"$",
"transGenerator",
"->",
"generate",
"(",
"$",
"namespace",
",",
"$",
"basePath",
",",
"$",
"metadata",
")",
")",
";",
"// update services.yml",
"$",
"servicesGenerator",
"->",
"setBundleName",
"(",
"$",
"this",
"->",
"getBundleNameFromEntity",
"(",
"$",
"metadata",
"->",
"rootEntityName",
")",
")",
";",
"$",
"output",
"->",
"writeln",
"(",
"$",
"servicesGenerator",
"->",
"generate",
"(",
"$",
"namespace",
",",
"$",
"basePath",
",",
"$",
"metadata",
")",
")",
";",
"}",
"}"
] |
execute command.
@param InputInterface $input InputInterface instance
@param OutputInterface $output OutputInterface instance
@return int|null|void
|
[
"execute",
"command",
"."
] |
04faac91884ac5ae270a32ba3d63dca8892aa1dd
|
https://github.com/vincenttouzet/BaseBundle/blob/04faac91884ac5ae270a32ba3d63dca8892aa1dd/Command/GenerateCommand.php#L93-L140
|
239,390
|
mtoolkit/mtoolkit-network
|
src/rpc/json/server/MRPCJsonWebService.php
|
MRPCJsonWebService.execute
|
public function execute( $className )
{
$this->className = $className;
// Parse the request
$rawRequest = file_get_contents( 'php://input' );
/* @var $request array */
$request = json_decode( $rawRequest, true );
// Is valid request?
if( $request == false )
{
throw new MRPCJsonServerException( sprintf( 'Invalid body (%s).', $rawRequest ) );
}
// Does the request respect the 2.0 specification?
if( $request['jsonrpc'] != '2.0' )
{
throw new MRPCJsonServerException( sprintf( 'The request does not respect the 2.0 specification.' ) );
}
// Set the request properties
$this->request = new MRPCJsonRequest();
$this->request
->setMethod( $request['method'] )
->setParams( $request['params'] )
->setId( $request['id'] );
// Call the procedure/member
$callResponse = call_user_func(
array( $this, $this->request->getMethod() )
, $this->request->getParams() );
// Does the call fail?
if( $callResponse === false )
{
throw new MRPCJsonServerException( 'Invalid method name.' );
}
}
|
php
|
public function execute( $className )
{
$this->className = $className;
// Parse the request
$rawRequest = file_get_contents( 'php://input' );
/* @var $request array */
$request = json_decode( $rawRequest, true );
// Is valid request?
if( $request == false )
{
throw new MRPCJsonServerException( sprintf( 'Invalid body (%s).', $rawRequest ) );
}
// Does the request respect the 2.0 specification?
if( $request['jsonrpc'] != '2.0' )
{
throw new MRPCJsonServerException( sprintf( 'The request does not respect the 2.0 specification.' ) );
}
// Set the request properties
$this->request = new MRPCJsonRequest();
$this->request
->setMethod( $request['method'] )
->setParams( $request['params'] )
->setId( $request['id'] );
// Call the procedure/member
$callResponse = call_user_func(
array( $this, $this->request->getMethod() )
, $this->request->getParams() );
// Does the call fail?
if( $callResponse === false )
{
throw new MRPCJsonServerException( 'Invalid method name.' );
}
}
|
[
"public",
"function",
"execute",
"(",
"$",
"className",
")",
"{",
"$",
"this",
"->",
"className",
"=",
"$",
"className",
";",
"// Parse the request",
"$",
"rawRequest",
"=",
"file_get_contents",
"(",
"'php://input'",
")",
";",
"/* @var $request array */",
"$",
"request",
"=",
"json_decode",
"(",
"$",
"rawRequest",
",",
"true",
")",
";",
"// Is valid request?",
"if",
"(",
"$",
"request",
"==",
"false",
")",
"{",
"throw",
"new",
"MRPCJsonServerException",
"(",
"sprintf",
"(",
"'Invalid body (%s).'",
",",
"$",
"rawRequest",
")",
")",
";",
"}",
"// Does the request respect the 2.0 specification?",
"if",
"(",
"$",
"request",
"[",
"'jsonrpc'",
"]",
"!=",
"'2.0'",
")",
"{",
"throw",
"new",
"MRPCJsonServerException",
"(",
"sprintf",
"(",
"'The request does not respect the 2.0 specification.'",
")",
")",
";",
"}",
"// Set the request properties",
"$",
"this",
"->",
"request",
"=",
"new",
"MRPCJsonRequest",
"(",
")",
";",
"$",
"this",
"->",
"request",
"->",
"setMethod",
"(",
"$",
"request",
"[",
"'method'",
"]",
")",
"->",
"setParams",
"(",
"$",
"request",
"[",
"'params'",
"]",
")",
"->",
"setId",
"(",
"$",
"request",
"[",
"'id'",
"]",
")",
";",
"// Call the procedure/member",
"$",
"callResponse",
"=",
"call_user_func",
"(",
"array",
"(",
"$",
"this",
",",
"$",
"this",
"->",
"request",
"->",
"getMethod",
"(",
")",
")",
",",
"$",
"this",
"->",
"request",
"->",
"getParams",
"(",
")",
")",
";",
"// Does the call fail?",
"if",
"(",
"$",
"callResponse",
"===",
"false",
")",
"{",
"throw",
"new",
"MRPCJsonServerException",
"(",
"'Invalid method name.'",
")",
";",
"}",
"}"
] |
Reads the request and run the web method.
@param $className
@throws MRPCJsonServerException
|
[
"Reads",
"the",
"request",
"and",
"run",
"the",
"web",
"method",
"."
] |
eecf251df546a60ecb693fd3983e78cb946cb9d4
|
https://github.com/mtoolkit/mtoolkit-network/blob/eecf251df546a60ecb693fd3983e78cb946cb9d4/src/rpc/json/server/MRPCJsonWebService.php#L120-L158
|
239,391
|
mtoolkit/mtoolkit-network
|
src/rpc/json/server/MRPCJsonWebService.php
|
MRPCJsonWebService.autorun
|
public static function autorun()
{
/* @var $classes string[] */
$classes = array_reverse( get_declared_classes() );
foreach( $classes as $class )
{
$type = new \ReflectionClass( $class );
$abstract = $type->isAbstract();
if( is_subclass_of( $class, MRPCJsonWebService::class ) === false || $abstract === true )
{
continue;
}
/* @var $webService MRPCJsonWebService */
$webService = new $class();
// If the definitions are requested
if( $_SERVER['QUERY_STRING'] == 'definition' )
{
$definition = new MRPCJsonWebServiceDefinition( $class );
$webService->getHttpResponse()->setContentType( ContentType::TEXT_HTML );
$webService->getHttpResponse()->setOutput( (string)$definition );
}
// Normal web service execution
else
{
$webService->getHttpResponse()->setContentType( ContentType::APPLICATION_JSON );
try
{
$webService->execute( $class );
$webService->getResponse()->setId( $webService->getRequest()->getId() );
} catch( MRPCJsonServerException $ex )
{
$error = new MRPCJsonError();
$error->setCode( -1 );
$error->setMessage( $ex->getMessage() );
$webService->response = new MRPCJsonResponse();
$webService->response->setError( $error );
}
$webService->getHttpResponse()->setOutput( $webService->getResponse()->toJSON() );
}
return $webService;
}
return null;
}
|
php
|
public static function autorun()
{
/* @var $classes string[] */
$classes = array_reverse( get_declared_classes() );
foreach( $classes as $class )
{
$type = new \ReflectionClass( $class );
$abstract = $type->isAbstract();
if( is_subclass_of( $class, MRPCJsonWebService::class ) === false || $abstract === true )
{
continue;
}
/* @var $webService MRPCJsonWebService */
$webService = new $class();
// If the definitions are requested
if( $_SERVER['QUERY_STRING'] == 'definition' )
{
$definition = new MRPCJsonWebServiceDefinition( $class );
$webService->getHttpResponse()->setContentType( ContentType::TEXT_HTML );
$webService->getHttpResponse()->setOutput( (string)$definition );
}
// Normal web service execution
else
{
$webService->getHttpResponse()->setContentType( ContentType::APPLICATION_JSON );
try
{
$webService->execute( $class );
$webService->getResponse()->setId( $webService->getRequest()->getId() );
} catch( MRPCJsonServerException $ex )
{
$error = new MRPCJsonError();
$error->setCode( -1 );
$error->setMessage( $ex->getMessage() );
$webService->response = new MRPCJsonResponse();
$webService->response->setError( $error );
}
$webService->getHttpResponse()->setOutput( $webService->getResponse()->toJSON() );
}
return $webService;
}
return null;
}
|
[
"public",
"static",
"function",
"autorun",
"(",
")",
"{",
"/* @var $classes string[] */",
"$",
"classes",
"=",
"array_reverse",
"(",
"get_declared_classes",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"class",
")",
"{",
"$",
"type",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"$",
"abstract",
"=",
"$",
"type",
"->",
"isAbstract",
"(",
")",
";",
"if",
"(",
"is_subclass_of",
"(",
"$",
"class",
",",
"MRPCJsonWebService",
"::",
"class",
")",
"===",
"false",
"||",
"$",
"abstract",
"===",
"true",
")",
"{",
"continue",
";",
"}",
"/* @var $webService MRPCJsonWebService */",
"$",
"webService",
"=",
"new",
"$",
"class",
"(",
")",
";",
"// If the definitions are requested",
"if",
"(",
"$",
"_SERVER",
"[",
"'QUERY_STRING'",
"]",
"==",
"'definition'",
")",
"{",
"$",
"definition",
"=",
"new",
"MRPCJsonWebServiceDefinition",
"(",
"$",
"class",
")",
";",
"$",
"webService",
"->",
"getHttpResponse",
"(",
")",
"->",
"setContentType",
"(",
"ContentType",
"::",
"TEXT_HTML",
")",
";",
"$",
"webService",
"->",
"getHttpResponse",
"(",
")",
"->",
"setOutput",
"(",
"(",
"string",
")",
"$",
"definition",
")",
";",
"}",
"// Normal web service execution",
"else",
"{",
"$",
"webService",
"->",
"getHttpResponse",
"(",
")",
"->",
"setContentType",
"(",
"ContentType",
"::",
"APPLICATION_JSON",
")",
";",
"try",
"{",
"$",
"webService",
"->",
"execute",
"(",
"$",
"class",
")",
";",
"$",
"webService",
"->",
"getResponse",
"(",
")",
"->",
"setId",
"(",
"$",
"webService",
"->",
"getRequest",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"}",
"catch",
"(",
"MRPCJsonServerException",
"$",
"ex",
")",
"{",
"$",
"error",
"=",
"new",
"MRPCJsonError",
"(",
")",
";",
"$",
"error",
"->",
"setCode",
"(",
"-",
"1",
")",
";",
"$",
"error",
"->",
"setMessage",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"webService",
"->",
"response",
"=",
"new",
"MRPCJsonResponse",
"(",
")",
";",
"$",
"webService",
"->",
"response",
"->",
"setError",
"(",
"$",
"error",
")",
";",
"}",
"$",
"webService",
"->",
"getHttpResponse",
"(",
")",
"->",
"setOutput",
"(",
"$",
"webService",
"->",
"getResponse",
"(",
")",
"->",
"toJSON",
"(",
")",
")",
";",
"}",
"return",
"$",
"webService",
";",
"}",
"return",
"null",
";",
"}"
] |
Run the instance of the web service.
|
[
"Run",
"the",
"instance",
"of",
"the",
"web",
"service",
"."
] |
eecf251df546a60ecb693fd3983e78cb946cb9d4
|
https://github.com/mtoolkit/mtoolkit-network/blob/eecf251df546a60ecb693fd3983e78cb946cb9d4/src/rpc/json/server/MRPCJsonWebService.php#L163-L215
|
239,392
|
rozaverta/cmf
|
core/Event/Driver/EventDriverInterface.php
|
EventDriverInterface.update
|
public function update( string $name, string $title = "", bool $completable = false ): Prop
{
$row = self::getEventItem($name);
if( !$row )
{
throw new NotFoundException("Event '{$name}' not found");
}
$this->permissible($row->module_id, $name);
$title = trim($title);
if( strlen($title) < 1 )
{
$title = $name . " event";
}
$prop = new Prop([
"action" => "update",
"updated" => false
]);
if( $title === $row->title && $completable === $row->completable )
{
return $prop;
}
// dispatch event
$event = new EventUpdateDriverEvent($this, $name, $title, $completable);
$dispatcher = EventManager::dispatcher($event->getName());
$dispatcher->dispatch($event);
$prop->set(
"updated",
\DB::
table("events")
->whereId($row->id)
->update(compact('title', 'completable')) > 0
);
$prop->get("updated") && $this->addLogDebug(Text::createInstance("The %s event is successfully updated", $name));
$dispatcher->complete($prop);
return $prop;
}
|
php
|
public function update( string $name, string $title = "", bool $completable = false ): Prop
{
$row = self::getEventItem($name);
if( !$row )
{
throw new NotFoundException("Event '{$name}' not found");
}
$this->permissible($row->module_id, $name);
$title = trim($title);
if( strlen($title) < 1 )
{
$title = $name . " event";
}
$prop = new Prop([
"action" => "update",
"updated" => false
]);
if( $title === $row->title && $completable === $row->completable )
{
return $prop;
}
// dispatch event
$event = new EventUpdateDriverEvent($this, $name, $title, $completable);
$dispatcher = EventManager::dispatcher($event->getName());
$dispatcher->dispatch($event);
$prop->set(
"updated",
\DB::
table("events")
->whereId($row->id)
->update(compact('title', 'completable')) > 0
);
$prop->get("updated") && $this->addLogDebug(Text::createInstance("The %s event is successfully updated", $name));
$dispatcher->complete($prop);
return $prop;
}
|
[
"public",
"function",
"update",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"title",
"=",
"\"\"",
",",
"bool",
"$",
"completable",
"=",
"false",
")",
":",
"Prop",
"{",
"$",
"row",
"=",
"self",
"::",
"getEventItem",
"(",
"$",
"name",
")",
";",
"if",
"(",
"!",
"$",
"row",
")",
"{",
"throw",
"new",
"NotFoundException",
"(",
"\"Event '{$name}' not found\"",
")",
";",
"}",
"$",
"this",
"->",
"permissible",
"(",
"$",
"row",
"->",
"module_id",
",",
"$",
"name",
")",
";",
"$",
"title",
"=",
"trim",
"(",
"$",
"title",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"title",
")",
"<",
"1",
")",
"{",
"$",
"title",
"=",
"$",
"name",
".",
"\" event\"",
";",
"}",
"$",
"prop",
"=",
"new",
"Prop",
"(",
"[",
"\"action\"",
"=>",
"\"update\"",
",",
"\"updated\"",
"=>",
"false",
"]",
")",
";",
"if",
"(",
"$",
"title",
"===",
"$",
"row",
"->",
"title",
"&&",
"$",
"completable",
"===",
"$",
"row",
"->",
"completable",
")",
"{",
"return",
"$",
"prop",
";",
"}",
"// dispatch event",
"$",
"event",
"=",
"new",
"EventUpdateDriverEvent",
"(",
"$",
"this",
",",
"$",
"name",
",",
"$",
"title",
",",
"$",
"completable",
")",
";",
"$",
"dispatcher",
"=",
"EventManager",
"::",
"dispatcher",
"(",
"$",
"event",
"->",
"getName",
"(",
")",
")",
";",
"$",
"dispatcher",
"->",
"dispatch",
"(",
"$",
"event",
")",
";",
"$",
"prop",
"->",
"set",
"(",
"\"updated\"",
",",
"\\",
"DB",
"::",
"table",
"(",
"\"events\"",
")",
"->",
"whereId",
"(",
"$",
"row",
"->",
"id",
")",
"->",
"update",
"(",
"compact",
"(",
"'title'",
",",
"'completable'",
")",
")",
">",
"0",
")",
";",
"$",
"prop",
"->",
"get",
"(",
"\"updated\"",
")",
"&&",
"$",
"this",
"->",
"addLogDebug",
"(",
"Text",
"::",
"createInstance",
"(",
"\"The %s event is successfully updated\"",
",",
"$",
"name",
")",
")",
";",
"$",
"dispatcher",
"->",
"complete",
"(",
"$",
"prop",
")",
";",
"return",
"$",
"prop",
";",
"}"
] |
Update event data
@param string $name
@param string $title
@param bool $completable
@return Prop
@throws NotFoundException
|
[
"Update",
"event",
"data"
] |
95ed38362e397d1c700ee255f7200234ef98d356
|
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Event/Driver/EventDriverInterface.php#L93-L135
|
239,393
|
rozaverta/cmf
|
core/Event/Driver/EventDriverInterface.php
|
EventDriverInterface.hasName
|
public static function hasName( $name, $module_id = null ): bool
{
if( !self::isValidName($name) )
{
return false;
}
$builder = \DB::table("events")->where("name", $name);
if( is_numeric($module_id) )
{
$builder->where("module_id", (int) $module_id );
}
return $builder->count(["id"]) > 0;
}
|
php
|
public static function hasName( $name, $module_id = null ): bool
{
if( !self::isValidName($name) )
{
return false;
}
$builder = \DB::table("events")->where("name", $name);
if( is_numeric($module_id) )
{
$builder->where("module_id", (int) $module_id );
}
return $builder->count(["id"]) > 0;
}
|
[
"public",
"static",
"function",
"hasName",
"(",
"$",
"name",
",",
"$",
"module_id",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"self",
"::",
"isValidName",
"(",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"builder",
"=",
"\\",
"DB",
"::",
"table",
"(",
"\"events\"",
")",
"->",
"where",
"(",
"\"name\"",
",",
"$",
"name",
")",
";",
"if",
"(",
"is_numeric",
"(",
"$",
"module_id",
")",
")",
"{",
"$",
"builder",
"->",
"where",
"(",
"\"module_id\"",
",",
"(",
"int",
")",
"$",
"module_id",
")",
";",
"}",
"return",
"$",
"builder",
"->",
"count",
"(",
"[",
"\"id\"",
"]",
")",
">",
"0",
";",
"}"
] |
Config name is exists
@param string $name
@param null | int $module_id
@return bool
|
[
"Config",
"name",
"is",
"exists"
] |
95ed38362e397d1c700ee255f7200234ef98d356
|
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Event/Driver/EventDriverInterface.php#L317-L331
|
239,394
|
rozaverta/cmf
|
core/Event/Driver/EventDriverInterface.php
|
EventDriverInterface.isValidName
|
public static function isValidName( $name ): bool
{
$len = strlen($name);
if( $len < 5 || ! preg_match('/^on[A-Z][a-zA-Z]*$/', $name) )
{
return false;
}
return $len < 256;
}
|
php
|
public static function isValidName( $name ): bool
{
$len = strlen($name);
if( $len < 5 || ! preg_match('/^on[A-Z][a-zA-Z]*$/', $name) )
{
return false;
}
return $len < 256;
}
|
[
"public",
"static",
"function",
"isValidName",
"(",
"$",
"name",
")",
":",
"bool",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"name",
")",
";",
"if",
"(",
"$",
"len",
"<",
"5",
"||",
"!",
"preg_match",
"(",
"'/^on[A-Z][a-zA-Z]*$/'",
",",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"len",
"<",
"256",
";",
"}"
] |
Validate config name
@param string $name
@return bool
|
[
"Validate",
"config",
"name"
] |
95ed38362e397d1c700ee255f7200234ef98d356
|
https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Event/Driver/EventDriverInterface.php#L339-L348
|
239,395
|
sndatabase/core
|
src/PreparedStatement.php
|
PreparedStatement.bindParam
|
public function bindParam($tag, &$param, $type = DB::PARAM_AUTO) {
if (!is_int($tag) and ctype_digit($tag))
$tag = intval($tag);
elseif (is_string($tag)) {
if (':' != substr($tag, 0, 1))
$tag = ":$tag";
} else
return false;
$this->parameters[$tag] = array('param' => &$param, 'type' => $type);
return true;
}
|
php
|
public function bindParam($tag, &$param, $type = DB::PARAM_AUTO) {
if (!is_int($tag) and ctype_digit($tag))
$tag = intval($tag);
elseif (is_string($tag)) {
if (':' != substr($tag, 0, 1))
$tag = ":$tag";
} else
return false;
$this->parameters[$tag] = array('param' => &$param, 'type' => $type);
return true;
}
|
[
"public",
"function",
"bindParam",
"(",
"$",
"tag",
",",
"&",
"$",
"param",
",",
"$",
"type",
"=",
"DB",
"::",
"PARAM_AUTO",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"tag",
")",
"and",
"ctype_digit",
"(",
"$",
"tag",
")",
")",
"$",
"tag",
"=",
"intval",
"(",
"$",
"tag",
")",
";",
"elseif",
"(",
"is_string",
"(",
"$",
"tag",
")",
")",
"{",
"if",
"(",
"':'",
"!=",
"substr",
"(",
"$",
"tag",
",",
"0",
",",
"1",
")",
")",
"$",
"tag",
"=",
"\":$tag\"",
";",
"}",
"else",
"return",
"false",
";",
"$",
"this",
"->",
"parameters",
"[",
"$",
"tag",
"]",
"=",
"array",
"(",
"'param'",
"=>",
"&",
"$",
"param",
",",
"'type'",
"=>",
"$",
"type",
")",
";",
"return",
"true",
";",
"}"
] |
Binds parameter to statement
@param string|int $tag Parameter marker in the statement. If marker is '?', use integer value here.
@param &mixed $param Parameter to bind, as reference
@param int $type Parameter type, defaults to string.
@return boolean
|
[
"Binds",
"parameter",
"to",
"statement"
] |
8645b71f1cb437a845fcf12ae742655dd874b229
|
https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/PreparedStatement.php#L51-L61
|
239,396
|
ddehart/dilmun
|
src/Nabu/StaticLogger.php
|
StaticLogger.processContext
|
private static function processContext($message, array $context = array())
{
$replace = array();
foreach ($context as $key => $value) {
$templated = "{" . $key . "}";
$replace[$templated] = $value;
}
if (self::checkContextException($context)) {
/**
* @var \Exception $exception
*/
$exception = $context["exception"];
$replace["{line}"] = $exception->getLine();
$replace["{file}"] = $exception->getFile();
$replace["{message}"] = $exception->getMessage();
}
return strtr($message, $replace);
}
|
php
|
private static function processContext($message, array $context = array())
{
$replace = array();
foreach ($context as $key => $value) {
$templated = "{" . $key . "}";
$replace[$templated] = $value;
}
if (self::checkContextException($context)) {
/**
* @var \Exception $exception
*/
$exception = $context["exception"];
$replace["{line}"] = $exception->getLine();
$replace["{file}"] = $exception->getFile();
$replace["{message}"] = $exception->getMessage();
}
return strtr($message, $replace);
}
|
[
"private",
"static",
"function",
"processContext",
"(",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"$",
"replace",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"context",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"templated",
"=",
"\"{\"",
".",
"$",
"key",
".",
"\"}\"",
";",
"$",
"replace",
"[",
"$",
"templated",
"]",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"self",
"::",
"checkContextException",
"(",
"$",
"context",
")",
")",
"{",
"/**\n * @var \\Exception $exception\n */",
"$",
"exception",
"=",
"$",
"context",
"[",
"\"exception\"",
"]",
";",
"$",
"replace",
"[",
"\"{line}\"",
"]",
"=",
"$",
"exception",
"->",
"getLine",
"(",
")",
";",
"$",
"replace",
"[",
"\"{file}\"",
"]",
"=",
"$",
"exception",
"->",
"getFile",
"(",
")",
";",
"$",
"replace",
"[",
"\"{message}\"",
"]",
"=",
"$",
"exception",
"->",
"getMessage",
"(",
")",
";",
"}",
"return",
"strtr",
"(",
"$",
"message",
",",
"$",
"replace",
")",
";",
"}"
] |
Processes context as supplied by the log method, replacing templated strings with data from the context array
or processing exception data via checkContextException.
Context array elements with the "exception" key are processed by pulling Exception line, file, and message into
the log message provided appropriate templates within the message: {line}, {file}, and {message}, respectively.
Note that any line, file, or message templates provided outside of an exception will be overwritten by context
processing, and so the order in which the context array data are stacked is relevant.
@param string $message The original log message to be processed with context.
@param array $context An array of key => value pairs with additional data to be inserted into the log
message provided {templated text} (i.e. surrounded by curly braces.
@return string The processed log message
|
[
"Processes",
"context",
"as",
"supplied",
"by",
"the",
"log",
"method",
"replacing",
"templated",
"strings",
"with",
"data",
"from",
"the",
"context",
"array",
"or",
"processing",
"exception",
"data",
"via",
"checkContextException",
"."
] |
e2a294dbcd4c6754063c247be64930c5ee91378f
|
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/StaticLogger.php#L208-L229
|
239,397
|
ddehart/dilmun
|
src/Nabu/StaticLogger.php
|
StaticLogger.checkContextException
|
private static function checkContextException(array $context = array())
{
if (isset($context["exception"])) {
$includes_exception = $context["exception"] instanceof \Exception;
} else {
$includes_exception = false;
}
return $includes_exception;
}
|
php
|
private static function checkContextException(array $context = array())
{
if (isset($context["exception"])) {
$includes_exception = $context["exception"] instanceof \Exception;
} else {
$includes_exception = false;
}
return $includes_exception;
}
|
[
"private",
"static",
"function",
"checkContextException",
"(",
"array",
"$",
"context",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"context",
"[",
"\"exception\"",
"]",
")",
")",
"{",
"$",
"includes_exception",
"=",
"$",
"context",
"[",
"\"exception\"",
"]",
"instanceof",
"\\",
"Exception",
";",
"}",
"else",
"{",
"$",
"includes_exception",
"=",
"false",
";",
"}",
"return",
"$",
"includes_exception",
";",
"}"
] |
Determines whether a context array contains an Exception.
@param array $context PSR-3 context array.
@return bool Returns true if the context array contains an element identified by an "exception" key
AND the value that corresponds with the "exception" key is an Exception.
Returns false otherwise.
|
[
"Determines",
"whether",
"a",
"context",
"array",
"contains",
"an",
"Exception",
"."
] |
e2a294dbcd4c6754063c247be64930c5ee91378f
|
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Nabu/StaticLogger.php#L239-L248
|
239,398
|
digipolisgent/robo-digipolis-code-validation
|
src/PhpMd.php
|
PhpMd.rulesets
|
public function rulesets($ruleSetFileNames)
{
if (!is_array($ruleSetFileNames)) {
$ruleSetFileNames = [$ruleSetFileNames];
}
$this->rulesets = array_unique(array_merge($this->rulesets, $ruleSetFileNames));
return $this;
}
|
php
|
public function rulesets($ruleSetFileNames)
{
if (!is_array($ruleSetFileNames)) {
$ruleSetFileNames = [$ruleSetFileNames];
}
$this->rulesets = array_unique(array_merge($this->rulesets, $ruleSetFileNames));
return $this;
}
|
[
"public",
"function",
"rulesets",
"(",
"$",
"ruleSetFileNames",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"ruleSetFileNames",
")",
")",
"{",
"$",
"ruleSetFileNames",
"=",
"[",
"$",
"ruleSetFileNames",
"]",
";",
"}",
"$",
"this",
"->",
"rulesets",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"rulesets",
",",
"$",
"ruleSetFileNames",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets the rule-sets.
@param array|string $ruleSetFileNames
Array of rule-set filenames or identifiers.
@return $this
|
[
"Sets",
"the",
"rule",
"-",
"sets",
"."
] |
56f69f88a368a5049af7021901042820bee914df
|
https://github.com/digipolisgent/robo-digipolis-code-validation/blob/56f69f88a368a5049af7021901042820bee914df/src/PhpMd.php#L131-L139
|
239,399
|
digipolisgent/robo-digipolis-code-validation
|
src/PhpMd.php
|
PhpMd.allowedFileExtensions
|
public function allowedFileExtensions($fileExtensions)
{
if (!is_array($fileExtensions)) {
$fileExtensions = [$fileExtensions];
}
$this->extensions = array_unique(array_merge($this->extensions, $fileExtensions));
return $this;
}
|
php
|
public function allowedFileExtensions($fileExtensions)
{
if (!is_array($fileExtensions)) {
$fileExtensions = [$fileExtensions];
}
$this->extensions = array_unique(array_merge($this->extensions, $fileExtensions));
return $this;
}
|
[
"public",
"function",
"allowedFileExtensions",
"(",
"$",
"fileExtensions",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fileExtensions",
")",
")",
"{",
"$",
"fileExtensions",
"=",
"[",
"$",
"fileExtensions",
"]",
";",
"}",
"$",
"this",
"->",
"extensions",
"=",
"array_unique",
"(",
"array_merge",
"(",
"$",
"this",
"->",
"extensions",
",",
"$",
"fileExtensions",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a list of filename extensions for valid php source code files.
@param array|string $fileExtensions
List of valid file extensions without leading dot.
@return $this
|
[
"Sets",
"a",
"list",
"of",
"filename",
"extensions",
"for",
"valid",
"php",
"source",
"code",
"files",
"."
] |
56f69f88a368a5049af7021901042820bee914df
|
https://github.com/digipolisgent/robo-digipolis-code-validation/blob/56f69f88a368a5049af7021901042820bee914df/src/PhpMd.php#L149-L157
|
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.