id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
34,900 | mike182uk/cart | src/Cart.php | Cart.save | public function save()
{
$data = serialize($this->toArray());
$this->store->put($this->id, $data);
} | php | public function save()
{
$data = serialize($this->toArray());
$this->store->put($this->id, $data);
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"data",
"=",
"serialize",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
")",
";",
"$",
"this",
"->",
"store",
"->",
"put",
"(",
"$",
"this",
"->",
"id",
",",
"$",
"data",
")",
";",
"}"
] | Save the cart state. | [
"Save",
"the",
"cart",
"state",
"."
] | 88dadd4b419826336b9a60296264c085d969f77a | https://github.com/mike182uk/cart/blob/88dadd4b419826336b9a60296264c085d969f77a/src/Cart.php#L252-L257 |
34,901 | mike182uk/cart | src/Cart.php | Cart.restore | public function restore()
{
$state = $this->store->get($this->id);
if ($state == '') {
return;
}
$data = @unserialize($state); // suppress unserializable error
$this->restoreCheckType($data);
$this->restoreCheckContents($data);
$this->restoreChe... | php | public function restore()
{
$state = $this->store->get($this->id);
if ($state == '') {
return;
}
$data = @unserialize($state); // suppress unserializable error
$this->restoreCheckType($data);
$this->restoreCheckContents($data);
$this->restoreChe... | [
"public",
"function",
"restore",
"(",
")",
"{",
"$",
"state",
"=",
"$",
"this",
"->",
"store",
"->",
"get",
"(",
"$",
"this",
"->",
"id",
")",
";",
"if",
"(",
"$",
"state",
"==",
"''",
")",
"{",
"return",
";",
"}",
"$",
"data",
"=",
"@",
"uns... | Restore the cart from its saved state.
@throws CartRestoreException | [
"Restore",
"the",
"cart",
"from",
"its",
"saved",
"state",
"."
] | 88dadd4b419826336b9a60296264c085d969f77a | https://github.com/mike182uk/cart/blob/88dadd4b419826336b9a60296264c085d969f77a/src/Cart.php#L264-L284 |
34,902 | mike182uk/cart | src/Cart.php | Cart.toArray | public function toArray()
{
return [
'id' => $this->id,
'items' => array_map(function (CartItem $item) {
return $item->toArray();
}, $this->items),
];
} | php | public function toArray()
{
return [
'id' => $this->id,
'items' => array_map(function (CartItem $item) {
return $item->toArray();
}, $this->items),
];
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"return",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"id",
",",
"'items'",
"=>",
"array_map",
"(",
"function",
"(",
"CartItem",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"->",
"toArray",
"(",
")",
";",
... | Export the cart as an array.
@return array | [
"Export",
"the",
"cart",
"as",
"an",
"array",
"."
] | 88dadd4b419826336b9a60296264c085d969f77a | https://github.com/mike182uk/cart/blob/88dadd4b419826336b9a60296264c085d969f77a/src/Cart.php#L337-L345 |
34,903 | izniburak/php-router | src/Router/RouterRequest.php | RouterRequest.validMethod | public static function validMethod($data, $method)
{
$valid = false;
if (strstr($data, '|')) {
foreach (explode('|', $data) as $value) {
$valid = self::checkMethods($value, $method);
if ($valid) {
break;
}
}
... | php | public static function validMethod($data, $method)
{
$valid = false;
if (strstr($data, '|')) {
foreach (explode('|', $data) as $value) {
$valid = self::checkMethods($value, $method);
if ($valid) {
break;
}
}
... | [
"public",
"static",
"function",
"validMethod",
"(",
"$",
"data",
",",
"$",
"method",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"if",
"(",
"strstr",
"(",
"$",
"data",
",",
"'|'",
")",
")",
"{",
"foreach",
"(",
"explode",
"(",
"'|'",
",",
"$",
"da... | Request method validation
@param string $data
@param string $method
@return bool | [
"Request",
"method",
"validation"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router/RouterRequest.php#L28-L43 |
34,904 | izniburak/php-router | src/Router/RouterRequest.php | RouterRequest.checkMethods | protected static function checkMethods($value, $method)
{
$valid = false;
if ($value === 'AJAX' && self::isAjax() && $value === $method) {
$valid = true;
} elseif ($value === 'AJAXP' && self::isAjax() && $method === 'POST') {
$valid = true;
} elseif (in_array(... | php | protected static function checkMethods($value, $method)
{
$valid = false;
if ($value === 'AJAX' && self::isAjax() && $value === $method) {
$valid = true;
} elseif ($value === 'AJAXP' && self::isAjax() && $method === 'POST') {
$valid = true;
} elseif (in_array(... | [
"protected",
"static",
"function",
"checkMethods",
"(",
"$",
"value",
",",
"$",
"method",
")",
"{",
"$",
"valid",
"=",
"false",
";",
"if",
"(",
"$",
"value",
"===",
"'AJAX'",
"&&",
"self",
"::",
"isAjax",
"(",
")",
"&&",
"$",
"value",
"===",
"$",
"... | check method valid
@param string $value
@param string $method
@return bool | [
"check",
"method",
"valid"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router/RouterRequest.php#L53-L65 |
34,905 | izniburak/php-router | src/Router/RouterCommand.php | RouterCommand.beforeAfter | public function beforeAfter($command, $path = '', $namespace = '')
{
if (! is_null($command)) {
if (is_array($command)) {
foreach ($command as $key => $value) {
$this->beforeAfter($value, $path, $namespace);
}
} elseif (is_string($c... | php | public function beforeAfter($command, $path = '', $namespace = '')
{
if (! is_null($command)) {
if (is_array($command)) {
foreach ($command as $key => $value) {
$this->beforeAfter($value, $path, $namespace);
}
} elseif (is_string($c... | [
"public",
"function",
"beforeAfter",
"(",
"$",
"command",
",",
"$",
"path",
"=",
"''",
",",
"$",
"namespace",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"command",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"command",
")",
")"... | Run Route Middlewares
@param $command
@param $path
@param $namespace
@return mixed|void
@throws | [
"Run",
"Route",
"Middlewares"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router/RouterCommand.php#L56-L74 |
34,906 | izniburak/php-router | src/Router/RouterCommand.php | RouterCommand.resolveClass | protected function resolveClass($class, $path, $namespace)
{
$file = realpath(rtrim($path, '/') . '/' . $class . '.php');
if (! file_exists($file)) {
return $this->exception($class . ' class is not found. Please, check file.');
}
require_once($file);
$class = $na... | php | protected function resolveClass($class, $path, $namespace)
{
$file = realpath(rtrim($path, '/') . '/' . $class . '.php');
if (! file_exists($file)) {
return $this->exception($class . ' class is not found. Please, check file.');
}
require_once($file);
$class = $na... | [
"protected",
"function",
"resolveClass",
"(",
"$",
"class",
",",
"$",
"path",
",",
"$",
"namespace",
")",
"{",
"$",
"file",
"=",
"realpath",
"(",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"'/'",
".",
"$",
"class",
".",
"'.php'",
")",
";",
... | Resolve Controller or Middleware class.
@param $class
@param $path
@param $namespace
@return object
@throws | [
"Resolve",
"Controller",
"or",
"Middleware",
"class",
"."
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router/RouterCommand.php#L124-L135 |
34,907 | izniburak/php-router | src/Router.php | Router.setPaths | protected function setPaths($params)
{
if (isset($params['paths']) && $paths = $params['paths']) {
$this->paths['controllers'] =
isset($paths['controllers'])
? trim($paths['controllers'], '/')
: $this->paths['controllers'];
$th... | php | protected function setPaths($params)
{
if (isset($params['paths']) && $paths = $params['paths']) {
$this->paths['controllers'] =
isset($paths['controllers'])
? trim($paths['controllers'], '/')
: $this->paths['controllers'];
$th... | [
"protected",
"function",
"setPaths",
"(",
"$",
"params",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'paths'",
"]",
")",
"&&",
"$",
"paths",
"=",
"$",
"params",
"[",
"'paths'",
"]",
")",
"{",
"$",
"this",
"->",
"paths",
"[",
"'controlle... | Set paths and namespaces for Controllers and Middlewares.
@param array $params
@return void | [
"Set",
"paths",
"and",
"namespaces",
"for",
"Controllers",
"and",
"Middlewares",
"."
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L117-L156 |
34,908 | izniburak/php-router | src/Router.php | Router.add | public function add($methods, $route, $settings, $callback = null)
{
if($this->cacheLoaded) {
return true;
}
if (is_null($callback)) {
$callback = $settings;
$settings = null;
}
if (strstr($methods, '|')) {
foreach (array_uniq... | php | public function add($methods, $route, $settings, $callback = null)
{
if($this->cacheLoaded) {
return true;
}
if (is_null($callback)) {
$callback = $settings;
$settings = null;
}
if (strstr($methods, '|')) {
foreach (array_uniq... | [
"public",
"function",
"add",
"(",
"$",
"methods",
",",
"$",
"route",
",",
"$",
"settings",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheLoaded",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_null",
"(",
... | Add new route method one or more http methods.
@param string $methods
@param string $route
@param array|string|closure $settings
@param string|closure $callback
@return bool | [
"Add",
"new",
"route",
"method",
"one",
"or",
"more",
"http",
"methods",
"."
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L229-L251 |
34,909 | izniburak/php-router | src/Router.php | Router.pattern | public function pattern($pattern, $attr = null)
{
if (is_array($pattern)) {
foreach ($pattern as $key => $value) {
if (! in_array('{' . $key . '}', array_keys($this->patterns))) {
$this->patterns['{' . $key . '}'] = '(' . $value . ')';
} else {... | php | public function pattern($pattern, $attr = null)
{
if (is_array($pattern)) {
foreach ($pattern as $key => $value) {
if (! in_array('{' . $key . '}', array_keys($this->patterns))) {
$this->patterns['{' . $key . '}'] = '(' . $value . ')';
} else {... | [
"public",
"function",
"pattern",
"(",
"$",
"pattern",
",",
"$",
"attr",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"pattern",
")",
")",
"{",
"foreach",
"(",
"$",
"pattern",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
... | Add new route rules pattern; String or Array
@param string|array $pattern
@param null|string $attr
@return mixed
@throws | [
"Add",
"new",
"route",
"rules",
"pattern",
";",
"String",
"or",
"Array"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L262-L281 |
34,910 | izniburak/php-router | src/Router.php | Router.controller | public function controller($route, $settings, $controller = null)
{
if($this->cacheLoaded) {
return true;
}
if (is_null($controller)) {
$controller = $settings;
$settings = [];
}
$controller = str_replace(['\\', '.'], '/', $controller);
... | php | public function controller($route, $settings, $controller = null)
{
if($this->cacheLoaded) {
return true;
}
if (is_null($controller)) {
$controller = $settings;
$settings = [];
}
$controller = str_replace(['\\', '.'], '/', $controller);
... | [
"public",
"function",
"controller",
"(",
"$",
"route",
",",
"$",
"settings",
",",
"$",
"controller",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"cacheLoaded",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"controller... | Added route from methods of Controller file.
@param string $route
@param string|array $settings
@param null|string $controller
@return mixed
@throws | [
"Added",
"route",
"from",
"methods",
"of",
"Controller",
"file",
"."
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L454-L508 |
34,911 | izniburak/php-router | src/Router.php | Router.addRoute | private function addRoute($uri, $method, $callback, $settings)
{
$groupItem = count($this->groups) - 1;
$group = '';
if ($groupItem > -1) {
foreach ($this->groups as $key => $value) {
$group .= $value['route'];
}
}
$page = dirname($_SE... | php | private function addRoute($uri, $method, $callback, $settings)
{
$groupItem = count($this->groups) - 1;
$group = '';
if ($groupItem > -1) {
foreach ($this->groups as $key => $value) {
$group .= $value['route'];
}
}
$page = dirname($_SE... | [
"private",
"function",
"addRoute",
"(",
"$",
"uri",
",",
"$",
"method",
",",
"$",
"callback",
",",
"$",
"settings",
")",
"{",
"$",
"groupItem",
"=",
"count",
"(",
"$",
"this",
"->",
"groups",
")",
"-",
"1",
";",
"$",
"group",
"=",
"''",
";",
"if"... | Add new Route and it's settings
@param $uri
@param $method
@param $callback
@param $settings
@return void | [
"Add",
"new",
"Route",
"and",
"it",
"s",
"settings"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L532-L574 |
34,912 | izniburak/php-router | src/Router.php | Router.runRouteMiddleware | public function runRouteMiddleware($middleware, $type)
{
$middlewarePath = $this->baseFolder . '/' . $this->paths['middlewares'];
$middlewareNs = $this->namespaces['middlewares'];
if ($type == 'before') {
if (! is_null($middleware['group'])) {
$this->routerCommand... | php | public function runRouteMiddleware($middleware, $type)
{
$middlewarePath = $this->baseFolder . '/' . $this->paths['middlewares'];
$middlewareNs = $this->namespaces['middlewares'];
if ($type == 'before') {
if (! is_null($middleware['group'])) {
$this->routerCommand... | [
"public",
"function",
"runRouteMiddleware",
"(",
"$",
"middleware",
",",
"$",
"type",
")",
"{",
"$",
"middlewarePath",
"=",
"$",
"this",
"->",
"baseFolder",
".",
"'/'",
".",
"$",
"this",
"->",
"paths",
"[",
"'middlewares'",
"]",
";",
"$",
"middlewareNs",
... | Detect Routes Middleware; before or after
@param $middleware
@param $type
@return void | [
"Detect",
"Routes",
"Middleware",
";",
"before",
"or",
"after"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L601-L624 |
34,913 | izniburak/php-router | src/Router.php | Router.cache | public function cache()
{
foreach($this->getRoutes() as $key => $r) {
if (!is_string($r['callback'])) {
throw new Exception(sprintf('Routes cannot contain a Closure/Function callback while caching.'));
}
}
$cacheContent = '<?php return '.var_export($t... | php | public function cache()
{
foreach($this->getRoutes() as $key => $r) {
if (!is_string($r['callback'])) {
throw new Exception(sprintf('Routes cannot contain a Closure/Function callback while caching.'));
}
}
$cacheContent = '<?php return '.var_export($t... | [
"public",
"function",
"cache",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getRoutes",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"r",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"r",
"[",
"'callback'",
"]",
")",
")",
"{",
"throw",
"new... | Cache all routes
@return bool
@throws Exception | [
"Cache",
"all",
"routes"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L688-L702 |
34,914 | izniburak/php-router | src/Router.php | Router.loadCache | protected function loadCache()
{
if (file_exists($this->cacheFile)) {
$this->routes = require $this->cacheFile;
$this->cacheLoaded = true;
return true;
}
return false;
} | php | protected function loadCache()
{
if (file_exists($this->cacheFile)) {
$this->routes = require $this->cacheFile;
$this->cacheLoaded = true;
return true;
}
return false;
} | [
"protected",
"function",
"loadCache",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"cacheFile",
")",
")",
"{",
"$",
"this",
"->",
"routes",
"=",
"require",
"$",
"this",
"->",
"cacheFile",
";",
"$",
"this",
"->",
"cacheLoaded",
"=",
... | Load Cache file
@return bool | [
"Load",
"Cache",
"file"
] | cc75420df6c0c889123aa0051cbab446c7d79e07 | https://github.com/izniburak/php-router/blob/cc75420df6c0c889123aa0051cbab446c7d79e07/src/Router.php#L709-L718 |
34,915 | Litecms/Block | src/Block.php | Block.count | public function count($module)
{
if (User::hasRole('user')) {
$this->block->pushCriteria(new \Litecms\Block\Repositories\Criteria\BlockUserCriteria());
}
if ($module == 'block') {
return $this->block
->scopeQuery(function ($query) {
... | php | public function count($module)
{
if (User::hasRole('user')) {
$this->block->pushCriteria(new \Litecms\Block\Repositories\Criteria\BlockUserCriteria());
}
if ($module == 'block') {
return $this->block
->scopeQuery(function ($query) {
... | [
"public",
"function",
"count",
"(",
"$",
"module",
")",
"{",
"if",
"(",
"User",
"::",
"hasRole",
"(",
"'user'",
")",
")",
"{",
"$",
"this",
"->",
"block",
"->",
"pushCriteria",
"(",
"new",
"\\",
"Litecms",
"\\",
"Block",
"\\",
"Repositories",
"\\",
"... | Returns count of blog or category.
@param array $filter
@return int | [
"Returns",
"count",
"of",
"blog",
"or",
"category",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Block.php#L34-L64 |
34,916 | Litecms/Block | src/Block.php | Block.selectCategories | public function selectCategories()
{
$temp = [];
$category = $this->category->scopeQuery(function ($query) {
return $query->whereStatus('Show')->orderBy('name', 'ASC');
})->all();
foreach ($category as $key => $value) {
$temp[$value->id] = ucfirst($value->nam... | php | public function selectCategories()
{
$temp = [];
$category = $this->category->scopeQuery(function ($query) {
return $query->whereStatus('Show')->orderBy('name', 'ASC');
})->all();
foreach ($category as $key => $value) {
$temp[$value->id] = ucfirst($value->nam... | [
"public",
"function",
"selectCategories",
"(",
")",
"{",
"$",
"temp",
"=",
"[",
"]",
";",
"$",
"category",
"=",
"$",
"this",
"->",
"category",
"->",
"scopeQuery",
"(",
"function",
"(",
"$",
"query",
")",
"{",
"return",
"$",
"query",
"->",
"whereStatus"... | take block category
@return array | [
"take",
"block",
"category"
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Block.php#L71-L83 |
34,917 | Litecms/Block | src/Block.php | Block.display | public function display($category)
{
$view = (View::exists("block::{$category}")) ? "block::{$category}" : "block::default";
$category = $this->category
->scopeQuery(function ($query) use ($category) {
return $query->with('blocks')->whereSlug($category);
... | php | public function display($category)
{
$view = (View::exists("block::{$category}")) ? "block::{$category}" : "block::default";
$category = $this->category
->scopeQuery(function ($query) use ($category) {
return $query->with('blocks')->whereSlug($category);
... | [
"public",
"function",
"display",
"(",
"$",
"category",
")",
"{",
"$",
"view",
"=",
"(",
"View",
"::",
"exists",
"(",
"\"block::{$category}\"",
")",
")",
"?",
"\"block::{$category}\"",
":",
"\"block::default\"",
";",
"$",
"category",
"=",
"$",
"this",
"->",
... | take latest blocks for public side
@param type $count
@param type|string $view
@return type | [
"take",
"latest",
"blocks",
"for",
"public",
"side"
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Block.php#L92-L104 |
34,918 | Litecms/Block | src/Http/Controllers/CategoryResourceController.php | CategoryResourceController.show | public function show(CategoryRequest $request, Category $category)
{
if ($category->exists) {
$view = 'block::admin.category.show';
} else {
$view = 'block::admin.category.new';
}
return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('block::c... | php | public function show(CategoryRequest $request, Category $category)
{
if ($category->exists) {
$view = 'block::admin.category.show';
} else {
$view = 'block::admin.category.new';
}
return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('block::c... | [
"public",
"function",
"show",
"(",
"CategoryRequest",
"$",
"request",
",",
"Category",
"$",
"category",
")",
"{",
"if",
"(",
"$",
"category",
"->",
"exists",
")",
"{",
"$",
"view",
"=",
"'block::admin.category.show'",
";",
"}",
"else",
"{",
"$",
"view",
... | Display category.
@param Request $request
@param Model $category
@return Response | [
"Display",
"category",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Http/Controllers/CategoryResourceController.php#L66-L79 |
34,919 | Litecms/Block | src/Policies/CategoryPolicy.php | CategoryPolicy.view | public function view(User $user, Category $category)
{
if ($user->canDo('block.category.view') && $user->isAdmin()) {
return true;
}
return $user->id == $category->user_id;
} | php | public function view(User $user, Category $category)
{
if ($user->canDo('block.category.view') && $user->isAdmin()) {
return true;
}
return $user->id == $category->user_id;
} | [
"public",
"function",
"view",
"(",
"User",
"$",
"user",
",",
"Category",
"$",
"category",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"canDo",
"(",
"'block.category.view'",
")",
"&&",
"$",
"user",
"->",
"isAdmin",
"(",
")",
")",
"{",
"return",
"true",
";... | Determine if the given user can view the category.
@param User $user
@param Category $category
@return bool | [
"Determine",
"if",
"the",
"given",
"user",
"can",
"view",
"the",
"category",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Policies/CategoryPolicy.php#L21-L29 |
34,920 | Litecms/Block | src/Http/Controllers/BlockResourceController.php | BlockResourceController.index | public function index(BlockRequest $request)
{
if ($this->response->typeIs('json')) {
$pageLimit = $request->input('pageLimit');
$data = $this->repository
->setPresenter(\Litecms\Block\Repositories\Presenter\BlockListPresenter::class)
->getDataTa... | php | public function index(BlockRequest $request)
{
if ($this->response->typeIs('json')) {
$pageLimit = $request->input('pageLimit');
$data = $this->repository
->setPresenter(\Litecms\Block\Repositories\Presenter\BlockListPresenter::class)
->getDataTa... | [
"public",
"function",
"index",
"(",
"BlockRequest",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"response",
"->",
"typeIs",
"(",
"'json'",
")",
")",
"{",
"$",
"pageLimit",
"=",
"$",
"request",
"->",
"input",
"(",
"'pageLimit'",
")",
";",
... | Display a list of block.
@return Response | [
"Display",
"a",
"list",
"of",
"block",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Http/Controllers/BlockResourceController.php#L37-L56 |
34,921 | Litecms/Block | src/Http/Controllers/BlockResourceController.php | BlockResourceController.show | public function show(BlockRequest $request, Block $block)
{
if ($block->exists) {
$view = 'block::admin.block.show';
} else {
$view = 'block::admin.block.new';
}
return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('block::block.name'))
... | php | public function show(BlockRequest $request, Block $block)
{
if ($block->exists) {
$view = 'block::admin.block.show';
} else {
$view = 'block::admin.block.new';
}
return $this->response->setMetaTitle(trans('app.view') . ' ' . trans('block::block.name'))
... | [
"public",
"function",
"show",
"(",
"BlockRequest",
"$",
"request",
",",
"Block",
"$",
"block",
")",
"{",
"if",
"(",
"$",
"block",
"->",
"exists",
")",
"{",
"$",
"view",
"=",
"'block::admin.block.show'",
";",
"}",
"else",
"{",
"$",
"view",
"=",
"'block:... | Display block.
@param Request $request
@param Model $block
@return Response | [
"Display",
"block",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Http/Controllers/BlockResourceController.php#L66-L79 |
34,922 | Litecms/Block | src/Http/Controllers/BlockResourceController.php | BlockResourceController.create | public function create(BlockRequest $request)
{
$block = $this->repository->newInstance([]);
return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('block::block.name'))
->view('block::admin.block.create')
->data(compact('block'))
->output();
} | php | public function create(BlockRequest $request)
{
$block = $this->repository->newInstance([]);
return $this->response->setMetaTitle(trans('app.new') . ' ' . trans('block::block.name'))
->view('block::admin.block.create')
->data(compact('block'))
->output();
} | [
"public",
"function",
"create",
"(",
"BlockRequest",
"$",
"request",
")",
"{",
"$",
"block",
"=",
"$",
"this",
"->",
"repository",
"->",
"newInstance",
"(",
"[",
"]",
")",
";",
"return",
"$",
"this",
"->",
"response",
"->",
"setMetaTitle",
"(",
"trans",
... | Show the form for creating a new block.
@param Request $request
@return Response | [
"Show",
"the",
"form",
"for",
"creating",
"a",
"new",
"block",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Http/Controllers/BlockResourceController.php#L88-L96 |
34,923 | Litecms/Block | src/Http/Controllers/BlockResourceController.php | BlockResourceController.edit | public function edit(BlockRequest $request, Block $block)
{
return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('block::block.name'))
->view('block::admin.block.edit')
->data(compact('block'))
->output();
} | php | public function edit(BlockRequest $request, Block $block)
{
return $this->response->setMetaTitle(trans('app.edit') . ' ' . trans('block::block.name'))
->view('block::admin.block.edit')
->data(compact('block'))
->output();
} | [
"public",
"function",
"edit",
"(",
"BlockRequest",
"$",
"request",
",",
"Block",
"$",
"block",
")",
"{",
"return",
"$",
"this",
"->",
"response",
"->",
"setMetaTitle",
"(",
"trans",
"(",
"'app.edit'",
")",
".",
"' '",
".",
"trans",
"(",
"'block::block.name... | Show block for editing.
@param Request $request
@param Model $block
@return Response | [
"Show",
"block",
"for",
"editing",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Http/Controllers/BlockResourceController.php#L136-L142 |
34,924 | Litecms/Block | src/Http/Controllers/BlockResourceController.php | BlockResourceController.update | public function update(BlockRequest $request, Block $block)
{
try {
$attributes = $request->all();
$block->update($attributes);
return $this->response->message(trans('messages.success.updated', ['Module' => trans('block::block.name')]))
->code(204)
... | php | public function update(BlockRequest $request, Block $block)
{
try {
$attributes = $request->all();
$block->update($attributes);
return $this->response->message(trans('messages.success.updated', ['Module' => trans('block::block.name')]))
->code(204)
... | [
"public",
"function",
"update",
"(",
"BlockRequest",
"$",
"request",
",",
"Block",
"$",
"block",
")",
"{",
"try",
"{",
"$",
"attributes",
"=",
"$",
"request",
"->",
"all",
"(",
")",
";",
"$",
"block",
"->",
"update",
"(",
"$",
"attributes",
")",
";",... | Update the block.
@param Request $request
@param Model $block
@return Response | [
"Update",
"the",
"block",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Http/Controllers/BlockResourceController.php#L152-L171 |
34,925 | Litecms/Block | src/Http/Controllers/BlockResourceController.php | BlockResourceController.destroy | public function destroy(BlockRequest $request, Block $block)
{
try {
$block->delete();
return $this->response->message(trans('messages.success.deleted', ['Module' => trans('block::block.name')]))
->code(202)
->status('success')
->url(g... | php | public function destroy(BlockRequest $request, Block $block)
{
try {
$block->delete();
return $this->response->message(trans('messages.success.deleted', ['Module' => trans('block::block.name')]))
->code(202)
->status('success')
->url(g... | [
"public",
"function",
"destroy",
"(",
"BlockRequest",
"$",
"request",
",",
"Block",
"$",
"block",
")",
"{",
"try",
"{",
"$",
"block",
"->",
"delete",
"(",
")",
";",
"return",
"$",
"this",
"->",
"response",
"->",
"message",
"(",
"trans",
"(",
"'messages... | Remove the block.
@param Model $block
@return Response | [
"Remove",
"the",
"block",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Http/Controllers/BlockResourceController.php#L180-L200 |
34,926 | Litecms/Block | src/Policies/BlockPolicy.php | BlockPolicy.update | public function update(User $user, Block $block)
{
if ($user->canDo('block.block.update') && $user->isAdmin()) {
return true;
}
return $user->id == $block->user_id;
} | php | public function update(User $user, Block $block)
{
if ($user->canDo('block.block.update') && $user->isAdmin()) {
return true;
}
return $user->id == $block->user_id;
} | [
"public",
"function",
"update",
"(",
"User",
"$",
"user",
",",
"Block",
"$",
"block",
")",
"{",
"if",
"(",
"$",
"user",
"->",
"canDo",
"(",
"'block.block.update'",
")",
"&&",
"$",
"user",
"->",
"isAdmin",
"(",
")",
")",
"{",
"return",
"true",
";",
... | Determine if the given user can update the given block.
@param User $user
@param Block $block
@return bool | [
"Determine",
"if",
"the",
"given",
"user",
"can",
"update",
"the",
"given",
"block",
"."
] | 79b6abff0180a2fabeb3574e883972ddd44daaa6 | https://github.com/Litecms/Block/blob/79b6abff0180a2fabeb3574e883972ddd44daaa6/src/Policies/BlockPolicy.php#L52-L60 |
34,927 | spatie/7to5 | src/NodeVisitors/AnonymousClassReplacer.php | AnonymousClassReplacer.getAnonymousClassHookIndex | protected function getAnonymousClassHookIndex(array $statements)
{
$hookIndex = false;
foreach ($statements as $index => $statement) {
if (!$statement instanceof Declare_ &&
!$statement instanceof Use_ &&
!$statement instanceof Namespace_) {
... | php | protected function getAnonymousClassHookIndex(array $statements)
{
$hookIndex = false;
foreach ($statements as $index => $statement) {
if (!$statement instanceof Declare_ &&
!$statement instanceof Use_ &&
!$statement instanceof Namespace_) {
... | [
"protected",
"function",
"getAnonymousClassHookIndex",
"(",
"array",
"$",
"statements",
")",
"{",
"$",
"hookIndex",
"=",
"false",
";",
"foreach",
"(",
"$",
"statements",
"as",
"$",
"index",
"=>",
"$",
"statement",
")",
"{",
"if",
"(",
"!",
"$",
"statement"... | Find the index of the first statement that is not a declare, use or namespace statement.
@param array $statements
@return int
@throws \Spatie\Php7to5\Exceptions\InvalidPhpCode | [
"Find",
"the",
"index",
"of",
"the",
"first",
"statement",
"that",
"is",
"not",
"a",
"declare",
"use",
"or",
"namespace",
"statement",
"."
] | 64d1e12570eb3e4ce4976245ba48e881383b5580 | https://github.com/spatie/7to5/blob/64d1e12570eb3e4ce4976245ba48e881383b5580/src/NodeVisitors/AnonymousClassReplacer.php#L79-L96 |
34,928 | rairlie/laravel-locking-session | src/Rairlie/LockingSession/LockingSessionServiceProvider.php | LockingSessionServiceProvider.register | public function register()
{
$this->registerSessionManager();
$this->registerSessionDriver();
$this->app->singleton('Illuminate\Session\Middleware\StartSession', function ($app) {
return new Middleware\StartSession($app->make('session'));
});
} | php | public function register()
{
$this->registerSessionManager();
$this->registerSessionDriver();
$this->app->singleton('Illuminate\Session\Middleware\StartSession', function ($app) {
return new Middleware\StartSession($app->make('session'));
});
} | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"registerSessionManager",
"(",
")",
";",
"$",
"this",
"->",
"registerSessionDriver",
"(",
")",
";",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'Illuminate\\Session\\Middleware\\StartSess... | Override so we return our own Middleware\StartSession
@return void | [
"Override",
"so",
"we",
"return",
"our",
"own",
"Middleware",
"\\",
"StartSession"
] | 93a623a7eacbcab6ef29b4f036ec35d7383d7395 | https://github.com/rairlie/laravel-locking-session/blob/93a623a7eacbcab6ef29b4f036ec35d7383d7395/src/Rairlie/LockingSession/LockingSessionServiceProvider.php#L14-L23 |
34,929 | rairlie/laravel-locking-session | src/Rairlie/LockingSession/Lock.php | Lock.acquire | public function acquire()
{
if ($this->lockfp) {
$this->log("acquire - existing lock");
return;
}
$this->openLockFile();
$this->log("acquire - try lock");
flock($this->lockfp, LOCK_EX);
$this->log("acquire - got lock");
} | php | public function acquire()
{
if ($this->lockfp) {
$this->log("acquire - existing lock");
return;
}
$this->openLockFile();
$this->log("acquire - try lock");
flock($this->lockfp, LOCK_EX);
$this->log("acquire - got lock");
} | [
"public",
"function",
"acquire",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"lockfp",
")",
"{",
"$",
"this",
"->",
"log",
"(",
"\"acquire - existing lock\"",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"openLockFile",
"(",
")",
";",
"$",
"this... | Acquire an exclusive lock. Will block if locked by another process. | [
"Acquire",
"an",
"exclusive",
"lock",
".",
"Will",
"block",
"if",
"locked",
"by",
"another",
"process",
"."
] | 93a623a7eacbcab6ef29b4f036ec35d7383d7395 | https://github.com/rairlie/laravel-locking-session/blob/93a623a7eacbcab6ef29b4f036ec35d7383d7395/src/Rairlie/LockingSession/Lock.php#L46-L57 |
34,930 | rairlie/laravel-locking-session | src/Rairlie/LockingSession/Lock.php | Lock.release | public function release()
{
if (!$this->lockfp) {
throw new UnderflowException("No lock to release");
}
$this->log("release");
flock($this->lockfp, LOCK_UN);
$this->closeLockFile();
} | php | public function release()
{
if (!$this->lockfp) {
throw new UnderflowException("No lock to release");
}
$this->log("release");
flock($this->lockfp, LOCK_UN);
$this->closeLockFile();
} | [
"public",
"function",
"release",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"lockfp",
")",
"{",
"throw",
"new",
"UnderflowException",
"(",
"\"No lock to release\"",
")",
";",
"}",
"$",
"this",
"->",
"log",
"(",
"\"release\"",
")",
";",
"flock",
... | Release an acquired lock | [
"Release",
"an",
"acquired",
"lock"
] | 93a623a7eacbcab6ef29b4f036ec35d7383d7395 | https://github.com/rairlie/laravel-locking-session/blob/93a623a7eacbcab6ef29b4f036ec35d7383d7395/src/Rairlie/LockingSession/Lock.php#L62-L71 |
34,931 | rairlie/laravel-locking-session | src/Rairlie/LockingSession/Lock.php | Lock.openLockFile | protected function openLockFile()
{
if (!is_dir(dirname($this->lockfilePath))) {
// Suppress warning on mkdir - may be created by another process
@mkdir(dirname($this->lockfilePath), 0744, true);
}
$this->lockfp = fopen($this->lockfilePath, 'w+');
} | php | protected function openLockFile()
{
if (!is_dir(dirname($this->lockfilePath))) {
// Suppress warning on mkdir - may be created by another process
@mkdir(dirname($this->lockfilePath), 0744, true);
}
$this->lockfp = fopen($this->lockfilePath, 'w+');
} | [
"protected",
"function",
"openLockFile",
"(",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"this",
"->",
"lockfilePath",
")",
")",
")",
"{",
"// Suppress warning on mkdir - may be created by another process",
"@",
"mkdir",
"(",
"dirname",
"(",
"... | Open the lock file on disk, creating it if it doesn't exist | [
"Open",
"the",
"lock",
"file",
"on",
"disk",
"creating",
"it",
"if",
"it",
"doesn",
"t",
"exist"
] | 93a623a7eacbcab6ef29b4f036ec35d7383d7395 | https://github.com/rairlie/laravel-locking-session/blob/93a623a7eacbcab6ef29b4f036ec35d7383d7395/src/Rairlie/LockingSession/Lock.php#L95-L102 |
34,932 | rairlie/laravel-locking-session | src/Rairlie/LockingSession/Lock.php | Lock.log | protected function log($message)
{
$this->debug && Log::info($this->lockfilePath . ' ' . getmypid() . ' ' . $message);
} | php | protected function log($message)
{
$this->debug && Log::info($this->lockfilePath . ' ' . getmypid() . ' ' . $message);
} | [
"protected",
"function",
"log",
"(",
"$",
"message",
")",
"{",
"$",
"this",
"->",
"debug",
"&&",
"Log",
"::",
"info",
"(",
"$",
"this",
"->",
"lockfilePath",
".",
"' '",
".",
"getmypid",
"(",
")",
".",
"' '",
".",
"$",
"message",
")",
";",
"}"
] | Log a debug diagnostic message, if enabled | [
"Log",
"a",
"debug",
"diagnostic",
"message",
"if",
"enabled"
] | 93a623a7eacbcab6ef29b4f036ec35d7383d7395 | https://github.com/rairlie/laravel-locking-session/blob/93a623a7eacbcab6ef29b4f036ec35d7383d7395/src/Rairlie/LockingSession/Lock.php#L118-L121 |
34,933 | LUSHDigital/microservice-core | src/Pagination/Response.php | Response.snakeFormat | public function snakeFormat()
{
$snake = new \stdClass;
$rawValues = get_object_vars($this);
foreach ($rawValues as $property => $value){
$snake->{Str::snake($property)} = $value;
}
return $snake;
} | php | public function snakeFormat()
{
$snake = new \stdClass;
$rawValues = get_object_vars($this);
foreach ($rawValues as $property => $value){
$snake->{Str::snake($property)} = $value;
}
return $snake;
} | [
"public",
"function",
"snakeFormat",
"(",
")",
"{",
"$",
"snake",
"=",
"new",
"\\",
"stdClass",
";",
"$",
"rawValues",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"rawValues",
"as",
"$",
"property",
"=>",
"$",
"value",
")",... | Format the response object with snake case properties.
@return \stdClass | [
"Format",
"the",
"response",
"object",
"with",
"snake",
"case",
"properties",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Pagination/Response.php#L209-L219 |
34,934 | LUSHDigital/microservice-core | src/Helpers/MicroServiceHelper.php | MicroServiceHelper.jsonResponseFormatter | public static function jsonResponseFormatter($type, $data, $code = 200, $status = Status::OK, $message = '')
{
// Validate the arguments.
if ($status == Status::OK && empty($type)) {
throw new Exception('Cannot prepare response. No type specified');
}
else {
$... | php | public static function jsonResponseFormatter($type, $data, $code = 200, $status = Status::OK, $message = '')
{
// Validate the arguments.
if ($status == Status::OK && empty($type)) {
throw new Exception('Cannot prepare response. No type specified');
}
else {
$... | [
"public",
"static",
"function",
"jsonResponseFormatter",
"(",
"$",
"type",
",",
"$",
"data",
",",
"$",
"code",
"=",
"200",
",",
"$",
"status",
"=",
"Status",
"::",
"OK",
",",
"$",
"message",
"=",
"''",
")",
"{",
"// Validate the arguments.",
"if",
"(",
... | Prepare a response an endpoint.
This ensures that all API endpoints return data in a standardised format:
{
"status": "ok", - Can contain any string. Usually 'ok', 'error' etc.
"code": 200, - A HTTP status code.
"message": "", - A message string elaborating on the status.
"data": {[ - A collection of return data. Can... | [
"Prepare",
"a",
"response",
"an",
"endpoint",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Helpers/MicroServiceHelper.php#L64-L96 |
34,935 | LUSHDigital/microservice-core | src/Traits/MicroServiceStringTrait.php | MicroServiceStringTrait.padTrim | protected function padTrim($input, $pad = '0', $length = 3, $mode = STR_PAD_LEFT)
{
// Make sure we have a string.
if (!is_string($input)) {
$input = (string) $input;
}
return substr(str_pad($input, $length, $pad, $mode), 0, $length);
} | php | protected function padTrim($input, $pad = '0', $length = 3, $mode = STR_PAD_LEFT)
{
// Make sure we have a string.
if (!is_string($input)) {
$input = (string) $input;
}
return substr(str_pad($input, $length, $pad, $mode), 0, $length);
} | [
"protected",
"function",
"padTrim",
"(",
"$",
"input",
",",
"$",
"pad",
"=",
"'0'",
",",
"$",
"length",
"=",
"3",
",",
"$",
"mode",
"=",
"STR_PAD_LEFT",
")",
"{",
"// Make sure we have a string.",
"if",
"(",
"!",
"is_string",
"(",
"$",
"input",
")",
")... | Trim a string to the specified length. Padding if necessary.
@param string $input
The input string.
@param string $pad
The padding character.
@param int $length
The length of string we want.
@param int $mode
The string padding mode.
@return string | [
"Trim",
"a",
"string",
"to",
"the",
"specified",
"length",
".",
"Padding",
"if",
"necessary",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceStringTrait.php#L30-L38 |
34,936 | LUSHDigital/microservice-core | src/Traits/MicroServiceJsonResponseTrait.php | MicroServiceJsonResponseTrait.generateResponse | protected function generateResponse($type, $data, $code = 200, $status = Status::OK, $message = '')
{
if ($code == 204) {
return response('', 204);
}
$returnData = MicroServiceHelper::jsonResponseFormatter($type, $data, $code, $status, $message);
return response()->jso... | php | protected function generateResponse($type, $data, $code = 200, $status = Status::OK, $message = '')
{
if ($code == 204) {
return response('', 204);
}
$returnData = MicroServiceHelper::jsonResponseFormatter($type, $data, $code, $status, $message);
return response()->jso... | [
"protected",
"function",
"generateResponse",
"(",
"$",
"type",
",",
"$",
"data",
",",
"$",
"code",
"=",
"200",
",",
"$",
"status",
"=",
"Status",
"::",
"OK",
",",
"$",
"message",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"code",
"==",
"204",
")",
"{",... | Generate a response object in the microservices expected format.
@param string $type
The type of data being returned. Will be used to name the collection.
@param object|array|NULL $data
The data to return. Will always be parsed into a collection.
@param int $code
HTTP status code for the response.
@param string $statu... | [
"Generate",
"a",
"response",
"object",
"in",
"the",
"microservices",
"expected",
"format",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceJsonResponseTrait.php#L36-L43 |
34,937 | LUSHDigital/microservice-core | src/Traits/MicroServiceJsonResponseTrait.php | MicroServiceJsonResponseTrait.generatePaginatedResponse | protected function generatePaginatedResponse(Paginator $paginator, $type, $data, $code = 200, $status = Status::OK, $message = '')
{
$returnData = MicroServiceHelper::jsonResponseFormatter($type, $data, $code, $status, $message);
// Append the pagination response to the data.
$returnData->p... | php | protected function generatePaginatedResponse(Paginator $paginator, $type, $data, $code = 200, $status = Status::OK, $message = '')
{
$returnData = MicroServiceHelper::jsonResponseFormatter($type, $data, $code, $status, $message);
// Append the pagination response to the data.
$returnData->p... | [
"protected",
"function",
"generatePaginatedResponse",
"(",
"Paginator",
"$",
"paginator",
",",
"$",
"type",
",",
"$",
"data",
",",
"$",
"code",
"=",
"200",
",",
"$",
"status",
"=",
"Status",
"::",
"OK",
",",
"$",
"message",
"=",
"''",
")",
"{",
"$",
... | Generate a paginated response object in the microservices expected format.
@param Paginator $paginator
A paginator for the data being returned.
@param string $type
The type of data being returned. Will be used to name the collection.
@param object|array|NULL $data
The data to return. Will always be parsed into a colle... | [
"Generate",
"a",
"paginated",
"response",
"object",
"in",
"the",
"microservices",
"expected",
"format",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceJsonResponseTrait.php#L63-L71 |
34,938 | LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.isMicroServiceException | public function isMicroServiceException(Exception $e)
{
foreach ($this->microServicesExceptionTypes as $exceptionType) {
if ($e instanceof $exceptionType) {
return true;
}
}
return false;
} | php | public function isMicroServiceException(Exception $e)
{
foreach ($this->microServicesExceptionTypes as $exceptionType) {
if ($e instanceof $exceptionType) {
return true;
}
}
return false;
} | [
"public",
"function",
"isMicroServiceException",
"(",
"Exception",
"$",
"e",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"microServicesExceptionTypes",
"as",
"$",
"exceptionType",
")",
"{",
"if",
"(",
"$",
"e",
"instanceof",
"$",
"exceptionType",
")",
"{",
... | Check if the supplied exception is of any of the types we handle.
@param Exception $e
@return bool | [
"Check",
"if",
"the",
"supplied",
"exception",
"is",
"of",
"any",
"of",
"the",
"types",
"we",
"handle",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L42-L51 |
34,939 | LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleMicroServiceException | public function handleMicroServiceException(Exception $e)
{
// Determine the status code and message to return.
if ($e instanceof HttpException) {
return $this->handleHttpException($e);
} elseif ($e instanceof ModelNotFoundException) {
return $this->handleModelNotFoun... | php | public function handleMicroServiceException(Exception $e)
{
// Determine the status code and message to return.
if ($e instanceof HttpException) {
return $this->handleHttpException($e);
} elseif ($e instanceof ModelNotFoundException) {
return $this->handleModelNotFoun... | [
"public",
"function",
"handleMicroServiceException",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Determine the status code and message to return.",
"if",
"(",
"$",
"e",
"instanceof",
"HttpException",
")",
"{",
"return",
"$",
"this",
"->",
"handleHttpException",
"(",
"$"... | Handle the exception and produce a valid JSON response.
@param Exception $e
@return \Illuminate\Http\JsonResponse | [
"Handle",
"the",
"exception",
"and",
"produce",
"a",
"valid",
"JSON",
"response",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L59-L71 |
34,940 | LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleHttpException | protected function handleHttpException(Exception $e)
{
$statusCode = $e->getStatusCode();
// if there is no exception message just get the standard HTTP text.
if (empty($e->getMessage())) {
$message = Response::$statusTexts[$statusCode];
} else {
$message = $... | php | protected function handleHttpException(Exception $e)
{
$statusCode = $e->getStatusCode();
// if there is no exception message just get the standard HTTP text.
if (empty($e->getMessage())) {
$message = Response::$statusTexts[$statusCode];
} else {
$message = $... | [
"protected",
"function",
"handleHttpException",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"statusCode",
"=",
"$",
"e",
"->",
"getStatusCode",
"(",
")",
";",
"// if there is no exception message just get the standard HTTP text.",
"if",
"(",
"empty",
"(",
"$",
"e",
... | Handle a HTTP exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"HTTP",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L79-L91 |
34,941 | LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleModelNotFoundException | protected function handleModelNotFoundException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 404;
$reflection = new \ReflectionClass($e->getModel());
$message = $reflection->getShortName() . ' not found';
return $this->generateResponse('', null... | php | protected function handleModelNotFoundException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 404;
$reflection = new \ReflectionClass($e->getModel());
$message = $reflection->getShortName() . ' not found';
return $this->generateResponse('', null... | [
"protected",
"function",
"handleModelNotFoundException",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Get the status code and build the message.",
"$",
"statusCode",
"=",
"404",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"e",
"->",
"getModel... | Handle a model not found exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"model",
"not",
"found",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L99-L107 |
34,942 | LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleValidationException | protected function handleValidationException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 422;
$message = $e->getMessage();
$errorData = $e->getResponse()->getData();
return $this->generateResponse('errors', $errorData, $statusCode, Status::FAI... | php | protected function handleValidationException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 422;
$message = $e->getMessage();
$errorData = $e->getResponse()->getData();
return $this->generateResponse('errors', $errorData, $statusCode, Status::FAI... | [
"protected",
"function",
"handleValidationException",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Get the status code and build the message.",
"$",
"statusCode",
"=",
"422",
";",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"errorData",
"... | Handle a validation exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"validation",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L115-L123 |
34,943 | LUSHDigital/microservice-core | src/Traits/MicroServiceExceptionHandlerTrait.php | MicroServiceExceptionHandlerTrait.handleGenericException | protected function handleGenericException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 500;
$message = $e->getMessage();
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | php | protected function handleGenericException(Exception $e)
{
// Get the status code and build the message.
$statusCode = 500;
$message = $e->getMessage();
return $this->generateResponse('', null, $statusCode, Status::FAIL, $message);
} | [
"protected",
"function",
"handleGenericException",
"(",
"Exception",
"$",
"e",
")",
"{",
"// Get the status code and build the message.",
"$",
"statusCode",
"=",
"500",
";",
"$",
"message",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"$",
"this",... | Handle a generic exception and build return data.
@param Exception $e
@return mixed | [
"Handle",
"a",
"generic",
"exception",
"and",
"build",
"return",
"data",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Traits/MicroServiceExceptionHandlerTrait.php#L131-L138 |
34,944 | LUSHDigital/microservice-core | src/Http/Controllers/MicroServiceController.php | MicroServiceController.info | public function info()
{
// Build the response object.
$serviceInfo = (object) MicroServiceHelper::getServiceInfo();
$serviceInfo->endpoints = [];
// Add the endpoints.
foreach (app()->getRoutes() as $appRoute) {
$endpoint = new \stdClass();
$endpoint... | php | public function info()
{
// Build the response object.
$serviceInfo = (object) MicroServiceHelper::getServiceInfo();
$serviceInfo->endpoints = [];
// Add the endpoints.
foreach (app()->getRoutes() as $appRoute) {
$endpoint = new \stdClass();
$endpoint... | [
"public",
"function",
"info",
"(",
")",
"{",
"// Build the response object.",
"$",
"serviceInfo",
"=",
"(",
"object",
")",
"MicroServiceHelper",
"::",
"getServiceInfo",
"(",
")",
";",
"$",
"serviceInfo",
"->",
"endpoints",
"=",
"[",
"]",
";",
"// Add the endpoin... | Retrieve information about this microservice.
Required by the service registry.
@return Response | [
"Retrieve",
"information",
"about",
"this",
"microservice",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Http/Controllers/MicroServiceController.php#L35-L51 |
34,945 | LUSHDigital/microservice-core | src/Http/Controllers/MicroServiceController.php | MicroServiceController.health | public function health()
{
try {
// Logic for validating health (e.g. connections to external
// services) should go here.
// If a cache driver is defined, check it is working.
if (!empty(env('CACHE_DRIVER', null))) {
Cache::put('health_check'... | php | public function health()
{
try {
// Logic for validating health (e.g. connections to external
// services) should go here.
// If a cache driver is defined, check it is working.
if (!empty(env('CACHE_DRIVER', null))) {
Cache::put('health_check'... | [
"public",
"function",
"health",
"(",
")",
"{",
"try",
"{",
"// Logic for validating health (e.g. connections to external",
"// services) should go here.",
"// If a cache driver is defined, check it is working.",
"if",
"(",
"!",
"empty",
"(",
"env",
"(",
"'CACHE_DRIVER'",
",",
... | Retrieve a health check for this microservice.
Required by the service gateway and load balancer.
@return Response | [
"Retrieve",
"a",
"health",
"check",
"for",
"this",
"microservice",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Http/Controllers/MicroServiceController.php#L60-L83 |
34,946 | LUSHDigital/microservice-core | src/Pagination/Paginator.php | Paginator.preparePaginationResponse | public function preparePaginationResponse()
{
return new Response($this->total, $this->perPage, $this->page, $this->lastPage);
} | php | public function preparePaginationResponse()
{
return new Response($this->total, $this->perPage, $this->page, $this->lastPage);
} | [
"public",
"function",
"preparePaginationResponse",
"(",
")",
"{",
"return",
"new",
"Response",
"(",
"$",
"this",
"->",
"total",
",",
"$",
"this",
"->",
"perPage",
",",
"$",
"this",
"->",
"page",
",",
"$",
"this",
"->",
"lastPage",
")",
";",
"}"
] | Prepare the pagination response.
@return Response | [
"Prepare",
"the",
"pagination",
"response",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Pagination/Paginator.php#L178-L181 |
34,947 | LUSHDigital/microservice-core | src/Pagination/Paginator.php | Paginator.calculateOffset | protected function calculateOffset()
{
if (empty($this->page) || empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate offset. Insufficient data');
}
$this->offset = ($this->page - 1) * $this->perPage;
} | php | protected function calculateOffset()
{
if (empty($this->page) || empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate offset. Insufficient data');
}
$this->offset = ($this->page - 1) * $this->perPage;
} | [
"protected",
"function",
"calculateOffset",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"page",
")",
"||",
"empty",
"(",
"$",
"this",
"->",
"perPage",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Cannot calculate offset. I... | Calculate the offset based on the current values. | [
"Calculate",
"the",
"offset",
"based",
"on",
"the",
"current",
"values",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Pagination/Paginator.php#L186-L193 |
34,948 | LUSHDigital/microservice-core | src/Pagination/Paginator.php | Paginator.calculateLastPage | protected function calculateLastPage()
{
if (empty($this->total)) {
$this->lastPage = 0;
return;
}
if (empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate last page. Insufficient data');
}
$this->lastPage = (int) ceil($... | php | protected function calculateLastPage()
{
if (empty($this->total)) {
$this->lastPage = 0;
return;
}
if (empty($this->perPage)) {
throw new \RuntimeException('Cannot calculate last page. Insufficient data');
}
$this->lastPage = (int) ceil($... | [
"protected",
"function",
"calculateLastPage",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"total",
")",
")",
"{",
"$",
"this",
"->",
"lastPage",
"=",
"0",
";",
"return",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"perPage"... | Calculate the last page based on the current values. | [
"Calculate",
"the",
"last",
"page",
"based",
"on",
"the",
"current",
"values",
"."
] | 8455b7c0d53f2d06bcbfd2854191bf0da1f263f5 | https://github.com/LUSHDigital/microservice-core/blob/8455b7c0d53f2d06bcbfd2854191bf0da1f263f5/src/Pagination/Paginator.php#L198-L210 |
34,949 | view-components/grids | src/Component/Column.php | Column.formatValue | public function formatValue($value)
{
$formatter = $this->getValueFormatter();
return (string)($formatter ? call_user_func($formatter, $value, $this->getGrid()->getCurrentRow()) : $value);
} | php | public function formatValue($value)
{
$formatter = $this->getValueFormatter();
return (string)($formatter ? call_user_func($formatter, $value, $this->getGrid()->getCurrentRow()) : $value);
} | [
"public",
"function",
"formatValue",
"(",
"$",
"value",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getValueFormatter",
"(",
")",
";",
"return",
"(",
"string",
")",
"(",
"$",
"formatter",
"?",
"call_user_func",
"(",
"$",
"formatter",
",",
"$",
... | Formats value extracted from data row.
@param $value
@return string | [
"Formats",
"value",
"extracted",
"from",
"data",
"row",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/Column.php#L93-L97 |
34,950 | view-components/grids | src/Component/Column.php | Column.getCurrentValue | public function getCurrentValue()
{
$func = $this->getValueCalculator();
$currentDataRow = $this->getGrid()->getCurrentRow();
if ($func !== null) {
return call_user_func($func, $currentDataRow);
} else {
return mp\getValue($currentDataRow, $this->getDataField... | php | public function getCurrentValue()
{
$func = $this->getValueCalculator();
$currentDataRow = $this->getGrid()->getCurrentRow();
if ($func !== null) {
return call_user_func($func, $currentDataRow);
} else {
return mp\getValue($currentDataRow, $this->getDataField... | [
"public",
"function",
"getCurrentValue",
"(",
")",
"{",
"$",
"func",
"=",
"$",
"this",
"->",
"getValueCalculator",
"(",
")",
";",
"$",
"currentDataRow",
"=",
"$",
"this",
"->",
"getGrid",
"(",
")",
"->",
"getCurrentRow",
"(",
")",
";",
"if",
"(",
"$",
... | Returns current data cell value.
@return mixed | [
"Returns",
"current",
"data",
"cell",
"value",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/Column.php#L104-L113 |
34,951 | view-components/grids | src/Component/Column.php | Column.getLabel | public function getLabel()
{
if ($this->label === null) {
$this->label = ucwords(str_replace(array('-', '_', '.'), ' ', $this->id));
}
return $this->label;
} | php | public function getLabel()
{
if ($this->label === null) {
$this->label = ucwords(str_replace(array('-', '_', '.'), ' ', $this->id));
}
return $this->label;
} | [
"public",
"function",
"getLabel",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"label",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"label",
"=",
"ucwords",
"(",
"str_replace",
"(",
"array",
"(",
"'-'",
",",
"'_'",
",",
"'.'",
")",
",",
"' '",
",... | Returns text label that will be rendered in table header.
@return string | [
"Returns",
"text",
"label",
"that",
"will",
"be",
"rendered",
"in",
"table",
"header",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/Column.php#L270-L276 |
34,952 | view-components/grids | src/Component/ColumnSortingControl.php | ColumnSortingControl.getDirection | protected function getDirection()
{
if (!$this->inputOption->hasValue()) {
return null;
}
list($columnName, $direction) = explode(static::DELIMITER, $this->inputOption->getValue());
if ($columnName !== $this->columnId) {
return null;
}
return $... | php | protected function getDirection()
{
if (!$this->inputOption->hasValue()) {
return null;
}
list($columnName, $direction) = explode(static::DELIMITER, $this->inputOption->getValue());
if ($columnName !== $this->columnId) {
return null;
}
return $... | [
"protected",
"function",
"getDirection",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"inputOption",
"->",
"hasValue",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"list",
"(",
"$",
"columnName",
",",
"$",
"direction",
")",
"=",
"explode",
"(... | Returns sorting direction for attached column if specified in input.
@return string|null 'asc', 'desc' or null | [
"Returns",
"sorting",
"direction",
"for",
"attached",
"column",
"if",
"specified",
"in",
"input",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/ColumnSortingControl.php#L40-L50 |
34,953 | view-components/grids | src/Component/ColumnSortingControl.php | ColumnSortingControl.getOperation | public function getOperation()
{
$direction = $this->getDirection();
if ($direction === null) {
return new DummyOperation();
}
if ($this->root !== null) {
/** @var Grid $root */
$root = $this->root;
$fieldName = $root->getColumn($this->... | php | public function getOperation()
{
$direction = $this->getDirection();
if ($direction === null) {
return new DummyOperation();
}
if ($this->root !== null) {
/** @var Grid $root */
$root = $this->root;
$fieldName = $root->getColumn($this->... | [
"public",
"function",
"getOperation",
"(",
")",
"{",
"$",
"direction",
"=",
"$",
"this",
"->",
"getDirection",
"(",
")",
";",
"if",
"(",
"$",
"direction",
"===",
"null",
")",
"{",
"return",
"new",
"DummyOperation",
"(",
")",
";",
"}",
"if",
"(",
"$",... | Creates operation for data provider.
@return DummyOperation|SortOperation | [
"Creates",
"operation",
"for",
"data",
"provider",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/ColumnSortingControl.php#L69-L83 |
34,954 | view-components/grids | src/GridPartsAccessTrait.php | GridPartsAccessTrait.setTable | public function setTable(ContainerComponentInterface $component)
{
return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID);
} | php | public function setTable(ContainerComponentInterface $component)
{
return $this->setComponent($component, Grid::TABLE_ID, Grid::FORM_ID);
} | [
"public",
"function",
"setTable",
"(",
"ContainerComponentInterface",
"$",
"component",
")",
"{",
"return",
"$",
"this",
"->",
"setComponent",
"(",
"$",
"component",
",",
"Grid",
"::",
"TABLE_ID",
",",
"Grid",
"::",
"FORM_ID",
")",
";",
"}"
] | Sets component for rendering 'table' tag.
@param ContainerComponentInterface $component
@return $this | [
"Sets",
"component",
"for",
"rendering",
"table",
"tag",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/GridPartsAccessTrait.php#L49-L52 |
34,955 | view-components/grids | src/Component/PageTotalsRow.php | PageTotalsRow.render | public function render()
{
/** @var Grid $grid */
$grid = $this->root;
$this->isTotalsCalculationFinished = true;
$tr = $grid->getRecordView();
// set total_row as current grid row
$lastRow = $grid->getCurrentRow();
$grid->setCurrentRow($this->totalData);
... | php | public function render()
{
/** @var Grid $grid */
$grid = $this->root;
$this->isTotalsCalculationFinished = true;
$tr = $grid->getRecordView();
// set total_row as current grid row
$lastRow = $grid->getCurrentRow();
$grid->setCurrentRow($this->totalData);
... | [
"public",
"function",
"render",
"(",
")",
"{",
"/** @var Grid $grid */",
"$",
"grid",
"=",
"$",
"this",
"->",
"root",
";",
"$",
"this",
"->",
"isTotalsCalculationFinished",
"=",
"true",
";",
"$",
"tr",
"=",
"$",
"grid",
"->",
"getRecordView",
"(",
")",
"... | Renders tag and returns output.
@return string | [
"Renders",
"tag",
"and",
"returns",
"output",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Component/PageTotalsRow.php#L126-L166 |
34,956 | view-components/grids | src/Grid.php | Grid.getColumn | public function getColumn($id)
{
$column = $this->getComponent($id);
if (!$column) {
throw new RuntimeException("Column '$id' is not defined.");
}
if (!$column instanceof Column) {
throw new RuntimeException("'$id' is not a column.");
}
return ... | php | public function getColumn($id)
{
$column = $this->getComponent($id);
if (!$column) {
throw new RuntimeException("Column '$id' is not defined.");
}
if (!$column instanceof Column) {
throw new RuntimeException("'$id' is not a column.");
}
return ... | [
"public",
"function",
"getColumn",
"(",
"$",
"id",
")",
"{",
"$",
"column",
"=",
"$",
"this",
"->",
"getComponent",
"(",
"$",
"id",
")",
";",
"if",
"(",
"!",
"$",
"column",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Column '$id' is not defined... | Returns column with specified id,
throws exception if grid does not have specified column.
@param string $id
@return Column | [
"Returns",
"column",
"with",
"specified",
"id",
"throws",
"exception",
"if",
"grid",
"does",
"not",
"have",
"specified",
"column",
"."
] | 38554165e67c90f48c87a6358212f9b67d6ffd4d | https://github.com/view-components/grids/blob/38554165e67c90f48c87a6358212f9b67d6ffd4d/src/Grid.php#L49-L59 |
34,957 | lanthaler/HydraConsole | proxylib.php | AjaxProxy.execute | public function execute()
{
$this->_checkPermissions();
$this->_gatherRequestInfo();
$this->_makeRequest();
$this->_parseResponse();
$this->_buildAndExecuteProxyResponse();
} | php | public function execute()
{
$this->_checkPermissions();
$this->_gatherRequestInfo();
$this->_makeRequest();
$this->_parseResponse();
$this->_buildAndExecuteProxyResponse();
} | [
"public",
"function",
"execute",
"(",
")",
"{",
"$",
"this",
"->",
"_checkPermissions",
"(",
")",
";",
"$",
"this",
"->",
"_gatherRequestInfo",
"(",
")",
";",
"$",
"this",
"->",
"_makeRequest",
"(",
")",
";",
"$",
"this",
"->",
"_parseResponse",
"(",
"... | Execute the proxy request. This method sets HTTP headers and write to the
output stream. Make sure that no whitespace or headers have already been
sent. | [
"Execute",
"the",
"proxy",
"request",
".",
"This",
"method",
"sets",
"HTTP",
"headers",
"and",
"write",
"to",
"the",
"output",
"stream",
".",
"Make",
"sure",
"that",
"no",
"whitespace",
"or",
"headers",
"have",
"already",
"been",
"sent",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L182-L189 |
34,958 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._gatherRequestInfo | protected function _gatherRequestInfo()
{
$this->_loadRequestMethod();
$this->_loadRequestCookies();
$this->_loadRequestUserAgent();
$this->_loadRequestAuthorizationHeader();
$this->_loadRequestAcceptHeader();
$this->_loadRawHeaders();
$this->_loadCont... | php | protected function _gatherRequestInfo()
{
$this->_loadRequestMethod();
$this->_loadRequestCookies();
$this->_loadRequestUserAgent();
$this->_loadRequestAuthorizationHeader();
$this->_loadRequestAcceptHeader();
$this->_loadRawHeaders();
$this->_loadCont... | [
"protected",
"function",
"_gatherRequestInfo",
"(",
")",
"{",
"$",
"this",
"->",
"_loadRequestMethod",
"(",
")",
";",
"$",
"this",
"->",
"_loadRequestCookies",
"(",
")",
";",
"$",
"this",
"->",
"_loadRequestUserAgent",
"(",
")",
";",
"$",
"this",
"->",
"_l... | Gather any information we need about the request and
store them in the class properties | [
"Gather",
"any",
"information",
"we",
"need",
"about",
"the",
"request",
"and",
"store",
"them",
"in",
"the",
"class",
"properties"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L195-L211 |
34,959 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadUrl | protected function _loadUrl()
{
if(!key_exists('url', $_GET))
throw new Exception("You must supply a 'url' parameter in the request");
$this->_url = ($this->_forwardHost)
? $this->_forwardHost . $_GET['url']
: $_GET['url'];
} | php | protected function _loadUrl()
{
if(!key_exists('url', $_GET))
throw new Exception("You must supply a 'url' parameter in the request");
$this->_url = ($this->_forwardHost)
? $this->_forwardHost . $_GET['url']
: $_GET['url'];
} | [
"protected",
"function",
"_loadUrl",
"(",
")",
"{",
"if",
"(",
"!",
"key_exists",
"(",
"'url'",
",",
"$",
"_GET",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"You must supply a 'url' parameter in the request\"",
")",
";",
"$",
"this",
"->",
"_url",
"=",
"(... | Get the url to where the request will be made.
@throws Exception When there is no 'url' parameter | [
"Get",
"the",
"url",
"to",
"where",
"the",
"request",
"will",
"be",
"made",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L218-L226 |
34,960 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestMethod | protected function _loadRequestMethod()
{
if($this->_requestMethod !== NULL) return;
if(!key_exists('REQUEST_METHOD', $_SERVER)) {
throw new Exception("Request method unknown");
}
$method = strtoupper($_SERVER['REQUEST_METHOD']);
if (in_array($method,... | php | protected function _loadRequestMethod()
{
if($this->_requestMethod !== NULL) return;
if(!key_exists('REQUEST_METHOD', $_SERVER)) {
throw new Exception("Request method unknown");
}
$method = strtoupper($_SERVER['REQUEST_METHOD']);
if (in_array($method,... | [
"protected",
"function",
"_loadRequestMethod",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestMethod",
"!==",
"NULL",
")",
"return",
";",
"if",
"(",
"!",
"key_exists",
"(",
"'REQUEST_METHOD'",
",",
"$",
"_SERVER",
")",
")",
"{",
"throw",
"new",
"E... | Examine the request and load the HTTP request method
into the _requestMethod property
@throws Exception When there is no request method | [
"Examine",
"the",
"request",
"and",
"load",
"the",
"HTTP",
"request",
"method",
"into",
"the",
"_requestMethod",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L248-L263 |
34,961 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestUserAgent | protected function _loadRequestUserAgent()
{
if($this->_requestUserAgent !== NULL) return;
if(! key_exists('HTTP_USER_AGENT', $_SERVER))
throw new Exception("No HTTP User Agent was found");
$this->_requestUserAgent = $_SERVER['HTTP_USER_AGENT'];
} | php | protected function _loadRequestUserAgent()
{
if($this->_requestUserAgent !== NULL) return;
if(! key_exists('HTTP_USER_AGENT', $_SERVER))
throw new Exception("No HTTP User Agent was found");
$this->_requestUserAgent = $_SERVER['HTTP_USER_AGENT'];
} | [
"protected",
"function",
"_loadRequestUserAgent",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestUserAgent",
"!==",
"NULL",
")",
"return",
";",
"if",
"(",
"!",
"key_exists",
"(",
"'HTTP_USER_AGENT'",
",",
"$",
"_SERVER",
")",
")",
"throw",
"new",
"E... | Loads the user-agent string into the _requestUserAgent property
@throws Exception When the user agent is not sent by the client | [
"Loads",
"the",
"user",
"-",
"agent",
"string",
"into",
"the",
"_requestUserAgent",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L269-L277 |
34,962 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestAuthorizationHeader | protected function _loadRequestAuthorizationHeader()
{
if($this->_requestAuthorization !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Authorization', $this->_rawHeaders)) {
$this->_requestAuthorization = $this->_rawHeaders['Authorization'];
}
} | php | protected function _loadRequestAuthorizationHeader()
{
if($this->_requestAuthorization !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Authorization', $this->_rawHeaders)) {
$this->_requestAuthorization = $this->_rawHeaders['Authorization'];
}
} | [
"protected",
"function",
"_loadRequestAuthorizationHeader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestAuthorization",
"!==",
"NULL",
")",
"return",
";",
"$",
"this",
"->",
"_loadRawHeaders",
"(",
")",
";",
"if",
"(",
"key_exists",
"(",
"'Authorizat... | Store the Authorization header in _requestAuthorization
property | [
"Store",
"the",
"Authorization",
"header",
"in",
"_requestAuthorization",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L294-L303 |
34,963 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRequestAcceptHeader | protected function _loadRequestAcceptHeader()
{
if($this->_requestAccept !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Accept', $this->_rawHeaders)) {
$this->_requestAccept = $this->_rawHeaders['Accept'];
}
} | php | protected function _loadRequestAcceptHeader()
{
if($this->_requestAccept !== NULL) return;
$this->_loadRawHeaders();
if (key_exists('Accept', $this->_rawHeaders)) {
$this->_requestAccept = $this->_rawHeaders['Accept'];
}
} | [
"protected",
"function",
"_loadRequestAcceptHeader",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_requestAccept",
"!==",
"NULL",
")",
"return",
";",
"$",
"this",
"->",
"_loadRawHeaders",
"(",
")",
";",
"if",
"(",
"key_exists",
"(",
"'Accept'",
",",
"$",
... | Store the Accept header in _requestAccept property | [
"Store",
"the",
"Accept",
"header",
"in",
"_requestAccept",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L308-L317 |
34,964 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadContentType | protected function _loadContentType()
{
$this->_loadRawHeaders();
if(key_exists('Content-Type', $this->_rawHeaders))
$this->_requestContentType = $this->_rawHeaders['Content-Type'];
} | php | protected function _loadContentType()
{
$this->_loadRawHeaders();
if(key_exists('Content-Type', $this->_rawHeaders))
$this->_requestContentType = $this->_rawHeaders['Content-Type'];
} | [
"protected",
"function",
"_loadContentType",
"(",
")",
"{",
"$",
"this",
"->",
"_loadRawHeaders",
"(",
")",
";",
"if",
"(",
"key_exists",
"(",
"'Content-Type'",
",",
"$",
"this",
"->",
"_rawHeaders",
")",
")",
"$",
"this",
"->",
"_requestContentType",
"=",
... | Load the content type into the _requestContentType property | [
"Load",
"the",
"content",
"type",
"into",
"the",
"_requestContentType",
"property"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L322-L328 |
34,965 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._loadRawHeaders | protected function _loadRawHeaders()
{
if($this->_rawHeaders !== NULL) return;
$this->_rawHeaders = apache_request_headers();
if($this->_rawHeaders === FALSE)
throw new Exception("Could not get request headers");
} | php | protected function _loadRawHeaders()
{
if($this->_rawHeaders !== NULL) return;
$this->_rawHeaders = apache_request_headers();
if($this->_rawHeaders === FALSE)
throw new Exception("Could not get request headers");
} | [
"protected",
"function",
"_loadRawHeaders",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_rawHeaders",
"!==",
"NULL",
")",
"return",
";",
"$",
"this",
"->",
"_rawHeaders",
"=",
"apache_request_headers",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"_raw... | Load raw headers into the _rawHeaders property.
This method REQUIRES APACHE
@throws Exception When we can't load request headers (perhaps when Apache
isn't being used) | [
"Load",
"raw",
"headers",
"into",
"the",
"_rawHeaders",
"property",
".",
"This",
"method",
"REQUIRES",
"APACHE"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L336-L344 |
34,966 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._checkPermissions | protected function _checkPermissions()
{
if($this->_allowedHostnames === NULL)
return;
if(key_exists('REMOTE_HOST', $_SERVER))
$host = $_SERVER['REMOTE_HOST'];
else
$host = $_SERVER['REMOTE_ADDR'];
if(!in_array($host, $this->_allowedHos... | php | protected function _checkPermissions()
{
if($this->_allowedHostnames === NULL)
return;
if(key_exists('REMOTE_HOST', $_SERVER))
$host = $_SERVER['REMOTE_HOST'];
else
$host = $_SERVER['REMOTE_ADDR'];
if(!in_array($host, $this->_allowedHos... | [
"protected",
"function",
"_checkPermissions",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_allowedHostnames",
"===",
"NULL",
")",
"return",
";",
"if",
"(",
"key_exists",
"(",
"'REMOTE_HOST'",
",",
"$",
"_SERVER",
")",
")",
"$",
"host",
"=",
"$",
"_SERV... | Check that the proxy request is coming from the appropriate host
that was set in the second argument of the constructor
@return void
@throws Exception when a client hostname is not permitted on a request | [
"Check",
"that",
"the",
"proxy",
"request",
"is",
"coming",
"from",
"the",
"appropriate",
"host",
"that",
"was",
"set",
"in",
"the",
"second",
"argument",
"of",
"the",
"constructor"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L352-L364 |
34,967 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._makeRequest | protected function _makeRequest()
{
# Check for cURL. If it isn't loaded, fall back to fopen()
if(function_exists('curl_init'))
$this->_rawResponse = $this->_makeCurlRequest($this->_url);
else
$this->_rawResponse = $this->_makeFOpenRequest($this->_url);
} | php | protected function _makeRequest()
{
# Check for cURL. If it isn't loaded, fall back to fopen()
if(function_exists('curl_init'))
$this->_rawResponse = $this->_makeCurlRequest($this->_url);
else
$this->_rawResponse = $this->_makeFOpenRequest($this->_url);
} | [
"protected",
"function",
"_makeRequest",
"(",
")",
"{",
"# Check for cURL. If it isn't loaded, fall back to fopen()\r",
"if",
"(",
"function_exists",
"(",
"'curl_init'",
")",
")",
"$",
"this",
"->",
"_rawResponse",
"=",
"$",
"this",
"->",
"_makeCurlRequest",
"(",
"$",... | Make the proxy request using the supplied route and the base host we got
in the constructor. Store the response in _rawResponse | [
"Make",
"the",
"proxy",
"request",
"using",
"the",
"supplied",
"route",
"and",
"the",
"base",
"host",
"we",
"got",
"in",
"the",
"constructor",
".",
"Store",
"the",
"response",
"in",
"_rawResponse"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L370-L377 |
34,968 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._makeCurlRequest | protected function _makeCurlRequest($url)
{
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->_requestMethod);
if($this->_requestBody)
{
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->_requestBody);
}
... | php | protected function _makeCurlRequest($url)
{
$curl_handle = curl_init($url);
curl_setopt($curl_handle, CURLOPT_CUSTOMREQUEST, $this->_requestMethod);
if($this->_requestBody)
{
curl_setopt($curl_handle, CURLOPT_POSTFIELDS, $this->_requestBody);
}
... | [
"protected",
"function",
"_makeCurlRequest",
"(",
"$",
"url",
")",
"{",
"$",
"curl_handle",
"=",
"curl_init",
"(",
"$",
"url",
")",
";",
"curl_setopt",
"(",
"$",
"curl_handle",
",",
"CURLOPT_CUSTOMREQUEST",
",",
"$",
"this",
"->",
"_requestMethod",
")",
";",... | Given the object's current settings, make a request to the given url
using the cURL library
@param string $url The url to make the request to
@return string The full HTTP response | [
"Given",
"the",
"object",
"s",
"current",
"settings",
"make",
"a",
"request",
"to",
"the",
"given",
"url",
"using",
"the",
"cURL",
"library"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L385-L408 |
34,969 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._makeFOpenRequest | protected function _makeFOpenRequest($url)
{
$context = $this->_buildFOpenStreamContext();
$file_pointer = @fopen($url, 'r', null, $context);
if(!$file_pointer)
throw new Exception("There was an error making the request. Make sure that the url is valid, and either fop... | php | protected function _makeFOpenRequest($url)
{
$context = $this->_buildFOpenStreamContext();
$file_pointer = @fopen($url, 'r', null, $context);
if(!$file_pointer)
throw new Exception("There was an error making the request. Make sure that the url is valid, and either fop... | [
"protected",
"function",
"_makeFOpenRequest",
"(",
"$",
"url",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"_buildFOpenStreamContext",
"(",
")",
";",
"$",
"file_pointer",
"=",
"@",
"fopen",
"(",
"$",
"url",
",",
"'r'",
",",
"null",
",",
"$",
"con... | Given the object's current settings, make a request to the supplied url
using PHP's native, less speedy, fopen functions
@param string $url The url to make the request to
@return string The full HTTP response | [
"Given",
"the",
"object",
"s",
"current",
"settings",
"make",
"a",
"request",
"to",
"the",
"supplied",
"url",
"using",
"PHP",
"s",
"native",
"less",
"speedy",
"fopen",
"functions"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L416-L431 |
34,970 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._buildResponseHeaderFromMeta | protected function _buildResponseHeaderFromMeta($meta)
{
if(! array_key_exists('wrapper_data', $meta))
throw new Exception("Did not receive a valid response from the server");
$headers = $meta['wrapper_data'];
/**
* When using stream_context_create, if the sock... | php | protected function _buildResponseHeaderFromMeta($meta)
{
if(! array_key_exists('wrapper_data', $meta))
throw new Exception("Did not receive a valid response from the server");
$headers = $meta['wrapper_data'];
/**
* When using stream_context_create, if the sock... | [
"protected",
"function",
"_buildResponseHeaderFromMeta",
"(",
"$",
"meta",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'wrapper_data'",
",",
"$",
"meta",
")",
")",
"throw",
"new",
"Exception",
"(",
"\"Did not receive a valid response from the server\"",
")",
... | Given an associative array returned by PHP's methods to get stream meta,
extract the HTTP response header from it
@param array $meta The associative array contianing stream information
@return array | [
"Given",
"an",
"associative",
"array",
"returned",
"by",
"PHP",
"s",
"methods",
"to",
"get",
"stream",
"meta",
"extract",
"the",
"HTTP",
"response",
"header",
"from",
"it"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L439-L465 |
34,971 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._parseResponse | protected function _parseResponse()
{
/**
* According to the HTTP spec, we have to respect \n\n too
* @todo: Respect \n\n
*/
$break_1 = strpos($this->_rawResponse, "\r\n\r\n");
$break_2 = strpos($this->_rawResponse, "\n\n");
$break = 0;
... | php | protected function _parseResponse()
{
/**
* According to the HTTP spec, we have to respect \n\n too
* @todo: Respect \n\n
*/
$break_1 = strpos($this->_rawResponse, "\r\n\r\n");
$break_2 = strpos($this->_rawResponse, "\n\n");
$break = 0;
... | [
"protected",
"function",
"_parseResponse",
"(",
")",
"{",
"/**\r\n * According to the HTTP spec, we have to respect \\n\\n too\r\n * @todo: Respect \\n\\n\r\n */",
"$",
"break_1",
"=",
"strpos",
"(",
"$",
"this",
"->",
"_rawResponse",
",",
"\"\\r\\n\\r\\n\"... | Parse the headers and the body out of the raw response sent back by the
server. Store them in _responseHeaders and _responseBody.
@throws Exception When the server does not give us a valid response | [
"Parse",
"the",
"headers",
"and",
"the",
"body",
"out",
"of",
"the",
"raw",
"response",
"sent",
"back",
"by",
"the",
"server",
".",
"Store",
"them",
"in",
"_responseHeaders",
"and",
"_responseBody",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L501-L532 |
34,972 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._parseResponseHeaders | protected function _parseResponseHeaders($headers)
{
$headers = str_replace("\r", "", $headers);
$headers = explode("\n", $headers);
$parsed = array();
foreach($headers as $header)
{
$field_end = strpos($header, ':');
if($field_end === FAL... | php | protected function _parseResponseHeaders($headers)
{
$headers = str_replace("\r", "", $headers);
$headers = explode("\n", $headers);
$parsed = array();
foreach($headers as $header)
{
$field_end = strpos($header, ':');
if($field_end === FAL... | [
"protected",
"function",
"_parseResponseHeaders",
"(",
"$",
"headers",
")",
"{",
"$",
"headers",
"=",
"str_replace",
"(",
"\"\\r\"",
",",
"\"\"",
",",
"$",
"headers",
")",
";",
"$",
"headers",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"headers",
")",
";"... | Parse out the headers from the response and store them in a key-value
array and return it
@param string $headers A big chunk of text representing the HTTP headers
@return array A key-value array containing heder names and values | [
"Parse",
"out",
"the",
"headers",
"from",
"the",
"response",
"and",
"store",
"them",
"in",
"a",
"key",
"-",
"value",
"array",
"and",
"return",
"it"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L540-L568 |
34,973 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._generateProxyRequestHeaders | protected function _generateProxyRequestHeaders($as_string = FALSE)
{
$headers = array();
$headers[] = 'Content-Type: ' . $this->_requestContentType;
if ($this->_requestAuthorization) {
$headers[] = 'Authorization: ' . $this->_requestAuthorization;
}
if... | php | protected function _generateProxyRequestHeaders($as_string = FALSE)
{
$headers = array();
$headers[] = 'Content-Type: ' . $this->_requestContentType;
if ($this->_requestAuthorization) {
$headers[] = 'Authorization: ' . $this->_requestAuthorization;
}
if... | [
"protected",
"function",
"_generateProxyRequestHeaders",
"(",
"$",
"as_string",
"=",
"FALSE",
")",
"{",
"$",
"headers",
"=",
"array",
"(",
")",
";",
"$",
"headers",
"[",
"]",
"=",
"'Content-Type: '",
".",
"$",
"this",
"->",
"_requestContentType",
";",
"if",
... | Generate and return any headers needed to make the proxy request
@param bool $as_string Whether to return the headers as a string instead
of an associative array
@return array|string | [
"Generate",
"and",
"return",
"any",
"headers",
"needed",
"to",
"make",
"the",
"proxy",
"request"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L576-L600 |
34,974 | lanthaler/HydraConsole | proxylib.php | AjaxProxy._buildAndExecuteProxyResponse | protected function _buildAndExecuteProxyResponse()
{
if($this->_responseModifier)
{
$data = call_user_func_array($this->_responseModifier, array(&$this->_responseBody, &$this->_responseHeaders));
}
$this->_generateProxyResponseHeaders();
$this->_output($t... | php | protected function _buildAndExecuteProxyResponse()
{
if($this->_responseModifier)
{
$data = call_user_func_array($this->_responseModifier, array(&$this->_responseBody, &$this->_responseHeaders));
}
$this->_generateProxyResponseHeaders();
$this->_output($t... | [
"protected",
"function",
"_buildAndExecuteProxyResponse",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_responseModifier",
")",
"{",
"$",
"data",
"=",
"call_user_func_array",
"(",
"$",
"this",
"->",
"_responseModifier",
",",
"array",
"(",
"&",
"$",
"this",
... | Generate the headers and send the final response to the output stream | [
"Generate",
"the",
"headers",
"and",
"send",
"the",
"final",
"response",
"to",
"the",
"output",
"stream"
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L639-L649 |
34,975 | lanthaler/HydraConsole | proxylib.php | AjaxProxy.handleException | public function handleException(Exception $exception)
{
$this->_sendFatalError("Fatal proxy Exception: '"
. $exception->getMessage()
. "' in "
. $exception->getFile()
. ":"
... | php | public function handleException(Exception $exception)
{
$this->_sendFatalError("Fatal proxy Exception: '"
. $exception->getMessage()
. "' in "
. $exception->getFile()
. ":"
... | [
"public",
"function",
"handleException",
"(",
"Exception",
"$",
"exception",
")",
"{",
"$",
"this",
"->",
"_sendFatalError",
"(",
"\"Fatal proxy Exception: '\"",
".",
"$",
"exception",
"->",
"getMessage",
"(",
")",
".",
"\"' in \"",
".",
"$",
"exception",
"->",
... | A callback method for PHP's set_exception_handler function. Used to
handle application-wide exceptions.
@param Exception $exception The exception being thrown | [
"A",
"callback",
"method",
"for",
"PHP",
"s",
"set_exception_handler",
"function",
".",
"Used",
"to",
"handle",
"application",
"-",
"wide",
"exceptions",
"."
] | 43c3216038b7a65b99f7d1caf3b838424b6b8d3c | https://github.com/lanthaler/HydraConsole/blob/43c3216038b7a65b99f7d1caf3b838424b6b8d3c/proxylib.php#L690-L698 |
34,976 | bobthecow/Faker | src/Faker/DateTime.php | DateTime.dateTimeFormat | public static function dateTimeFormat()
{
return self::pickOne(array(
DATE_ATOM,
DATE_COOKIE,
DATE_ISO8601,
DATE_RFC822,
DATE_RFC850,
DATE_RFC1036,
DATE_RFC1123,
DATE_RFC2822,
DATE_RSS,
DA... | php | public static function dateTimeFormat()
{
return self::pickOne(array(
DATE_ATOM,
DATE_COOKIE,
DATE_ISO8601,
DATE_RFC822,
DATE_RFC850,
DATE_RFC1036,
DATE_RFC1123,
DATE_RFC2822,
DATE_RSS,
DA... | [
"public",
"static",
"function",
"dateTimeFormat",
"(",
")",
"{",
"return",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"DATE_ATOM",
",",
"DATE_COOKIE",
",",
"DATE_ISO8601",
",",
"DATE_RFC822",
",",
"DATE_RFC850",
",",
"DATE_RFC1036",
",",
"DATE_RFC1123",
",",
... | Return a random date and time format.
@access public
@static
@return string Date and time format | [
"Return",
"a",
"random",
"date",
"and",
"time",
"format",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/DateTime.php#L129-L143 |
34,977 | bobthecow/Faker | src/Faker/Address.php | Address.streetAddress | public static function streetAddress($includeSecondary = false)
{
$chunks = array(
self::pickOne(array('#####', '####', '###')),
self::streetName(),
);
if ($includeSecondary) {
$chunks[] = self::secondaryAddress();
}
return self::numerify... | php | public static function streetAddress($includeSecondary = false)
{
$chunks = array(
self::pickOne(array('#####', '####', '###')),
self::streetName(),
);
if ($includeSecondary) {
$chunks[] = self::secondaryAddress();
}
return self::numerify... | [
"public",
"static",
"function",
"streetAddress",
"(",
"$",
"includeSecondary",
"=",
"false",
")",
"{",
"$",
"chunks",
"=",
"array",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'#####'",
",",
"'####'",
",",
"'###'",
")",
")",
",",
"self",
"::",
"s... | Generate a random street address.
@access public
@static
@param bool $includeSecondary Include a secondary address, e.g. "Apt. 100"? (default: false)
@return string Street address | [
"Generate",
"a",
"random",
"street",
"address",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Address.php#L54-L66 |
34,978 | bobthecow/Faker | src/Faker/Address.php | Address.city | public static function city()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s%4$s',
'%1$s %2$s',
'%2$s%4$s',
'%3$s%4$s',
)),
self::cityPrefix(),
Name::firstName(),
Name::lastName(),
... | php | public static function city()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s%4$s',
'%1$s %2$s',
'%2$s%4$s',
'%3$s%4$s',
)),
self::cityPrefix(),
Name::firstName(),
Name::lastName(),
... | [
"public",
"static",
"function",
"city",
"(",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'%1$s %2$s%4$s'",
",",
"'%1$s %2$s'",
",",
"'%2$s%4$s'",
",",
"'%3$s%4$s'",
",",
")",
")",
",",
"self",
"::",
"cityPrefix",
"(",
... | Generate a random city name.
@access public
@static
@return string City name | [
"Generate",
"a",
"random",
"city",
"name",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Address.php#L114-L128 |
34,979 | bobthecow/Faker | src/Faker/Geo.php | Geo.point | public static function point(array $bounds = null)
{
if ($bounds === null) {
$bounds = static::bounds();
}
return array(
self::LAT => self::randFloat(self::latRange($bounds)),
self::LNG => self::randFloat(self::lngRange($bounds)),
);
} | php | public static function point(array $bounds = null)
{
if ($bounds === null) {
$bounds = static::bounds();
}
return array(
self::LAT => self::randFloat(self::latRange($bounds)),
self::LNG => self::randFloat(self::lngRange($bounds)),
);
} | [
"public",
"static",
"function",
"point",
"(",
"array",
"$",
"bounds",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"bounds",
"===",
"null",
")",
"{",
"$",
"bounds",
"=",
"static",
"::",
"bounds",
"(",
")",
";",
"}",
"return",
"array",
"(",
"self",
"::",
... | Generate random coordinates, as an array.
@access public
@static
@param array $bounds
@return array [$lat, $lng] | [
"Generate",
"random",
"coordinates",
"as",
"an",
"array",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Geo.php#L57-L67 |
34,980 | bobthecow/Faker | src/Faker/Geo.php | Geo.pointDMS | public static function pointDMS(array $bounds = null)
{
list($lat, $lng) = static::point($bounds);
return sprintf('%s %s', self::floatToDMS($lat), self::floatToDMS($lng));
} | php | public static function pointDMS(array $bounds = null)
{
list($lat, $lng) = static::point($bounds);
return sprintf('%s %s', self::floatToDMS($lat), self::floatToDMS($lng));
} | [
"public",
"static",
"function",
"pointDMS",
"(",
"array",
"$",
"bounds",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"lat",
",",
"$",
"lng",
")",
"=",
"static",
"::",
"point",
"(",
"$",
"bounds",
")",
";",
"return",
"sprintf",
"(",
"'%s %s'",
",",
"se... | Generate random coordinates, formatted as degrees, minutes and seconds.
45°30'15" -90°30'15"
@access public
@static
@param array $bounds
@return string Formatted coordinates | [
"Generate",
"random",
"coordinates",
"formatted",
"as",
"degrees",
"minutes",
"and",
"seconds",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Geo.php#L79-L84 |
34,981 | bobthecow/Faker | src/Faker/Internet.php | Internet.userName | public static function userName($name = null)
{
if ($name !== null) {
$email = preg_split('/\W+/', $name);
shuffle($email);
$email = implode(self::separator(), $email);
} else {
$email = sprintf(
self::pickOne(array(
... | php | public static function userName($name = null)
{
if ($name !== null) {
$email = preg_split('/\W+/', $name);
shuffle($email);
$email = implode(self::separator(), $email);
} else {
$email = sprintf(
self::pickOne(array(
... | [
"public",
"static",
"function",
"userName",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"name",
"!==",
"null",
")",
"{",
"$",
"email",
"=",
"preg_split",
"(",
"'/\\W+/'",
",",
"$",
"name",
")",
";",
"shuffle",
"(",
"$",
"email",
")",
... | Generate a random username.
Optionally, supply a user's name, from which the username will be generated.
@access public
@static
@param string $name (default: null)
@return string Username | [
"Generate",
"a",
"random",
"username",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Internet.php#L87-L106 |
34,982 | bobthecow/Faker | src/Faker/Lorem.php | Lorem.sentences | public static function sentences($sentenceCount = 3)
{
$ret = array();
for ($i = 0; $i < $sentenceCount; $i++) {
$ret[] = self::sentence();
}
return $ret;
} | php | public static function sentences($sentenceCount = 3)
{
$ret = array();
for ($i = 0; $i < $sentenceCount; $i++) {
$ret[] = self::sentence();
}
return $ret;
} | [
"public",
"static",
"function",
"sentences",
"(",
"$",
"sentenceCount",
"=",
"3",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"sentenceCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
... | Generate random sentences.
@access public
@static
@param int $sentenceCount Number of sentences (default: 3)
@return array Sentences | [
"Generate",
"random",
"sentences",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Lorem.php#L99-L106 |
34,983 | bobthecow/Faker | src/Faker/Lorem.php | Lorem.paragraphs | public static function paragraphs($paragraphCount = 3)
{
$ret = array();
for ($i = 0; $i < $paragraphCount; $i++) {
$ret[] = self::paragraph();
}
return $ret;
} | php | public static function paragraphs($paragraphCount = 3)
{
$ret = array();
for ($i = 0; $i < $paragraphCount; $i++) {
$ret[] = self::paragraph();
}
return $ret;
} | [
"public",
"static",
"function",
"paragraphs",
"(",
"$",
"paragraphCount",
"=",
"3",
")",
"{",
"$",
"ret",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"paragraphCount",
";",
"$",
"i",
"++",
")",
"{",
"$"... | Generate random paragraphs.
@access public
@static
@param int $paragraphCount Number of paragraphs (default: 3)
@return array Paragraphs | [
"Generate",
"random",
"paragraphs",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Lorem.php#L132-L139 |
34,984 | bobthecow/Faker | src/Faker/Name.php | Name.name | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s %3$s',
'%2$s %3$s %4$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
)),
self::prefix(),... | php | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %2$s %3$s',
'%2$s %3$s %4$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
'%2$s %3$s',
)),
self::prefix(),... | [
"public",
"static",
"function",
"name",
"(",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'%1$s %2$s %3$s'",
",",
"'%2$s %3$s %4$s'",
",",
"'%2$s %3$s'",
",",
"'%2$s %3$s'",
",",
"'%2$s %3$s'",
",",
"'%2$s %3$s'",
",",
")",
... | Generate a random full name.
@access public
@static
@return string Full name | [
"Generate",
"a",
"random",
"full",
"name",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Name.php#L29-L45 |
34,985 | bobthecow/Faker | src/Faker/Company.php | Company.name | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %4$s',
'%1$s-%2$s',
'%1$s, %2$s and %3$s'
)),
Name::lastName(),
Name::lastName(),
Name::lastName(),
self::suffix(... | php | public static function name()
{
return sprintf(
self::pickOne(array(
'%1$s %4$s',
'%1$s-%2$s',
'%1$s, %2$s and %3$s'
)),
Name::lastName(),
Name::lastName(),
Name::lastName(),
self::suffix(... | [
"public",
"static",
"function",
"name",
"(",
")",
"{",
"return",
"sprintf",
"(",
"self",
"::",
"pickOne",
"(",
"array",
"(",
"'%1$s %4$s'",
",",
"'%1$s-%2$s'",
",",
"'%1$s, %2$s and %3$s'",
")",
")",
",",
"Name",
"::",
"lastName",
"(",
")",
",",
"Name",
... | Generate a fake company name.
@access public
@static
@return string Company name | [
"Generate",
"a",
"fake",
"company",
"name",
"."
] | 332c9ad613f3511cc30b33a49566f10bb04162a9 | https://github.com/bobthecow/Faker/blob/332c9ad613f3511cc30b33a49566f10bb04162a9/src/Faker/Company.php#L29-L42 |
34,986 | ostark/craft-async-queue | src/ProcessPool.php | ProcessPool.canIUse | public function canIUse($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
return ($poolUsage < $this->maxItems) ? true : false;
} | php | public function canIUse($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
return ($poolUsage < $this->maxItems) ? true : false;
} | [
"public",
"function",
"canIUse",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"poolUsage",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"CACHE_KEY",
")",
"?",
":",
"0",
";",
"$",
"this",
"->",
"logPoolUsage",
"(",
"$",
"pool... | Check if there is room
@param mixed $context
@return bool | [
"Check",
"if",
"there",
"is",
"room"
] | ba6ef528473ab352e1fb5be23c1550f56570efc0 | https://github.com/ostark/craft-async-queue/blob/ba6ef528473ab352e1fb5be23c1550f56570efc0/src/ProcessPool.php#L55-L61 |
34,987 | ostark/craft-async-queue | src/ProcessPool.php | ProcessPool.increment | public function increment($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
$this->cache->set(self::CACHE_KEY, $poolUsage + 1, $this->lifetime);
} | php | public function increment($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
$this->cache->set(self::CACHE_KEY, $poolUsage + 1, $this->lifetime);
} | [
"public",
"function",
"increment",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"poolUsage",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"CACHE_KEY",
")",
"?",
":",
"0",
";",
"$",
"this",
"->",
"logPoolUsage",
"(",
"$",
"po... | Add one item to pool
@param mixed $context | [
"Add",
"one",
"item",
"to",
"pool"
] | ba6ef528473ab352e1fb5be23c1550f56570efc0 | https://github.com/ostark/craft-async-queue/blob/ba6ef528473ab352e1fb5be23c1550f56570efc0/src/ProcessPool.php#L69-L74 |
34,988 | ostark/craft-async-queue | src/ProcessPool.php | ProcessPool.decrement | public function decrement($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
if ($poolUsage > 1) {
$this->cache->set(self::CACHE_KEY, $poolUsage - 1, $this->lifetime);
} else {
$this->cache->dele... | php | public function decrement($context = null)
{
$poolUsage = $this->cache->get(self::CACHE_KEY) ?: 0;
$this->logPoolUsage($poolUsage, $context);
if ($poolUsage > 1) {
$this->cache->set(self::CACHE_KEY, $poolUsage - 1, $this->lifetime);
} else {
$this->cache->dele... | [
"public",
"function",
"decrement",
"(",
"$",
"context",
"=",
"null",
")",
"{",
"$",
"poolUsage",
"=",
"$",
"this",
"->",
"cache",
"->",
"get",
"(",
"self",
"::",
"CACHE_KEY",
")",
"?",
":",
"0",
";",
"$",
"this",
"->",
"logPoolUsage",
"(",
"$",
"po... | Remove one item from pool
@param mixed $context | [
"Remove",
"one",
"item",
"from",
"pool"
] | ba6ef528473ab352e1fb5be23c1550f56570efc0 | https://github.com/ostark/craft-async-queue/blob/ba6ef528473ab352e1fb5be23c1550f56570efc0/src/ProcessPool.php#L81-L90 |
34,989 | approached/laravel-image-optimizer | src/ImageOptimizer.php | ImageOptimizer.optimizeImage | public function optimizeImage($filepath)
{
$fileExtension = $this->extensions[mime_content_type($filepath)];
$transformHandler = config('imageoptimizer.transform_handler');
if (!isset($transformHandler[$fileExtension])) {
throw new \Exception('TransformHandler for file extensio... | php | public function optimizeImage($filepath)
{
$fileExtension = $this->extensions[mime_content_type($filepath)];
$transformHandler = config('imageoptimizer.transform_handler');
if (!isset($transformHandler[$fileExtension])) {
throw new \Exception('TransformHandler for file extensio... | [
"public",
"function",
"optimizeImage",
"(",
"$",
"filepath",
")",
"{",
"$",
"fileExtension",
"=",
"$",
"this",
"->",
"extensions",
"[",
"mime_content_type",
"(",
"$",
"filepath",
")",
"]",
";",
"$",
"transformHandler",
"=",
"config",
"(",
"'imageoptimizer.tran... | Opitimize a image.
@param $filepath
@throws \Exception | [
"Opitimize",
"a",
"image",
"."
] | 5e822ebe1c366c43a3cec484d45b37c8c56fb383 | https://github.com/approached/laravel-image-optimizer/blob/5e822ebe1c366c43a3cec484d45b37c8c56fb383/src/ImageOptimizer.php#L24-L35 |
34,990 | approached/laravel-image-optimizer | src/ImageOptimizer.php | ImageOptimizer.getFileExtensionFromFilepath | private function getFileExtensionFromFilepath($filepath)
{
$fileExtension = pathinfo($filepath, PATHINFO_EXTENSION);
if (empty($fileExtension)) {
throw new \Exception('File extension not found');
}
return $fileExtension;
} | php | private function getFileExtensionFromFilepath($filepath)
{
$fileExtension = pathinfo($filepath, PATHINFO_EXTENSION);
if (empty($fileExtension)) {
throw new \Exception('File extension not found');
}
return $fileExtension;
} | [
"private",
"function",
"getFileExtensionFromFilepath",
"(",
"$",
"filepath",
")",
"{",
"$",
"fileExtension",
"=",
"pathinfo",
"(",
"$",
"filepath",
",",
"PATHINFO_EXTENSION",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"fileExtension",
")",
")",
"{",
"throw",
"n... | Get extension from a file.
@param $filepath
@throws \Exception
@return string | [
"Get",
"extension",
"from",
"a",
"file",
"."
] | 5e822ebe1c366c43a3cec484d45b37c8c56fb383 | https://github.com/approached/laravel-image-optimizer/blob/5e822ebe1c366c43a3cec484d45b37c8c56fb383/src/ImageOptimizer.php#L58-L67 |
34,991 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setCredentials | function setCredentials($xmlrpcEndPoint, $username, $password)
{
// prepend http protocol to the end point if needed
$scheme = parse_url($xmlrpcEndPoint, PHP_URL_SCHEME);
if (!$scheme) {
$xmlrpcEndPoint = "http://{$xmlrpcEndPoint}";
}
// swith to https when worki... | php | function setCredentials($xmlrpcEndPoint, $username, $password)
{
// prepend http protocol to the end point if needed
$scheme = parse_url($xmlrpcEndPoint, PHP_URL_SCHEME);
if (!$scheme) {
$xmlrpcEndPoint = "http://{$xmlrpcEndPoint}";
}
// swith to https when worki... | [
"function",
"setCredentials",
"(",
"$",
"xmlrpcEndPoint",
",",
"$",
"username",
",",
"$",
"password",
")",
"{",
"// prepend http protocol to the end point if needed",
"$",
"scheme",
"=",
"parse_url",
"(",
"$",
"xmlrpcEndPoint",
",",
"PHP_URL_SCHEME",
")",
";",
"if",... | Set the endpoint, username and password for next requests
@param string $xmlrpcEndPoint The wordpress XML-RPC endpoint
@param string $username The client's username
@param string $password The client's password
@since 2.4.0 | [
"Set",
"the",
"endpoint",
"username",
"and",
"password",
"for",
"next",
"requests"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L79-L97 |
34,992 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setUserAgent | function setUserAgent($userAgent)
{
if ($userAgent) {
$this->userAgent = $userAgent;
} else {
$this->userAgent = $this->getDefaultUserAgent();
}
} | php | function setUserAgent($userAgent)
{
if ($userAgent) {
$this->userAgent = $userAgent;
} else {
$this->userAgent = $this->getDefaultUserAgent();
}
} | [
"function",
"setUserAgent",
"(",
"$",
"userAgent",
")",
"{",
"if",
"(",
"$",
"userAgent",
")",
"{",
"$",
"this",
"->",
"userAgent",
"=",
"$",
"userAgent",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"userAgent",
"=",
"$",
"this",
"->",
"getDefaultUserAge... | Set the user agent for next requests
@param string $userAgent custom user agent, give a falsy value to use library user agent
@since 2.4.0 | [
"Set",
"the",
"user",
"agent",
"for",
"next",
"requests"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L145-L152 |
34,993 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.setAuth | function setAuth($authConfig)
{
if ($authConfig === false || is_array($authConfig)) {
$this->authConfig = $authConfig;
} else {
throw new \InvalidArgumentException(__METHOD__ . " only accept boolean 'false' or an array as parameter.");
}
} | php | function setAuth($authConfig)
{
if ($authConfig === false || is_array($authConfig)) {
$this->authConfig = $authConfig;
} else {
throw new \InvalidArgumentException(__METHOD__ . " only accept boolean 'false' or an array as parameter.");
}
} | [
"function",
"setAuth",
"(",
"$",
"authConfig",
")",
"{",
"if",
"(",
"$",
"authConfig",
"===",
"false",
"||",
"is_array",
"(",
"$",
"authConfig",
")",
")",
"{",
"$",
"this",
"->",
"authConfig",
"=",
"$",
"authConfig",
";",
"}",
"else",
"{",
"throw",
"... | Set authentication info
@param boolean|array $authConfig the configuation array
<ul>
<li><code>auth_user</code>: the username for server authentication</li>
<li><code>auth_pass</code>: the password for server authentication</li>
<li><code>auth_mode</code>: value for CURLOPT_HTTPAUTH option (default to
CURLAUTH_BASIC)<... | [
"Set",
"authentication",
"info"
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L218-L225 |
34,994 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getPost | function getPost($postId, array $fields = array())
{
if (empty($fields)) {
$params = array(1, $this->username, $this->password, $postId);
} else {
$params = array(1, $this->username, $this->password, $postId, $fields);
}
return $this->sendRequest('wp.getPost'... | php | function getPost($postId, array $fields = array())
{
if (empty($fields)) {
$params = array(1, $this->username, $this->password, $postId);
} else {
$params = array(1, $this->username, $this->password, $postId, $fields);
}
return $this->sendRequest('wp.getPost'... | [
"function",
"getPost",
"(",
"$",
"postId",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$"... | Retrieve a post of any registered post type.
@param integer $postId the id of selected post
@param array $fields (optional) list of field or meta-field names to include in response.
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPosts | [
"Retrieve",
"a",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L247-L256 |
34,995 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.newPost | function newPost($title, $body, array $content = array())
{
$default = array(
'post_type' => 'post',
'post_status' => 'publish',
);
$content = array_merge($default, $content);
$content['post_title'] = $title;
$conten... | php | function newPost($title, $body, array $content = array())
{
$default = array(
'post_type' => 'post',
'post_status' => 'publish',
);
$content = array_merge($default, $content);
$content['post_title'] = $title;
$conten... | [
"function",
"newPost",
"(",
"$",
"title",
",",
"$",
"body",
",",
"array",
"$",
"content",
"=",
"array",
"(",
")",
")",
"{",
"$",
"default",
"=",
"array",
"(",
"'post_type'",
"=>",
"'post'",
",",
"'post_status'",
"=>",
"'publish'",
",",
")",
";",
"$",... | Create a new post of any registered post type.
@param string $title the post title
@param string $body the post body
@param array $categorieIds the list of category ids
@param integer $thumbnailId the thumbnail id
@param array $content the content array, see more at wordpress documentation
... | [
"Create",
"a",
"new",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L290-L303 |
34,996 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.editPost | function editPost($postId, array $content)
{
$params = array(1, $this->username, $this->password, $postId, $content);
return $this->sendRequest('wp.editPost', $params);
} | php | function editPost($postId, array $content)
{
$params = array(1, $this->username, $this->password, $postId, $content);
return $this->sendRequest('wp.editPost', $params);
} | [
"function",
"editPost",
"(",
"$",
"postId",
",",
"array",
"$",
"content",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postId",
",",
"$",
"content",
")",
";",
... | Edit an existing post of any registered post type.
@param integer $postId the id of selected post
@param string $title the new title
@param string $body the new body
@param array $categorieIds the new list of category ids
@param integer $thumbnailId the new thumbnail id
@param array $conten... | [
"Edit",
"an",
"existing",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L319-L324 |
34,997 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.deletePost | function deletePost($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.deletePost', $params);
} | php | function deletePost($postId)
{
$params = array(1, $this->username, $this->password, $postId);
return $this->sendRequest('wp.deletePost', $params);
} | [
"function",
"deletePost",
"(",
"$",
"postId",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postId",
")",
";",
"return",
"$",
"this",
"->",
"sendRequest",
"(",
"'... | Delete an existing post of any registered post type.
@param integer $postId the id of selected post
@return boolean
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.deletePost | [
"Delete",
"an",
"existing",
"post",
"of",
"any",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L335-L340 |
34,998 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getPostType | function getPostType($postTypeName, array $fields = array())
{
$params = array(1, $this->username, $this->password, $postTypeName, $fields);
return $this->sendRequest('wp.getPostType', $params);
} | php | function getPostType($postTypeName, array $fields = array())
{
$params = array(1, $this->username, $this->password, $postTypeName, $fields);
return $this->sendRequest('wp.getPostType', $params);
} | [
"function",
"getPostType",
"(",
"$",
"postTypeName",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"password",
",",
"$",
"postTypeName... | Retrieve a registered post type.
@param string $postTypeName the post type name
@param array $fields (optional) list of field or meta-field names to include in response.
@return array
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostType | [
"Retrieve",
"a",
"registered",
"post",
"type",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L352-L357 |
34,999 | letrunghieu/wordpress-xmlrpc-client | src/WordpressClient.php | WordpressClient.getPostTypes | function getPostTypes(array $filter = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filter, $fields);
return $this->sendRequest('wp.getPostTypes', $params);
} | php | function getPostTypes(array $filter = array(), array $fields = array())
{
$params = array(1, $this->username, $this->password, $filter, $fields);
return $this->sendRequest('wp.getPostTypes', $params);
} | [
"function",
"getPostTypes",
"(",
"array",
"$",
"filter",
"=",
"array",
"(",
")",
",",
"array",
"$",
"fields",
"=",
"array",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"1",
",",
"$",
"this",
"->",
"username",
",",
"$",
"this",
"->",
"pa... | Retrieve list of registered post types.
@param array $filter
@param array $fields
@return array list of struct
@link http://codex.wordpress.org/XML-RPC_WordPress_API/Posts#wp.getPostTypes | [
"Retrieve",
"list",
"of",
"registered",
"post",
"types",
"."
] | 64ce550961b1885b8fc8b63dec66670f54fff28f | https://github.com/letrunghieu/wordpress-xmlrpc-client/blob/64ce550961b1885b8fc8b63dec66670f54fff28f/src/WordpressClient.php#L369-L374 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.