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
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
7,000 | noordawod/php-util | src/Shutdown.php | Shutdown.prioritize | public function prioritize(/*string*/ $id, /*int*/ $newPriority) {
// Normalize priority.
$newPriority = intval($newPriority);
// The priority must be valid.
if(self::PRIO_START <= $newPriority && self::PRIO_END >= $newPriority) {
// The new priority must be different than old one.
if(
isset($this->priorities[$id]) &&
$newPriority !== ($priority = $this->priorities[$id])
) {
// Get the callback.
$callback = $this->callbacks[$priority][$id];
// Unregister from old priority.
$this->releaseImpl($id, $priority);
// Register new callback at the new priority.
$this->registerImpl($id, $callback, $newPriority);
}
}
} | php | public function prioritize(/*string*/ $id, /*int*/ $newPriority) {
// Normalize priority.
$newPriority = intval($newPriority);
// The priority must be valid.
if(self::PRIO_START <= $newPriority && self::PRIO_END >= $newPriority) {
// The new priority must be different than old one.
if(
isset($this->priorities[$id]) &&
$newPriority !== ($priority = $this->priorities[$id])
) {
// Get the callback.
$callback = $this->callbacks[$priority][$id];
// Unregister from old priority.
$this->releaseImpl($id, $priority);
// Register new callback at the new priority.
$this->registerImpl($id, $callback, $newPriority);
}
}
} | [
"public",
"function",
"prioritize",
"(",
"/*string*/",
"$",
"id",
",",
"/*int*/",
"$",
"newPriority",
")",
"{",
"// Normalize priority.",
"$",
"newPriority",
"=",
"intval",
"(",
"$",
"newPriority",
")",
";",
"// The priority must be valid.",
"if",
"(",
"self",
"::",
"PRIO_START",
"<=",
"$",
"newPriority",
"&&",
"self",
"::",
"PRIO_END",
">=",
"$",
"newPriority",
")",
"{",
"// The new priority must be different than old one.",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"priorities",
"[",
"$",
"id",
"]",
")",
"&&",
"$",
"newPriority",
"!==",
"(",
"$",
"priority",
"=",
"$",
"this",
"->",
"priorities",
"[",
"$",
"id",
"]",
")",
")",
"{",
"// Get the callback.",
"$",
"callback",
"=",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
"[",
"$",
"id",
"]",
";",
"// Unregister from old priority.",
"$",
"this",
"->",
"releaseImpl",
"(",
"$",
"id",
",",
"$",
"priority",
")",
";",
"// Register new callback at the new priority.",
"$",
"this",
"->",
"registerImpl",
"(",
"$",
"id",
",",
"$",
"callback",
",",
"$",
"newPriority",
")",
";",
"}",
"}",
"}"
] | Change a shutdown callback's priority to the specified one.
@param string $id unique identifier of this callback
@param int $newPriority of the callback | [
"Change",
"a",
"shutdown",
"callback",
"s",
"priority",
"to",
"the",
"specified",
"one",
"."
] | 6458690cc2c8457914a2aa74b131451d4a8e5797 | https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/Shutdown.php#L132-L153 |
7,001 | noordawod/php-util | src/Shutdown.php | Shutdown.execute | public function execute() {
// Make sure this runs only once.
if($this->priorities) {
// Sort the functions by their priority.
if(ksort($this->callbacks)) {
foreach($this->callbacks as $callbacks) {
foreach($callbacks as $callback) {
call_user_func($callback);
}
}
}
// Destroy instance.
$this->priorities = null;
$this->callbacks = null;
}
} | php | public function execute() {
// Make sure this runs only once.
if($this->priorities) {
// Sort the functions by their priority.
if(ksort($this->callbacks)) {
foreach($this->callbacks as $callbacks) {
foreach($callbacks as $callback) {
call_user_func($callback);
}
}
}
// Destroy instance.
$this->priorities = null;
$this->callbacks = null;
}
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"// Make sure this runs only once.",
"if",
"(",
"$",
"this",
"->",
"priorities",
")",
"{",
"// Sort the functions by their priority.",
"if",
"(",
"ksort",
"(",
"$",
"this",
"->",
"callbacks",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"callbacks",
"as",
"$",
"callbacks",
")",
"{",
"foreach",
"(",
"$",
"callbacks",
"as",
"$",
"callback",
")",
"{",
"call_user_func",
"(",
"$",
"callback",
")",
";",
"}",
"}",
"}",
"// Destroy instance.",
"$",
"this",
"->",
"priorities",
"=",
"null",
";",
"$",
"this",
"->",
"callbacks",
"=",
"null",
";",
"}",
"}"
] | Executes the shutdown routine and call all registered callbacks in the
order they were registered. You should never have to call this method in
your app as the class will call it on its own.
Note that once this method runs, either manually by you or automatically
as part of a normal PHP shutdown, it will free all resources and destroy
the class. | [
"Executes",
"the",
"shutdown",
"routine",
"and",
"call",
"all",
"registered",
"callbacks",
"in",
"the",
"order",
"they",
"were",
"registered",
".",
"You",
"should",
"never",
"have",
"to",
"call",
"this",
"method",
"in",
"your",
"app",
"as",
"the",
"class",
"will",
"call",
"it",
"on",
"its",
"own",
"."
] | 6458690cc2c8457914a2aa74b131451d4a8e5797 | https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/Shutdown.php#L164-L180 |
7,002 | noordawod/php-util | src/Shutdown.php | Shutdown.registerImpl | private function registerImpl(
/*string*/ $id,
callable $callback,
/*int*/ $priority
) {
// Initialize array for this priority.
if(!isset($this->callbacks[$priority])) {
$this->callbacks[$priority] = [];
}
// Keep a pointer to the callback and what priority it is.
$this->priorities[$id] = $priority;
$this->callbacks[$priority][$id] = $callback;
} | php | private function registerImpl(
/*string*/ $id,
callable $callback,
/*int*/ $priority
) {
// Initialize array for this priority.
if(!isset($this->callbacks[$priority])) {
$this->callbacks[$priority] = [];
}
// Keep a pointer to the callback and what priority it is.
$this->priorities[$id] = $priority;
$this->callbacks[$priority][$id] = $callback;
} | [
"private",
"function",
"registerImpl",
"(",
"/*string*/",
"$",
"id",
",",
"callable",
"$",
"callback",
",",
"/*int*/",
"$",
"priority",
")",
"{",
"// Initialize array for this priority.",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
"=",
"[",
"]",
";",
"}",
"// Keep a pointer to the callback and what priority it is.",
"$",
"this",
"->",
"priorities",
"[",
"$",
"id",
"]",
"=",
"$",
"priority",
";",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
"[",
"$",
"id",
"]",
"=",
"$",
"callback",
";",
"}"
] | The actual registration implementation takes place here. If you extend this
class, you can register the callbacks using this method.
@param string $id unique identifier of this callback
@param callable $callback to register
@param int $priority of the callback | [
"The",
"actual",
"registration",
"implementation",
"takes",
"place",
"here",
".",
"If",
"you",
"extend",
"this",
"class",
"you",
"can",
"register",
"the",
"callbacks",
"using",
"this",
"method",
"."
] | 6458690cc2c8457914a2aa74b131451d4a8e5797 | https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/Shutdown.php#L190-L203 |
7,003 | noordawod/php-util | src/Shutdown.php | Shutdown.releaseImpl | private function releaseImpl(/*string*/ $id, /*int*/ $priority = -1) {
if(-1 === $priority) {
$priority = $this->priorities[$id];
}
unset($this->priorities[$id]);
unset($this->callbacks[$priority][$id]);
} | php | private function releaseImpl(/*string*/ $id, /*int*/ $priority = -1) {
if(-1 === $priority) {
$priority = $this->priorities[$id];
}
unset($this->priorities[$id]);
unset($this->callbacks[$priority][$id]);
} | [
"private",
"function",
"releaseImpl",
"(",
"/*string*/",
"$",
"id",
",",
"/*int*/",
"$",
"priority",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"-",
"1",
"===",
"$",
"priority",
")",
"{",
"$",
"priority",
"=",
"$",
"this",
"->",
"priorities",
"[",
"$",
"id",
"]",
";",
"}",
"unset",
"(",
"$",
"this",
"->",
"priorities",
"[",
"$",
"id",
"]",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"priority",
"]",
"[",
"$",
"id",
"]",
")",
";",
"}"
] | The actual deregistration implementation takes place here. If you extend
this class, you can deregister the callbacks using this method.
@param string $id unique identifier of this callback
@param int $priority of the callback, or pass -1 to detect the priority | [
"The",
"actual",
"deregistration",
"implementation",
"takes",
"place",
"here",
".",
"If",
"you",
"extend",
"this",
"class",
"you",
"can",
"deregister",
"the",
"callbacks",
"using",
"this",
"method",
"."
] | 6458690cc2c8457914a2aa74b131451d4a8e5797 | https://github.com/noordawod/php-util/blob/6458690cc2c8457914a2aa74b131451d4a8e5797/src/Shutdown.php#L212-L218 |
7,004 | tux-rampage/rampage-php | library/rampage/core/xml/mergerule/UniqueAttributeRule.php | UniqueAttributeRule.isValidAttribute | protected function isValidAttribute($name)
{
$pattern = '~^' . self::ATTRIBUTE_REGEX . '$~i';
$result = @preg_match($pattern, $name);
return (bool)$result;
} | php | protected function isValidAttribute($name)
{
$pattern = '~^' . self::ATTRIBUTE_REGEX . '$~i';
$result = @preg_match($pattern, $name);
return (bool)$result;
} | [
"protected",
"function",
"isValidAttribute",
"(",
"$",
"name",
")",
"{",
"$",
"pattern",
"=",
"'~^'",
".",
"self",
"::",
"ATTRIBUTE_REGEX",
".",
"'$~i'",
";",
"$",
"result",
"=",
"@",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"name",
")",
";",
"return",
"(",
"bool",
")",
"$",
"result",
";",
"}"
] | validate attribute name
@param string $name
@return bool | [
"validate",
"attribute",
"name"
] | 1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf | https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/mergerule/UniqueAttributeRule.php#L82-L87 |
7,005 | tux-rampage/rampage-php | library/rampage/core/xml/mergerule/UniqueAttributeRule.php | UniqueAttributeRule.setAttribute | public function setAttribute($name)
{
if (!$this->isValidAttribute($name)) {
throw new exception\InvalidArgumentException(sprintf(
'Invalid attribute name "%s"', $name
));
}
$this->attribute = $name;
return $this;
} | php | public function setAttribute($name)
{
if (!$this->isValidAttribute($name)) {
throw new exception\InvalidArgumentException(sprintf(
'Invalid attribute name "%s"', $name
));
}
$this->attribute = $name;
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isValidAttribute",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"exception",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Invalid attribute name \"%s\"'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"attribute",
"=",
"$",
"name",
";",
"return",
"$",
"this",
";",
"}"
] | set attribute name
@param string $name
@throws \rampage\core\xml\InvalidArgumentException | [
"set",
"attribute",
"name"
] | 1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf | https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/mergerule/UniqueAttributeRule.php#L95-L105 |
7,006 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.withSaveHandler | public function withSaveHandler(SessionHandlerInterface $save_handler): SessionMiddleware
{
return new SessionMiddleware(
$save_handler,
$this->name,
$this->save_path,
$this->cache_limiter,
$this->cache_expire,
$this->cookie_params
);
} | php | public function withSaveHandler(SessionHandlerInterface $save_handler): SessionMiddleware
{
return new SessionMiddleware(
$save_handler,
$this->name,
$this->save_path,
$this->cache_limiter,
$this->cache_expire,
$this->cookie_params
);
} | [
"public",
"function",
"withSaveHandler",
"(",
"SessionHandlerInterface",
"$",
"save_handler",
")",
":",
"SessionMiddleware",
"{",
"return",
"new",
"SessionMiddleware",
"(",
"$",
"save_handler",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"save_path",
",",
"$",
"this",
"->",
"cache_limiter",
",",
"$",
"this",
"->",
"cache_expire",
",",
"$",
"this",
"->",
"cookie_params",
")",
";",
"}"
] | Return a new session middleware using the given session save handler.
@param \SessionHandlerInterface $save_handler
@return \Ellipse\Session\SessionMiddleware | [
"Return",
"a",
"new",
"session",
"middleware",
"using",
"the",
"given",
"session",
"save",
"handler",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L121-L131 |
7,007 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.withName | public function withName(string $name): SessionMiddleware
{
return new SessionMiddleware(
$this->save_handler,
$name,
$this->save_path,
$this->cache_limiter,
$this->cache_expire,
$this->cookie_params
);
} | php | public function withName(string $name): SessionMiddleware
{
return new SessionMiddleware(
$this->save_handler,
$name,
$this->save_path,
$this->cache_limiter,
$this->cache_expire,
$this->cookie_params
);
} | [
"public",
"function",
"withName",
"(",
"string",
"$",
"name",
")",
":",
"SessionMiddleware",
"{",
"return",
"new",
"SessionMiddleware",
"(",
"$",
"this",
"->",
"save_handler",
",",
"$",
"name",
",",
"$",
"this",
"->",
"save_path",
",",
"$",
"this",
"->",
"cache_limiter",
",",
"$",
"this",
"->",
"cache_expire",
",",
"$",
"this",
"->",
"cookie_params",
")",
";",
"}"
] | Return a new session middleware using the given session name.
@param string $name
@return \Ellipse\Session\SessionMiddleware | [
"Return",
"a",
"new",
"session",
"middleware",
"using",
"the",
"given",
"session",
"name",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L139-L149 |
7,008 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.withCacheExpire | public function withCacheExpire(int $cache_expire): SessionMiddleware
{
return new SessionMiddleware(
$this->save_handler,
$this->name,
$this->save_path,
$this->cache_limiter,
$cache_expire,
$this->cookie_params
);
} | php | public function withCacheExpire(int $cache_expire): SessionMiddleware
{
return new SessionMiddleware(
$this->save_handler,
$this->name,
$this->save_path,
$this->cache_limiter,
$cache_expire,
$this->cookie_params
);
} | [
"public",
"function",
"withCacheExpire",
"(",
"int",
"$",
"cache_expire",
")",
":",
"SessionMiddleware",
"{",
"return",
"new",
"SessionMiddleware",
"(",
"$",
"this",
"->",
"save_handler",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"save_path",
",",
"$",
"this",
"->",
"cache_limiter",
",",
"$",
"cache_expire",
",",
"$",
"this",
"->",
"cookie_params",
")",
";",
"}"
] | Return a new session middleware using the given session cache expire.
@param int $cache_expire
@return \Ellipse\Session\SessionMiddleware | [
"Return",
"a",
"new",
"session",
"middleware",
"using",
"the",
"given",
"session",
"cache",
"expire",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L193-L203 |
7,009 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.withCookieParams | public function withCookieParams(array $cookie_params): SessionMiddleware
{
return new SessionMiddleware(
$this->save_handler,
$this->name,
$this->save_path,
$this->cache_limiter,
$this->cache_expire,
$cookie_params
);
} | php | public function withCookieParams(array $cookie_params): SessionMiddleware
{
return new SessionMiddleware(
$this->save_handler,
$this->name,
$this->save_path,
$this->cache_limiter,
$this->cache_expire,
$cookie_params
);
} | [
"public",
"function",
"withCookieParams",
"(",
"array",
"$",
"cookie_params",
")",
":",
"SessionMiddleware",
"{",
"return",
"new",
"SessionMiddleware",
"(",
"$",
"this",
"->",
"save_handler",
",",
"$",
"this",
"->",
"name",
",",
"$",
"this",
"->",
"save_path",
",",
"$",
"this",
"->",
"cache_limiter",
",",
"$",
"this",
"->",
"cache_expire",
",",
"$",
"cookie_params",
")",
";",
"}"
] | Return a new session middleware using the given session cookie params.
@param array $cookie_params
@return \Ellipse\Session\SessionMiddleware | [
"Return",
"a",
"new",
"session",
"middleware",
"using",
"the",
"given",
"session",
"cookie",
"params",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L211-L221 |
7,010 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.process | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// Fail when session is disabled.
if (session_status() === PHP_SESSION_DISABLED) {
throw new SessionDisabledException;
}
// Fail when session is already started.
if (session_status() === PHP_SESSION_ACTIVE) {
throw new SessionAlreadyStartedException;
}
// Set the user defined session parameters.
if (! is_null($this->save_handler)) session_set_save_handler($this->save_handler);
if (! is_null($this->name)) session_name($this->name);
if (! is_null($this->save_path)) session_save_path($this->save_path);
if (! is_null($this->cache_limiter)) session_cache_limiter($this->cache_limiter);
if (! is_null($this->cache_expire)) session_cache_expire($this->cache_expire);
if ($this->cookie_params != []) $this->setCookieParams($this->cookie_params);
// Set the session id.
$name = session_name();
$id = $request->getCookieParams()[$name] ?? '';
session_id($id);
// Start the session with options disabling cookies.
if (session_start(self::SESSION_START_OPTIONS)) {
// Add the session to the request.
$request = $request->withAttribute(Session::class, new Session($_SESSION));
// Get a response from the request handler.
$response = $handler->handle($request);
// Save the session data and close the session.
session_write_close();
// Return a response with session headers attached.
return $this->attachSessionHeaders($response);
}
throw new SessionStartException;
} | php | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
// Fail when session is disabled.
if (session_status() === PHP_SESSION_DISABLED) {
throw new SessionDisabledException;
}
// Fail when session is already started.
if (session_status() === PHP_SESSION_ACTIVE) {
throw new SessionAlreadyStartedException;
}
// Set the user defined session parameters.
if (! is_null($this->save_handler)) session_set_save_handler($this->save_handler);
if (! is_null($this->name)) session_name($this->name);
if (! is_null($this->save_path)) session_save_path($this->save_path);
if (! is_null($this->cache_limiter)) session_cache_limiter($this->cache_limiter);
if (! is_null($this->cache_expire)) session_cache_expire($this->cache_expire);
if ($this->cookie_params != []) $this->setCookieParams($this->cookie_params);
// Set the session id.
$name = session_name();
$id = $request->getCookieParams()[$name] ?? '';
session_id($id);
// Start the session with options disabling cookies.
if (session_start(self::SESSION_START_OPTIONS)) {
// Add the session to the request.
$request = $request->withAttribute(Session::class, new Session($_SESSION));
// Get a response from the request handler.
$response = $handler->handle($request);
// Save the session data and close the session.
session_write_close();
// Return a response with session headers attached.
return $this->attachSessionHeaders($response);
}
throw new SessionStartException;
} | [
"public",
"function",
"process",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"RequestHandlerInterface",
"$",
"handler",
")",
":",
"ResponseInterface",
"{",
"// Fail when session is disabled.",
"if",
"(",
"session_status",
"(",
")",
"===",
"PHP_SESSION_DISABLED",
")",
"{",
"throw",
"new",
"SessionDisabledException",
";",
"}",
"// Fail when session is already started.",
"if",
"(",
"session_status",
"(",
")",
"===",
"PHP_SESSION_ACTIVE",
")",
"{",
"throw",
"new",
"SessionAlreadyStartedException",
";",
"}",
"// Set the user defined session parameters.",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"save_handler",
")",
")",
"session_set_save_handler",
"(",
"$",
"this",
"->",
"save_handler",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"name",
")",
")",
"session_name",
"(",
"$",
"this",
"->",
"name",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"save_path",
")",
")",
"session_save_path",
"(",
"$",
"this",
"->",
"save_path",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"cache_limiter",
")",
")",
"session_cache_limiter",
"(",
"$",
"this",
"->",
"cache_limiter",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"cache_expire",
")",
")",
"session_cache_expire",
"(",
"$",
"this",
"->",
"cache_expire",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cookie_params",
"!=",
"[",
"]",
")",
"$",
"this",
"->",
"setCookieParams",
"(",
"$",
"this",
"->",
"cookie_params",
")",
";",
"// Set the session id.",
"$",
"name",
"=",
"session_name",
"(",
")",
";",
"$",
"id",
"=",
"$",
"request",
"->",
"getCookieParams",
"(",
")",
"[",
"$",
"name",
"]",
"??",
"''",
";",
"session_id",
"(",
"$",
"id",
")",
";",
"// Start the session with options disabling cookies.",
"if",
"(",
"session_start",
"(",
"self",
"::",
"SESSION_START_OPTIONS",
")",
")",
"{",
"// Add the session to the request.",
"$",
"request",
"=",
"$",
"request",
"->",
"withAttribute",
"(",
"Session",
"::",
"class",
",",
"new",
"Session",
"(",
"$",
"_SESSION",
")",
")",
";",
"// Get a response from the request handler.",
"$",
"response",
"=",
"$",
"handler",
"->",
"handle",
"(",
"$",
"request",
")",
";",
"// Save the session data and close the session.",
"session_write_close",
"(",
")",
";",
"// Return a response with session headers attached.",
"return",
"$",
"this",
"->",
"attachSessionHeaders",
"(",
"$",
"response",
")",
";",
"}",
"throw",
"new",
"SessionStartException",
";",
"}"
] | Enable session for the given request handler.
@param \Psr\Http\Message\ServerRequestInterface $request
@param \Psr\Http\Server\RequestHandlerInterface $handler
@return \Psr\Http\Message\ResponseInterface
@throws \Ellipse\Session\Exceptions\SessionStartException
@throws \Ellipse\Session\Exceptions\SessionDisabledException
@throws \Ellipse\Session\Exceptions\SessionAlreadyStartedException | [
"Enable",
"session",
"for",
"the",
"given",
"request",
"handler",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L233-L282 |
7,011 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.setCookieParams | private function setCookieParams(array $cookie_params)
{
$params = array_merge(session_get_cookie_params(), array_change_key_case($cookie_params));
session_set_cookie_params(
$params['lifetime'],
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
} | php | private function setCookieParams(array $cookie_params)
{
$params = array_merge(session_get_cookie_params(), array_change_key_case($cookie_params));
session_set_cookie_params(
$params['lifetime'],
$params['path'],
$params['domain'],
$params['secure'],
$params['httponly']
);
} | [
"private",
"function",
"setCookieParams",
"(",
"array",
"$",
"cookie_params",
")",
"{",
"$",
"params",
"=",
"array_merge",
"(",
"session_get_cookie_params",
"(",
")",
",",
"array_change_key_case",
"(",
"$",
"cookie_params",
")",
")",
";",
"session_set_cookie_params",
"(",
"$",
"params",
"[",
"'lifetime'",
"]",
",",
"$",
"params",
"[",
"'path'",
"]",
",",
"$",
"params",
"[",
"'domain'",
"]",
",",
"$",
"params",
"[",
"'secure'",
"]",
",",
"$",
"params",
"[",
"'httponly'",
"]",
")",
";",
"}"
] | Set the given session cookie params.
@param array $cookie_params
@return void | [
"Set",
"the",
"given",
"session",
"cookie",
"params",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L290-L301 |
7,012 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.attachSessionHeaders | private function attachSessionHeaders(ResponseInterface $response): ResponseInterface
{
$time = time();
$response = $this->attachCacheLimiterHeader($response, $time);
$response = $this->attachSessionCookie($response, $time);
return $response;
} | php | private function attachSessionHeaders(ResponseInterface $response): ResponseInterface
{
$time = time();
$response = $this->attachCacheLimiterHeader($response, $time);
$response = $this->attachSessionCookie($response, $time);
return $response;
} | [
"private",
"function",
"attachSessionHeaders",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"ResponseInterface",
"{",
"$",
"time",
"=",
"time",
"(",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"attachCacheLimiterHeader",
"(",
"$",
"response",
",",
"$",
"time",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"attachSessionCookie",
"(",
"$",
"response",
",",
"$",
"time",
")",
";",
"return",
"$",
"response",
";",
"}"
] | Attach the session headers to the given response.
Trying to emulate the default php 7.0 headers generations. Adapted from
Relay.Middleware SessionHeadersHandler.
@param \Psr\Http\Message\ResponseInterface $response
@return \Psr\Http\Message\ResponseInterface
@see https://github.com/relayphp/Relay.Middleware/blob/1.x/src/SessionHeadersHandler.php | [
"Attach",
"the",
"session",
"headers",
"to",
"the",
"given",
"response",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L314-L322 |
7,013 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.attachCacheLimiterHeader | private function attachCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$cache_limiter = session_cache_limiter();
switch ($cache_limiter) {
case 'public':
return $this->attachPublicCacheLimiterHeader($response, $time);
case 'private':
return $this->attachPrivateCacheLimiterHeader($response, $time);
case 'private_no_expire':
return $this->attachPrivateNoExpireCacheLimiterHeader($response, $time);
case 'nocache':
return $this->attachNocacheCacheLimiterHeader($response);
default:
return $response;
}
} | php | private function attachCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$cache_limiter = session_cache_limiter();
switch ($cache_limiter) {
case 'public':
return $this->attachPublicCacheLimiterHeader($response, $time);
case 'private':
return $this->attachPrivateCacheLimiterHeader($response, $time);
case 'private_no_expire':
return $this->attachPrivateNoExpireCacheLimiterHeader($response, $time);
case 'nocache':
return $this->attachNocacheCacheLimiterHeader($response);
default:
return $response;
}
} | [
"private",
"function",
"attachCacheLimiterHeader",
"(",
"ResponseInterface",
"$",
"response",
",",
"int",
"$",
"time",
")",
":",
"ResponseInterface",
"{",
"$",
"cache_limiter",
"=",
"session_cache_limiter",
"(",
")",
";",
"switch",
"(",
"$",
"cache_limiter",
")",
"{",
"case",
"'public'",
":",
"return",
"$",
"this",
"->",
"attachPublicCacheLimiterHeader",
"(",
"$",
"response",
",",
"$",
"time",
")",
";",
"case",
"'private'",
":",
"return",
"$",
"this",
"->",
"attachPrivateCacheLimiterHeader",
"(",
"$",
"response",
",",
"$",
"time",
")",
";",
"case",
"'private_no_expire'",
":",
"return",
"$",
"this",
"->",
"attachPrivateNoExpireCacheLimiterHeader",
"(",
"$",
"response",
",",
"$",
"time",
")",
";",
"case",
"'nocache'",
":",
"return",
"$",
"this",
"->",
"attachNocacheCacheLimiterHeader",
"(",
"$",
"response",
")",
";",
"default",
":",
"return",
"$",
"response",
";",
"}",
"}"
] | Attach a session cache limiter header to the given response.
@param \Psr\Http\Message\ResponseInterface $response
@param int $time
@return \Psr\Http\Message\ResponseInterface | [
"Attach",
"a",
"session",
"cache",
"limiter",
"header",
"to",
"the",
"given",
"response",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L331-L347 |
7,014 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.attachPublicCacheLimiterHeader | private function attachPublicCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$cache_expire = session_cache_expire();
$max_age = $cache_expire * 60;
$expires = gmdate(self::DATE_FORMAT, $time + $max_age);
$cache_control = "public, max-age={$max_age}";
$last_modified = gmdate(self::DATE_FORMAT, $time);
return $response
->withAddedHeader('Expires', $expires)
->withAddedHeader('Cache-Control', $cache_control)
->withAddedHeader('Last-Modified', $last_modified);
} | php | private function attachPublicCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$cache_expire = session_cache_expire();
$max_age = $cache_expire * 60;
$expires = gmdate(self::DATE_FORMAT, $time + $max_age);
$cache_control = "public, max-age={$max_age}";
$last_modified = gmdate(self::DATE_FORMAT, $time);
return $response
->withAddedHeader('Expires', $expires)
->withAddedHeader('Cache-Control', $cache_control)
->withAddedHeader('Last-Modified', $last_modified);
} | [
"private",
"function",
"attachPublicCacheLimiterHeader",
"(",
"ResponseInterface",
"$",
"response",
",",
"int",
"$",
"time",
")",
":",
"ResponseInterface",
"{",
"$",
"cache_expire",
"=",
"session_cache_expire",
"(",
")",
";",
"$",
"max_age",
"=",
"$",
"cache_expire",
"*",
"60",
";",
"$",
"expires",
"=",
"gmdate",
"(",
"self",
"::",
"DATE_FORMAT",
",",
"$",
"time",
"+",
"$",
"max_age",
")",
";",
"$",
"cache_control",
"=",
"\"public, max-age={$max_age}\"",
";",
"$",
"last_modified",
"=",
"gmdate",
"(",
"self",
"::",
"DATE_FORMAT",
",",
"$",
"time",
")",
";",
"return",
"$",
"response",
"->",
"withAddedHeader",
"(",
"'Expires'",
",",
"$",
"expires",
")",
"->",
"withAddedHeader",
"(",
"'Cache-Control'",
",",
"$",
"cache_control",
")",
"->",
"withAddedHeader",
"(",
"'Last-Modified'",
",",
"$",
"last_modified",
")",
";",
"}"
] | Attach a public cache limiter header to the given response.
@param \Psr\Http\Message\ResponseInterface $response
@param int $time
@return \Psr\Http\Message\ResponseInterface
@see https://github.com/php/php-src/blob/PHP-7.0/ext/session/session.c#L1267-L1284 | [
"Attach",
"a",
"public",
"cache",
"limiter",
"header",
"to",
"the",
"given",
"response",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L358-L371 |
7,015 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.attachPrivateCacheLimiterHeader | private function attachPrivateCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$response = $response->withAddedHeader('Expires', self::EXPIRED);
return $this->attachPrivateNoExpireCacheLimiterHeader($response, $time);
} | php | private function attachPrivateCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$response = $response->withAddedHeader('Expires', self::EXPIRED);
return $this->attachPrivateNoExpireCacheLimiterHeader($response, $time);
} | [
"private",
"function",
"attachPrivateCacheLimiterHeader",
"(",
"ResponseInterface",
"$",
"response",
",",
"int",
"$",
"time",
")",
":",
"ResponseInterface",
"{",
"$",
"response",
"=",
"$",
"response",
"->",
"withAddedHeader",
"(",
"'Expires'",
",",
"self",
"::",
"EXPIRED",
")",
";",
"return",
"$",
"this",
"->",
"attachPrivateNoExpireCacheLimiterHeader",
"(",
"$",
"response",
",",
"$",
"time",
")",
";",
"}"
] | Attach a private cache limiter header to the given response.
@param \Psr\Http\Message\ResponseInterface $response
@param int $time
@return \Psr\Http\Message\ResponseInterface
@see https://github.com/php/php-src/blob/PHP-7.0/ext/session/session.c#L1297-L1302 | [
"Attach",
"a",
"private",
"cache",
"limiter",
"header",
"to",
"the",
"given",
"response",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L382-L387 |
7,016 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.attachPrivateNoExpireCacheLimiterHeader | private function attachPrivateNoExpireCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$cache_expire = session_cache_expire();
$max_age = $cache_expire * 60;
$cache_control = "private, max-age={$max_age}";
$last_modified = gmdate(self::DATE_FORMAT, $time);
return $response
->withAddedHeader('Cache-Control', $cache_control)
->withAddedHeader('Last-Modified', $last_modified);
} | php | private function attachPrivateNoExpireCacheLimiterHeader(ResponseInterface $response, int $time): ResponseInterface
{
$cache_expire = session_cache_expire();
$max_age = $cache_expire * 60;
$cache_control = "private, max-age={$max_age}";
$last_modified = gmdate(self::DATE_FORMAT, $time);
return $response
->withAddedHeader('Cache-Control', $cache_control)
->withAddedHeader('Last-Modified', $last_modified);
} | [
"private",
"function",
"attachPrivateNoExpireCacheLimiterHeader",
"(",
"ResponseInterface",
"$",
"response",
",",
"int",
"$",
"time",
")",
":",
"ResponseInterface",
"{",
"$",
"cache_expire",
"=",
"session_cache_expire",
"(",
")",
";",
"$",
"max_age",
"=",
"$",
"cache_expire",
"*",
"60",
";",
"$",
"cache_control",
"=",
"\"private, max-age={$max_age}\"",
";",
"$",
"last_modified",
"=",
"gmdate",
"(",
"self",
"::",
"DATE_FORMAT",
",",
"$",
"time",
")",
";",
"return",
"$",
"response",
"->",
"withAddedHeader",
"(",
"'Cache-Control'",
",",
"$",
"cache_control",
")",
"->",
"withAddedHeader",
"(",
"'Last-Modified'",
",",
"$",
"last_modified",
")",
";",
"}"
] | Attach a private_no_expire cache limiter header to the given response.
@param \Psr\Http\Message\ResponseInterface $response
@param int $time
@return \Psr\Http\Message\ResponseInterface
@see https://github.com/php/php-src/blob/PHP-7.0/ext/session/session.c#L1286-L1295 | [
"Attach",
"a",
"private_no_expire",
"cache",
"limiter",
"header",
"to",
"the",
"given",
"response",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L398-L409 |
7,017 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.attachNocacheCacheLimiterHeader | private function attachNocacheCacheLimiterHeader(ResponseInterface $response): ResponseInterface
{
return $response
->withAddedHeader('Expires', self::EXPIRED)
->withAddedHeader('Cache-Control', 'no-store, no-cache, must-revalidate')
->withAddedHeader('Pragma', 'no-cache');
} | php | private function attachNocacheCacheLimiterHeader(ResponseInterface $response): ResponseInterface
{
return $response
->withAddedHeader('Expires', self::EXPIRED)
->withAddedHeader('Cache-Control', 'no-store, no-cache, must-revalidate')
->withAddedHeader('Pragma', 'no-cache');
} | [
"private",
"function",
"attachNocacheCacheLimiterHeader",
"(",
"ResponseInterface",
"$",
"response",
")",
":",
"ResponseInterface",
"{",
"return",
"$",
"response",
"->",
"withAddedHeader",
"(",
"'Expires'",
",",
"self",
"::",
"EXPIRED",
")",
"->",
"withAddedHeader",
"(",
"'Cache-Control'",
",",
"'no-store, no-cache, must-revalidate'",
")",
"->",
"withAddedHeader",
"(",
"'Pragma'",
",",
"'no-cache'",
")",
";",
"}"
] | Attach a nocache cache limiter header to the given response.
@param \Psr\Http\Message\ResponseInterface $response
@return \Psr\Http\Message\ResponseInterface
@see https://github.com/php/php-src/blob/PHP-7.0/ext/session/session.c#L1304-L1314 | [
"Attach",
"a",
"nocache",
"cache",
"limiter",
"header",
"to",
"the",
"given",
"response",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L419-L425 |
7,018 | ellipsephp/session | src/Session/SessionMiddleware.php | SessionMiddleware.attachSessionCookie | private function attachSessionCookie(ResponseInterface $response, int $time): ResponseInterface
{
// Get the session id, name and the cookie options.
$id = session_id();
$name = session_name();
$options = session_get_cookie_params();
// Create a cookie header.
$header = urlencode($name) . '=' . urlencode($id);
if ($options['lifetime'] > 0) {
$expires = gmdate(self::DATE_FORMAT, $time + $options['lifetime']);
$header .= "; expires={$expires}; max-age={$options['lifetime']}";
}
if ($options['path']) $header .= "; path={$options['path']}";
if ($options['domain']) $header .= "; domain={$options['domain']}";
if ($options['secure']) $header .= '; secure';
if ($options['httponly']) $header .= '; httponly';
// Return a new response with the cookie header.
return $response->withAddedHeader('set-cookie', $header);
} | php | private function attachSessionCookie(ResponseInterface $response, int $time): ResponseInterface
{
// Get the session id, name and the cookie options.
$id = session_id();
$name = session_name();
$options = session_get_cookie_params();
// Create a cookie header.
$header = urlencode($name) . '=' . urlencode($id);
if ($options['lifetime'] > 0) {
$expires = gmdate(self::DATE_FORMAT, $time + $options['lifetime']);
$header .= "; expires={$expires}; max-age={$options['lifetime']}";
}
if ($options['path']) $header .= "; path={$options['path']}";
if ($options['domain']) $header .= "; domain={$options['domain']}";
if ($options['secure']) $header .= '; secure';
if ($options['httponly']) $header .= '; httponly';
// Return a new response with the cookie header.
return $response->withAddedHeader('set-cookie', $header);
} | [
"private",
"function",
"attachSessionCookie",
"(",
"ResponseInterface",
"$",
"response",
",",
"int",
"$",
"time",
")",
":",
"ResponseInterface",
"{",
"// Get the session id, name and the cookie options.",
"$",
"id",
"=",
"session_id",
"(",
")",
";",
"$",
"name",
"=",
"session_name",
"(",
")",
";",
"$",
"options",
"=",
"session_get_cookie_params",
"(",
")",
";",
"// Create a cookie header.",
"$",
"header",
"=",
"urlencode",
"(",
"$",
"name",
")",
".",
"'='",
".",
"urlencode",
"(",
"$",
"id",
")",
";",
"if",
"(",
"$",
"options",
"[",
"'lifetime'",
"]",
">",
"0",
")",
"{",
"$",
"expires",
"=",
"gmdate",
"(",
"self",
"::",
"DATE_FORMAT",
",",
"$",
"time",
"+",
"$",
"options",
"[",
"'lifetime'",
"]",
")",
";",
"$",
"header",
".=",
"\"; expires={$expires}; max-age={$options['lifetime']}\"",
";",
"}",
"if",
"(",
"$",
"options",
"[",
"'path'",
"]",
")",
"$",
"header",
".=",
"\"; path={$options['path']}\"",
";",
"if",
"(",
"$",
"options",
"[",
"'domain'",
"]",
")",
"$",
"header",
".=",
"\"; domain={$options['domain']}\"",
";",
"if",
"(",
"$",
"options",
"[",
"'secure'",
"]",
")",
"$",
"header",
".=",
"'; secure'",
";",
"if",
"(",
"$",
"options",
"[",
"'httponly'",
"]",
")",
"$",
"header",
".=",
"'; httponly'",
";",
"// Return a new response with the cookie header.",
"return",
"$",
"response",
"->",
"withAddedHeader",
"(",
"'set-cookie'",
",",
"$",
"header",
")",
";",
"}"
] | Attach a session cookie to the given response.
@param \Psr\Http\Message\ResponseInterface $response
@param int $time
@return \Psr\Http\Message\ResponseInterface
@see https://github.com/php/php-src/blob/PHP-7.0/ext/session/session.c#L1402-L1476 | [
"Attach",
"a",
"session",
"cookie",
"to",
"the",
"given",
"response",
"."
] | 53256a3b4f6e96edde2de6f32b561b20021368f7 | https://github.com/ellipsephp/session/blob/53256a3b4f6e96edde2de6f32b561b20021368f7/src/Session/SessionMiddleware.php#L436-L461 |
7,019 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNull | public static function assertIsNull($variable, Throwable $exception): bool
{
static::makeAssertion(null === $variable, $exception);
return true;
} | php | public static function assertIsNull($variable, Throwable $exception): bool
{
static::makeAssertion(null === $variable, $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNull",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"null",
"===",
"$",
"variable",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is NULL.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"NULL",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L26-L30 |
7,020 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsResource | public static function assertIsResource($variable, Throwable $exception): bool
{
static::makeAssertion(\is_resource($variable), $exception);
return true;
} | php | public static function assertIsResource($variable, Throwable $exception): bool
{
static::makeAssertion(\is_resource($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsResource",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_resource",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is a resource.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"a",
"resource",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L39-L43 |
7,021 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNumeric | public static function assertIsNumeric($variable, Throwable $exception): bool
{
static::makeAssertion(\is_numeric($variable), $exception);
return true;
} | php | public static function assertIsNumeric($variable, Throwable $exception): bool
{
static::makeAssertion(\is_numeric($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNumeric",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_numeric",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is numeric.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"numeric",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L52-L56 |
7,022 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsObject | public static function assertIsObject($variable, Throwable $exception): bool
{
static::makeAssertion(\is_object($variable), $exception);
return true;
} | php | public static function assertIsObject($variable, Throwable $exception): bool
{
static::makeAssertion(\is_object($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsObject",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_object",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is object.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"object",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L65-L69 |
7,023 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsCallable | public static function assertIsCallable($variable, Throwable $exception): bool
{
static::makeAssertion(\is_callable($variable), $exception);
return true;
} | php | public static function assertIsCallable($variable, Throwable $exception): bool
{
static::makeAssertion(\is_callable($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsCallable",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_callable",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is callable.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"callable",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L78-L82 |
7,024 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsFloat | public static function assertIsFloat($variable, Throwable $exception): bool
{
static::makeAssertion(\is_float($variable), $exception);
return true;
} | php | public static function assertIsFloat($variable, Throwable $exception): bool
{
static::makeAssertion(\is_float($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsFloat",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_float",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is float.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"float",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L91-L95 |
7,025 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsInt | public static function assertIsInt($variable, Throwable $exception): bool
{
static::makeAssertion(\is_int($variable), $exception);
return true;
} | php | public static function assertIsInt($variable, Throwable $exception): bool
{
static::makeAssertion(\is_int($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsInt",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_int",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is an int.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"an",
"int",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L104-L108 |
7,026 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNumber | public static function assertIsNumber($variable, Throwable $exception): bool
{
static::makeAssertion(\is_int($variable) || \is_float($variable), $exception);
return true;
} | php | public static function assertIsNumber($variable, Throwable $exception): bool
{
static::makeAssertion(\is_int($variable) || \is_float($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNumber",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_int",
"(",
"$",
"variable",
")",
"||",
"\\",
"is_float",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is either an integer or a float.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"either",
"an",
"integer",
"or",
"a",
"float",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L117-L121 |
7,027 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsString | public static function assertIsString($variable, Throwable $exception): bool
{
static::makeAssertion(\is_string($variable), $exception);
return true;
} | php | public static function assertIsString($variable, Throwable $exception): bool
{
static::makeAssertion(\is_string($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsString",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_string",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is a string.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"a",
"string",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L130-L134 |
7,028 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsBool | public static function assertIsBool($variable, Throwable $exception): bool
{
static::makeAssertion(\is_bool($variable), $exception);
return true;
} | php | public static function assertIsBool($variable, Throwable $exception): bool
{
static::makeAssertion(\is_bool($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsBool",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_bool",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is a bool.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"a",
"bool",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L143-L147 |
7,029 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsArray | public static function assertIsArray($variable, Throwable $exception): bool
{
static::makeAssertion(\is_array($variable), $exception);
return true;
} | php | public static function assertIsArray($variable, Throwable $exception): bool
{
static::makeAssertion(\is_array($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsArray",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_array",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is an array.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"an",
"array",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L156-L160 |
7,030 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsScalar | public static function assertIsScalar($variable, Throwable $exception): bool
{
static::makeAssertion(\is_scalar($variable), $exception);
return true;
} | php | public static function assertIsScalar($variable, Throwable $exception): bool
{
static::makeAssertion(\is_scalar($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsScalar",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"is_scalar",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is a scalar.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"a",
"scalar",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L169-L173 |
7,031 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotNull | public static function assertIsNotNull($variable, Throwable $exception): bool
{
static::makeAssertion(null !== $variable, $exception);
return true;
} | php | public static function assertIsNotNull($variable, Throwable $exception): bool
{
static::makeAssertion(null !== $variable, $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotNull",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"null",
"!==",
"$",
"variable",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not NULL.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"NULL",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L196-L200 |
7,032 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotResource | public static function assertIsNotResource($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_resource($variable), $exception);
return true;
} | php | public static function assertIsNotResource($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_resource($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotResource",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not a resource.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"a",
"resource",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L209-L213 |
7,033 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotNumeric | public static function assertIsNotNumeric($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_numeric($variable), $exception);
return true;
} | php | public static function assertIsNotNumeric($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_numeric($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotNumeric",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_numeric",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not numeric.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"numeric",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L222-L226 |
7,034 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotObject | public static function assertIsNotObject($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_object($variable), $exception);
return true;
} | php | public static function assertIsNotObject($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_object($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotObject",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_object",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not object.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"object",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L235-L239 |
7,035 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotCallable | public static function assertIsNotCallable($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_callable($variable), $exception);
return true;
} | php | public static function assertIsNotCallable($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_callable($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotCallable",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_callable",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not callable.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"callable",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L248-L252 |
7,036 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotFloat | public static function assertIsNotFloat($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_float($variable), $exception);
return true;
} | php | public static function assertIsNotFloat($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_float($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotFloat",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_float",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not float.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"float",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L261-L265 |
7,037 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotInt | public static function assertIsNotInt($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_int($variable), $exception);
return true;
} | php | public static function assertIsNotInt($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_int($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotInt",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_int",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not an int.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"an",
"int",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L274-L278 |
7,038 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotString | public static function assertIsNotString($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_string($variable), $exception);
return true;
} | php | public static function assertIsNotString($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_string($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotString",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_string",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not a string.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"a",
"string",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L300-L304 |
7,039 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotBool | public static function assertIsNotBool($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_bool($variable), $exception);
return true;
} | php | public static function assertIsNotBool($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_bool($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotBool",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_bool",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not a bool.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"a",
"bool",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L313-L317 |
7,040 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotArray | public static function assertIsNotArray($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_array($variable), $exception);
return true;
} | php | public static function assertIsNotArray($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_array($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotArray",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not an array.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"an",
"array",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L326-L330 |
7,041 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotScalar | public static function assertIsNotScalar($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_scalar($variable), $exception);
return true;
} | php | public static function assertIsNotScalar($variable, Throwable $exception): bool
{
static::makeAssertion(!\is_scalar($variable), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotScalar",
"(",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"is_scalar",
"(",
"$",
"variable",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not a scalar.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"a",
"scalar",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L339-L343 |
7,042 | niconoe-/asserts | src/Asserts/Categories/AssertTypeTrait.php | AssertTypeTrait.assertIsNotTypeOf | public static function assertIsNotTypeOf(array $types, $variable, Throwable $exception): bool
{
static::makeAssertion(!\in_array(\gettype($variable), $types, true), $exception);
return true;
} | php | public static function assertIsNotTypeOf(array $types, $variable, Throwable $exception): bool
{
static::makeAssertion(!\in_array(\gettype($variable), $types, true), $exception);
return true;
} | [
"public",
"static",
"function",
"assertIsNotTypeOf",
"(",
"array",
"$",
"types",
",",
"$",
"variable",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"!",
"\\",
"in_array",
"(",
"\\",
"gettype",
"(",
"$",
"variable",
")",
",",
"$",
"types",
",",
"true",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the variable is not one of the given types.
@param array $types The given types.
@param mixed $variable The given variable to test.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"variable",
"is",
"not",
"one",
"of",
"the",
"given",
"types",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertTypeTrait.php#L353-L357 |
7,043 | slickframework/orm | features/bootstrap/Orm/OrmContext.php | OrmContext.iShouldSeeInDatabaseTableFieldEquals | public function iShouldSeeInDatabaseTableFieldEquals($table, $field, $pattern)
{
$found = Sql::createSql($this->getAdapter())
->select($table)
->where(["{$table}.{$field} = ?" => $pattern])
->count();
Assert::assertTrue($found > 0);
} | php | public function iShouldSeeInDatabaseTableFieldEquals($table, $field, $pattern)
{
$found = Sql::createSql($this->getAdapter())
->select($table)
->where(["{$table}.{$field} = ?" => $pattern])
->count();
Assert::assertTrue($found > 0);
} | [
"public",
"function",
"iShouldSeeInDatabaseTableFieldEquals",
"(",
"$",
"table",
",",
"$",
"field",
",",
"$",
"pattern",
")",
"{",
"$",
"found",
"=",
"Sql",
"::",
"createSql",
"(",
"$",
"this",
"->",
"getAdapter",
"(",
")",
")",
"->",
"select",
"(",
"$",
"table",
")",
"->",
"where",
"(",
"[",
"\"{$table}.{$field} = ?\"",
"=>",
"$",
"pattern",
"]",
")",
"->",
"count",
"(",
")",
";",
"Assert",
"::",
"assertTrue",
"(",
"$",
"found",
">",
"0",
")",
";",
"}"
] | Run query where field equals provided pattern
@Then /^I should see in database "([^"]*)" table a row where "([^"]*)" equals "([^"]*)"$/
@param string $table
@param string $field
@param string $pattern | [
"Run",
"query",
"where",
"field",
"equals",
"provided",
"pattern"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/features/bootstrap/Orm/OrmContext.php#L119-L126 |
7,044 | slickframework/orm | features/bootstrap/Orm/OrmContext.php | OrmContext.iGetEntityWithId | public function iGetEntityWithId($entityId)
{
$this->lastEntity = $this->entity;
$this->entity = $this->repository->get($entityId);
} | php | public function iGetEntityWithId($entityId)
{
$this->lastEntity = $this->entity;
$this->entity = $this->repository->get($entityId);
} | [
"public",
"function",
"iGetEntityWithId",
"(",
"$",
"entityId",
")",
"{",
"$",
"this",
"->",
"lastEntity",
"=",
"$",
"this",
"->",
"entity",
";",
"$",
"this",
"->",
"entity",
"=",
"$",
"this",
"->",
"repository",
"->",
"get",
"(",
"$",
"entityId",
")",
";",
"}"
] | Gets the entity with
@When /^I get entity with id "([^"]*)"$/
@param string $entityId | [
"Gets",
"the",
"entity",
"with"
] | c5c782f5e3a46cdc6c934eda4411cb9edc48f969 | https://github.com/slickframework/orm/blob/c5c782f5e3a46cdc6c934eda4411cb9edc48f969/features/bootstrap/Orm/OrmContext.php#L197-L201 |
7,045 | asbsoft/yii2-common_2_170212 | rbac/AuthHelper.php | AuthHelper.canUserRunAction | public static function canUserRunAction($actionUid, $user = null)
{
if (empty($user)) $user = Yii::$app->user;
$parts = explode('/', $actionUid);
if ($parts === false || count($parts) < 3) {
throw new Exception("Illegal action uniqueId format: '{$actionUid}'");
} else {
$actionId = array_pop($parts);
$controllerId = array_pop($parts);
$moduleUid = implode ('/', $parts);
$module = Yii::$app->getModule($moduleUid);
if (empty($module)) {
//throw new Exception("Can't get module '{$moduleUid}'");
return false;
} else {
$controller = $module->createControllerByID($controllerId);
if ($controller instanceof YiiBaseController) {
//static::$_modulesControllers[$moduleUid][$controllerId] = $controller::className();
$behaviors = $controller->behaviors();
if (empty($behaviors['access']['rules'])) {
$rules = [];
} else {
$rules = $behaviors['access']['rules'];
}
//static::$_accessRules[$moduleUid][$controllerId] = $rules;
} else {
throw new Exception("Illegal controller '{$controllerId}' in module '{$moduleUid}'");
}
}
if (empty($rules)) {
$result = true; // no rules - action allow
} else {
$ac = Yii::createObject(['class' => AccessControl::className(), 'user' => $user, 'rules' => $rules]);
$action = $controller->createAction($actionId);
$request = Yii::$app->getRequest();
$result = false; // if rule(s) exists - deny by default
foreach ($ac->rules as $rule) {
if ($rule->allows($action, $user, $request)) {
$result = true; // found allow rule
break;
}
}
}
return $result;
}
} | php | public static function canUserRunAction($actionUid, $user = null)
{
if (empty($user)) $user = Yii::$app->user;
$parts = explode('/', $actionUid);
if ($parts === false || count($parts) < 3) {
throw new Exception("Illegal action uniqueId format: '{$actionUid}'");
} else {
$actionId = array_pop($parts);
$controllerId = array_pop($parts);
$moduleUid = implode ('/', $parts);
$module = Yii::$app->getModule($moduleUid);
if (empty($module)) {
//throw new Exception("Can't get module '{$moduleUid}'");
return false;
} else {
$controller = $module->createControllerByID($controllerId);
if ($controller instanceof YiiBaseController) {
//static::$_modulesControllers[$moduleUid][$controllerId] = $controller::className();
$behaviors = $controller->behaviors();
if (empty($behaviors['access']['rules'])) {
$rules = [];
} else {
$rules = $behaviors['access']['rules'];
}
//static::$_accessRules[$moduleUid][$controllerId] = $rules;
} else {
throw new Exception("Illegal controller '{$controllerId}' in module '{$moduleUid}'");
}
}
if (empty($rules)) {
$result = true; // no rules - action allow
} else {
$ac = Yii::createObject(['class' => AccessControl::className(), 'user' => $user, 'rules' => $rules]);
$action = $controller->createAction($actionId);
$request = Yii::$app->getRequest();
$result = false; // if rule(s) exists - deny by default
foreach ($ac->rules as $rule) {
if ($rule->allows($action, $user, $request)) {
$result = true; // found allow rule
break;
}
}
}
return $result;
}
} | [
"public",
"static",
"function",
"canUserRunAction",
"(",
"$",
"actionUid",
",",
"$",
"user",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"user",
")",
")",
"$",
"user",
"=",
"Yii",
"::",
"$",
"app",
"->",
"user",
";",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"actionUid",
")",
";",
"if",
"(",
"$",
"parts",
"===",
"false",
"||",
"count",
"(",
"$",
"parts",
")",
"<",
"3",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Illegal action uniqueId format: '{$actionUid}'\"",
")",
";",
"}",
"else",
"{",
"$",
"actionId",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"controllerId",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"moduleUid",
"=",
"implode",
"(",
"'/'",
",",
"$",
"parts",
")",
";",
"$",
"module",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getModule",
"(",
"$",
"moduleUid",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"module",
")",
")",
"{",
"//throw new Exception(\"Can't get module '{$moduleUid}'\");",
"return",
"false",
";",
"}",
"else",
"{",
"$",
"controller",
"=",
"$",
"module",
"->",
"createControllerByID",
"(",
"$",
"controllerId",
")",
";",
"if",
"(",
"$",
"controller",
"instanceof",
"YiiBaseController",
")",
"{",
"//static::$_modulesControllers[$moduleUid][$controllerId] = $controller::className();",
"$",
"behaviors",
"=",
"$",
"controller",
"->",
"behaviors",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"behaviors",
"[",
"'access'",
"]",
"[",
"'rules'",
"]",
")",
")",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"$",
"rules",
"=",
"$",
"behaviors",
"[",
"'access'",
"]",
"[",
"'rules'",
"]",
";",
"}",
"//static::$_accessRules[$moduleUid][$controllerId] = $rules;",
"}",
"else",
"{",
"throw",
"new",
"Exception",
"(",
"\"Illegal controller '{$controllerId}' in module '{$moduleUid}'\"",
")",
";",
"}",
"}",
"if",
"(",
"empty",
"(",
"$",
"rules",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"// no rules - action allow",
"}",
"else",
"{",
"$",
"ac",
"=",
"Yii",
"::",
"createObject",
"(",
"[",
"'class'",
"=>",
"AccessControl",
"::",
"className",
"(",
")",
",",
"'user'",
"=>",
"$",
"user",
",",
"'rules'",
"=>",
"$",
"rules",
"]",
")",
";",
"$",
"action",
"=",
"$",
"controller",
"->",
"createAction",
"(",
"$",
"actionId",
")",
";",
"$",
"request",
"=",
"Yii",
"::",
"$",
"app",
"->",
"getRequest",
"(",
")",
";",
"$",
"result",
"=",
"false",
";",
"// if rule(s) exists - deny by default",
"foreach",
"(",
"$",
"ac",
"->",
"rules",
"as",
"$",
"rule",
")",
"{",
"if",
"(",
"$",
"rule",
"->",
"allows",
"(",
"$",
"action",
",",
"$",
"user",
",",
"$",
"request",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"// found allow rule",
"break",
";",
"}",
"}",
"}",
"return",
"$",
"result",
";",
"}",
"}"
] | Check if user can run action.
@param string $actionUid action uniqueId
@param yii\web\User $user application user
@return boolean | [
"Check",
"if",
"user",
"can",
"run",
"action",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/rbac/AuthHelper.php#L74-L123 |
7,046 | themichaelhall/bluemvc-forms | src/RadioButtonCollection.php | RadioButtonCollection.addRadioButton | public function addRadioButton(RadioButtonInterface $radioButton): void
{
$radioButton->setName($this->getName());
$radioButton->setSelected($radioButton->getValue() === $this->value);
$this->radioButtons[] = $radioButton;
} | php | public function addRadioButton(RadioButtonInterface $radioButton): void
{
$radioButton->setName($this->getName());
$radioButton->setSelected($radioButton->getValue() === $this->value);
$this->radioButtons[] = $radioButton;
} | [
"public",
"function",
"addRadioButton",
"(",
"RadioButtonInterface",
"$",
"radioButton",
")",
":",
"void",
"{",
"$",
"radioButton",
"->",
"setName",
"(",
"$",
"this",
"->",
"getName",
"(",
")",
")",
";",
"$",
"radioButton",
"->",
"setSelected",
"(",
"$",
"radioButton",
"->",
"getValue",
"(",
")",
"===",
"$",
"this",
"->",
"value",
")",
";",
"$",
"this",
"->",
"radioButtons",
"[",
"]",
"=",
"$",
"radioButton",
";",
"}"
] | Adds a radio button.
@since 1.0.0
@param RadioButtonInterface $radioButton The radio button. | [
"Adds",
"a",
"radio",
"button",
"."
] | 8f0e29aaf71eba70b50697384b22edaf72f2f45b | https://github.com/themichaelhall/bluemvc-forms/blob/8f0e29aaf71eba70b50697384b22edaf72f2f45b/src/RadioButtonCollection.php#L45-L51 |
7,047 | OpenResourceManager/client-php | src/Client/Client.php | Client.urlFromRoute | protected function urlFromRoute($path = '')
{
$url = $this->baseURL;
$url[] = $path;
if (!empty($this->page)) $url[] = '?page=' . $this->page;
return implode('', $url);
} | php | protected function urlFromRoute($path = '')
{
$url = $this->baseURL;
$url[] = $path;
if (!empty($this->page)) $url[] = '?page=' . $this->page;
return implode('', $url);
} | [
"protected",
"function",
"urlFromRoute",
"(",
"$",
"path",
"=",
"''",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"baseURL",
";",
"$",
"url",
"[",
"]",
"=",
"$",
"path",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"page",
")",
")",
"$",
"url",
"[",
"]",
"=",
"'?page='",
".",
"$",
"this",
"->",
"page",
";",
"return",
"implode",
"(",
"''",
",",
"$",
"url",
")",
";",
"}"
] | URL From Route
Forms an API url from a route path.
@param string $path
@return string | [
"URL",
"From",
"Route"
] | fa468e3425d32f97294fefed77a7f096f3f8cc86 | https://github.com/OpenResourceManager/client-php/blob/fa468e3425d32f97294fefed77a7f096f3f8cc86/src/Client/Client.php#L156-L162 |
7,048 | broeser/wellid | src/ValidatorHolderTrait.php | ValidatorHolderTrait.validateValue | public function validateValue($value) {
$validationResultSet = new ValidationResultSet();
foreach($this->validators as $validator) {
$validationResultSet->add($validator->validate($value));
}
return $validationResultSet;
} | php | public function validateValue($value) {
$validationResultSet = new ValidationResultSet();
foreach($this->validators as $validator) {
$validationResultSet->add($validator->validate($value));
}
return $validationResultSet;
} | [
"public",
"function",
"validateValue",
"(",
"$",
"value",
")",
"{",
"$",
"validationResultSet",
"=",
"new",
"ValidationResultSet",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"validators",
"as",
"$",
"validator",
")",
"{",
"$",
"validationResultSet",
"->",
"add",
"(",
"$",
"validator",
"->",
"validate",
"(",
"$",
"value",
")",
")",
";",
"}",
"return",
"$",
"validationResultSet",
";",
"}"
] | Validates a value against all given Validators
@param mixed $value
@return ValidationResultSet | [
"Validates",
"a",
"value",
"against",
"all",
"given",
"Validators"
] | 0de2e6119382530221f4f7285158f19d45c78704 | https://github.com/broeser/wellid/blob/0de2e6119382530221f4f7285158f19d45c78704/src/ValidatorHolderTrait.php#L46-L52 |
7,049 | broeser/wellid | src/ValidatorHolderTrait.php | ValidatorHolderTrait.addValidator | public function addValidator(Validator\ValidatorInterface $validator) {
$this->validators[get_class($validator)] = $validator;
return $this;
} | php | public function addValidator(Validator\ValidatorInterface $validator) {
$this->validators[get_class($validator)] = $validator;
return $this;
} | [
"public",
"function",
"addValidator",
"(",
"Validator",
"\\",
"ValidatorInterface",
"$",
"validator",
")",
"{",
"$",
"this",
"->",
"validators",
"[",
"get_class",
"(",
"$",
"validator",
")",
"]",
"=",
"$",
"validator",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a Validator to this
@param ValidatorInterface $validator
@return ValidatorHolderInterface Returns itself for daisy-chaining | [
"Adds",
"a",
"Validator",
"to",
"this"
] | 0de2e6119382530221f4f7285158f19d45c78704 | https://github.com/broeser/wellid/blob/0de2e6119382530221f4f7285158f19d45c78704/src/ValidatorHolderTrait.php#L60-L64 |
7,050 | broeser/wellid | src/ValidatorHolderTrait.php | ValidatorHolderTrait.addValidators | public function addValidators(Validator\ValidatorInterface ...$validators) {
foreach($validators as $validator) {
$this->addValidator($validator);
}
return $this;
} | php | public function addValidators(Validator\ValidatorInterface ...$validators) {
foreach($validators as $validator) {
$this->addValidator($validator);
}
return $this;
} | [
"public",
"function",
"addValidators",
"(",
"Validator",
"\\",
"ValidatorInterface",
"...",
"$",
"validators",
")",
"{",
"foreach",
"(",
"$",
"validators",
"as",
"$",
"validator",
")",
"{",
"$",
"this",
"->",
"addValidator",
"(",
"$",
"validator",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Assigns several Validators that shall be used to validate this
@param Validator\ValidatorInterface ...$validators
@return ValidatorHolderInterface Returns itself for daisy-chaining | [
"Assigns",
"several",
"Validators",
"that",
"shall",
"be",
"used",
"to",
"validate",
"this"
] | 0de2e6119382530221f4f7285158f19d45c78704 | https://github.com/broeser/wellid/blob/0de2e6119382530221f4f7285158f19d45c78704/src/ValidatorHolderTrait.php#L72-L77 |
7,051 | oroinc/OroChainProcessorComponent | AbstractMatcher.php | AbstractMatcher.isMatch | protected function isMatch($value, $contextValue, $name)
{
if ($contextValue instanceof ToArrayInterface) {
return $this->isMatchAnyInArray($value, $contextValue->toArray(), $name);
}
return \is_array($contextValue)
? $this->isMatchAnyInArray($value, $contextValue, $name)
: $this->isMatchAnyWithScalar($value, $contextValue, $name);
} | php | protected function isMatch($value, $contextValue, $name)
{
if ($contextValue instanceof ToArrayInterface) {
return $this->isMatchAnyInArray($value, $contextValue->toArray(), $name);
}
return \is_array($contextValue)
? $this->isMatchAnyInArray($value, $contextValue, $name)
: $this->isMatchAnyWithScalar($value, $contextValue, $name);
} | [
"protected",
"function",
"isMatch",
"(",
"$",
"value",
",",
"$",
"contextValue",
",",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"contextValue",
"instanceof",
"ToArrayInterface",
")",
"{",
"return",
"$",
"this",
"->",
"isMatchAnyInArray",
"(",
"$",
"value",
",",
"$",
"contextValue",
"->",
"toArray",
"(",
")",
",",
"$",
"name",
")",
";",
"}",
"return",
"\\",
"is_array",
"(",
"$",
"contextValue",
")",
"?",
"$",
"this",
"->",
"isMatchAnyInArray",
"(",
"$",
"value",
",",
"$",
"contextValue",
",",
"$",
"name",
")",
":",
"$",
"this",
"->",
"isMatchAnyWithScalar",
"(",
"$",
"value",
",",
"$",
"contextValue",
",",
"$",
"name",
")",
";",
"}"
] | Checks if a value of a processor attribute matches a corresponding value
from the execution context.
@param mixed $value Array or Scalar
@param mixed $contextValue Array or Scalar
@param string $name The name of an attribute
@return bool | [
"Checks",
"if",
"a",
"value",
"of",
"a",
"processor",
"attribute",
"matches",
"a",
"corresponding",
"value",
"from",
"the",
"execution",
"context",
"."
] | 89c9bc60140292c9367a0c3178f760ecbcec6bd2 | https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/AbstractMatcher.php#L25-L34 |
7,052 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.get | public function get(Module $module)
{
$moduleName = $module->getName();
if (Lang::has("$moduleName::module.title")) {
$module->localname = Lang::get("$moduleName::module.title");
} else {
$module->localname = $module->getStudlyName();
}
if (Lang::has("$moduleName::module.description")) {
$module->description = Lang::get("$moduleName::module.description");
}
$package = $this->packageVersion->getPackageInfo("societycms/module-$moduleName");
if (isset($package->name) && strpos($package->name, '/')) {
$module->vendor = explode('/', $package->name)[0];
}
$module->version = isset($package->version) ? $package->version : 'N/A';
$module->versionUrl = '#';
$module->isCore = $this->isCoreModule($module);
if (isset($package->source->url)) {
$packageUrl = str_replace('.git', '', $package->source->url);
$module->versionUrl = $packageUrl.'/tree/'.$package->dist->reference;
}
$module->license = $package->license;
return $module;
} | php | public function get(Module $module)
{
$moduleName = $module->getName();
if (Lang::has("$moduleName::module.title")) {
$module->localname = Lang::get("$moduleName::module.title");
} else {
$module->localname = $module->getStudlyName();
}
if (Lang::has("$moduleName::module.description")) {
$module->description = Lang::get("$moduleName::module.description");
}
$package = $this->packageVersion->getPackageInfo("societycms/module-$moduleName");
if (isset($package->name) && strpos($package->name, '/')) {
$module->vendor = explode('/', $package->name)[0];
}
$module->version = isset($package->version) ? $package->version : 'N/A';
$module->versionUrl = '#';
$module->isCore = $this->isCoreModule($module);
if (isset($package->source->url)) {
$packageUrl = str_replace('.git', '', $package->source->url);
$module->versionUrl = $packageUrl.'/tree/'.$package->dist->reference;
}
$module->license = $package->license;
return $module;
} | [
"public",
"function",
"get",
"(",
"Module",
"$",
"module",
")",
"{",
"$",
"moduleName",
"=",
"$",
"module",
"->",
"getName",
"(",
")",
";",
"if",
"(",
"Lang",
"::",
"has",
"(",
"\"$moduleName::module.title\"",
")",
")",
"{",
"$",
"module",
"->",
"localname",
"=",
"Lang",
"::",
"get",
"(",
"\"$moduleName::module.title\"",
")",
";",
"}",
"else",
"{",
"$",
"module",
"->",
"localname",
"=",
"$",
"module",
"->",
"getStudlyName",
"(",
")",
";",
"}",
"if",
"(",
"Lang",
"::",
"has",
"(",
"\"$moduleName::module.description\"",
")",
")",
"{",
"$",
"module",
"->",
"description",
"=",
"Lang",
"::",
"get",
"(",
"\"$moduleName::module.description\"",
")",
";",
"}",
"$",
"package",
"=",
"$",
"this",
"->",
"packageVersion",
"->",
"getPackageInfo",
"(",
"\"societycms/module-$moduleName\"",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"package",
"->",
"name",
")",
"&&",
"strpos",
"(",
"$",
"package",
"->",
"name",
",",
"'/'",
")",
")",
"{",
"$",
"module",
"->",
"vendor",
"=",
"explode",
"(",
"'/'",
",",
"$",
"package",
"->",
"name",
")",
"[",
"0",
"]",
";",
"}",
"$",
"module",
"->",
"version",
"=",
"isset",
"(",
"$",
"package",
"->",
"version",
")",
"?",
"$",
"package",
"->",
"version",
":",
"'N/A'",
";",
"$",
"module",
"->",
"versionUrl",
"=",
"'#'",
";",
"$",
"module",
"->",
"isCore",
"=",
"$",
"this",
"->",
"isCoreModule",
"(",
"$",
"module",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"package",
"->",
"source",
"->",
"url",
")",
")",
"{",
"$",
"packageUrl",
"=",
"str_replace",
"(",
"'.git'",
",",
"''",
",",
"$",
"package",
"->",
"source",
"->",
"url",
")",
";",
"$",
"module",
"->",
"versionUrl",
"=",
"$",
"packageUrl",
".",
"'/tree/'",
".",
"$",
"package",
"->",
"dist",
"->",
"reference",
";",
"}",
"$",
"module",
"->",
"license",
"=",
"$",
"package",
"->",
"license",
";",
"return",
"$",
"module",
";",
"}"
] | Return a modules.
@return \Illuminate\Support\Collection | [
"Return",
"a",
"modules",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L48-L81 |
7,053 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.all | public function all()
{
$modules = new Collection($this->module->all());
foreach ($modules as $module) {
$module = $this->get($module);
}
return $modules;
} | php | public function all()
{
$modules = new Collection($this->module->all());
foreach ($modules as $module) {
$module = $this->get($module);
}
return $modules;
} | [
"public",
"function",
"all",
"(",
")",
"{",
"$",
"modules",
"=",
"new",
"Collection",
"(",
"$",
"this",
"->",
"module",
"->",
"all",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"get",
"(",
"$",
"module",
")",
";",
"}",
"return",
"$",
"modules",
";",
"}"
] | Return all modules.
@return \Illuminate\Support\Collection | [
"Return",
"all",
"modules",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L88-L97 |
7,054 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.getCoreModulesByName | public function getCoreModulesByName()
{
$coreModules = $this->config->get('society.core.core.CoreModules');
$coreModules = array_flip($coreModules);
return collect($coreModules);
} | php | public function getCoreModulesByName()
{
$coreModules = $this->config->get('society.core.core.CoreModules');
$coreModules = array_flip($coreModules);
return collect($coreModules);
} | [
"public",
"function",
"getCoreModulesByName",
"(",
")",
"{",
"$",
"coreModules",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'society.core.core.CoreModules'",
")",
";",
"$",
"coreModules",
"=",
"array_flip",
"(",
"$",
"coreModules",
")",
";",
"return",
"collect",
"(",
"$",
"coreModules",
")",
";",
"}"
] | Get the core modules as an array of names.
@return array|mixed | [
"Get",
"the",
"core",
"modules",
"as",
"an",
"array",
"of",
"names",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L114-L120 |
7,055 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.isCoreModule | public function isCoreModule(Module $module)
{
$coreModulesByName = $this->getCoreModulesByName();
return $coreModulesByName->has($module->getLowerName());
} | php | public function isCoreModule(Module $module)
{
$coreModulesByName = $this->getCoreModulesByName();
return $coreModulesByName->has($module->getLowerName());
} | [
"public",
"function",
"isCoreModule",
"(",
"Module",
"$",
"module",
")",
"{",
"$",
"coreModulesByName",
"=",
"$",
"this",
"->",
"getCoreModulesByName",
"(",
")",
";",
"return",
"$",
"coreModulesByName",
"->",
"has",
"(",
"$",
"module",
"->",
"getLowerName",
"(",
")",
")",
";",
"}"
] | Check if the given module is a core module that should be be disabled.
@param Module $module
@return bool | [
"Check",
"if",
"the",
"given",
"module",
"is",
"a",
"core",
"module",
"that",
"should",
"be",
"be",
"disabled",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L146-L151 |
7,056 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.getFlippedEnabledModules | public function getFlippedEnabledModules()
{
$enabledModules = $this->module->enabled();
$enabledModules = array_map(function (Module $module) {
return $module->getName();
}, $enabledModules);
return array_flip($enabledModules);
} | php | public function getFlippedEnabledModules()
{
$enabledModules = $this->module->enabled();
$enabledModules = array_map(function (Module $module) {
return $module->getName();
}, $enabledModules);
return array_flip($enabledModules);
} | [
"public",
"function",
"getFlippedEnabledModules",
"(",
")",
"{",
"$",
"enabledModules",
"=",
"$",
"this",
"->",
"module",
"->",
"enabled",
"(",
")",
";",
"$",
"enabledModules",
"=",
"array_map",
"(",
"function",
"(",
"Module",
"$",
"module",
")",
"{",
"return",
"$",
"module",
"->",
"getName",
"(",
")",
";",
"}",
",",
"$",
"enabledModules",
")",
";",
"return",
"array_flip",
"(",
"$",
"enabledModules",
")",
";",
"}"
] | Get the enabled modules, with the module name as the key.
@return array | [
"Get",
"the",
"enabled",
"modules",
"with",
"the",
"module",
"name",
"as",
"the",
"key",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L175-L184 |
7,057 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.disableModules | public function disableModules($enabledModules)
{
$coreModules = $this->getCoreModules();
foreach ($enabledModules as $moduleToDisable => $value) {
if (isset($coreModules[$moduleToDisable])) {
continue;
}
$module = $this->module->get($moduleToDisable);
$module->disable();
}
} | php | public function disableModules($enabledModules)
{
$coreModules = $this->getCoreModules();
foreach ($enabledModules as $moduleToDisable => $value) {
if (isset($coreModules[$moduleToDisable])) {
continue;
}
$module = $this->module->get($moduleToDisable);
$module->disable();
}
} | [
"public",
"function",
"disableModules",
"(",
"$",
"enabledModules",
")",
"{",
"$",
"coreModules",
"=",
"$",
"this",
"->",
"getCoreModules",
"(",
")",
";",
"foreach",
"(",
"$",
"enabledModules",
"as",
"$",
"moduleToDisable",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"coreModules",
"[",
"$",
"moduleToDisable",
"]",
")",
")",
"{",
"continue",
";",
"}",
"$",
"module",
"=",
"$",
"this",
"->",
"module",
"->",
"get",
"(",
"$",
"moduleToDisable",
")",
";",
"$",
"module",
"->",
"disable",
"(",
")",
";",
"}",
"}"
] | Disable the given modules.
@param $enabledModules | [
"Disable",
"the",
"given",
"modules",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L191-L202 |
7,058 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.enableModules | public function enableModules($modules)
{
foreach ($modules as $moduleToEnable => $value) {
$module = $this->module->get($moduleToEnable);
$module->enable();
}
} | php | public function enableModules($modules)
{
foreach ($modules as $moduleToEnable => $value) {
$module = $this->module->get($moduleToEnable);
$module->enable();
}
} | [
"public",
"function",
"enableModules",
"(",
"$",
"modules",
")",
"{",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"moduleToEnable",
"=>",
"$",
"value",
")",
"{",
"$",
"module",
"=",
"$",
"this",
"->",
"module",
"->",
"get",
"(",
"$",
"moduleToEnable",
")",
";",
"$",
"module",
"->",
"enable",
"(",
")",
";",
"}",
"}"
] | Enable the given modules.
@param $modules | [
"Enable",
"the",
"given",
"modules",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L209-L215 |
7,059 | SocietyCMS/Modules | Manager/ModuleManager.php | ModuleManager.changelogFor | public function changelogFor(Module $module)
{
$path = $module->getPath().'/CHANGELOG.md';
if (! $this->finder->isFile($path)) {
return [];
}
$parser = new \Changelog\Parser(file_get_contents($path));
return $parser->getReleases();
} | php | public function changelogFor(Module $module)
{
$path = $module->getPath().'/CHANGELOG.md';
if (! $this->finder->isFile($path)) {
return [];
}
$parser = new \Changelog\Parser(file_get_contents($path));
return $parser->getReleases();
} | [
"public",
"function",
"changelogFor",
"(",
"Module",
"$",
"module",
")",
"{",
"$",
"path",
"=",
"$",
"module",
"->",
"getPath",
"(",
")",
".",
"'/CHANGELOG.md'",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"finder",
"->",
"isFile",
"(",
"$",
"path",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"parser",
"=",
"new",
"\\",
"Changelog",
"\\",
"Parser",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
")",
";",
"return",
"$",
"parser",
"->",
"getReleases",
"(",
")",
";",
"}"
] | Get the changelog for the given module.
@param Module $module
@return array | [
"Get",
"the",
"changelog",
"for",
"the",
"given",
"module",
"."
] | bfb8d29fa47bd61787d16dbb1d14e144eb902ec1 | https://github.com/SocietyCMS/Modules/blob/bfb8d29fa47bd61787d16dbb1d14e144eb902ec1/Manager/ModuleManager.php#L224-L234 |
7,060 | dailex/dlx-security | lib/Authentication/HeaderTokenAuthenticator.php | HeaderTokenAuthenticator.start | public function start(Request $request, AuthenticationException $exception = null)
{
if ($exception) {
$message = $exception->getMessage();
if (empty($message) && is_callable([$exception, 'getMessageKey'])) {
$message = $e->getMessageKey();
}
} else {
$message = 'Full authentication is required to access this resource.';
}
$content = [
'errors' => [
'code' => 401,
'message' => $this->translator->trans($message, [], 'errors')
]
];
return new JsonResponse($content, JsonResponse::HTTP_UNAUTHORIZED);
} | php | public function start(Request $request, AuthenticationException $exception = null)
{
if ($exception) {
$message = $exception->getMessage();
if (empty($message) && is_callable([$exception, 'getMessageKey'])) {
$message = $e->getMessageKey();
}
} else {
$message = 'Full authentication is required to access this resource.';
}
$content = [
'errors' => [
'code' => 401,
'message' => $this->translator->trans($message, [], 'errors')
]
];
return new JsonResponse($content, JsonResponse::HTTP_UNAUTHORIZED);
} | [
"public",
"function",
"start",
"(",
"Request",
"$",
"request",
",",
"AuthenticationException",
"$",
"exception",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"exception",
")",
"{",
"$",
"message",
"=",
"$",
"exception",
"->",
"getMessage",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"message",
")",
"&&",
"is_callable",
"(",
"[",
"$",
"exception",
",",
"'getMessageKey'",
"]",
")",
")",
"{",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessageKey",
"(",
")",
";",
"}",
"}",
"else",
"{",
"$",
"message",
"=",
"'Full authentication is required to access this resource.'",
";",
"}",
"$",
"content",
"=",
"[",
"'errors'",
"=>",
"[",
"'code'",
"=>",
"401",
",",
"'message'",
"=>",
"$",
"this",
"->",
"translator",
"->",
"trans",
"(",
"$",
"message",
",",
"[",
"]",
",",
"'errors'",
")",
"]",
"]",
";",
"return",
"new",
"JsonResponse",
"(",
"$",
"content",
",",
"JsonResponse",
"::",
"HTTP_UNAUTHORIZED",
")",
";",
"}"
] | Called when authentication is needed, but it's not sent or is invalid | [
"Called",
"when",
"authentication",
"is",
"needed",
"but",
"it",
"s",
"not",
"sent",
"or",
"is",
"invalid"
] | 0cab2cab58aa7a992cf6649498688ece23343a60 | https://github.com/dailex/dlx-security/blob/0cab2cab58aa7a992cf6649498688ece23343a60/lib/Authentication/HeaderTokenAuthenticator.php#L81-L100 |
7,061 | getmoxy/event | src/Event/Emitter.php | Emitter.emit | public function emit($name, $eventData = array())
{
if(!is_array($eventData)) {
throw new \Exception('Moxy\Event data must be an array');
}
if(isset(self::$_events[$name])) {
self::$_events[$name]->dispatch($eventData);
}
} | php | public function emit($name, $eventData = array())
{
if(!is_array($eventData)) {
throw new \Exception('Moxy\Event data must be an array');
}
if(isset(self::$_events[$name])) {
self::$_events[$name]->dispatch($eventData);
}
} | [
"public",
"function",
"emit",
"(",
"$",
"name",
",",
"$",
"eventData",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"eventData",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Moxy\\Event data must be an array'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"_events",
"[",
"$",
"name",
"]",
")",
")",
"{",
"self",
"::",
"$",
"_events",
"[",
"$",
"name",
"]",
"->",
"dispatch",
"(",
"$",
"eventData",
")",
";",
"}",
"}"
] | Emit an Event
@author Tom Morton
@param string $name Name of the event
@param array $eventData Optional array of event data
@throws \Exception when $eventData is not an array | [
"Emit",
"an",
"Event"
] | d12b8f15916007151249aa03e3c09f7863a2d29c | https://github.com/getmoxy/event/blob/d12b8f15916007151249aa03e3c09f7863a2d29c/src/Event/Emitter.php#L25-L36 |
7,062 | getmoxy/event | src/Event/Emitter.php | Emitter.on | public function on($name, $callback)
{
if(!is_a($callback, '\Moxy\Event\ListenerInterface')) {
if(!is_callable($callback)) {
throw new \Exception('Event callback must be a callable');
}
// Co-erce the callback into an event listener
// This allows you to pass either a pure callable or
// your own listener class
$callback = new \Moxy\Event\Listener($callback);
}
// Set up the Event Dispatcher
if(!array_key_exists($name, self::$_events)) {
self::$_events[$name] = new \Moxy\Event\Dispatcher($name);
}
self::$_events[$name]->addListener($callback);
} | php | public function on($name, $callback)
{
if(!is_a($callback, '\Moxy\Event\ListenerInterface')) {
if(!is_callable($callback)) {
throw new \Exception('Event callback must be a callable');
}
// Co-erce the callback into an event listener
// This allows you to pass either a pure callable or
// your own listener class
$callback = new \Moxy\Event\Listener($callback);
}
// Set up the Event Dispatcher
if(!array_key_exists($name, self::$_events)) {
self::$_events[$name] = new \Moxy\Event\Dispatcher($name);
}
self::$_events[$name]->addListener($callback);
} | [
"public",
"function",
"on",
"(",
"$",
"name",
",",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"is_a",
"(",
"$",
"callback",
",",
"'\\Moxy\\Event\\ListenerInterface'",
")",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callback",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Event callback must be a callable'",
")",
";",
"}",
"// Co-erce the callback into an event listener",
"// This allows you to pass either a pure callable or",
"// your own listener class",
"$",
"callback",
"=",
"new",
"\\",
"Moxy",
"\\",
"Event",
"\\",
"Listener",
"(",
"$",
"callback",
")",
";",
"}",
"// Set up the Event Dispatcher",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"_events",
")",
")",
"{",
"self",
"::",
"$",
"_events",
"[",
"$",
"name",
"]",
"=",
"new",
"\\",
"Moxy",
"\\",
"Event",
"\\",
"Dispatcher",
"(",
"$",
"name",
")",
";",
"}",
"self",
"::",
"$",
"_events",
"[",
"$",
"name",
"]",
"->",
"addListener",
"(",
"$",
"callback",
")",
";",
"}"
] | Listen for an Event
Binds callback to a named event. You can pass either
a pure PHP callable or a class that implements
\Moxy\Event\ListenerInterface
@author Tom Morton
@param string $name Name of the event
@param callabel $callback Callable to run on triggering of event
@throws \Exception When callback is not callable | [
"Listen",
"for",
"an",
"Event"
] | d12b8f15916007151249aa03e3c09f7863a2d29c | https://github.com/getmoxy/event/blob/d12b8f15916007151249aa03e3c09f7863a2d29c/src/Event/Emitter.php#L50-L70 |
7,063 | phlexible/phlexible | src/Phlexible/Bundle/MessageBundle/Entity/Repository/MessageRepository.php | MessageRepository.findByCriteria | public function findByCriteria(Criteria $criteria, $order = null, $limit = null, $offset = 0)
{
$qb = $this->createCriteriaQueryBuilder($criteria, 'm');
if ($order) {
foreach ($order as $field => $dir) {
$qb->orderBy("m.$field", $dir);
}
}
if ($limit) {
$qb->setMaxResults($limit);
}
if ($offset) {
$qb->setFirstResult($offset);
}
return $qb->getQuery()->getResult();
} | php | public function findByCriteria(Criteria $criteria, $order = null, $limit = null, $offset = 0)
{
$qb = $this->createCriteriaQueryBuilder($criteria, 'm');
if ($order) {
foreach ($order as $field => $dir) {
$qb->orderBy("m.$field", $dir);
}
}
if ($limit) {
$qb->setMaxResults($limit);
}
if ($offset) {
$qb->setFirstResult($offset);
}
return $qb->getQuery()->getResult();
} | [
"public",
"function",
"findByCriteria",
"(",
"Criteria",
"$",
"criteria",
",",
"$",
"order",
"=",
"null",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"$",
"qb",
"=",
"$",
"this",
"->",
"createCriteriaQueryBuilder",
"(",
"$",
"criteria",
",",
"'m'",
")",
";",
"if",
"(",
"$",
"order",
")",
"{",
"foreach",
"(",
"$",
"order",
"as",
"$",
"field",
"=>",
"$",
"dir",
")",
"{",
"$",
"qb",
"->",
"orderBy",
"(",
"\"m.$field\"",
",",
"$",
"dir",
")",
";",
"}",
"}",
"if",
"(",
"$",
"limit",
")",
"{",
"$",
"qb",
"->",
"setMaxResults",
"(",
"$",
"limit",
")",
";",
"}",
"if",
"(",
"$",
"offset",
")",
"{",
"$",
"qb",
"->",
"setFirstResult",
"(",
"$",
"offset",
")",
";",
"}",
"return",
"$",
"qb",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}"
] | Find messages by criteria.
@param Criteria $criteria
@param array $order
@param int $limit
@param int $offset
@return Filter | [
"Find",
"messages",
"by",
"criteria",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MessageBundle/Entity/Repository/MessageRepository.php#L39-L56 |
7,064 | phlexible/phlexible | src/Phlexible/Bundle/MessageBundle/Entity/Repository/MessageRepository.php | MessageRepository.applyCriteriaToQueryBuilder | private function applyCriteriaToQueryBuilder(Criteria $criteria, QueryBuilder $qb, $prefix)
{
if ($criteria->getMode() === Criteria::MODE_OR) {
$expr = $qb->expr()->orX();
} else {
$expr = $qb->expr()->andX();
}
foreach ($criteria as $criterium) {
if ($criterium instanceof Criteria) {
$expr->add(
$this->applyCriteriaToQueryBuilder($criterium, $qb, $prefix)
);
} else {
$this->applyCriteriumToQueryBuilder($criterium, $qb, $expr, $prefix);
}
}
return $expr;
} | php | private function applyCriteriaToQueryBuilder(Criteria $criteria, QueryBuilder $qb, $prefix)
{
if ($criteria->getMode() === Criteria::MODE_OR) {
$expr = $qb->expr()->orX();
} else {
$expr = $qb->expr()->andX();
}
foreach ($criteria as $criterium) {
if ($criterium instanceof Criteria) {
$expr->add(
$this->applyCriteriaToQueryBuilder($criterium, $qb, $prefix)
);
} else {
$this->applyCriteriumToQueryBuilder($criterium, $qb, $expr, $prefix);
}
}
return $expr;
} | [
"private",
"function",
"applyCriteriaToQueryBuilder",
"(",
"Criteria",
"$",
"criteria",
",",
"QueryBuilder",
"$",
"qb",
",",
"$",
"prefix",
")",
"{",
"if",
"(",
"$",
"criteria",
"->",
"getMode",
"(",
")",
"===",
"Criteria",
"::",
"MODE_OR",
")",
"{",
"$",
"expr",
"=",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"orX",
"(",
")",
";",
"}",
"else",
"{",
"$",
"expr",
"=",
"$",
"qb",
"->",
"expr",
"(",
")",
"->",
"andX",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"criteria",
"as",
"$",
"criterium",
")",
"{",
"if",
"(",
"$",
"criterium",
"instanceof",
"Criteria",
")",
"{",
"$",
"expr",
"->",
"add",
"(",
"$",
"this",
"->",
"applyCriteriaToQueryBuilder",
"(",
"$",
"criterium",
",",
"$",
"qb",
",",
"$",
"prefix",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"applyCriteriumToQueryBuilder",
"(",
"$",
"criterium",
",",
"$",
"qb",
",",
"$",
"expr",
",",
"$",
"prefix",
")",
";",
"}",
"}",
"return",
"$",
"expr",
";",
"}"
] | Apply criteria to select.
@param Criteria $criteria
@param QueryBuilder $qb
@param string $prefix
@return Composite | [
"Apply",
"criteria",
"to",
"select",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MessageBundle/Entity/Repository/MessageRepository.php#L172-L190 |
7,065 | ciims/cii | utilities/CiiFileDeleter.php | CiiFileDeleter.removeDirectory | public static function removeDirectory($dir = '')
{
if ($dir == '' || $dir == NULL || $dir == '/')
return false;
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file)
(is_dir("$dir/$file")) ? CiiFileDeleter::removeDirectory("$dir/$file") : unlink("$dir/$file");
return rmdir($dir);
} | php | public static function removeDirectory($dir = '')
{
if ($dir == '' || $dir == NULL || $dir == '/')
return false;
$files = array_diff(scandir($dir), array('.','..'));
foreach ($files as $file)
(is_dir("$dir/$file")) ? CiiFileDeleter::removeDirectory("$dir/$file") : unlink("$dir/$file");
return rmdir($dir);
} | [
"public",
"static",
"function",
"removeDirectory",
"(",
"$",
"dir",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"dir",
"==",
"''",
"||",
"$",
"dir",
"==",
"NULL",
"||",
"$",
"dir",
"==",
"'/'",
")",
"return",
"false",
";",
"$",
"files",
"=",
"array_diff",
"(",
"scandir",
"(",
"$",
"dir",
")",
",",
"array",
"(",
"'.'",
",",
"'..'",
")",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"(",
"is_dir",
"(",
"\"$dir/$file\"",
")",
")",
"?",
"CiiFileDeleter",
"::",
"removeDirectory",
"(",
"\"$dir/$file\"",
")",
":",
"unlink",
"(",
"\"$dir/$file\"",
")",
";",
"return",
"rmdir",
"(",
"$",
"dir",
")",
";",
"}"
] | Terrifying function that recursively deletes a directory
@url http://php.net/manual/en/function.rmdir.php
@param string $dir The directory that we want to delete
@return boolean | [
"Terrifying",
"function",
"that",
"recursively",
"deletes",
"a",
"directory"
] | cc8550b9a3a6a0bf0214554679de8743d50dc9ef | https://github.com/ciims/cii/blob/cc8550b9a3a6a0bf0214554679de8743d50dc9ef/utilities/CiiFileDeleter.php#L12-L22 |
7,066 | octris/debug | libs/Debug.php | Debug.format | protected function format($str, $indent = true)
{
$spaces = str_repeat(' ', ((int)$indent) * $this->indent);
return $spaces . trim(
str_replace(
"\n",
"\n" . $spaces,
(php_sapi_name() != 'cli' ? htmlspecialchars($str) : $str)
)
) . "\n";
} | php | protected function format($str, $indent = true)
{
$spaces = str_repeat(' ', ((int)$indent) * $this->indent);
return $spaces . trim(
str_replace(
"\n",
"\n" . $spaces,
(php_sapi_name() != 'cli' ? htmlspecialchars($str) : $str)
)
) . "\n";
} | [
"protected",
"function",
"format",
"(",
"$",
"str",
",",
"$",
"indent",
"=",
"true",
")",
"{",
"$",
"spaces",
"=",
"str_repeat",
"(",
"' '",
",",
"(",
"(",
"int",
")",
"$",
"indent",
")",
"*",
"$",
"this",
"->",
"indent",
")",
";",
"return",
"$",
"spaces",
".",
"trim",
"(",
"str_replace",
"(",
"\"\\n\"",
",",
"\"\\n\"",
".",
"$",
"spaces",
",",
"(",
"php_sapi_name",
"(",
")",
"!=",
"'cli'",
"?",
"htmlspecialchars",
"(",
"$",
"str",
")",
":",
"$",
"str",
")",
")",
")",
".",
"\"\\n\"",
";",
"}"
] | Format output.
@param string $str String to output.
@param bool $indent Whether to indent output.
@return string Formatted output. | [
"Format",
"output",
"."
] | f23d41575c01855037e0346bb7833cf959ef831c | https://github.com/octris/debug/blob/f23d41575c01855037e0346bb7833cf959ef831c/libs/Debug.php#L96-L107 |
7,067 | octris/debug | libs/Debug.php | Debug.ddump | public function ddump($file, $line, ...$data)
{
static $last_key = '';
if (($is_html = $this->isHtml())) {
fputs($this->output, '<pre>');
}
$key = $file . ':' . $line;
if ($last_key != $key) {
fputs($this->output, $this->format(sprintf("\n** DEBUG: %s(%d)**\n", $file, $line), false));
$last_key = $key;
}
if (extension_loaded('xdebug')) {
for ($i = 0, $cnt = count($data); $i < $cnt; ++$i) {
var_dump($data[$i]);
}
} else {
for ($i = 0, $cnt = count($data); $i < $cnt; ++$i) {
ob_start(array($this, 'format'));
var_dump($data[$i]);
ob_end_flush();
}
}
if ($is_html) {
fputs($this->output, '</pre>');
}
} | php | public function ddump($file, $line, ...$data)
{
static $last_key = '';
if (($is_html = $this->isHtml())) {
fputs($this->output, '<pre>');
}
$key = $file . ':' . $line;
if ($last_key != $key) {
fputs($this->output, $this->format(sprintf("\n** DEBUG: %s(%d)**\n", $file, $line), false));
$last_key = $key;
}
if (extension_loaded('xdebug')) {
for ($i = 0, $cnt = count($data); $i < $cnt; ++$i) {
var_dump($data[$i]);
}
} else {
for ($i = 0, $cnt = count($data); $i < $cnt; ++$i) {
ob_start(array($this, 'format'));
var_dump($data[$i]);
ob_end_flush();
}
}
if ($is_html) {
fputs($this->output, '</pre>');
}
} | [
"public",
"function",
"ddump",
"(",
"$",
"file",
",",
"$",
"line",
",",
"...",
"$",
"data",
")",
"{",
"static",
"$",
"last_key",
"=",
"''",
";",
"if",
"(",
"(",
"$",
"is_html",
"=",
"$",
"this",
"->",
"isHtml",
"(",
")",
")",
")",
"{",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"'<pre>'",
")",
";",
"}",
"$",
"key",
"=",
"$",
"file",
".",
"':'",
".",
"$",
"line",
";",
"if",
"(",
"$",
"last_key",
"!=",
"$",
"key",
")",
"{",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"$",
"this",
"->",
"format",
"(",
"sprintf",
"(",
"\"\\n** DEBUG: %s(%d)**\\n\"",
",",
"$",
"file",
",",
"$",
"line",
")",
",",
"false",
")",
")",
";",
"$",
"last_key",
"=",
"$",
"key",
";",
"}",
"if",
"(",
"extension_loaded",
"(",
"'xdebug'",
")",
")",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"cnt",
"=",
"count",
"(",
"$",
"data",
")",
";",
"$",
"i",
"<",
"$",
"cnt",
";",
"++",
"$",
"i",
")",
"{",
"var_dump",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
")",
";",
"}",
"}",
"else",
"{",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"cnt",
"=",
"count",
"(",
"$",
"data",
")",
";",
"$",
"i",
"<",
"$",
"cnt",
";",
"++",
"$",
"i",
")",
"{",
"ob_start",
"(",
"array",
"(",
"$",
"this",
",",
"'format'",
")",
")",
";",
"var_dump",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
")",
";",
"ob_end_flush",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"is_html",
")",
"{",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"'</pre>'",
")",
";",
"}",
"}"
] | Dump contents of one or multiple variables. This method should not be called directly, use global
function 'ddump' instead.
@param string $file File the ddump command was called from.
@param int $line Line number of file the ddump command was called from.
@param ... $data Data to dump. | [
"Dump",
"contents",
"of",
"one",
"or",
"multiple",
"variables",
".",
"This",
"method",
"should",
"not",
"be",
"called",
"directly",
"use",
"global",
"function",
"ddump",
"instead",
"."
] | f23d41575c01855037e0346bb7833cf959ef831c | https://github.com/octris/debug/blob/f23d41575c01855037e0346bb7833cf959ef831c/libs/Debug.php#L117-L147 |
7,068 | octris/debug | libs/Debug.php | Debug.error | public function error($context, $context_line, array $info, $trace = null, \Exception $exception = null)
{
// start formatting
if (($is_html = $this->isHtml())) {
// Yes, this is an injection but it's OK here, because we want to try to force visible error output
// even when in a context the output would normally not visible in. {{
fputs($this->output, '--></script>">\'>');
// }}
fputs($this->output, '<pre>');
}
// general information
fputs($this->output, $this->format(sprintf("\n** ERROR: %s(%d)**\n", $context, $context_line), false));
$max = array_reduce(array_keys($info), function($carry, $key) {
return max($carry, strlen($key) + 3);
}, 0);
foreach ($info as $key => $value) {
fputs($this->output, $this->format(sprintf('%-' . $max . "s %s\n", $key . ': ', $value)));
}
// output stacktrace
if (is_null($trace)) {
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = ob_get_contents();
ob_end_clean();
}
fputs($this->output, "\n" . $this->format($trace) . "\n");
if (!is_null($exception)) {
// exception
throw $exception;
} elseif ($is_html) {
fputs($this->output, '</pre>');
}
} | php | public function error($context, $context_line, array $info, $trace = null, \Exception $exception = null)
{
// start formatting
if (($is_html = $this->isHtml())) {
// Yes, this is an injection but it's OK here, because we want to try to force visible error output
// even when in a context the output would normally not visible in. {{
fputs($this->output, '--></script>">\'>');
// }}
fputs($this->output, '<pre>');
}
// general information
fputs($this->output, $this->format(sprintf("\n** ERROR: %s(%d)**\n", $context, $context_line), false));
$max = array_reduce(array_keys($info), function($carry, $key) {
return max($carry, strlen($key) + 3);
}, 0);
foreach ($info as $key => $value) {
fputs($this->output, $this->format(sprintf('%-' . $max . "s %s\n", $key . ': ', $value)));
}
// output stacktrace
if (is_null($trace)) {
ob_start();
debug_print_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS);
$trace = ob_get_contents();
ob_end_clean();
}
fputs($this->output, "\n" . $this->format($trace) . "\n");
if (!is_null($exception)) {
// exception
throw $exception;
} elseif ($is_html) {
fputs($this->output, '</pre>');
}
} | [
"public",
"function",
"error",
"(",
"$",
"context",
",",
"$",
"context_line",
",",
"array",
"$",
"info",
",",
"$",
"trace",
"=",
"null",
",",
"\\",
"Exception",
"$",
"exception",
"=",
"null",
")",
"{",
"// start formatting",
"if",
"(",
"(",
"$",
"is_html",
"=",
"$",
"this",
"->",
"isHtml",
"(",
")",
")",
")",
"{",
"// Yes, this is an injection but it's OK here, because we want to try to force visible error output",
"// even when in a context the output would normally not visible in. {{",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"'--></script>\">\\'>'",
")",
";",
"// }}",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"'<pre>'",
")",
";",
"}",
"// general information",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"$",
"this",
"->",
"format",
"(",
"sprintf",
"(",
"\"\\n** ERROR: %s(%d)**\\n\"",
",",
"$",
"context",
",",
"$",
"context_line",
")",
",",
"false",
")",
")",
";",
"$",
"max",
"=",
"array_reduce",
"(",
"array_keys",
"(",
"$",
"info",
")",
",",
"function",
"(",
"$",
"carry",
",",
"$",
"key",
")",
"{",
"return",
"max",
"(",
"$",
"carry",
",",
"strlen",
"(",
"$",
"key",
")",
"+",
"3",
")",
";",
"}",
",",
"0",
")",
";",
"foreach",
"(",
"$",
"info",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"$",
"this",
"->",
"format",
"(",
"sprintf",
"(",
"'%-'",
".",
"$",
"max",
".",
"\"s %s\\n\"",
",",
"$",
"key",
".",
"': '",
",",
"$",
"value",
")",
")",
")",
";",
"}",
"// output stacktrace",
"if",
"(",
"is_null",
"(",
"$",
"trace",
")",
")",
"{",
"ob_start",
"(",
")",
";",
"debug_print_backtrace",
"(",
"DEBUG_BACKTRACE_IGNORE_ARGS",
")",
";",
"$",
"trace",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"}",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"\"\\n\"",
".",
"$",
"this",
"->",
"format",
"(",
"$",
"trace",
")",
".",
"\"\\n\"",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"exception",
")",
")",
"{",
"// exception",
"throw",
"$",
"exception",
";",
"}",
"elseif",
"(",
"$",
"is_html",
")",
"{",
"fputs",
"(",
"$",
"this",
"->",
"output",
",",
"'</pre>'",
")",
";",
"}",
"}"
] | Output error message with stack trace.
@param string $context Context the error occured in.
@param int $context_line Line of the context.
@param array $info Key/Value pairs of information to print.
@param string|null $trace Optional stack trace.
@param \Exception|null $exception Optional exception to throw after output. | [
"Output",
"error",
"message",
"with",
"stack",
"trace",
"."
] | f23d41575c01855037e0346bb7833cf959ef831c | https://github.com/octris/debug/blob/f23d41575c01855037e0346bb7833cf959ef831c/libs/Debug.php#L191-L230 |
7,069 | mattferris/application | src/Application.php | Application.doComponentPass | protected function doComponentPass(array $components)
{
foreach ($components as $component) {
$instance = $this->container->injectConstructor($component);
$this->components[$component] = $instance;
if ($instance instanceof ProviderInterface) {
$instance->provides($this);
}
}
foreach ($this->components as $instance) {
$instance->init($this->providers);
DomainEvents::dispatch(new InitializedComponentEvent($instance));
}
} | php | protected function doComponentPass(array $components)
{
foreach ($components as $component) {
$instance = $this->container->injectConstructor($component);
$this->components[$component] = $instance;
if ($instance instanceof ProviderInterface) {
$instance->provides($this);
}
}
foreach ($this->components as $instance) {
$instance->init($this->providers);
DomainEvents::dispatch(new InitializedComponentEvent($instance));
}
} | [
"protected",
"function",
"doComponentPass",
"(",
"array",
"$",
"components",
")",
"{",
"foreach",
"(",
"$",
"components",
"as",
"$",
"component",
")",
"{",
"$",
"instance",
"=",
"$",
"this",
"->",
"container",
"->",
"injectConstructor",
"(",
"$",
"component",
")",
";",
"$",
"this",
"->",
"components",
"[",
"$",
"component",
"]",
"=",
"$",
"instance",
";",
"if",
"(",
"$",
"instance",
"instanceof",
"ProviderInterface",
")",
"{",
"$",
"instance",
"->",
"provides",
"(",
"$",
"this",
")",
";",
"}",
"}",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"instance",
")",
"{",
"$",
"instance",
"->",
"init",
"(",
"$",
"this",
"->",
"providers",
")",
";",
"DomainEvents",
"::",
"dispatch",
"(",
"new",
"InitializedComponentEvent",
"(",
"$",
"instance",
")",
")",
";",
"}",
"}"
] | Initialize a group of components.
@param array $components A array of components | [
"Initialize",
"a",
"group",
"of",
"components",
"."
] | c63948c4ea0eca25fde1e8980a5e9e685619b1d4 | https://github.com/mattferris/application/blob/c63948c4ea0eca25fde1e8980a5e9e685619b1d4/src/Application.php#L68-L84 |
7,070 | mattferris/application | src/Application.php | Application.addProvider | public function addProvider($providerName, $consumer)
{
if (!class_exists($consumer) && !interface_exists($consumer)) {
throw new InvalidArgumentException(
'Consumer "'.$consumer.'" doesn\'t exist for provider "'.$providerName.'"'
);
}
if (isset($this->providers[$providerName])) {
throw new DuplicateProviderException($providerName);
}
$this->providers[$providerName] = ['consumer' => $consumer, 'scope' => 'global'];
DomainEvents::dispatch(new AddedProviderEvent($providerName, $consumer));
} | php | public function addProvider($providerName, $consumer)
{
if (!class_exists($consumer) && !interface_exists($consumer)) {
throw new InvalidArgumentException(
'Consumer "'.$consumer.'" doesn\'t exist for provider "'.$providerName.'"'
);
}
if (isset($this->providers[$providerName])) {
throw new DuplicateProviderException($providerName);
}
$this->providers[$providerName] = ['consumer' => $consumer, 'scope' => 'global'];
DomainEvents::dispatch(new AddedProviderEvent($providerName, $consumer));
} | [
"public",
"function",
"addProvider",
"(",
"$",
"providerName",
",",
"$",
"consumer",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"consumer",
")",
"&&",
"!",
"interface_exists",
"(",
"$",
"consumer",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Consumer \"'",
".",
"$",
"consumer",
".",
"'\" doesn\\'t exist for provider \"'",
".",
"$",
"providerName",
".",
"'\"'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"providers",
"[",
"$",
"providerName",
"]",
")",
")",
"{",
"throw",
"new",
"DuplicateProviderException",
"(",
"$",
"providerName",
")",
";",
"}",
"$",
"this",
"->",
"providers",
"[",
"$",
"providerName",
"]",
"=",
"[",
"'consumer'",
"=>",
"$",
"consumer",
",",
"'scope'",
"=>",
"'global'",
"]",
";",
"DomainEvents",
"::",
"dispatch",
"(",
"new",
"AddedProviderEvent",
"(",
"$",
"providerName",
",",
"$",
"consumer",
")",
")",
";",
"}"
] | Add global providers
@param string $providerName The provider name
@param string $consumer The consumer of the provider
@return self
@throws \InvalidArgumentException If $consumer class doesn't exist
@throws DuplicateProviderException If $providerName already exists | [
"Add",
"global",
"providers"
] | c63948c4ea0eca25fde1e8980a5e9e685619b1d4 | https://github.com/mattferris/application/blob/c63948c4ea0eca25fde1e8980a5e9e685619b1d4/src/Application.php#L95-L110 |
7,071 | 10quality/wpmvc-commands | src/Base/BaseCommand.php | BaseCommand.prettyJson | protected function prettyJson($json, $istr=' ')
{
$result = '';
for($p=$q=$i=0; isset($json[$p]); $p++)
{
$json[$p] == '"' && ($p>0?$json[$p-1]:'') != '\\' && $q=!$q;
if(!$q && strchr(" \t\n", $json[$p])){continue;}
if(strchr('}]', $json[$p]) && !$q && $i--)
{
strchr('{[', $json[$p-1]) || $result .= "\n".str_repeat($istr, $i);
}
$result .= $json[$p];
if(strchr(',{[', $json[$p]) && !$q)
{
$i += strchr('{[', $json[$p])===FALSE?0:1;
strchr('}]', $json[$p+1]) || $result .= "\n".str_repeat($istr, $i);
}
}
return $result;
} | php | protected function prettyJson($json, $istr=' ')
{
$result = '';
for($p=$q=$i=0; isset($json[$p]); $p++)
{
$json[$p] == '"' && ($p>0?$json[$p-1]:'') != '\\' && $q=!$q;
if(!$q && strchr(" \t\n", $json[$p])){continue;}
if(strchr('}]', $json[$p]) && !$q && $i--)
{
strchr('{[', $json[$p-1]) || $result .= "\n".str_repeat($istr, $i);
}
$result .= $json[$p];
if(strchr(',{[', $json[$p]) && !$q)
{
$i += strchr('{[', $json[$p])===FALSE?0:1;
strchr('}]', $json[$p+1]) || $result .= "\n".str_repeat($istr, $i);
}
}
return $result;
} | [
"protected",
"function",
"prettyJson",
"(",
"$",
"json",
",",
"$",
"istr",
"=",
"' '",
")",
"{",
"$",
"result",
"=",
"''",
";",
"for",
"(",
"$",
"p",
"=",
"$",
"q",
"=",
"$",
"i",
"=",
"0",
";",
"isset",
"(",
"$",
"json",
"[",
"$",
"p",
"]",
")",
";",
"$",
"p",
"++",
")",
"{",
"$",
"json",
"[",
"$",
"p",
"]",
"==",
"'\"'",
"&&",
"(",
"$",
"p",
">",
"0",
"?",
"$",
"json",
"[",
"$",
"p",
"-",
"1",
"]",
":",
"''",
")",
"!=",
"'\\\\'",
"&&",
"$",
"q",
"=",
"!",
"$",
"q",
";",
"if",
"(",
"!",
"$",
"q",
"&&",
"strchr",
"(",
"\" \\t\\n\"",
",",
"$",
"json",
"[",
"$",
"p",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"strchr",
"(",
"'}]'",
",",
"$",
"json",
"[",
"$",
"p",
"]",
")",
"&&",
"!",
"$",
"q",
"&&",
"$",
"i",
"--",
")",
"{",
"strchr",
"(",
"'{['",
",",
"$",
"json",
"[",
"$",
"p",
"-",
"1",
"]",
")",
"||",
"$",
"result",
".=",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"istr",
",",
"$",
"i",
")",
";",
"}",
"$",
"result",
".=",
"$",
"json",
"[",
"$",
"p",
"]",
";",
"if",
"(",
"strchr",
"(",
"',{['",
",",
"$",
"json",
"[",
"$",
"p",
"]",
")",
"&&",
"!",
"$",
"q",
")",
"{",
"$",
"i",
"+=",
"strchr",
"(",
"'{['",
",",
"$",
"json",
"[",
"$",
"p",
"]",
")",
"===",
"FALSE",
"?",
"0",
":",
"1",
";",
"strchr",
"(",
"'}]'",
",",
"$",
"json",
"[",
"$",
"p",
"+",
"1",
"]",
")",
"||",
"$",
"result",
".=",
"\"\\n\"",
".",
"str_repeat",
"(",
"$",
"istr",
",",
"$",
"i",
")",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | jsonpp - Pretty print JSON data
In versions of PHP < 5.4.x, the json_encode() function does not yet provide a
pretty-print option. In lieu of forgoing the feature, an additional call can
be made to this function, passing in JSON text, and (optionally) a string to
be used for indentation.
@param string $json The JSON data, pre-encoded
@param string $istr The indentation string
@link https://github.com/ryanuber/projects/blob/master/PHP/JSON/jsonpp.php
@return string | [
"jsonpp",
"-",
"Pretty",
"print",
"JSON",
"data"
] | 283016f921589c0161bda9064cd8a879bc82f9de | https://github.com/10quality/wpmvc-commands/blob/283016f921589c0161bda9064cd8a879bc82f9de/src/Base/BaseCommand.php#L124-L143 |
7,072 | sypherlev/blueprint | src/Blueprint.php | Blueprint.one | protected function one() {
$query = $this->loadElements();
$this->source->setQuery($query);
$result = $this->source->one();
$activeTransformations = $this->activeTransformations;
$this->reset();
if($result && !empty($activeTransformations)) {
foreach ($activeTransformations as $transform) {
if(isset($this->transforms[$transform])) {
$result = call_user_func($this->transforms[$transform], $result);
}
if(isset($this->arraytransforms[$transform])) {
$temp = call_user_func($this->arraytransforms[$transform], [$result]);
$result = $temp[0];
}
}
}
$this->reset();
return $result;
} | php | protected function one() {
$query = $this->loadElements();
$this->source->setQuery($query);
$result = $this->source->one();
$activeTransformations = $this->activeTransformations;
$this->reset();
if($result && !empty($activeTransformations)) {
foreach ($activeTransformations as $transform) {
if(isset($this->transforms[$transform])) {
$result = call_user_func($this->transforms[$transform], $result);
}
if(isset($this->arraytransforms[$transform])) {
$temp = call_user_func($this->arraytransforms[$transform], [$result]);
$result = $temp[0];
}
}
}
$this->reset();
return $result;
} | [
"protected",
"function",
"one",
"(",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"loadElements",
"(",
")",
";",
"$",
"this",
"->",
"source",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"source",
"->",
"one",
"(",
")",
";",
"$",
"activeTransformations",
"=",
"$",
"this",
"->",
"activeTransformations",
";",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"if",
"(",
"$",
"result",
"&&",
"!",
"empty",
"(",
"$",
"activeTransformations",
")",
")",
"{",
"foreach",
"(",
"$",
"activeTransformations",
"as",
"$",
"transform",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"transforms",
"[",
"$",
"transform",
"]",
")",
")",
"{",
"$",
"result",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"transforms",
"[",
"$",
"transform",
"]",
",",
"$",
"result",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"arraytransforms",
"[",
"$",
"transform",
"]",
")",
")",
"{",
"$",
"temp",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"arraytransforms",
"[",
"$",
"transform",
"]",
",",
"[",
"$",
"result",
"]",
")",
";",
"$",
"result",
"=",
"$",
"temp",
"[",
"0",
"]",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"reset",
"(",
")",
";",
"return",
"$",
"result",
";",
"}"
] | call one of these last | [
"call",
"one",
"of",
"these",
"last"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L159-L178 |
7,073 | sypherlev/blueprint | src/Blueprint.php | Blueprint.limit | protected function limit($rows, $offset = false) {
$this->query->setLimit($rows, $offset);
return $this;
} | php | protected function limit($rows, $offset = false) {
$this->query->setLimit($rows, $offset);
return $this;
} | [
"protected",
"function",
"limit",
"(",
"$",
"rows",
",",
"$",
"offset",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"setLimit",
"(",
"$",
"rows",
",",
"$",
"offset",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the LIMIT for the current query.
@param int $rows
@param int $offset
@return $this | [
"Sets",
"the",
"LIMIT",
"for",
"the",
"current",
"query",
"."
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L310-L313 |
7,074 | sypherlev/blueprint | src/Blueprint.php | Blueprint.orderBy | protected function orderBy($columnname_or_columnarray, $order = 'ASC', $useAliases = false) {
if (!is_array($columnname_or_columnarray)) {
$columnname_or_columnarray = [$columnname_or_columnarray];
}
$this->query->setOrderBy($columnname_or_columnarray, $order, $useAliases);
return $this;
} | php | protected function orderBy($columnname_or_columnarray, $order = 'ASC', $useAliases = false) {
if (!is_array($columnname_or_columnarray)) {
$columnname_or_columnarray = [$columnname_or_columnarray];
}
$this->query->setOrderBy($columnname_or_columnarray, $order, $useAliases);
return $this;
} | [
"protected",
"function",
"orderBy",
"(",
"$",
"columnname_or_columnarray",
",",
"$",
"order",
"=",
"'ASC'",
",",
"$",
"useAliases",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"columnname_or_columnarray",
")",
")",
"{",
"$",
"columnname_or_columnarray",
"=",
"[",
"$",
"columnname_or_columnarray",
"]",
";",
"}",
"$",
"this",
"->",
"query",
"->",
"setOrderBy",
"(",
"$",
"columnname_or_columnarray",
",",
"$",
"order",
",",
"$",
"useAliases",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the order for the query
@param $columnName_or_columnArray - has three possible types:
$column
array($columnone, $columntwo, ...)
array($tableone => array($columnone, $columntwo, ...), $tabletwo => array(...), ...)
@param $direction - must be one of 'ASC' or 'DESC'
@param $aliases - whether aliases are being used or not
@return $this | [
"Sets",
"the",
"order",
"for",
"the",
"query"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L326-L332 |
7,075 | sypherlev/blueprint | src/Blueprint.php | Blueprint.groupBy | protected function groupBy($columnname_or_columnarray) {
if (!is_array($columnname_or_columnarray)) {
$columnname_or_columnarray = [$columnname_or_columnarray];
}
$this->query->setGroupBy($columnname_or_columnarray);
return $this;
} | php | protected function groupBy($columnname_or_columnarray) {
if (!is_array($columnname_or_columnarray)) {
$columnname_or_columnarray = [$columnname_or_columnarray];
}
$this->query->setGroupBy($columnname_or_columnarray);
return $this;
} | [
"protected",
"function",
"groupBy",
"(",
"$",
"columnname_or_columnarray",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"columnname_or_columnarray",
")",
")",
"{",
"$",
"columnname_or_columnarray",
"=",
"[",
"$",
"columnname_or_columnarray",
"]",
";",
"}",
"$",
"this",
"->",
"query",
"->",
"setGroupBy",
"(",
"$",
"columnname_or_columnarray",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the groupby clause
@param $groupby - has three possible types:
string $columnname
array($columnone, $columntwo, ...)
array($tableone => array($columnone, $columntwo, ...), $tabletwo => array(...), ...)
@return $this | [
"Sets",
"the",
"groupby",
"clause"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L362-L368 |
7,076 | sypherlev/blueprint | src/Blueprint.php | Blueprint.join | protected function join($firsttable, $secondtable, Array $on, $type = 'inner') {
$this->query->setJoin($firsttable, $secondtable, $on, strtoupper($type));
return $this;
} | php | protected function join($firsttable, $secondtable, Array $on, $type = 'inner') {
$this->query->setJoin($firsttable, $secondtable, $on, strtoupper($type));
return $this;
} | [
"protected",
"function",
"join",
"(",
"$",
"firsttable",
",",
"$",
"secondtable",
",",
"Array",
"$",
"on",
",",
"$",
"type",
"=",
"'inner'",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"setJoin",
"(",
"$",
"firsttable",
",",
"$",
"secondtable",
",",
"$",
"on",
",",
"strtoupper",
"(",
"$",
"type",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Adds a JOIN clause
@param $firsttable - tablename
@param $secondtable - tablename
@param array $on - must be in the format array('firsttablecolumn' => 'secondtablecolumn, ...)
@param string $type - inner|full|left|right
@return $this | [
"Adds",
"a",
"JOIN",
"clause"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L379-L382 |
7,077 | sypherlev/blueprint | src/Blueprint.php | Blueprint.getCurrentSQL | protected function getCurrentSQL() {
$cloneQuery = clone $this->query;
$cloneQuery = $this->loadElements($cloneQuery);
return $cloneQuery->compile();
} | php | protected function getCurrentSQL() {
$cloneQuery = clone $this->query;
$cloneQuery = $this->loadElements($cloneQuery);
return $cloneQuery->compile();
} | [
"protected",
"function",
"getCurrentSQL",
"(",
")",
"{",
"$",
"cloneQuery",
"=",
"clone",
"$",
"this",
"->",
"query",
";",
"$",
"cloneQuery",
"=",
"$",
"this",
"->",
"loadElements",
"(",
"$",
"cloneQuery",
")",
";",
"return",
"$",
"cloneQuery",
"->",
"compile",
"(",
")",
";",
"}"
] | Attempts to compile the current query, including all Patterns and Filters
Excludes Transformations
@return string | [
"Attempts",
"to",
"compile",
"the",
"current",
"query",
"including",
"all",
"Patterns",
"and",
"Filters",
"Excludes",
"Transformations"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L413-L417 |
7,078 | sypherlev/blueprint | src/Blueprint.php | Blueprint.getCurrentBindings | protected function getCurrentBindings() {
$cloneQuery = clone $this->query;
$cloneQuery = $this->loadElements($cloneQuery);
if(!empty($this->set)) {
$cloneQuery->setUpdates($this->set);
}
if(!empty($this->insert_records)) {
foreach ($this->insert_records as $record) {
$cloneQuery->addInsertRecord($record);
}
}
return $cloneQuery->getBindings();
} | php | protected function getCurrentBindings() {
$cloneQuery = clone $this->query;
$cloneQuery = $this->loadElements($cloneQuery);
if(!empty($this->set)) {
$cloneQuery->setUpdates($this->set);
}
if(!empty($this->insert_records)) {
foreach ($this->insert_records as $record) {
$cloneQuery->addInsertRecord($record);
}
}
return $cloneQuery->getBindings();
} | [
"protected",
"function",
"getCurrentBindings",
"(",
")",
"{",
"$",
"cloneQuery",
"=",
"clone",
"$",
"this",
"->",
"query",
";",
"$",
"cloneQuery",
"=",
"$",
"this",
"->",
"loadElements",
"(",
"$",
"cloneQuery",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"set",
")",
")",
"{",
"$",
"cloneQuery",
"->",
"setUpdates",
"(",
"$",
"this",
"->",
"set",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"insert_records",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"insert_records",
"as",
"$",
"record",
")",
"{",
"$",
"cloneQuery",
"->",
"addInsertRecord",
"(",
"$",
"record",
")",
";",
"}",
"}",
"return",
"$",
"cloneQuery",
"->",
"getBindings",
"(",
")",
";",
"}"
] | Attempts to compile the current query and returns the resulting bindings
@return array | [
"Attempts",
"to",
"compile",
"the",
"current",
"query",
"and",
"returns",
"the",
"resulting",
"bindings"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L424-L436 |
7,079 | sypherlev/blueprint | src/Blueprint.php | Blueprint.whitelistTable | protected function whitelistTable($table) {
if(is_array($table)) {
foreach ($table as $t) {
$this->query->addToTableWhitelist($t);
}
}
else {
$this->query->addToTableWhitelist($table);
}
} | php | protected function whitelistTable($table) {
if(is_array($table)) {
foreach ($table as $t) {
$this->query->addToTableWhitelist($t);
}
}
else {
$this->query->addToTableWhitelist($table);
}
} | [
"protected",
"function",
"whitelistTable",
"(",
"$",
"table",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"table",
")",
")",
"{",
"foreach",
"(",
"$",
"table",
"as",
"$",
"t",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"addToTableWhitelist",
"(",
"$",
"t",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"->",
"addToTableWhitelist",
"(",
"$",
"table",
")",
";",
"}",
"}"
] | Add either a table or an array of tables to the current whitelist
@param string $table | array $table | [
"Add",
"either",
"a",
"table",
"or",
"an",
"array",
"of",
"tables",
"to",
"the",
"current",
"whitelist"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L474-L483 |
7,080 | sypherlev/blueprint | src/Blueprint.php | Blueprint.whitelistColumn | protected function whitelistColumn($column) {
if(is_array($column)) {
foreach ($column as $c) {
$this->query->addToColumnWhitelist($c);
}
}
else {
$this->query->addToColumnWhitelist($column);
}
} | php | protected function whitelistColumn($column) {
if(is_array($column)) {
foreach ($column as $c) {
$this->query->addToColumnWhitelist($c);
}
}
else {
$this->query->addToColumnWhitelist($column);
}
} | [
"protected",
"function",
"whitelistColumn",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"column",
")",
")",
"{",
"foreach",
"(",
"$",
"column",
"as",
"$",
"c",
")",
"{",
"$",
"this",
"->",
"query",
"->",
"addToColumnWhitelist",
"(",
"$",
"c",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"query",
"->",
"addToColumnWhitelist",
"(",
"$",
"column",
")",
";",
"}",
"}"
] | Add either a column or an array of columns to the current whitelist
@param string $column | array $column | [
"Add",
"either",
"a",
"column",
"or",
"an",
"array",
"of",
"columns",
"to",
"the",
"current",
"whitelist"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L490-L499 |
7,081 | sypherlev/blueprint | src/Blueprint.php | Blueprint.reset | protected function reset() {
$this->activePattern = false;
$this->activeFilters = [];
$this->activeTransformations = [];
$this->insert_records = [];
$this->set = [];
$queryclass = get_class($this->query);
$this->query = new $queryclass();
} | php | protected function reset() {
$this->activePattern = false;
$this->activeFilters = [];
$this->activeTransformations = [];
$this->insert_records = [];
$this->set = [];
$queryclass = get_class($this->query);
$this->query = new $queryclass();
} | [
"protected",
"function",
"reset",
"(",
")",
"{",
"$",
"this",
"->",
"activePattern",
"=",
"false",
";",
"$",
"this",
"->",
"activeFilters",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"activeTransformations",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"insert_records",
"=",
"[",
"]",
";",
"$",
"this",
"->",
"set",
"=",
"[",
"]",
";",
"$",
"queryclass",
"=",
"get_class",
"(",
"$",
"this",
"->",
"query",
")",
";",
"$",
"this",
"->",
"query",
"=",
"new",
"$",
"queryclass",
"(",
")",
";",
"}"
] | Reset the query and source; prep for another pass | [
"Reset",
"the",
"query",
"and",
"source",
";",
"prep",
"for",
"another",
"pass"
] | 11e36d5aae192f179cc7a2872013d4190d52f2e5 | https://github.com/sypherlev/blueprint/blob/11e36d5aae192f179cc7a2872013d4190d52f2e5/src/Blueprint.php#L505-L513 |
7,082 | ehough/generators | src/AbstractGenerator.php | AbstractGenerator.current | final public function current()
{
if (!$this->valid()) {
return null;
}
/*
* Multiple calls to current() should be idempotent
*/
if ($this->_lastPositionExecuted !== $this->_position) {
$this->runToNextYieldStatement();
}
return $this->valid() ? $this->getLastYieldedValue() : null;
} | php | final public function current()
{
if (!$this->valid()) {
return null;
}
/*
* Multiple calls to current() should be idempotent
*/
if ($this->_lastPositionExecuted !== $this->_position) {
$this->runToNextYieldStatement();
}
return $this->valid() ? $this->getLastYieldedValue() : null;
} | [
"final",
"public",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"/*\n * Multiple calls to current() should be idempotent\n */",
"if",
"(",
"$",
"this",
"->",
"_lastPositionExecuted",
"!==",
"$",
"this",
"->",
"_position",
")",
"{",
"$",
"this",
"->",
"runToNextYieldStatement",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"valid",
"(",
")",
"?",
"$",
"this",
"->",
"getLastYieldedValue",
"(",
")",
":",
"null",
";",
"}"
] | Get the yielded value.
@return mixed|null the yielded value | [
"Get",
"the",
"yielded",
"value",
"."
] | 4138bc0602b8f1ca7d467ba89ff8c4251284e1b1 | https://github.com/ehough/generators/blob/4138bc0602b8f1ca7d467ba89ff8c4251284e1b1/src/AbstractGenerator.php#L61-L77 |
7,083 | ehough/generators | src/AbstractGenerator.php | AbstractGenerator.send | final public function send($value)
{
$this->_lastValueSentIn = $value;
$this->_sendInvokedAtLeastOnce = true;
/*
* If we've already ran to the first yield statement (from rewind() or key(), for instance), we need
* to try to move to the next position;
*/
if ($this->_positionsExecutedCount > 0) {
$this->_position++;
}
return $this->current();
} | php | final public function send($value)
{
$this->_lastValueSentIn = $value;
$this->_sendInvokedAtLeastOnce = true;
/*
* If we've already ran to the first yield statement (from rewind() or key(), for instance), we need
* to try to move to the next position;
*/
if ($this->_positionsExecutedCount > 0) {
$this->_position++;
}
return $this->current();
} | [
"final",
"public",
"function",
"send",
"(",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"_lastValueSentIn",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"_sendInvokedAtLeastOnce",
"=",
"true",
";",
"/*\n * If we've already ran to the first yield statement (from rewind() or key(), for instance), we need\n * to try to move to the next position;\n */",
"if",
"(",
"$",
"this",
"->",
"_positionsExecutedCount",
">",
"0",
")",
"{",
"$",
"this",
"->",
"_position",
"++",
";",
"}",
"return",
"$",
"this",
"->",
"current",
"(",
")",
";",
"}"
] | Send a value to the generator.
@param mixed $value
@return mixed | [
"Send",
"a",
"value",
"to",
"the",
"generator",
"."
] | 4138bc0602b8f1ca7d467ba89ff8c4251284e1b1 | https://github.com/ehough/generators/blob/4138bc0602b8f1ca7d467ba89ff8c4251284e1b1/src/AbstractGenerator.php#L140-L155 |
7,084 | dms-org/package.contact-us | src/Core/ContactEnquiryService.php | ContactEnquiryService.recordEnquiry | public function recordEnquiry(string $email, string $name, string $subject, string $message, callable $sendMailToAdminCallback) : ContactEnquiry
{
$enquiry = new ContactEnquiry(
$this->clock, new EmailAddress($email), $name, $subject, $message
);
$this->repository->save($enquiry);
$sendMailToAdminCallback($enquiry);
return $enquiry;
} | php | public function recordEnquiry(string $email, string $name, string $subject, string $message, callable $sendMailToAdminCallback) : ContactEnquiry
{
$enquiry = new ContactEnquiry(
$this->clock, new EmailAddress($email), $name, $subject, $message
);
$this->repository->save($enquiry);
$sendMailToAdminCallback($enquiry);
return $enquiry;
} | [
"public",
"function",
"recordEnquiry",
"(",
"string",
"$",
"email",
",",
"string",
"$",
"name",
",",
"string",
"$",
"subject",
",",
"string",
"$",
"message",
",",
"callable",
"$",
"sendMailToAdminCallback",
")",
":",
"ContactEnquiry",
"{",
"$",
"enquiry",
"=",
"new",
"ContactEnquiry",
"(",
"$",
"this",
"->",
"clock",
",",
"new",
"EmailAddress",
"(",
"$",
"email",
")",
",",
"$",
"name",
",",
"$",
"subject",
",",
"$",
"message",
")",
";",
"$",
"this",
"->",
"repository",
"->",
"save",
"(",
"$",
"enquiry",
")",
";",
"$",
"sendMailToAdminCallback",
"(",
"$",
"enquiry",
")",
";",
"return",
"$",
"enquiry",
";",
"}"
] | Records a contact enquiry.
@param string $email
@param string $name
@param string $subject
@param string $message
@param callable $sendMailToAdminCallback
@return ContactEnquiry | [
"Records",
"a",
"contact",
"enquiry",
"."
] | 1d56fb8d5538a0386bce293b18c394bfb90f5d63 | https://github.com/dms-org/package.contact-us/blob/1d56fb8d5538a0386bce293b18c394bfb90f5d63/src/Core/ContactEnquiryService.php#L45-L56 |
7,085 | arrounded/reflection | src/Http/Traits/Redirectable.php | Redirectable.redirectHere | protected function redirectHere($action, $parameters = [])
{
$controller = get_class($this);
return Redirect::action($controller.'@'.$action, $parameters);
} | php | protected function redirectHere($action, $parameters = [])
{
$controller = get_class($this);
return Redirect::action($controller.'@'.$action, $parameters);
} | [
"protected",
"function",
"redirectHere",
"(",
"$",
"action",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"controller",
"=",
"get_class",
"(",
"$",
"this",
")",
";",
"return",
"Redirect",
"::",
"action",
"(",
"$",
"controller",
".",
"'@'",
".",
"$",
"action",
",",
"$",
"parameters",
")",
";",
"}"
] | Redirect to an action in the current controller.
@param string $action
@param array $parameters
@return \Illuminate\Http\RedirectResponse | [
"Redirect",
"to",
"an",
"action",
"in",
"the",
"current",
"controller",
"."
] | 39ebcecba28b0af2b5cdaadf9621035037863979 | https://github.com/arrounded/reflection/blob/39ebcecba28b0af2b5cdaadf9621035037863979/src/Http/Traits/Redirectable.php#L22-L27 |
7,086 | arrounded/reflection | src/Http/Traits/Redirectable.php | Redirectable.redirectBackWithSession | protected function redirectBackWithSession()
{
if ($redirect = Session::get('redirect')) {
Session::forget('redirect');
return Redirect::to($redirect);
}
return Redirect::back();
} | php | protected function redirectBackWithSession()
{
if ($redirect = Session::get('redirect')) {
Session::forget('redirect');
return Redirect::to($redirect);
}
return Redirect::back();
} | [
"protected",
"function",
"redirectBackWithSession",
"(",
")",
"{",
"if",
"(",
"$",
"redirect",
"=",
"Session",
"::",
"get",
"(",
"'redirect'",
")",
")",
"{",
"Session",
"::",
"forget",
"(",
"'redirect'",
")",
";",
"return",
"Redirect",
"::",
"to",
"(",
"$",
"redirect",
")",
";",
"}",
"return",
"Redirect",
"::",
"back",
"(",
")",
";",
"}"
] | Redirect back or to a saved URL if any.
@return \Illuminate\Http\RedirectResponse | [
"Redirect",
"back",
"or",
"to",
"a",
"saved",
"URL",
"if",
"any",
"."
] | 39ebcecba28b0af2b5cdaadf9621035037863979 | https://github.com/arrounded/reflection/blob/39ebcecba28b0af2b5cdaadf9621035037863979/src/Http/Traits/Redirectable.php#L46-L55 |
7,087 | ionutmilica/ionix-framework | src/Routing/Router.php | Router.group | public function group($data, $callback = null)
{
if (is_callable($data)) {
$callback = $data;
$data = null;
}
if ($data) {
$this->prefix[] = $data;
}
call_user_func($callback, $this);
if ($data) {
array_pop($this->prefix);
}
} | php | public function group($data, $callback = null)
{
if (is_callable($data)) {
$callback = $data;
$data = null;
}
if ($data) {
$this->prefix[] = $data;
}
call_user_func($callback, $this);
if ($data) {
array_pop($this->prefix);
}
} | [
"public",
"function",
"group",
"(",
"$",
"data",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"data",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"data",
";",
"$",
"data",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"prefix",
"[",
"]",
"=",
"$",
"data",
";",
"}",
"call_user_func",
"(",
"$",
"callback",
",",
"$",
"this",
")",
";",
"if",
"(",
"$",
"data",
")",
"{",
"array_pop",
"(",
"$",
"this",
"->",
"prefix",
")",
";",
"}",
"}"
] | Create group of routes
@param $data
@param null $callback | [
"Create",
"group",
"of",
"routes"
] | a0363667ff677f1772bdd9ac9530a9f4710f9321 | https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Routing/Router.php#L87-L103 |
7,088 | ionutmilica/ionix-framework | src/Routing/Router.php | Router.dispatch | public function dispatch(Request $request)
{
$pathInfo = $request->getPathInfo();
$method = $request->getMethod();
$route = $this->collection->find($method, $pathInfo);
if ( ! $route) {
throw new \Exception('Route not found !');
}
return $this->dispatcher->dispatch($route);
} | php | public function dispatch(Request $request)
{
$pathInfo = $request->getPathInfo();
$method = $request->getMethod();
$route = $this->collection->find($method, $pathInfo);
if ( ! $route) {
throw new \Exception('Route not found !');
}
return $this->dispatcher->dispatch($route);
} | [
"public",
"function",
"dispatch",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"pathInfo",
"=",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
";",
"$",
"method",
"=",
"$",
"request",
"->",
"getMethod",
"(",
")",
";",
"$",
"route",
"=",
"$",
"this",
"->",
"collection",
"->",
"find",
"(",
"$",
"method",
",",
"$",
"pathInfo",
")",
";",
"if",
"(",
"!",
"$",
"route",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Route not found !'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"dispatcher",
"->",
"dispatch",
"(",
"$",
"route",
")",
";",
"}"
] | For a specific method and uri, dispatch the route.
@param Request $request
@return bool
@throws \Exception | [
"For",
"a",
"specific",
"method",
"and",
"uri",
"dispatch",
"the",
"route",
"."
] | a0363667ff677f1772bdd9ac9530a9f4710f9321 | https://github.com/ionutmilica/ionix-framework/blob/a0363667ff677f1772bdd9ac9530a9f4710f9321/src/Routing/Router.php#L112-L124 |
7,089 | Sparhandy/CodingStandard | src/phpcs/Production/Sniffs/Commenting/MethodHasDocBlockSniff.php | MethodHasDocBlockSniff.methodNeedsDocBlock | private function methodNeedsDocBlock(File $sniffedFile, $index)
{
$methodName = $sniffedFile->getDeclarationName($index);
return !in_array($methodName, $this->methodNamesWithoutNecessaryDocBlock, true);
} | php | private function methodNeedsDocBlock(File $sniffedFile, $index)
{
$methodName = $sniffedFile->getDeclarationName($index);
return !in_array($methodName, $this->methodNamesWithoutNecessaryDocBlock, true);
} | [
"private",
"function",
"methodNeedsDocBlock",
"(",
"File",
"$",
"sniffedFile",
",",
"$",
"index",
")",
"{",
"$",
"methodName",
"=",
"$",
"sniffedFile",
"->",
"getDeclarationName",
"(",
"$",
"index",
")",
";",
"return",
"!",
"in_array",
"(",
"$",
"methodName",
",",
"$",
"this",
"->",
"methodNamesWithoutNecessaryDocBlock",
",",
"true",
")",
";",
"}"
] | Checks if the method declaration is in need of a docblock.
@param File $sniffedFile file to be checked
@param int $index position of current token in token list
@return bool | [
"Checks",
"if",
"the",
"method",
"declaration",
"is",
"in",
"need",
"of",
"a",
"docblock",
"."
] | 519a0b0a4dc172b118bac1f22a25badfbf993b87 | https://github.com/Sparhandy/CodingStandard/blob/519a0b0a4dc172b118bac1f22a25badfbf993b87/src/phpcs/Production/Sniffs/Commenting/MethodHasDocBlockSniff.php#L44-L49 |
7,090 | dbojdo/Test-Tools | src/Helper/ContainerDebugger.php | ContainerDebugger.isInWhitelist | private function isInWhitelist($serviceName)
{
foreach ($this->whiteList as $pattern) {
if (!preg_match($pattern, $serviceName)) {
return false;
}
}
return true;
} | php | private function isInWhitelist($serviceName)
{
foreach ($this->whiteList as $pattern) {
if (!preg_match($pattern, $serviceName)) {
return false;
}
}
return true;
} | [
"private",
"function",
"isInWhitelist",
"(",
"$",
"serviceName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"whiteList",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"$",
"pattern",
",",
"$",
"serviceName",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
] | Returns true if one of the patterns is match
@param string $serviceName
@return bool | [
"Returns",
"true",
"if",
"one",
"of",
"the",
"patterns",
"is",
"match"
] | e55fbf1252a8fff1a6a0b454482ff899ef49f8e1 | https://github.com/dbojdo/Test-Tools/blob/e55fbf1252a8fff1a6a0b454482ff899ef49f8e1/src/Helper/ContainerDebugger.php#L158-L167 |
7,091 | rseyferth/chickenwire | src/ChickenWire/Core/Mime.php | Mime.byExtension | public static function byExtension($extension, $quality = 1.0)
{
// Trim it!
$extension = trim($extension, '. ');
// Look it up
if (!array_key_exists($extension, self::$extensionMap)) {
return false;
} else {
return new Mime(self::$extensionMap[$extension], $quality);
}
} | php | public static function byExtension($extension, $quality = 1.0)
{
// Trim it!
$extension = trim($extension, '. ');
// Look it up
if (!array_key_exists($extension, self::$extensionMap)) {
return false;
} else {
return new Mime(self::$extensionMap[$extension], $quality);
}
} | [
"public",
"static",
"function",
"byExtension",
"(",
"$",
"extension",
",",
"$",
"quality",
"=",
"1.0",
")",
"{",
"// Trim it!",
"$",
"extension",
"=",
"trim",
"(",
"$",
"extension",
",",
"'. '",
")",
";",
"// Look it up",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"extension",
",",
"self",
"::",
"$",
"extensionMap",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"new",
"Mime",
"(",
"self",
"::",
"$",
"extensionMap",
"[",
"$",
"extension",
"]",
",",
"$",
"quality",
")",
";",
"}",
"}"
] | Find a Mime type by its extension
@param string $extension The file extension
@param float $quality (default: 1) The quality of the mime in a HTTP Accept header (i.e. it's rank)
@return Mime|false A Mime instance, or false when extension is not known. | [
"Find",
"a",
"Mime",
"type",
"by",
"its",
"extension"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Core/Mime.php#L193-L208 |
7,092 | rseyferth/chickenwire | src/ChickenWire/Core/Mime.php | Mime.byContentType | public static function byContentType($contentType, $quality = 1.0)
{
// Look it up
if (!array_key_exists($contentType, self::$contentTypeMap)) {
return false;
} else {
return new Mime(self::$contentTypeMap[$contentType], $quality);
}
} | php | public static function byContentType($contentType, $quality = 1.0)
{
// Look it up
if (!array_key_exists($contentType, self::$contentTypeMap)) {
return false;
} else {
return new Mime(self::$contentTypeMap[$contentType], $quality);
}
} | [
"public",
"static",
"function",
"byContentType",
"(",
"$",
"contentType",
",",
"$",
"quality",
"=",
"1.0",
")",
"{",
"// Look it up",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"contentType",
",",
"self",
"::",
"$",
"contentTypeMap",
")",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"new",
"Mime",
"(",
"self",
"::",
"$",
"contentTypeMap",
"[",
"$",
"contentType",
"]",
",",
"$",
"quality",
")",
";",
"}",
"}"
] | Find a Mime type by a contentType
@param string $contentType The content type to look for, such as application/pdf.
@param float $quality (default: 1) The quality of the mime in a HTTP Accept header (i.e. it's rank)
@return Mime|false A Mime instance, or false when contentType is not known. | [
"Find",
"a",
"Mime",
"type",
"by",
"a",
"contentType"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Core/Mime.php#L251-L263 |
7,093 | rseyferth/chickenwire | src/ChickenWire/Core/Mime.php | Mime.getExtensions | public function getExtensions()
{
// Loop through extension map
$exts = array();
foreach (self::$extensionMap as $ext => $type) {
if ($type == $this->type) {
$exts[] = $ext;
}
}
return $exts;
} | php | public function getExtensions()
{
// Loop through extension map
$exts = array();
foreach (self::$extensionMap as $ext => $type) {
if ($type == $this->type) {
$exts[] = $ext;
}
}
return $exts;
} | [
"public",
"function",
"getExtensions",
"(",
")",
"{",
"// Loop through extension map",
"$",
"exts",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"extensionMap",
"as",
"$",
"ext",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"$",
"this",
"->",
"type",
")",
"{",
"$",
"exts",
"[",
"]",
"=",
"$",
"ext",
";",
"}",
"}",
"return",
"$",
"exts",
";",
"}"
] | Get possible extensions for this type
@return array Array of possible extensions for this Mime type | [
"Get",
"possible",
"extensions",
"for",
"this",
"type"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Core/Mime.php#L289-L301 |
7,094 | rseyferth/chickenwire | src/ChickenWire/Core/Mime.php | Mime.getContentType | public function getContentType()
{
foreach (self::$contentTypeMap as $ct => $type) {
if ($type == $this->type) {
return $ct;
}
}
return false;
} | php | public function getContentType()
{
foreach (self::$contentTypeMap as $ct => $type) {
if ($type == $this->type) {
return $ct;
}
}
return false;
} | [
"public",
"function",
"getContentType",
"(",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"contentTypeMap",
"as",
"$",
"ct",
"=>",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"$",
"this",
"->",
"type",
")",
"{",
"return",
"$",
"ct",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Get the default content-type string for this Mime type
@return string The content-type | [
"Get",
"the",
"default",
"content",
"-",
"type",
"string",
"for",
"this",
"Mime",
"type"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Core/Mime.php#L307-L317 |
7,095 | jnjxp/html-format | src/Locator.php | Locator.get | public function get($name)
{
if (! $this->has($name)) {
throw new Exception\HelperNotFoundException("Helper '$name' not found");
}
if (! isset($this->helpers[$name])) {
$factory = $this->factories[$name];
$this->helpers[$name] = $factory();
}
return $this->helpers[$name];
} | php | public function get($name)
{
if (! $this->has($name)) {
throw new Exception\HelperNotFoundException("Helper '$name' not found");
}
if (! isset($this->helpers[$name])) {
$factory = $this->factories[$name];
$this->helpers[$name] = $factory();
}
return $this->helpers[$name];
} | [
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"HelperNotFoundException",
"(",
"\"Helper '$name' not found\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"helpers",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"factories",
"[",
"$",
"name",
"]",
";",
"$",
"this",
"->",
"helpers",
"[",
"$",
"name",
"]",
"=",
"$",
"factory",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"helpers",
"[",
"$",
"name",
"]",
";",
"}"
] | gets a helper
@param string $name name of helper
@return mixed
@throws Exception if factory is not set
@access public | [
"gets",
"a",
"helper"
] | 123e8f33fa4607a7536878d0b08535e6bf3688d4 | https://github.com/jnjxp/html-format/blob/123e8f33fa4607a7536878d0b08535e6bf3688d4/src/Locator.php#L166-L178 |
7,096 | aedart/model | src/Traits/Strings/IpV6Trait.php | IpV6Trait.getIpV6 | public function getIpV6() : ?string
{
if ( ! $this->hasIpV6()) {
$this->setIpV6($this->getDefaultIpV6());
}
return $this->ipV6;
} | php | public function getIpV6() : ?string
{
if ( ! $this->hasIpV6()) {
$this->setIpV6($this->getDefaultIpV6());
}
return $this->ipV6;
} | [
"public",
"function",
"getIpV6",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasIpV6",
"(",
")",
")",
"{",
"$",
"this",
"->",
"setIpV6",
"(",
"$",
"this",
"->",
"getDefaultIpV6",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"ipV6",
";",
"}"
] | Get ip v6
If no "ip v6" value has been set, this method will
set and return a default "ip v6" value,
if any such value is available
@see getDefaultIpV6()
@return string|null ip v6 or null if no ip v6 has been set | [
"Get",
"ip",
"v6"
] | 9a562c1c53a276d01ace0ab71f5305458bea542f | https://github.com/aedart/model/blob/9a562c1c53a276d01ace0ab71f5305458bea542f/src/Traits/Strings/IpV6Trait.php#L48-L54 |
7,097 | alevilar/MtSites | Controller/Component/Auth/MtSitesAuthorize.php | MtSitesAuthorize.authorize | public function authorize($user, CakeRequest $request) {
//sesion expiro
if( empty( $user['id'] ) ){
return false;
}
//si es admin general esta autorizado
if(array_key_exists('is_admin', $user) && $user['is_admin']) {
return true;
}
// si es pantalla de instalacion de nuevo tenant
if ( $request->params['plugin'] == 'mt_sites' && $request->params['controller'] == 'sites' && $request->params['action'] == 'install'){
return true;
}
if ( $request->params['plugin'] == 'install' && $request->params['controller'] == 'configurations' && $request->params['action'] == 'first_configuration_wizard'){
return true;
}
if ( !array_key_exists('tenant', $request->params) && empty($request->params['tenant']) ){
// es pagina global. O sea, no estoy dentro del tenant
// debug( $request->params );
if ( $request->params['action'] == 'display' ) {
return true;
}
}
if ( !array_key_exists('Site', $user) ) {
// el usuario no tiene sitios asignados. No puede entrar a ningun lado
return false;
}
// listar sitios del la variable de sesion del usuario actual
$siteAlias = Hash::extract( $user['Site'], '{n}.alias' );
if ( array_key_exists('tenant', $request->params) && in_array( $request->params['tenant'], $siteAlias ) ) {
// si el usuario tiene, entre sus sitios al sitio actual, entonces esta autorizado
return true;
}
// acceso a la pagina de edicion y de cambio de contraseña propia de cada usuario registrado y logueado.
if ( (strtolower($request->params['controller']) == "users"
&& strtolower($request->params['action']) == 'my_edit')
or (strtolower($request->params['controller']) == "users"
&& strtolower($request->params['action']) == 'change_password') ){
//Si el controlador es users y el action es my_edit o change_password te dejara entrar siempre que estes logeado.
return true;
}
return false;
} | php | public function authorize($user, CakeRequest $request) {
//sesion expiro
if( empty( $user['id'] ) ){
return false;
}
//si es admin general esta autorizado
if(array_key_exists('is_admin', $user) && $user['is_admin']) {
return true;
}
// si es pantalla de instalacion de nuevo tenant
if ( $request->params['plugin'] == 'mt_sites' && $request->params['controller'] == 'sites' && $request->params['action'] == 'install'){
return true;
}
if ( $request->params['plugin'] == 'install' && $request->params['controller'] == 'configurations' && $request->params['action'] == 'first_configuration_wizard'){
return true;
}
if ( !array_key_exists('tenant', $request->params) && empty($request->params['tenant']) ){
// es pagina global. O sea, no estoy dentro del tenant
// debug( $request->params );
if ( $request->params['action'] == 'display' ) {
return true;
}
}
if ( !array_key_exists('Site', $user) ) {
// el usuario no tiene sitios asignados. No puede entrar a ningun lado
return false;
}
// listar sitios del la variable de sesion del usuario actual
$siteAlias = Hash::extract( $user['Site'], '{n}.alias' );
if ( array_key_exists('tenant', $request->params) && in_array( $request->params['tenant'], $siteAlias ) ) {
// si el usuario tiene, entre sus sitios al sitio actual, entonces esta autorizado
return true;
}
// acceso a la pagina de edicion y de cambio de contraseña propia de cada usuario registrado y logueado.
if ( (strtolower($request->params['controller']) == "users"
&& strtolower($request->params['action']) == 'my_edit')
or (strtolower($request->params['controller']) == "users"
&& strtolower($request->params['action']) == 'change_password') ){
//Si el controlador es users y el action es my_edit o change_password te dejara entrar siempre que estes logeado.
return true;
}
return false;
} | [
"public",
"function",
"authorize",
"(",
"$",
"user",
",",
"CakeRequest",
"$",
"request",
")",
"{",
"//sesion expiro",
"if",
"(",
"empty",
"(",
"$",
"user",
"[",
"'id'",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"//si es admin general esta autorizado",
"if",
"(",
"array_key_exists",
"(",
"'is_admin'",
",",
"$",
"user",
")",
"&&",
"$",
"user",
"[",
"'is_admin'",
"]",
")",
"{",
"return",
"true",
";",
"}",
"// si es pantalla de instalacion de nuevo tenant",
"if",
"(",
"$",
"request",
"->",
"params",
"[",
"'plugin'",
"]",
"==",
"'mt_sites'",
"&&",
"$",
"request",
"->",
"params",
"[",
"'controller'",
"]",
"==",
"'sites'",
"&&",
"$",
"request",
"->",
"params",
"[",
"'action'",
"]",
"==",
"'install'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"request",
"->",
"params",
"[",
"'plugin'",
"]",
"==",
"'install'",
"&&",
"$",
"request",
"->",
"params",
"[",
"'controller'",
"]",
"==",
"'configurations'",
"&&",
"$",
"request",
"->",
"params",
"[",
"'action'",
"]",
"==",
"'first_configuration_wizard'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'tenant'",
",",
"$",
"request",
"->",
"params",
")",
"&&",
"empty",
"(",
"$",
"request",
"->",
"params",
"[",
"'tenant'",
"]",
")",
")",
"{",
"// es pagina global. O sea, no estoy dentro del tenant",
"// debug( $request->params );",
"if",
"(",
"$",
"request",
"->",
"params",
"[",
"'action'",
"]",
"==",
"'display'",
")",
"{",
"return",
"true",
";",
"}",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"'Site'",
",",
"$",
"user",
")",
")",
"{",
"// el usuario no tiene sitios asignados. No puede entrar a ningun lado",
"return",
"false",
";",
"}",
"// listar sitios del la variable de sesion del usuario actual",
"$",
"siteAlias",
"=",
"Hash",
"::",
"extract",
"(",
"$",
"user",
"[",
"'Site'",
"]",
",",
"'{n}.alias'",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'tenant'",
",",
"$",
"request",
"->",
"params",
")",
"&&",
"in_array",
"(",
"$",
"request",
"->",
"params",
"[",
"'tenant'",
"]",
",",
"$",
"siteAlias",
")",
")",
"{",
"// si el usuario tiene, entre sus sitios al sitio actual, entonces esta autorizado ",
"return",
"true",
";",
"}",
"// acceso a la pagina de edicion y de cambio de contraseña propia de cada usuario registrado y logueado. ",
"if",
"(",
"(",
"strtolower",
"(",
"$",
"request",
"->",
"params",
"[",
"'controller'",
"]",
")",
"==",
"\"users\"",
"&&",
"strtolower",
"(",
"$",
"request",
"->",
"params",
"[",
"'action'",
"]",
")",
"==",
"'my_edit'",
")",
"or",
"(",
"strtolower",
"(",
"$",
"request",
"->",
"params",
"[",
"'controller'",
"]",
")",
"==",
"\"users\"",
"&&",
"strtolower",
"(",
"$",
"request",
"->",
"params",
"[",
"'action'",
"]",
")",
"==",
"'change_password'",
")",
")",
"{",
"//Si el controlador es users y el action es my_edit o change_password te dejara entrar siempre que estes logeado.",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Checks user authorization using a controller callback.
@param array $user Active user data
@param CakeRequest $request Request instance.
@return bool | [
"Checks",
"user",
"authorization",
"using",
"a",
"controller",
"callback",
"."
] | 5b1cdc52a929ca86a220ae12add84c52027a3c20 | https://github.com/alevilar/MtSites/blob/5b1cdc52a929ca86a220ae12add84c52027a3c20/Controller/Component/Auth/MtSitesAuthorize.php#L51-L106 |
7,098 | phlexible/phlexible | src/Phlexible/Bundle/CmsBundle/Twig/Extension/MiscExtension.php | MiscExtension.id | public function id($prefix = '')
{
// raise id
$id = ++self::$id;
if ($prefix) {
$id = $prefix.$id;
}
return $id;
} | php | public function id($prefix = '')
{
// raise id
$id = ++self::$id;
if ($prefix) {
$id = $prefix.$id;
}
return $id;
} | [
"public",
"function",
"id",
"(",
"$",
"prefix",
"=",
"''",
")",
"{",
"// raise id",
"$",
"id",
"=",
"++",
"self",
"::",
"$",
"id",
";",
"if",
"(",
"$",
"prefix",
")",
"{",
"$",
"id",
"=",
"$",
"prefix",
".",
"$",
"id",
";",
"}",
"return",
"$",
"id",
";",
"}"
] | Generate and return a unique id.
@param string $prefix
@return string | [
"Generate",
"and",
"return",
"a",
"unique",
"id",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/CmsBundle/Twig/Extension/MiscExtension.php#L54-L64 |
7,099 | phlexible/phlexible | src/Phlexible/Bundle/CmsBundle/Twig/Extension/MiscExtension.php | MiscExtension.readableSize | public function readableSize($size, $decimals = 0, $binarySuffix = false)
{
$formatter = new FilesizeFormatter();
return $formatter->formatFilesize($size, $decimals, $binarySuffix);
} | php | public function readableSize($size, $decimals = 0, $binarySuffix = false)
{
$formatter = new FilesizeFormatter();
return $formatter->formatFilesize($size, $decimals, $binarySuffix);
} | [
"public",
"function",
"readableSize",
"(",
"$",
"size",
",",
"$",
"decimals",
"=",
"0",
",",
"$",
"binarySuffix",
"=",
"false",
")",
"{",
"$",
"formatter",
"=",
"new",
"FilesizeFormatter",
"(",
")",
";",
"return",
"$",
"formatter",
"->",
"formatFilesize",
"(",
"$",
"size",
",",
"$",
"decimals",
",",
"$",
"binarySuffix",
")",
";",
"}"
] | Return readable file size for given value.
@param int $size
@param int $decimals
@param bool $binarySuffix
@return string | [
"Return",
"readable",
"file",
"size",
"for",
"given",
"value",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/CmsBundle/Twig/Extension/MiscExtension.php#L75-L80 |
Subsets and Splits