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
partition
stringclasses
1 value
BKWLD/decoy
classes/Controllers/Commands.php
Commands.execute
public function execute($command_name) { // Find it if (!($command = Command::find($command_name))) { App::abort(404); } // Run it, ignoring all output set_time_limit(self::MAX_EXECUTION_TIME); ob_start(); Artisan::call($command->getName()); ob_end_clean(); // Return response return Response::json('ok'); }
php
public function execute($command_name) { // Find it if (!($command = Command::find($command_name))) { App::abort(404); } // Run it, ignoring all output set_time_limit(self::MAX_EXECUTION_TIME); ob_start(); Artisan::call($command->getName()); ob_end_clean(); // Return response return Response::json('ok'); }
[ "public", "function", "execute", "(", "$", "command_name", ")", "{", "// Find it", "if", "(", "!", "(", "$", "command", "=", "Command", "::", "find", "(", "$", "command_name", ")", ")", ")", "{", "App", "::", "abort", "(", "404", ")", ";", "}", "//...
Run one of the commands, designed to be called via AJAX @return Response
[ "Run", "one", "of", "the", "commands", "designed", "to", "be", "called", "via", "AJAX" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Controllers/Commands.php#L49-L64
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.detectAndExecute
public function detectAndExecute() { // Get the controller if (!($controller = $this->detectController())) { return false; } // Get the action $action = $this->detectAction(); if (!$action || !method_exists($controller, $action)) { return false; } // Get the id $id = $this->detectId(); // Tell other classes what was found $event = Event::fire('wildcard.detection', [ $controller, $action, $id ]); // Instantiate controller $controller = new $controller(); if ($parent = $this->detectParent()) { list($parent_slug, $parent_id) = $parent; $parent_model = 'App\\'.Str::singular(Str::studly($parent_slug)); $controller->parent($parent_model::findOrFail($parent_id)); } // Execute the request $params = $id ? [$id] : []; return $controller->callAction($action, $params); }
php
public function detectAndExecute() { // Get the controller if (!($controller = $this->detectController())) { return false; } // Get the action $action = $this->detectAction(); if (!$action || !method_exists($controller, $action)) { return false; } // Get the id $id = $this->detectId(); // Tell other classes what was found $event = Event::fire('wildcard.detection', [ $controller, $action, $id ]); // Instantiate controller $controller = new $controller(); if ($parent = $this->detectParent()) { list($parent_slug, $parent_id) = $parent; $parent_model = 'App\\'.Str::singular(Str::studly($parent_slug)); $controller->parent($parent_model::findOrFail($parent_id)); } // Execute the request $params = $id ? [$id] : []; return $controller->callAction($action, $params); }
[ "public", "function", "detectAndExecute", "(", ")", "{", "// Get the controller", "if", "(", "!", "(", "$", "controller", "=", "$", "this", "->", "detectController", "(", ")", ")", ")", "{", "return", "false", ";", "}", "// Get the action", "$", "action", ...
Detect the controller for a given route and then execute the action that is specified in the route.
[ "Detect", "the", "controller", "for", "a", "given", "route", "and", "then", "execute", "the", "action", "that", "is", "specified", "in", "the", "route", "." ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L48-L80
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.detectController
public function detectController($class_name = null) { // Setup the two schemes if (!$class_name) { $class_name = $this->detectControllerClass(); } $app = 'App\\Http\\Controllers\\' . ucfirst(Str::studly($this->dir)) . '\\'.$class_name; $decoy = 'Bkwld\Decoy\Controllers\\'.$class_name; // Find the right one if (class_exists($app)) { return $app; } elseif (class_exists($decoy)) { return $decoy; } return false; }
php
public function detectController($class_name = null) { // Setup the two schemes if (!$class_name) { $class_name = $this->detectControllerClass(); } $app = 'App\\Http\\Controllers\\' . ucfirst(Str::studly($this->dir)) . '\\'.$class_name; $decoy = 'Bkwld\Decoy\Controllers\\'.$class_name; // Find the right one if (class_exists($app)) { return $app; } elseif (class_exists($decoy)) { return $decoy; } return false; }
[ "public", "function", "detectController", "(", "$", "class_name", "=", "null", ")", "{", "// Setup the two schemes", "if", "(", "!", "$", "class_name", ")", "{", "$", "class_name", "=", "$", "this", "->", "detectControllerClass", "(", ")", ";", "}", "$", "...
Get the full namespaced controller @return string i.e. App\Http\Controllers\Admin\People or Bkwld\Decoy\Controllers\Admins
[ "Get", "the", "full", "namespaced", "controller" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L88-L108
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.detectControllerClass
public function detectControllerClass($name = null) { // The path must begin with the config dir if (!preg_match('#^'.$this->dir.'#i', $this->path, $matches)) { return false; } // Find the controller from the end of the path if (!$name) { $name = $this->detectControllerName(); } // Form the namespaced controller return Str::studly($name); }
php
public function detectControllerClass($name = null) { // The path must begin with the config dir if (!preg_match('#^'.$this->dir.'#i', $this->path, $matches)) { return false; } // Find the controller from the end of the path if (!$name) { $name = $this->detectControllerName(); } // Form the namespaced controller return Str::studly($name); }
[ "public", "function", "detectControllerClass", "(", "$", "name", "=", "null", ")", "{", "// The path must begin with the config dir", "if", "(", "!", "preg_match", "(", "'#^'", ".", "$", "this", "->", "dir", ".", "'#i'", ",", "$", "this", "->", "path", ",", ...
Detect the controller for a path. Which is the last non-action string in the path @return string The controller class, i.e. Articles
[ "Detect", "the", "controller", "for", "a", "path", ".", "Which", "is", "the", "last", "non", "-", "action", "string", "in", "the", "path" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L116-L130
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.detectControllerName
public function detectControllerName() { $pattern = '#/'.$this->controllerNameRegex().'#i'; if (!preg_match($pattern, $this->path, $matches)) { return false; } return $matches[1]; }
php
public function detectControllerName() { $pattern = '#/'.$this->controllerNameRegex().'#i'; if (!preg_match($pattern, $this->path, $matches)) { return false; } return $matches[1]; }
[ "public", "function", "detectControllerName", "(", ")", "{", "$", "pattern", "=", "'#/'", ".", "$", "this", "->", "controllerNameRegex", "(", ")", ".", "'#i'", ";", "if", "(", "!", "preg_match", "(", "$", "pattern", ",", "$", "this", "->", "path", ",",...
Get just the controller's short name from the path @return mixed false if not found, otherwise a string like "news" or "slides"
[ "Get", "just", "the", "controller", "s", "short", "name", "from", "the", "path" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L136-L144
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.detectAction
public function detectAction() { // If the path ends in one of the special actions, use that as the action // as long as the verb is a GET if (preg_match('#[a-z-]+$#i', $this->path, $matches)) { $action = $matches[0]; // If posting to the create/edit route, treat as a 'post' route rather than // a 'create/edit' one. This is a shorthand so the create forms can // post to themselves if ($action == 'create' && $this->verb == 'POST') { return 'store'; } elseif ($action == 'edit' && $this->verb == 'POST') { return 'update'; } // ... otherwise, use the route explicitly elseif (in_array($action, $this->actions)) { return $action; } } // If the path ends in a number, the verb defines what it is if (preg_match('#\d+$#', $this->path)) { switch ($this->verb) { case 'PUT': case 'POST': return 'update'; case 'DELETE': return 'destroy'; default: return false; } } // Else, it must end with the controller name switch ($this->verb) { case 'POST': return 'store'; case 'GET': return 'index'; } // Must have been an erorr if we got here return false; }
php
public function detectAction() { // If the path ends in one of the special actions, use that as the action // as long as the verb is a GET if (preg_match('#[a-z-]+$#i', $this->path, $matches)) { $action = $matches[0]; // If posting to the create/edit route, treat as a 'post' route rather than // a 'create/edit' one. This is a shorthand so the create forms can // post to themselves if ($action == 'create' && $this->verb == 'POST') { return 'store'; } elseif ($action == 'edit' && $this->verb == 'POST') { return 'update'; } // ... otherwise, use the route explicitly elseif (in_array($action, $this->actions)) { return $action; } } // If the path ends in a number, the verb defines what it is if (preg_match('#\d+$#', $this->path)) { switch ($this->verb) { case 'PUT': case 'POST': return 'update'; case 'DELETE': return 'destroy'; default: return false; } } // Else, it must end with the controller name switch ($this->verb) { case 'POST': return 'store'; case 'GET': return 'index'; } // Must have been an erorr if we got here return false; }
[ "public", "function", "detectAction", "(", ")", "{", "// If the path ends in one of the special actions, use that as the action", "// as long as the verb is a GET", "if", "(", "preg_match", "(", "'#[a-z-]+$#i'", ",", "$", "this", "->", "path", ",", "$", "matches", ")", ")...
Detect the action for a path @return string 'create', 'update', 'edit', ....
[ "Detect", "the", "action", "for", "a", "path" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L159-L208
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.detectId
public function detectId() { // If there is an id, it will be the last number if (preg_match('#\d+$#', $this->path, $matches)) { return $matches[0]; } // .. or the route will be an action preceeded by an id $pattern = '#(\d+)/('.implode('|', $this->actions).')$#i'; if (preg_match($pattern, $this->path, $matches)) { return $matches[1]; } // There's no id return false; }
php
public function detectId() { // If there is an id, it will be the last number if (preg_match('#\d+$#', $this->path, $matches)) { return $matches[0]; } // .. or the route will be an action preceeded by an id $pattern = '#(\d+)/('.implode('|', $this->actions).')$#i'; if (preg_match($pattern, $this->path, $matches)) { return $matches[1]; } // There's no id return false; }
[ "public", "function", "detectId", "(", ")", "{", "// If there is an id, it will be the last number", "if", "(", "preg_match", "(", "'#\\d+$#'", ",", "$", "this", "->", "path", ",", "$", "matches", ")", ")", "{", "return", "$", "matches", "[", "0", "]", ";", ...
Detect the id for the path @return integer An id number for a DB record
[ "Detect", "the", "id", "for", "the", "path" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L214-L229
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.detectParent
public function detectParent() { // Look for a string, then a number (the parent id), followed by a non-action // string, then possiby a number and/or an action string and then the end $pattern = '#([a-z-]+)/(\d+)/(?!'.implode('|', $this->actions).')[a-z-]+(?:/\d+)?(/('.implode('|', $this->actions).'))?$#i'; if (preg_match($pattern, $this->path, $matches)) { return [$matches[1], $matches[2]]; } return false; }
php
public function detectParent() { // Look for a string, then a number (the parent id), followed by a non-action // string, then possiby a number and/or an action string and then the end $pattern = '#([a-z-]+)/(\d+)/(?!'.implode('|', $this->actions).')[a-z-]+(?:/\d+)?(/('.implode('|', $this->actions).'))?$#i'; if (preg_match($pattern, $this->path, $matches)) { return [$matches[1], $matches[2]]; } return false; }
[ "public", "function", "detectParent", "(", ")", "{", "// Look for a string, then a number (the parent id), followed by a non-action", "// string, then possiby a number and/or an action string and then the end", "$", "pattern", "=", "'#([a-z-]+)/(\\d+)/(?!'", ".", "implode", "(", "'|'",...
Detect the parent id of the path @return mixed False or an array containing: - The slug of the parent controller - The id of the parent record
[ "Detect", "the", "parent", "id", "of", "the", "path" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L238-L248
train
BKWLD/decoy
classes/Routing/Wildcard.php
Wildcard.getAllClasses
public function getAllClasses() { // Get all slugs that lead with a slash $pattern = '#(?:/([a-z-]+))#i'; // If no matches, return an empty array. Matches will be at first index; preg_match_all($pattern, $this->path, $matches); if (count($matches) <= 1) { return []; } $matches = $matches[1]; // Remove actions from the matches list (like "edit") if (in_array($matches[count($matches) - 1], $this->actions)) { array_pop($matches); } // Convert all the matches to their classes return array_map(function ($name) { return $this->detectController($this->detectControllerClass($name)); }, $matches); }
php
public function getAllClasses() { // Get all slugs that lead with a slash $pattern = '#(?:/([a-z-]+))#i'; // If no matches, return an empty array. Matches will be at first index; preg_match_all($pattern, $this->path, $matches); if (count($matches) <= 1) { return []; } $matches = $matches[1]; // Remove actions from the matches list (like "edit") if (in_array($matches[count($matches) - 1], $this->actions)) { array_pop($matches); } // Convert all the matches to their classes return array_map(function ($name) { return $this->detectController($this->detectControllerClass($name)); }, $matches); }
[ "public", "function", "getAllClasses", "(", ")", "{", "// Get all slugs that lead with a slash", "$", "pattern", "=", "'#(?:/([a-z-]+))#i'", ";", "// If no matches, return an empty array. Matches will be at first index;", "preg_match_all", "(", "$", "pattern", ",", "$", "this"...
Return an array of all classes represented in the URL
[ "Return", "an", "array", "of", "all", "classes", "represented", "in", "the", "URL" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Routing/Wildcard.php#L253-L274
train
BKWLD/decoy
classes/Models/Traits/Loggable.php
Loggable.showTrashedVersion
private static function showTrashedVersion(Builder $builder) { if (($change = static::lookupRequestedChange()) && static::builderMatchesChange($change, $builder)) { $builder->withoutGlobalScope(SoftDeletingScope::class); } }
php
private static function showTrashedVersion(Builder $builder) { if (($change = static::lookupRequestedChange()) && static::builderMatchesChange($change, $builder)) { $builder->withoutGlobalScope(SoftDeletingScope::class); } }
[ "private", "static", "function", "showTrashedVersion", "(", "Builder", "$", "builder", ")", "{", "if", "(", "(", "$", "change", "=", "static", "::", "lookupRequestedChange", "(", ")", ")", "&&", "static", "::", "builderMatchesChange", "(", "$", "change", ","...
Show trashed models for matching change @param Builder $builder @return void
[ "Show", "trashed", "models", "for", "matching", "change" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Loggable.php#L84-L90
train
BKWLD/decoy
classes/Models/Traits/Loggable.php
Loggable.lookupRequestedChange
private static function lookupRequestedChange() { // Only run if the query param is present if (!$change_id = request(Change::QUERY_KEY)) { return; } // Don't execute for classes that result in recusirve queries when the // Change model gets built below $class = get_called_class(); if (in_array($class, [Change::class, Admin::class, Image::class])) { return; } // Check whether the referenced Change is for this class $change = Change::find($change_id); if ($class == $change->model) { return $change; } }
php
private static function lookupRequestedChange() { // Only run if the query param is present if (!$change_id = request(Change::QUERY_KEY)) { return; } // Don't execute for classes that result in recusirve queries when the // Change model gets built below $class = get_called_class(); if (in_array($class, [Change::class, Admin::class, Image::class])) { return; } // Check whether the referenced Change is for this class $change = Change::find($change_id); if ($class == $change->model) { return $change; } }
[ "private", "static", "function", "lookupRequestedChange", "(", ")", "{", "// Only run if the query param is present", "if", "(", "!", "$", "change_id", "=", "request", "(", "Change", "::", "QUERY_KEY", ")", ")", "{", "return", ";", "}", "// Don't execute for classes...
Get a Change record mentioned in the query, if appropriate @return Change|void
[ "Get", "a", "Change", "record", "mentioned", "in", "the", "query", "if", "appropriate" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Loggable.php#L97-L116
train
BKWLD/decoy
classes/Models/Traits/Loggable.php
Loggable.builderMatchesChange
private static function builderMatchesChange(Change $change, Builder $builder) { $class = $change->model; $route_key_name = (new $class)->getRouteKeyName(); return collect($builder->getQuery()->wheres) ->contains(function($where) use ($change, $route_key_name) { // If the builder is keyed to a simple "id" in the route, return // whether the Change matches it. if ($route_key_name == 'id') { return $where['column'] == $route_key_name && $where['operator'] == '=' && $where['value'] == $change->key; // Otherwise compare against model logged by the change. The // scope needs to be removed to prevent recursion. } else { $value = $change->changedModel() ->withoutGlobalScope(static::$LOGGABLE_SCOPE) ->first() ->$route_key_name; return $where['column'] == $route_key_name && $where['operator'] == '=' && $where['value'] == $value; } }); }
php
private static function builderMatchesChange(Change $change, Builder $builder) { $class = $change->model; $route_key_name = (new $class)->getRouteKeyName(); return collect($builder->getQuery()->wheres) ->contains(function($where) use ($change, $route_key_name) { // If the builder is keyed to a simple "id" in the route, return // whether the Change matches it. if ($route_key_name == 'id') { return $where['column'] == $route_key_name && $where['operator'] == '=' && $where['value'] == $change->key; // Otherwise compare against model logged by the change. The // scope needs to be removed to prevent recursion. } else { $value = $change->changedModel() ->withoutGlobalScope(static::$LOGGABLE_SCOPE) ->first() ->$route_key_name; return $where['column'] == $route_key_name && $where['operator'] == '=' && $where['value'] == $value; } }); }
[ "private", "static", "function", "builderMatchesChange", "(", "Change", "$", "change", ",", "Builder", "$", "builder", ")", "{", "$", "class", "=", "$", "change", "->", "model", ";", "$", "route_key_name", "=", "(", "new", "$", "class", ")", "->", "getRo...
Does the Change referenced in the GET query match the conditions already applied in the query builder? @param Change $change @param Builder $builder @return boolean
[ "Does", "the", "Change", "referenced", "in", "the", "GET", "query", "match", "the", "conditions", "already", "applied", "in", "the", "query", "builder?" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Loggable.php#L126-L152
train
BKWLD/decoy
classes/Models/Traits/Loggable.php
Loggable.replaceAttributesWithChange
private function replaceAttributesWithChange() { if (($change = static::lookupRequestedChange()) && $change->key == $this->getKey()) { $this->attributes = array_merge( $this->attributes, $this->attributesAtChange($change) ); } }
php
private function replaceAttributesWithChange() { if (($change = static::lookupRequestedChange()) && $change->key == $this->getKey()) { $this->attributes = array_merge( $this->attributes, $this->attributesAtChange($change) ); } }
[ "private", "function", "replaceAttributesWithChange", "(", ")", "{", "if", "(", "(", "$", "change", "=", "static", "::", "lookupRequestedChange", "(", ")", ")", "&&", "$", "change", "->", "key", "==", "$", "this", "->", "getKey", "(", ")", ")", "{", "$...
Replace all the attributes with those from the specified Change specified in the reqeust query. @return void
[ "Replace", "all", "the", "attributes", "with", "those", "from", "the", "specified", "Change", "specified", "in", "the", "reqeust", "query", "." ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Loggable.php#L160-L169
train
BKWLD/decoy
classes/Models/Traits/Loggable.php
Loggable.attributesAtChange
private function attributesAtChange(Change $change) { return $this->previousChanges($change) ->reduce(function($attributes, $change) { return array_merge($attributes, $change->changed); }, []); }
php
private function attributesAtChange(Change $change) { return $this->previousChanges($change) ->reduce(function($attributes, $change) { return array_merge($attributes, $change->changed); }, []); }
[ "private", "function", "attributesAtChange", "(", "Change", "$", "change", ")", "{", "return", "$", "this", "->", "previousChanges", "(", "$", "change", ")", "->", "reduce", "(", "function", "(", "$", "attributes", ",", "$", "change", ")", "{", "return", ...
Get the attributes of the model at a given Change @param Change $change @return array
[ "Get", "the", "attributes", "of", "the", "model", "at", "a", "given", "Change" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Loggable.php#L177-L183
train
BKWLD/decoy
classes/Models/Traits/Loggable.php
Loggable.previousChanges
private function previousChanges(Change $change) { return $this->changes() ->where('changes.id', '<=', $change->id) ->orderBy('changes.id', 'asc') ->get(); }
php
private function previousChanges(Change $change) { return $this->changes() ->where('changes.id', '<=', $change->id) ->orderBy('changes.id', 'asc') ->get(); }
[ "private", "function", "previousChanges", "(", "Change", "$", "change", ")", "{", "return", "$", "this", "->", "changes", "(", ")", "->", "where", "(", "'changes.id'", ",", "'<='", ",", "$", "change", "->", "id", ")", "->", "orderBy", "(", "'changes.id'"...
Get the list of pervious changes of this model, storing it to reduce future lookups @param Change $change @return Collection
[ "Get", "the", "list", "of", "pervious", "changes", "of", "this", "model", "storing", "it", "to", "reduce", "future", "lookups" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Models/Traits/Loggable.php#L192-L199
train
BKWLD/decoy
classes/Input/EncodingProviders/EncodingProvider.php
EncodingProvider.mergeConfigWithDefaults
protected function mergeConfigWithDefaults($preset) { // Get the preset settings if (!$settings = Config::get('decoy.encode.presets.'.$preset.'.settings')) { throw new Exception('Encoding preset not found: '.$preset); } // If the settings are an assoc array, then there is only one output and it // needs to be wrapped in an array if (!is_numeric(array_keys($settings)[0])) { $settings = ['mp4' => $settings]; } // Merge defaults with each output in the settings return array_map(function ($output) { return array_merge($this->defaults, $output); }, $settings); }
php
protected function mergeConfigWithDefaults($preset) { // Get the preset settings if (!$settings = Config::get('decoy.encode.presets.'.$preset.'.settings')) { throw new Exception('Encoding preset not found: '.$preset); } // If the settings are an assoc array, then there is only one output and it // needs to be wrapped in an array if (!is_numeric(array_keys($settings)[0])) { $settings = ['mp4' => $settings]; } // Merge defaults with each output in the settings return array_map(function ($output) { return array_merge($this->defaults, $output); }, $settings); }
[ "protected", "function", "mergeConfigWithDefaults", "(", "$", "preset", ")", "{", "// Get the preset settings", "if", "(", "!", "$", "settings", "=", "Config", "::", "get", "(", "'decoy.encode.presets.'", ".", "$", "preset", ".", "'.settings'", ")", ")", "{", ...
Update the default configwith the user config @param string $preset @return array @throws Exception
[ "Update", "the", "default", "configwith", "the", "user", "config" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Input/EncodingProviders/EncodingProvider.php#L77-L94
train
BKWLD/decoy
classes/Fields/Image.php
Image.applyRules
protected function applyRules() { // Check if there are rules for this field $rules_key = 'images.' . ($this->name ?: 'default'); if (!$rules = Former::getRules($rules_key)) { return; } // If there already is an image, drop the forced requirement if ($this->hasImage() && array_key_exists('required', $rules)) { unset($rules['required']); $this->addClass('required'); // So the icon shows up } // Apply rules using Former's LiveValidation $live = new LiveValidation($this); $live->apply($rules); }
php
protected function applyRules() { // Check if there are rules for this field $rules_key = 'images.' . ($this->name ?: 'default'); if (!$rules = Former::getRules($rules_key)) { return; } // If there already is an image, drop the forced requirement if ($this->hasImage() && array_key_exists('required', $rules)) { unset($rules['required']); $this->addClass('required'); // So the icon shows up } // Apply rules using Former's LiveValidation $live = new LiveValidation($this); $live->apply($rules); }
[ "protected", "function", "applyRules", "(", ")", "{", "// Check if there are rules for this field", "$", "rules_key", "=", "'images.'", ".", "(", "$", "this", "->", "name", "?", ":", "'default'", ")", ";", "if", "(", "!", "$", "rules", "=", "Former", "::", ...
Apply validation rules @return void
[ "Apply", "validation", "rules" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Image.php#L84-L101
train
BKWLD/decoy
classes/Fields/Image.php
Image.showErrors
public function showErrors() { $key = sprintf('images.%s.file', $this->inputId()); if (session('errors') && ($error = session('errors')->first($key))) { $this->help($error); $this->group->addClass('has-error'); } }
php
public function showErrors() { $key = sprintf('images.%s.file', $this->inputId()); if (session('errors') && ($error = session('errors')->first($key))) { $this->help($error); $this->group->addClass('has-error'); } }
[ "public", "function", "showErrors", "(", ")", "{", "$", "key", "=", "sprintf", "(", "'images.%s.file'", ",", "$", "this", "->", "inputId", "(", ")", ")", ";", "if", "(", "session", "(", "'errors'", ")", "&&", "(", "$", "error", "=", "session", "(", ...
Show errors that will have been stored on the `file` proeperty @return void
[ "Show", "errors", "that", "will", "have", "been", "stored", "on", "the", "file", "proeperty" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Image.php#L108-L115
train
BKWLD/decoy
classes/Fields/Image.php
Image.wrapAndRender
public function wrapAndRender() { // Get additional UI first so it can modify the normal form-group UI. $html = $this->renderEditor(); // Add the aspect ratio choice $this->group->dataAspectRatio($this->ratio ?: false); // Set errors $this->showErrors(); // Inform whether there is an existing image to preview if ($this->hasImage()) { $this->group->addClass('has-image'); } // Add extra markup return $this->appendToGroup(parent::wrapAndRender(), $html); }
php
public function wrapAndRender() { // Get additional UI first so it can modify the normal form-group UI. $html = $this->renderEditor(); // Add the aspect ratio choice $this->group->dataAspectRatio($this->ratio ?: false); // Set errors $this->showErrors(); // Inform whether there is an existing image to preview if ($this->hasImage()) { $this->group->addClass('has-image'); } // Add extra markup return $this->appendToGroup(parent::wrapAndRender(), $html); }
[ "public", "function", "wrapAndRender", "(", ")", "{", "// Get additional UI first so it can modify the normal form-group UI.", "$", "html", "=", "$", "this", "->", "renderEditor", "(", ")", ";", "// Add the aspect ratio choice", "$", "this", "->", "group", "->", "dataAs...
Prints out the field, wrapped in its group. Additional review UI is tacked on here. @return string
[ "Prints", "out", "the", "field", "wrapped", "in", "its", "group", ".", "Additional", "review", "UI", "is", "tacked", "on", "here", "." ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Image.php#L135-L153
train
BKWLD/decoy
classes/Fields/Image.php
Image.createHidden
protected function createHidden($name, $value = null) { $field = Former::hidden($this->inputName($name))->class('input-'.$name); if ($value) { if (!is_scalar($value)) { $value = json_encode($value); } $field->forceValue($value); } return $field->render(); }
php
protected function createHidden($name, $value = null) { $field = Former::hidden($this->inputName($name))->class('input-'.$name); if ($value) { if (!is_scalar($value)) { $value = json_encode($value); } $field->forceValue($value); } return $field->render(); }
[ "protected", "function", "createHidden", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "$", "field", "=", "Former", "::", "hidden", "(", "$", "this", "->", "inputName", "(", "$", "name", ")", ")", "->", "class", "(", "'input-'", ".", ...
Make a hidden field @param string $name @param string $value @return string
[ "Make", "a", "hidden", "field" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Image.php#L234-L245
train
BKWLD/decoy
classes/Fields/Image.php
Image.inputId
protected function inputId() { // If we're editing an already existing image, return it's Image id if (($image = $this->image()) && $image->id) { return $image->id; } // Otherwise, use the name of the field, which should be unique compared // to other image fields on the page. if (!$this->input_id) { $this->input_id = '_'.preg_replace('#[^\w]#', '', $this->name); } return $this->input_id; }
php
protected function inputId() { // If we're editing an already existing image, return it's Image id if (($image = $this->image()) && $image->id) { return $image->id; } // Otherwise, use the name of the field, which should be unique compared // to other image fields on the page. if (!$this->input_id) { $this->input_id = '_'.preg_replace('#[^\w]#', '', $this->name); } return $this->input_id; }
[ "protected", "function", "inputId", "(", ")", "{", "// If we're editing an already existing image, return it's Image id", "if", "(", "(", "$", "image", "=", "$", "this", "->", "image", "(", ")", ")", "&&", "$", "image", "->", "id", ")", "{", "return", "$", "...
Get the id to use in all inputs for this Image @return string Either a model id or an arbitrary number prefixed by _
[ "Get", "the", "id", "to", "use", "in", "all", "inputs", "for", "this", "Image" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Image.php#L263-L277
train
BKWLD/decoy
classes/Fields/Image.php
Image.forElement
public function forElement(Element $el) { // Add help $this->model($el)->blockhelp($el->help); // Populate the image array with the image instance. This will create an // Image instance from the default value if it doesn't exist. $pop = app('former.populator')->all(); $pop['images'][$this->inputId()] = $el->img(); app('former.populator')->replace($pop); // Support chaining return $this; }
php
public function forElement(Element $el) { // Add help $this->model($el)->blockhelp($el->help); // Populate the image array with the image instance. This will create an // Image instance from the default value if it doesn't exist. $pop = app('former.populator')->all(); $pop['images'][$this->inputId()] = $el->img(); app('former.populator')->replace($pop); // Support chaining return $this; }
[ "public", "function", "forElement", "(", "Element", "$", "el", ")", "{", "// Add help", "$", "this", "->", "model", "(", "$", "el", ")", "->", "blockhelp", "(", "$", "el", "->", "help", ")", ";", "// Populate the image array with the image instance. This will c...
Logic for rendering an Image field for editing Element images @param Element $element @return $this
[ "Logic", "for", "rendering", "an", "Image", "field", "for", "editing", "Element", "images" ]
7a4acfa8e00cdca7ef4d82672a6547bae61f8e73
https://github.com/BKWLD/decoy/blob/7a4acfa8e00cdca7ef4d82672a6547bae61f8e73/classes/Fields/Image.php#L325-L338
train
bovigo/callmap
src/main/php/CallMap.php
CallMap.hasResultFor
public function hasResultFor(string $method, int $invocationCount): bool { if (!array_key_exists($method, $this->callMap)) { return false; } if ($this->callMap[$method] instanceof InvocationResults) { return $this->callMap[$method]->hasResultForInvocation($invocationCount - 1); } return true; }
php
public function hasResultFor(string $method, int $invocationCount): bool { if (!array_key_exists($method, $this->callMap)) { return false; } if ($this->callMap[$method] instanceof InvocationResults) { return $this->callMap[$method]->hasResultForInvocation($invocationCount - 1); } return true; }
[ "public", "function", "hasResultFor", "(", "string", "$", "method", ",", "int", "$", "invocationCount", ")", ":", "bool", "{", "if", "(", "!", "array_key_exists", "(", "$", "method", ",", "$", "this", "->", "callMap", ")", ")", "{", "return", "false", ...
checks whether callmap has a result for the invocation of method @param string $method name of invoked method @param int $invocationCount denotes which nth invocation of the method this is @return bool
[ "checks", "whether", "callmap", "has", "a", "result", "for", "the", "invocation", "of", "method" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/CallMap.php#L41-L52
train
bovigo/callmap
src/main/php/CallMap.php
CallMap.resultFor
public function resultFor(string $method, array $arguments, int $invocationCount) { if (!isset($this->callMap[$method])) { return null; } if ($this->callMap[$method] instanceof InvocationResults) { $result = $this->callMap[$method]->resultForInvocation($invocationCount - 1); } else { $result = $this->callMap[$method]; } if (is_callable($result)) { return $result(...$arguments); } return $result; }
php
public function resultFor(string $method, array $arguments, int $invocationCount) { if (!isset($this->callMap[$method])) { return null; } if ($this->callMap[$method] instanceof InvocationResults) { $result = $this->callMap[$method]->resultForInvocation($invocationCount - 1); } else { $result = $this->callMap[$method]; } if (is_callable($result)) { return $result(...$arguments); } return $result; }
[ "public", "function", "resultFor", "(", "string", "$", "method", ",", "array", "$", "arguments", ",", "int", "$", "invocationCount", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "callMap", "[", "$", "method", "]", ")", ")", "{", "return...
returns the result for the method invocation done with given arguments @param string $method name of invoked method @param mixed[] $arguments arguments passed for the method call @param int $invocationCount denotes which nth invocation of the method this is @return mixed @throws \Exception
[ "returns", "the", "result", "for", "the", "method", "invocation", "done", "with", "given", "arguments" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/CallMap.php#L63-L80
train
bovigo/callmap
src/main/php/NewCallable.php
NewCallable.callMapClass
private static function callMapClass(string $function): \ReflectionClass { if (!isset(self::$functions[$function])) { self::$functions[$function] = self::forkCallMapClass( new \ReflectionFunction($function) ); } return self::$functions[$function]; }
php
private static function callMapClass(string $function): \ReflectionClass { if (!isset(self::$functions[$function])) { self::$functions[$function] = self::forkCallMapClass( new \ReflectionFunction($function) ); } return self::$functions[$function]; }
[ "private", "static", "function", "callMapClass", "(", "string", "$", "function", ")", ":", "\\", "ReflectionClass", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "functions", "[", "$", "function", "]", ")", ")", "{", "self", "::", "$", "functio...
returns the proxy class for given function @param string $function @return \ReflectionClass
[ "returns", "the", "proxy", "class", "for", "given", "function" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewCallable.php#L64-L73
train
bovigo/callmap
src/main/php/NewCallable.php
NewCallable.forkCallMapClass
private static function forkCallMapClass(\ReflectionFunction $function): \ReflectionClass { try { $compile = self::$compile; $compile(self::createProxyCode($function)); } catch (\ParseError $pe) { throw new ProxyCreationFailure( 'Failure while creating callable CallMap instance of ' . $function->getName() . '(): ' . $pe->getMessage(), $pe ); } return new \ReflectionClass($function->getName() . 'CallMapProxy'); }
php
private static function forkCallMapClass(\ReflectionFunction $function): \ReflectionClass { try { $compile = self::$compile; $compile(self::createProxyCode($function)); } catch (\ParseError $pe) { throw new ProxyCreationFailure( 'Failure while creating callable CallMap instance of ' . $function->getName() . '(): ' . $pe->getMessage(), $pe ); } return new \ReflectionClass($function->getName() . 'CallMapProxy'); }
[ "private", "static", "function", "forkCallMapClass", "(", "\\", "ReflectionFunction", "$", "function", ")", ":", "\\", "ReflectionClass", "{", "try", "{", "$", "compile", "=", "self", "::", "$", "compile", ";", "$", "compile", "(", "self", "::", "createProxy...
creates a new class from the given function which uses the CallMap trait @param \ReflectionFunction $function @return \ReflectionClass @throws ProxyCreationFailure
[ "creates", "a", "new", "class", "from", "the", "given", "function", "which", "uses", "the", "CallMap", "trait" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewCallable.php#L90-L104
train
gocom/rah_flat
src/Rah/Flat.php
Rah_Flat.import
public function import() { $skin = \Txp::get('\Textpattern\Skin\Skin'); $skin->setNames(array_keys((array)$skin->getUploaded()))->import(true, true); }
php
public function import() { $skin = \Txp::get('\Textpattern\Skin\Skin'); $skin->setNames(array_keys((array)$skin->getUploaded()))->import(true, true); }
[ "public", "function", "import", "(", ")", "{", "$", "skin", "=", "\\", "Txp", "::", "get", "(", "'\\Textpattern\\Skin\\Skin'", ")", ";", "$", "skin", "->", "setNames", "(", "array_keys", "(", "(", "array", ")", "$", "skin", "->", "getUploaded", "(", ")...
Imports themes. @return void
[ "Imports", "themes", "." ]
2af2f68ffa1d65151302032a4bbab0bf4f6503d0
https://github.com/gocom/rah_flat/blob/2af2f68ffa1d65151302032a4bbab0bf4f6503d0/src/Rah/Flat.php#L49-L53
train
bovigo/callmap
src/main/php/Verification.php
Verification.wasCalledAtLeastOnce
public function wasCalledAtLeastOnce(): bool { if (count($this->invocations) < 1) { throw new CallAmountViolation(sprintf( '%s was expected to be called at least once,' . ' but was never called.', $this->invocations->name() )); } return true; }
php
public function wasCalledAtLeastOnce(): bool { if (count($this->invocations) < 1) { throw new CallAmountViolation(sprintf( '%s was expected to be called at least once,' . ' but was never called.', $this->invocations->name() )); } return true; }
[ "public", "function", "wasCalledAtLeastOnce", "(", ")", ":", "bool", "{", "if", "(", "count", "(", "$", "this", "->", "invocations", ")", "<", "1", ")", "{", "throw", "new", "CallAmountViolation", "(", "sprintf", "(", "'%s was expected to be called at least once...
verifies that the method on the class was called at least once @api @return bool @throws \bovigo\callmap\CallAmountViolation
[ "verifies", "that", "the", "method", "on", "the", "class", "was", "called", "at", "least", "once" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L63-L74
train
bovigo/callmap
src/main/php/Verification.php
Verification.wasCalledOnce
public function wasCalledOnce(): bool { $callsReceived = count($this->invocations); if (1 !== $callsReceived) { throw new CallAmountViolation(sprintf( '%s was expected to be called once, but actually %s.', $this->invocations->name(), 1 < $callsReceived ? 'called ' . $callsReceived . ' time(s)' : 'never called' )); } return true; }
php
public function wasCalledOnce(): bool { $callsReceived = count($this->invocations); if (1 !== $callsReceived) { throw new CallAmountViolation(sprintf( '%s was expected to be called once, but actually %s.', $this->invocations->name(), 1 < $callsReceived ? 'called ' . $callsReceived . ' time(s)' : 'never called' )); } return true; }
[ "public", "function", "wasCalledOnce", "(", ")", ":", "bool", "{", "$", "callsReceived", "=", "count", "(", "$", "this", "->", "invocations", ")", ";", "if", "(", "1", "!==", "$", "callsReceived", ")", "{", "throw", "new", "CallAmountViolation", "(", "sp...
verifies that the method on the class was called exactly once @api @return bool @throws \bovigo\callmap\CallAmountViolation
[ "verifies", "that", "the", "method", "on", "the", "class", "was", "called", "exactly", "once" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L106-L121
train
bovigo/callmap
src/main/php/Verification.php
Verification.wasNeverCalled
public function wasNeverCalled(): bool { if (count($this->invocations) > 0) { throw new CallAmountViolation(sprintf( '%s was not expected to be called,' . ' but actually called %d time(s).', $this->invocations->name(), count($this->invocations) )); } return true; }
php
public function wasNeverCalled(): bool { if (count($this->invocations) > 0) { throw new CallAmountViolation(sprintf( '%s was not expected to be called,' . ' but actually called %d time(s).', $this->invocations->name(), count($this->invocations) )); } return true; }
[ "public", "function", "wasNeverCalled", "(", ")", ":", "bool", "{", "if", "(", "count", "(", "$", "this", "->", "invocations", ")", ">", "0", ")", "{", "throw", "new", "CallAmountViolation", "(", "sprintf", "(", "'%s was not expected to be called,'", ".", "'...
verifies that the method on the class was never called @api @return bool @throws \bovigo\callmap\CallAmountViolation
[ "verifies", "that", "the", "method", "on", "the", "class", "was", "never", "called" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L153-L165
train
bovigo/callmap
src/main/php/Verification.php
Verification.receivedNothing
public function receivedNothing(int $invocation = 1): bool { $received = $this->invocations->argumentsOf($invocation); if (count($received) === 0) { return true; } throw new ArgumentMismatch(sprintf( 'Argument count for invocation #%d of %s is too' . ' high: received %d argument(s), expected no arguments.', $invocation, $this->invocations->name(), count($received) )); }
php
public function receivedNothing(int $invocation = 1): bool { $received = $this->invocations->argumentsOf($invocation); if (count($received) === 0) { return true; } throw new ArgumentMismatch(sprintf( 'Argument count for invocation #%d of %s is too' . ' high: received %d argument(s), expected no arguments.', $invocation, $this->invocations->name(), count($received) )); }
[ "public", "function", "receivedNothing", "(", "int", "$", "invocation", "=", "1", ")", ":", "bool", "{", "$", "received", "=", "$", "this", "->", "invocations", "->", "argumentsOf", "(", "$", "invocation", ")", ";", "if", "(", "count", "(", "$", "recei...
verifies that the method received nothing on the given invocation @api @param int $invocation optional nth invocation to check, defaults to 1 aka first invocation @return bool @throws \bovigo\callmap\ArgumentMismatch
[ "verifies", "that", "the", "method", "received", "nothing", "on", "the", "given", "invocation" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L175-L189
train
bovigo/callmap
src/main/php/Verification.php
Verification.verifyArgs
private function verifyArgs(int $invocation, array $expected): bool { $received = $this->invocations->argumentsOf($invocation); if (count($received) < count($expected)) { throw new ArgumentMismatch(sprintf( 'Argument count for invocation #%d of %s is too' . ' low: received %d argument(s), expected %d argument(s).', $invocation, $this->invocations->name(), count($received), count($expected) )); } foreach ($expected as $atPosition => $constraint) { $this->evaluate( $constraint, $received[$atPosition] ?? null, sprintf( 'Parameter %sat position %d for invocation #%d of %s' . ' does not match expected value.', $this->invocations->argumentName($atPosition, ' '), $atPosition, $invocation, $this->invocations->name() ) ); } return true; }
php
private function verifyArgs(int $invocation, array $expected): bool { $received = $this->invocations->argumentsOf($invocation); if (count($received) < count($expected)) { throw new ArgumentMismatch(sprintf( 'Argument count for invocation #%d of %s is too' . ' low: received %d argument(s), expected %d argument(s).', $invocation, $this->invocations->name(), count($received), count($expected) )); } foreach ($expected as $atPosition => $constraint) { $this->evaluate( $constraint, $received[$atPosition] ?? null, sprintf( 'Parameter %sat position %d for invocation #%d of %s' . ' does not match expected value.', $this->invocations->argumentName($atPosition, ' '), $atPosition, $invocation, $this->invocations->name() ) ); } return true; }
[ "private", "function", "verifyArgs", "(", "int", "$", "invocation", ",", "array", "$", "expected", ")", ":", "bool", "{", "$", "received", "=", "$", "this", "->", "invocations", "->", "argumentsOf", "(", "$", "invocation", ")", ";", "if", "(", "count", ...
verifies arguments of given invocation with the expected constraints If a constraint is not an instance of PHPUnit\Framework\Constraint\Constraint it will automatically use PHPUnit\Framework\Constraint\IsEqual. @param int $invocation number of invocation to check @param array $expected constraints which describe expected parameters @return bool @throws \bovigo\callmap\ArgumentMismatch
[ "verifies", "arguments", "of", "given", "invocation", "with", "the", "expected", "constraints" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L233-L263
train
bovigo/callmap
src/main/php/Verification.php
Verification.evaluate
private function evaluate($constraint, $received, string $description): bool { if (function_exists('bovigo\assert\assertThat')) { return \bovigo\assert\assertThat( $received, $this->predicateFor($constraint), $description ); } if (class_exists('\PHPUnit\Framework\Constraint\IsEqual')) { return $this->evaluateWithPhpUnit($constraint, $received, $description); } if (class_exists('\unittest\TestCase')) { return $this->evaluateWithXpFrameworkCore($constraint, $received, $description); } throw new \RuntimeException('Neither bovigo/assert, PHPUnit nor xp-framework/unittest found, can not perform argument verification'); }
php
private function evaluate($constraint, $received, string $description): bool { if (function_exists('bovigo\assert\assertThat')) { return \bovigo\assert\assertThat( $received, $this->predicateFor($constraint), $description ); } if (class_exists('\PHPUnit\Framework\Constraint\IsEqual')) { return $this->evaluateWithPhpUnit($constraint, $received, $description); } if (class_exists('\unittest\TestCase')) { return $this->evaluateWithXpFrameworkCore($constraint, $received, $description); } throw new \RuntimeException('Neither bovigo/assert, PHPUnit nor xp-framework/unittest found, can not perform argument verification'); }
[ "private", "function", "evaluate", "(", "$", "constraint", ",", "$", "received", ",", "string", "$", "description", ")", ":", "bool", "{", "if", "(", "function_exists", "(", "'bovigo\\assert\\assertThat'", ")", ")", "{", "return", "\\", "bovigo", "\\", "asse...
evaluates given constraint given received argument @param mixed|\bovigo\assert\predicate\Predicate|\PHPUnit\Framework\Constraint\Constraint $constraint constraint for argument @param mixed $received actually received argument @param string $description description for invocation in case of error @return bool @throws \RuntimeException in case neither bovigo/assert, PHPUnit not xp-framework/unittest is present
[ "evaluates", "given", "constraint", "given", "received", "argument" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L274-L293
train
bovigo/callmap
src/main/php/Verification.php
Verification.predicateFor
private function predicateFor($constraint): \bovigo\assert\predicate\Predicate { if ($constraint instanceof \PHPUnit\Framework\Constraint\Constraint) { return new \bovigo\assert\phpunit\ConstraintAdapter($constraint); } if ($constraint instanceof \bovigo\assert\predicate\Predicate) { return $constraint; } return \bovigo\assert\predicate\equals($constraint); }
php
private function predicateFor($constraint): \bovigo\assert\predicate\Predicate { if ($constraint instanceof \PHPUnit\Framework\Constraint\Constraint) { return new \bovigo\assert\phpunit\ConstraintAdapter($constraint); } if ($constraint instanceof \bovigo\assert\predicate\Predicate) { return $constraint; } return \bovigo\assert\predicate\equals($constraint); }
[ "private", "function", "predicateFor", "(", "$", "constraint", ")", ":", "\\", "bovigo", "\\", "assert", "\\", "predicate", "\\", "Predicate", "{", "if", "(", "$", "constraint", "instanceof", "\\", "PHPUnit", "\\", "Framework", "\\", "Constraint", "\\", "Con...
creates precicate for given constraint @param mixed|\bovigo\assert\predicate\Predicate|\PHPUnit\Framework\Constraint\Constraint $constraint @return \bovigo\assert\predicate\Predicate
[ "creates", "precicate", "for", "given", "constraint" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L301-L312
train
bovigo/callmap
src/main/php/Verification.php
Verification.evaluateWithPhpUnit
protected function evaluateWithPhpUnit($constraint, $received, string $description): bool { if ($constraint instanceof \PHPUnit\Framework\Constraint\Constraint) { return $constraint->evaluate($received, $description); } return (new \PHPUnit\Framework\Constraint\IsEqual($constraint)) ->evaluate($received, $description); }
php
protected function evaluateWithPhpUnit($constraint, $received, string $description): bool { if ($constraint instanceof \PHPUnit\Framework\Constraint\Constraint) { return $constraint->evaluate($received, $description); } return (new \PHPUnit\Framework\Constraint\IsEqual($constraint)) ->evaluate($received, $description); }
[ "protected", "function", "evaluateWithPhpUnit", "(", "$", "constraint", ",", "$", "received", ",", "string", "$", "description", ")", ":", "bool", "{", "if", "(", "$", "constraint", "instanceof", "\\", "PHPUnit", "\\", "Framework", "\\", "Constraint", "\\", ...
evaluates given constraint using PHPUnit If given constraint is not a instance of \PHPUnit\Framework\Constraint\Constraint it will be wrapped with \PHPUnit\Framework\Constraint\IsEqual. @param mixed|\PHPUnit\Framework\Constraint\Constraint $constraint constraint for argument @param mixed $received actually received argument @param string $description description for invocation in case of error @return bool
[ "evaluates", "given", "constraint", "using", "PHPUnit" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Verification.php#L325-L333
train
dshanske/parse-this
includes/class-parse-this-mf2.php
Parse_This_MF2.is_type
public static function is_type( $mf, $type ) { return is_array( $mf ) && ! empty( $mf['type'] ) && is_array( $mf['type'] ) && in_array( $type, $mf['type'], true ); }
php
public static function is_type( $mf, $type ) { return is_array( $mf ) && ! empty( $mf['type'] ) && is_array( $mf['type'] ) && in_array( $type, $mf['type'], true ); }
[ "public", "static", "function", "is_type", "(", "$", "mf", ",", "$", "type", ")", "{", "return", "is_array", "(", "$", "mf", ")", "&&", "!", "empty", "(", "$", "mf", "[", "'type'", "]", ")", "&&", "is_array", "(", "$", "mf", "[", "'type'", "]", ...
is this what type @param array $mf Parsed Microformats Array @param string $type Type @return bool
[ "is", "this", "what", "type" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-mf2.php#L18-L20
train
dshanske/parse-this
includes/class-parse-this-mf2.php
Parse_This_MF2.get_prop
public static function get_prop( array $mf, $propname, $fallback = null ) { return self::get_plaintext( $mf, $propname, $fallback ); }
php
public static function get_prop( array $mf, $propname, $fallback = null ) { return self::get_plaintext( $mf, $propname, $fallback ); }
[ "public", "static", "function", "get_prop", "(", "array", "$", "mf", ",", "$", "propname", ",", "$", "fallback", "=", "null", ")", "{", "return", "self", "::", "get_plaintext", "(", "$", "mf", ",", "$", "propname", ",", "$", "fallback", ")", ";", "}"...
shortcut for getPlaintext. @deprecated use getPlaintext from now on @param array $mf @param $propname @param null|string $fallback @return mixed|null
[ "shortcut", "for", "getPlaintext", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-mf2.php#L117-L119
train
dshanske/parse-this
includes/class-parse-this-mf2.php
Parse_This_MF2.get_prop_array
public static function get_prop_array( array $mf, $properties, $args = null ) { if ( ! self::is_microformat( $mf ) ) { return array(); } $data = array(); foreach ( $properties as $p ) { if ( array_key_exists( $p, $mf['properties'] ) ) { foreach ( $mf['properties'][ $p ] as $v ) { if ( self::is_microformat( $v ) ) { $data[ $p ] = self::parse_item( $v, $mf, $args ); } else { if ( isset( $data[ $p ] ) ) { $data[ $p ][] = $v; } else { $data[ $p ] = array( $v ); } } } } } return $data; }
php
public static function get_prop_array( array $mf, $properties, $args = null ) { if ( ! self::is_microformat( $mf ) ) { return array(); } $data = array(); foreach ( $properties as $p ) { if ( array_key_exists( $p, $mf['properties'] ) ) { foreach ( $mf['properties'][ $p ] as $v ) { if ( self::is_microformat( $v ) ) { $data[ $p ] = self::parse_item( $v, $mf, $args ); } else { if ( isset( $data[ $p ] ) ) { $data[ $p ][] = $v; } else { $data[ $p ] = array( $v ); } } } } } return $data; }
[ "public", "static", "function", "get_prop_array", "(", "array", "$", "mf", ",", "$", "properties", ",", "$", "args", "=", "null", ")", "{", "if", "(", "!", "self", "::", "is_microformat", "(", "$", "mf", ")", ")", "{", "return", "array", "(", ")", ...
Return an array of properties, and may contain plaintext content @param array $mf @param array $properties @return null|array
[ "Return", "an", "array", "of", "properties", "and", "may", "contain", "plaintext", "content" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-mf2.php#L173-L195
train
dshanske/parse-this
includes/class-parse-this-mf2.php
Parse_This_MF2.get_datetime_property
public static function get_datetime_property( $name, array $mf, $ensurevalid = false, $fallback = null ) { $compliment = 'published' === $name ? 'updated' : 'published'; if ( self::has_prop( $mf, $name ) ) { $return = self::get_prop( $mf, $name ); } elseif ( self::has_prop( $mf, $compliment ) ) { $return = self::get_prop( $mf, $compliment ); } else { return $fallback; } if ( ! $ensurevalid ) { return $return; } else { try { $date = new DateTime( $return ); return $date->format( DATE_W3C ); } catch ( Exception $e ) { return $fallback; } } }
php
public static function get_datetime_property( $name, array $mf, $ensurevalid = false, $fallback = null ) { $compliment = 'published' === $name ? 'updated' : 'published'; if ( self::has_prop( $mf, $name ) ) { $return = self::get_prop( $mf, $name ); } elseif ( self::has_prop( $mf, $compliment ) ) { $return = self::get_prop( $mf, $compliment ); } else { return $fallback; } if ( ! $ensurevalid ) { return $return; } else { try { $date = new DateTime( $return ); return $date->format( DATE_W3C ); } catch ( Exception $e ) { return $fallback; } } }
[ "public", "static", "function", "get_datetime_property", "(", "$", "name", ",", "array", "$", "mf", ",", "$", "ensurevalid", "=", "false", ",", "$", "fallback", "=", "null", ")", "{", "$", "compliment", "=", "'published'", "===", "$", "name", "?", "'upda...
Gets the DateTime properties including published or updated, depending on params. @param $name string updated or published @param array $mf @param bool $ensurevalid @param null|string $fallback @return mixed|null
[ "Gets", "the", "DateTime", "properties", "including", "published", "or", "updated", "depending", "on", "params", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-mf2.php#L282-L298
train
dshanske/parse-this
includes/class-parse-this-mf2.php
Parse_This_MF2.parse_url
public static function parse_url( $url ) { $r = wp_parse_url( $url ); $r['pathname'] = empty( $r['path'] ) ? '/' : $r['path']; return $r; }
php
public static function parse_url( $url ) { $r = wp_parse_url( $url ); $r['pathname'] = empty( $r['path'] ) ? '/' : $r['path']; return $r; }
[ "public", "static", "function", "parse_url", "(", "$", "url", ")", "{", "$", "r", "=", "wp_parse_url", "(", "$", "url", ")", ";", "$", "r", "[", "'pathname'", "]", "=", "empty", "(", "$", "r", "[", "'path'", "]", ")", "?", "'/'", ":", "$", "r",...
Returns array per parse_url standard with pathname key added. @param $url @return mixed @link http://php.net/manual/en/function.parse-url.php
[ "Returns", "array", "per", "parse_url", "standard", "with", "pathname", "key", "added", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-mf2.php#L380-L384
train
dshanske/parse-this
includes/class-parse-this-mf2.php
Parse_This_MF2.normalize_feed
public static function normalize_feed( $input ) { $hcard = array(); foreach ( $input['items'] as $key => $item ) { if ( self::is_type( $item, 'h-card' ) ) { $hcard = $item; unset( $input['items'][ $key ] ); break; } } if ( 1 === count( $input['items'] ) ) { if ( self::has_prop( $input['items'][0], 'author' ) ) { $input['items'][0]['properties']['author'] = array( $hcard ); } return $input; } return array( 'items' => array( array( 'type' => array( 'h-feed' ), 'properties' => array( 'author' => array( $hcard ), ), 'children' => $input['items'], ), ), ); }
php
public static function normalize_feed( $input ) { $hcard = array(); foreach ( $input['items'] as $key => $item ) { if ( self::is_type( $item, 'h-card' ) ) { $hcard = $item; unset( $input['items'][ $key ] ); break; } } if ( 1 === count( $input['items'] ) ) { if ( self::has_prop( $input['items'][0], 'author' ) ) { $input['items'][0]['properties']['author'] = array( $hcard ); } return $input; } return array( 'items' => array( array( 'type' => array( 'h-feed' ), 'properties' => array( 'author' => array( $hcard ), ), 'children' => $input['items'], ), ), ); }
[ "public", "static", "function", "normalize_feed", "(", "$", "input", ")", "{", "$", "hcard", "=", "array", "(", ")", ";", "foreach", "(", "$", "input", "[", "'items'", "]", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "self", "::", "...
Tries to normalize a set of items into a feed
[ "Tries", "to", "normalize", "a", "set", "of", "items", "into", "a", "feed" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-mf2.php#L610-L636
train
GrahamCampbell/Laravel-TestBench-Core
src/HelperTrait.php
HelperTrait.assertInArray
public static function assertInArray($needle, array $haystack, string $msg = '') { if ($msg === '') { $msg = "Expected the array to contain the element '$needle'."; } static::assertTrue(in_array($needle, $haystack, true), $msg); }
php
public static function assertInArray($needle, array $haystack, string $msg = '') { if ($msg === '') { $msg = "Expected the array to contain the element '$needle'."; } static::assertTrue(in_array($needle, $haystack, true), $msg); }
[ "public", "static", "function", "assertInArray", "(", "$", "needle", ",", "array", "$", "haystack", ",", "string", "$", "msg", "=", "''", ")", "{", "if", "(", "$", "msg", "===", "''", ")", "{", "$", "msg", "=", "\"Expected the array to contain the element ...
Assert that the element exists in the array. @param mixed $needle @param array $haystack @param string $msg @return void
[ "Assert", "that", "the", "element", "exists", "in", "the", "array", "." ]
138218735a65f4532d6c4242a44ffa6c591bca09
https://github.com/GrahamCampbell/Laravel-TestBench-Core/blob/138218735a65f4532d6c4242a44ffa6c591bca09/src/HelperTrait.php#L35-L42
train
GrahamCampbell/Laravel-TestBench-Core
src/HelperTrait.php
HelperTrait.assertMethodExists
public static function assertMethodExists(string $method, string $class, string $msg = '') { if ($msg === '') { $msg = "Expected the class '$class' to have method '$method'."; } static::assertTrue(method_exists($class, $method), $msg); }
php
public static function assertMethodExists(string $method, string $class, string $msg = '') { if ($msg === '') { $msg = "Expected the class '$class' to have method '$method'."; } static::assertTrue(method_exists($class, $method), $msg); }
[ "public", "static", "function", "assertMethodExists", "(", "string", "$", "method", ",", "string", "$", "class", ",", "string", "$", "msg", "=", "''", ")", "{", "if", "(", "$", "msg", "===", "''", ")", "{", "$", "msg", "=", "\"Expected the class '$class'...
Assert that the specified method exists on the class. @param string $method @param string $class @param string $msg @return void
[ "Assert", "that", "the", "specified", "method", "exists", "on", "the", "class", "." ]
138218735a65f4532d6c4242a44ffa6c591bca09
https://github.com/GrahamCampbell/Laravel-TestBench-Core/blob/138218735a65f4532d6c4242a44ffa6c591bca09/src/HelperTrait.php#L53-L60
train
GrahamCampbell/Laravel-TestBench-Core
src/HelperTrait.php
HelperTrait.assertInJson
public static function assertInJson(string $needle, array $haystack, string $msg = '') { if ($msg === '') { $msg = "Expected the array to contain the element '$needle'."; } $array = json_decode($needle, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new InvalidArgumentException("Invalid json provided: '$needle'."); } static::assertArraySubset($haystack, $array, false, $msg); }
php
public static function assertInJson(string $needle, array $haystack, string $msg = '') { if ($msg === '') { $msg = "Expected the array to contain the element '$needle'."; } $array = json_decode($needle, true); if (json_last_error() !== JSON_ERROR_NONE) { throw new InvalidArgumentException("Invalid json provided: '$needle'."); } static::assertArraySubset($haystack, $array, false, $msg); }
[ "public", "static", "function", "assertInJson", "(", "string", "$", "needle", ",", "array", "$", "haystack", ",", "string", "$", "msg", "=", "''", ")", "{", "if", "(", "$", "msg", "===", "''", ")", "{", "$", "msg", "=", "\"Expected the array to contain t...
Assert that the element exists in the json. @param string $needle @param array $haystack @param string $msg @throws \InvalidArgumentException @return void
[ "Assert", "that", "the", "element", "exists", "in", "the", "json", "." ]
138218735a65f4532d6c4242a44ffa6c591bca09
https://github.com/GrahamCampbell/Laravel-TestBench-Core/blob/138218735a65f4532d6c4242a44ffa6c591bca09/src/HelperTrait.php#L73-L86
train
QuickenLoans/mcp-cache
src/Item/Item.php
Item.data
public function data(TimePoint $now = null) { if ($now && $this->isExpired($now)) { return null; } return $this->data; }
php
public function data(TimePoint $now = null) { if ($now && $this->isExpired($now)) { return null; } return $this->data; }
[ "public", "function", "data", "(", "TimePoint", "$", "now", "=", "null", ")", "{", "if", "(", "$", "now", "&&", "$", "this", "->", "isExpired", "(", "$", "now", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "data", ";", ...
If provided, the data will be checked for expiration. @param TimePoint|null $now @return mixed
[ "If", "provided", "the", "data", "will", "be", "checked", "for", "expiration", "." ]
2dba32705f85452cb9099e35e0241a6c7a98b717
https://github.com/QuickenLoans/mcp-cache/blob/2dba32705f85452cb9099e35e0241a6c7a98b717/src/Item/Item.php#L67-L74
train
GrahamCampbell/Laravel-TestBench-Core
src/MockeryTrait.php
MockeryTrait.tearDownMockery
public function tearDownMockery() { if (class_exists(Mockery::class, false)) { $container = Mockery::getContainer(); if ($container) { $this->addToAssertionCount($container->mockery_getExpectationCount()); } Mockery::close(); } }
php
public function tearDownMockery() { if (class_exists(Mockery::class, false)) { $container = Mockery::getContainer(); if ($container) { $this->addToAssertionCount($container->mockery_getExpectationCount()); } Mockery::close(); } }
[ "public", "function", "tearDownMockery", "(", ")", "{", "if", "(", "class_exists", "(", "Mockery", "::", "class", ",", "false", ")", ")", "{", "$", "container", "=", "Mockery", "::", "getContainer", "(", ")", ";", "if", "(", "$", "container", ")", "{",...
Tear down mockery. @after @return void
[ "Tear", "down", "mockery", "." ]
138218735a65f4532d6c4242a44ffa6c591bca09
https://github.com/GrahamCampbell/Laravel-TestBench-Core/blob/138218735a65f4532d6c4242a44ffa6c591bca09/src/MockeryTrait.php#L32-L43
train
dshanske/parse-this
includes/class-parse-this-api.php
Parse_This_API.debug
public static function debug() { ?> <div class="wrap"> <h2> <?php esc_html_e( 'Parse This Debugger', 'indieweb-post-kinds' ); ?> </h2> <p> <?php esc_html_e( 'Test the Parse Tools Debugger. You can report sites to the developer for possibly improvement in future', 'parse-this' ); ?> </p> <a href="https://github.com/dshanske/parse-this/issues"><?php esc_html_e( 'Open an Issue', 'parse-this' ); ?></a> <p> <?php if ( is_plugin_active( 'parse-this/parse-this.php' ) ) { esc_html_e( 'You are using the plugin version of Parse This as opposed to a version built into any plugin', 'parse-this' ); } ?> <hr /> <form method="get" action="<?php echo esc_url( rest_url( '/parse-this/1.0/parse/' ) ); ?> "> <p><label for="url"><?php esc_html_e( 'URL', 'indieweb-post-kinds' ); ?></label><input type="url" class="widefat" name="url" id="url" /></p> <p><label for="mf2"><?php esc_html_e( 'MF2', 'indieweb-post-kinds' ); ?></label><input type="checkbox" name="mf2" id="mf2" /></p> <p><label for="discovery"><?php esc_html_e( 'Feed Discovery', 'indieweb-post-kinds' ); ?></label><input type="checkbox" name="discovery" id="discovery" /></p> <p><label for"return"><?php esc_html_e( 'Return Type', 'indieweb-post-kinds' ); ?></label> <select name="return"> <option value="single"><?php esc_html_e( 'Single', 'indieweb-post-kinds' ); ?></option> <option value="feed"><?php esc_html_e( 'Feed', 'indieweb-post-kinds' ); ?></option> </select> </p> <p><label for="follow"><?php esc_html_e( 'Follow Author Links', 'indieweb-post-kinds' ); ?></label><input type="checkbox" name="follow" id="follow" /></p> <?php wp_nonce_field( 'wp_rest' ); ?> <?php submit_button( __( 'Parse', 'indieweb-post-kinds' ) ); ?> </form> </div> <?php }
php
public static function debug() { ?> <div class="wrap"> <h2> <?php esc_html_e( 'Parse This Debugger', 'indieweb-post-kinds' ); ?> </h2> <p> <?php esc_html_e( 'Test the Parse Tools Debugger. You can report sites to the developer for possibly improvement in future', 'parse-this' ); ?> </p> <a href="https://github.com/dshanske/parse-this/issues"><?php esc_html_e( 'Open an Issue', 'parse-this' ); ?></a> <p> <?php if ( is_plugin_active( 'parse-this/parse-this.php' ) ) { esc_html_e( 'You are using the plugin version of Parse This as opposed to a version built into any plugin', 'parse-this' ); } ?> <hr /> <form method="get" action="<?php echo esc_url( rest_url( '/parse-this/1.0/parse/' ) ); ?> "> <p><label for="url"><?php esc_html_e( 'URL', 'indieweb-post-kinds' ); ?></label><input type="url" class="widefat" name="url" id="url" /></p> <p><label for="mf2"><?php esc_html_e( 'MF2', 'indieweb-post-kinds' ); ?></label><input type="checkbox" name="mf2" id="mf2" /></p> <p><label for="discovery"><?php esc_html_e( 'Feed Discovery', 'indieweb-post-kinds' ); ?></label><input type="checkbox" name="discovery" id="discovery" /></p> <p><label for"return"><?php esc_html_e( 'Return Type', 'indieweb-post-kinds' ); ?></label> <select name="return"> <option value="single"><?php esc_html_e( 'Single', 'indieweb-post-kinds' ); ?></option> <option value="feed"><?php esc_html_e( 'Feed', 'indieweb-post-kinds' ); ?></option> </select> </p> <p><label for="follow"><?php esc_html_e( 'Follow Author Links', 'indieweb-post-kinds' ); ?></label><input type="checkbox" name="follow" id="follow" /></p> <?php wp_nonce_field( 'wp_rest' ); ?> <?php submit_button( __( 'Parse', 'indieweb-post-kinds' ) ); ?> </form> </div> <?php }
[ "public", "static", "function", "debug", "(", ")", "{", "?>\n\t\t\t\t<div class=\"wrap\">\n\t\t\t\t\t\t<h2> <?php", "esc_html_e", "(", "'Parse This Debugger'", ",", "'indieweb-post-kinds'", ")", ";", "?> </h2>\n\t\t\t\t\t\t<p> <?php", "esc_html_e", "(", "'Test the Parse Tools Deb...
Generate Debug Tool @access public
[ "Generate", "Debug", "Tool" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-api.php#L40-L70
train
bovigo/callmap
src/main/php/Invocations.php
Invocations.argumentName
public function argumentName(int $argumentPosition, string $suffix = ''): ?string { if (isset($this->paramNames[$argumentPosition])) { return '$' . $this->paramNames[$argumentPosition] . $suffix; } return null; }
php
public function argumentName(int $argumentPosition, string $suffix = ''): ?string { if (isset($this->paramNames[$argumentPosition])) { return '$' . $this->paramNames[$argumentPosition] . $suffix; } return null; }
[ "public", "function", "argumentName", "(", "int", "$", "argumentPosition", ",", "string", "$", "suffix", "=", "''", ")", ":", "?", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "paramNames", "[", "$", "argumentPosition", "]", ")", ")", "{"...
returns name of argument at requested position Returns null if there is no argument at requested position or the name of that argument is unknown. @param int $argumentPosition @param string $suffix optional string to append after argument name @return string|null
[ "returns", "name", "of", "argument", "at", "requested", "position" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Invocations.php#L85-L92
train
bovigo/callmap
src/main/php/Invocations.php
Invocations.argumentsOf
public function argumentsOf(int $invocation = 1): array { if (isset($this->callHistory[$invocation - 1])) { return $this->callHistory[$invocation - 1]; } $totalInvocations = $this->count(); throw new MissingInvocation(sprintf( 'Missing invocation #%d for %s, was %s.', $invocation, $this->name, ($totalInvocations === 0 ? 'never called' : ('only called ' . ($totalInvocations === 1 ? 'once' : $totalInvocations . ' times') ) ) )); }
php
public function argumentsOf(int $invocation = 1): array { if (isset($this->callHistory[$invocation - 1])) { return $this->callHistory[$invocation - 1]; } $totalInvocations = $this->count(); throw new MissingInvocation(sprintf( 'Missing invocation #%d for %s, was %s.', $invocation, $this->name, ($totalInvocations === 0 ? 'never called' : ('only called ' . ($totalInvocations === 1 ? 'once' : $totalInvocations . ' times') ) ) )); }
[ "public", "function", "argumentsOf", "(", "int", "$", "invocation", "=", "1", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "this", "->", "callHistory", "[", "$", "invocation", "-", "1", "]", ")", ")", "{", "return", "$", "this", "->", "cal...
returns the arguments received for a specific invocation @param int $invocation nth invocation to check, defaults to 1 aka first invocation @return mixed[] @throws \bovigo\callmap\MissingInvocation in case no such invocation was received
[ "returns", "the", "arguments", "received", "for", "a", "specific", "invocation" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/Invocations.php#L101-L119
train
QuickenLoans/mcp-logger
src/Message/MessageFactory.php
MessageFactory.setDefaultProperty
public function setDefaultProperty(string $name, $value): void { $this->validateProperty($name, $value); $this->logProperties[$name] = $value; }
php
public function setDefaultProperty(string $name, $value): void { $this->validateProperty($name, $value); $this->logProperties[$name] = $value; }
[ "public", "function", "setDefaultProperty", "(", "string", "$", "name", ",", "$", "value", ")", ":", "void", "{", "$", "this", "->", "validateProperty", "(", "$", "name", ",", "$", "value", ")", ";", "$", "this", "->", "logProperties", "[", "$", "name"...
Set a property that will be attached to all log messages. @param string $name @param mixed $value @return void
[ "Set", "a", "property", "that", "will", "be", "attached", "to", "all", "log", "messages", "." ]
ec0960fc32de1a4c583b2447b99d0ef8c801f1ae
https://github.com/QuickenLoans/mcp-logger/blob/ec0960fc32de1a4c583b2447b99d0ef8c801f1ae/src/Message/MessageFactory.php#L118-L123
train
QuickenLoans/mcp-logger
src/Message/MessageFactory.php
MessageFactory.buildMessage
public function buildMessage($level, string $message, array $context = []): MessageInterface { $level = $this->validateSeverity($level); $data = [ MessageInterface::CONTEXT => [] ]; // Append message defaults to this payload $data = $this->consume($data, $this->logProperties); // Append message context to this payload $data = $this->consume($data, $context); return new Message($level, $message, $data); }
php
public function buildMessage($level, string $message, array $context = []): MessageInterface { $level = $this->validateSeverity($level); $data = [ MessageInterface::CONTEXT => [] ]; // Append message defaults to this payload $data = $this->consume($data, $this->logProperties); // Append message context to this payload $data = $this->consume($data, $context); return new Message($level, $message, $data); }
[ "public", "function", "buildMessage", "(", "$", "level", ",", "string", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", ":", "MessageInterface", "{", "$", "level", "=", "$", "this", "->", "validateSeverity", "(", "$", "level", ")", ";...
Sanitize and instantiate a Message @param mixed $level @param string $message @param array $context @return Message
[ "Sanitize", "and", "instantiate", "a", "Message" ]
ec0960fc32de1a4c583b2447b99d0ef8c801f1ae
https://github.com/QuickenLoans/mcp-logger/blob/ec0960fc32de1a4c583b2447b99d0ef8c801f1ae/src/Message/MessageFactory.php#L163-L177
train
QuickenLoans/mcp-logger
src/Message/MessageFactory.php
MessageFactory.consume
private function consume(array $data, array $context) { foreach ($context as $property => $value) { $sanitized = $this->validateValue($value); if ($sanitized === null) { continue; } if (in_array($property, [MessageInterface::SERVER_IP, MessageInterface::USER_IP], true)) { try { $ip = new IP($value); $value = $ip->getShortAddress(); } catch (InvalidIpAddressException $e) { $value = '0.0.0.0'; } } if (in_array($property, $this->knownProperties, true)) { $data[$property] = $sanitized; } else { $data[MessageInterface::CONTEXT][$property] = $sanitized; } } return $data; }
php
private function consume(array $data, array $context) { foreach ($context as $property => $value) { $sanitized = $this->validateValue($value); if ($sanitized === null) { continue; } if (in_array($property, [MessageInterface::SERVER_IP, MessageInterface::USER_IP], true)) { try { $ip = new IP($value); $value = $ip->getShortAddress(); } catch (InvalidIpAddressException $e) { $value = '0.0.0.0'; } } if (in_array($property, $this->knownProperties, true)) { $data[$property] = $sanitized; } else { $data[MessageInterface::CONTEXT][$property] = $sanitized; } } return $data; }
[ "private", "function", "consume", "(", "array", "$", "data", ",", "array", "$", "context", ")", "{", "foreach", "(", "$", "context", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "sanitized", "=", "$", "this", "->", "validateValue", "(", ...
Parse the provided context data and add it to the message payload @param mixed[] $data @param mixed[] $context @return mixed[]
[ "Parse", "the", "provided", "context", "data", "and", "add", "it", "to", "the", "message", "payload" ]
ec0960fc32de1a4c583b2447b99d0ef8c801f1ae
https://github.com/QuickenLoans/mcp-logger/blob/ec0960fc32de1a4c583b2447b99d0ef8c801f1ae/src/Message/MessageFactory.php#L187-L213
train
QuickenLoans/mcp-logger
src/Transformer/QLLogSeverityTransformer.php
QLLogSeverityTransformer.convertLogLevelFromPSRToQL
private function convertLogLevelFromPSRToQL($severity) { // Equal mappings if ($severity === LogLevel::DEBUG) { return 'debug'; } elseif ($severity === LogLevel::INFO) { return 'info'; } elseif ($severity === LogLevel::WARNING) { return 'warn'; } elseif ($severity === LogLevel::ERROR) { return 'error'; } // Duplicate mappings if ($severity === LogLevel::NOTICE) { return 'info'; } elseif ($severity === LogLevel::CRITICAL) { return 'fatal'; } elseif ($severity === LogLevel::ALERT) { return 'fatal'; } elseif ($severity === LogLevel::EMERGENCY) { return 'fatal'; } // Default to error return 'error'; }
php
private function convertLogLevelFromPSRToQL($severity) { // Equal mappings if ($severity === LogLevel::DEBUG) { return 'debug'; } elseif ($severity === LogLevel::INFO) { return 'info'; } elseif ($severity === LogLevel::WARNING) { return 'warn'; } elseif ($severity === LogLevel::ERROR) { return 'error'; } // Duplicate mappings if ($severity === LogLevel::NOTICE) { return 'info'; } elseif ($severity === LogLevel::CRITICAL) { return 'fatal'; } elseif ($severity === LogLevel::ALERT) { return 'fatal'; } elseif ($severity === LogLevel::EMERGENCY) { return 'fatal'; } // Default to error return 'error'; }
[ "private", "function", "convertLogLevelFromPSRToQL", "(", "$", "severity", ")", "{", "// Equal mappings", "if", "(", "$", "severity", "===", "LogLevel", "::", "DEBUG", ")", "{", "return", "'debug'", ";", "}", "elseif", "(", "$", "severity", "===", "LogLevel", ...
Translate a PRS-3 log level to QL log level Not used: - 'audit' @param string $severity @return string
[ "Translate", "a", "PRS", "-", "3", "log", "level", "to", "QL", "log", "level" ]
ec0960fc32de1a4c583b2447b99d0ef8c801f1ae
https://github.com/QuickenLoans/mcp-logger/blob/ec0960fc32de1a4c583b2447b99d0ef8c801f1ae/src/Transformer/QLLogSeverityTransformer.php#L41-L73
train
bovigo/callmap
src/main/php/ClassProxyMethodHandler.php
ClassProxyMethodHandler.returns
public function returns(array $callMap): ClassProxy { foreach (array_keys($callMap) as $method) { if (!isset($this->_allowedMethods[$method]) || isset($this->_voidMethods[$method])) { throw new \InvalidArgumentException( $this->canNot('map', $method) ); } } $this->callMap = new CallMap($callMap); return $this; }
php
public function returns(array $callMap): ClassProxy { foreach (array_keys($callMap) as $method) { if (!isset($this->_allowedMethods[$method]) || isset($this->_voidMethods[$method])) { throw new \InvalidArgumentException( $this->canNot('map', $method) ); } } $this->callMap = new CallMap($callMap); return $this; }
[ "public", "function", "returns", "(", "array", "$", "callMap", ")", ":", "ClassProxy", "{", "foreach", "(", "array_keys", "(", "$", "callMap", ")", "as", "$", "method", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_allowedMethods", "[", ...
sets the call map with return values @api @since 3.2.0 @param array $callMap @return ClassProxy @throws \InvalidArgumentException in case any of the mapped methods does not exist or is not applicable
[ "sets", "the", "call", "map", "with", "return", "values" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/ClassProxyMethodHandler.php#L56-L68
train
bovigo/callmap
src/main/php/ClassProxyMethodHandler.php
ClassProxyMethodHandler.handleMethodCall
protected function handleMethodCall(string $method, array $arguments, bool $shouldReturnSelf) { $invocation = $this->invocations($method)->recordCall($arguments); if (null !== $this->callMap && $this->callMap->hasResultFor($method, $invocation)) { return $this->callMap->resultFor($method, $arguments, $invocation); } if ($this->parentCallsAllowed && is_callable(['parent', $method])) { // is_callable() returns true even for abstract methods $refMethod = new \ReflectionMethod(get_parent_class(), $method); if (!$refMethod->isAbstract()) { return parent::$method(...$arguments); } } if ($shouldReturnSelf) { return $this; } return null; }
php
protected function handleMethodCall(string $method, array $arguments, bool $shouldReturnSelf) { $invocation = $this->invocations($method)->recordCall($arguments); if (null !== $this->callMap && $this->callMap->hasResultFor($method, $invocation)) { return $this->callMap->resultFor($method, $arguments, $invocation); } if ($this->parentCallsAllowed && is_callable(['parent', $method])) { // is_callable() returns true even for abstract methods $refMethod = new \ReflectionMethod(get_parent_class(), $method); if (!$refMethod->isAbstract()) { return parent::$method(...$arguments); } } if ($shouldReturnSelf) { return $this; } return null; }
[ "protected", "function", "handleMethodCall", "(", "string", "$", "method", ",", "array", "$", "arguments", ",", "bool", "$", "shouldReturnSelf", ")", "{", "$", "invocation", "=", "$", "this", "->", "invocations", "(", "$", "method", ")", "->", "recordCall", ...
handles actual method calls @param string $method actually called method @param mixed[] $arguments list of given arguments for methods @param bool $shouldReturnSelf whether the return value should be the instance itself @return mixed @throws \Exception
[ "handles", "actual", "method", "calls" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/ClassProxyMethodHandler.php#L79-L99
train
bovigo/callmap
src/main/php/ClassProxyMethodHandler.php
ClassProxyMethodHandler.invocations
public function invocations(string $method): Invocations { if (empty($method)) { throw new \InvalidArgumentException( 'Please provide a method name to retrieve invocations for.' ); } if (!isset($this->_allowedMethods[$method])) { throw new \InvalidArgumentException( $this->canNot('retrieve invocations for', $method) ); } if (!isset($this->invocations[$method])) { $this->invocations[$method] = new Invocations( $this->completeNameOf($method), $this->_methodParams[$method] ); } return $this->invocations[$method]; }
php
public function invocations(string $method): Invocations { if (empty($method)) { throw new \InvalidArgumentException( 'Please provide a method name to retrieve invocations for.' ); } if (!isset($this->_allowedMethods[$method])) { throw new \InvalidArgumentException( $this->canNot('retrieve invocations for', $method) ); } if (!isset($this->invocations[$method])) { $this->invocations[$method] = new Invocations( $this->completeNameOf($method), $this->_methodParams[$method] ); } return $this->invocations[$method]; }
[ "public", "function", "invocations", "(", "string", "$", "method", ")", ":", "Invocations", "{", "if", "(", "empty", "(", "$", "method", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Please provide a method name to retrieve invocations for....
returns recorded invocations for given method @param string $method @return Invocations @throws \InvalidArgumentException in case the method does not exist or is not applicable @since 3.1.0
[ "returns", "recorded", "invocations", "for", "given", "method" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/ClassProxyMethodHandler.php#L109-L131
train
bovigo/callmap
src/main/php/ClassProxyMethodHandler.php
ClassProxyMethodHandler.canNot
private function canNot(string $message, string $invalidMethod): string { if (isset($this->_voidMethods[$invalidMethod])) { $reason = 'is declared as returning void.'; } elseif (method_exists($this, $invalidMethod)) { $reason = 'is not applicable for mapping.'; } else { $reason = 'does not exist. Probably a typo?'; } return sprintf( 'Trying to %s method %s, but it %s', $message, $this->completeNameOf($invalidMethod), $reason ); }
php
private function canNot(string $message, string $invalidMethod): string { if (isset($this->_voidMethods[$invalidMethod])) { $reason = 'is declared as returning void.'; } elseif (method_exists($this, $invalidMethod)) { $reason = 'is not applicable for mapping.'; } else { $reason = 'does not exist. Probably a typo?'; } return sprintf( 'Trying to %s method %s, but it %s', $message, $this->completeNameOf($invalidMethod), $reason ); }
[ "private", "function", "canNot", "(", "string", "$", "message", ",", "string", "$", "invalidMethod", ")", ":", "string", "{", "if", "(", "isset", "(", "$", "this", "->", "_voidMethods", "[", "$", "invalidMethod", "]", ")", ")", "{", "$", "reason", "=",...
creates complete error message that invalid method can not be used @param string $message @param string $invalidMethod
[ "creates", "complete", "error", "message", "that", "invalid", "method", "can", "not", "be", "used" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/ClassProxyMethodHandler.php#L154-L170
train
dshanske/parse-this
includes/class-mf2-post.php
MF2_Post.get_mf2meta
private function get_mf2meta() { $meta = get_post_meta( $this->uid ); if ( ! $meta ) { return array(); } if ( isset( $meta['response'] ) ) { $response = maybe_unserialize( $meta['response'] ); // Retrieve from the old response array and store in new location. if ( ! empty( $response ) ) { $new = array(); // Convert to new format and update. if ( ! empty( $response['title'] ) ) { $new['name'] = $response['title']; } if ( ! empty( $response['url'] ) ) { $new['url'] = $response['url']; } if ( ! empty( $response['content'] ) ) { $new['content'] = $response['content']; } if ( ! empty( $response['published'] ) ) { $new['published'] = $response['published']; } if ( ! empty( $response['author'] ) ) { $new['card'] = array(); $new['card']['name'] = $response['author']; if ( ! empty( $response['icon'] ) ) { $new['card']['photo'] = $response['icon']; } } $new = array_unique( $new ); $new['card'] = array_unique( $new['card'] ); if ( isset( $new ) ) { update_post_meta( $this->uid, 'mf2_cite', $new ); delete_post_meta( $this->uid, 'response' ); $meta['cite'] = $new; } } } foreach ( $meta as $key => $value ) { if ( ! self::str_prefix( $key, 'mf2_' ) ) { unset( $meta[ $key ] ); } else { unset( $meta[ $key ] ); $key = str_replace( 'mf2_', '', $key ); // Do not save microput prefixed instructions if ( self::str_prefix( $key, 'mp-' ) ) { continue; } $value = array_map( 'maybe_unserialize', $value ); if ( 1 === count( $value ) ) { $value = array_shift( $value ); } if ( is_string( $value ) ) { $meta[ $key ] = array( $value ); } else { $meta[ $key ] = $value; } } } return array_filter( $meta ); }
php
private function get_mf2meta() { $meta = get_post_meta( $this->uid ); if ( ! $meta ) { return array(); } if ( isset( $meta['response'] ) ) { $response = maybe_unserialize( $meta['response'] ); // Retrieve from the old response array and store in new location. if ( ! empty( $response ) ) { $new = array(); // Convert to new format and update. if ( ! empty( $response['title'] ) ) { $new['name'] = $response['title']; } if ( ! empty( $response['url'] ) ) { $new['url'] = $response['url']; } if ( ! empty( $response['content'] ) ) { $new['content'] = $response['content']; } if ( ! empty( $response['published'] ) ) { $new['published'] = $response['published']; } if ( ! empty( $response['author'] ) ) { $new['card'] = array(); $new['card']['name'] = $response['author']; if ( ! empty( $response['icon'] ) ) { $new['card']['photo'] = $response['icon']; } } $new = array_unique( $new ); $new['card'] = array_unique( $new['card'] ); if ( isset( $new ) ) { update_post_meta( $this->uid, 'mf2_cite', $new ); delete_post_meta( $this->uid, 'response' ); $meta['cite'] = $new; } } } foreach ( $meta as $key => $value ) { if ( ! self::str_prefix( $key, 'mf2_' ) ) { unset( $meta[ $key ] ); } else { unset( $meta[ $key ] ); $key = str_replace( 'mf2_', '', $key ); // Do not save microput prefixed instructions if ( self::str_prefix( $key, 'mp-' ) ) { continue; } $value = array_map( 'maybe_unserialize', $value ); if ( 1 === count( $value ) ) { $value = array_shift( $value ); } if ( is_string( $value ) ) { $meta[ $key ] = array( $value ); } else { $meta[ $key ] = $value; } } } return array_filter( $meta ); }
[ "private", "function", "get_mf2meta", "(", ")", "{", "$", "meta", "=", "get_post_meta", "(", "$", "this", "->", "uid", ")", ";", "if", "(", "!", "$", "meta", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "meta", ...
Sets an array with only the mf2 prefixed meta.
[ "Sets", "an", "array", "with", "only", "the", "mf2", "prefixed", "meta", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-mf2-post.php#L221-L282
train
dshanske/parse-this
includes/class-mf2-post.php
MF2_Post.fetch
public function fetch( $property ) { // If the property is not set then exit if ( ! $property || ! $this->has_key( $property ) ) { return false; } $return = $this->get( $property ); if ( wp_is_numeric_array( $return ) ) { $return = array_shift( $return ); } // If it is in fact a string it is the pre 2.7.0 format and should be updated if ( is_string( $return ) ) { if ( $this->has_key( 'cite' ) ) { $cite = array_filter( $this->get( 'cite' ) ); $cite['url'] = $return; $this->set( $property, $cite ); $this->delete( 'cite' ); return $cite; } else { return array( 'url' => $return ); } } if ( is_array( $return ) ) { return mf2_to_jf2( $return ); } return false; }
php
public function fetch( $property ) { // If the property is not set then exit if ( ! $property || ! $this->has_key( $property ) ) { return false; } $return = $this->get( $property ); if ( wp_is_numeric_array( $return ) ) { $return = array_shift( $return ); } // If it is in fact a string it is the pre 2.7.0 format and should be updated if ( is_string( $return ) ) { if ( $this->has_key( 'cite' ) ) { $cite = array_filter( $this->get( 'cite' ) ); $cite['url'] = $return; $this->set( $property, $cite ); $this->delete( 'cite' ); return $cite; } else { return array( 'url' => $return ); } } if ( is_array( $return ) ) { return mf2_to_jf2( $return ); } return false; }
[ "public", "function", "fetch", "(", "$", "property", ")", "{", "// If the property is not set then exit", "if", "(", "!", "$", "property", "||", "!", "$", "this", "->", "has_key", "(", "$", "property", ")", ")", "{", "return", "false", ";", "}", "$", "re...
Also will update old posts with new settings
[ "Also", "will", "update", "old", "posts", "with", "new", "settings" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-mf2-post.php#L487-L513
train
GrahamCampbell/Laravel-TestBench-Core
src/LaravelTrait.php
LaravelTrait.assertIsInjectable
public function assertIsInjectable(string $name) { $injectable = true; $message = "The class '$name' couldn't be automatically injected."; try { $class = $this->makeInjectableClass($name); $this->assertInstanceOf($name, $class->getInjectedObject()); } catch (Exception $e) { $injectable = false; if ($msg = $e->getMessage()) { $message .= " $msg"; } } $this->assertTrue($injectable, $message); }
php
public function assertIsInjectable(string $name) { $injectable = true; $message = "The class '$name' couldn't be automatically injected."; try { $class = $this->makeInjectableClass($name); $this->assertInstanceOf($name, $class->getInjectedObject()); } catch (Exception $e) { $injectable = false; if ($msg = $e->getMessage()) { $message .= " $msg"; } } $this->assertTrue($injectable, $message); }
[ "public", "function", "assertIsInjectable", "(", "string", "$", "name", ")", "{", "$", "injectable", "=", "true", ";", "$", "message", "=", "\"The class '$name' couldn't be automatically injected.\"", ";", "try", "{", "$", "class", "=", "$", "this", "->", "makeI...
Assert that a class can be automatically injected. @param string $name @return void
[ "Assert", "that", "a", "class", "can", "be", "automatically", "injected", "." ]
138218735a65f4532d6c4242a44ffa6c591bca09
https://github.com/GrahamCampbell/Laravel-TestBench-Core/blob/138218735a65f4532d6c4242a44ffa6c591bca09/src/LaravelTrait.php#L32-L49
train
dshanske/parse-this
includes/Parser.php
Parser.isElementParsed
private function isElementParsed(\DOMElement $e, $prefix) { if (!$this->parsed->contains($e)) { return false; } $prefixes = $this->parsed[$e]; if (!in_array($prefix, $prefixes)) { return false; } return true; }
php
private function isElementParsed(\DOMElement $e, $prefix) { if (!$this->parsed->contains($e)) { return false; } $prefixes = $this->parsed[$e]; if (!in_array($prefix, $prefixes)) { return false; } return true; }
[ "private", "function", "isElementParsed", "(", "\\", "DOMElement", "$", "e", ",", "$", "prefix", ")", "{", "if", "(", "!", "$", "this", "->", "parsed", "->", "contains", "(", "$", "e", ")", ")", "{", "return", "false", ";", "}", "$", "prefixes", "=...
Determine if the element has already been parsed @param DOMElement $e @param string $prefix @return bool
[ "Determine", "if", "the", "element", "has", "already", "been", "parsed" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L421-L433
train
dshanske/parse-this
includes/Parser.php
Parser.isElementUpgraded
private function isElementUpgraded(\DOMElement $el, $property) { if ( $this->upgraded->contains($el) ) { if ( in_array($property, $this->upgraded[$el]) ) { return true; } } return false; }
php
private function isElementUpgraded(\DOMElement $el, $property) { if ( $this->upgraded->contains($el) ) { if ( in_array($property, $this->upgraded[$el]) ) { return true; } } return false; }
[ "private", "function", "isElementUpgraded", "(", "\\", "DOMElement", "$", "el", ",", "$", "property", ")", "{", "if", "(", "$", "this", "->", "upgraded", "->", "contains", "(", "$", "el", ")", ")", "{", "if", "(", "in_array", "(", "$", "property", ",...
Determine if the element's specified property has already been upgraded during backcompat @param DOMElement $el @param string $property @return bool
[ "Determine", "if", "the", "element", "s", "specified", "property", "has", "already", "been", "upgraded", "during", "backcompat" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L441-L449
train
dshanske/parse-this
includes/Parser.php
Parser.textContent
public function textContent(DOMElement $element, $implied=false) { return preg_replace( '/(^[\t\n\f\r ]+| +(?=\n)|(?<=\n) +| +(?= )|[\t\n\f\r ]+$)/', '', $this->elementToString($element, $implied) ); }
php
public function textContent(DOMElement $element, $implied=false) { return preg_replace( '/(^[\t\n\f\r ]+| +(?=\n)|(?<=\n) +| +(?= )|[\t\n\f\r ]+$)/', '', $this->elementToString($element, $implied) ); }
[ "public", "function", "textContent", "(", "DOMElement", "$", "element", ",", "$", "implied", "=", "false", ")", "{", "return", "preg_replace", "(", "'/(^[\\t\\n\\f\\r ]+| +(?=\\n)|(?<=\\n) +| +(?= )|[\\t\\n\\f\\r ]+$)/'", ",", "''", ",", "$", "this", "->", "elementToS...
The following two methods implements plain text parsing. @param DOMElement $element @param bool $implied @see https://wiki.zegnat.net/media/textparsing.html
[ "The", "following", "two", "methods", "implements", "plain", "text", "parsing", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L472-L479
train
dshanske/parse-this
includes/Parser.php
Parser.language
public function language(DOMElement $el) { // element has a lang attribute; use it if ($el->hasAttribute('lang')) { return unicodeTrim($el->getAttribute('lang')); } if ($el->tagName == 'html') { // we're at the <html> element and no lang; check <meta> http-equiv Content-Language foreach ( $this->xpath->query('.//meta[@http-equiv]') as $node ) { if ($node->hasAttribute('http-equiv') && $node->hasAttribute('content') && strtolower($node->getAttribute('http-equiv')) == 'content-language') { return unicodeTrim($node->getAttribute('content')); } } } elseif ($el->parentNode instanceof DOMElement) { // check the parent node return $this->language($el->parentNode); } return ''; }
php
public function language(DOMElement $el) { // element has a lang attribute; use it if ($el->hasAttribute('lang')) { return unicodeTrim($el->getAttribute('lang')); } if ($el->tagName == 'html') { // we're at the <html> element and no lang; check <meta> http-equiv Content-Language foreach ( $this->xpath->query('.//meta[@http-equiv]') as $node ) { if ($node->hasAttribute('http-equiv') && $node->hasAttribute('content') && strtolower($node->getAttribute('http-equiv')) == 'content-language') { return unicodeTrim($node->getAttribute('content')); } } } elseif ($el->parentNode instanceof DOMElement) { // check the parent node return $this->language($el->parentNode); } return ''; }
[ "public", "function", "language", "(", "DOMElement", "$", "el", ")", "{", "// element has a lang attribute; use it", "if", "(", "$", "el", "->", "hasAttribute", "(", "'lang'", ")", ")", "{", "return", "unicodeTrim", "(", "$", "el", "->", "getAttribute", "(", ...
This method parses the language of an element @param DOMElement $el @access public @return string
[ "This", "method", "parses", "the", "language", "of", "an", "element" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L514-L535
train
dshanske/parse-this
includes/Parser.php
Parser.parseE
public function parseE(\DOMElement $e) { $classTitle = $this->parseValueClassTitle($e); if ($classTitle !== null) return $classTitle; // Expand relative URLs within children of this element // TODO: as it is this is not relative to only children, make this .// and rerun tests $this->resolveChildUrls($e); // Temporarily move all descendants into a separate DocumentFragment. // This way we can DOMDocument::saveHTML on the entire collection at once. // Running DOMDocument::saveHTML per node may add whitespace that isn't in source. // See https://stackoverflow.com/q/38317903 $innerNodes = $e->ownerDocument->createDocumentFragment(); while ($e->hasChildNodes()) { $innerNodes->appendChild($e->firstChild); } $html = $e->ownerDocument->saveHtml($innerNodes); // Put the nodes back in place. if($innerNodes->hasChildNodes()) { $e->appendChild($innerNodes); } $return = array( 'html' => unicodeTrim($html), 'value' => $this->textContent($e), ); if($this->lang) { // Language if ( $html_lang = $this->language($e) ) { $return['lang'] = $html_lang; } } return $return; }
php
public function parseE(\DOMElement $e) { $classTitle = $this->parseValueClassTitle($e); if ($classTitle !== null) return $classTitle; // Expand relative URLs within children of this element // TODO: as it is this is not relative to only children, make this .// and rerun tests $this->resolveChildUrls($e); // Temporarily move all descendants into a separate DocumentFragment. // This way we can DOMDocument::saveHTML on the entire collection at once. // Running DOMDocument::saveHTML per node may add whitespace that isn't in source. // See https://stackoverflow.com/q/38317903 $innerNodes = $e->ownerDocument->createDocumentFragment(); while ($e->hasChildNodes()) { $innerNodes->appendChild($e->firstChild); } $html = $e->ownerDocument->saveHtml($innerNodes); // Put the nodes back in place. if($innerNodes->hasChildNodes()) { $e->appendChild($innerNodes); } $return = array( 'html' => unicodeTrim($html), 'value' => $this->textContent($e), ); if($this->lang) { // Language if ( $html_lang = $this->language($e) ) { $return['lang'] = $html_lang; } } return $return; }
[ "public", "function", "parseE", "(", "\\", "DOMElement", "$", "e", ")", "{", "$", "classTitle", "=", "$", "this", "->", "parseValueClassTitle", "(", "$", "e", ")", ";", "if", "(", "$", "classTitle", "!==", "null", ")", "return", "$", "classTitle", ";",...
Given the root element of some embedded markup, return a string representing that markup @param DOMElement $e The element to parse @return string $e’s innerHTML @todo need to mark this element as e- parsed so it doesn’t get parsed as it’s parent’s e-* too
[ "Given", "the", "root", "element", "of", "some", "embedded", "markup", "return", "a", "string", "representing", "that", "markup" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L861-L898
train
dshanske/parse-this
includes/Parser.php
Parser.parse
public function parse($convertClassic = true, DOMElement $context = null) { $this->convertClassic = $convertClassic; $mfs = $this->parse_recursive($context); // Parse rels list($rels, $rel_urls, $alternates) = $this->parseRelsAndAlternates(); $top = array( 'items' => array_values(array_filter($mfs)), 'rels' => $rels, 'rel-urls' => $rel_urls, ); if ($this->enableAlternates && count($alternates)) { $top['alternates'] = $alternates; } return $top; }
php
public function parse($convertClassic = true, DOMElement $context = null) { $this->convertClassic = $convertClassic; $mfs = $this->parse_recursive($context); // Parse rels list($rels, $rel_urls, $alternates) = $this->parseRelsAndAlternates(); $top = array( 'items' => array_values(array_filter($mfs)), 'rels' => $rels, 'rel-urls' => $rel_urls, ); if ($this->enableAlternates && count($alternates)) { $top['alternates'] = $alternates; } return $top; }
[ "public", "function", "parse", "(", "$", "convertClassic", "=", "true", ",", "DOMElement", "$", "context", "=", "null", ")", "{", "$", "this", "->", "convertClassic", "=", "$", "convertClassic", ";", "$", "mfs", "=", "$", "this", "->", "parse_recursive", ...
Kicks off the parsing routine @param bool $convertClassic whether to do backcompat parsing on microformats1. Defaults to true. @param DOMElement $context optionally specify an element from which to parse microformats @return array An array containing all the microformats found in the current document
[ "Kicks", "off", "the", "parsing", "routine" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L1349-L1367
train
dshanske/parse-this
includes/Parser.php
Parser.parseFromId
public function parseFromId($id, $convertClassic=true) { $matches = $this->xpath->query("//*[@id='{$id}']"); if (empty($matches)) return array('items' => array(), 'rels' => array(), 'alternates' => array()); return $this->parse($convertClassic, $matches->item(0)); }
php
public function parseFromId($id, $convertClassic=true) { $matches = $this->xpath->query("//*[@id='{$id}']"); if (empty($matches)) return array('items' => array(), 'rels' => array(), 'alternates' => array()); return $this->parse($convertClassic, $matches->item(0)); }
[ "public", "function", "parseFromId", "(", "$", "id", ",", "$", "convertClassic", "=", "true", ")", "{", "$", "matches", "=", "$", "this", "->", "xpath", "->", "query", "(", "\"//*[@id='{$id}']\"", ")", ";", "if", "(", "empty", "(", "$", "matches", ")",...
Parse From ID Given an ID, parse all microformats which are children of the element with that ID. Note that rel values are still document-wide. If an element with the ID is not found, an empty skeleton mf2 array structure will be returned. @param string $id @param bool $htmlSafe = false whether or not to HTML-encode angle brackets in non e-* properties @return array
[ "Parse", "From", "ID" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L1467-L1474
train
dshanske/parse-this
includes/Parser.php
Parser.getRootMF
public function getRootMF(DOMElement $context = null) { // start with mf2 root class name xpath $xpaths = array( 'contains(concat(" ",normalize-space(@class)), " h-")' ); // add mf1 root class names foreach ( $this->classicRootMap as $old => $new ) { $xpaths[] = '( contains(concat(" ",normalize-space(@class), " "), " ' . $old . ' ") )'; } // final xpath with OR $xpath = '//*[' . implode(' or ', $xpaths) . ']'; $mfElements = (null === $context) ? $this->xpath->query($xpath) : $this->xpath->query('.' . $xpath, $context); return $mfElements; }
php
public function getRootMF(DOMElement $context = null) { // start with mf2 root class name xpath $xpaths = array( 'contains(concat(" ",normalize-space(@class)), " h-")' ); // add mf1 root class names foreach ( $this->classicRootMap as $old => $new ) { $xpaths[] = '( contains(concat(" ",normalize-space(@class), " "), " ' . $old . ' ") )'; } // final xpath with OR $xpath = '//*[' . implode(' or ', $xpaths) . ']'; $mfElements = (null === $context) ? $this->xpath->query($xpath) : $this->xpath->query('.' . $xpath, $context); return $mfElements; }
[ "public", "function", "getRootMF", "(", "DOMElement", "$", "context", "=", "null", ")", "{", "// start with mf2 root class name xpath", "$", "xpaths", "=", "array", "(", "'contains(concat(\" \",normalize-space(@class)), \" h-\")'", ")", ";", "// add mf1 root class names", "...
Get the root microformat elements @param DOMElement $context @return DOMNodeList
[ "Get", "the", "root", "microformat", "elements" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L1481-L1500
train
dshanske/parse-this
includes/Parser.php
Parser.addUpgraded
public function addUpgraded(DOMElement $el, $property) { if ( !is_array($property) ) { $property = array($property); } // add element to list of upgraded elements if ( !$this->upgraded->contains($el) ) { $this->upgraded->attach($el, $property); } else { $this->upgraded[$el] = array_merge($this->upgraded[$el], $property); } }
php
public function addUpgraded(DOMElement $el, $property) { if ( !is_array($property) ) { $property = array($property); } // add element to list of upgraded elements if ( !$this->upgraded->contains($el) ) { $this->upgraded->attach($el, $property); } else { $this->upgraded[$el] = array_merge($this->upgraded[$el], $property); } }
[ "public", "function", "addUpgraded", "(", "DOMElement", "$", "el", ",", "$", "property", ")", "{", "if", "(", "!", "is_array", "(", "$", "property", ")", ")", "{", "$", "property", "=", "array", "(", "$", "property", ")", ";", "}", "// add element to l...
Add element + property as upgraded during backcompat @param DOMElement $el @param string|array $property
[ "Add", "element", "+", "property", "as", "upgraded", "during", "backcompat" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L1629-L1640
train
dshanske/parse-this
includes/Parser.php
Parser.addMfClasses
public function addMfClasses(DOMElement $el, $classes) { $existingClasses = str_replace(array("\t", "\n"), ' ', $el->getAttribute('class')); $existingClasses = array_filter(explode(' ', $existingClasses)); $addClasses = array_diff(explode(' ', $classes), $existingClasses); if ( $addClasses ) { $el->setAttribute('class', $el->getAttribute('class') . ' ' . implode(' ', $addClasses)); } }
php
public function addMfClasses(DOMElement $el, $classes) { $existingClasses = str_replace(array("\t", "\n"), ' ', $el->getAttribute('class')); $existingClasses = array_filter(explode(' ', $existingClasses)); $addClasses = array_diff(explode(' ', $classes), $existingClasses); if ( $addClasses ) { $el->setAttribute('class', $el->getAttribute('class') . ' ' . implode(' ', $addClasses)); } }
[ "public", "function", "addMfClasses", "(", "DOMElement", "$", "el", ",", "$", "classes", ")", "{", "$", "existingClasses", "=", "str_replace", "(", "array", "(", "\"\\t\"", ",", "\"\\n\"", ")", ",", "' '", ",", "$", "el", "->", "getAttribute", "(", "'cla...
Add the provided classes to an element. Does not add duplicate if class name already exists. @param DOMElement $el @param string $classes
[ "Add", "the", "provided", "classes", "to", "an", "element", ".", "Does", "not", "add", "duplicate", "if", "class", "name", "already", "exists", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L1648-L1657
train
dshanske/parse-this
includes/Parser.php
Parser.convertLegacy
public function convertLegacy() { $doc = $this->doc; $xp = new DOMXPath($doc); // replace all roots foreach ($this->classicRootMap as $old => $new) { foreach ($xp->query('//*[contains(concat(" ", @class, " "), " ' . $old . ' ") and not(contains(concat(" ", @class, " "), " ' . $new . ' "))]') as $el) { $el->setAttribute('class', $el->getAttribute('class') . ' ' . $new); } } foreach ($this->classicPropertyMap as $oldRoot => $properties) { $newRoot = $this->classicRootMap[$oldRoot]; foreach ($properties as $old => $data) { foreach ($xp->query('//*[contains(concat(" ", @class, " "), " ' . $oldRoot . ' ")]//*[contains(concat(" ", @class, " "), " ' . $old . ' ") and not(contains(concat(" ", @class, " "), " ' . $data['replace'] . ' "))]') as $el) { $el->setAttribute('class', $el->getAttribute('class') . ' ' . $data['replace']); } } } return $this; }
php
public function convertLegacy() { $doc = $this->doc; $xp = new DOMXPath($doc); // replace all roots foreach ($this->classicRootMap as $old => $new) { foreach ($xp->query('//*[contains(concat(" ", @class, " "), " ' . $old . ' ") and not(contains(concat(" ", @class, " "), " ' . $new . ' "))]') as $el) { $el->setAttribute('class', $el->getAttribute('class') . ' ' . $new); } } foreach ($this->classicPropertyMap as $oldRoot => $properties) { $newRoot = $this->classicRootMap[$oldRoot]; foreach ($properties as $old => $data) { foreach ($xp->query('//*[contains(concat(" ", @class, " "), " ' . $oldRoot . ' ")]//*[contains(concat(" ", @class, " "), " ' . $old . ' ") and not(contains(concat(" ", @class, " "), " ' . $data['replace'] . ' "))]') as $el) { $el->setAttribute('class', $el->getAttribute('class') . ' ' . $data['replace']); } } } return $this; }
[ "public", "function", "convertLegacy", "(", ")", "{", "$", "doc", "=", "$", "this", "->", "doc", ";", "$", "xp", "=", "new", "DOMXPath", "(", "$", "doc", ")", ";", "// replace all roots", "foreach", "(", "$", "this", "->", "classicRootMap", "as", "$", ...
Convert Legacy Classnames Adds microformats2 classnames into a document containing only legacy semantic classnames. @return Parser $this
[ "Convert", "Legacy", "Classnames" ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/Parser.php#L1684-L1705
train
QuickenLoans/mcp-logger
src/FilterLogger.php
FilterLogger.setLevel
public function setLevel($level) { if (!array_key_exists($level, self::LEVEL_PRIORITIES)) { throw new Exception(self::ERR_INVALID_LEVEL); } $lowestPriority = self::LEVEL_PRIORITIES[$level]; $accepted = []; foreach (self::LEVEL_PRIORITIES as $level => $priority) { if ($priority > $lowestPriority) { continue; } $accepted[] = $level; } $this->acceptedLevels = $accepted; }
php
public function setLevel($level) { if (!array_key_exists($level, self::LEVEL_PRIORITIES)) { throw new Exception(self::ERR_INVALID_LEVEL); } $lowestPriority = self::LEVEL_PRIORITIES[$level]; $accepted = []; foreach (self::LEVEL_PRIORITIES as $level => $priority) { if ($priority > $lowestPriority) { continue; } $accepted[] = $level; } $this->acceptedLevels = $accepted; }
[ "public", "function", "setLevel", "(", "$", "level", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "level", ",", "self", "::", "LEVEL_PRIORITIES", ")", ")", "{", "throw", "new", "Exception", "(", "self", "::", "ERR_INVALID_LEVEL", ")", ";", "}"...
Set the lowest priority log level. When setting this value, ensure it is a valid level as defined in `Psr\Log\LogLevel`. @param string $level @throws Exception @return void
[ "Set", "the", "lowest", "priority", "log", "level", "." ]
ec0960fc32de1a4c583b2447b99d0ef8c801f1ae
https://github.com/QuickenLoans/mcp-logger/blob/ec0960fc32de1a4c583b2447b99d0ef8c801f1ae/src/FilterLogger.php#L92-L110
train
dshanske/parse-this
includes/class-parse-this-html.php
Parse_This_HTML.limit_string
private static function limit_string( $value ) { $return = ''; if ( is_numeric( $value ) || is_bool( $value ) ) { $return = $value; } elseif ( is_string( $value ) ) { if ( mb_strlen( $value ) > 5000 ) { $return = mb_substr( $value, 0, 5000 ); } else { $return = $value; } // $return = html_entity_decode( $return, ENT_QUOTES, 'UTF-8' ); $return = sanitize_text_field( trim( $return ) ); } return $return; }
php
private static function limit_string( $value ) { $return = ''; if ( is_numeric( $value ) || is_bool( $value ) ) { $return = $value; } elseif ( is_string( $value ) ) { if ( mb_strlen( $value ) > 5000 ) { $return = mb_substr( $value, 0, 5000 ); } else { $return = $value; } // $return = html_entity_decode( $return, ENT_QUOTES, 'UTF-8' ); $return = sanitize_text_field( trim( $return ) ); } return $return; }
[ "private", "static", "function", "limit_string", "(", "$", "value", ")", "{", "$", "return", "=", "''", ";", "if", "(", "is_numeric", "(", "$", "value", ")", "||", "is_bool", "(", "$", "value", ")", ")", "{", "$", "return", "=", "$", "value", ";", ...
Utility method to limit the length of a given string to 5,000 characters. @ignore @since 4.2.0 @param string $value String to limit. @return bool|int|string If boolean or integer, that value. If a string, the original value if fewer than 5,000 characters, a truncated version, otherwise an empty string.
[ "Utility", "method", "to", "limit", "the", "length", "of", "a", "given", "string", "to", "5", "000", "characters", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-html.php#L41-L58
train
dshanske/parse-this
includes/class-parse-this-html.php
Parse_This_HTML.limit_url
private static function limit_url( $url, $source_url ) { if ( ! is_string( $url ) ) { return ''; } // HTTP 1.1 allows 8000 chars but the "de-facto" standard supported in all current browsers is 2048. if ( strlen( $url ) > 2048 ) { return ''; // Return empty rather than a truncated/invalid URL } // Does not look like a URL. if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) { return ''; } $url = WP_Http::make_absolute_url( $url, $source_url ); return esc_url_raw( $url, array( 'http', 'https' ) ); }
php
private static function limit_url( $url, $source_url ) { if ( ! is_string( $url ) ) { return ''; } // HTTP 1.1 allows 8000 chars but the "de-facto" standard supported in all current browsers is 2048. if ( strlen( $url ) > 2048 ) { return ''; // Return empty rather than a truncated/invalid URL } // Does not look like a URL. if ( ! filter_var( $url, FILTER_VALIDATE_URL ) ) { return ''; } $url = WP_Http::make_absolute_url( $url, $source_url ); return esc_url_raw( $url, array( 'http', 'https' ) ); }
[ "private", "static", "function", "limit_url", "(", "$", "url", ",", "$", "source_url", ")", "{", "if", "(", "!", "is_string", "(", "$", "url", ")", ")", "{", "return", "''", ";", "}", "// HTTP 1.1 allows 8000 chars but the \"de-facto\" standard supported in all cu...
Utility method to limit a given URL to 2,048 characters. @ignore @since 4.2.0 @param string $url URL to check for length and validity. @param string $source_url URL URL to use to resolve relative URLs @return string Escaped URL if of valid length (< 2048) and makeup. Empty string otherwise.
[ "Utility", "method", "to", "limit", "a", "given", "URL", "to", "2", "048", "characters", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-html.php#L70-L88
train
dshanske/parse-this
includes/class-parse-this-html.php
Parse_This_HTML.limit_img
private static function limit_img( $src, $source_url ) { $src = self::limit_url( $src, $source_url ); if ( preg_match( '!/ad[sx]?/!i', $src ) ) { // Ads return ''; } elseif ( preg_match( '!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src ) ) { // Share-this type button return ''; } elseif ( preg_match( '!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src ) ) { // Loaders, spinners, spacers return ''; } elseif ( preg_match( '!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src ) ) { // Fancy loaders, spinners, spacers return ''; } elseif ( preg_match( '!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src ) ) { // Thumbnails, too small, usually irrelevant to context return ''; } elseif ( false !== stripos( $src, '/wp-includes/' ) ) { // Classic WordPress interface images return ''; } elseif ( false !== stripos( $src, '/wp-content/themes' ) ) { // Anything within a WordPress theme directory return ''; } elseif ( false !== stripos( $src, '/wp-content/plugins' ) ) { // Anything within a WordPress plugin directory return ''; } elseif ( preg_match( '![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src ) ) { // Most often tiny buttons/thumbs (< 100px wide) return ''; } elseif ( preg_match( '!/pixel\.(mathtag|quantserve)\.com!i', $src ) ) { // See mathtag.com and https://www.quantcast.com/how-we-do-it/iab-standard-measurement/how-we-collect-data/ return ''; } elseif ( preg_match( '!/[gb]\.gif(\?.+)?$!i', $src ) ) { // WordPress.com stats gif return ''; } // Optionally add additional limits return apply_filters( 'parse_this_img_filters', $src ); }
php
private static function limit_img( $src, $source_url ) { $src = self::limit_url( $src, $source_url ); if ( preg_match( '!/ad[sx]?/!i', $src ) ) { // Ads return ''; } elseif ( preg_match( '!(/share-?this[^.]+?\.[a-z0-9]{3,4})(\?.*)?$!i', $src ) ) { // Share-this type button return ''; } elseif ( preg_match( '!/(spinner|loading|spacer|blank|rss)\.(gif|jpg|png)!i', $src ) ) { // Loaders, spinners, spacers return ''; } elseif ( preg_match( '!/([^./]+[-_])?(spinner|loading|spacer|blank)s?([-_][^./]+)?\.[a-z0-9]{3,4}!i', $src ) ) { // Fancy loaders, spinners, spacers return ''; } elseif ( preg_match( '!([^./]+[-_])?thumb[^.]*\.(gif|jpg|png)$!i', $src ) ) { // Thumbnails, too small, usually irrelevant to context return ''; } elseif ( false !== stripos( $src, '/wp-includes/' ) ) { // Classic WordPress interface images return ''; } elseif ( false !== stripos( $src, '/wp-content/themes' ) ) { // Anything within a WordPress theme directory return ''; } elseif ( false !== stripos( $src, '/wp-content/plugins' ) ) { // Anything within a WordPress plugin directory return ''; } elseif ( preg_match( '![^\d]\d{1,2}x\d+\.(gif|jpg|png)$!i', $src ) ) { // Most often tiny buttons/thumbs (< 100px wide) return ''; } elseif ( preg_match( '!/pixel\.(mathtag|quantserve)\.com!i', $src ) ) { // See mathtag.com and https://www.quantcast.com/how-we-do-it/iab-standard-measurement/how-we-collect-data/ return ''; } elseif ( preg_match( '!/[gb]\.gif(\?.+)?$!i', $src ) ) { // WordPress.com stats gif return ''; } // Optionally add additional limits return apply_filters( 'parse_this_img_filters', $src ); }
[ "private", "static", "function", "limit_img", "(", "$", "src", ",", "$", "source_url", ")", "{", "$", "src", "=", "self", "::", "limit_url", "(", "$", "src", ",", "$", "source_url", ")", ";", "if", "(", "preg_match", "(", "'!/ad[sx]?/!i'", ",", "$", ...
Utility method to limit image source URLs. Excluded URLs include share-this type buttons, loaders, spinners, spacers, WordPress interface images, tiny buttons or thumbs, mathtag.com or quantserve.com images, or the WordPress.com stats gif. @param string $src Image source URL. @return string If not matched an excluded URL type, the original URL, empty string otherwise.
[ "Utility", "method", "to", "limit", "image", "source", "URLs", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-html.php#L100-L139
train
dshanske/parse-this
includes/class-parse-this-html.php
Parse_This_HTML.limit_embed
private static function limit_embed( $src, $source_url ) { $src = self::limit_url( $src, $source_url ); if ( empty( $src ) ) { return ''; } if ( preg_match( '!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches ) ) { // Embedded Youtube videos (www or mobile) $src = 'https://www.youtube.com/watch?v=' . $src_matches[3]; } elseif ( preg_match( '!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches ) ) { // Embedded Vimeo iframe videos $src = 'https://vimeo.com/' . (int) $src_matches[1]; } elseif ( preg_match( '!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches ) ) { // Embedded Vimeo Flash videos $src = 'https://vimeo.com/' . (int) $src_matches[1]; } elseif ( preg_match( '!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches ) ) { // Embedded Vine videos $src = 'https://vine.co/v/' . $src_matches[1]; } elseif ( preg_match( '!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches ) ) { // Embedded Daily Motion videos $src = 'https://www.dailymotion.com/video/' . $src_matches[2]; } else { $oembed = _wp_oembed_get_object(); if ( ! $oembed->get_provider( $src, array( 'discover' => false, ) ) ) { $src = ''; } } return $src; }
php
private static function limit_embed( $src, $source_url ) { $src = self::limit_url( $src, $source_url ); if ( empty( $src ) ) { return ''; } if ( preg_match( '!//(m|www)\.youtube\.com/(embed|v)/([^?]+)\?.+$!i', $src, $src_matches ) ) { // Embedded Youtube videos (www or mobile) $src = 'https://www.youtube.com/watch?v=' . $src_matches[3]; } elseif ( preg_match( '!//player\.vimeo\.com/video/([\d]+)([?/].*)?$!i', $src, $src_matches ) ) { // Embedded Vimeo iframe videos $src = 'https://vimeo.com/' . (int) $src_matches[1]; } elseif ( preg_match( '!//vimeo\.com/moogaloop\.swf\?clip_id=([\d]+)$!i', $src, $src_matches ) ) { // Embedded Vimeo Flash videos $src = 'https://vimeo.com/' . (int) $src_matches[1]; } elseif ( preg_match( '!//vine\.co/v/([^/]+)/embed!i', $src, $src_matches ) ) { // Embedded Vine videos $src = 'https://vine.co/v/' . $src_matches[1]; } elseif ( preg_match( '!//(www\.)?dailymotion\.com/embed/video/([^/?]+)([/?].+)?!i', $src, $src_matches ) ) { // Embedded Daily Motion videos $src = 'https://www.dailymotion.com/video/' . $src_matches[2]; } else { $oembed = _wp_oembed_get_object(); if ( ! $oembed->get_provider( $src, array( 'discover' => false, ) ) ) { $src = ''; } } return $src; }
[ "private", "static", "function", "limit_embed", "(", "$", "src", ",", "$", "source_url", ")", "{", "$", "src", "=", "self", "::", "limit_url", "(", "$", "src", ",", "$", "source_url", ")", ";", "if", "(", "empty", "(", "$", "src", ")", ")", "{", ...
Limit embed source URLs to specific providers. Not all core oEmbed providers are supported. Supported providers include YouTube, Vimeo, Vine, Daily Motion, SoundCloud, and Twitter. @param string $src Embed source URL. @param string $source_url Source URL @return string If not from a supported provider, an empty string. Otherwise, a reformatted embed URL.
[ "Limit", "embed", "source", "URLs", "to", "specific", "providers", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this-html.php#L152-L188
train
QuickenLoans/mcp-cache
src/Utility/StampedeProtectionTrait.php
StampedeProtectionTrait.setPrecomputeBeta
public function setPrecomputeBeta($beta) { if (!is_int($beta) || $beta < 1 || $beta > 10) { throw new Exception('Invalid beta specified. An integer between 1 and 10 is required.'); } $this->precomputeBeta = $beta; }
php
public function setPrecomputeBeta($beta) { if (!is_int($beta) || $beta < 1 || $beta > 10) { throw new Exception('Invalid beta specified. An integer between 1 and 10 is required.'); } $this->precomputeBeta = $beta; }
[ "public", "function", "setPrecomputeBeta", "(", "$", "beta", ")", "{", "if", "(", "!", "is_int", "(", "$", "beta", ")", "||", "$", "beta", "<", "1", "||", "$", "beta", ">", "10", ")", "{", "throw", "new", "Exception", "(", "'Invalid beta specified. An ...
Set the beta - early expiration scale. This affects the probability of early expiration. Default is 4, Set to any value from 1 to 10 to increase the chance of early expiration. @return void
[ "Set", "the", "beta", "-", "early", "expiration", "scale", "." ]
2dba32705f85452cb9099e35e0241a6c7a98b717
https://github.com/QuickenLoans/mcp-cache/blob/2dba32705f85452cb9099e35e0241a6c7a98b717/src/Utility/StampedeProtectionTrait.php#L70-L77
train
QuickenLoans/mcp-cache
src/Utility/StampedeProtectionTrait.php
StampedeProtectionTrait.setPrecomputeDelta
public function setPrecomputeDelta($delta) { if (!is_int($delta) || $delta < 1 || $delta > 100) { throw new Exception('Invalid delta specified. An integer between 1 and 100 is required.'); } $this->precomputeDelta = $delta; }
php
public function setPrecomputeDelta($delta) { if (!is_int($delta) || $delta < 1 || $delta > 100) { throw new Exception('Invalid delta specified. An integer between 1 and 100 is required.'); } $this->precomputeDelta = $delta; }
[ "public", "function", "setPrecomputeDelta", "(", "$", "delta", ")", "{", "if", "(", "!", "is_int", "(", "$", "delta", ")", "||", "$", "delta", "<", "1", "||", "$", "delta", ">", "100", ")", "{", "throw", "new", "Exception", "(", "'Invalid delta specifi...
Set the delta - percentage of TTL at which data should have a change to expire. Default is 10%, set to higher to increase the time of early expiration. @return void
[ "Set", "the", "delta", "-", "percentage", "of", "TTL", "at", "which", "data", "should", "have", "a", "change", "to", "expire", "." ]
2dba32705f85452cb9099e35e0241a6c7a98b717
https://github.com/QuickenLoans/mcp-cache/blob/2dba32705f85452cb9099e35e0241a6c7a98b717/src/Utility/StampedeProtectionTrait.php#L86-L93
train
QuickenLoans/mcp-cache
src/PredisCache.php
PredisCache.get
public function get($key) { $key = $this->salted($key, $this->suffix); $raw = $this->predis->get($key); // every response should be a php serialized string. // values not matching this pattern will explode. // missing data should return null, which is not unserialized. if (is_string($raw)) { return unserialize($raw); } return $raw; }
php
public function get($key) { $key = $this->salted($key, $this->suffix); $raw = $this->predis->get($key); // every response should be a php serialized string. // values not matching this pattern will explode. // missing data should return null, which is not unserialized. if (is_string($raw)) { return unserialize($raw); } return $raw; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "key", "=", "$", "this", "->", "salted", "(", "$", "key", ",", "$", "this", "->", "suffix", ")", ";", "$", "raw", "=", "$", "this", "->", "predis", "->", "get", "(", "$", "key", ")"...
This cacher performs serialization and unserialization. All string responses from redis will be unserialized. For this reason, only mcp cachers should attempt to retrieve data cached by mcp cachers. {@inheritdoc}
[ "This", "cacher", "performs", "serialization", "and", "unserialization", ".", "All", "string", "responses", "from", "redis", "will", "be", "unserialized", "." ]
2dba32705f85452cb9099e35e0241a6c7a98b717
https://github.com/QuickenLoans/mcp-cache/blob/2dba32705f85452cb9099e35e0241a6c7a98b717/src/PredisCache.php#L58-L73
train
bovigo/callmap
src/main/php/FunctionProxy.php
FunctionProxy.returns
public function returns($returnValue): self { if ($this->returnVoid) { throw new \LogicException( 'Trying to map function ' . $this->name . '(), but it is declared as returning void.' ); } $this->callMap = new CallMap(['function' => $returnValue]); return $this; }
php
public function returns($returnValue): self { if ($this->returnVoid) { throw new \LogicException( 'Trying to map function ' . $this->name . '(), but it is declared as returning void.' ); } $this->callMap = new CallMap(['function' => $returnValue]); return $this; }
[ "public", "function", "returns", "(", "$", "returnValue", ")", ":", "self", "{", "if", "(", "$", "this", "->", "returnVoid", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Trying to map function '", ".", "$", "this", "->", "name", ".", "'(), but ...
sets the call map to use @api @param mixed $returnValue @return $this @throws \LogicException when mapped function is declared as returning void @since 3.2.0
[ "sets", "the", "call", "map", "to", "use" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/FunctionProxy.php#L70-L81
train
bovigo/callmap
src/main/php/FunctionProxy.php
FunctionProxy.handleFunctionCall
protected function handleFunctionCall(array $arguments) { $invocation = $this->invocations->recordCall($arguments); if (null !== $this->callMap && $this->callMap->hasResultFor('function', $invocation)) { return $this->callMap->resultFor('function', $arguments, $invocation); } if ($this->parentCallsAllowed) { $originalFunction = $this->invocations->name(); return $originalFunction(...$arguments); } return null; }
php
protected function handleFunctionCall(array $arguments) { $invocation = $this->invocations->recordCall($arguments); if (null !== $this->callMap && $this->callMap->hasResultFor('function', $invocation)) { return $this->callMap->resultFor('function', $arguments, $invocation); } if ($this->parentCallsAllowed) { $originalFunction = $this->invocations->name(); return $originalFunction(...$arguments); } return null; }
[ "protected", "function", "handleFunctionCall", "(", "array", "$", "arguments", ")", "{", "$", "invocation", "=", "$", "this", "->", "invocations", "->", "recordCall", "(", "$", "arguments", ")", ";", "if", "(", "null", "!==", "$", "this", "->", "callMap", ...
handles actual function calls @param mixed[] $arguments list of given arguments for function @return mixed
[ "handles", "actual", "function", "calls" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/FunctionProxy.php#L103-L116
train
QuickenLoans/mcp-cache
src/Utility/KeySaltingTrait.php
KeySaltingTrait.salted
private function salted($key, $suffix = null) { $delimiter = ':'; if (defined('static::DELIMITER')) { $delimiter = static::DELIMITER; } if (defined('static::PREFIX')) { $key = sprintf('%s%s%s', static::PREFIX, $delimiter, $key); } if ($suffix) { return sprintf('%s%s%s', $key, $delimiter, $suffix); } return $key; }
php
private function salted($key, $suffix = null) { $delimiter = ':'; if (defined('static::DELIMITER')) { $delimiter = static::DELIMITER; } if (defined('static::PREFIX')) { $key = sprintf('%s%s%s', static::PREFIX, $delimiter, $key); } if ($suffix) { return sprintf('%s%s%s', $key, $delimiter, $suffix); } return $key; }
[ "private", "function", "salted", "(", "$", "key", ",", "$", "suffix", "=", "null", ")", "{", "$", "delimiter", "=", "':'", ";", "if", "(", "defined", "(", "'static::DELIMITER'", ")", ")", "{", "$", "delimiter", "=", "static", "::", "DELIMITER", ";", ...
Salt the cache key if a salt is provided. @param string $key @param string|null $suffix @return string
[ "Salt", "the", "cache", "key", "if", "a", "salt", "is", "provided", "." ]
2dba32705f85452cb9099e35e0241a6c7a98b717
https://github.com/QuickenLoans/mcp-cache/blob/2dba32705f85452cb9099e35e0241a6c7a98b717/src/Utility/KeySaltingTrait.php#L26-L42
train
Werkspot/message-bus
src/Bus/DeliveryChain/Middleware/LockingMiddleware.php
LockingMiddleware.enqueue
private function enqueue(MessageInterface $message, callable $next): void { $this->queue[] = function () use ($message, $next): void { $next($message); }; }
php
private function enqueue(MessageInterface $message, callable $next): void { $this->queue[] = function () use ($message, $next): void { $next($message); }; }
[ "private", "function", "enqueue", "(", "MessageInterface", "$", "message", ",", "callable", "$", "next", ")", ":", "void", "{", "$", "this", "->", "queue", "[", "]", "=", "function", "(", ")", "use", "(", "$", "message", ",", "$", "next", ")", ":", ...
Queues the execution of the next message instead of executing it when it's added to the message bus
[ "Queues", "the", "execution", "of", "the", "next", "message", "instead", "of", "executing", "it", "when", "it", "s", "added", "to", "the", "message", "bus" ]
4dbc553c7fa7932c5413776dcf470ca8950ac2bd
https://github.com/Werkspot/message-bus/blob/4dbc553c7fa7932c5413776dcf470ca8950ac2bd/src/Bus/DeliveryChain/Middleware/LockingMiddleware.php#L51-L56
train
symbiote/silverstripe-datachange-tracker
src/Extension/ChangeRecordable.php
ChangeRecordable.getDataChangesList
public function getDataChangesList() { return DataChangeRecord::get()->filter([ 'ChangeRecordID' => $this->owner->ID, 'ChangeRecordClass' => $this->owner->ClassName ]); }
php
public function getDataChangesList() { return DataChangeRecord::get()->filter([ 'ChangeRecordID' => $this->owner->ID, 'ChangeRecordClass' => $this->owner->ClassName ]); }
[ "public", "function", "getDataChangesList", "(", ")", "{", "return", "DataChangeRecord", "::", "get", "(", ")", "->", "filter", "(", "[", "'ChangeRecordID'", "=>", "$", "this", "->", "owner", "->", "ID", ",", "'ChangeRecordClass'", "=>", "$", "this", "->", ...
Get the list of data changes for this item @return \SilverStripe\ORM\DataList
[ "Get", "the", "list", "of", "data", "changes", "for", "this", "item" ]
4895935726ecb3209a502cfd63a4b2ccef7a9bf1
https://github.com/symbiote/silverstripe-datachange-tracker/blob/4895935726ecb3209a502cfd63a4b2ccef7a9bf1/src/Extension/ChangeRecordable.php#L83-L88
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.callMapClass
private static function callMapClass($target): \ReflectionClass { $class = self::reflect($target); if (!isset(self::$classes[$class->getName()])) { self::$classes[$class->getName()] = self::forkCallMapClass($class); } return self::$classes[$class->getName()]; }
php
private static function callMapClass($target): \ReflectionClass { $class = self::reflect($target); if (!isset(self::$classes[$class->getName()])) { self::$classes[$class->getName()] = self::forkCallMapClass($class); } return self::$classes[$class->getName()]; }
[ "private", "static", "function", "callMapClass", "(", "$", "target", ")", ":", "\\", "ReflectionClass", "{", "$", "class", "=", "self", "::", "reflect", "(", "$", "target", ")", ";", "if", "(", "!", "isset", "(", "self", "::", "$", "classes", "[", "$...
returns the proxy class for given target class or interface @param string|object $target @return \ReflectionClass
[ "returns", "the", "proxy", "class", "for", "given", "target", "class", "or", "interface" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L77-L85
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.reflect
private static function reflect($class): \ReflectionClass { if (is_string($class) && (class_exists($class) || interface_exists($class) || trait_exists($class))) { return new \ReflectionClass($class); } elseif (is_object($class)) { return new \ReflectionObject($class); } throw new \InvalidArgumentException( 'Given class must either be an existing class, interface or' . ' trait name or class instance, ' . \gettype($class) . ' with value "' . $class . '" given' ); }
php
private static function reflect($class): \ReflectionClass { if (is_string($class) && (class_exists($class) || interface_exists($class) || trait_exists($class))) { return new \ReflectionClass($class); } elseif (is_object($class)) { return new \ReflectionObject($class); } throw new \InvalidArgumentException( 'Given class must either be an existing class, interface or' . ' trait name or class instance, ' . \gettype($class) . ' with value "' . $class . '" given' ); }
[ "private", "static", "function", "reflect", "(", "$", "class", ")", ":", "\\", "ReflectionClass", "{", "if", "(", "is_string", "(", "$", "class", ")", "&&", "(", "class_exists", "(", "$", "class", ")", "||", "interface_exists", "(", "$", "class", ")", ...
reflects given class value @param string|object $class @return \ReflectionClass @throws \InvalidArgumentException
[ "reflects", "given", "class", "value" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L94-L107
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.forkCallMapClass
private static function forkCallMapClass(\ReflectionClass $class): \ReflectionClass { if ($class->isTrait()) { $class = self::forkTrait($class); } try { $compile = self::$compile; $compile(self::createCallmapProxyCode($class)); } catch (\ParseError $pe) { throw new ProxyCreationFailure( 'Failure while creating CallMap instance of ' . $class->getName() . ': ' . $pe->getMessage(), $pe ); } return new \ReflectionClass($class->getName() . 'CallMapProxy'); }
php
private static function forkCallMapClass(\ReflectionClass $class): \ReflectionClass { if ($class->isTrait()) { $class = self::forkTrait($class); } try { $compile = self::$compile; $compile(self::createCallmapProxyCode($class)); } catch (\ParseError $pe) { throw new ProxyCreationFailure( 'Failure while creating CallMap instance of ' . $class->getName() . ': ' . $pe->getMessage(), $pe ); } return new \ReflectionClass($class->getName() . 'CallMapProxy'); }
[ "private", "static", "function", "forkCallMapClass", "(", "\\", "ReflectionClass", "$", "class", ")", ":", "\\", "ReflectionClass", "{", "if", "(", "$", "class", "->", "isTrait", "(", ")", ")", "{", "$", "class", "=", "self", "::", "forkTrait", "(", "$",...
creates a new class from the given class which uses the CallMap trait @param \ReflectionClass $class @return \ReflectionClass @throws ProxyCreationFailure
[ "creates", "a", "new", "class", "from", "the", "given", "class", "which", "uses", "the", "CallMap", "trait" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L124-L142
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.forkTrait
private static function forkTrait(\ReflectionClass $class): \ReflectionClass { $code = sprintf( "abstract class %sCallMapFork {\n" . " use \%s;\n}", $class->getShortName(), $class->getName() ); if ($class->inNamespace()) { $code = sprintf( "namespace %s {\n%s}\n", $class->getNamespaceName(), $code ); } try { $compile = self::$compile; $compile($code); } catch (\ParseError $pe) { throw new ProxyCreationFailure( 'Failure while creating forked trait instance of ' . $class->getName() . ': ' . $pe->getMessage(), $pe ); } return new \ReflectionClass($class->getName() . 'CallMapFork'); }
php
private static function forkTrait(\ReflectionClass $class): \ReflectionClass { $code = sprintf( "abstract class %sCallMapFork {\n" . " use \%s;\n}", $class->getShortName(), $class->getName() ); if ($class->inNamespace()) { $code = sprintf( "namespace %s {\n%s}\n", $class->getNamespaceName(), $code ); } try { $compile = self::$compile; $compile($code); } catch (\ParseError $pe) { throw new ProxyCreationFailure( 'Failure while creating forked trait instance of ' . $class->getName() . ': ' . $pe->getMessage(), $pe ); } return new \ReflectionClass($class->getName() . 'CallMapFork'); }
[ "private", "static", "function", "forkTrait", "(", "\\", "ReflectionClass", "$", "class", ")", ":", "\\", "ReflectionClass", "{", "$", "code", "=", "sprintf", "(", "\"abstract class %sCallMapFork {\\n\"", ".", "\" use \\%s;\\n}\"", ",", "$", "class", "->", "get...
create an intermediate class for the trait so that any methods of the trait become callable as parent @param \ReflectionClass $class @return \ReflectionClass @throws ProxyCreationFailure
[ "create", "an", "intermediate", "class", "for", "the", "trait", "so", "that", "any", "methods", "of", "the", "trait", "become", "callable", "as", "parent" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L152-L180
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.createMethods
private static function createMethods(\ReflectionClass $class): string { $code = ''; $methods = []; $params = []; $voidMethods = []; foreach (self::methodsOf($class) as $method) { $return = true; $returnType = determineReturnTypeOf($method); if ($returnType === ': void') { $voidMethods[$method->getName()] = $method->getName(); $return = false; } $param = paramsOf($method); /* @var $method \ReflectionMethod */ $code .= sprintf( " %s function %s(%s)%s {\n" . " %s\$this->handleMethodCall('%s', func_get_args(), %s);\n" . " }\n", ($method->isPublic() ? 'public' : 'protected'), $method->getName(), $param['string'], $returnType, $return ? 'return ' : '', $method->getName(), self::shouldReturnSelf($class, $method) ? 'true' : 'false' ); $methods[] = "'" . $method->getName() . "' => '" . $method->getName() . "'"; $params[$method->getName()] = $param['names']; } return $code . sprintf( "\n private \$_allowedMethods = [%s];\n", join(', ', $methods) ) . sprintf( "\n private \$_methodParams = %s;\n", var_export($params, true) ) . sprintf( "\n private \$_voidMethods = %s;\n", var_export($voidMethods, true) ); }
php
private static function createMethods(\ReflectionClass $class): string { $code = ''; $methods = []; $params = []; $voidMethods = []; foreach (self::methodsOf($class) as $method) { $return = true; $returnType = determineReturnTypeOf($method); if ($returnType === ': void') { $voidMethods[$method->getName()] = $method->getName(); $return = false; } $param = paramsOf($method); /* @var $method \ReflectionMethod */ $code .= sprintf( " %s function %s(%s)%s {\n" . " %s\$this->handleMethodCall('%s', func_get_args(), %s);\n" . " }\n", ($method->isPublic() ? 'public' : 'protected'), $method->getName(), $param['string'], $returnType, $return ? 'return ' : '', $method->getName(), self::shouldReturnSelf($class, $method) ? 'true' : 'false' ); $methods[] = "'" . $method->getName() . "' => '" . $method->getName() . "'"; $params[$method->getName()] = $param['names']; } return $code . sprintf( "\n private \$_allowedMethods = [%s];\n", join(', ', $methods) ) . sprintf( "\n private \$_methodParams = %s;\n", var_export($params, true) ) . sprintf( "\n private \$_voidMethods = %s;\n", var_export($voidMethods, true) ); }
[ "private", "static", "function", "createMethods", "(", "\\", "ReflectionClass", "$", "class", ")", ":", "string", "{", "$", "code", "=", "''", ";", "$", "methods", "=", "[", "]", ";", "$", "params", "=", "[", "]", ";", "$", "voidMethods", "=", "[", ...
creates methods for the proxy @param \ReflectionClass $class @return string
[ "creates", "methods", "for", "the", "proxy" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L235-L277
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.methodsOf
private static function methodsOf(\ReflectionClass $class): \Iterator { return new \CallbackFilterIterator( new \ArrayIterator($class->getMethods()), function(\ReflectionMethod $method) { return !$method->isPrivate() && !$method->isFinal() && !$method->isStatic() && !$method->isConstructor() && !$method->isDestructor(); } ); }
php
private static function methodsOf(\ReflectionClass $class): \Iterator { return new \CallbackFilterIterator( new \ArrayIterator($class->getMethods()), function(\ReflectionMethod $method) { return !$method->isPrivate() && !$method->isFinal() && !$method->isStatic() && !$method->isConstructor() && !$method->isDestructor(); } ); }
[ "private", "static", "function", "methodsOf", "(", "\\", "ReflectionClass", "$", "class", ")", ":", "\\", "Iterator", "{", "return", "new", "\\", "CallbackFilterIterator", "(", "new", "\\", "ArrayIterator", "(", "$", "class", "->", "getMethods", "(", ")", ")...
returns applicable methods for given class @param \ReflectionClass $class @return \Iterator
[ "returns", "applicable", "methods", "for", "given", "class" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L285-L298
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.shouldReturnSelf
private static function shouldReturnSelf(\ReflectionClass $class, \ReflectionMethod $method): bool { $returnType = self::detectReturnType($method); if (null === $returnType) { return false; } if (in_array($returnType, ['$this', 'self', $class->getName(), $class->getShortName()])) { return true; } foreach ($class->getInterfaces() as $interface) { if ($interface->getName() !== 'Traversable' && ($interface->getName() === $returnType || $interface->getShortName() === $returnType)) { return true; } } while ($parent = $class->getParentClass()) { if ($parent->getName() === $returnType || $parent->getShortName() === $returnType) { return true; } $class = $parent; } return false; }
php
private static function shouldReturnSelf(\ReflectionClass $class, \ReflectionMethod $method): bool { $returnType = self::detectReturnType($method); if (null === $returnType) { return false; } if (in_array($returnType, ['$this', 'self', $class->getName(), $class->getShortName()])) { return true; } foreach ($class->getInterfaces() as $interface) { if ($interface->getName() !== 'Traversable' && ($interface->getName() === $returnType || $interface->getShortName() === $returnType)) { return true; } } while ($parent = $class->getParentClass()) { if ($parent->getName() === $returnType || $parent->getShortName() === $returnType) { return true; } $class = $parent; } return false; }
[ "private", "static", "function", "shouldReturnSelf", "(", "\\", "ReflectionClass", "$", "class", ",", "\\", "ReflectionMethod", "$", "method", ")", ":", "bool", "{", "$", "returnType", "=", "self", "::", "detectReturnType", "(", "$", "method", ")", ";", "if"...
detects whether a method should return the instance or null @param \ReflectionClass $class @param \ReflectionMethod $method @return bool
[ "detects", "whether", "a", "method", "should", "return", "the", "instance", "or", "null" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L307-L333
train
bovigo/callmap
src/main/php/NewInstance.php
NewInstance.detectReturnType
private static function detectReturnType(\ReflectionMethod $method): ?string { if ($method->hasReturnType()) { return (string) $method->getReturnType(); } $docComment = $method->getDocComment(); if (false === $docComment) { return null; } $returnPart = strstr($docComment, '@return'); if (false === $returnPart) { return null; } $returnParts = explode(' ', trim(str_replace('@return', '', $returnPart))); $returnType = ltrim(trim($returnParts[0]), '\\'); if (empty($returnType) || strpos($returnType, '*') !== false) { return null; } return $returnType; }
php
private static function detectReturnType(\ReflectionMethod $method): ?string { if ($method->hasReturnType()) { return (string) $method->getReturnType(); } $docComment = $method->getDocComment(); if (false === $docComment) { return null; } $returnPart = strstr($docComment, '@return'); if (false === $returnPart) { return null; } $returnParts = explode(' ', trim(str_replace('@return', '', $returnPart))); $returnType = ltrim(trim($returnParts[0]), '\\'); if (empty($returnType) || strpos($returnType, '*') !== false) { return null; } return $returnType; }
[ "private", "static", "function", "detectReturnType", "(", "\\", "ReflectionMethod", "$", "method", ")", ":", "?", "string", "{", "if", "(", "$", "method", "->", "hasReturnType", "(", ")", ")", "{", "return", "(", "string", ")", "$", "method", "->", "getR...
detects return type of method It will make use of reflection to detect the return type. In case this does not yield a result the doc comment will be parsed for the return annotation. @param \ReflectionMethod $method @return string|null
[ "detects", "return", "type", "of", "method" ]
0dbf2c234469bf18f4cc06d31962b6141923754b
https://github.com/bovigo/callmap/blob/0dbf2c234469bf18f4cc06d31962b6141923754b/src/main/php/NewInstance.php#L345-L368
train
aplazame/php-sdk
src/Api/Client.php
Client.get
public function get($path, array $query = array()) { if (!empty($query)) { $query = http_build_query($query); $path .= '?' . $query; } return $this->request('GET', $path); }
php
public function get($path, array $query = array()) { if (!empty($query)) { $query = http_build_query($query); $path .= '?' . $query; } return $this->request('GET', $path); }
[ "public", "function", "get", "(", "$", "path", ",", "array", "$", "query", "=", "array", "(", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "query", ")", ")", "{", "$", "query", "=", "http_build_query", "(", "$", "query", ")", ";", "$", "pa...
Performs a GET request. @param string $path The path of the request. @param array $query The filters of the request. @return array The data of the response. @throws ApiCommunicationException if an I/O error occurs. @throws DeserializeException if response cannot be deserialized. @throws ApiServerException if server was not able to respond. @throws ApiClientException if request is invalid.
[ "Performs", "a", "GET", "request", "." ]
42d1b5a4650b004733728f8a009df33e9b7eeff1
https://github.com/aplazame/php-sdk/blob/42d1b5a4650b004733728f8a009df33e9b7eeff1/src/Api/Client.php#L86-L94
train
dshanske/parse-this
includes/class-parse-this.php
Parse_This.set
public function set( $source_content, $url, $jf2 = false ) { $this->content = $source_content; if ( wp_http_validate_url( $url ) ) { $this->url = $url; $this->domain = wp_parse_url( $url, PHP_URL_HOST ); } if ( $jf2 ) { $this->jf2 = $source_content; } elseif ( is_string( $this->content ) ) { if ( class_exists( 'Masterminds\\HTML5' ) ) { $this->doc = new \Masterminds\HTML5( array( 'disable_html_ns' => true ) ); $this->doc = $this->doc->loadHTML( $this->content ); } else { $this->doc = new DOMDocument(); libxml_use_internal_errors( true ); $this->doc->loadHTML( mb_convert_encoding( $this->content, 'HTML-ENTITIES', mb_detect_encoding( $this->content ) ) ); libxml_use_internal_errors( false ); } } }
php
public function set( $source_content, $url, $jf2 = false ) { $this->content = $source_content; if ( wp_http_validate_url( $url ) ) { $this->url = $url; $this->domain = wp_parse_url( $url, PHP_URL_HOST ); } if ( $jf2 ) { $this->jf2 = $source_content; } elseif ( is_string( $this->content ) ) { if ( class_exists( 'Masterminds\\HTML5' ) ) { $this->doc = new \Masterminds\HTML5( array( 'disable_html_ns' => true ) ); $this->doc = $this->doc->loadHTML( $this->content ); } else { $this->doc = new DOMDocument(); libxml_use_internal_errors( true ); $this->doc->loadHTML( mb_convert_encoding( $this->content, 'HTML-ENTITIES', mb_detect_encoding( $this->content ) ) ); libxml_use_internal_errors( false ); } } }
[ "public", "function", "set", "(", "$", "source_content", ",", "$", "url", ",", "$", "jf2", "=", "false", ")", "{", "$", "this", "->", "content", "=", "$", "source_content", ";", "if", "(", "wp_http_validate_url", "(", "$", "url", ")", ")", "{", "$", ...
Sets the source. @since x.x.x @access public @param string $source_content source content. @param string $url Source URL @param string $jf2 If set it passes the content directly as preparsed
[ "Sets", "the", "source", "." ]
722154e91fe47bca185256bd6388324de7bea012
https://github.com/dshanske/parse-this/blob/722154e91fe47bca185256bd6388324de7bea012/includes/class-parse-this.php#L46-L65
train
symbiote/silverstripe-datachange-tracker
src/Model/TrackedManyManyList.php
TrackedManyManyList.tableClass
private function tableClass($table) { $tables = DataObject::getSchema()->getTableNames(); $class = array_search($table, $tables, true); if ($class) { return $class; } return null; }
php
private function tableClass($table) { $tables = DataObject::getSchema()->getTableNames(); $class = array_search($table, $tables, true); if ($class) { return $class; } return null; }
[ "private", "function", "tableClass", "(", "$", "table", ")", "{", "$", "tables", "=", "DataObject", "::", "getSchema", "(", ")", "->", "getTableNames", "(", ")", ";", "$", "class", "=", "array_search", "(", "$", "table", ",", "$", "tables", ",", "true"...
Find the class for the given table. Stripped down version from framework that does not attempt to strip _Live and _versions postfixes as that throws errors in its preg_match(). (At least it did as of 2018-06-22 on SilverStripe 4.1.1) @param string $table @return string|null The FQN of the class, or null if not found
[ "Find", "the", "class", "for", "the", "given", "table", "." ]
4895935726ecb3209a502cfd63a4b2ccef7a9bf1
https://github.com/symbiote/silverstripe-datachange-tracker/blob/4895935726ecb3209a502cfd63a4b2ccef7a9bf1/src/Model/TrackedManyManyList.php#L76-L84
train
QuickenLoans/mcp-logger
src/Service/SyslogService.php
SyslogService.connect
private function connect() { $this->status = openlog( $this->config[self::CONFIG_IDENT], $this->config[self::CONFIG_OPTIONS], $this->config[self::CONFIG_FACILITY] ); }
php
private function connect() { $this->status = openlog( $this->config[self::CONFIG_IDENT], $this->config[self::CONFIG_OPTIONS], $this->config[self::CONFIG_FACILITY] ); }
[ "private", "function", "connect", "(", ")", "{", "$", "this", "->", "status", "=", "openlog", "(", "$", "this", "->", "config", "[", "self", "::", "CONFIG_IDENT", "]", ",", "$", "this", "->", "config", "[", "self", "::", "CONFIG_OPTIONS", "]", ",", "...
Attempt to connect to open syslog connection @return void
[ "Attempt", "to", "connect", "to", "open", "syslog", "connection" ]
ec0960fc32de1a4c583b2447b99d0ef8c801f1ae
https://github.com/QuickenLoans/mcp-logger/blob/ec0960fc32de1a4c583b2447b99d0ef8c801f1ae/src/Service/SyslogService.php#L78-L85
train
QuickenLoans/mcp-logger
src/Service/SyslogService.php
SyslogService.convertLogLevelFromPSRToSyslog
private function convertLogLevelFromPSRToSyslog($severity) { switch ($severity) { case LogLevel::DEBUG: return LOG_DEBUG; case LogLevel::INFO: return LOG_INFO; case LogLevel::NOTICE: return LOG_NOTICE; case LogLevel::WARNING: return LOG_WARNING; case LogLevel::ERROR: return LOG_ERR; case LogLevel::CRITICAL: return LOG_CRIT; case LogLevel::ALERT: return LOG_ALERT; case LogLevel::EMERGENCY: return LOG_EMERG; default: return LOG_ERR; } }
php
private function convertLogLevelFromPSRToSyslog($severity) { switch ($severity) { case LogLevel::DEBUG: return LOG_DEBUG; case LogLevel::INFO: return LOG_INFO; case LogLevel::NOTICE: return LOG_NOTICE; case LogLevel::WARNING: return LOG_WARNING; case LogLevel::ERROR: return LOG_ERR; case LogLevel::CRITICAL: return LOG_CRIT; case LogLevel::ALERT: return LOG_ALERT; case LogLevel::EMERGENCY: return LOG_EMERG; default: return LOG_ERR; } }
[ "private", "function", "convertLogLevelFromPSRToSyslog", "(", "$", "severity", ")", "{", "switch", "(", "$", "severity", ")", "{", "case", "LogLevel", "::", "DEBUG", ":", "return", "LOG_DEBUG", ";", "case", "LogLevel", "::", "INFO", ":", "return", "LOG_INFO", ...
Translate a PRS-3 log level to Syslog log level @param string $severity @return int
[ "Translate", "a", "PRS", "-", "3", "log", "level", "to", "Syslog", "log", "level" ]
ec0960fc32de1a4c583b2447b99d0ef8c801f1ae
https://github.com/QuickenLoans/mcp-logger/blob/ec0960fc32de1a4c583b2447b99d0ef8c801f1ae/src/Service/SyslogService.php#L94-L116
train
enygma/expose
src/Expose/Log/Mongo.php
Mongo.log
public function log($level, $message, array $context = array()) { $logger = new \Monolog\Logger('audit'); try { $handler = new \Monolog\Handler\MongoDBHandler( new \Mongo($this->getConnectString()), $this->getDbName(), $this->getDbCollection() ); } catch (\MongoConnectionException $e) { throw new \Exception('Cannot connect to Mongo - please check your server'); } $logger->pushHandler($handler); $logger->pushProcessor(function ($record) { $record['datetime'] = $record['datetime']->format('U'); return $record; }); return $logger->$level($message, $context); }
php
public function log($level, $message, array $context = array()) { $logger = new \Monolog\Logger('audit'); try { $handler = new \Monolog\Handler\MongoDBHandler( new \Mongo($this->getConnectString()), $this->getDbName(), $this->getDbCollection() ); } catch (\MongoConnectionException $e) { throw new \Exception('Cannot connect to Mongo - please check your server'); } $logger->pushHandler($handler); $logger->pushProcessor(function ($record) { $record['datetime'] = $record['datetime']->format('U'); return $record; }); return $logger->$level($message, $context); }
[ "public", "function", "log", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "array", "(", ")", ")", "{", "$", "logger", "=", "new", "\\", "Monolog", "\\", "Logger", "(", "'audit'", ")", ";", "try", "{", "$", "handler", ...
Push the log message and context information into Mongo @param string $level Logging level (ex. info, debug, notice...) @param string $message Log message @param array $context Extra context information @return boolean Success/fail of logging
[ "Push", "the", "log", "message", "and", "context", "information", "into", "Mongo" ]
07ee1ebe5af6a23029d4d30147463141df724fc5
https://github.com/enygma/expose/blob/07ee1ebe5af6a23029d4d30147463141df724fc5/src/Expose/Log/Mongo.php#L201-L220
train
enygma/expose
src/Expose/Console/Command/ProcessQueueCommand.php
ProcessQueueCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $queueType = $input->getOption('queue-type'); $notifyEmail = $input->getOption('notify-email'); $manager = $this->getManager(); if ($notifyEmail !== false) { $notify = new \Expose\Notify\Email(); $notify->setToAddress($notifyEmail); $manager->setNotify($notify); } if ($queueType !== false) { $queueConnect = $input->getOption('queue-connect'); if ($queueConnect === false) { $output->writeln('<error>Queue connection string not provided</error>'); return; } // make the queue object with the right adapter $queueClass = '\\Expose\\Queue\\'.ucwords(strtolower($queueType)); if (!class_exists($queueClass)) { $output->writeln('<error>Invalid queue type "'.$queueType.'"</error>'); return; } $queue = new $queueClass(); $adapter = $this->buildAdapter($queueType, $queueConnect, $queue->getDatabase()); if ($adapter === false) { $output->writeln('<error>Invalid connection string</error>'); return; } $queue->setAdapter($adapter); } else { $output->writeln('<error>Queue type not defined</error>'); return; } $this->setQueue($queue); if ($input->getOption('list') !== false) { $output->writeln('<info>Current Queue Items Pending</info>'); $this->listQueue($manager, $queue); return true; } // by default process the current queue $reports = $this->processQueue($output); if (count($reports) == 0) { return; } $exportFile = $input->getOption('export-file'); if ($exportFile !== false) { $output->writeln('<info>Outputting results to file '.$exportFile.'</info>'); file_put_contents( $exportFile, '['.date('m.d.Y H:i:s').'] '.json_encode($reports), FILE_APPEND ); } else { echo json_encode($reports); } }
php
protected function execute(InputInterface $input, OutputInterface $output) { $queueType = $input->getOption('queue-type'); $notifyEmail = $input->getOption('notify-email'); $manager = $this->getManager(); if ($notifyEmail !== false) { $notify = new \Expose\Notify\Email(); $notify->setToAddress($notifyEmail); $manager->setNotify($notify); } if ($queueType !== false) { $queueConnect = $input->getOption('queue-connect'); if ($queueConnect === false) { $output->writeln('<error>Queue connection string not provided</error>'); return; } // make the queue object with the right adapter $queueClass = '\\Expose\\Queue\\'.ucwords(strtolower($queueType)); if (!class_exists($queueClass)) { $output->writeln('<error>Invalid queue type "'.$queueType.'"</error>'); return; } $queue = new $queueClass(); $adapter = $this->buildAdapter($queueType, $queueConnect, $queue->getDatabase()); if ($adapter === false) { $output->writeln('<error>Invalid connection string</error>'); return; } $queue->setAdapter($adapter); } else { $output->writeln('<error>Queue type not defined</error>'); return; } $this->setQueue($queue); if ($input->getOption('list') !== false) { $output->writeln('<info>Current Queue Items Pending</info>'); $this->listQueue($manager, $queue); return true; } // by default process the current queue $reports = $this->processQueue($output); if (count($reports) == 0) { return; } $exportFile = $input->getOption('export-file'); if ($exportFile !== false) { $output->writeln('<info>Outputting results to file '.$exportFile.'</info>'); file_put_contents( $exportFile, '['.date('m.d.Y H:i:s').'] '.json_encode($reports), FILE_APPEND ); } else { echo json_encode($reports); } }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "queueType", "=", "$", "input", "->", "getOption", "(", "'queue-type'", ")", ";", "$", "notifyEmail", "=", "$", "input", "->", "g...
Execute the process-queue command @param InputInterface $input Input object @param OutputInterface $output Output object @return null
[ "Execute", "the", "process", "-", "queue", "command" ]
07ee1ebe5af6a23029d4d30147463141df724fc5
https://github.com/enygma/expose/blob/07ee1ebe5af6a23029d4d30147463141df724fc5/src/Expose/Console/Command/ProcessQueueCommand.php#L96-L159
train
enygma/expose
src/Expose/Console/Command/ProcessQueueCommand.php
ProcessQueueCommand.processQueue
protected function processQueue(OutputInterface &$output) { $manager = $this->getManager(); $queue = $this->getQueue(); $path = array(); $records = $queue->getPending(); $output->writeln('<info>'.count($records).' records found.</info>'); if (count($records) == 0) { $output->writeln('<error>No records found to process!</error>'); } else { $output->writeln('<info>Processing '.count($records).' records</info>'); } foreach ($records as $record) { $manager->runFilters($record['data'], $path); $queue->markProcessed($record['_id']); } $reports = $manager->getReports(); foreach ($reports as $index => $report) { $reports[$index] = $report->toArray(true); } return $reports; }
php
protected function processQueue(OutputInterface &$output) { $manager = $this->getManager(); $queue = $this->getQueue(); $path = array(); $records = $queue->getPending(); $output->writeln('<info>'.count($records).' records found.</info>'); if (count($records) == 0) { $output->writeln('<error>No records found to process!</error>'); } else { $output->writeln('<info>Processing '.count($records).' records</info>'); } foreach ($records as $record) { $manager->runFilters($record['data'], $path); $queue->markProcessed($record['_id']); } $reports = $manager->getReports(); foreach ($reports as $index => $report) { $reports[$index] = $report->toArray(true); } return $reports; }
[ "protected", "function", "processQueue", "(", "OutputInterface", "&", "$", "output", ")", "{", "$", "manager", "=", "$", "this", "->", "getManager", "(", ")", ";", "$", "queue", "=", "$", "this", "->", "getQueue", "(", ")", ";", "$", "path", "=", "ar...
Run the queue processing @param OutputInterface $output Reference to output instance @return array Updated reports set
[ "Run", "the", "queue", "processing" ]
07ee1ebe5af6a23029d4d30147463141df724fc5
https://github.com/enygma/expose/blob/07ee1ebe5af6a23029d4d30147463141df724fc5/src/Expose/Console/Command/ProcessQueueCommand.php#L167-L191
train