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
|
---|---|---|---|---|---|---|---|---|---|---|---|
4,800 | RitaCo/cakephp-tools-plugin | Routing/Filter/AssetDispatcher.php | AssetDispatcher._filterAsset | protected function _filterAsset(CakeEvent $event) {
$url = $event->data['request']->url;
$response = $event->data['response'];
$filters = Configure::read('Asset.filter');
$isCss = (
strpos($url, 'ccss/') === 0 ||
preg_match('#^(theme/([^/]+)/ccss/)|(([^/]+)(?<!css)/ccss)/#i', $url)
);
$isJs = (
strpos($url, 'cjs/') === 0 ||
preg_match('#^/((theme/[^/]+)/cjs/)|(([^/]+)(?<!js)/cjs)/#i', $url)
);
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
$response->statusCode(404);
return $response;
}
if ($isCss) {
include WWW_ROOT . DS . $filters['css'];
return $response;
}
if ($isJs) {
include WWW_ROOT . DS . $filters['js'];
return $response;
}
} | php | protected function _filterAsset(CakeEvent $event) {
$url = $event->data['request']->url;
$response = $event->data['response'];
$filters = Configure::read('Asset.filter');
$isCss = (
strpos($url, 'ccss/') === 0 ||
preg_match('#^(theme/([^/]+)/ccss/)|(([^/]+)(?<!css)/ccss)/#i', $url)
);
$isJs = (
strpos($url, 'cjs/') === 0 ||
preg_match('#^/((theme/[^/]+)/cjs/)|(([^/]+)(?<!js)/cjs)/#i', $url)
);
if (($isCss && empty($filters['css'])) || ($isJs && empty($filters['js']))) {
$response->statusCode(404);
return $response;
}
if ($isCss) {
include WWW_ROOT . DS . $filters['css'];
return $response;
}
if ($isJs) {
include WWW_ROOT . DS . $filters['js'];
return $response;
}
} | [
"protected",
"function",
"_filterAsset",
"(",
"CakeEvent",
"$",
"event",
")",
"{",
"$",
"url",
"=",
"$",
"event",
"->",
"data",
"[",
"'request'",
"]",
"->",
"url",
";",
"$",
"response",
"=",
"$",
"event",
"->",
"data",
"[",
"'response'",
"]",
";",
"$",
"filters",
"=",
"Configure",
"::",
"read",
"(",
"'Asset.filter'",
")",
";",
"$",
"isCss",
"=",
"(",
"strpos",
"(",
"$",
"url",
",",
"'ccss/'",
")",
"===",
"0",
"||",
"preg_match",
"(",
"'#^(theme/([^/]+)/ccss/)|(([^/]+)(?<!css)/ccss)/#i'",
",",
"$",
"url",
")",
")",
";",
"$",
"isJs",
"=",
"(",
"strpos",
"(",
"$",
"url",
",",
"'cjs/'",
")",
"===",
"0",
"||",
"preg_match",
"(",
"'#^/((theme/[^/]+)/cjs/)|(([^/]+)(?<!js)/cjs)/#i'",
",",
"$",
"url",
")",
")",
";",
"if",
"(",
"(",
"$",
"isCss",
"&&",
"empty",
"(",
"$",
"filters",
"[",
"'css'",
"]",
")",
")",
"||",
"(",
"$",
"isJs",
"&&",
"empty",
"(",
"$",
"filters",
"[",
"'js'",
"]",
")",
")",
")",
"{",
"$",
"response",
"->",
"statusCode",
"(",
"404",
")",
";",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"isCss",
")",
"{",
"include",
"WWW_ROOT",
".",
"DS",
".",
"$",
"filters",
"[",
"'css'",
"]",
";",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"isJs",
")",
"{",
"include",
"WWW_ROOT",
".",
"DS",
".",
"$",
"filters",
"[",
"'js'",
"]",
";",
"return",
"$",
"response",
";",
"}",
"}"
] | Checks if the client is requesting a filtered asset and runs the corresponding
filter if any is configured
@param CakeEvent $event containing the request and response object
@return CakeResponse if the client is requesting a recognized asset, null otherwise | [
"Checks",
"if",
"the",
"client",
"is",
"requesting",
"a",
"filtered",
"asset",
"and",
"runs",
"the",
"corresponding",
"filter",
"if",
"any",
"is",
"configured"
] | e9581f1d666560721d70f5dad116f52f77a687ff | https://github.com/RitaCo/cakephp-tools-plugin/blob/e9581f1d666560721d70f5dad116f52f77a687ff/Routing/Filter/AssetDispatcher.php#L87-L114 |
4,801 | iuravic/duktig-core | src/Core/Route/RouteProvider.php | RouteProvider.setRoutes | public function setRoutes() : void
{
if (is_null($this->routes)) {
$this->routes = [];
$routesConfig = $this->config->getParam('routes') ?? [];
foreach ($routesConfig as $routeName => $routeArr) {
$route = new Route(
$routeName,
$routeArr['methods'],
$routeArr['path'],
$routeArr['params_defaults'],
$routeArr['params_requirements'],
$routeArr['handler'],
$routeArr['handler_method'] ?? null
);
$this->routes[] = $route;
}
}
} | php | public function setRoutes() : void
{
if (is_null($this->routes)) {
$this->routes = [];
$routesConfig = $this->config->getParam('routes') ?? [];
foreach ($routesConfig as $routeName => $routeArr) {
$route = new Route(
$routeName,
$routeArr['methods'],
$routeArr['path'],
$routeArr['params_defaults'],
$routeArr['params_requirements'],
$routeArr['handler'],
$routeArr['handler_method'] ?? null
);
$this->routes[] = $route;
}
}
} | [
"public",
"function",
"setRoutes",
"(",
")",
":",
"void",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"routes",
")",
")",
"{",
"$",
"this",
"->",
"routes",
"=",
"[",
"]",
";",
"$",
"routesConfig",
"=",
"$",
"this",
"->",
"config",
"->",
"getParam",
"(",
"'routes'",
")",
"??",
"[",
"]",
";",
"foreach",
"(",
"$",
"routesConfig",
"as",
"$",
"routeName",
"=>",
"$",
"routeArr",
")",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
"$",
"routeName",
",",
"$",
"routeArr",
"[",
"'methods'",
"]",
",",
"$",
"routeArr",
"[",
"'path'",
"]",
",",
"$",
"routeArr",
"[",
"'params_defaults'",
"]",
",",
"$",
"routeArr",
"[",
"'params_requirements'",
"]",
",",
"$",
"routeArr",
"[",
"'handler'",
"]",
",",
"$",
"routeArr",
"[",
"'handler_method'",
"]",
"??",
"null",
")",
";",
"$",
"this",
"->",
"routes",
"[",
"]",
"=",
"$",
"route",
";",
"}",
"}",
"}"
] | Sets \Duktig\Core\Route\Route objects from config values | [
"Sets",
"\\",
"Duktig",
"\\",
"Core",
"\\",
"Route",
"\\",
"Route",
"objects",
"from",
"config",
"values"
] | 0e04495324516c2b151163fb42882ab0a319a3a8 | https://github.com/iuravic/duktig-core/blob/0e04495324516c2b151163fb42882ab0a319a3a8/src/Core/Route/RouteProvider.php#L30-L48 |
4,802 | neat-php/http | classes/Url.php | Url.get | protected function get()
{
$url = '';
if ($this->scheme) {
$url = $this->scheme . ':';
}
if ($this->host) {
$url .= '//' . $this->authority();
}
if ($this->path) {
$url .= '/' . ltrim($this->path, '/');
}
if ($this->query) {
$url .= '?' . $this->query;
}
if ($this->fragment) {
$url .= '#' . $this->fragment;
}
return $url;
} | php | protected function get()
{
$url = '';
if ($this->scheme) {
$url = $this->scheme . ':';
}
if ($this->host) {
$url .= '//' . $this->authority();
}
if ($this->path) {
$url .= '/' . ltrim($this->path, '/');
}
if ($this->query) {
$url .= '?' . $this->query;
}
if ($this->fragment) {
$url .= '#' . $this->fragment;
}
return $url;
} | [
"protected",
"function",
"get",
"(",
")",
"{",
"$",
"url",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"scheme",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"scheme",
".",
"':'",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"host",
")",
"{",
"$",
"url",
".=",
"'//'",
".",
"$",
"this",
"->",
"authority",
"(",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"path",
")",
"{",
"$",
"url",
".=",
"'/'",
".",
"ltrim",
"(",
"$",
"this",
"->",
"path",
",",
"'/'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"query",
")",
"{",
"$",
"url",
".=",
"'?'",
".",
"$",
"this",
"->",
"query",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"fragment",
")",
"{",
"$",
"url",
".=",
"'#'",
".",
"$",
"this",
"->",
"fragment",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Get URL as string
@return string | [
"Get",
"URL",
"as",
"string"
] | 5d4781a8481c1f708fd642292e44244435a8369c | https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Url.php#L79-L99 |
4,803 | neat-php/http | classes/Url.php | Url.set | protected function set($url)
{
$parts = parse_url($url);
if (!$parts) {
throw new \InvalidArgumentException('URL malformed');
}
$this->scheme = isset($parts['scheme']) ? strtolower($parts['scheme']) : '';
$this->username = $parts['user'] ?? '';
$this->password = $parts['pass'] ?? '';
$this->host = isset($parts['host']) ? strtolower($parts['host']) : '';
$this->port = isset($parts['port']) ? intval($parts['port']) : null;
$this->path = $parts['path'] ?? '';
$this->query = $parts['query'] ?? '';
$this->fragment = $parts['fragment'] ?? '';
} | php | protected function set($url)
{
$parts = parse_url($url);
if (!$parts) {
throw new \InvalidArgumentException('URL malformed');
}
$this->scheme = isset($parts['scheme']) ? strtolower($parts['scheme']) : '';
$this->username = $parts['user'] ?? '';
$this->password = $parts['pass'] ?? '';
$this->host = isset($parts['host']) ? strtolower($parts['host']) : '';
$this->port = isset($parts['port']) ? intval($parts['port']) : null;
$this->path = $parts['path'] ?? '';
$this->query = $parts['query'] ?? '';
$this->fragment = $parts['fragment'] ?? '';
} | [
"protected",
"function",
"set",
"(",
"$",
"url",
")",
"{",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"url",
")",
";",
"if",
"(",
"!",
"$",
"parts",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'URL malformed'",
")",
";",
"}",
"$",
"this",
"->",
"scheme",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
")",
"?",
"strtolower",
"(",
"$",
"parts",
"[",
"'scheme'",
"]",
")",
":",
"''",
";",
"$",
"this",
"->",
"username",
"=",
"$",
"parts",
"[",
"'user'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"password",
"=",
"$",
"parts",
"[",
"'pass'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"host",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'host'",
"]",
")",
"?",
"strtolower",
"(",
"$",
"parts",
"[",
"'host'",
"]",
")",
":",
"''",
";",
"$",
"this",
"->",
"port",
"=",
"isset",
"(",
"$",
"parts",
"[",
"'port'",
"]",
")",
"?",
"intval",
"(",
"$",
"parts",
"[",
"'port'",
"]",
")",
":",
"null",
";",
"$",
"this",
"->",
"path",
"=",
"$",
"parts",
"[",
"'path'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"query",
"=",
"$",
"parts",
"[",
"'query'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"fragment",
"=",
"$",
"parts",
"[",
"'fragment'",
"]",
"??",
"''",
";",
"}"
] | Set URL as string
@param string $url | [
"Set",
"URL",
"as",
"string"
] | 5d4781a8481c1f708fd642292e44244435a8369c | https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Url.php#L106-L121 |
4,804 | neat-php/http | classes/Url.php | Url.authority | public function authority()
{
$userInfo = $this->username;
if ($this->password) {
$userInfo .= ':' . $this->password;
}
$port = $this->port();
$authority = $this->host;
if ($authority && $userInfo) {
$authority = $userInfo . '@' . $authority;
}
if ($authority && $port) {
$authority .= ':' . $port;
}
return $authority;
} | php | public function authority()
{
$userInfo = $this->username;
if ($this->password) {
$userInfo .= ':' . $this->password;
}
$port = $this->port();
$authority = $this->host;
if ($authority && $userInfo) {
$authority = $userInfo . '@' . $authority;
}
if ($authority && $port) {
$authority .= ':' . $port;
}
return $authority;
} | [
"public",
"function",
"authority",
"(",
")",
"{",
"$",
"userInfo",
"=",
"$",
"this",
"->",
"username",
";",
"if",
"(",
"$",
"this",
"->",
"password",
")",
"{",
"$",
"userInfo",
".=",
"':'",
".",
"$",
"this",
"->",
"password",
";",
"}",
"$",
"port",
"=",
"$",
"this",
"->",
"port",
"(",
")",
";",
"$",
"authority",
"=",
"$",
"this",
"->",
"host",
";",
"if",
"(",
"$",
"authority",
"&&",
"$",
"userInfo",
")",
"{",
"$",
"authority",
"=",
"$",
"userInfo",
".",
"'@'",
".",
"$",
"authority",
";",
"}",
"if",
"(",
"$",
"authority",
"&&",
"$",
"port",
")",
"{",
"$",
"authority",
".=",
"':'",
".",
"$",
"port",
";",
"}",
"return",
"$",
"authority",
";",
"}"
] | Get authority component of the URL
@see https://tools.ietf.org/html/rfc3986#section-3.2
@return string Authority, in "[username[:password]@]host[:port]" format | [
"Get",
"authority",
"component",
"of",
"the",
"URL"
] | 5d4781a8481c1f708fd642292e44244435a8369c | https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Url.php#L216-L232 |
4,805 | neat-php/http | classes/Url.php | Url.capture | public static function capture(array $server = null)
{
if (!$server) {
$server = $_SERVER;
}
$source = 'http:';
if (isset($server['HTTPS']) && $server['HTTPS'] && $server['HTTPS'] != 'off') {
$source = 'https:';
}
if (isset($server['HTTP_HOST'])) {
$source .= '//' . $server['HTTP_HOST'];
}
if (isset($server['REQUEST_URI'])) {
$source .= $server['REQUEST_URI'];
}
$url = new static($source);
$url->username = $server['PHP_AUTH_USER'] ?? null;
$url->password = $server['PHP_AUTH_PW'] ?? null;
return $url;
} | php | public static function capture(array $server = null)
{
if (!$server) {
$server = $_SERVER;
}
$source = 'http:';
if (isset($server['HTTPS']) && $server['HTTPS'] && $server['HTTPS'] != 'off') {
$source = 'https:';
}
if (isset($server['HTTP_HOST'])) {
$source .= '//' . $server['HTTP_HOST'];
}
if (isset($server['REQUEST_URI'])) {
$source .= $server['REQUEST_URI'];
}
$url = new static($source);
$url->username = $server['PHP_AUTH_USER'] ?? null;
$url->password = $server['PHP_AUTH_PW'] ?? null;
return $url;
} | [
"public",
"static",
"function",
"capture",
"(",
"array",
"$",
"server",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"server",
")",
"{",
"$",
"server",
"=",
"$",
"_SERVER",
";",
"}",
"$",
"source",
"=",
"'http:'",
";",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'HTTPS'",
"]",
")",
"&&",
"$",
"server",
"[",
"'HTTPS'",
"]",
"&&",
"$",
"server",
"[",
"'HTTPS'",
"]",
"!=",
"'off'",
")",
"{",
"$",
"source",
"=",
"'https:'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'HTTP_HOST'",
"]",
")",
")",
"{",
"$",
"source",
".=",
"'//'",
".",
"$",
"server",
"[",
"'HTTP_HOST'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"server",
"[",
"'REQUEST_URI'",
"]",
")",
")",
"{",
"$",
"source",
".=",
"$",
"server",
"[",
"'REQUEST_URI'",
"]",
";",
"}",
"$",
"url",
"=",
"new",
"static",
"(",
"$",
"source",
")",
";",
"$",
"url",
"->",
"username",
"=",
"$",
"server",
"[",
"'PHP_AUTH_USER'",
"]",
"??",
"null",
";",
"$",
"url",
"->",
"password",
"=",
"$",
"server",
"[",
"'PHP_AUTH_PW'",
"]",
"??",
"null",
";",
"return",
"$",
"url",
";",
"}"
] | Capture the URL from the SERVER super global
@see https://secure.php.net/manual/en/reserved.variables.server.php
@param array $server SERVER super global
@return static Captured URL | [
"Capture",
"the",
"URL",
"from",
"the",
"SERVER",
"super",
"global"
] | 5d4781a8481c1f708fd642292e44244435a8369c | https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Url.php#L346-L368 |
4,806 | manovotny/wp-taxonomy-util | src/classes/class-wp-taxonomy-util.php | WP_Taxonomy_Util.create_taxonomy | public function create_taxonomy( $options ) {
// Ensure we have the correct options.
if ( ! $options instanceof WP_Taxonomy_Options ) {
// Trigger error.
trigger_error( 'Options must be passed as a WP_Taxonomy_Options.' );
// Exit.
return;
}
// Ensure we have all the properties required.
if ( ! $options->has_required_properties() ) {
// Trigger error.
trigger_error( 'WP_Taxonomy_Options are missing required properties.' );
// Exit.
return;
}
// Create labels.
$labels = array(
'add_new_item' => __( 'Add New ' . $options->get_singular_name() ),
'all_items' => __( 'All ' . $options->get_plural_name() ),
'edit_item' => __( 'Edit ' . $options->get_singular_name() ),
'menu_name' => __( $options->get_plural_name() ),
'name' => __( $options->get_plural_name() ),
'new_item_name' => __( 'New ' . $options->get_singular_name() . ' Name' ),
'parent_item' => __( 'Parent ' . $options->get_singular_name() ),
'parent_item_colon' => __( 'Parent ' . $options->get_singular_name() . ':' ),
'search_items' => __( 'Search ' . $options->get_plural_name() ),
'singular_name' => __( $options->get_singular_name() ),
'update_item' => __( 'Update ' . $options->get_singular_name() ),
);
// Create taxonomy arguments.
$args = array(
'hierarchical' => $options->get_hierarchical(),
'labels' => $labels,
'query_var' => true,
'rewrite' => array( 'slug' => $options->get_slug() ),
'show_admin_column' => true,
'show_ui' => true,
);
// Create taxonomy.
register_taxonomy( $options->get_slug(), array( $options->get_post_type() ), $args );
} | php | public function create_taxonomy( $options ) {
// Ensure we have the correct options.
if ( ! $options instanceof WP_Taxonomy_Options ) {
// Trigger error.
trigger_error( 'Options must be passed as a WP_Taxonomy_Options.' );
// Exit.
return;
}
// Ensure we have all the properties required.
if ( ! $options->has_required_properties() ) {
// Trigger error.
trigger_error( 'WP_Taxonomy_Options are missing required properties.' );
// Exit.
return;
}
// Create labels.
$labels = array(
'add_new_item' => __( 'Add New ' . $options->get_singular_name() ),
'all_items' => __( 'All ' . $options->get_plural_name() ),
'edit_item' => __( 'Edit ' . $options->get_singular_name() ),
'menu_name' => __( $options->get_plural_name() ),
'name' => __( $options->get_plural_name() ),
'new_item_name' => __( 'New ' . $options->get_singular_name() . ' Name' ),
'parent_item' => __( 'Parent ' . $options->get_singular_name() ),
'parent_item_colon' => __( 'Parent ' . $options->get_singular_name() . ':' ),
'search_items' => __( 'Search ' . $options->get_plural_name() ),
'singular_name' => __( $options->get_singular_name() ),
'update_item' => __( 'Update ' . $options->get_singular_name() ),
);
// Create taxonomy arguments.
$args = array(
'hierarchical' => $options->get_hierarchical(),
'labels' => $labels,
'query_var' => true,
'rewrite' => array( 'slug' => $options->get_slug() ),
'show_admin_column' => true,
'show_ui' => true,
);
// Create taxonomy.
register_taxonomy( $options->get_slug(), array( $options->get_post_type() ), $args );
} | [
"public",
"function",
"create_taxonomy",
"(",
"$",
"options",
")",
"{",
"// Ensure we have the correct options.",
"if",
"(",
"!",
"$",
"options",
"instanceof",
"WP_Taxonomy_Options",
")",
"{",
"// Trigger error.",
"trigger_error",
"(",
"'Options must be passed as a WP_Taxonomy_Options.'",
")",
";",
"// Exit.",
"return",
";",
"}",
"// Ensure we have all the properties required.",
"if",
"(",
"!",
"$",
"options",
"->",
"has_required_properties",
"(",
")",
")",
"{",
"// Trigger error.",
"trigger_error",
"(",
"'WP_Taxonomy_Options are missing required properties.'",
")",
";",
"// Exit.",
"return",
";",
"}",
"// Create labels.",
"$",
"labels",
"=",
"array",
"(",
"'add_new_item'",
"=>",
"__",
"(",
"'Add New '",
".",
"$",
"options",
"->",
"get_singular_name",
"(",
")",
")",
",",
"'all_items'",
"=>",
"__",
"(",
"'All '",
".",
"$",
"options",
"->",
"get_plural_name",
"(",
")",
")",
",",
"'edit_item'",
"=>",
"__",
"(",
"'Edit '",
".",
"$",
"options",
"->",
"get_singular_name",
"(",
")",
")",
",",
"'menu_name'",
"=>",
"__",
"(",
"$",
"options",
"->",
"get_plural_name",
"(",
")",
")",
",",
"'name'",
"=>",
"__",
"(",
"$",
"options",
"->",
"get_plural_name",
"(",
")",
")",
",",
"'new_item_name'",
"=>",
"__",
"(",
"'New '",
".",
"$",
"options",
"->",
"get_singular_name",
"(",
")",
".",
"' Name'",
")",
",",
"'parent_item'",
"=>",
"__",
"(",
"'Parent '",
".",
"$",
"options",
"->",
"get_singular_name",
"(",
")",
")",
",",
"'parent_item_colon'",
"=>",
"__",
"(",
"'Parent '",
".",
"$",
"options",
"->",
"get_singular_name",
"(",
")",
".",
"':'",
")",
",",
"'search_items'",
"=>",
"__",
"(",
"'Search '",
".",
"$",
"options",
"->",
"get_plural_name",
"(",
")",
")",
",",
"'singular_name'",
"=>",
"__",
"(",
"$",
"options",
"->",
"get_singular_name",
"(",
")",
")",
",",
"'update_item'",
"=>",
"__",
"(",
"'Update '",
".",
"$",
"options",
"->",
"get_singular_name",
"(",
")",
")",
",",
")",
";",
"// Create taxonomy arguments.",
"$",
"args",
"=",
"array",
"(",
"'hierarchical'",
"=>",
"$",
"options",
"->",
"get_hierarchical",
"(",
")",
",",
"'labels'",
"=>",
"$",
"labels",
",",
"'query_var'",
"=>",
"true",
",",
"'rewrite'",
"=>",
"array",
"(",
"'slug'",
"=>",
"$",
"options",
"->",
"get_slug",
"(",
")",
")",
",",
"'show_admin_column'",
"=>",
"true",
",",
"'show_ui'",
"=>",
"true",
",",
")",
";",
"// Create taxonomy.",
"register_taxonomy",
"(",
"$",
"options",
"->",
"get_slug",
"(",
")",
",",
"array",
"(",
"$",
"options",
"->",
"get_post_type",
"(",
")",
")",
",",
"$",
"args",
")",
";",
"}"
] | Creates a custom taxonomy.
@param WP_Taxonomy_Options $options Properties to create a new taxonomy. | [
"Creates",
"a",
"custom",
"taxonomy",
"."
] | 03401b5bbdce47a980f6f6fab2c9f7e8b670e6c6 | https://github.com/manovotny/wp-taxonomy-util/blob/03401b5bbdce47a980f6f6fab2c9f7e8b670e6c6/src/classes/class-wp-taxonomy-util.php#L58-L110 |
4,807 | zepi/turbo-base | Zepi/Web/General/src/Manager/MetaInformationManager.php | MetaInformationManager.getTitle | public function getTitle()
{
$title = '';
/**
* If there is a title, add it to the returned title
*/
if (trim($this->title) != '') {
$title = trim($this->title);
}
/**
* If there is a name of the framework instance, add it to
* the returned title
*/
if (trim($this->name) != '') {
if (trim($title) != '') {
$title .= $this->delimiter;
}
$title .= trim($this->name);
}
/**
* If the title is empty, return a default title
*/
if (trim($title) == '') {
$title = 'zepi Turbo';
}
return $title;
} | php | public function getTitle()
{
$title = '';
/**
* If there is a title, add it to the returned title
*/
if (trim($this->title) != '') {
$title = trim($this->title);
}
/**
* If there is a name of the framework instance, add it to
* the returned title
*/
if (trim($this->name) != '') {
if (trim($title) != '') {
$title .= $this->delimiter;
}
$title .= trim($this->name);
}
/**
* If the title is empty, return a default title
*/
if (trim($title) == '') {
$title = 'zepi Turbo';
}
return $title;
} | [
"public",
"function",
"getTitle",
"(",
")",
"{",
"$",
"title",
"=",
"''",
";",
"/**\n * If there is a title, add it to the returned title\n */",
"if",
"(",
"trim",
"(",
"$",
"this",
"->",
"title",
")",
"!=",
"''",
")",
"{",
"$",
"title",
"=",
"trim",
"(",
"$",
"this",
"->",
"title",
")",
";",
"}",
"/**\n * If there is a name of the framework instance, add it to \n * the returned title\n */",
"if",
"(",
"trim",
"(",
"$",
"this",
"->",
"name",
")",
"!=",
"''",
")",
"{",
"if",
"(",
"trim",
"(",
"$",
"title",
")",
"!=",
"''",
")",
"{",
"$",
"title",
".=",
"$",
"this",
"->",
"delimiter",
";",
"}",
"$",
"title",
".=",
"trim",
"(",
"$",
"this",
"->",
"name",
")",
";",
"}",
"/**\n * If the title is empty, return a default title\n */",
"if",
"(",
"trim",
"(",
"$",
"title",
")",
"==",
"''",
")",
"{",
"$",
"title",
"=",
"'zepi Turbo'",
";",
"}",
"return",
"$",
"title",
";",
"}"
] | Returns the title for the request
@access public
@return string | [
"Returns",
"the",
"title",
"for",
"the",
"request"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Web/General/src/Manager/MetaInformationManager.php#L120-L151 |
4,808 | tux-rampage/rampage-php | library/rampage/core/events/SharedEventManager.php | SharedEventManager.addConfigListeners | protected function addConfigListeners($id, $event)
{
if (isset($this->configuredEvents[$id][$event]) || !$this->canAddConfig || !$this->config) {
return $this;
}
// Disable config load now to avoid being triggerd recursively by inner events
$this->canAddConfig = false;
$this->config->configureEventManager($this, $id, $event);
$this->configuredEvents[$id][$event] = true;
// Add wildcard events if not done, yet
if (!isset($this->configuredEvents[$id]['*'])) {
$this->config->configureEventManager($this, $id, '*');
$this->configuredEvents[$id]['*'] = true;
}
$this->canAddConfig = true;
return $this;
} | php | protected function addConfigListeners($id, $event)
{
if (isset($this->configuredEvents[$id][$event]) || !$this->canAddConfig || !$this->config) {
return $this;
}
// Disable config load now to avoid being triggerd recursively by inner events
$this->canAddConfig = false;
$this->config->configureEventManager($this, $id, $event);
$this->configuredEvents[$id][$event] = true;
// Add wildcard events if not done, yet
if (!isset($this->configuredEvents[$id]['*'])) {
$this->config->configureEventManager($this, $id, '*');
$this->configuredEvents[$id]['*'] = true;
}
$this->canAddConfig = true;
return $this;
} | [
"protected",
"function",
"addConfigListeners",
"(",
"$",
"id",
",",
"$",
"event",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"configuredEvents",
"[",
"$",
"id",
"]",
"[",
"$",
"event",
"]",
")",
"||",
"!",
"$",
"this",
"->",
"canAddConfig",
"||",
"!",
"$",
"this",
"->",
"config",
")",
"{",
"return",
"$",
"this",
";",
"}",
"// Disable config load now to avoid being triggerd recursively by inner events",
"$",
"this",
"->",
"canAddConfig",
"=",
"false",
";",
"$",
"this",
"->",
"config",
"->",
"configureEventManager",
"(",
"$",
"this",
",",
"$",
"id",
",",
"$",
"event",
")",
";",
"$",
"this",
"->",
"configuredEvents",
"[",
"$",
"id",
"]",
"[",
"$",
"event",
"]",
"=",
"true",
";",
"// Add wildcard events if not done, yet",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"configuredEvents",
"[",
"$",
"id",
"]",
"[",
"'*'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"config",
"->",
"configureEventManager",
"(",
"$",
"this",
",",
"$",
"id",
",",
"'*'",
")",
";",
"$",
"this",
"->",
"configuredEvents",
"[",
"$",
"id",
"]",
"[",
"'*'",
"]",
"=",
"true",
";",
"}",
"$",
"this",
"->",
"canAddConfig",
"=",
"true",
";",
"return",
"$",
"this",
";",
"}"
] | Add config events
@param string $id
@param string $event | [
"Add",
"config",
"events"
] | 1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf | https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/events/SharedEventManager.php#L71-L91 |
4,809 | Fenzland/Htsl.php | libs/Parser/Node/ControlNode.php | ControlNode.close | public function close( Line$closerLine ):string
{
if( isset($this->config['close_by']) && $closerLine->indentLevel==$this->line->indentLevel ){
foreach( $this->config['close_by'] as $key=>$value ){
if( $closerLine->pregMatch($key) ){
return $this->withParam($value);
}
}
}
if( isset($this->config['closer']) )
{ return $this->withParam($this->config['closer']); }
return '';
} | php | public function close( Line$closerLine ):string
{
if( isset($this->config['close_by']) && $closerLine->indentLevel==$this->line->indentLevel ){
foreach( $this->config['close_by'] as $key=>$value ){
if( $closerLine->pregMatch($key) ){
return $this->withParam($value);
}
}
}
if( isset($this->config['closer']) )
{ return $this->withParam($this->config['closer']); }
return '';
} | [
"public",
"function",
"close",
"(",
"Line",
"$",
"closerLine",
")",
":",
"string",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'close_by'",
"]",
")",
"&&",
"$",
"closerLine",
"->",
"indentLevel",
"==",
"$",
"this",
"->",
"line",
"->",
"indentLevel",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"config",
"[",
"'close_by'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"closerLine",
"->",
"pregMatch",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"withParam",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"config",
"[",
"'closer'",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"withParam",
"(",
"$",
"this",
"->",
"config",
"[",
"'closer'",
"]",
")",
";",
"}",
"return",
"''",
";",
"}"
] | Close this control node, and returning node closer.
@access public
@param \Htsl\ReadingBuffer\Line $closerLine The line when node closed.
@return string | [
"Close",
"this",
"control",
"node",
"and",
"returning",
"node",
"closer",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/ControlNode.php#L106-L120 |
4,810 | Fenzland/Htsl.php | libs/Parser/Node/ControlNode.php | ControlNode.withParam | private function withParam( string$input )
{
return str_replace('$_FLAG_$',"__HTSL_CTRL_FLAG_{$this->id}__",preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/',function( array$matches ){
$param= $this->param;
if( isset($matches[1]) ){
array_map(...[
function($replacer)use(&$param){
list($pattern,$replacement,)= preg_split('/(?<!\\\\)\\//',$replacer);
$param= preg_replace(...[
"/$pattern/",
preg_replace('/^\\\\_$/','',$replacement),
$param,
]);
},
preg_split(
'/(?<!\\\\)\\/\\//'
,
trim($matches[1],'/')
),
]);
}
return $param;
},$input));
} | php | private function withParam( string$input )
{
return str_replace('$_FLAG_$',"__HTSL_CTRL_FLAG_{$this->id}__",preg_replace_callback('/(?<!%)%s((?:\\/.+?(?<!\\\\)\\/.+?(?<!\\\\)\\/)+)?/',function( array$matches ){
$param= $this->param;
if( isset($matches[1]) ){
array_map(...[
function($replacer)use(&$param){
list($pattern,$replacement,)= preg_split('/(?<!\\\\)\\//',$replacer);
$param= preg_replace(...[
"/$pattern/",
preg_replace('/^\\\\_$/','',$replacement),
$param,
]);
},
preg_split(
'/(?<!\\\\)\\/\\//'
,
trim($matches[1],'/')
),
]);
}
return $param;
},$input));
} | [
"private",
"function",
"withParam",
"(",
"string",
"$",
"input",
")",
"{",
"return",
"str_replace",
"(",
"'$_FLAG_$'",
",",
"\"__HTSL_CTRL_FLAG_{$this->id}__\"",
",",
"preg_replace_callback",
"(",
"'/(?<!%)%s((?:\\\\/.+?(?<!\\\\\\\\)\\\\/.+?(?<!\\\\\\\\)\\\\/)+)?/'",
",",
"function",
"(",
"array",
"$",
"matches",
")",
"{",
"$",
"param",
"=",
"$",
"this",
"->",
"param",
";",
"if",
"(",
"isset",
"(",
"$",
"matches",
"[",
"1",
"]",
")",
")",
"{",
"array_map",
"(",
"...",
"[",
"function",
"(",
"$",
"replacer",
")",
"use",
"(",
"&",
"$",
"param",
")",
"{",
"list",
"(",
"$",
"pattern",
",",
"$",
"replacement",
",",
")",
"=",
"preg_split",
"(",
"'/(?<!\\\\\\\\)\\\\//'",
",",
"$",
"replacer",
")",
";",
"$",
"param",
"=",
"preg_replace",
"(",
"...",
"[",
"\"/$pattern/\"",
",",
"preg_replace",
"(",
"'/^\\\\\\\\_$/'",
",",
"''",
",",
"$",
"replacement",
")",
",",
"$",
"param",
",",
"]",
")",
";",
"}",
",",
"preg_split",
"(",
"'/(?<!\\\\\\\\)\\\\/\\\\//'",
",",
"trim",
"(",
"$",
"matches",
"[",
"1",
"]",
",",
"'/'",
")",
")",
",",
"]",
")",
";",
"}",
"return",
"$",
"param",
";",
"}",
",",
"$",
"input",
")",
")",
";",
"}"
] | Parse opener or closer with parameters.
@access private
@param string $input Opener or Closer
@return string | [
"Parse",
"opener",
"or",
"closer",
"with",
"parameters",
"."
] | 28ecc4afd1a5bdb29dea3589c8132adba87f3947 | https://github.com/Fenzland/Htsl.php/blob/28ecc4afd1a5bdb29dea3589c8132adba87f3947/libs/Parser/Node/ControlNode.php#L131-L155 |
4,811 | gearhub/tactician-for-laravel | src/DispatchesCommands.php | DispatchesCommands.dispatchCommandFrom | protected function dispatchCommandFrom($command, ArrayAccess $source, array $extras = [])
{
return app('tactician.dispatcher')->dispatchFrom($command, $source, $extras);
} | php | protected function dispatchCommandFrom($command, ArrayAccess $source, array $extras = [])
{
return app('tactician.dispatcher')->dispatchFrom($command, $source, $extras);
} | [
"protected",
"function",
"dispatchCommandFrom",
"(",
"$",
"command",
",",
"ArrayAccess",
"$",
"source",
",",
"array",
"$",
"extras",
"=",
"[",
"]",
")",
"{",
"return",
"app",
"(",
"'tactician.dispatcher'",
")",
"->",
"dispatchFrom",
"(",
"$",
"command",
",",
"$",
"source",
",",
"$",
"extras",
")",
";",
"}"
] | Marshal a command and dispatch it to its respective handler.
@param mixed $command
@param ArrayAccess $source
@param array $extras
@return mixed | [
"Marshal",
"a",
"command",
"and",
"dispatch",
"it",
"to",
"its",
"respective",
"handler",
"."
] | 417bb3683ceefe636ce1cd16ee03031649c80735 | https://github.com/gearhub/tactician-for-laravel/blob/417bb3683ceefe636ce1cd16ee03031649c80735/src/DispatchesCommands.php#L30-L33 |
4,812 | sgoendoer/json | src/JSONObject.php | JSONObject.remove | public function remove($key)
{
if(array_key_exists($key, $this->map))
{
$tmp = $this->map[$key];
unset($this->map[$key]);
return $tmp;
}
else
return NULL;
} | php | public function remove($key)
{
if(array_key_exists($key, $this->map))
{
$tmp = $this->map[$key];
unset($this->map[$key]);
return $tmp;
}
else
return NULL;
} | [
"public",
"function",
"remove",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"map",
")",
")",
"{",
"$",
"tmp",
"=",
"$",
"this",
"->",
"map",
"[",
"$",
"key",
"]",
";",
"unset",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"key",
"]",
")",
";",
"return",
"$",
"tmp",
";",
"}",
"else",
"return",
"NULL",
";",
"}"
] | Remove a name and its value, if present.
@param key The name to be removed.
@return The value that was associated with the name, or null if there was no value. | [
"Remove",
"a",
"name",
"and",
"its",
"value",
"if",
"present",
"."
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONObject.php#L259-L269 |
4,813 | sgoendoer/json | src/JSONObject.php | JSONObject.stringToValue | public static function stringToValue($string)
{
if($string == '')
{
return $string;
}
if(is_float($string))
{
return (float) $string;
}
if(is_int($string))
{
return (int) $string;
}
if(strtolower($string) == 'true')
{
return true;
}
if(strtolower($string) == 'false')
{
return false;
}
if(strtolower($string) == 'null')
{
return NULL;
}
return $string;
} | php | public static function stringToValue($string)
{
if($string == '')
{
return $string;
}
if(is_float($string))
{
return (float) $string;
}
if(is_int($string))
{
return (int) $string;
}
if(strtolower($string) == 'true')
{
return true;
}
if(strtolower($string) == 'false')
{
return false;
}
if(strtolower($string) == 'null')
{
return NULL;
}
return $string;
} | [
"public",
"static",
"function",
"stringToValue",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"$",
"string",
"==",
"''",
")",
"{",
"return",
"$",
"string",
";",
"}",
"if",
"(",
"is_float",
"(",
"$",
"string",
")",
")",
"{",
"return",
"(",
"float",
")",
"$",
"string",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"string",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"string",
";",
"}",
"if",
"(",
"strtolower",
"(",
"$",
"string",
")",
"==",
"'true'",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"strtolower",
"(",
"$",
"string",
")",
"==",
"'false'",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"strtolower",
"(",
"$",
"string",
")",
"==",
"'null'",
")",
"{",
"return",
"NULL",
";",
"}",
"return",
"$",
"string",
";",
"}"
] | Try to convert a string into a number, boolean, or null. If the string can't be converted, return the string.
@param string A String.
@return A simple JSON value. | [
"Try",
"to",
"convert",
"a",
"string",
"into",
"a",
"number",
"boolean",
"or",
"null",
".",
"If",
"the",
"string",
"can",
"t",
"be",
"converted",
"return",
"the",
"string",
"."
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONObject.php#L304-L332 |
4,814 | sgoendoer/json | src/JSONObject.php | JSONObject.isAssoc | private static function isAssoc($value)
{
if(!is_array($value)) return false;
return array_keys($value) !== range(0, count($value) - 1);
} | php | private static function isAssoc($value)
{
if(!is_array($value)) return false;
return array_keys($value) !== range(0, count($value) - 1);
} | [
"private",
"static",
"function",
"isAssoc",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"return",
"false",
";",
"return",
"array_keys",
"(",
"$",
"value",
")",
"!==",
"range",
"(",
"0",
",",
"count",
"(",
"$",
"value",
")",
"-",
"1",
")",
";",
"}"
] | Determines if an value is an associative array
@param $value The value to check
@return true, if the value is an associative array, else false | [
"Determines",
"if",
"an",
"value",
"is",
"an",
"associative",
"array"
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONObject.php#L384-L388 |
4,815 | sgoendoer/json | src/JSONObject.php | JSONObject.numberToString | public static function numberToString($number = NULL)
{
if($number === NULL)
{
throw new JSONException('Null pointer');
}
self::testValidity($number);
// Shave off trailing zeros and decimal point, if possible.
$number = (string) $number;
if(strpos($number, '.') > 0 && strpos($number, 'e') < 0 && strpos($number, 'E') < 0)
{
while(substr($number, -1) == '0')
{
$number = substr(0, strlen($number) - 1);
}
if(substr($number, -1) == '.')
{
$number = substr(0, strlen($number) - 1);
}
}
return $number;
} | php | public static function numberToString($number = NULL)
{
if($number === NULL)
{
throw new JSONException('Null pointer');
}
self::testValidity($number);
// Shave off trailing zeros and decimal point, if possible.
$number = (string) $number;
if(strpos($number, '.') > 0 && strpos($number, 'e') < 0 && strpos($number, 'E') < 0)
{
while(substr($number, -1) == '0')
{
$number = substr(0, strlen($number) - 1);
}
if(substr($number, -1) == '.')
{
$number = substr(0, strlen($number) - 1);
}
}
return $number;
} | [
"public",
"static",
"function",
"numberToString",
"(",
"$",
"number",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"number",
"===",
"NULL",
")",
"{",
"throw",
"new",
"JSONException",
"(",
"'Null pointer'",
")",
";",
"}",
"self",
"::",
"testValidity",
"(",
"$",
"number",
")",
";",
"// Shave off trailing zeros and decimal point, if possible.",
"$",
"number",
"=",
"(",
"string",
")",
"$",
"number",
";",
"if",
"(",
"strpos",
"(",
"$",
"number",
",",
"'.'",
")",
">",
"0",
"&&",
"strpos",
"(",
"$",
"number",
",",
"'e'",
")",
"<",
"0",
"&&",
"strpos",
"(",
"$",
"number",
",",
"'E'",
")",
"<",
"0",
")",
"{",
"while",
"(",
"substr",
"(",
"$",
"number",
",",
"-",
"1",
")",
"==",
"'0'",
")",
"{",
"$",
"number",
"=",
"substr",
"(",
"0",
",",
"strlen",
"(",
"$",
"number",
")",
"-",
"1",
")",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"number",
",",
"-",
"1",
")",
"==",
"'.'",
")",
"{",
"$",
"number",
"=",
"substr",
"(",
"0",
",",
"strlen",
"(",
"$",
"number",
")",
"-",
"1",
")",
";",
"}",
"}",
"return",
"$",
"number",
";",
"}"
] | Produce a string from a number.
@param number A number
@return A string.
@throws JSONException If $number is a non-finite number. | [
"Produce",
"a",
"string",
"from",
"a",
"number",
"."
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONObject.php#L397-L422 |
4,816 | sgoendoer/json | src/JSONObject.php | JSONObject.toJSONArray | public function toJSONArray($names = NULL)
{
if($names == NULL || count($names) == 0)
{
return NULL;
}
$ja = new JSONArray();
foreach($this->map as $key => $value)
{
$ja->put($this->opt($key));
}
return $ja;
} | php | public function toJSONArray($names = NULL)
{
if($names == NULL || count($names) == 0)
{
return NULL;
}
$ja = new JSONArray();
foreach($this->map as $key => $value)
{
$ja->put($this->opt($key));
}
return $ja;
} | [
"public",
"function",
"toJSONArray",
"(",
"$",
"names",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"names",
"==",
"NULL",
"||",
"count",
"(",
"$",
"names",
")",
"==",
"0",
")",
"{",
"return",
"NULL",
";",
"}",
"$",
"ja",
"=",
"new",
"JSONArray",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"map",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"ja",
"->",
"put",
"(",
"$",
"this",
"->",
"opt",
"(",
"$",
"key",
")",
")",
";",
"}",
"return",
"$",
"ja",
";",
"}"
] | Produce a JSONArray containing the values of the members of this JSONObject.
@param $names An array containing a list of key strings. This determines the sequence of the values in the result.
@return A JSONArray of values. | [
"Produce",
"a",
"JSONArray",
"containing",
"the",
"values",
"of",
"the",
"members",
"of",
"this",
"JSONObject",
"."
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONObject.php#L472-L487 |
4,817 | sgoendoer/json | src/JSONObject.php | JSONObject.write | public function write()
{
//var_dump($this->map);die();
$returnstring = '{';
foreach($this->map as $key => $value)
{
$returnstring .= '"' . $key . '":';
if($value instanceof JSONObject || $value instanceof JSONArray)
$returnstring .= $value->write();
elseif(gettype($value) == 'integer' || gettype($value) == 'double')
$returnstring .= $value;
elseif(gettype($value) == 'boolean')
$returnstring .= (($value) ? 'true' : 'false');
elseif(gettype($value) == 'NULL')
$returnstring .= 'null';
elseif(gettype($value) == 'string')
$returnstring .= '"' . $value . '"';
else
throw new JSONException('Invalid type ' . gettype($value));
if($value !== end($this->map)) $returnstring .= ',';
}
$returnstring .= '}';
return $returnstring;
} | php | public function write()
{
//var_dump($this->map);die();
$returnstring = '{';
foreach($this->map as $key => $value)
{
$returnstring .= '"' . $key . '":';
if($value instanceof JSONObject || $value instanceof JSONArray)
$returnstring .= $value->write();
elseif(gettype($value) == 'integer' || gettype($value) == 'double')
$returnstring .= $value;
elseif(gettype($value) == 'boolean')
$returnstring .= (($value) ? 'true' : 'false');
elseif(gettype($value) == 'NULL')
$returnstring .= 'null';
elseif(gettype($value) == 'string')
$returnstring .= '"' . $value . '"';
else
throw new JSONException('Invalid type ' . gettype($value));
if($value !== end($this->map)) $returnstring .= ',';
}
$returnstring .= '}';
return $returnstring;
} | [
"public",
"function",
"write",
"(",
")",
"{",
"//var_dump($this->map);die();",
"$",
"returnstring",
"=",
"'{'",
";",
"foreach",
"(",
"$",
"this",
"->",
"map",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"returnstring",
".=",
"'\"'",
".",
"$",
"key",
".",
"'\":'",
";",
"if",
"(",
"$",
"value",
"instanceof",
"JSONObject",
"||",
"$",
"value",
"instanceof",
"JSONArray",
")",
"$",
"returnstring",
".=",
"$",
"value",
"->",
"write",
"(",
")",
";",
"elseif",
"(",
"gettype",
"(",
"$",
"value",
")",
"==",
"'integer'",
"||",
"gettype",
"(",
"$",
"value",
")",
"==",
"'double'",
")",
"$",
"returnstring",
".=",
"$",
"value",
";",
"elseif",
"(",
"gettype",
"(",
"$",
"value",
")",
"==",
"'boolean'",
")",
"$",
"returnstring",
".=",
"(",
"(",
"$",
"value",
")",
"?",
"'true'",
":",
"'false'",
")",
";",
"elseif",
"(",
"gettype",
"(",
"$",
"value",
")",
"==",
"'NULL'",
")",
"$",
"returnstring",
".=",
"'null'",
";",
"elseif",
"(",
"gettype",
"(",
"$",
"value",
")",
"==",
"'string'",
")",
"$",
"returnstring",
".=",
"'\"'",
".",
"$",
"value",
".",
"'\"'",
";",
"else",
"throw",
"new",
"JSONException",
"(",
"'Invalid type '",
".",
"gettype",
"(",
"$",
"value",
")",
")",
";",
"if",
"(",
"$",
"value",
"!==",
"end",
"(",
"$",
"this",
"->",
"map",
")",
")",
"$",
"returnstring",
".=",
"','",
";",
"}",
"$",
"returnstring",
".=",
"'}'",
";",
"return",
"$",
"returnstring",
";",
"}"
] | Returns the contents of the JSONObject as a JSONString. For compactness, no whitespace is added.
@return string | [
"Returns",
"the",
"contents",
"of",
"the",
"JSONObject",
"as",
"a",
"JSONString",
".",
"For",
"compactness",
"no",
"whitespace",
"is",
"added",
"."
] | 31fb7330d185e6f91bb260c4bf55050982f0bad1 | https://github.com/sgoendoer/json/blob/31fb7330d185e6f91bb260c4bf55050982f0bad1/src/JSONObject.php#L504-L532 |
4,818 | grape-fluid/magic-control | src/MagicTemplate.php | MagicTemplate.render | public function render()
{
$this->latte->setLoader($this->file ? new FileLoader() : new StringLoader());
$this->latte->render($this->file ?: $this->source, $this->params);
} | php | public function render()
{
$this->latte->setLoader($this->file ? new FileLoader() : new StringLoader());
$this->latte->render($this->file ?: $this->source, $this->params);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"latte",
"->",
"setLoader",
"(",
"$",
"this",
"->",
"file",
"?",
"new",
"FileLoader",
"(",
")",
":",
"new",
"StringLoader",
"(",
")",
")",
";",
"$",
"this",
"->",
"latte",
"->",
"render",
"(",
"$",
"this",
"->",
"file",
"?",
":",
"$",
"this",
"->",
"source",
",",
"$",
"this",
"->",
"params",
")",
";",
"}"
] | Renders template to output.
@return void | [
"Renders",
"template",
"to",
"output",
"."
] | 4f4c1e631d762c187fc58326efaa5a2cf422905e | https://github.com/grape-fluid/magic-control/blob/4f4c1e631d762c187fc58326efaa5a2cf422905e/src/MagicTemplate.php#L65-L69 |
4,819 | digipolisgent/openbib-id-api | src/Value/UserActivities/UserActivities.php | UserActivities.fromXml | public static function fromXml(\DOMDocument $xml)
{
$static = new static();
$loans = $xml->getElementsByTagName('loan');
$static->loans = LoanCollection::fromXml($loans);
$loanHistory = $xml->getElementsByTagName('loanHistory');
$static->loanHistory = LoanCollection::fromXml($loanHistory);
$holds = $xml->getElementsByTagName('hold');
$static->holds = HoldCollection::fromXml($holds);
$expenses = $xml->getElementsByTagName('fine');
$static->expenses = ExpenseCollection::fromXml($expenses);
$totalFine = $xml->getElementsByTagName('totalFine');
$static->totalFine = FloatLiteral::fromXml($totalFine);
$totalCost = $xml->getElementsByTagName('totalCost');
$static->totalCost = FloatLiteral::fromXml($totalCost);
$message = $xml->getElementsByTagName('message');
$static->message = StringLiteral::fromXml($message);
$loanHistoryConfig = $xml->getElementsByTagName('loanHistoryConfigurable');
$static->loanHistoryConfigurable = BoolLiteral::fromXml($loanHistoryConfig);
return $static;
} | php | public static function fromXml(\DOMDocument $xml)
{
$static = new static();
$loans = $xml->getElementsByTagName('loan');
$static->loans = LoanCollection::fromXml($loans);
$loanHistory = $xml->getElementsByTagName('loanHistory');
$static->loanHistory = LoanCollection::fromXml($loanHistory);
$holds = $xml->getElementsByTagName('hold');
$static->holds = HoldCollection::fromXml($holds);
$expenses = $xml->getElementsByTagName('fine');
$static->expenses = ExpenseCollection::fromXml($expenses);
$totalFine = $xml->getElementsByTagName('totalFine');
$static->totalFine = FloatLiteral::fromXml($totalFine);
$totalCost = $xml->getElementsByTagName('totalCost');
$static->totalCost = FloatLiteral::fromXml($totalCost);
$message = $xml->getElementsByTagName('message');
$static->message = StringLiteral::fromXml($message);
$loanHistoryConfig = $xml->getElementsByTagName('loanHistoryConfigurable');
$static->loanHistoryConfigurable = BoolLiteral::fromXml($loanHistoryConfig);
return $static;
} | [
"public",
"static",
"function",
"fromXml",
"(",
"\\",
"DOMDocument",
"$",
"xml",
")",
"{",
"$",
"static",
"=",
"new",
"static",
"(",
")",
";",
"$",
"loans",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'loan'",
")",
";",
"$",
"static",
"->",
"loans",
"=",
"LoanCollection",
"::",
"fromXml",
"(",
"$",
"loans",
")",
";",
"$",
"loanHistory",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'loanHistory'",
")",
";",
"$",
"static",
"->",
"loanHistory",
"=",
"LoanCollection",
"::",
"fromXml",
"(",
"$",
"loanHistory",
")",
";",
"$",
"holds",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'hold'",
")",
";",
"$",
"static",
"->",
"holds",
"=",
"HoldCollection",
"::",
"fromXml",
"(",
"$",
"holds",
")",
";",
"$",
"expenses",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'fine'",
")",
";",
"$",
"static",
"->",
"expenses",
"=",
"ExpenseCollection",
"::",
"fromXml",
"(",
"$",
"expenses",
")",
";",
"$",
"totalFine",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'totalFine'",
")",
";",
"$",
"static",
"->",
"totalFine",
"=",
"FloatLiteral",
"::",
"fromXml",
"(",
"$",
"totalFine",
")",
";",
"$",
"totalCost",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'totalCost'",
")",
";",
"$",
"static",
"->",
"totalCost",
"=",
"FloatLiteral",
"::",
"fromXml",
"(",
"$",
"totalCost",
")",
";",
"$",
"message",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'message'",
")",
";",
"$",
"static",
"->",
"message",
"=",
"StringLiteral",
"::",
"fromXml",
"(",
"$",
"message",
")",
";",
"$",
"loanHistoryConfig",
"=",
"$",
"xml",
"->",
"getElementsByTagName",
"(",
"'loanHistoryConfigurable'",
")",
";",
"$",
"static",
"->",
"loanHistoryConfigurable",
"=",
"BoolLiteral",
"::",
"fromXml",
"(",
"$",
"loanHistoryConfig",
")",
";",
"return",
"$",
"static",
";",
"}"
] | Builds a UserActivities object from XML.
@param \DomDocument $xml
The xml tree containing the user activities.
@return UserActivities
A UserActivities object. | [
"Builds",
"a",
"UserActivities",
"object",
"from",
"XML",
"."
] | 79f58dec53a91f44333d10fa4ef79f85f31fc2de | https://github.com/digipolisgent/openbib-id-api/blob/79f58dec53a91f44333d10fa4ef79f85f31fc2de/src/Value/UserActivities/UserActivities.php#L85-L114 |
4,820 | phPoirot/Storage | src/PdoStore.php | PdoStore.givePdo | function givePdo(\PDO $conn)
{
if ($this->pdo)
throw new exImmutable;
$this->pdo = $conn;
return $this;
} | php | function givePdo(\PDO $conn)
{
if ($this->pdo)
throw new exImmutable;
$this->pdo = $conn;
return $this;
} | [
"function",
"givePdo",
"(",
"\\",
"PDO",
"$",
"conn",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"pdo",
")",
"throw",
"new",
"exImmutable",
";",
"$",
"this",
"->",
"pdo",
"=",
"$",
"conn",
";",
"return",
"$",
"this",
";",
"}"
] | Set PDO Instance
@param \PDO $conn
@return $this | [
"Set",
"PDO",
"Instance"
] | a942de2f1c4245f5cb564c6a32ec619e4ab63d40 | https://github.com/phPoirot/Storage/blob/a942de2f1c4245f5cb564c6a32ec619e4ab63d40/src/PdoStore.php#L320-L328 |
4,821 | SysCodeSoft/Sofi-HTTP-Message | src/UploadedFile.php | UploadedFile.createFromGlobals | public static function createFromGlobals(array $globals)
{
$env = new \Sofi\Base\Collection($globals);
if (is_array($env['slim.files']) && $env->has('slim.files')) {
return $env['slim.files'];
} elseif (isset($_FILES)) {
return static::parseUploadedFiles($_FILES);
}
return [];
} | php | public static function createFromGlobals(array $globals)
{
$env = new \Sofi\Base\Collection($globals);
if (is_array($env['slim.files']) && $env->has('slim.files')) {
return $env['slim.files'];
} elseif (isset($_FILES)) {
return static::parseUploadedFiles($_FILES);
}
return [];
} | [
"public",
"static",
"function",
"createFromGlobals",
"(",
"array",
"$",
"globals",
")",
"{",
"$",
"env",
"=",
"new",
"\\",
"Sofi",
"\\",
"Base",
"\\",
"Collection",
"(",
"$",
"globals",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"env",
"[",
"'slim.files'",
"]",
")",
"&&",
"$",
"env",
"->",
"has",
"(",
"'slim.files'",
")",
")",
"{",
"return",
"$",
"env",
"[",
"'slim.files'",
"]",
";",
"}",
"elseif",
"(",
"isset",
"(",
"$",
"_FILES",
")",
")",
"{",
"return",
"static",
"::",
"parseUploadedFiles",
"(",
"$",
"_FILES",
")",
";",
"}",
"return",
"[",
"]",
";",
"}"
] | Create a normalized tree of UploadedFile instances from global server variables.
@param array $globals The global server variables.
@return array|null A normalized tree of UploadedFile instances or null if none are provided. | [
"Create",
"a",
"normalized",
"tree",
"of",
"UploadedFile",
"instances",
"from",
"global",
"server",
"variables",
"."
] | dd2161d117d15268641310b0092479b714a46651 | https://github.com/SysCodeSoft/Sofi-HTTP-Message/blob/dd2161d117d15268641310b0092479b714a46651/src/UploadedFile.php#L74-L83 |
4,822 | tmquang6805/phalex | library/Phalex/Config/Config.php | Config.getConfig | public function getConfig()
{
if ($this->cache instanceof Cache\CacheInterface && !empty($configs = $this->cache->getConfig())) {
return $configs;
}
$configs = $this->moduleHandler->getModulesConfig();
foreach ($this->files as $file) {
$config = require $file;
if (!is_array($config)) {
throw new Exception\RuntimeException(sprintf('The config in "%s" file must be array data type', $file));
}
$configs = ArrayUtils::merge($configs, require $file);
}
return $this->cleanUp($configs);
} | php | public function getConfig()
{
if ($this->cache instanceof Cache\CacheInterface && !empty($configs = $this->cache->getConfig())) {
return $configs;
}
$configs = $this->moduleHandler->getModulesConfig();
foreach ($this->files as $file) {
$config = require $file;
if (!is_array($config)) {
throw new Exception\RuntimeException(sprintf('The config in "%s" file must be array data type', $file));
}
$configs = ArrayUtils::merge($configs, require $file);
}
return $this->cleanUp($configs);
} | [
"public",
"function",
"getConfig",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cache",
"instanceof",
"Cache",
"\\",
"CacheInterface",
"&&",
"!",
"empty",
"(",
"$",
"configs",
"=",
"$",
"this",
"->",
"cache",
"->",
"getConfig",
"(",
")",
")",
")",
"{",
"return",
"$",
"configs",
";",
"}",
"$",
"configs",
"=",
"$",
"this",
"->",
"moduleHandler",
"->",
"getModulesConfig",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"config",
"=",
"require",
"$",
"file",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"config",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"'The config in \"%s\" file must be array data type'",
",",
"$",
"file",
")",
")",
";",
"}",
"$",
"configs",
"=",
"ArrayUtils",
"::",
"merge",
"(",
"$",
"configs",
",",
"require",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
"->",
"cleanUp",
"(",
"$",
"configs",
")",
";",
"}"
] | Get entire configurations in application and modules
@return array | [
"Get",
"entire",
"configurations",
"in",
"application",
"and",
"modules"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Config/Config.php#L56-L72 |
4,823 | tmquang6805/phalex | library/Phalex/Config/Config.php | Config.filterViewPath | protected function filterViewPath($configViewPaths)
{
if (!ArrayUtils::isHashTable($configViewPaths)) {
throw new Exception\InvalidArgumentException('Config view path is not valid');
}
foreach ($configViewPaths as $moduleName => $viewPath) {
$viewPath = realpath($viewPath);
if (!$viewPath) {
$errMsg = sprintf('Config view path for "%s" module is invalid', $moduleName);
throw new Exception\RuntimeException($errMsg);
}
$configViewPaths[$moduleName] = $viewPath;
}
return $configViewPaths;
} | php | protected function filterViewPath($configViewPaths)
{
if (!ArrayUtils::isHashTable($configViewPaths)) {
throw new Exception\InvalidArgumentException('Config view path is not valid');
}
foreach ($configViewPaths as $moduleName => $viewPath) {
$viewPath = realpath($viewPath);
if (!$viewPath) {
$errMsg = sprintf('Config view path for "%s" module is invalid', $moduleName);
throw new Exception\RuntimeException($errMsg);
}
$configViewPaths[$moduleName] = $viewPath;
}
return $configViewPaths;
} | [
"protected",
"function",
"filterViewPath",
"(",
"$",
"configViewPaths",
")",
"{",
"if",
"(",
"!",
"ArrayUtils",
"::",
"isHashTable",
"(",
"$",
"configViewPaths",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidArgumentException",
"(",
"'Config view path is not valid'",
")",
";",
"}",
"foreach",
"(",
"$",
"configViewPaths",
"as",
"$",
"moduleName",
"=>",
"$",
"viewPath",
")",
"{",
"$",
"viewPath",
"=",
"realpath",
"(",
"$",
"viewPath",
")",
";",
"if",
"(",
"!",
"$",
"viewPath",
")",
"{",
"$",
"errMsg",
"=",
"sprintf",
"(",
"'Config view path for \"%s\" module is invalid'",
",",
"$",
"moduleName",
")",
";",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"$",
"errMsg",
")",
";",
"}",
"$",
"configViewPaths",
"[",
"$",
"moduleName",
"]",
"=",
"$",
"viewPath",
";",
"}",
"return",
"$",
"configViewPaths",
";",
"}"
] | Get real path for view path configs
@param array $configViewPaths
@return array
@throws Exception\InvalidArgumentException
@throws Exception\RuntimeException | [
"Get",
"real",
"path",
"for",
"view",
"path",
"configs"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Config/Config.php#L81-L96 |
4,824 | tmquang6805/phalex | library/Phalex/Config/Config.php | Config.filterVoltPath | protected function filterVoltPath($configVolt)
{
foreach ($configVolt as $moduleName => $config) {
$path = false;
if (isset($config['path'])) {
unset($configVolt[$moduleName]['path']);
$path = realpath($config['path']);
}
if ($path) {
$configVolt[$moduleName]['path'] = $path;
}
}
return $configVolt;
} | php | protected function filterVoltPath($configVolt)
{
foreach ($configVolt as $moduleName => $config) {
$path = false;
if (isset($config['path'])) {
unset($configVolt[$moduleName]['path']);
$path = realpath($config['path']);
}
if ($path) {
$configVolt[$moduleName]['path'] = $path;
}
}
return $configVolt;
} | [
"protected",
"function",
"filterVoltPath",
"(",
"$",
"configVolt",
")",
"{",
"foreach",
"(",
"$",
"configVolt",
"as",
"$",
"moduleName",
"=>",
"$",
"config",
")",
"{",
"$",
"path",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'path'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"configVolt",
"[",
"$",
"moduleName",
"]",
"[",
"'path'",
"]",
")",
";",
"$",
"path",
"=",
"realpath",
"(",
"$",
"config",
"[",
"'path'",
"]",
")",
";",
"}",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"configVolt",
"[",
"$",
"moduleName",
"]",
"[",
"'path'",
"]",
"=",
"$",
"path",
";",
"}",
"}",
"return",
"$",
"configVolt",
";",
"}"
] | Filter config volt template engine
@param array $configVolt
@return array
@throws Exception\InvalidArgumentException | [
"Filter",
"config",
"volt",
"template",
"engine"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Config/Config.php#L104-L117 |
4,825 | tmquang6805/phalex | library/Phalex/Config/Config.php | Config.cleanUp | protected function cleanUp(array $configs)
{
$configs['view'] = !isset($configs['view']) ? [] : $this->filterViewPath($configs['view']);
$configs['volt'] = !isset($configs['volt']) ? [] : $this->filterVoltPath($configs['volt']);
if ($this->cache instanceof Cache\CacheInterface) {
$this->cache->setConfig($configs);
}
return $configs;
} | php | protected function cleanUp(array $configs)
{
$configs['view'] = !isset($configs['view']) ? [] : $this->filterViewPath($configs['view']);
$configs['volt'] = !isset($configs['volt']) ? [] : $this->filterVoltPath($configs['volt']);
if ($this->cache instanceof Cache\CacheInterface) {
$this->cache->setConfig($configs);
}
return $configs;
} | [
"protected",
"function",
"cleanUp",
"(",
"array",
"$",
"configs",
")",
"{",
"$",
"configs",
"[",
"'view'",
"]",
"=",
"!",
"isset",
"(",
"$",
"configs",
"[",
"'view'",
"]",
")",
"?",
"[",
"]",
":",
"$",
"this",
"->",
"filterViewPath",
"(",
"$",
"configs",
"[",
"'view'",
"]",
")",
";",
"$",
"configs",
"[",
"'volt'",
"]",
"=",
"!",
"isset",
"(",
"$",
"configs",
"[",
"'volt'",
"]",
")",
"?",
"[",
"]",
":",
"$",
"this",
"->",
"filterVoltPath",
"(",
"$",
"configs",
"[",
"'volt'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"instanceof",
"Cache",
"\\",
"CacheInterface",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"setConfig",
"(",
"$",
"configs",
")",
";",
"}",
"return",
"$",
"configs",
";",
"}"
] | Clean up entire application config
@param array $configs
@return array | [
"Clean",
"up",
"entire",
"application",
"config"
] | 6452b4e695b456838d9d553d96f2b114e1c110b4 | https://github.com/tmquang6805/phalex/blob/6452b4e695b456838d9d553d96f2b114e1c110b4/library/Phalex/Config/Config.php#L124-L132 |
4,826 | spiral/validation | src/Checker/StringChecker.php | StringChecker.regexp | public function regexp($value, string $expression): bool
{
return is_string($value) && preg_match($expression, $value);
} | php | public function regexp($value, string $expression): bool
{
return is_string($value) && preg_match($expression, $value);
} | [
"public",
"function",
"regexp",
"(",
"$",
"value",
",",
"string",
"$",
"expression",
")",
":",
"bool",
"{",
"return",
"is_string",
"(",
"$",
"value",
")",
"&&",
"preg_match",
"(",
"$",
"expression",
",",
"$",
"value",
")",
";",
"}"
] | Check string using regexp.
@param mixed $value
@param string $expression
@return bool | [
"Check",
"string",
"using",
"regexp",
"."
] | aa8977dfe93904acfcce354e000d7d384579e2e3 | https://github.com/spiral/validation/blob/aa8977dfe93904acfcce354e000d7d384579e2e3/src/Checker/StringChecker.php#L39-L42 |
4,827 | spiral/validation | src/Checker/StringChecker.php | StringChecker.shorter | public function shorter($value, int $length): bool
{
return is_string($value) && mb_strlen(trim($value)) <= $length;
} | php | public function shorter($value, int $length): bool
{
return is_string($value) && mb_strlen(trim($value)) <= $length;
} | [
"public",
"function",
"shorter",
"(",
"$",
"value",
",",
"int",
"$",
"length",
")",
":",
"bool",
"{",
"return",
"is_string",
"(",
"$",
"value",
")",
"&&",
"mb_strlen",
"(",
"trim",
"(",
"$",
"value",
")",
")",
"<=",
"$",
"length",
";",
"}"
] | Check if string length is shorter or equal that specified value.
@param string $value
@param int $length
@return bool | [
"Check",
"if",
"string",
"length",
"is",
"shorter",
"or",
"equal",
"that",
"specified",
"value",
"."
] | aa8977dfe93904acfcce354e000d7d384579e2e3 | https://github.com/spiral/validation/blob/aa8977dfe93904acfcce354e000d7d384579e2e3/src/Checker/StringChecker.php#L52-L55 |
4,828 | spiral/validation | src/Checker/StringChecker.php | StringChecker.range | public function range($value, int $min, int $max): bool
{
return is_string($value)
&& (mb_strlen($trimmed = trim($value)) >= $min)
&& (mb_strlen($trimmed) <= $max);
} | php | public function range($value, int $min, int $max): bool
{
return is_string($value)
&& (mb_strlen($trimmed = trim($value)) >= $min)
&& (mb_strlen($trimmed) <= $max);
} | [
"public",
"function",
"range",
"(",
"$",
"value",
",",
"int",
"$",
"min",
",",
"int",
"$",
"max",
")",
":",
"bool",
"{",
"return",
"is_string",
"(",
"$",
"value",
")",
"&&",
"(",
"mb_strlen",
"(",
"$",
"trimmed",
"=",
"trim",
"(",
"$",
"value",
")",
")",
">=",
"$",
"min",
")",
"&&",
"(",
"mb_strlen",
"(",
"$",
"trimmed",
")",
"<=",
"$",
"max",
")",
";",
"}"
] | Check if string length are fits in specified range.
@param mixed $value
@param int $min
@param int $max
@return bool | [
"Check",
"if",
"string",
"length",
"are",
"fits",
"in",
"specified",
"range",
"."
] | aa8977dfe93904acfcce354e000d7d384579e2e3 | https://github.com/spiral/validation/blob/aa8977dfe93904acfcce354e000d7d384579e2e3/src/Checker/StringChecker.php#L92-L97 |
4,829 | flancer32/php_data_object | src/Data/TMain.php | TMain._getByPath | public function _getByPath($path)
{
$result = null;
$steps = $this->_pathAsArray($path);
$depth = count($steps); // number of steps in the path
if ($depth == 0) {
$result = $this->data;
} else {
$pointer = $this->data;
$level = 0;
foreach ($steps as $step) {
if (is_array($pointer)) {
if (isset($pointer[$step])) {
/* go to the next step */
$pointer = $pointer[$step];
} else {
/* next step is missed in the path, return null */
break;
}
} elseif ($pointer instanceof \Flancer32\Lib\Data) {
if (!is_null($pointer->get($step))) {
/* go to the next step */
$pointer = $pointer->get($step);
} else {
/* next step is missed in the path, return null */
break;
}
} elseif (is_object($pointer)) {
if (isset($pointer->$step)) {
/* go to the next step */
$pointer = $pointer->$step;
} else {
/* next step is missed in the path, return null */
break;
}
} else {
/* we have no data for the next step */
break;
}
$level++; // one step on the path is done
}
if ($level >= $depth) {
/* we have reached the end of path */
$result = $pointer;
}
}
return $result;
} | php | public function _getByPath($path)
{
$result = null;
$steps = $this->_pathAsArray($path);
$depth = count($steps); // number of steps in the path
if ($depth == 0) {
$result = $this->data;
} else {
$pointer = $this->data;
$level = 0;
foreach ($steps as $step) {
if (is_array($pointer)) {
if (isset($pointer[$step])) {
/* go to the next step */
$pointer = $pointer[$step];
} else {
/* next step is missed in the path, return null */
break;
}
} elseif ($pointer instanceof \Flancer32\Lib\Data) {
if (!is_null($pointer->get($step))) {
/* go to the next step */
$pointer = $pointer->get($step);
} else {
/* next step is missed in the path, return null */
break;
}
} elseif (is_object($pointer)) {
if (isset($pointer->$step)) {
/* go to the next step */
$pointer = $pointer->$step;
} else {
/* next step is missed in the path, return null */
break;
}
} else {
/* we have no data for the next step */
break;
}
$level++; // one step on the path is done
}
if ($level >= $depth) {
/* we have reached the end of path */
$result = $pointer;
}
}
return $result;
} | [
"public",
"function",
"_getByPath",
"(",
"$",
"path",
")",
"{",
"$",
"result",
"=",
"null",
";",
"$",
"steps",
"=",
"$",
"this",
"->",
"_pathAsArray",
"(",
"$",
"path",
")",
";",
"$",
"depth",
"=",
"count",
"(",
"$",
"steps",
")",
";",
"// number of steps in the path",
"if",
"(",
"$",
"depth",
"==",
"0",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"data",
";",
"}",
"else",
"{",
"$",
"pointer",
"=",
"$",
"this",
"->",
"data",
";",
"$",
"level",
"=",
"0",
";",
"foreach",
"(",
"$",
"steps",
"as",
"$",
"step",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"pointer",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"pointer",
"[",
"$",
"step",
"]",
")",
")",
"{",
"/* go to the next step */",
"$",
"pointer",
"=",
"$",
"pointer",
"[",
"$",
"step",
"]",
";",
"}",
"else",
"{",
"/* next step is missed in the path, return null */",
"break",
";",
"}",
"}",
"elseif",
"(",
"$",
"pointer",
"instanceof",
"\\",
"Flancer32",
"\\",
"Lib",
"\\",
"Data",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"pointer",
"->",
"get",
"(",
"$",
"step",
")",
")",
")",
"{",
"/* go to the next step */",
"$",
"pointer",
"=",
"$",
"pointer",
"->",
"get",
"(",
"$",
"step",
")",
";",
"}",
"else",
"{",
"/* next step is missed in the path, return null */",
"break",
";",
"}",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"pointer",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"pointer",
"->",
"$",
"step",
")",
")",
"{",
"/* go to the next step */",
"$",
"pointer",
"=",
"$",
"pointer",
"->",
"$",
"step",
";",
"}",
"else",
"{",
"/* next step is missed in the path, return null */",
"break",
";",
"}",
"}",
"else",
"{",
"/* we have no data for the next step */",
"break",
";",
"}",
"$",
"level",
"++",
";",
"// one step on the path is done",
"}",
"if",
"(",
"$",
"level",
">=",
"$",
"depth",
")",
"{",
"/* we have reached the end of path */",
"$",
"result",
"=",
"$",
"pointer",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Recursive method to get some attribute of the DataObject by path.
@param $path
@return array|\Flancer32\Lib\Data|mixed|null | [
"Recursive",
"method",
"to",
"get",
"some",
"attribute",
"of",
"the",
"DataObject",
"by",
"path",
"."
] | 22d5ad5dda3fb31379bd0014994b9e89551911bf | https://github.com/flancer32/php_data_object/blob/22d5ad5dda3fb31379bd0014994b9e89551911bf/src/Data/TMain.php#L63-L110 |
4,830 | dannyvink/omnipay-komoju | src/Message/PurchaseRequest.php | PurchaseRequest.getData | public function getData()
{
$this->validate('amount', 'currency');
$data = array();
$data['timestamp'] = $this->getTimestamp();
$data['transaction[amount]'] = $this->getAmountInteger();
$data['transaction[cancel_url]'] = $this->getCancelUrl();
$data['transaction[currency]'] = strtoupper($this->getCurrency());
$data['transaction[external_order_num]'] = $this->getTransactionReference();
$data['transaction[return_url]'] = $this->getReturnUrl();
$data['transaction[tax]'] = $this->getTax();
return $data;
} | php | public function getData()
{
$this->validate('amount', 'currency');
$data = array();
$data['timestamp'] = $this->getTimestamp();
$data['transaction[amount]'] = $this->getAmountInteger();
$data['transaction[cancel_url]'] = $this->getCancelUrl();
$data['transaction[currency]'] = strtoupper($this->getCurrency());
$data['transaction[external_order_num]'] = $this->getTransactionReference();
$data['transaction[return_url]'] = $this->getReturnUrl();
$data['transaction[tax]'] = $this->getTax();
return $data;
} | [
"public",
"function",
"getData",
"(",
")",
"{",
"$",
"this",
"->",
"validate",
"(",
"'amount'",
",",
"'currency'",
")",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"data",
"[",
"'timestamp'",
"]",
"=",
"$",
"this",
"->",
"getTimestamp",
"(",
")",
";",
"$",
"data",
"[",
"'transaction[amount]'",
"]",
"=",
"$",
"this",
"->",
"getAmountInteger",
"(",
")",
";",
"$",
"data",
"[",
"'transaction[cancel_url]'",
"]",
"=",
"$",
"this",
"->",
"getCancelUrl",
"(",
")",
";",
"$",
"data",
"[",
"'transaction[currency]'",
"]",
"=",
"strtoupper",
"(",
"$",
"this",
"->",
"getCurrency",
"(",
")",
")",
";",
"$",
"data",
"[",
"'transaction[external_order_num]'",
"]",
"=",
"$",
"this",
"->",
"getTransactionReference",
"(",
")",
";",
"$",
"data",
"[",
"'transaction[return_url]'",
"]",
"=",
"$",
"this",
"->",
"getReturnUrl",
"(",
")",
";",
"$",
"data",
"[",
"'transaction[tax]'",
"]",
"=",
"$",
"this",
"->",
"getTax",
"(",
")",
";",
"return",
"$",
"data",
";",
"}"
] | Assemble the data to send with the request.
@return array | [
"Assemble",
"the",
"data",
"to",
"send",
"with",
"the",
"request",
"."
] | 15eb62abb6b043c93528ea363f0e643e477fb0c7 | https://github.com/dannyvink/omnipay-komoju/blob/15eb62abb6b043c93528ea363f0e643e477fb0c7/src/Message/PurchaseRequest.php#L22-L37 |
4,831 | Puzzlout/FrameworkMvcLegacy | src/Core/ResourceManagers/ResourceBase.php | ResourceBase.GetResourceNamespace | protected function GetResourceNamespace($prefix, $resourceKey) {
$resourceNamespace = $prefix . ucfirst(strtolower($resourceKey)) . "Resx_" . $this->CultureValue;
return $resourceNamespace;
} | php | protected function GetResourceNamespace($prefix, $resourceKey) {
$resourceNamespace = $prefix . ucfirst(strtolower($resourceKey)) . "Resx_" . $this->CultureValue;
return $resourceNamespace;
} | [
"protected",
"function",
"GetResourceNamespace",
"(",
"$",
"prefix",
",",
"$",
"resourceKey",
")",
"{",
"$",
"resourceNamespace",
"=",
"$",
"prefix",
".",
"ucfirst",
"(",
"strtolower",
"(",
"$",
"resourceKey",
")",
")",
".",
"\"Resx_\"",
".",
"$",
"this",
"->",
"CultureValue",
";",
"return",
"$",
"resourceNamespace",
";",
"}"
] | Computes the resource namespace from the context.
@param string $prefix The namespace prefix to the resource class.
@param string $resourceKey The key to build the namespace from.
@return string The resource namespace. | [
"Computes",
"the",
"resource",
"namespace",
"from",
"the",
"context",
"."
] | 14e0fc5b16978cbd209f552ee9c649f66a0dfc6e | https://github.com/Puzzlout/FrameworkMvcLegacy/blob/14e0fc5b16978cbd209f552ee9c649f66a0dfc6e/src/Core/ResourceManagers/ResourceBase.php#L81-L84 |
4,832 | pablodip/PablodipModuleBundle | Controller/ModuleController.php | ModuleController.executeAction | public function executeAction()
{
$moduleClass = $this->get('request')->get('_module.module');
$actionName = $this->get('request')->get('_module.action');
$module = $this->get('module_manager')->get($moduleClass);
foreach ($module->getControllerPreExecutes() as $controllerPreExecute) {
if (null !== $retval = call_user_func($controllerPreExecute, $module)) {
return $retval;
}
}
return $module->getAction($actionName)->executeController();
} | php | public function executeAction()
{
$moduleClass = $this->get('request')->get('_module.module');
$actionName = $this->get('request')->get('_module.action');
$module = $this->get('module_manager')->get($moduleClass);
foreach ($module->getControllerPreExecutes() as $controllerPreExecute) {
if (null !== $retval = call_user_func($controllerPreExecute, $module)) {
return $retval;
}
}
return $module->getAction($actionName)->executeController();
} | [
"public",
"function",
"executeAction",
"(",
")",
"{",
"$",
"moduleClass",
"=",
"$",
"this",
"->",
"get",
"(",
"'request'",
")",
"->",
"get",
"(",
"'_module.module'",
")",
";",
"$",
"actionName",
"=",
"$",
"this",
"->",
"get",
"(",
"'request'",
")",
"->",
"get",
"(",
"'_module.action'",
")",
";",
"$",
"module",
"=",
"$",
"this",
"->",
"get",
"(",
"'module_manager'",
")",
"->",
"get",
"(",
"$",
"moduleClass",
")",
";",
"foreach",
"(",
"$",
"module",
"->",
"getControllerPreExecutes",
"(",
")",
"as",
"$",
"controllerPreExecute",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"retval",
"=",
"call_user_func",
"(",
"$",
"controllerPreExecute",
",",
"$",
"module",
")",
")",
"{",
"return",
"$",
"retval",
";",
"}",
"}",
"return",
"$",
"module",
"->",
"getAction",
"(",
"$",
"actionName",
")",
"->",
"executeController",
"(",
")",
";",
"}"
] | Executes an action. | [
"Executes",
"an",
"action",
"."
] | 6d26df909fa4c57b8b3337d58f8cbecd7781c6ef | https://github.com/pablodip/PablodipModuleBundle/blob/6d26df909fa4c57b8b3337d58f8cbecd7781c6ef/Controller/ModuleController.php#L26-L39 |
4,833 | viktor-melnikov/requester | src/Collection.php | Collection.offsetGet | public function offsetGet($key)
{
$result = array_get($this->items, $key);
if (is_array($result))
return new static($result);
return $result;
} | php | public function offsetGet($key)
{
$result = array_get($this->items, $key);
if (is_array($result))
return new static($result);
return $result;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"key",
")",
"{",
"$",
"result",
"=",
"array_get",
"(",
"$",
"this",
"->",
"items",
",",
"$",
"key",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"result",
")",
")",
"return",
"new",
"static",
"(",
"$",
"result",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Get an item at a given offset using Dot-notation.
@param mixed $key
@return Collection|bool|string | [
"Get",
"an",
"item",
"at",
"a",
"given",
"offset",
"using",
"Dot",
"-",
"notation",
"."
] | e155bc422374ac4a9b32147bbe557f1b6d03e457 | https://github.com/viktor-melnikov/requester/blob/e155bc422374ac4a9b32147bbe557f1b6d03e457/src/Collection.php#L89-L97 |
4,834 | viktor-melnikov/requester | src/Collection.php | Collection.get | public function get($key, $default = null)
{
if ($this->offsetExists($key))
{
return $this->offsetGet($key);
}
return value($default);
} | php | public function get($key, $default = null)
{
if ($this->offsetExists($key))
{
return $this->offsetGet($key);
}
return value($default);
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"key",
")",
";",
"}",
"return",
"value",
"(",
"$",
"default",
")",
";",
"}"
] | Get an item from the collection by key using Dot-notation.
@param mixed $key
@param mixed $default
@return Collection|bool|string|Closure | [
"Get",
"an",
"item",
"from",
"the",
"collection",
"by",
"key",
"using",
"Dot",
"-",
"notation",
"."
] | e155bc422374ac4a9b32147bbe557f1b6d03e457 | https://github.com/viktor-melnikov/requester/blob/e155bc422374ac4a9b32147bbe557f1b6d03e457/src/Collection.php#L106-L114 |
4,835 | remote-office/libx | src/External/SimplePay/Provider.php | Provider.setName | public function setName($name)
{
if(!is_string($name) || strlen(trim($name)) == 0)
throw new InvalidArgumentException(__METHOD__ . '; Invalid name, must be a non empty string');
$this->name = $name;
} | php | public function setName($name)
{
if(!is_string($name) || strlen(trim($name)) == 0)
throw new InvalidArgumentException(__METHOD__ . '; Invalid name, must be a non empty string');
$this->name = $name;
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
"||",
"strlen",
"(",
"trim",
"(",
"$",
"name",
")",
")",
"==",
"0",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"'; Invalid name, must be a non empty string'",
")",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"name",
";",
"}"
] | Set name of this Provider
@param string $name
@return void | [
"Set",
"name",
"of",
"this",
"Provider"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/SimplePay/Provider.php#L81-L87 |
4,836 | remote-office/libx | src/External/SimplePay/Provider.php | Provider.setType | public function setType($type)
{
if(!is_string($type) || strlen(trim($type)) == 0)
throw new InvalidArgumentException(__METHOD__ . '; Invalid type, must be a non empty string');
$this->type = $type;
} | php | public function setType($type)
{
if(!is_string($type) || strlen(trim($type)) == 0)
throw new InvalidArgumentException(__METHOD__ . '; Invalid type, must be a non empty string');
$this->type = $type;
} | [
"public",
"function",
"setType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"type",
")",
"||",
"strlen",
"(",
"trim",
"(",
"$",
"type",
")",
")",
"==",
"0",
")",
"throw",
"new",
"InvalidArgumentException",
"(",
"__METHOD__",
".",
"'; Invalid type, must be a non empty string'",
")",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"type",
";",
"}"
] | Set type of this Provider
@param string $type
@return void | [
"Set",
"type",
"of",
"this",
"Provider"
] | 8baeaae99a6110e7c588bc0388df89a0dc0768b5 | https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/SimplePay/Provider.php#L106-L112 |
4,837 | davidecesarano/Embryo-Logger | Embryo/Log/StreamLogger.php | StreamLogger.log | public function log($level, $message, array $context = [])
{
if (!is_string($level) || !is_string($message)) {
throw new \InvalidArgumentException('Level or message must be a string');
}
$file = $this->logPath.'/'.$level.'.log';
$stream = $this->streamFactory->createStreamFromFile($file, 'a+');
$content = $this->interpolate($message."\n", $context);
$stream->write($content);
} | php | public function log($level, $message, array $context = [])
{
if (!is_string($level) || !is_string($message)) {
throw new \InvalidArgumentException('Level or message must be a string');
}
$file = $this->logPath.'/'.$level.'.log';
$stream = $this->streamFactory->createStreamFromFile($file, 'a+');
$content = $this->interpolate($message."\n", $context);
$stream->write($content);
} | [
"public",
"function",
"log",
"(",
"$",
"level",
",",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"level",
")",
"||",
"!",
"is_string",
"(",
"$",
"message",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Level or message must be a string'",
")",
";",
"}",
"$",
"file",
"=",
"$",
"this",
"->",
"logPath",
".",
"'/'",
".",
"$",
"level",
".",
"'.log'",
";",
"$",
"stream",
"=",
"$",
"this",
"->",
"streamFactory",
"->",
"createStreamFromFile",
"(",
"$",
"file",
",",
"'a+'",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"interpolate",
"(",
"$",
"message",
".",
"\"\\n\"",
",",
"$",
"context",
")",
";",
"$",
"stream",
"->",
"write",
"(",
"$",
"content",
")",
";",
"}"
] | Write log.
@param string $level
@param mixed $message
@param array $context
@return void | [
"Write",
"log",
"."
] | 809036385b986aac3fe55d8aa553373f914b770e | https://github.com/davidecesarano/Embryo-Logger/blob/809036385b986aac3fe55d8aa553373f914b770e/Embryo/Log/StreamLogger.php#L56-L66 |
4,838 | wasabi-cms/cms | src/View/Theme/ThemeManager.php | ThemeManager.loadThemes | public static function loadThemes()
{
$themesFolder = new Folder(ROOT . DS . 'themes');
$themes = $themesFolder->read()[0];
$loader = require ROOT . DS . 'vendor' . DS . 'autoload.php';
foreach ($themes as $theme) {
$loader->addPsr4('WasabiTheme\\' . $theme . '\\', [$themesFolder->path . DS . $theme . DS . 'src']);
Plugin::load('WasabiTheme/' . $theme, [
'path' => $themesFolder->path . DS . $theme . DS,
'bootstrap' => true,
'routes' => false
]);
}
} | php | public static function loadThemes()
{
$themesFolder = new Folder(ROOT . DS . 'themes');
$themes = $themesFolder->read()[0];
$loader = require ROOT . DS . 'vendor' . DS . 'autoload.php';
foreach ($themes as $theme) {
$loader->addPsr4('WasabiTheme\\' . $theme . '\\', [$themesFolder->path . DS . $theme . DS . 'src']);
Plugin::load('WasabiTheme/' . $theme, [
'path' => $themesFolder->path . DS . $theme . DS,
'bootstrap' => true,
'routes' => false
]);
}
} | [
"public",
"static",
"function",
"loadThemes",
"(",
")",
"{",
"$",
"themesFolder",
"=",
"new",
"Folder",
"(",
"ROOT",
".",
"DS",
".",
"'themes'",
")",
";",
"$",
"themes",
"=",
"$",
"themesFolder",
"->",
"read",
"(",
")",
"[",
"0",
"]",
";",
"$",
"loader",
"=",
"require",
"ROOT",
".",
"DS",
".",
"'vendor'",
".",
"DS",
".",
"'autoload.php'",
";",
"foreach",
"(",
"$",
"themes",
"as",
"$",
"theme",
")",
"{",
"$",
"loader",
"->",
"addPsr4",
"(",
"'WasabiTheme\\\\'",
".",
"$",
"theme",
".",
"'\\\\'",
",",
"[",
"$",
"themesFolder",
"->",
"path",
".",
"DS",
".",
"$",
"theme",
".",
"DS",
".",
"'src'",
"]",
")",
";",
"Plugin",
"::",
"load",
"(",
"'WasabiTheme/'",
".",
"$",
"theme",
",",
"[",
"'path'",
"=>",
"$",
"themesFolder",
"->",
"path",
".",
"DS",
".",
"$",
"theme",
".",
"DS",
",",
"'bootstrap'",
"=>",
"true",
",",
"'routes'",
"=>",
"false",
"]",
")",
";",
"}",
"}"
] | Register all available themes in the composer classloader and load them as plugin.
@return void | [
"Register",
"all",
"available",
"themes",
"in",
"the",
"composer",
"classloader",
"and",
"load",
"them",
"as",
"plugin",
"."
] | 2787b6422ea1d719cf49951b3253fd0ac31d22ca | https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/View/Theme/ThemeManager.php#L44-L57 |
4,839 | wasabi-cms/cms | src/View/Theme/ThemeManager.php | ThemeManager.init | public static function init()
{
foreach (self::$_registeredThemes as $registeredTheme) {
$theme = self::_initializeTheme($registeredTheme);
self::$_themes[$theme->id()] = $theme;
}
self::$_initialized = true;
} | php | public static function init()
{
foreach (self::$_registeredThemes as $registeredTheme) {
$theme = self::_initializeTheme($registeredTheme);
self::$_themes[$theme->id()] = $theme;
}
self::$_initialized = true;
} | [
"public",
"static",
"function",
"init",
"(",
")",
"{",
"foreach",
"(",
"self",
"::",
"$",
"_registeredThemes",
"as",
"$",
"registeredTheme",
")",
"{",
"$",
"theme",
"=",
"self",
"::",
"_initializeTheme",
"(",
"$",
"registeredTheme",
")",
";",
"self",
"::",
"$",
"_themes",
"[",
"$",
"theme",
"->",
"id",
"(",
")",
"]",
"=",
"$",
"theme",
";",
"}",
"self",
"::",
"$",
"_initialized",
"=",
"true",
";",
"}"
] | Initialize all available themes.
@return void | [
"Initialize",
"all",
"available",
"themes",
"."
] | 2787b6422ea1d719cf49951b3253fd0ac31d22ca | https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/View/Theme/ThemeManager.php#L80-L88 |
4,840 | wasabi-cms/cms | src/View/Theme/ThemeManager.php | ThemeManager.theme | public static function theme($theme = null)
{
if (!self::$_initialized) {
self::init();
}
if ($theme !== null) {
if (!isset(self::$_themes[$theme])) {
throw new Exception(__d('wasabi_cms', 'Theme "{0}" does not exist.', $theme));
}
self::$_theme = self::$_themes[$theme];
}
return self::$_theme;
} | php | public static function theme($theme = null)
{
if (!self::$_initialized) {
self::init();
}
if ($theme !== null) {
if (!isset(self::$_themes[$theme])) {
throw new Exception(__d('wasabi_cms', 'Theme "{0}" does not exist.', $theme));
}
self::$_theme = self::$_themes[$theme];
}
return self::$_theme;
} | [
"public",
"static",
"function",
"theme",
"(",
"$",
"theme",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_initialized",
")",
"{",
"self",
"::",
"init",
"(",
")",
";",
"}",
"if",
"(",
"$",
"theme",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"_themes",
"[",
"$",
"theme",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__d",
"(",
"'wasabi_cms'",
",",
"'Theme \"{0}\" does not exist.'",
",",
"$",
"theme",
")",
")",
";",
"}",
"self",
"::",
"$",
"_theme",
"=",
"self",
"::",
"$",
"_themes",
"[",
"$",
"theme",
"]",
";",
"}",
"return",
"self",
"::",
"$",
"_theme",
";",
"}"
] | Get or set the currently active theme.
@param string $theme the id of the theme
@return Theme | [
"Get",
"or",
"set",
"the",
"currently",
"active",
"theme",
"."
] | 2787b6422ea1d719cf49951b3253fd0ac31d22ca | https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/View/Theme/ThemeManager.php#L96-L110 |
4,841 | wasabi-cms/cms | src/View/Theme/ThemeManager.php | ThemeManager.getThemesForSelect | public static function getThemesForSelect()
{
if (!self::$_initialized) {
self::init();
}
$results = [];
foreach (self::$_themes as $theme) {
$results[$theme->id()] = $theme->name();
}
return $results;
} | php | public static function getThemesForSelect()
{
if (!self::$_initialized) {
self::init();
}
$results = [];
foreach (self::$_themes as $theme) {
$results[$theme->id()] = $theme->name();
}
return $results;
} | [
"public",
"static",
"function",
"getThemesForSelect",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"_initialized",
")",
"{",
"self",
"::",
"init",
"(",
")",
";",
"}",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"$",
"_themes",
"as",
"$",
"theme",
")",
"{",
"$",
"results",
"[",
"$",
"theme",
"->",
"id",
"(",
")",
"]",
"=",
"$",
"theme",
"->",
"name",
"(",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | Get all themes for a form select input.
@return array | [
"Get",
"all",
"themes",
"for",
"a",
"form",
"select",
"input",
"."
] | 2787b6422ea1d719cf49951b3253fd0ac31d22ca | https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/View/Theme/ThemeManager.php#L117-L129 |
4,842 | wasabi-cms/cms | src/View/Theme/ThemeManager.php | ThemeManager._initializeTheme | protected static function _initializeTheme($registeredTheme)
{
list($theme, $themeName) = pluginSplit($registeredTheme);
$themeNamespace = preg_replace('/\\//', '\\', $theme);
$themeClass = $themeNamespace . '\\' . $themeName;
try {
$theme = new $themeClass();
} catch (Exception $e) {
throw new Exception(__d('wasabi_core', 'The theme "{0}" could not be instatiated. Check the namespace and file location.', $themeClass));
}
return $theme;
} | php | protected static function _initializeTheme($registeredTheme)
{
list($theme, $themeName) = pluginSplit($registeredTheme);
$themeNamespace = preg_replace('/\\//', '\\', $theme);
$themeClass = $themeNamespace . '\\' . $themeName;
try {
$theme = new $themeClass();
} catch (Exception $e) {
throw new Exception(__d('wasabi_core', 'The theme "{0}" could not be instatiated. Check the namespace and file location.', $themeClass));
}
return $theme;
} | [
"protected",
"static",
"function",
"_initializeTheme",
"(",
"$",
"registeredTheme",
")",
"{",
"list",
"(",
"$",
"theme",
",",
"$",
"themeName",
")",
"=",
"pluginSplit",
"(",
"$",
"registeredTheme",
")",
";",
"$",
"themeNamespace",
"=",
"preg_replace",
"(",
"'/\\\\//'",
",",
"'\\\\'",
",",
"$",
"theme",
")",
";",
"$",
"themeClass",
"=",
"$",
"themeNamespace",
".",
"'\\\\'",
".",
"$",
"themeName",
";",
"try",
"{",
"$",
"theme",
"=",
"new",
"$",
"themeClass",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"Exception",
"(",
"__d",
"(",
"'wasabi_core'",
",",
"'The theme \"{0}\" could not be instatiated. Check the namespace and file location.'",
",",
"$",
"themeClass",
")",
")",
";",
"}",
"return",
"$",
"theme",
";",
"}"
] | Initialize a single registered theme.
@param string $registeredTheme
@return Theme | [
"Initialize",
"a",
"single",
"registered",
"theme",
"."
] | 2787b6422ea1d719cf49951b3253fd0ac31d22ca | https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/View/Theme/ThemeManager.php#L137-L150 |
4,843 | tonjoo/tiga-framework | src/App.php | App.loadServiceProvider | private function loadServiceProvider()
{
\Tiga\Framework\Facade\Facade::setFacadeContainer($this);
// Available Provider
$providers = $this['config']->get('provider');
$providers = array_unique($providers);
foreach ($providers as $provider) {
$instance = new $provider($this);
$instance->register();
}
// Aliases
$aliases = $this['config']->get('alias');
$aliases = array_unique($aliases);
$aliasMapper = \Tonjoo\Almari\AliasMapper::getInstance();
$aliasMapper->classAlias($aliases);
} | php | private function loadServiceProvider()
{
\Tiga\Framework\Facade\Facade::setFacadeContainer($this);
// Available Provider
$providers = $this['config']->get('provider');
$providers = array_unique($providers);
foreach ($providers as $provider) {
$instance = new $provider($this);
$instance->register();
}
// Aliases
$aliases = $this['config']->get('alias');
$aliases = array_unique($aliases);
$aliasMapper = \Tonjoo\Almari\AliasMapper::getInstance();
$aliasMapper->classAlias($aliases);
} | [
"private",
"function",
"loadServiceProvider",
"(",
")",
"{",
"\\",
"Tiga",
"\\",
"Framework",
"\\",
"Facade",
"\\",
"Facade",
"::",
"setFacadeContainer",
"(",
"$",
"this",
")",
";",
"// Available Provider",
"$",
"providers",
"=",
"$",
"this",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'provider'",
")",
";",
"$",
"providers",
"=",
"array_unique",
"(",
"$",
"providers",
")",
";",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"provider",
")",
"{",
"$",
"instance",
"=",
"new",
"$",
"provider",
"(",
"$",
"this",
")",
";",
"$",
"instance",
"->",
"register",
"(",
")",
";",
"}",
"// Aliases",
"$",
"aliases",
"=",
"$",
"this",
"[",
"'config'",
"]",
"->",
"get",
"(",
"'alias'",
")",
";",
"$",
"aliases",
"=",
"array_unique",
"(",
"$",
"aliases",
")",
";",
"$",
"aliasMapper",
"=",
"\\",
"Tonjoo",
"\\",
"Almari",
"\\",
"AliasMapper",
"::",
"getInstance",
"(",
")",
";",
"$",
"aliasMapper",
"->",
"classAlias",
"(",
"$",
"aliases",
")",
";",
"}"
] | Load registered service provider in the main plugin and child plugin. | [
"Load",
"registered",
"service",
"provider",
"in",
"the",
"main",
"plugin",
"and",
"child",
"plugin",
"."
] | 3c2eebd3bc616106fa1bba3e43f1791aff75eec5 | https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/App.php#L34-L56 |
4,844 | modulusphp/system | Scheduler.php | Scheduler.removeLogs | private function removeLogs(Schedule $scheduler)
{
$scheduler->call(function () {
$searchDir = Config::$root . 'storage' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR;
$prefix = config('app.logger.name');
$logs = glob($searchDir . $prefix . '-*-*-*.log');
if (count($logs) < 1) return;
foreach($logs as $log) {
$date = str_replace($prefix . '-', '', Filesystem::name($log));
$end = new Carbon($date);
$now = Carbon::now();
if ($now->diffInDays($end) > config('app.logger.keep')) {
try {
Filesystem::delete($log);
} catch (\Exception $e) {
// do nothing...
}
}
}
})->daily();
} | php | private function removeLogs(Schedule $scheduler)
{
$scheduler->call(function () {
$searchDir = Config::$root . 'storage' . DIRECTORY_SEPARATOR . 'logs' . DIRECTORY_SEPARATOR;
$prefix = config('app.logger.name');
$logs = glob($searchDir . $prefix . '-*-*-*.log');
if (count($logs) < 1) return;
foreach($logs as $log) {
$date = str_replace($prefix . '-', '', Filesystem::name($log));
$end = new Carbon($date);
$now = Carbon::now();
if ($now->diffInDays($end) > config('app.logger.keep')) {
try {
Filesystem::delete($log);
} catch (\Exception $e) {
// do nothing...
}
}
}
})->daily();
} | [
"private",
"function",
"removeLogs",
"(",
"Schedule",
"$",
"scheduler",
")",
"{",
"$",
"scheduler",
"->",
"call",
"(",
"function",
"(",
")",
"{",
"$",
"searchDir",
"=",
"Config",
"::",
"$",
"root",
".",
"'storage'",
".",
"DIRECTORY_SEPARATOR",
".",
"'logs'",
".",
"DIRECTORY_SEPARATOR",
";",
"$",
"prefix",
"=",
"config",
"(",
"'app.logger.name'",
")",
";",
"$",
"logs",
"=",
"glob",
"(",
"$",
"searchDir",
".",
"$",
"prefix",
".",
"'-*-*-*.log'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"logs",
")",
"<",
"1",
")",
"return",
";",
"foreach",
"(",
"$",
"logs",
"as",
"$",
"log",
")",
"{",
"$",
"date",
"=",
"str_replace",
"(",
"$",
"prefix",
".",
"'-'",
",",
"''",
",",
"Filesystem",
"::",
"name",
"(",
"$",
"log",
")",
")",
";",
"$",
"end",
"=",
"new",
"Carbon",
"(",
"$",
"date",
")",
";",
"$",
"now",
"=",
"Carbon",
"::",
"now",
"(",
")",
";",
"if",
"(",
"$",
"now",
"->",
"diffInDays",
"(",
"$",
"end",
")",
">",
"config",
"(",
"'app.logger.keep'",
")",
")",
"{",
"try",
"{",
"Filesystem",
"::",
"delete",
"(",
"$",
"log",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"// do nothing...",
"}",
"}",
"}",
"}",
")",
"->",
"daily",
"(",
")",
";",
"}"
] | Remove application logs
@param Schedule $scheduler
@return void | [
"Remove",
"application",
"logs"
] | d4f0ec37448e1aaf0bc841d13c420e6b6d8198a8 | https://github.com/modulusphp/system/blob/d4f0ec37448e1aaf0bc841d13c420e6b6d8198a8/Scheduler.php#L29-L53 |
4,845 | northern/PHP-Common | src/Northern/Common/Util/ExceptionUtil.php | ExceptionUtil.getExceptionNameHierarchy | public static function getExceptionNameHierarchy(\Exception $e, $separator = ' >> ')
{
$names = array();
// Loop through the exception hierarchy until there is no previous
// exception and store the class names of each found exception in the
// $names array.
do {
$names[] = get_class($e);
} while (($e = $e->getPrevious()) !== null);
// Concatenate the exception name with the separator.
$names = implode($separator, $names);
return $names;
} | php | public static function getExceptionNameHierarchy(\Exception $e, $separator = ' >> ')
{
$names = array();
// Loop through the exception hierarchy until there is no previous
// exception and store the class names of each found exception in the
// $names array.
do {
$names[] = get_class($e);
} while (($e = $e->getPrevious()) !== null);
// Concatenate the exception name with the separator.
$names = implode($separator, $names);
return $names;
} | [
"public",
"static",
"function",
"getExceptionNameHierarchy",
"(",
"\\",
"Exception",
"$",
"e",
",",
"$",
"separator",
"=",
"' >> '",
")",
"{",
"$",
"names",
"=",
"array",
"(",
")",
";",
"// Loop through the exception hierarchy until there is no previous",
"// exception and store the class names of each found exception in the",
"// $names array.",
"do",
"{",
"$",
"names",
"[",
"]",
"=",
"get_class",
"(",
"$",
"e",
")",
";",
"}",
"while",
"(",
"(",
"$",
"e",
"=",
"$",
"e",
"->",
"getPrevious",
"(",
")",
")",
"!==",
"null",
")",
";",
"// Concatenate the exception name with the separator.",
"$",
"names",
"=",
"implode",
"(",
"$",
"separator",
",",
"$",
"names",
")",
";",
"return",
"$",
"names",
";",
"}"
] | Returns a formatted string containing the class names of the exeptions thrown.
@param Exception $e
@param string $separator
@return string | [
"Returns",
"a",
"formatted",
"string",
"containing",
"the",
"class",
"names",
"of",
"the",
"exeptions",
"thrown",
"."
] | 7c63ef19252fd540fb412a18af956b8563afaa55 | https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ExceptionUtil.php#L14-L29 |
4,846 | northern/PHP-Common | src/Northern/Common/Util/ExceptionUtil.php | ExceptionUtil.getFormattedExceptionMessage | public static function getFormattedExceptionMessage(\Exception $e)
{
$name = static::getExceptionNameHierarchy($e);
list($file, $line, $stackTrace) = static::getOriginalExceptionFileAndLineNumber($e);
$message = "{$name}: {$e->getMessage()} ({$e->getcode()})\n{$file} {$line}\n{$stackTrace}";
return $message;
} | php | public static function getFormattedExceptionMessage(\Exception $e)
{
$name = static::getExceptionNameHierarchy($e);
list($file, $line, $stackTrace) = static::getOriginalExceptionFileAndLineNumber($e);
$message = "{$name}: {$e->getMessage()} ({$e->getcode()})\n{$file} {$line}\n{$stackTrace}";
return $message;
} | [
"public",
"static",
"function",
"getFormattedExceptionMessage",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"name",
"=",
"static",
"::",
"getExceptionNameHierarchy",
"(",
"$",
"e",
")",
";",
"list",
"(",
"$",
"file",
",",
"$",
"line",
",",
"$",
"stackTrace",
")",
"=",
"static",
"::",
"getOriginalExceptionFileAndLineNumber",
"(",
"$",
"e",
")",
";",
"$",
"message",
"=",
"\"{$name}: {$e->getMessage()} ({$e->getcode()})\\n{$file} {$line}\\n{$stackTrace}\"",
";",
"return",
"$",
"message",
";",
"}"
] | Returns the formatted message of a passed in exception.
@param \Exception $e
@return string | [
"Returns",
"the",
"formatted",
"message",
"of",
"a",
"passed",
"in",
"exception",
"."
] | 7c63ef19252fd540fb412a18af956b8563afaa55 | https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ExceptionUtil.php#L37-L46 |
4,847 | northern/PHP-Common | src/Northern/Common/Util/ExceptionUtil.php | ExceptionUtil.getOriginalExceptionFileAndLineNumber | public static function getOriginalExceptionFileAndLineNumber(\Exception $e)
{
$names = array();
do {
// Keep track of the "previous" exception in the list. Once $e equals NULL
// we want to return the values of $p which at the point contains the
// previous execption.
$p = $e;
$names[] = get_class($e);
} while (($e = $e->getPrevious()) !== null);
return array( $p->getFile(), $p->getLine(), $p->getTraceAsString() );
} | php | public static function getOriginalExceptionFileAndLineNumber(\Exception $e)
{
$names = array();
do {
// Keep track of the "previous" exception in the list. Once $e equals NULL
// we want to return the values of $p which at the point contains the
// previous execption.
$p = $e;
$names[] = get_class($e);
} while (($e = $e->getPrevious()) !== null);
return array( $p->getFile(), $p->getLine(), $p->getTraceAsString() );
} | [
"public",
"static",
"function",
"getOriginalExceptionFileAndLineNumber",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"names",
"=",
"array",
"(",
")",
";",
"do",
"{",
"// Keep track of the \"previous\" exception in the list. Once $e equals NULL",
"// we want to return the values of $p which at the point contains the",
"// previous execption.",
"$",
"p",
"=",
"$",
"e",
";",
"$",
"names",
"[",
"]",
"=",
"get_class",
"(",
"$",
"e",
")",
";",
"}",
"while",
"(",
"(",
"$",
"e",
"=",
"$",
"e",
"->",
"getPrevious",
"(",
")",
")",
"!==",
"null",
")",
";",
"return",
"array",
"(",
"$",
"p",
"->",
"getFile",
"(",
")",
",",
"$",
"p",
"->",
"getLine",
"(",
")",
",",
"$",
"p",
"->",
"getTraceAsString",
"(",
")",
")",
";",
"}"
] | Returns the file name, line number and stack trace where the original exception
was thrown.
@param \Exception $e
@return array | [
"Returns",
"the",
"file",
"name",
"line",
"number",
"and",
"stack",
"trace",
"where",
"the",
"original",
"exception",
"was",
"thrown",
"."
] | 7c63ef19252fd540fb412a18af956b8563afaa55 | https://github.com/northern/PHP-Common/blob/7c63ef19252fd540fb412a18af956b8563afaa55/src/Northern/Common/Util/ExceptionUtil.php#L55-L69 |
4,848 | crayner/symfony-form | Type/Transform/ImageToStringTransformer.php | ImageToStringTransformer.transform | public function transform($data): File
{
$file = file_exists($data) ? $data : null;
$file = is_null($file) ? new File('', false) : new File($file, true);
return $file;
} | php | public function transform($data): File
{
$file = file_exists($data) ? $data : null;
$file = is_null($file) ? new File('', false) : new File($file, true);
return $file;
} | [
"public",
"function",
"transform",
"(",
"$",
"data",
")",
":",
"File",
"{",
"$",
"file",
"=",
"file_exists",
"(",
"$",
"data",
")",
"?",
"$",
"data",
":",
"null",
";",
"$",
"file",
"=",
"is_null",
"(",
"$",
"file",
")",
"?",
"new",
"File",
"(",
"''",
",",
"false",
")",
":",
"new",
"File",
"(",
"$",
"file",
",",
"true",
")",
";",
"return",
"$",
"file",
";",
"}"
] | Transforms an string to File
@param File|null $data
@return string | [
"Transforms",
"an",
"string",
"to",
"File"
] | d9fb4f01265ffbcbc74cf4e2adebf99da359c8c2 | https://github.com/crayner/symfony-form/blob/d9fb4f01265ffbcbc74cf4e2adebf99da359c8c2/Type/Transform/ImageToStringTransformer.php#L16-L22 |
4,849 | lengthofrope/create-jsonld-tiny | src/Generator/Build.php | Build.getJSONVersionOfSchema | private function getJSONVersionOfSchema()
{
// Set cachefile
$cacheFile = dirname(dirname(__DIR__)) . '/data/schemaorg.cache';
if (!file_exists($cacheFile)) {
// Create dir
if (!file_exists(dirname($cacheFile))) {
mkdir(dirname($cacheFile), 0777, true);
}
// Load RDFA Schema
$graph = new \EasyRdf_Graph(self::RDFA_SCHEMA);
$graph->load(self::RDFA_SCHEMA, 'rdfa');
// Lookup the output format
$format = \EasyRdf_Format::getFormat('jsonld');
// Serialise to the new output format
$output = $graph->serialise($format);
if (!is_scalar($output)) {
$output = var_export($output, true);
}
$this->schema = \ML\JsonLD\JsonLD::compact($graph->serialise($format), 'http://schema.org/');
// Write cache file
file_put_contents($cacheFile, serialize($this->schema));
} else {
$this->schema = unserialize(file_get_contents($cacheFile));
}
} | php | private function getJSONVersionOfSchema()
{
// Set cachefile
$cacheFile = dirname(dirname(__DIR__)) . '/data/schemaorg.cache';
if (!file_exists($cacheFile)) {
// Create dir
if (!file_exists(dirname($cacheFile))) {
mkdir(dirname($cacheFile), 0777, true);
}
// Load RDFA Schema
$graph = new \EasyRdf_Graph(self::RDFA_SCHEMA);
$graph->load(self::RDFA_SCHEMA, 'rdfa');
// Lookup the output format
$format = \EasyRdf_Format::getFormat('jsonld');
// Serialise to the new output format
$output = $graph->serialise($format);
if (!is_scalar($output)) {
$output = var_export($output, true);
}
$this->schema = \ML\JsonLD\JsonLD::compact($graph->serialise($format), 'http://schema.org/');
// Write cache file
file_put_contents($cacheFile, serialize($this->schema));
} else {
$this->schema = unserialize(file_get_contents($cacheFile));
}
} | [
"private",
"function",
"getJSONVersionOfSchema",
"(",
")",
"{",
"// Set cachefile",
"$",
"cacheFile",
"=",
"dirname",
"(",
"dirname",
"(",
"__DIR__",
")",
")",
".",
"'/data/schemaorg.cache'",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"cacheFile",
")",
")",
"{",
"// Create dir",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"cacheFile",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"cacheFile",
")",
",",
"0777",
",",
"true",
")",
";",
"}",
"// Load RDFA Schema",
"$",
"graph",
"=",
"new",
"\\",
"EasyRdf_Graph",
"(",
"self",
"::",
"RDFA_SCHEMA",
")",
";",
"$",
"graph",
"->",
"load",
"(",
"self",
"::",
"RDFA_SCHEMA",
",",
"'rdfa'",
")",
";",
"// Lookup the output format",
"$",
"format",
"=",
"\\",
"EasyRdf_Format",
"::",
"getFormat",
"(",
"'jsonld'",
")",
";",
"// Serialise to the new output format",
"$",
"output",
"=",
"$",
"graph",
"->",
"serialise",
"(",
"$",
"format",
")",
";",
"if",
"(",
"!",
"is_scalar",
"(",
"$",
"output",
")",
")",
"{",
"$",
"output",
"=",
"var_export",
"(",
"$",
"output",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"schema",
"=",
"\\",
"ML",
"\\",
"JsonLD",
"\\",
"JsonLD",
"::",
"compact",
"(",
"$",
"graph",
"->",
"serialise",
"(",
"$",
"format",
")",
",",
"'http://schema.org/'",
")",
";",
"// Write cache file",
"file_put_contents",
"(",
"$",
"cacheFile",
",",
"serialize",
"(",
"$",
"this",
"->",
"schema",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"schema",
"=",
"unserialize",
"(",
"file_get_contents",
"(",
"$",
"cacheFile",
")",
")",
";",
"}",
"}"
] | Retrieve the latest RDFA version of schema.org and converts it to JSON-LD.
Note: caches the file in data and retrieves it from there as long as it exists. | [
"Retrieve",
"the",
"latest",
"RDFA",
"version",
"of",
"schema",
".",
"org",
"and",
"converts",
"it",
"to",
"JSON",
"-",
"LD",
"."
] | 7abf2e46b8eb4a5e886949ef737588c67c65acd9 | https://github.com/lengthofrope/create-jsonld-tiny/blob/7abf2e46b8eb4a5e886949ef737588c67c65acd9/src/Generator/Build.php#L76-L108 |
4,850 | avalonphp/database-migrations | src/Migrator.php | Migrator.migrate | public function migrate($direction = 'up')
{
if (!$this->tableExists('schema_migrations')) {
$this->createMigrationsTable();
}
foreach (get_declared_classes() as $declaredClass) {
if (is_subclass_of($declaredClass, "Avalon\\Database\\Migration")) {
if ($direction === 'up') {
$this->up($declaredClass);
} elseif ($direction === 'down') {
$this->down($declaredClass);
}
}
}
} | php | public function migrate($direction = 'up')
{
if (!$this->tableExists('schema_migrations')) {
$this->createMigrationsTable();
}
foreach (get_declared_classes() as $declaredClass) {
if (is_subclass_of($declaredClass, "Avalon\\Database\\Migration")) {
if ($direction === 'up') {
$this->up($declaredClass);
} elseif ($direction === 'down') {
$this->down($declaredClass);
}
}
}
} | [
"public",
"function",
"migrate",
"(",
"$",
"direction",
"=",
"'up'",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"tableExists",
"(",
"'schema_migrations'",
")",
")",
"{",
"$",
"this",
"->",
"createMigrationsTable",
"(",
")",
";",
"}",
"foreach",
"(",
"get_declared_classes",
"(",
")",
"as",
"$",
"declaredClass",
")",
"{",
"if",
"(",
"is_subclass_of",
"(",
"$",
"declaredClass",
",",
"\"Avalon\\\\Database\\\\Migration\"",
")",
")",
"{",
"if",
"(",
"$",
"direction",
"===",
"'up'",
")",
"{",
"$",
"this",
"->",
"up",
"(",
"$",
"declaredClass",
")",
";",
"}",
"elseif",
"(",
"$",
"direction",
"===",
"'down'",
")",
"{",
"$",
"this",
"->",
"down",
"(",
"$",
"declaredClass",
")",
";",
"}",
"}",
"}",
"}"
] | Handles the execution of migrations.
@param string $direction | [
"Handles",
"the",
"execution",
"of",
"migrations",
"."
] | 32f9ce2b2edb136892a7fb9de6319ba280735ae3 | https://github.com/avalonphp/database-migrations/blob/32f9ce2b2edb136892a7fb9de6319ba280735ae3/src/Migrator.php#L63-L78 |
4,851 | avalonphp/database-migrations | src/Migrator.php | Migrator.up | protected function up($className)
{
if ($fileName = $this->migrated($className)) {
$migration = new $className;
$migration->up();
$migration->execute();
$this->connection->insert("schema_migrations", [
'version' => $fileName,
'date' => date("Y-m-d")
]);
}
} | php | protected function up($className)
{
if ($fileName = $this->migrated($className)) {
$migration = new $className;
$migration->up();
$migration->execute();
$this->connection->insert("schema_migrations", [
'version' => $fileName,
'date' => date("Y-m-d")
]);
}
} | [
"protected",
"function",
"up",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"$",
"fileName",
"=",
"$",
"this",
"->",
"migrated",
"(",
"$",
"className",
")",
")",
"{",
"$",
"migration",
"=",
"new",
"$",
"className",
";",
"$",
"migration",
"->",
"up",
"(",
")",
";",
"$",
"migration",
"->",
"execute",
"(",
")",
";",
"$",
"this",
"->",
"connection",
"->",
"insert",
"(",
"\"schema_migrations\"",
",",
"[",
"'version'",
"=>",
"$",
"fileName",
",",
"'date'",
"=>",
"date",
"(",
"\"Y-m-d\"",
")",
"]",
")",
";",
"}",
"}"
] | Migrates the database forward.
@param string $className | [
"Migrates",
"the",
"database",
"forward",
"."
] | 32f9ce2b2edb136892a7fb9de6319ba280735ae3 | https://github.com/avalonphp/database-migrations/blob/32f9ce2b2edb136892a7fb9de6319ba280735ae3/src/Migrator.php#L85-L97 |
4,852 | avalonphp/database-migrations | src/Migrator.php | Migrator.migrated | protected function migrated($className)
{
$classInfo = new ReflectionClass($className);
$fileName = str_replace('.php', '', basename($classInfo->getFileName()));
$result = $this->connection->createQueryBuilder()->select('version')
->from('schema_migrations')
->where('version = ?')
->setParameter(0, $fileName)
->execute();
if (!count($result->fetchAll())) {
return $fileName;
} else {
return false;
}
} | php | protected function migrated($className)
{
$classInfo = new ReflectionClass($className);
$fileName = str_replace('.php', '', basename($classInfo->getFileName()));
$result = $this->connection->createQueryBuilder()->select('version')
->from('schema_migrations')
->where('version = ?')
->setParameter(0, $fileName)
->execute();
if (!count($result->fetchAll())) {
return $fileName;
} else {
return false;
}
} | [
"protected",
"function",
"migrated",
"(",
"$",
"className",
")",
"{",
"$",
"classInfo",
"=",
"new",
"ReflectionClass",
"(",
"$",
"className",
")",
";",
"$",
"fileName",
"=",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"basename",
"(",
"$",
"classInfo",
"->",
"getFileName",
"(",
")",
")",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"connection",
"->",
"createQueryBuilder",
"(",
")",
"->",
"select",
"(",
"'version'",
")",
"->",
"from",
"(",
"'schema_migrations'",
")",
"->",
"where",
"(",
"'version = ?'",
")",
"->",
"setParameter",
"(",
"0",
",",
"$",
"fileName",
")",
"->",
"execute",
"(",
")",
";",
"if",
"(",
"!",
"count",
"(",
"$",
"result",
"->",
"fetchAll",
"(",
")",
")",
")",
"{",
"return",
"$",
"fileName",
";",
"}",
"else",
"{",
"return",
"false",
";",
"}",
"}"
] | Checks if the migration has been executed and returns the migrations
base file name.
@param string $className
@return string | [
"Checks",
"if",
"the",
"migration",
"has",
"been",
"executed",
"and",
"returns",
"the",
"migrations",
"base",
"file",
"name",
"."
] | 32f9ce2b2edb136892a7fb9de6319ba280735ae3 | https://github.com/avalonphp/database-migrations/blob/32f9ce2b2edb136892a7fb9de6319ba280735ae3/src/Migrator.php#L107-L123 |
4,853 | avalonphp/database-migrations | src/Migrator.php | Migrator.createMigrationsTable | protected function createMigrationsTable()
{
$schema = new Schema;
$table = $schema->createTable("schema_migrations");
$table->addColumn("version", "string");
$table->addColumn("date", "date");
$queries = $schema->toSql($this->connection->getDatabasePlatform());
foreach ($queries as $query) {
$this->connection->query($query);
}
} | php | protected function createMigrationsTable()
{
$schema = new Schema;
$table = $schema->createTable("schema_migrations");
$table->addColumn("version", "string");
$table->addColumn("date", "date");
$queries = $schema->toSql($this->connection->getDatabasePlatform());
foreach ($queries as $query) {
$this->connection->query($query);
}
} | [
"protected",
"function",
"createMigrationsTable",
"(",
")",
"{",
"$",
"schema",
"=",
"new",
"Schema",
";",
"$",
"table",
"=",
"$",
"schema",
"->",
"createTable",
"(",
"\"schema_migrations\"",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"\"version\"",
",",
"\"string\"",
")",
";",
"$",
"table",
"->",
"addColumn",
"(",
"\"date\"",
",",
"\"date\"",
")",
";",
"$",
"queries",
"=",
"$",
"schema",
"->",
"toSql",
"(",
"$",
"this",
"->",
"connection",
"->",
"getDatabasePlatform",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"queries",
"as",
"$",
"query",
")",
"{",
"$",
"this",
"->",
"connection",
"->",
"query",
"(",
"$",
"query",
")",
";",
"}",
"}"
] | Creates the migration log table. | [
"Creates",
"the",
"migration",
"log",
"table",
"."
] | 32f9ce2b2edb136892a7fb9de6319ba280735ae3 | https://github.com/avalonphp/database-migrations/blob/32f9ce2b2edb136892a7fb9de6319ba280735ae3/src/Migrator.php#L148-L160 |
4,854 | FrenzelGmbH/appcommon | components/XmlImporter.php | XmlImporter.toXML | public static function toXML($data, $rootNodeName = 'entity', &$xml=null )
{
// turn off compatibility mode
if ( ini_get('zend.ze1_compatibility_mode') == 1 ) ini_set ( 'zend.ze1_compatibility_mode', 0 );
if ( is_null( $xml ) ) //$xml = simplexml_load_string( "" );
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
// loop through the data passed in.
foreach( $data as $key => $value ) {
$numeric = false;
// no numeric keys in our xml please!
if ( is_numeric( $key ) ) {
$numeric = 1;
$key = $rootNodeName;
}
// delete any char not allowed in XML element names
$key = preg_replace('/[^a-z0-9\-\_\.\:]/i', '', $key);
// if there is another array found recrusively call this function
if ( is_array( $value ) ) {
$node = self::isAssoc( $value ) || $numeric ? $xml->addChild( $key ) : $xml;
// recrusive call.
if ($numeric) $key = 'anon';
self::toXml( $value, $key, $node );
} else {
// add single node.
$value = Html::encode($value);
$xml->addChild($key, $value);
}
}
// pass back as XML
return $xml->asXML();
} | php | public static function toXML($data, $rootNodeName = 'entity', &$xml=null )
{
// turn off compatibility mode
if ( ini_get('zend.ze1_compatibility_mode') == 1 ) ini_set ( 'zend.ze1_compatibility_mode', 0 );
if ( is_null( $xml ) ) //$xml = simplexml_load_string( "" );
$xml = simplexml_load_string("<?xml version='1.0' encoding='utf-8'?><$rootNodeName />");
// loop through the data passed in.
foreach( $data as $key => $value ) {
$numeric = false;
// no numeric keys in our xml please!
if ( is_numeric( $key ) ) {
$numeric = 1;
$key = $rootNodeName;
}
// delete any char not allowed in XML element names
$key = preg_replace('/[^a-z0-9\-\_\.\:]/i', '', $key);
// if there is another array found recrusively call this function
if ( is_array( $value ) ) {
$node = self::isAssoc( $value ) || $numeric ? $xml->addChild( $key ) : $xml;
// recrusive call.
if ($numeric) $key = 'anon';
self::toXml( $value, $key, $node );
} else {
// add single node.
$value = Html::encode($value);
$xml->addChild($key, $value);
}
}
// pass back as XML
return $xml->asXML();
} | [
"public",
"static",
"function",
"toXML",
"(",
"$",
"data",
",",
"$",
"rootNodeName",
"=",
"'entity'",
",",
"&",
"$",
"xml",
"=",
"null",
")",
"{",
"// turn off compatibility mode",
"if",
"(",
"ini_get",
"(",
"'zend.ze1_compatibility_mode'",
")",
"==",
"1",
")",
"ini_set",
"(",
"'zend.ze1_compatibility_mode'",
",",
"0",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"xml",
")",
")",
"//$xml = simplexml_load_string( \"\" );",
"$",
"xml",
"=",
"simplexml_load_string",
"(",
"\"<?xml version='1.0' encoding='utf-8'?><$rootNodeName />\"",
")",
";",
"// loop through the data passed in.",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"numeric",
"=",
"false",
";",
"// no numeric keys in our xml please!",
"if",
"(",
"is_numeric",
"(",
"$",
"key",
")",
")",
"{",
"$",
"numeric",
"=",
"1",
";",
"$",
"key",
"=",
"$",
"rootNodeName",
";",
"}",
"// delete any char not allowed in XML element names",
"$",
"key",
"=",
"preg_replace",
"(",
"'/[^a-z0-9\\-\\_\\.\\:]/i'",
",",
"''",
",",
"$",
"key",
")",
";",
"// if there is another array found recrusively call this function",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"node",
"=",
"self",
"::",
"isAssoc",
"(",
"$",
"value",
")",
"||",
"$",
"numeric",
"?",
"$",
"xml",
"->",
"addChild",
"(",
"$",
"key",
")",
":",
"$",
"xml",
";",
"// recrusive call.",
"if",
"(",
"$",
"numeric",
")",
"$",
"key",
"=",
"'anon'",
";",
"self",
"::",
"toXml",
"(",
"$",
"value",
",",
"$",
"key",
",",
"$",
"node",
")",
";",
"}",
"else",
"{",
"// add single node.",
"$",
"value",
"=",
"Html",
"::",
"encode",
"(",
"$",
"value",
")",
";",
"$",
"xml",
"->",
"addChild",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"// pass back as XML",
"return",
"$",
"xml",
"->",
"asXML",
"(",
")",
";",
"}"
] | Converts a multidimensional associative array to an XML document.
@param array $data
@param string $rootNodeName - what you want the root node to be - defaultsto data.
@param SimpleXMLElement $xml - should only be used recursively
@return string XML | [
"Converts",
"a",
"multidimensional",
"associative",
"array",
"to",
"an",
"XML",
"document",
"."
] | d6d137b4c92b53832ce4b2e517644ed9fb545b7a | https://github.com/FrenzelGmbH/appcommon/blob/d6d137b4c92b53832ce4b2e517644ed9fb545b7a/components/XmlImporter.php#L104-L136 |
4,855 | nirix/radium | src/Routing/Route.php | Route.to | public function to($destination, array $defaults = [])
{
if ($this->name === null) {
$this->name = strtolower(
str_replace(['\\', '::'], '_', $destination)
);
}
$this->destination = $destination;
$this->defaults = $defaults;
return $this;
} | php | public function to($destination, array $defaults = [])
{
if ($this->name === null) {
$this->name = strtolower(
str_replace(['\\', '::'], '_', $destination)
);
}
$this->destination = $destination;
$this->defaults = $defaults;
return $this;
} | [
"public",
"function",
"to",
"(",
"$",
"destination",
",",
"array",
"$",
"defaults",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"name",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"strtolower",
"(",
"str_replace",
"(",
"[",
"'\\\\'",
",",
"'::'",
"]",
",",
"'_'",
",",
"$",
"destination",
")",
")",
";",
"}",
"$",
"this",
"->",
"destination",
"=",
"$",
"destination",
";",
"$",
"this",
"->",
"defaults",
"=",
"$",
"defaults",
";",
"return",
"$",
"this",
";",
"}"
] | Destination class and method of route.
@param string $destination Class and method to route to
@param array $args Arguments to pass to the routed method
@example
to('Admin\Settings::index') | [
"Destination",
"class",
"and",
"method",
"of",
"route",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Routing/Route.php#L91-L102 |
4,856 | nirix/radium | src/Routing/Route.php | Route.method | public function method($method)
{
// Convert to an array if needed
if (!is_array($method)) {
$method = [$method];
}
$this->method = $method;
return $this;
} | php | public function method($method)
{
// Convert to an array if needed
if (!is_array($method)) {
$method = [$method];
}
$this->method = $method;
return $this;
} | [
"public",
"function",
"method",
"(",
"$",
"method",
")",
"{",
"// Convert to an array if needed",
"if",
"(",
"!",
"is_array",
"(",
"$",
"method",
")",
")",
"{",
"$",
"method",
"=",
"[",
"$",
"method",
"]",
";",
"}",
"$",
"this",
"->",
"method",
"=",
"$",
"method",
";",
"return",
"$",
"this",
";",
"}"
] | HTTP methods to accept.
@param mixed $method
@example
method('get');
method(['get', 'post']); | [
"HTTP",
"methods",
"to",
"accept",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Routing/Route.php#L127-L136 |
4,857 | nirix/radium | src/Routing/Route.php | Route.generateUrl | public function generateUrl(array $tokens = [])
{
$path = $this->path;
foreach ($tokens as $key => $value) {
$path = str_replace(":{$key}", $value, $path);
}
return $path;
} | php | public function generateUrl(array $tokens = [])
{
$path = $this->path;
foreach ($tokens as $key => $value) {
$path = str_replace(":{$key}", $value, $path);
}
return $path;
} | [
"public",
"function",
"generateUrl",
"(",
"array",
"$",
"tokens",
"=",
"[",
"]",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"path",
";",
"foreach",
"(",
"$",
"tokens",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"\":{$key}\"",
",",
"$",
"value",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Generates the path, replacing tokens with specified values.
@param array $tokens
@return string | [
"Generates",
"the",
"path",
"replacing",
"tokens",
"with",
"specified",
"values",
"."
] | cc6907bfee296b64a7630b0b188e233d7cdb86fd | https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Routing/Route.php#L145-L154 |
4,858 | mvccore/ext-form | src/MvcCore/Ext/Forms/View.php | View.& | public function & SetForm (\MvcCore\Ext\Forms\IForm & $form) {
$this->form = & $form;
return $this;
} | php | public function & SetForm (\MvcCore\Ext\Forms\IForm & $form) {
$this->form = & $form;
return $this;
} | [
"public",
"function",
"&",
"SetForm",
"(",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Forms",
"\\",
"IForm",
"&",
"$",
"form",
")",
"{",
"$",
"this",
"->",
"form",
"=",
"&",
"$",
"form",
";",
"return",
"$",
"this",
";",
"}"
] | Set form instance to render.
@param \MvcCore\Ext\Form|\MvcCore\Ext\Forms\IForm $form
@return \MvcCore\Ext\Forms\View|\MvcCore\Ext\Forms\IView | [
"Set",
"form",
"instance",
"to",
"render",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/View.php#L158-L161 |
4,859 | mvccore/ext-form | src/MvcCore/Ext/Forms/View.php | View.& | public function & SetField (\MvcCore\Ext\Forms\IField & $field) {
$this->__protected['fieldRendering'] = TRUE;
$this->field = & $field;
return $this;
} | php | public function & SetField (\MvcCore\Ext\Forms\IField & $field) {
$this->__protected['fieldRendering'] = TRUE;
$this->field = & $field;
return $this;
} | [
"public",
"function",
"&",
"SetField",
"(",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Forms",
"\\",
"IField",
"&",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"__protected",
"[",
"'fieldRendering'",
"]",
"=",
"TRUE",
";",
"$",
"this",
"->",
"field",
"=",
"&",
"$",
"field",
";",
"return",
"$",
"this",
";",
"}"
] | Set rendered field.
@param \MvcCore\Ext\Forms\Field|\MvcCore\Ext\Forms\IField $field
@return \MvcCore\Ext\Forms\View|\MvcCore\Ext\Forms\IView | [
"Set",
"rendered",
"field",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/View.php#L176-L180 |
4,860 | mvccore/ext-form | src/MvcCore/Ext/Forms/View.php | View.RenderTemplate | public function RenderTemplate () {
$formViewScript = $this->form->GetViewScript();
return $this->Render(
static::$formsDir,
is_bool($formViewScript) ? $this->form->GetId() : $formViewScript
);
} | php | public function RenderTemplate () {
$formViewScript = $this->form->GetViewScript();
return $this->Render(
static::$formsDir,
is_bool($formViewScript) ? $this->form->GetId() : $formViewScript
);
} | [
"public",
"function",
"RenderTemplate",
"(",
")",
"{",
"$",
"formViewScript",
"=",
"$",
"this",
"->",
"form",
"->",
"GetViewScript",
"(",
")",
";",
"return",
"$",
"this",
"->",
"Render",
"(",
"static",
"::",
"$",
"formsDir",
",",
"is_bool",
"(",
"$",
"formViewScript",
")",
"?",
"$",
"this",
"->",
"form",
"->",
"GetId",
"(",
")",
":",
"$",
"formViewScript",
")",
";",
"}"
] | Render configured form template.
@return string | [
"Render",
"configured",
"form",
"template",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/View.php#L330-L336 |
4,861 | mvccore/ext-form | src/MvcCore/Ext/Forms/View.php | View.RenderErrors | public function RenderErrors () {
$this->form->PreDispatch();
$result = '';
$errors = & $this->form->GetErrors();
if ($errors && $this->form->GetErrorsRenderMode() == \MvcCore\Ext\Forms\IForm::ERROR_RENDER_MODE_ALL_TOGETHER) {
$result .= '<div class="errors">';
foreach ($errors as & $errorMessageAndFieldNames) {
list($errorMessage, $fieldNames) = $errorMessageAndFieldNames;
$result .= '<div class="error ' . implode(' ', $fieldNames) . '">'.$errorMessage.'</div>';
}
$result .= '</div>';
}
return $result;
} | php | public function RenderErrors () {
$this->form->PreDispatch();
$result = '';
$errors = & $this->form->GetErrors();
if ($errors && $this->form->GetErrorsRenderMode() == \MvcCore\Ext\Forms\IForm::ERROR_RENDER_MODE_ALL_TOGETHER) {
$result .= '<div class="errors">';
foreach ($errors as & $errorMessageAndFieldNames) {
list($errorMessage, $fieldNames) = $errorMessageAndFieldNames;
$result .= '<div class="error ' . implode(' ', $fieldNames) . '">'.$errorMessage.'</div>';
}
$result .= '</div>';
}
return $result;
} | [
"public",
"function",
"RenderErrors",
"(",
")",
"{",
"$",
"this",
"->",
"form",
"->",
"PreDispatch",
"(",
")",
";",
"$",
"result",
"=",
"''",
";",
"$",
"errors",
"=",
"&",
"$",
"this",
"->",
"form",
"->",
"GetErrors",
"(",
")",
";",
"if",
"(",
"$",
"errors",
"&&",
"$",
"this",
"->",
"form",
"->",
"GetErrorsRenderMode",
"(",
")",
"==",
"\\",
"MvcCore",
"\\",
"Ext",
"\\",
"Forms",
"\\",
"IForm",
"::",
"ERROR_RENDER_MODE_ALL_TOGETHER",
")",
"{",
"$",
"result",
".=",
"'<div class=\"errors\">'",
";",
"foreach",
"(",
"$",
"errors",
"as",
"&",
"$",
"errorMessageAndFieldNames",
")",
"{",
"list",
"(",
"$",
"errorMessage",
",",
"$",
"fieldNames",
")",
"=",
"$",
"errorMessageAndFieldNames",
";",
"$",
"result",
".=",
"'<div class=\"error '",
".",
"implode",
"(",
"' '",
",",
"$",
"fieldNames",
")",
".",
"'\">'",
".",
"$",
"errorMessage",
".",
"'</div>'",
";",
"}",
"$",
"result",
".=",
"'</div>'",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Render form errors.
If form is configured to render all errors together at form beginning,
this function completes all form errors into `div.errors` with `div.error` elements
inside containing each single errors message.
@return string | [
"Render",
"form",
"errors",
".",
"If",
"form",
"is",
"configured",
"to",
"render",
"all",
"errors",
"together",
"at",
"form",
"beginning",
"this",
"function",
"completes",
"all",
"form",
"errors",
"into",
"div",
".",
"errors",
"with",
"div",
".",
"error",
"elements",
"inside",
"containing",
"each",
"single",
"errors",
"message",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/View.php#L426-L439 |
4,862 | mvccore/ext-form | src/MvcCore/Ext/Forms/View.php | View.Format | public static function Format ($str = '', array $args = []) {
foreach ($args as $key => $value) {
$pos = strpos($str, '{'.$key.'}');
if ($pos !== FALSE)
$str = substr($str, 0, $pos) . $value . substr($str, $pos + strlen($key) + 2);
}
return $str;
} | php | public static function Format ($str = '', array $args = []) {
foreach ($args as $key => $value) {
$pos = strpos($str, '{'.$key.'}');
if ($pos !== FALSE)
$str = substr($str, 0, $pos) . $value . substr($str, $pos + strlen($key) + 2);
}
return $str;
} | [
"public",
"static",
"function",
"Format",
"(",
"$",
"str",
"=",
"''",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"str",
",",
"'{'",
".",
"$",
"key",
".",
"'}'",
")",
";",
"if",
"(",
"$",
"pos",
"!==",
"FALSE",
")",
"$",
"str",
"=",
"substr",
"(",
"$",
"str",
",",
"0",
",",
"$",
"pos",
")",
".",
"$",
"value",
".",
"substr",
"(",
"$",
"str",
",",
"$",
"pos",
"+",
"strlen",
"(",
"$",
"key",
")",
"+",
"2",
")",
";",
"}",
"return",
"$",
"str",
";",
"}"
] | Format string function.
@param string $str Template with replacements like `{0}`, `{1}`, `{anyStringKey}`...
@param array $args Each value under it's index is replaced as
string representation by replacement in form `{arrayKey}`
@return string | [
"Format",
"string",
"function",
"."
] | 8d81a3c7326236702f37dc4b9d968907b3230b9f | https://github.com/mvccore/ext-form/blob/8d81a3c7326236702f37dc4b9d968907b3230b9f/src/MvcCore/Ext/Forms/View.php#L480-L487 |
4,863 | Flowpack/Flowpack.SingleSignOn.Server | Classes/Flowpack/SingleSignOn/Server/Domain/Model/SsoServer.php | SsoServer.verifyAuthenticationRequest | public function verifyAuthenticationRequest(SsoClient $ssoClient, \TYPO3\Flow\Http\Request $request, $argumentName, $signature) {
$uri = clone $request->getUri();
$arguments = $uri->getArguments();
unset($arguments[$argumentName]);
if (isset($arguments['__csrfToken'])) {
unset($arguments['__csrfToken']);
}
$uri->setQuery(http_build_query($arguments));
$originalUri = (string)$uri;
// TODO Check if RsaWalletService has a key stored for the fingerprint, e.g. import or use public key string from client
return $this->rsaWalletService->verifySignature($originalUri, base64_decode($signature), $ssoClient->getPublicKey());
} | php | public function verifyAuthenticationRequest(SsoClient $ssoClient, \TYPO3\Flow\Http\Request $request, $argumentName, $signature) {
$uri = clone $request->getUri();
$arguments = $uri->getArguments();
unset($arguments[$argumentName]);
if (isset($arguments['__csrfToken'])) {
unset($arguments['__csrfToken']);
}
$uri->setQuery(http_build_query($arguments));
$originalUri = (string)$uri;
// TODO Check if RsaWalletService has a key stored for the fingerprint, e.g. import or use public key string from client
return $this->rsaWalletService->verifySignature($originalUri, base64_decode($signature), $ssoClient->getPublicKey());
} | [
"public",
"function",
"verifyAuthenticationRequest",
"(",
"SsoClient",
"$",
"ssoClient",
",",
"\\",
"TYPO3",
"\\",
"Flow",
"\\",
"Http",
"\\",
"Request",
"$",
"request",
",",
"$",
"argumentName",
",",
"$",
"signature",
")",
"{",
"$",
"uri",
"=",
"clone",
"$",
"request",
"->",
"getUri",
"(",
")",
";",
"$",
"arguments",
"=",
"$",
"uri",
"->",
"getArguments",
"(",
")",
";",
"unset",
"(",
"$",
"arguments",
"[",
"$",
"argumentName",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"arguments",
"[",
"'__csrfToken'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"arguments",
"[",
"'__csrfToken'",
"]",
")",
";",
"}",
"$",
"uri",
"->",
"setQuery",
"(",
"http_build_query",
"(",
"$",
"arguments",
")",
")",
";",
"$",
"originalUri",
"=",
"(",
"string",
")",
"$",
"uri",
";",
"// TODO Check if RsaWalletService has a key stored for the fingerprint, e.g. import or use public key string from client",
"return",
"$",
"this",
"->",
"rsaWalletService",
"->",
"verifySignature",
"(",
"$",
"originalUri",
",",
"base64_decode",
"(",
"$",
"signature",
")",
",",
"$",
"ssoClient",
"->",
"getPublicKey",
"(",
")",
")",
";",
"}"
] | Verifies the authenticity of an request to the authentication endpoint
Verifies the signature with the public key from the given SSO client excluding
the signature argument and a possible CSRF token.
@param \Flowpack\SingleSignOn\Server\Domain\Model\SsoClient $ssoClient
@param \TYPO3\Flow\Http\Request $request The original authentication endpoint request
@param string $argumentName Argument name of the signature argument (defaults to "signature")
@param string $signature Base64 encoded signature of the URI with arguments (excluding the signature argument)
@return boolean | [
"Verifies",
"the",
"authenticity",
"of",
"an",
"request",
"to",
"the",
"authentication",
"endpoint"
] | b1fa014f31d0d101a79cb95d5585b9973f35347d | https://github.com/Flowpack/Flowpack.SingleSignOn.Server/blob/b1fa014f31d0d101a79cb95d5585b9973f35347d/Classes/Flowpack/SingleSignOn/Server/Domain/Model/SsoServer.php#L54-L66 |
4,864 | Flowpack/Flowpack.SingleSignOn.Server | Classes/Flowpack/SingleSignOn/Server/Domain/Model/SsoServer.php | SsoServer.buildCallbackRedirectUri | public function buildCallbackRedirectUri(SsoClient $ssoClient, AccessToken $accessToken, $callbackUri) {
$accessTokenCipher = $this->rsaWalletService->encryptWithPublicKey($accessToken->getIdentifier(), $ssoClient->getPublicKey());
$signature = $this->rsaWalletService->sign($accessTokenCipher, $this->keyPairFingerprint);
$uri = new Uri($ssoClient->getServiceBaseUri() . 'authentication/callback');
$query = $uri->getQuery();
if ($query !== '') {
$query = $query . '&';
}
$query .= 'callbackUri=' . urlencode($callbackUri) . '&__flowpack[singlesignon][accessToken]=' . urlencode(base64_encode($accessTokenCipher)) . '&__flowpack[singlesignon][signature]=' . urlencode(base64_encode($signature));
$uri->setQuery($query);
return $uri;
} | php | public function buildCallbackRedirectUri(SsoClient $ssoClient, AccessToken $accessToken, $callbackUri) {
$accessTokenCipher = $this->rsaWalletService->encryptWithPublicKey($accessToken->getIdentifier(), $ssoClient->getPublicKey());
$signature = $this->rsaWalletService->sign($accessTokenCipher, $this->keyPairFingerprint);
$uri = new Uri($ssoClient->getServiceBaseUri() . 'authentication/callback');
$query = $uri->getQuery();
if ($query !== '') {
$query = $query . '&';
}
$query .= 'callbackUri=' . urlencode($callbackUri) . '&__flowpack[singlesignon][accessToken]=' . urlencode(base64_encode($accessTokenCipher)) . '&__flowpack[singlesignon][signature]=' . urlencode(base64_encode($signature));
$uri->setQuery($query);
return $uri;
} | [
"public",
"function",
"buildCallbackRedirectUri",
"(",
"SsoClient",
"$",
"ssoClient",
",",
"AccessToken",
"$",
"accessToken",
",",
"$",
"callbackUri",
")",
"{",
"$",
"accessTokenCipher",
"=",
"$",
"this",
"->",
"rsaWalletService",
"->",
"encryptWithPublicKey",
"(",
"$",
"accessToken",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"ssoClient",
"->",
"getPublicKey",
"(",
")",
")",
";",
"$",
"signature",
"=",
"$",
"this",
"->",
"rsaWalletService",
"->",
"sign",
"(",
"$",
"accessTokenCipher",
",",
"$",
"this",
"->",
"keyPairFingerprint",
")",
";",
"$",
"uri",
"=",
"new",
"Uri",
"(",
"$",
"ssoClient",
"->",
"getServiceBaseUri",
"(",
")",
".",
"'authentication/callback'",
")",
";",
"$",
"query",
"=",
"$",
"uri",
"->",
"getQuery",
"(",
")",
";",
"if",
"(",
"$",
"query",
"!==",
"''",
")",
"{",
"$",
"query",
"=",
"$",
"query",
".",
"'&'",
";",
"}",
"$",
"query",
".=",
"'callbackUri='",
".",
"urlencode",
"(",
"$",
"callbackUri",
")",
".",
"'&__flowpack[singlesignon][accessToken]='",
".",
"urlencode",
"(",
"base64_encode",
"(",
"$",
"accessTokenCipher",
")",
")",
".",
"'&__flowpack[singlesignon][signature]='",
".",
"urlencode",
"(",
"base64_encode",
"(",
"$",
"signature",
")",
")",
";",
"$",
"uri",
"->",
"setQuery",
"(",
"$",
"query",
")",
";",
"return",
"$",
"uri",
";",
"}"
] | Builds the callback URI to the client after authentication on the server
The URI will include an encrypted access token and is signed by the server private key.
@param \Flowpack\SingleSignOn\Server\Domain\Model\SsoClient $ssoClient
@param \Flowpack\SingleSignOn\Server\Domain\Model\AccessToken $accessToken
@param string $callbackUri
@return \TYPO3\Flow\Http\Uri | [
"Builds",
"the",
"callback",
"URI",
"to",
"the",
"client",
"after",
"authentication",
"on",
"the",
"server"
] | b1fa014f31d0d101a79cb95d5585b9973f35347d | https://github.com/Flowpack/Flowpack.SingleSignOn.Server/blob/b1fa014f31d0d101a79cb95d5585b9973f35347d/Classes/Flowpack/SingleSignOn/Server/Domain/Model/SsoServer.php#L78-L90 |
4,865 | Flowpack/Flowpack.SingleSignOn.Server | Classes/Flowpack/SingleSignOn/Server/Domain/Model/SsoServer.php | SsoServer.createAccessToken | public function createAccessToken(SsoClient $ssoClient, \TYPO3\Flow\Security\Account $account) {
$accessToken = new \Flowpack\SingleSignOn\Server\Domain\Model\AccessToken();
$accessToken->setAccount($account);
$accessToken->setExpiryTime(time() + \Flowpack\SingleSignOn\Server\Domain\Model\AccessToken::DEFAULT_VALIDITY_TIME);
$accessToken->setSessionId($this->session->getId());
$accessToken->setSsoClient($ssoClient);
return $accessToken;
} | php | public function createAccessToken(SsoClient $ssoClient, \TYPO3\Flow\Security\Account $account) {
$accessToken = new \Flowpack\SingleSignOn\Server\Domain\Model\AccessToken();
$accessToken->setAccount($account);
$accessToken->setExpiryTime(time() + \Flowpack\SingleSignOn\Server\Domain\Model\AccessToken::DEFAULT_VALIDITY_TIME);
$accessToken->setSessionId($this->session->getId());
$accessToken->setSsoClient($ssoClient);
return $accessToken;
} | [
"public",
"function",
"createAccessToken",
"(",
"SsoClient",
"$",
"ssoClient",
",",
"\\",
"TYPO3",
"\\",
"Flow",
"\\",
"Security",
"\\",
"Account",
"$",
"account",
")",
"{",
"$",
"accessToken",
"=",
"new",
"\\",
"Flowpack",
"\\",
"SingleSignOn",
"\\",
"Server",
"\\",
"Domain",
"\\",
"Model",
"\\",
"AccessToken",
"(",
")",
";",
"$",
"accessToken",
"->",
"setAccount",
"(",
"$",
"account",
")",
";",
"$",
"accessToken",
"->",
"setExpiryTime",
"(",
"time",
"(",
")",
"+",
"\\",
"Flowpack",
"\\",
"SingleSignOn",
"\\",
"Server",
"\\",
"Domain",
"\\",
"Model",
"\\",
"AccessToken",
"::",
"DEFAULT_VALIDITY_TIME",
")",
";",
"$",
"accessToken",
"->",
"setSessionId",
"(",
"$",
"this",
"->",
"session",
"->",
"getId",
"(",
")",
")",
";",
"$",
"accessToken",
"->",
"setSsoClient",
"(",
"$",
"ssoClient",
")",
";",
"return",
"$",
"accessToken",
";",
"}"
] | Create an access token for the given SSO client
The access token allows the client to get authentication details and transfer the session id.
@param \Flowpack\SingleSignOn\Server\Domain\Model\SsoClient $ssoClient
@param \TYPO3\Flow\Security\Account $account
@return \Flowpack\SingleSignOn\Server\Domain\Model\AccessToken | [
"Create",
"an",
"access",
"token",
"for",
"the",
"given",
"SSO",
"client"
] | b1fa014f31d0d101a79cb95d5585b9973f35347d | https://github.com/Flowpack/Flowpack.SingleSignOn.Server/blob/b1fa014f31d0d101a79cb95d5585b9973f35347d/Classes/Flowpack/SingleSignOn/Server/Domain/Model/SsoServer.php#L101-L108 |
4,866 | chigix/chiji-frontend | src/Util/StaticsManager.php | StaticsManager.getReference | public static function getReference($name) {
if (isset(self::$customer_references[$name])) {
return self::$customer_references[$name];
} else {
return null;
}
} | php | public static function getReference($name) {
if (isset(self::$customer_references[$name])) {
return self::$customer_references[$name];
} else {
return null;
}
} | [
"public",
"static",
"function",
"getReference",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"customer_references",
"[",
"$",
"name",
"]",
")",
")",
"{",
"return",
"self",
"::",
"$",
"customer_references",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get the target static from the manager
@param string $name
@return mixed | [
"Get",
"the",
"target",
"static",
"from",
"the",
"manager"
] | 5407f98c21ee99f8bbef43c97a231c0f81ed3e74 | https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Util/StaticsManager.php#L62-L68 |
4,867 | synapsestudios/synapse-base | src/Synapse/OAuth2/OAuthController.php | OAuthController.token | public function token(Request $request)
{
$bridgeResponse = new BridgeResponse;
$oauthRequest = OAuthRequest::createFromRequest($request);
$response = $this->server->handleTokenRequest($oauthRequest, $bridgeResponse);
if ($response->isOk()) {
$user = $this->userService->findById($response->getParameter('user_id'));
if (! $user) {
return $this->createInvalidCredentialResponse();
}
if (! $user->getEnabled()) {
return $this->createInvalidCredentialResponse();
}
// If enabled in config, check that user is verified
if ($this->requireVerification && ! $user->getVerified()) {
return $this->createSimpleResponse(422, 'Unverified user');
}
$userId = $response->getParameter('user_id');
$this->setLastLogin($userId);
$this->session->set('user', $userId);
}
return $response;
} | php | public function token(Request $request)
{
$bridgeResponse = new BridgeResponse;
$oauthRequest = OAuthRequest::createFromRequest($request);
$response = $this->server->handleTokenRequest($oauthRequest, $bridgeResponse);
if ($response->isOk()) {
$user = $this->userService->findById($response->getParameter('user_id'));
if (! $user) {
return $this->createInvalidCredentialResponse();
}
if (! $user->getEnabled()) {
return $this->createInvalidCredentialResponse();
}
// If enabled in config, check that user is verified
if ($this->requireVerification && ! $user->getVerified()) {
return $this->createSimpleResponse(422, 'Unverified user');
}
$userId = $response->getParameter('user_id');
$this->setLastLogin($userId);
$this->session->set('user', $userId);
}
return $response;
} | [
"public",
"function",
"token",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"bridgeResponse",
"=",
"new",
"BridgeResponse",
";",
"$",
"oauthRequest",
"=",
"OAuthRequest",
"::",
"createFromRequest",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"server",
"->",
"handleTokenRequest",
"(",
"$",
"oauthRequest",
",",
"$",
"bridgeResponse",
")",
";",
"if",
"(",
"$",
"response",
"->",
"isOk",
"(",
")",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"userService",
"->",
"findById",
"(",
"$",
"response",
"->",
"getParameter",
"(",
"'user_id'",
")",
")",
";",
"if",
"(",
"!",
"$",
"user",
")",
"{",
"return",
"$",
"this",
"->",
"createInvalidCredentialResponse",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"user",
"->",
"getEnabled",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createInvalidCredentialResponse",
"(",
")",
";",
"}",
"// If enabled in config, check that user is verified",
"if",
"(",
"$",
"this",
"->",
"requireVerification",
"&&",
"!",
"$",
"user",
"->",
"getVerified",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"createSimpleResponse",
"(",
"422",
",",
"'Unverified user'",
")",
";",
"}",
"$",
"userId",
"=",
"$",
"response",
"->",
"getParameter",
"(",
"'user_id'",
")",
";",
"$",
"this",
"->",
"setLastLogin",
"(",
"$",
"userId",
")",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"'user'",
",",
"$",
"userId",
")",
";",
"}",
"return",
"$",
"response",
";",
"}"
] | Handle an OAuth token request
(Implements the "Resource Owner Password Credentials" grant type
or Part 3 of the "Authorization Code" grant type)
Note: Expects input as POST variables, not JSON request body
@link http://tools.ietf.org/html/rfc6749#section-4.3.2 Access Token Request
@param Request $request
@return Response | [
"Handle",
"an",
"OAuth",
"token",
"request"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/OAuth2/OAuthController.php#L196-L226 |
4,868 | synapsestudios/synapse-base | src/Synapse/OAuth2/OAuthController.php | OAuthController.setLastLogin | protected function setLastLogin($userId)
{
$user = $this->userService->findById($userId);
$result = $this->userService->update($user, [
'last_login' => time()
]);
} | php | protected function setLastLogin($userId)
{
$user = $this->userService->findById($userId);
$result = $this->userService->update($user, [
'last_login' => time()
]);
} | [
"protected",
"function",
"setLastLogin",
"(",
"$",
"userId",
")",
"{",
"$",
"user",
"=",
"$",
"this",
"->",
"userService",
"->",
"findById",
"(",
"$",
"userId",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"userService",
"->",
"update",
"(",
"$",
"user",
",",
"[",
"'last_login'",
"=>",
"time",
"(",
")",
"]",
")",
";",
"}"
] | Set the last_login timestamp in the database
@param string $userId | [
"Set",
"the",
"last_login",
"timestamp",
"in",
"the",
"database"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/OAuth2/OAuthController.php#L233-L240 |
4,869 | synapsestudios/synapse-base | src/Synapse/OAuth2/OAuthController.php | OAuthController.logout | public function logout(Request $request)
{
$content = json_decode($request->getContent(), true);
$securityToken = $this->security->getToken();
$user = $securityToken->getUser();
$accessToken = $securityToken->getOAuthToken();
$refreshToken = Arr::get($content, 'refresh_token');
$this->session->set('user', null);
if (! $refreshToken) {
return new Response('Refresh token not provided', 422);
}
try {
$this->expireAccessToken($accessToken);
$this->expireRefreshToken($refreshToken, $user);
} catch (OutOfBoundsException $e) {
return new Response($e->getMessage(), 422);
}
return new Response('', 200);
} | php | public function logout(Request $request)
{
$content = json_decode($request->getContent(), true);
$securityToken = $this->security->getToken();
$user = $securityToken->getUser();
$accessToken = $securityToken->getOAuthToken();
$refreshToken = Arr::get($content, 'refresh_token');
$this->session->set('user', null);
if (! $refreshToken) {
return new Response('Refresh token not provided', 422);
}
try {
$this->expireAccessToken($accessToken);
$this->expireRefreshToken($refreshToken, $user);
} catch (OutOfBoundsException $e) {
return new Response($e->getMessage(), 422);
}
return new Response('', 200);
} | [
"public",
"function",
"logout",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"content",
"=",
"json_decode",
"(",
"$",
"request",
"->",
"getContent",
"(",
")",
",",
"true",
")",
";",
"$",
"securityToken",
"=",
"$",
"this",
"->",
"security",
"->",
"getToken",
"(",
")",
";",
"$",
"user",
"=",
"$",
"securityToken",
"->",
"getUser",
"(",
")",
";",
"$",
"accessToken",
"=",
"$",
"securityToken",
"->",
"getOAuthToken",
"(",
")",
";",
"$",
"refreshToken",
"=",
"Arr",
"::",
"get",
"(",
"$",
"content",
",",
"'refresh_token'",
")",
";",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"'user'",
",",
"null",
")",
";",
"if",
"(",
"!",
"$",
"refreshToken",
")",
"{",
"return",
"new",
"Response",
"(",
"'Refresh token not provided'",
",",
"422",
")",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"expireAccessToken",
"(",
"$",
"accessToken",
")",
";",
"$",
"this",
"->",
"expireRefreshToken",
"(",
"$",
"refreshToken",
",",
"$",
"user",
")",
";",
"}",
"catch",
"(",
"OutOfBoundsException",
"$",
"e",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"422",
")",
";",
"}",
"return",
"new",
"Response",
"(",
"''",
",",
"200",
")",
";",
"}"
] | Handle logout request
@param Request $request
@return Response | [
"Handle",
"logout",
"request"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/OAuth2/OAuthController.php#L248-L271 |
4,870 | synapsestudios/synapse-base | src/Synapse/OAuth2/OAuthController.php | OAuthController.expireAccessToken | protected function expireAccessToken($accessToken)
{
// Expire access token
$token = $this->accessTokenMapper->findBy([
'access_token' => $accessToken
]);
if (! $token) {
throw new OutOfBoundsException('Access token not found.');
}
$token->setExpires(date("Y-m-d H:i:s", time()));
$this->accessTokenMapper->update($token);
} | php | protected function expireAccessToken($accessToken)
{
// Expire access token
$token = $this->accessTokenMapper->findBy([
'access_token' => $accessToken
]);
if (! $token) {
throw new OutOfBoundsException('Access token not found.');
}
$token->setExpires(date("Y-m-d H:i:s", time()));
$this->accessTokenMapper->update($token);
} | [
"protected",
"function",
"expireAccessToken",
"(",
"$",
"accessToken",
")",
"{",
"// Expire access token",
"$",
"token",
"=",
"$",
"this",
"->",
"accessTokenMapper",
"->",
"findBy",
"(",
"[",
"'access_token'",
"=>",
"$",
"accessToken",
"]",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"'Access token not found.'",
")",
";",
"}",
"$",
"token",
"->",
"setExpires",
"(",
"date",
"(",
"\"Y-m-d H:i:s\"",
",",
"time",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"accessTokenMapper",
"->",
"update",
"(",
"$",
"token",
")",
";",
"}"
] | Expire an access token
@param string $accessToken | [
"Expire",
"an",
"access",
"token"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/OAuth2/OAuthController.php#L288-L302 |
4,871 | synapsestudios/synapse-base | src/Synapse/OAuth2/OAuthController.php | OAuthController.expireRefreshToken | protected function expireRefreshToken($refreshToken, $user)
{
$token = $this->refreshTokenMapper->findBy([
'refresh_token' => $refreshToken,
'user_id' => $user->getId(),
]);
if (! $token) {
throw new OutOfBoundsException('Refresh token not found.');
}
$token->setExpires(date("Y-m-d H:i:s", time()));
$this->refreshTokenMapper->update($token);
} | php | protected function expireRefreshToken($refreshToken, $user)
{
$token = $this->refreshTokenMapper->findBy([
'refresh_token' => $refreshToken,
'user_id' => $user->getId(),
]);
if (! $token) {
throw new OutOfBoundsException('Refresh token not found.');
}
$token->setExpires(date("Y-m-d H:i:s", time()));
$this->refreshTokenMapper->update($token);
} | [
"protected",
"function",
"expireRefreshToken",
"(",
"$",
"refreshToken",
",",
"$",
"user",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"refreshTokenMapper",
"->",
"findBy",
"(",
"[",
"'refresh_token'",
"=>",
"$",
"refreshToken",
",",
"'user_id'",
"=>",
"$",
"user",
"->",
"getId",
"(",
")",
",",
"]",
")",
";",
"if",
"(",
"!",
"$",
"token",
")",
"{",
"throw",
"new",
"OutOfBoundsException",
"(",
"'Refresh token not found.'",
")",
";",
"}",
"$",
"token",
"->",
"setExpires",
"(",
"date",
"(",
"\"Y-m-d H:i:s\"",
",",
"time",
"(",
")",
")",
")",
";",
"$",
"this",
"->",
"refreshTokenMapper",
"->",
"update",
"(",
"$",
"token",
")",
";",
"}"
] | Expire a refresh token
@param string $refreshToken
@param UserEntity $user | [
"Expire",
"a",
"refresh",
"token"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/OAuth2/OAuthController.php#L310-L324 |
4,872 | synapsestudios/synapse-base | src/Synapse/OAuth2/OAuthController.php | OAuthController.getUserFromRequest | protected function getUserFromRequest(Request $request)
{
$username = $request->get('username');
return $this->userService->findByEmail($username);
} | php | protected function getUserFromRequest(Request $request)
{
$username = $request->get('username');
return $this->userService->findByEmail($username);
} | [
"protected",
"function",
"getUserFromRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"username",
"=",
"$",
"request",
"->",
"get",
"(",
"'username'",
")",
";",
"return",
"$",
"this",
"->",
"userService",
"->",
"findByEmail",
"(",
"$",
"username",
")",
";",
"}"
] | Get the user from the request
@param Request $request
@return UserEntity|boolean | [
"Get",
"the",
"user",
"from",
"the",
"request"
] | 60c830550491742a077ab063f924e2f0b63825da | https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/OAuth2/OAuthController.php#L344-L349 |
4,873 | znframework/package-payment | Nestpay/Request.php | Request.cardType | public function cardType(Int $type)
{
if( ! isset($this->cardTypes[$type]) )
{
throw new Exception\InvalidCardTypeException(NULL, $type);
}
$this->settings['cardType'] = $type;
return $this;
} | php | public function cardType(Int $type)
{
if( ! isset($this->cardTypes[$type]) )
{
throw new Exception\InvalidCardTypeException(NULL, $type);
}
$this->settings['cardType'] = $type;
return $this;
} | [
"public",
"function",
"cardType",
"(",
"Int",
"$",
"type",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"cardTypes",
"[",
"$",
"type",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"InvalidCardTypeException",
"(",
"NULL",
",",
"$",
"type",
")",
";",
"}",
"$",
"this",
"->",
"settings",
"[",
"'cardType'",
"]",
"=",
"$",
"type",
";",
"return",
"$",
"this",
";",
"}"
] | Sets card type.
@param int $type
@return $this | [
"Sets",
"card",
"type",
"."
] | 6864a8510947fb19a50668bdd14840d1d0988d19 | https://github.com/znframework/package-payment/blob/6864a8510947fb19a50668bdd14840d1d0988d19/Nestpay/Request.php#L73-L83 |
4,874 | znframework/package-payment | Nestpay/Request.php | Request.returnUrl | public function returnUrl(String $success, String $fail = NULL)
{
$this->settings['okUrl'] = URL::site($success);
$this->settings['failUrl'] = URL::site($fail ?? $success);
return $this;
} | php | public function returnUrl(String $success, String $fail = NULL)
{
$this->settings['okUrl'] = URL::site($success);
$this->settings['failUrl'] = URL::site($fail ?? $success);
return $this;
} | [
"public",
"function",
"returnUrl",
"(",
"String",
"$",
"success",
",",
"String",
"$",
"fail",
"=",
"NULL",
")",
"{",
"$",
"this",
"->",
"settings",
"[",
"'okUrl'",
"]",
"=",
"URL",
"::",
"site",
"(",
"$",
"success",
")",
";",
"$",
"this",
"->",
"settings",
"[",
"'failUrl'",
"]",
"=",
"URL",
"::",
"site",
"(",
"$",
"fail",
"??",
"$",
"success",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Sets return url.
@param string $success
@param string $fail
@return $this | [
"Sets",
"return",
"url",
"."
] | 6864a8510947fb19a50668bdd14840d1d0988d19 | https://github.com/znframework/package-payment/blob/6864a8510947fb19a50668bdd14840d1d0988d19/Nestpay/Request.php#L163-L169 |
4,875 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/cache/storage/file.php | Cache_Storage_File.prep_contents | protected function prep_contents()
{
$properties = array(
'created' => $this->created,
'expiration' => $this->expiration,
'dependencies' => $this->dependencies,
'content_handler' => $this->content_handler
);
$properties = '{{'.self::PROPS_TAG.'}}'.json_encode($properties).'{{/'.self::PROPS_TAG.'}}';
return $properties.$this->contents;
} | php | protected function prep_contents()
{
$properties = array(
'created' => $this->created,
'expiration' => $this->expiration,
'dependencies' => $this->dependencies,
'content_handler' => $this->content_handler
);
$properties = '{{'.self::PROPS_TAG.'}}'.json_encode($properties).'{{/'.self::PROPS_TAG.'}}';
return $properties.$this->contents;
} | [
"protected",
"function",
"prep_contents",
"(",
")",
"{",
"$",
"properties",
"=",
"array",
"(",
"'created'",
"=>",
"$",
"this",
"->",
"created",
",",
"'expiration'",
"=>",
"$",
"this",
"->",
"expiration",
",",
"'dependencies'",
"=>",
"$",
"this",
"->",
"dependencies",
",",
"'content_handler'",
"=>",
"$",
"this",
"->",
"content_handler",
")",
";",
"$",
"properties",
"=",
"'{{'",
".",
"self",
"::",
"PROPS_TAG",
".",
"'}}'",
".",
"json_encode",
"(",
"$",
"properties",
")",
".",
"'{{/'",
".",
"self",
"::",
"PROPS_TAG",
".",
"'}}'",
";",
"return",
"$",
"properties",
".",
"$",
"this",
"->",
"contents",
";",
"}"
] | Prepend the cache properties
@return string | [
"Prepend",
"the",
"cache",
"properties"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache/storage/file.php#L196-L207 |
4,876 | indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/cache/storage/file.php | Cache_Storage_File.unprep_contents | protected function unprep_contents($payload)
{
$properties_end = strpos($payload, '{{/'.self::PROPS_TAG.'}}');
if ($properties_end === false)
{
throw new \UnexpectedValueException('Cache has bad formatting');
}
$this->contents = substr($payload, $properties_end + strlen('{{/'.self::PROPS_TAG.'}}'));
$props = substr(substr($payload, 0, $properties_end), strlen('{{'.self::PROPS_TAG.'}}'));
$props = json_decode($props, true);
if ($props === null)
{
throw new \UnexpectedValueException('Cache properties retrieval failed');
}
$this->created = $props['created'];
$this->expiration = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time());
$this->dependencies = $props['dependencies'];
$this->content_handler = $props['content_handler'];
} | php | protected function unprep_contents($payload)
{
$properties_end = strpos($payload, '{{/'.self::PROPS_TAG.'}}');
if ($properties_end === false)
{
throw new \UnexpectedValueException('Cache has bad formatting');
}
$this->contents = substr($payload, $properties_end + strlen('{{/'.self::PROPS_TAG.'}}'));
$props = substr(substr($payload, 0, $properties_end), strlen('{{'.self::PROPS_TAG.'}}'));
$props = json_decode($props, true);
if ($props === null)
{
throw new \UnexpectedValueException('Cache properties retrieval failed');
}
$this->created = $props['created'];
$this->expiration = is_null($props['expiration']) ? null : (int) ($props['expiration'] - time());
$this->dependencies = $props['dependencies'];
$this->content_handler = $props['content_handler'];
} | [
"protected",
"function",
"unprep_contents",
"(",
"$",
"payload",
")",
"{",
"$",
"properties_end",
"=",
"strpos",
"(",
"$",
"payload",
",",
"'{{/'",
".",
"self",
"::",
"PROPS_TAG",
".",
"'}}'",
")",
";",
"if",
"(",
"$",
"properties_end",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Cache has bad formatting'",
")",
";",
"}",
"$",
"this",
"->",
"contents",
"=",
"substr",
"(",
"$",
"payload",
",",
"$",
"properties_end",
"+",
"strlen",
"(",
"'{{/'",
".",
"self",
"::",
"PROPS_TAG",
".",
"'}}'",
")",
")",
";",
"$",
"props",
"=",
"substr",
"(",
"substr",
"(",
"$",
"payload",
",",
"0",
",",
"$",
"properties_end",
")",
",",
"strlen",
"(",
"'{{'",
".",
"self",
"::",
"PROPS_TAG",
".",
"'}}'",
")",
")",
";",
"$",
"props",
"=",
"json_decode",
"(",
"$",
"props",
",",
"true",
")",
";",
"if",
"(",
"$",
"props",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"UnexpectedValueException",
"(",
"'Cache properties retrieval failed'",
")",
";",
"}",
"$",
"this",
"->",
"created",
"=",
"$",
"props",
"[",
"'created'",
"]",
";",
"$",
"this",
"->",
"expiration",
"=",
"is_null",
"(",
"$",
"props",
"[",
"'expiration'",
"]",
")",
"?",
"null",
":",
"(",
"int",
")",
"(",
"$",
"props",
"[",
"'expiration'",
"]",
"-",
"time",
"(",
")",
")",
";",
"$",
"this",
"->",
"dependencies",
"=",
"$",
"props",
"[",
"'dependencies'",
"]",
";",
"$",
"this",
"->",
"content_handler",
"=",
"$",
"props",
"[",
"'content_handler'",
"]",
";",
"}"
] | Remove the prepended cache properties and save them in class properties
@param string
@throws UnexpectedValueException | [
"Remove",
"the",
"prepended",
"cache",
"properties",
"and",
"save",
"them",
"in",
"class",
"properties"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/cache/storage/file.php#L215-L235 |
4,877 | phlexible/phlexible | src/Phlexible/Bundle/ElementtypeBundle/Controller/UsageController.php | UsageController.listAction | public function listAction(Request $request)
{
$id = $request->get('id');
$elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
$usageManager = $this->get('phlexible_elementtype.usage_manager');
$elementtype = $elementtypeService->findElementtype($id);
$usages = [];
foreach ($usageManager->getUsage($elementtype) as $usage) {
$usages[] = [
'type' => $usage->getType(),
'as' => $usage->getAs(),
'id' => $usage->getId(),
'title' => $usage->getTitle(),
'latest_version' => $usage->getLatestVersion(),
];
}
return new JsonResponse(['list' => $usages, 'total' => count($usages)]);
} | php | public function listAction(Request $request)
{
$id = $request->get('id');
$elementtypeService = $this->get('phlexible_elementtype.elementtype_service');
$usageManager = $this->get('phlexible_elementtype.usage_manager');
$elementtype = $elementtypeService->findElementtype($id);
$usages = [];
foreach ($usageManager->getUsage($elementtype) as $usage) {
$usages[] = [
'type' => $usage->getType(),
'as' => $usage->getAs(),
'id' => $usage->getId(),
'title' => $usage->getTitle(),
'latest_version' => $usage->getLatestVersion(),
];
}
return new JsonResponse(['list' => $usages, 'total' => count($usages)]);
} | [
"public",
"function",
"listAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"elementtypeService",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_elementtype.elementtype_service'",
")",
";",
"$",
"usageManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'phlexible_elementtype.usage_manager'",
")",
";",
"$",
"elementtype",
"=",
"$",
"elementtypeService",
"->",
"findElementtype",
"(",
"$",
"id",
")",
";",
"$",
"usages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"usageManager",
"->",
"getUsage",
"(",
"$",
"elementtype",
")",
"as",
"$",
"usage",
")",
"{",
"$",
"usages",
"[",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"usage",
"->",
"getType",
"(",
")",
",",
"'as'",
"=>",
"$",
"usage",
"->",
"getAs",
"(",
")",
",",
"'id'",
"=>",
"$",
"usage",
"->",
"getId",
"(",
")",
",",
"'title'",
"=>",
"$",
"usage",
"->",
"getTitle",
"(",
")",
",",
"'latest_version'",
"=>",
"$",
"usage",
"->",
"getLatestVersion",
"(",
")",
",",
"]",
";",
"}",
"return",
"new",
"JsonResponse",
"(",
"[",
"'list'",
"=>",
"$",
"usages",
",",
"'total'",
"=>",
"count",
"(",
"$",
"usages",
")",
"]",
")",
";",
"}"
] | Show Usage of an Element Type.
@param Request $request
@return JsonResponse
@Route("/elementtypes/usage", name="elementtypes_usage") | [
"Show",
"Usage",
"of",
"an",
"Element",
"Type",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/ElementtypeBundle/Controller/UsageController.php#L37-L58 |
4,878 | gregorybesson/PlaygroundFacebook | src/PlaygroundFacebook/Entity/App.php | App.addPages | public function addPages(ArrayCollection $pages)
{
foreach ($pages as $page) {
$page->addApp($this);
$this->pages->add($page);
}
} | php | public function addPages(ArrayCollection $pages)
{
foreach ($pages as $page) {
$page->addApp($this);
$this->pages->add($page);
}
} | [
"public",
"function",
"addPages",
"(",
"ArrayCollection",
"$",
"pages",
")",
"{",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"$",
"page",
"->",
"addApp",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"pages",
"->",
"add",
"(",
"$",
"page",
")",
";",
"}",
"}"
] | Add pages to the app.
@param ArrayCollection $pages
@return void | [
"Add",
"pages",
"to",
"the",
"app",
"."
] | 35d9561af5af6ccda8a02f4c61a55ff0107e8efd | https://github.com/gregorybesson/PlaygroundFacebook/blob/35d9561af5af6ccda8a02f4c61a55ff0107e8efd/src/PlaygroundFacebook/Entity/App.php#L495-L501 |
4,879 | gregorybesson/PlaygroundFacebook | src/PlaygroundFacebook/Entity/App.php | App.removePages | public function removePages(ArrayCollection $pages)
{
foreach ($pages as $page) {
$page->removeApp($this);
$this->pages->removeElement($page);
}
} | php | public function removePages(ArrayCollection $pages)
{
foreach ($pages as $page) {
$page->removeApp($this);
$this->pages->removeElement($page);
}
} | [
"public",
"function",
"removePages",
"(",
"ArrayCollection",
"$",
"pages",
")",
"{",
"foreach",
"(",
"$",
"pages",
"as",
"$",
"page",
")",
"{",
"$",
"page",
"->",
"removeApp",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"pages",
"->",
"removeElement",
"(",
"$",
"page",
")",
";",
"}",
"}"
] | Remove pages from the app.
@param ArrayCollection $pages
@return void | [
"Remove",
"pages",
"from",
"the",
"app",
"."
] | 35d9561af5af6ccda8a02f4c61a55ff0107e8efd | https://github.com/gregorybesson/PlaygroundFacebook/blob/35d9561af5af6ccda8a02f4c61a55ff0107e8efd/src/PlaygroundFacebook/Entity/App.php#L510-L516 |
4,880 | sgoendoer/sonic | src/Model/ObjectFactory.php | ObjectFactory.init | public static function init(JSONObject $json)
{
$object = NULL;
if(!$json->has("@type"))
throw new ModelFormatException("Not a valid object");
try
{
switch(strtolower($json->get("@type")))
{
case "comment":
$object = CommentObjectBuilder::buildFromJSON($json->__toString());
break;
case "like":
$object = LikeObjectBuilder::buildFromJSON($json->__toString());
break;
case "image":
$object = ImageObjectBuilder::buildFromJSON($json->__toString());
break;
case "profile":
$object = ProfileObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation":
$object = ConversationObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation-status":
$object = ConversationStatusObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation-message":
$object = ConversationMessageObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation-message-status":
$object = ConversationMessageStatusObjectBuilder::buildFromJSON($json->__toString());
break;
case "accesscontrolgroup":
$object = AccessControlGroupObjectBuilder::buildFromJSON($json->__toString());
break;
case "accesscontrolrule":
$object = AccessControlRuleObjectBuilder::buildFromJSON($json->__toString());
break;
case "link":
$object = LinkObjectBuilder::buildFromJSON($json->__toString());
break;
case "link-request":
$object = LinkRequesObjectBuilder::buildFromJSON($json->__toString());
break;
case "link-response":
$object = LinkResponseObjectBuilder::buildFromJSON($json->__toString());
break;
case "response":
$object = ResponseObjectBuilder::buildFromJSON($json->__toString());
break;
case "search-query":
$object = SearchQueryObjectBuilder::buildFromJSON($json->__toString());
break;
case "search-result":
$object = SearchResultObjectBuilder::buildFromJSON($json->__toString());
break;
case "search-result-collection":
$object = SearchResultCollectionObjectBuilder::buildFromJSON($json->__toString());
break;
//case "signature":
//$object = SignaObjectBuilder::buildFromJSON($json->__toString());
//break;
// feature
// migration
case "activity":
$object = StreamItemObjectBuilder::buildFromJSON($json->__toString());
break;
case "tag":
$object = TagObjectBuilder::buildFromJSON($json->__toString());
break;
default:
throw new ModelFormatException("Not a valid object type");
break;
}
}
catch(Exception $e)
{
throw new ModelFormatException("Could not init object for " . strtolower($json->get("@type")) . ": " . $e->getMessage());
}
return $object;
} | php | public static function init(JSONObject $json)
{
$object = NULL;
if(!$json->has("@type"))
throw new ModelFormatException("Not a valid object");
try
{
switch(strtolower($json->get("@type")))
{
case "comment":
$object = CommentObjectBuilder::buildFromJSON($json->__toString());
break;
case "like":
$object = LikeObjectBuilder::buildFromJSON($json->__toString());
break;
case "image":
$object = ImageObjectBuilder::buildFromJSON($json->__toString());
break;
case "profile":
$object = ProfileObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation":
$object = ConversationObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation-status":
$object = ConversationStatusObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation-message":
$object = ConversationMessageObjectBuilder::buildFromJSON($json->__toString());
break;
case "conversation-message-status":
$object = ConversationMessageStatusObjectBuilder::buildFromJSON($json->__toString());
break;
case "accesscontrolgroup":
$object = AccessControlGroupObjectBuilder::buildFromJSON($json->__toString());
break;
case "accesscontrolrule":
$object = AccessControlRuleObjectBuilder::buildFromJSON($json->__toString());
break;
case "link":
$object = LinkObjectBuilder::buildFromJSON($json->__toString());
break;
case "link-request":
$object = LinkRequesObjectBuilder::buildFromJSON($json->__toString());
break;
case "link-response":
$object = LinkResponseObjectBuilder::buildFromJSON($json->__toString());
break;
case "response":
$object = ResponseObjectBuilder::buildFromJSON($json->__toString());
break;
case "search-query":
$object = SearchQueryObjectBuilder::buildFromJSON($json->__toString());
break;
case "search-result":
$object = SearchResultObjectBuilder::buildFromJSON($json->__toString());
break;
case "search-result-collection":
$object = SearchResultCollectionObjectBuilder::buildFromJSON($json->__toString());
break;
//case "signature":
//$object = SignaObjectBuilder::buildFromJSON($json->__toString());
//break;
// feature
// migration
case "activity":
$object = StreamItemObjectBuilder::buildFromJSON($json->__toString());
break;
case "tag":
$object = TagObjectBuilder::buildFromJSON($json->__toString());
break;
default:
throw new ModelFormatException("Not a valid object type");
break;
}
}
catch(Exception $e)
{
throw new ModelFormatException("Could not init object for " . strtolower($json->get("@type")) . ": " . $e->getMessage());
}
return $object;
} | [
"public",
"static",
"function",
"init",
"(",
"JSONObject",
"$",
"json",
")",
"{",
"$",
"object",
"=",
"NULL",
";",
"if",
"(",
"!",
"$",
"json",
"->",
"has",
"(",
"\"@type\"",
")",
")",
"throw",
"new",
"ModelFormatException",
"(",
"\"Not a valid object\"",
")",
";",
"try",
"{",
"switch",
"(",
"strtolower",
"(",
"$",
"json",
"->",
"get",
"(",
"\"@type\"",
")",
")",
")",
"{",
"case",
"\"comment\"",
":",
"$",
"object",
"=",
"CommentObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"like\"",
":",
"$",
"object",
"=",
"LikeObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"image\"",
":",
"$",
"object",
"=",
"ImageObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"profile\"",
":",
"$",
"object",
"=",
"ProfileObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"conversation\"",
":",
"$",
"object",
"=",
"ConversationObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"conversation-status\"",
":",
"$",
"object",
"=",
"ConversationStatusObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"conversation-message\"",
":",
"$",
"object",
"=",
"ConversationMessageObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"conversation-message-status\"",
":",
"$",
"object",
"=",
"ConversationMessageStatusObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"accesscontrolgroup\"",
":",
"$",
"object",
"=",
"AccessControlGroupObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"accesscontrolrule\"",
":",
"$",
"object",
"=",
"AccessControlRuleObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"link\"",
":",
"$",
"object",
"=",
"LinkObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"link-request\"",
":",
"$",
"object",
"=",
"LinkRequesObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"link-response\"",
":",
"$",
"object",
"=",
"LinkResponseObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"response\"",
":",
"$",
"object",
"=",
"ResponseObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"search-query\"",
":",
"$",
"object",
"=",
"SearchQueryObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"search-result\"",
":",
"$",
"object",
"=",
"SearchResultObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"search-result-collection\"",
":",
"$",
"object",
"=",
"SearchResultCollectionObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"//case \"signature\":",
"//$object = SignaObjectBuilder::buildFromJSON($json->__toString());",
"//break;",
"// feature",
"// migration",
"case",
"\"activity\"",
":",
"$",
"object",
"=",
"StreamItemObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"case",
"\"tag\"",
":",
"$",
"object",
"=",
"TagObjectBuilder",
"::",
"buildFromJSON",
"(",
"$",
"json",
"->",
"__toString",
"(",
")",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"ModelFormatException",
"(",
"\"Not a valid object type\"",
")",
";",
"break",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"ModelFormatException",
"(",
"\"Could not init object for \"",
".",
"strtolower",
"(",
"$",
"json",
"->",
"get",
"(",
"\"@type\"",
")",
")",
".",
"\": \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"return",
"$",
"object",
";",
"}"
] | Parses the JSONObject and creates a matching Sonic object
@param JSONObbject $json The JSONObject to parse
@return BasicObject
@throws ModelFormatException on malformed object content | [
"Parses",
"the",
"JSONObject",
"and",
"creates",
"a",
"matching",
"Sonic",
"object"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Model/ObjectFactory.php#L49-L153 |
4,881 | webservices-nl/utils | src/EntityUtils.php | EntityUtils.extractValueFromEntity | public static function extractValueFromEntity($entity, $property)
{
$getter = self::createGetter($entity, $property);
return $entity->$getter();
} | php | public static function extractValueFromEntity($entity, $property)
{
$getter = self::createGetter($entity, $property);
return $entity->$getter();
} | [
"public",
"static",
"function",
"extractValueFromEntity",
"(",
"$",
"entity",
",",
"$",
"property",
")",
"{",
"$",
"getter",
"=",
"self",
"::",
"createGetter",
"(",
"$",
"entity",
",",
"$",
"property",
")",
";",
"return",
"$",
"entity",
"->",
"$",
"getter",
"(",
")",
";",
"}"
] | Extract the value of a property from an entity.
@param mixed $entity
@param string $property
@throws \InvalidArgumentException
@return mixed | [
"Extract",
"the",
"value",
"of",
"a",
"property",
"from",
"an",
"entity",
"."
] | 052f41ff725808b19d529e640f890ce7c863e100 | https://github.com/webservices-nl/utils/blob/052f41ff725808b19d529e640f890ce7c863e100/src/EntityUtils.php#L20-L25 |
4,882 | AnonymPHP/Anonym-Library | src/Anonym/Cron/Cron.php | Cron.install | public function install(TaskReposity $job){
// install the default schedule
if (!$this->getBasic()->jobExists($job->buildCommandWithExpression())) {
$this->getBasic()->event(
function () use ($job) {
return $job;
}
);
$this->getBasic()->run();
}
} | php | public function install(TaskReposity $job){
// install the default schedule
if (!$this->getBasic()->jobExists($job->buildCommandWithExpression())) {
$this->getBasic()->event(
function () use ($job) {
return $job;
}
);
$this->getBasic()->run();
}
} | [
"public",
"function",
"install",
"(",
"TaskReposity",
"$",
"job",
")",
"{",
"// install the default schedule",
"if",
"(",
"!",
"$",
"this",
"->",
"getBasic",
"(",
")",
"->",
"jobExists",
"(",
"$",
"job",
"->",
"buildCommandWithExpression",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"getBasic",
"(",
")",
"->",
"event",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"job",
")",
"{",
"return",
"$",
"job",
";",
"}",
")",
";",
"$",
"this",
"->",
"getBasic",
"(",
")",
"->",
"run",
"(",
")",
";",
"}",
"}"
] | install the default cron
@param TaskReposity $job | [
"install",
"the",
"default",
"cron"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Cron.php#L55-L67 |
4,883 | AnonymPHP/Anonym-Library | src/Anonym/Cron/Cron.php | Cron.event | public function event(Closure $command)
{
$response = $command();
if ($this->resolveCommandResponse($response)) {
EventReposity::add($response);
}
} | php | public function event(Closure $command)
{
$response = $command();
if ($this->resolveCommandResponse($response)) {
EventReposity::add($response);
}
} | [
"public",
"function",
"event",
"(",
"Closure",
"$",
"command",
")",
"{",
"$",
"response",
"=",
"$",
"command",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"resolveCommandResponse",
"(",
"$",
"response",
")",
")",
"{",
"EventReposity",
"::",
"add",
"(",
"$",
"response",
")",
";",
"}",
"}"
] | add a new event to reposity
Note: $command must be a closure
@param Closure $command | [
"add",
"a",
"new",
"event",
"to",
"reposity"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Cron.php#L115-L122 |
4,884 | AnonymPHP/Anonym-Library | src/Anonym/Cron/Cron.php | Cron.run | public function run()
{
$events = $this->dueEvents(EventReposity::getEvents());
foreach ($events as $event) {
$event->execute();
}
} | php | public function run()
{
$events = $this->dueEvents(EventReposity::getEvents());
foreach ($events as $event) {
$event->execute();
}
} | [
"public",
"function",
"run",
"(",
")",
"{",
"$",
"events",
"=",
"$",
"this",
"->",
"dueEvents",
"(",
"EventReposity",
"::",
"getEvents",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"events",
"as",
"$",
"event",
")",
"{",
"$",
"event",
"->",
"execute",
"(",
")",
";",
"}",
"}"
] | run the all commands | [
"run",
"the",
"all",
"commands"
] | c967ad804f84e8fb204593a0959cda2fed5ae075 | https://github.com/AnonymPHP/Anonym-Library/blob/c967ad804f84e8fb204593a0959cda2fed5ae075/src/Anonym/Cron/Cron.php#L139-L146 |
4,885 | puli/asset-plugin | src/Api/Installation/NotInstallableException.php | NotInstallableException.targetNotFound | public static function targetNotFound($targetName, Exception $cause = null)
{
return new static(sprintf(
'The install target "%s" does not exist.',
$targetName
), self::TARGET_NOT_FOUND, $cause);
} | php | public static function targetNotFound($targetName, Exception $cause = null)
{
return new static(sprintf(
'The install target "%s" does not exist.',
$targetName
), self::TARGET_NOT_FOUND, $cause);
} | [
"public",
"static",
"function",
"targetNotFound",
"(",
"$",
"targetName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The install target \"%s\" does not exist.'",
",",
"$",
"targetName",
")",
",",
"self",
"::",
"TARGET_NOT_FOUND",
",",
"$",
"cause",
")",
";",
"}"
] | Creates an exception for a target name that was not found.
@param string $targetName The target name.
@param Exception $cause The exception that caused this exception.
@return static The created exception. | [
"Creates",
"an",
"exception",
"for",
"a",
"target",
"name",
"that",
"was",
"not",
"found",
"."
] | f36c4a403a2173aced54376690a399884cde2627 | https://github.com/puli/asset-plugin/blob/f36c4a403a2173aced54376690a399884cde2627/src/Api/Installation/NotInstallableException.php#L140-L146 |
4,886 | diatem-net/jin-webapp | src/WebApp/Context/Output.php | Output.addTo | public static function addTo($key, $value)
{
if (isset(self::$vars[$key])) {
self::$vars[$key] .= $value;
} else {
self::$vars[$key] = $value;
}
} | php | public static function addTo($key, $value)
{
if (isset(self::$vars[$key])) {
self::$vars[$key] .= $value;
} else {
self::$vars[$key] = $value;
}
} | [
"public",
"static",
"function",
"addTo",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"vars",
"[",
"$",
"key",
"]",
")",
")",
"{",
"self",
"::",
"$",
"vars",
"[",
"$",
"key",
"]",
".=",
"$",
"value",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"vars",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Add content to an existing variable
@param string $key Variable's name
@param string $value Value to add | [
"Add",
"content",
"to",
"an",
"existing",
"variable"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Context/Output.php#L58-L65 |
4,887 | diatem-net/jin-webapp | src/WebApp/Context/Output.php | Output.get | public static function get($key, $nullIfUndefined = true, $defaultValueIfUndefined = null)
{
if (!isset(self::$vars[$key])) {
if ($nullIfUndefined) {
if ($defaultValueIfUndefined) {
return $defaultValueIfUndefined;
}
return null;
} else {
throw new \Exception('Valeur '.$key.' non définie');
}
} else {
return self::$vars[$key];
}
} | php | public static function get($key, $nullIfUndefined = true, $defaultValueIfUndefined = null)
{
if (!isset(self::$vars[$key])) {
if ($nullIfUndefined) {
if ($defaultValueIfUndefined) {
return $defaultValueIfUndefined;
}
return null;
} else {
throw new \Exception('Valeur '.$key.' non définie');
}
} else {
return self::$vars[$key];
}
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"nullIfUndefined",
"=",
"true",
",",
"$",
"defaultValueIfUndefined",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"vars",
"[",
"$",
"key",
"]",
")",
")",
"{",
"if",
"(",
"$",
"nullIfUndefined",
")",
"{",
"if",
"(",
"$",
"defaultValueIfUndefined",
")",
"{",
"return",
"$",
"defaultValueIfUndefined",
";",
"}",
"return",
"null",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Valeur '",
".",
"$",
"key",
".",
"' non définie')",
";",
"\r",
"}",
"}",
"else",
"{",
"return",
"self",
"::",
"$",
"vars",
"[",
"$",
"key",
"]",
";",
"}",
"}"
] | Get a variable's content
@param string $key Variable's name
@param boolean $nullIfUndefined (optional) Return null if undefined (default: TRUE)
@param string $defaultValueIfUndefined (optional) Return a specified value if undefined
@return void | [
"Get",
"a",
"variable",
"s",
"content"
] | 43e85f780c3841a536e3a5d41929523e5aacd272 | https://github.com/diatem-net/jin-webapp/blob/43e85f780c3841a536e3a5d41929523e5aacd272/src/WebApp/Context/Output.php#L75-L89 |
4,888 | headzoo/core | src/Headzoo/Core/Conversions.php | Conversions.bytesToHuman | public static function bytesToHuman($bytes, $decimals = 2)
{
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(self::KILOBYTE));
$pow = min($pow, count(self::$byte_units) - 1);
$bytes /= pow(self::KILOBYTE, $pow);
return self::numberFormat($bytes, $decimals) . self::$byte_units[$pow];
} | php | public static function bytesToHuman($bytes, $decimals = 2)
{
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(self::KILOBYTE));
$pow = min($pow, count(self::$byte_units) - 1);
$bytes /= pow(self::KILOBYTE, $pow);
return self::numberFormat($bytes, $decimals) . self::$byte_units[$pow];
} | [
"public",
"static",
"function",
"bytesToHuman",
"(",
"$",
"bytes",
",",
"$",
"decimals",
"=",
"2",
")",
"{",
"$",
"bytes",
"=",
"max",
"(",
"$",
"bytes",
",",
"0",
")",
";",
"$",
"pow",
"=",
"floor",
"(",
"(",
"$",
"bytes",
"?",
"log",
"(",
"$",
"bytes",
")",
":",
"0",
")",
"/",
"log",
"(",
"self",
"::",
"KILOBYTE",
")",
")",
";",
"$",
"pow",
"=",
"min",
"(",
"$",
"pow",
",",
"count",
"(",
"self",
"::",
"$",
"byte_units",
")",
"-",
"1",
")",
";",
"$",
"bytes",
"/=",
"pow",
"(",
"self",
"::",
"KILOBYTE",
",",
"$",
"pow",
")",
";",
"return",
"self",
"::",
"numberFormat",
"(",
"$",
"bytes",
",",
"$",
"decimals",
")",
".",
"self",
"::",
"$",
"byte_units",
"[",
"$",
"pow",
"]",
";",
"}"
] | Converts a byte number into a human readable format
Examples:
```php
echo Conversions::bytesToHuman(100);
// Outputs: "100B"
echo Conversions::bytesToHuman(1024);
// Outputs: "1KB"
echo Conversions::bytesToHuman(1050);
// Outputs: "1.02KB"
```
@param int $bytes The number of bytes
@param int $decimals Number of decimal places to round to
@return string | [
"Converts",
"a",
"byte",
"number",
"into",
"a",
"human",
"readable",
"format"
] | 1e574813e197aa827b3e952f8caa81be31a8b5b5 | https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/Conversions.php#L90-L98 |
4,889 | ncuesta/pinocchio | src/Pinocchio/Formatter.php | Formatter.apply | protected function apply($pinocchio)
{
$variables = array(
'configuration' => $this->configuration,
'pinocchio' => $pinocchio,
);
ob_start();
extract($variables);
include($this->configuration->get('template'));
return ob_get_clean();
} | php | protected function apply($pinocchio)
{
$variables = array(
'configuration' => $this->configuration,
'pinocchio' => $pinocchio,
);
ob_start();
extract($variables);
include($this->configuration->get('template'));
return ob_get_clean();
} | [
"protected",
"function",
"apply",
"(",
"$",
"pinocchio",
")",
"{",
"$",
"variables",
"=",
"array",
"(",
"'configuration'",
"=>",
"$",
"this",
"->",
"configuration",
",",
"'pinocchio'",
"=>",
"$",
"pinocchio",
",",
")",
";",
"ob_start",
"(",
")",
";",
"extract",
"(",
"$",
"variables",
")",
";",
"include",
"(",
"$",
"this",
"->",
"configuration",
"->",
"get",
"(",
"'template'",
")",
")",
";",
"return",
"ob_get_clean",
"(",
")",
";",
"}"
] | Apply the formatter to the given Pinocchio instance.
Returns the resulting HTML page.
@param \Pinocchio\Pinocchio $pinocchio The Pinocchio instance to format.
@return string | [
"Apply",
"the",
"formatter",
"to",
"the",
"given",
"Pinocchio",
"instance",
".",
"Returns",
"the",
"resulting",
"HTML",
"page",
"."
] | 01b119a003362fd3a50e843341c62c95374d87cf | https://github.com/ncuesta/pinocchio/blob/01b119a003362fd3a50e843341c62c95374d87cf/src/Pinocchio/Formatter.php#L68-L81 |
4,890 | bluetree-service/register | src/Register.php | Register.factory | public function factory($namespace, array $args = [])
{
$namespace = $this->checkOverrider($namespace);
$this->classExists($namespace)
->callEvent('register_before_create', [$namespace, $args]);
try {
$object = new $namespace(...$args);
} catch (\Exception $exception) {
throw new RegisterException($exception);
}
$this->callEvent('register_after_create', [$object]);
$this->setClassCounter($namespace);
$this->registeredObjects[$namespace] = get_class($object);
$this->makeLog([
'Object created: ' . $namespace . '. With args:',
$args
]);
return $object;
} | php | public function factory($namespace, array $args = [])
{
$namespace = $this->checkOverrider($namespace);
$this->classExists($namespace)
->callEvent('register_before_create', [$namespace, $args]);
try {
$object = new $namespace(...$args);
} catch (\Exception $exception) {
throw new RegisterException($exception);
}
$this->callEvent('register_after_create', [$object]);
$this->setClassCounter($namespace);
$this->registeredObjects[$namespace] = get_class($object);
$this->makeLog([
'Object created: ' . $namespace . '. With args:',
$args
]);
return $object;
} | [
"public",
"function",
"factory",
"(",
"$",
"namespace",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
"{",
"$",
"namespace",
"=",
"$",
"this",
"->",
"checkOverrider",
"(",
"$",
"namespace",
")",
";",
"$",
"this",
"->",
"classExists",
"(",
"$",
"namespace",
")",
"->",
"callEvent",
"(",
"'register_before_create'",
",",
"[",
"$",
"namespace",
",",
"$",
"args",
"]",
")",
";",
"try",
"{",
"$",
"object",
"=",
"new",
"$",
"namespace",
"(",
"...",
"$",
"args",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"throw",
"new",
"RegisterException",
"(",
"$",
"exception",
")",
";",
"}",
"$",
"this",
"->",
"callEvent",
"(",
"'register_after_create'",
",",
"[",
"$",
"object",
"]",
")",
";",
"$",
"this",
"->",
"setClassCounter",
"(",
"$",
"namespace",
")",
";",
"$",
"this",
"->",
"registeredObjects",
"[",
"$",
"namespace",
"]",
"=",
"get_class",
"(",
"$",
"object",
")",
";",
"$",
"this",
"->",
"makeLog",
"(",
"[",
"'Object created: '",
".",
"$",
"namespace",
".",
"'. With args:'",
",",
"$",
"args",
"]",
")",
";",
"return",
"$",
"object",
";",
"}"
] | create new instance of given class
@param string $namespace
@param array $args
@return mixed
@throws \InvalidArgumentException
@throws RegisterException | [
"create",
"new",
"instance",
"of",
"given",
"class"
] | e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7 | https://github.com/bluetree-service/register/blob/e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7/src/Register.php#L94-L118 |
4,891 | bluetree-service/register | src/Register.php | Register.singletonFactory | public function singletonFactory($namespace, array $args = [], $name = null)
{
if (is_null($name)) {
$name = $namespace;
}
if (!isset($this->singletons[$name])) {
$this->singletons[$name] = $this->factory($namespace, $args);
}
$this->callEvent(
'register_before_return_singleton',
[$this->singletons[$name], $args, $name]
);
return $this->singletons[$name];
} | php | public function singletonFactory($namespace, array $args = [], $name = null)
{
if (is_null($name)) {
$name = $namespace;
}
if (!isset($this->singletons[$name])) {
$this->singletons[$name] = $this->factory($namespace, $args);
}
$this->callEvent(
'register_before_return_singleton',
[$this->singletons[$name], $args, $name]
);
return $this->singletons[$name];
} | [
"public",
"function",
"singletonFactory",
"(",
"$",
"namespace",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"name",
"=",
"$",
"namespace",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"singletons",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"singletons",
"[",
"$",
"name",
"]",
"=",
"$",
"this",
"->",
"factory",
"(",
"$",
"namespace",
",",
"$",
"args",
")",
";",
"}",
"$",
"this",
"->",
"callEvent",
"(",
"'register_before_return_singleton'",
",",
"[",
"$",
"this",
"->",
"singletons",
"[",
"$",
"name",
"]",
",",
"$",
"args",
",",
"$",
"name",
"]",
")",
";",
"return",
"$",
"this",
"->",
"singletons",
"[",
"$",
"name",
"]",
";",
"}"
] | create singleton instance of given class
@param string $namespace
@param array $args
@param null|string $name
@return mixed
@throws \InvalidArgumentException
@throws RegisterException | [
"create",
"singleton",
"instance",
"of",
"given",
"class"
] | e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7 | https://github.com/bluetree-service/register/blob/e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7/src/Register.php#L130-L146 |
4,892 | bluetree-service/register | src/Register.php | Register.checkOverrider | protected function checkOverrider($namespace)
{
if ($this->allowOverride && isset($this->overrides[$namespace])) {
$oldNamespace = $namespace;
$namespace = $this->overrides[$namespace]['overrider'];
$this->classExists($namespace);
if ($this->overrides[$oldNamespace]['only_once']) {
$this->unsetOverrider($oldNamespace);
}
}
return $namespace;
} | php | protected function checkOverrider($namespace)
{
if ($this->allowOverride && isset($this->overrides[$namespace])) {
$oldNamespace = $namespace;
$namespace = $this->overrides[$namespace]['overrider'];
$this->classExists($namespace);
if ($this->overrides[$oldNamespace]['only_once']) {
$this->unsetOverrider($oldNamespace);
}
}
return $namespace;
} | [
"protected",
"function",
"checkOverrider",
"(",
"$",
"namespace",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"allowOverride",
"&&",
"isset",
"(",
"$",
"this",
"->",
"overrides",
"[",
"$",
"namespace",
"]",
")",
")",
"{",
"$",
"oldNamespace",
"=",
"$",
"namespace",
";",
"$",
"namespace",
"=",
"$",
"this",
"->",
"overrides",
"[",
"$",
"namespace",
"]",
"[",
"'overrider'",
"]",
";",
"$",
"this",
"->",
"classExists",
"(",
"$",
"namespace",
")",
";",
"if",
"(",
"$",
"this",
"->",
"overrides",
"[",
"$",
"oldNamespace",
"]",
"[",
"'only_once'",
"]",
")",
"{",
"$",
"this",
"->",
"unsetOverrider",
"(",
"$",
"oldNamespace",
")",
";",
"}",
"}",
"return",
"$",
"namespace",
";",
"}"
] | check that given class should be replaced by some other
@param string $namespace
@return string
@throws \InvalidArgumentException | [
"check",
"that",
"given",
"class",
"should",
"be",
"replaced",
"by",
"some",
"other"
] | e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7 | https://github.com/bluetree-service/register/blob/e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7/src/Register.php#L155-L169 |
4,893 | bluetree-service/register | src/Register.php | Register.destroySingleton | public function destroySingleton($name = null)
{
if (is_null($name)) {
$this->singletons = [];
}
if (isset($this->singletons[$name])) {
unset($this->singletons[$name]);
}
$this->makeLog('Destroy singleton: ' . (is_null($name) ? 'all' : $name));
return $this;
} | php | public function destroySingleton($name = null)
{
if (is_null($name)) {
$this->singletons = [];
}
if (isset($this->singletons[$name])) {
unset($this->singletons[$name]);
}
$this->makeLog('Destroy singleton: ' . (is_null($name) ? 'all' : $name));
return $this;
} | [
"public",
"function",
"destroySingleton",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"singletons",
"=",
"[",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"singletons",
"[",
"$",
"name",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"singletons",
"[",
"$",
"name",
"]",
")",
";",
"}",
"$",
"this",
"->",
"makeLog",
"(",
"'Destroy singleton: '",
".",
"(",
"is_null",
"(",
"$",
"name",
")",
"?",
"'all'",
":",
"$",
"name",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | destroy called object
@param string $name
@return $this | [
"destroy",
"called",
"object"
] | e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7 | https://github.com/bluetree-service/register/blob/e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7/src/Register.php#L250-L263 |
4,894 | bluetree-service/register | src/Register.php | Register.unsetOverrider | public function unsetOverrider($namespace = null)
{
if (is_null($namespace)) {
$this->overrides = [];
} else {
unset($this->overrides[$namespace]);
}
$this->makeLog('Override unset for: ' . $namespace);
return $this;
} | php | public function unsetOverrider($namespace = null)
{
if (is_null($namespace)) {
$this->overrides = [];
} else {
unset($this->overrides[$namespace]);
}
$this->makeLog('Override unset for: ' . $namespace);
return $this;
} | [
"public",
"function",
"unsetOverrider",
"(",
"$",
"namespace",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"namespace",
")",
")",
"{",
"$",
"this",
"->",
"overrides",
"=",
"[",
"]",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"overrides",
"[",
"$",
"namespace",
"]",
")",
";",
"}",
"$",
"this",
"->",
"makeLog",
"(",
"'Override unset for: '",
".",
"$",
"namespace",
")",
";",
"return",
"$",
"this",
";",
"}"
] | disable given or all overriders
@param null|string $namespace
@return $this | [
"disable",
"given",
"or",
"all",
"overriders"
] | e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7 | https://github.com/bluetree-service/register/blob/e6eb7d4ad6bdf8d46b5fb14ce7f3c7dff62f25c7/src/Register.php#L347-L358 |
4,895 | faithmade/churchthemes | includes/classes/widget-categories.php | CTFW_Widget_Categories.ctc_redirect_taxonomy | function ctc_redirect_taxonomy() {
// Redirect is being attempted on front page with valid taxonomy
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';
if ( is_front_page() && ! empty( $_GET['redirect_taxonomy'] ) && taxonomy_exists( $_GET['redirect_taxonomy'] ) && ! empty( $id ) ) {
// Get pretty URL
$taxonomy = $_GET['redirect_taxonomy'];
$term_url = get_term_link( $id, $taxonomy );
// Send to URL
wp_redirect( $term_url, 301 );
}
} | php | function ctc_redirect_taxonomy() {
// Redirect is being attempted on front page with valid taxonomy
$id = isset( $_GET['id'] ) ? (int) $_GET['id'] : '';
if ( is_front_page() && ! empty( $_GET['redirect_taxonomy'] ) && taxonomy_exists( $_GET['redirect_taxonomy'] ) && ! empty( $id ) ) {
// Get pretty URL
$taxonomy = $_GET['redirect_taxonomy'];
$term_url = get_term_link( $id, $taxonomy );
// Send to URL
wp_redirect( $term_url, 301 );
}
} | [
"function",
"ctc_redirect_taxonomy",
"(",
")",
"{",
"// Redirect is being attempted on front page with valid taxonomy",
"$",
"id",
"=",
"isset",
"(",
"$",
"_GET",
"[",
"'id'",
"]",
")",
"?",
"(",
"int",
")",
"$",
"_GET",
"[",
"'id'",
"]",
":",
"''",
";",
"if",
"(",
"is_front_page",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"_GET",
"[",
"'redirect_taxonomy'",
"]",
")",
"&&",
"taxonomy_exists",
"(",
"$",
"_GET",
"[",
"'redirect_taxonomy'",
"]",
")",
"&&",
"!",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"// Get pretty URL",
"$",
"taxonomy",
"=",
"$",
"_GET",
"[",
"'redirect_taxonomy'",
"]",
";",
"$",
"term_url",
"=",
"get_term_link",
"(",
"$",
"id",
",",
"$",
"taxonomy",
")",
";",
"// Send to URL",
"wp_redirect",
"(",
"$",
"term_url",
",",
"301",
")",
";",
"}",
"}"
] | Redirect Dropdown URL
Dropdown selection results in URL like http://yourname.com/?redirect_taxonomy=ctc_sermon_topic&id=14
This uses that query string to get permalink for that taxonomy and term
@since 0.9 | [
"Redirect",
"Dropdown",
"URL"
] | b121e840edaec8fdb3189fc9324cc88d7a0db81c | https://github.com/faithmade/churchthemes/blob/b121e840edaec8fdb3189fc9324cc88d7a0db81c/includes/classes/widget-categories.php#L336-L351 |
4,896 | unclecheese/silverstripe-green | code/DataSource.php | DataSource.toDBObject | public function toDBObject()
{
$info = pathinfo($this->path);
switch ($info['extension']) {
case 'yaml':
case 'yml':
return DBField::create_field('YAMLField', file_get_contents($this->path));
case 'json':
return DBField::create_field('JSONField', file_get_contents($this->path));
default:
return null;
}
} | php | public function toDBObject()
{
$info = pathinfo($this->path);
switch ($info['extension']) {
case 'yaml':
case 'yml':
return DBField::create_field('YAMLField', file_get_contents($this->path));
case 'json':
return DBField::create_field('JSONField', file_get_contents($this->path));
default:
return null;
}
} | [
"public",
"function",
"toDBObject",
"(",
")",
"{",
"$",
"info",
"=",
"pathinfo",
"(",
"$",
"this",
"->",
"path",
")",
";",
"switch",
"(",
"$",
"info",
"[",
"'extension'",
"]",
")",
"{",
"case",
"'yaml'",
":",
"case",
"'yml'",
":",
"return",
"DBField",
"::",
"create_field",
"(",
"'YAMLField'",
",",
"file_get_contents",
"(",
"$",
"this",
"->",
"path",
")",
")",
";",
"case",
"'json'",
":",
"return",
"DBField",
"::",
"create_field",
"(",
"'JSONField'",
",",
"file_get_contents",
"(",
"$",
"this",
"->",
"path",
")",
")",
";",
"default",
":",
"return",
"null",
";",
"}",
"}"
] | Converts the file content into a SerialisedDBField
@return SerialisedDBField|null | [
"Converts",
"the",
"file",
"content",
"into",
"a",
"SerialisedDBField"
] | 4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4 | https://github.com/unclecheese/silverstripe-green/blob/4395dcef5f4efd5a2c67e0bba3ab5cc583e3fdd4/code/DataSource.php#L45-L59 |
4,897 | yujin1st/yii2-user | commands/RbacController.php | RbacController.actionInit | public function actionInit() {
$rbac = new Rbac();
$rbac->initRolesAndActions();
$this->stdout(Yii::t('users', 'Roles updated') . "\n", Console::FG_GREEN);
} | php | public function actionInit() {
$rbac = new Rbac();
$rbac->initRolesAndActions();
$this->stdout(Yii::t('users', 'Roles updated') . "\n", Console::FG_GREEN);
} | [
"public",
"function",
"actionInit",
"(",
")",
"{",
"$",
"rbac",
"=",
"new",
"Rbac",
"(",
")",
";",
"$",
"rbac",
"->",
"initRolesAndActions",
"(",
")",
";",
"$",
"this",
"->",
"stdout",
"(",
"Yii",
"::",
"t",
"(",
"'users'",
",",
"'Roles updated'",
")",
".",
"\"\\n\"",
",",
"Console",
"::",
"FG_GREEN",
")",
";",
"}"
] | Init all roles | [
"Init",
"all",
"roles"
] | b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f | https://github.com/yujin1st/yii2-user/blob/b404c77acf4a96f0cdf9bb0af5c8d62bcae3946f/commands/RbacController.php#L21-L25 |
4,898 | headzoo/core | src/Headzoo/Core/AbstractEnum.php | AbstractEnum.equals | public function equals($value)
{
if (is_object($value) && get_class($value) == get_class($this)) {
$equals = $value->value() === $this->value();
} else {
$equals = $this->value() === ((string)$value);
}
return $equals;
} | php | public function equals($value)
{
if (is_object($value) && get_class($value) == get_class($this)) {
$equals = $value->value() === $this->value();
} else {
$equals = $this->value() === ((string)$value);
}
return $equals;
} | [
"public",
"function",
"equals",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"get_class",
"(",
"$",
"value",
")",
"==",
"get_class",
"(",
"$",
"this",
")",
")",
"{",
"$",
"equals",
"=",
"$",
"value",
"->",
"value",
"(",
")",
"===",
"$",
"this",
"->",
"value",
"(",
")",
";",
"}",
"else",
"{",
"$",
"equals",
"=",
"$",
"this",
"->",
"value",
"(",
")",
"===",
"(",
"(",
"string",
")",
"$",
"value",
")",
";",
"}",
"return",
"$",
"equals",
";",
"}"
] | Returns whether the value is equal to this value
Performs a strict comparison of this enum value, and another value. The other value may be either a string,
or another instance of the same enum.
@param string|AbstractEnum $value The value to compare
@return bool | [
"Returns",
"whether",
"the",
"value",
"is",
"equal",
"to",
"this",
"value"
] | 1e574813e197aa827b3e952f8caa81be31a8b5b5 | https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/AbstractEnum.php#L233-L242 |
4,899 | headzoo/core | src/Headzoo/Core/AbstractEnum.php | AbstractEnum.validate | private static function validate()
{
$me = get_called_class();
if (!isset(self::$consts[$me])) {
$constants = self::constants();
if (!isset($constants["__DEFAULT"])) {
self::toss(
"UndefinedConstantException",
"Class {me} does have a __DEFAULT constant."
);
}
foreach($constants as $name => $value) {
if ("__DEFAULT" !== $name && $name !== $value) {
self::toss(
"LogicException",
"Constant {me}:{0} does not match value {1}.",
$name,
$value
);
}
}
self::$consts[$me] = $constants;
}
return self::$consts[$me];
} | php | private static function validate()
{
$me = get_called_class();
if (!isset(self::$consts[$me])) {
$constants = self::constants();
if (!isset($constants["__DEFAULT"])) {
self::toss(
"UndefinedConstantException",
"Class {me} does have a __DEFAULT constant."
);
}
foreach($constants as $name => $value) {
if ("__DEFAULT" !== $name && $name !== $value) {
self::toss(
"LogicException",
"Constant {me}:{0} does not match value {1}.",
$name,
$value
);
}
}
self::$consts[$me] = $constants;
}
return self::$consts[$me];
} | [
"private",
"static",
"function",
"validate",
"(",
")",
"{",
"$",
"me",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"consts",
"[",
"$",
"me",
"]",
")",
")",
"{",
"$",
"constants",
"=",
"self",
"::",
"constants",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"constants",
"[",
"\"__DEFAULT\"",
"]",
")",
")",
"{",
"self",
"::",
"toss",
"(",
"\"UndefinedConstantException\"",
",",
"\"Class {me} does have a __DEFAULT constant.\"",
")",
";",
"}",
"foreach",
"(",
"$",
"constants",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"\"__DEFAULT\"",
"!==",
"$",
"name",
"&&",
"$",
"name",
"!==",
"$",
"value",
")",
"{",
"self",
"::",
"toss",
"(",
"\"LogicException\"",
",",
"\"Constant {me}:{0} does not match value {1}.\"",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"self",
"::",
"$",
"consts",
"[",
"$",
"me",
"]",
"=",
"$",
"constants",
";",
"}",
"return",
"self",
"::",
"$",
"consts",
"[",
"$",
"me",
"]",
";",
"}"
] | Validates the enum class definition for correctness
Checks the class has defined a __DEFAULT constant, and that the constant names and values
match each other. This check only needs to be performed the first time an instance of the
class is created, so the results of the validation are cached in the self::$consts property.
Future invocations of the class will skip the validation checks.
The self::$consts property must be static so each instance has access to the same cache data.
Once a class has been validated, an array of the class constants are saved in the self::$consts
array using the name of the validated class as the key.
Returns an array of the class constants.
@return array
@throws \Headzoo\Core\Exceptions\LogicException When the child class defines constants with non-string values
@throws \Headzoo\Core\Exceptions\UndefinedConstantException When the child class does not define a __DEFAULT constant | [
"Validates",
"the",
"enum",
"class",
"definition",
"for",
"correctness"
] | 1e574813e197aa827b3e952f8caa81be31a8b5b5 | https://github.com/headzoo/core/blob/1e574813e197aa827b3e952f8caa81be31a8b5b5/src/Headzoo/Core/AbstractEnum.php#L358-L385 |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.