repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
Kris-Kuiper/sFire-Framework
src/MVC/View.php
View.escapeCss
public function escapeCss($string, $encoding = 'utf-8') { $current = Escape :: getEncoding(); Escape :: setEncoding($encoding); $result = Escape :: css($string); Escape :: setEncoding($current); return $result; }
php
public function escapeCss($string, $encoding = 'utf-8') { $current = Escape :: getEncoding(); Escape :: setEncoding($encoding); $result = Escape :: css($string); Escape :: setEncoding($current); return $result; }
[ "public", "function", "escapeCss", "(", "$", "string", ",", "$", "encoding", "=", "'utf-8'", ")", "{", "$", "current", "=", "Escape", "::", "getEncoding", "(", ")", ";", "Escape", "::", "setEncoding", "(", "$", "encoding", ")", ";", "$", "result", "=", "Escape", "::", "css", "(", "$", "string", ")", ";", "Escape", "::", "setEncoding", "(", "$", "current", ")", ";", "return", "$", "result", ";", "}" ]
Escape a string for the CSS context. @param string $string @return string
[ "Escape", "a", "string", "for", "the", "CSS", "context", "." ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/MVC/View.php#L147-L155
train
Kris-Kuiper/sFire-Framework
src/MVC/View.php
View.partial
protected function partial($file) { $viewmodel = new ViewModel($file); $viewmodel -> assign($this -> viewmodel -> getVariables()); ViewContainer :: output($viewmodel); }
php
protected function partial($file) { $viewmodel = new ViewModel($file); $viewmodel -> assign($this -> viewmodel -> getVariables()); ViewContainer :: output($viewmodel); }
[ "protected", "function", "partial", "(", "$", "file", ")", "{", "$", "viewmodel", "=", "new", "ViewModel", "(", "$", "file", ")", ";", "$", "viewmodel", "->", "assign", "(", "$", "this", "->", "viewmodel", "->", "getVariables", "(", ")", ")", ";", "ViewContainer", "::", "output", "(", "$", "viewmodel", ")", ";", "}" ]
Calls the parse function @param string $template @return
[ "Calls", "the", "parse", "function" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/MVC/View.php#L198-L204
train
Kris-Kuiper/sFire-Framework
src/MVC/View.php
View.form
protected function form($type, $name = null, $value = null) { $form = new Form(); return $form -> {$type}($name, $value); }
php
protected function form($type, $name = null, $value = null) { $form = new Form(); return $form -> {$type}($name, $value); }
[ "protected", "function", "form", "(", "$", "type", ",", "$", "name", "=", "null", ",", "$", "value", "=", "null", ")", "{", "$", "form", "=", "new", "Form", "(", ")", ";", "return", "$", "form", "->", "{", "$", "type", "}", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Calls the url function of the sFire\Routing\Router @param string $identifier @return string
[ "Calls", "the", "url", "function", "of", "the", "sFire", "\\", "Routing", "\\", "Router" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/MVC/View.php#L222-L226
train
Kris-Kuiper/sFire-Framework
src/MVC/View.php
View.translate
protected function translate($key, $params = null, $language = null) { return Translation :: translate($key, $params, $language, $this -> getViewmodel()); }
php
protected function translate($key, $params = null, $language = null) { return Translation :: translate($key, $params, $language, $this -> getViewmodel()); }
[ "protected", "function", "translate", "(", "$", "key", ",", "$", "params", "=", "null", ",", "$", "language", "=", "null", ")", "{", "return", "Translation", "::", "translate", "(", "$", "key", ",", "$", "params", ",", "$", "language", ",", "$", "this", "->", "getViewmodel", "(", ")", ")", ";", "}" ]
Calls the translate function of the sFire\Translation\Translate @param string $key @return string
[ "Calls", "the", "translate", "function", "of", "the", "sFire", "\\", "Translation", "\\", "Translate" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/MVC/View.php#L234-L236
train
Kris-Kuiper/sFire-Framework
src/MVC/View.php
View.template
protected function template($action, $params = null) { if(false === is_string($action)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($action)), E_USER_ERROR); } if(null !== $params && false === is_array($params)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR); } $functions = TemplateData :: getTemplateFunctions(); if(false === isset($functions[$action])) { return trigger_error(sprintf('Argument 1 passed to %s() must be a valid callable template function, "%s" given', __METHOD__, $action), E_USER_ERROR); } return call_user_func_array($functions[$action], $params); }
php
protected function template($action, $params = null) { if(false === is_string($action)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($action)), E_USER_ERROR); } if(null !== $params && false === is_array($params)) { return trigger_error(sprintf('Argument 2 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($params)), E_USER_ERROR); } $functions = TemplateData :: getTemplateFunctions(); if(false === isset($functions[$action])) { return trigger_error(sprintf('Argument 1 passed to %s() must be a valid callable template function, "%s" given', __METHOD__, $action), E_USER_ERROR); } return call_user_func_array($functions[$action], $params); }
[ "protected", "function", "template", "(", "$", "action", ",", "$", "params", "=", "null", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "action", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "action", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "null", "!==", "$", "params", "&&", "false", "===", "is_array", "(", "$", "params", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 2 passed to %s() must be of the type array, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "params", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "functions", "=", "TemplateData", "::", "getTemplateFunctions", "(", ")", ";", "if", "(", "false", "===", "isset", "(", "$", "functions", "[", "$", "action", "]", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be a valid callable template function, \"%s\" given'", ",", "__METHOD__", ",", "$", "action", ")", ",", "E_USER_ERROR", ")", ";", "}", "return", "call_user_func_array", "(", "$", "functions", "[", "$", "action", "]", ",", "$", "params", ")", ";", "}" ]
Execute user defined template function @param string $action @param array $params @return mixed
[ "Execute", "user", "defined", "template", "function" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/MVC/View.php#L245-L262
train
Wedeto/Auth
src/ACL/Entity.php
Entity.getPolicy
public function getPolicy(Role $role, string $action) { $rules = $this->getRules(); $pref_policy = $this->getACL()->getPreferredPolicy(); $inherit = true; $ancestor_distance = null; $ancestor_policy = null; foreach ($rules as $rule) { // NOINHERIT-rules disable rule inheritance and do nothing else if ($rule->policy === Rule::NOINHERIT) { $inherit = false; continue; } // Always ignore INHERIT rules if ($rule->policy === Rule::INHERIT) continue; // If the action doesn't match, don't consider the rule // TODO: What about container actions? if ($rule->action !== $action) continue; // If the Rule applies to the specified Role, its answer is definitive if ($rule->role->is($role)) return $rule->policy; // Find the closest matching parent if (($distance = $rule->role->isAncestorOf($role)) > 0) { // Always select the closest parent that has a defined rule. // When there are several conflicting rules, applying to the // same level of ancestry, select the preferred policy. if ( $ancestor_distance === null || $distance < $ancestor_distance || ($distance === $ancestor_distance && $rule->policy === $pref_policy) ) { $ancestor_policy = $rule; $ancestor_distance = $distance; } } } if ($ancestor_policy !== null) return $ancestor_policy->policy; // This Entity doesn't have a defined policy for this action. // If inheritance is disabled, or the Entity does not have a parent (root), // return the default policy. if (!$inherit || empty($this->parents)) { // Return default policy return Rule::UNDEFINED; } // Inherit from the parents $parents = $this->getParents(); $policy = Rule::UNDEFINED; foreach ($parents as $parent) { $policy = $parent->getPolicy($role, $action); // If an Entity has multiple parents, just one of them needs to // allow the action to allow it on this Entity. if ($policy === $pref_policy) return $pref_policy; } // None of the parents have a preferred policy, so return the alternative return $policy; }
php
public function getPolicy(Role $role, string $action) { $rules = $this->getRules(); $pref_policy = $this->getACL()->getPreferredPolicy(); $inherit = true; $ancestor_distance = null; $ancestor_policy = null; foreach ($rules as $rule) { // NOINHERIT-rules disable rule inheritance and do nothing else if ($rule->policy === Rule::NOINHERIT) { $inherit = false; continue; } // Always ignore INHERIT rules if ($rule->policy === Rule::INHERIT) continue; // If the action doesn't match, don't consider the rule // TODO: What about container actions? if ($rule->action !== $action) continue; // If the Rule applies to the specified Role, its answer is definitive if ($rule->role->is($role)) return $rule->policy; // Find the closest matching parent if (($distance = $rule->role->isAncestorOf($role)) > 0) { // Always select the closest parent that has a defined rule. // When there are several conflicting rules, applying to the // same level of ancestry, select the preferred policy. if ( $ancestor_distance === null || $distance < $ancestor_distance || ($distance === $ancestor_distance && $rule->policy === $pref_policy) ) { $ancestor_policy = $rule; $ancestor_distance = $distance; } } } if ($ancestor_policy !== null) return $ancestor_policy->policy; // This Entity doesn't have a defined policy for this action. // If inheritance is disabled, or the Entity does not have a parent (root), // return the default policy. if (!$inherit || empty($this->parents)) { // Return default policy return Rule::UNDEFINED; } // Inherit from the parents $parents = $this->getParents(); $policy = Rule::UNDEFINED; foreach ($parents as $parent) { $policy = $parent->getPolicy($role, $action); // If an Entity has multiple parents, just one of them needs to // allow the action to allow it on this Entity. if ($policy === $pref_policy) return $pref_policy; } // None of the parents have a preferred policy, so return the alternative return $policy; }
[ "public", "function", "getPolicy", "(", "Role", "$", "role", ",", "string", "$", "action", ")", "{", "$", "rules", "=", "$", "this", "->", "getRules", "(", ")", ";", "$", "pref_policy", "=", "$", "this", "->", "getACL", "(", ")", "->", "getPreferredPolicy", "(", ")", ";", "$", "inherit", "=", "true", ";", "$", "ancestor_distance", "=", "null", ";", "$", "ancestor_policy", "=", "null", ";", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "// NOINHERIT-rules disable rule inheritance and do nothing else", "if", "(", "$", "rule", "->", "policy", "===", "Rule", "::", "NOINHERIT", ")", "{", "$", "inherit", "=", "false", ";", "continue", ";", "}", "// Always ignore INHERIT rules", "if", "(", "$", "rule", "->", "policy", "===", "Rule", "::", "INHERIT", ")", "continue", ";", "// If the action doesn't match, don't consider the rule", "// TODO: What about container actions?", "if", "(", "$", "rule", "->", "action", "!==", "$", "action", ")", "continue", ";", "// If the Rule applies to the specified Role, its answer is definitive", "if", "(", "$", "rule", "->", "role", "->", "is", "(", "$", "role", ")", ")", "return", "$", "rule", "->", "policy", ";", "// Find the closest matching parent", "if", "(", "(", "$", "distance", "=", "$", "rule", "->", "role", "->", "isAncestorOf", "(", "$", "role", ")", ")", ">", "0", ")", "{", "// Always select the closest parent that has a defined rule.", "// When there are several conflicting rules, applying to the", "// same level of ancestry, select the preferred policy.", "if", "(", "$", "ancestor_distance", "===", "null", "||", "$", "distance", "<", "$", "ancestor_distance", "||", "(", "$", "distance", "===", "$", "ancestor_distance", "&&", "$", "rule", "->", "policy", "===", "$", "pref_policy", ")", ")", "{", "$", "ancestor_policy", "=", "$", "rule", ";", "$", "ancestor_distance", "=", "$", "distance", ";", "}", "}", "}", "if", "(", "$", "ancestor_policy", "!==", "null", ")", "return", "$", "ancestor_policy", "->", "policy", ";", "// This Entity doesn't have a defined policy for this action.", "// If inheritance is disabled, or the Entity does not have a parent (root),", "// return the default policy.", "if", "(", "!", "$", "inherit", "||", "empty", "(", "$", "this", "->", "parents", ")", ")", "{", "// Return default policy", "return", "Rule", "::", "UNDEFINED", ";", "}", "// Inherit from the parents", "$", "parents", "=", "$", "this", "->", "getParents", "(", ")", ";", "$", "policy", "=", "Rule", "::", "UNDEFINED", ";", "foreach", "(", "$", "parents", "as", "$", "parent", ")", "{", "$", "policy", "=", "$", "parent", "->", "getPolicy", "(", "$", "role", ",", "$", "action", ")", ";", "// If an Entity has multiple parents, just one of them needs to", "// allow the action to allow it on this Entity.", "if", "(", "$", "policy", "===", "$", "pref_policy", ")", "return", "$", "pref_policy", ";", "}", "// None of the parents have a preferred policy, so return the alternative", "return", "$", "policy", ";", "}" ]
Find the policy to the Role performing the action on this Entity. @param $role Role The Role wanting to perform an action @param $action string The action Role wishes to perform @return integer The policy, either Rule::ALLOW or Rule::DENY.
[ "Find", "the", "policy", "to", "the", "Role", "performing", "the", "action", "on", "this", "Entity", "." ]
d53777d860a9e67154b84b425e29da5d4dcd28e0
https://github.com/Wedeto/Auth/blob/d53777d860a9e67154b84b425e29da5d4dcd28e0/src/ACL/Entity.php#L99-L173
train
Linkvalue-Interne/MobileNotif
src/Client/ApnsClient.php
ApnsClient.setUp
public function setUp(array $params) { if (empty($params['endpoint'])) { throw new \RuntimeException('Parameter "endpoint" cannot be empty.'); } if (empty($params['ssl_pem_path'])) { throw new \RuntimeException('Parameter "ssl_pem_path" cannot be empty.'); } if (!is_readable($params['ssl_pem_path'])) { throw new \RuntimeException('"ssl_pem_path" file does not exist or is not readable.'); } $this->params = $params; }
php
public function setUp(array $params) { if (empty($params['endpoint'])) { throw new \RuntimeException('Parameter "endpoint" cannot be empty.'); } if (empty($params['ssl_pem_path'])) { throw new \RuntimeException('Parameter "ssl_pem_path" cannot be empty.'); } if (!is_readable($params['ssl_pem_path'])) { throw new \RuntimeException('"ssl_pem_path" file does not exist or is not readable.'); } $this->params = $params; }
[ "public", "function", "setUp", "(", "array", "$", "params", ")", "{", "if", "(", "empty", "(", "$", "params", "[", "'endpoint'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Parameter \"endpoint\" cannot be empty.'", ")", ";", "}", "if", "(", "empty", "(", "$", "params", "[", "'ssl_pem_path'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Parameter \"ssl_pem_path\" cannot be empty.'", ")", ";", "}", "if", "(", "!", "is_readable", "(", "$", "params", "[", "'ssl_pem_path'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'\"ssl_pem_path\" file does not exist or is not readable.'", ")", ";", "}", "$", "this", "->", "params", "=", "$", "params", ";", "}" ]
Set up parameters. @param array $params @throws \RuntimeException
[ "Set", "up", "parameters", "." ]
e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Client/ApnsClient.php#L49-L64
train
Linkvalue-Interne/MobileNotif
src/Client/ApnsClient.php
ApnsClient.getStreamSocketClient
private function getStreamSocketClient() { $stream_socket_client = stream_socket_client( $this->params['endpoint'], $errno, $errstr, 30, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $this->getStreamContext() ); if ($stream_socket_client === false) { throw new PushException('An error occurred while trying to contact APNS server.'); } return $stream_socket_client; }
php
private function getStreamSocketClient() { $stream_socket_client = stream_socket_client( $this->params['endpoint'], $errno, $errstr, 30, STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT, $this->getStreamContext() ); if ($stream_socket_client === false) { throw new PushException('An error occurred while trying to contact APNS server.'); } return $stream_socket_client; }
[ "private", "function", "getStreamSocketClient", "(", ")", "{", "$", "stream_socket_client", "=", "stream_socket_client", "(", "$", "this", "->", "params", "[", "'endpoint'", "]", ",", "$", "errno", ",", "$", "errstr", ",", "30", ",", "STREAM_CLIENT_CONNECT", "|", "STREAM_CLIENT_PERSISTENT", ",", "$", "this", "->", "getStreamContext", "(", ")", ")", ";", "if", "(", "$", "stream_socket_client", "===", "false", ")", "{", "throw", "new", "PushException", "(", "'An error occurred while trying to contact APNS server.'", ")", ";", "}", "return", "$", "stream_socket_client", ";", "}" ]
Get the Stream socket client. Connect to the APNS server and open a client socket to it. @return resource Socket to the APNS server. @throws PushException if connection to APNS server failed.
[ "Get", "the", "Stream", "socket", "client", "." ]
e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Client/ApnsClient.php#L110-L126
train
Linkvalue-Interne/MobileNotif
src/Client/ApnsClient.php
ApnsClient.getStreamContext
private function getStreamContext() { $context = array( 'ssl' => array( 'local_cert' => $this->params['ssl_pem_path'], ), ); // Handle Certificate Bundle passphrase if (!empty($this->params['ssl_passphrase'])) { $context['ssl']['passphrase'] = $this->params['ssl_passphrase']; } return stream_context_create($context); }
php
private function getStreamContext() { $context = array( 'ssl' => array( 'local_cert' => $this->params['ssl_pem_path'], ), ); // Handle Certificate Bundle passphrase if (!empty($this->params['ssl_passphrase'])) { $context['ssl']['passphrase'] = $this->params['ssl_passphrase']; } return stream_context_create($context); }
[ "private", "function", "getStreamContext", "(", ")", "{", "$", "context", "=", "array", "(", "'ssl'", "=>", "array", "(", "'local_cert'", "=>", "$", "this", "->", "params", "[", "'ssl_pem_path'", "]", ",", ")", ",", ")", ";", "// Handle Certificate Bundle passphrase", "if", "(", "!", "empty", "(", "$", "this", "->", "params", "[", "'ssl_passphrase'", "]", ")", ")", "{", "$", "context", "[", "'ssl'", "]", "[", "'passphrase'", "]", "=", "$", "this", "->", "params", "[", "'ssl_passphrase'", "]", ";", "}", "return", "stream_context_create", "(", "$", "context", ")", ";", "}" ]
Get secured stream context from SSL certificate. @return resource
[ "Get", "secured", "stream", "context", "from", "SSL", "certificate", "." ]
e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6
https://github.com/Linkvalue-Interne/MobileNotif/blob/e6e4c4219f3bbb0aee32e90e5fdfc8c6a7ed53f6/src/Client/ApnsClient.php#L133-L147
train
wb-crowdfusion/crowdfusion
system/core/classes/mvc/filters/FormFilterer.php
FormFilterer.hiddenFormFields
public function hiddenFormFields() { $fields = $this->getParameter('fields'); if (empty($fields)) return ''; $html_array = ArrayUtils::htmlArrayFlatten($fields); foreach ($html_array as $name => $value) { $name = htmlentities($name, ENT_QUOTES); $value = htmlentities($value, ENT_QUOTES); $output[] = "<input type=\"hidden\" name=\"$name\" value=\"$value\" />"; } return join("\n", $output); }
php
public function hiddenFormFields() { $fields = $this->getParameter('fields'); if (empty($fields)) return ''; $html_array = ArrayUtils::htmlArrayFlatten($fields); foreach ($html_array as $name => $value) { $name = htmlentities($name, ENT_QUOTES); $value = htmlentities($value, ENT_QUOTES); $output[] = "<input type=\"hidden\" name=\"$name\" value=\"$value\" />"; } return join("\n", $output); }
[ "public", "function", "hiddenFormFields", "(", ")", "{", "$", "fields", "=", "$", "this", "->", "getParameter", "(", "'fields'", ")", ";", "if", "(", "empty", "(", "$", "fields", ")", ")", "return", "''", ";", "$", "html_array", "=", "ArrayUtils", "::", "htmlArrayFlatten", "(", "$", "fields", ")", ";", "foreach", "(", "$", "html_array", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "name", "=", "htmlentities", "(", "$", "name", ",", "ENT_QUOTES", ")", ";", "$", "value", "=", "htmlentities", "(", "$", "value", ",", "ENT_QUOTES", ")", ";", "$", "output", "[", "]", "=", "\"<input type=\\\"hidden\\\" name=\\\"$name\\\" value=\\\"$value\\\" />\"", ";", "}", "return", "join", "(", "\"\\n\"", ",", "$", "output", ")", ";", "}" ]
Returns all the fields passed into 'fields' as hidden fields to submit Expected Param: fields array A PHP array that needs to be converted to hidden fields @return string
[ "Returns", "all", "the", "fields", "passed", "into", "fields", "as", "hidden", "fields", "to", "submit" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/mvc/filters/FormFilterer.php#L42-L59
train
Hnto/nuki
src/Handlers/Http/Input/Request.php
Request.protocol
public function protocol($version = false) : string { if ($version === false) { $protocol = 'http'; if ($this->server()->get('HTTPS')) { $protocol = 'https'; } return $protocol; } return $this->server()->get('SERVER_PROTOCOL'); }
php
public function protocol($version = false) : string { if ($version === false) { $protocol = 'http'; if ($this->server()->get('HTTPS')) { $protocol = 'https'; } return $protocol; } return $this->server()->get('SERVER_PROTOCOL'); }
[ "public", "function", "protocol", "(", "$", "version", "=", "false", ")", ":", "string", "{", "if", "(", "$", "version", "===", "false", ")", "{", "$", "protocol", "=", "'http'", ";", "if", "(", "$", "this", "->", "server", "(", ")", "->", "get", "(", "'HTTPS'", ")", ")", "{", "$", "protocol", "=", "'https'", ";", "}", "return", "$", "protocol", ";", "}", "return", "$", "this", "->", "server", "(", ")", "->", "get", "(", "'SERVER_PROTOCOL'", ")", ";", "}" ]
Get used server protocal @param bool $version @return string
[ "Get", "used", "server", "protocal" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Http/Input/Request.php#L186-L197
train
Hnto/nuki
src/Handlers/Http/Input/Request.php
Request.incoming
public function incoming(Application $app) { $route = $app->getService('router') ->findHttpRoute($this); /** Route is a callback execution */ if (!empty($route->offsetGet('action'))) { //Route is a callback execution $app::getContainer()->offsetSet( 'callback', $route ); return; } /** Route is a service execution */ //Set active unit $app->setActiveUnit( Application::APPLICATION_UNIT_NAMESPACE . $route->get('unit') ); //Set active service if (!class_exists( $app->getActiveUnit() . Application::APPLICATION_SERVICES_TRAIL . $route->get('service')) ) { throw new \Nuki\Exceptions\Base('No available service has been found for the provided unit'); } $app->setActiveService($route->get('service')); //Set active process $process = $this->buildProcess( $route->get('process'), $app->getActiveUnit() . Application::APPLICATION_SERVICES_TRAIL . $app->getActiveService() ); $app->setActiveProcess($process); //Add params from service call to params-handler /** @var Params $paramsHandler */ $paramsHandler = $app->getService('params-handler'); $paramsHandler->add('route-params', $route->get('params')); }
php
public function incoming(Application $app) { $route = $app->getService('router') ->findHttpRoute($this); /** Route is a callback execution */ if (!empty($route->offsetGet('action'))) { //Route is a callback execution $app::getContainer()->offsetSet( 'callback', $route ); return; } /** Route is a service execution */ //Set active unit $app->setActiveUnit( Application::APPLICATION_UNIT_NAMESPACE . $route->get('unit') ); //Set active service if (!class_exists( $app->getActiveUnit() . Application::APPLICATION_SERVICES_TRAIL . $route->get('service')) ) { throw new \Nuki\Exceptions\Base('No available service has been found for the provided unit'); } $app->setActiveService($route->get('service')); //Set active process $process = $this->buildProcess( $route->get('process'), $app->getActiveUnit() . Application::APPLICATION_SERVICES_TRAIL . $app->getActiveService() ); $app->setActiveProcess($process); //Add params from service call to params-handler /** @var Params $paramsHandler */ $paramsHandler = $app->getService('params-handler'); $paramsHandler->add('route-params', $route->get('params')); }
[ "public", "function", "incoming", "(", "Application", "$", "app", ")", "{", "$", "route", "=", "$", "app", "->", "getService", "(", "'router'", ")", "->", "findHttpRoute", "(", "$", "this", ")", ";", "/** Route is a callback execution */", "if", "(", "!", "empty", "(", "$", "route", "->", "offsetGet", "(", "'action'", ")", ")", ")", "{", "//Route is a callback execution", "$", "app", "::", "getContainer", "(", ")", "->", "offsetSet", "(", "'callback'", ",", "$", "route", ")", ";", "return", ";", "}", "/** Route is a service execution */", "//Set active unit", "$", "app", "->", "setActiveUnit", "(", "Application", "::", "APPLICATION_UNIT_NAMESPACE", ".", "$", "route", "->", "get", "(", "'unit'", ")", ")", ";", "//Set active service", "if", "(", "!", "class_exists", "(", "$", "app", "->", "getActiveUnit", "(", ")", ".", "Application", "::", "APPLICATION_SERVICES_TRAIL", ".", "$", "route", "->", "get", "(", "'service'", ")", ")", ")", "{", "throw", "new", "\\", "Nuki", "\\", "Exceptions", "\\", "Base", "(", "'No available service has been found for the provided unit'", ")", ";", "}", "$", "app", "->", "setActiveService", "(", "$", "route", "->", "get", "(", "'service'", ")", ")", ";", "//Set active process", "$", "process", "=", "$", "this", "->", "buildProcess", "(", "$", "route", "->", "get", "(", "'process'", ")", ",", "$", "app", "->", "getActiveUnit", "(", ")", ".", "Application", "::", "APPLICATION_SERVICES_TRAIL", ".", "$", "app", "->", "getActiveService", "(", ")", ")", ";", "$", "app", "->", "setActiveProcess", "(", "$", "process", ")", ";", "//Add params from service call to params-handler", "/** @var Params $paramsHandler */", "$", "paramsHandler", "=", "$", "app", "->", "getService", "(", "'params-handler'", ")", ";", "$", "paramsHandler", "->", "add", "(", "'route-params'", ",", "$", "route", "->", "get", "(", "'params'", ")", ")", ";", "}" ]
Initialize incoming request Determine if route contains callback or service execution - set callback - set active unit - set active service - set active process - register service @param Application $app @return void @throws Base
[ "Initialize", "incoming", "request", "Determine", "if", "route", "contains", "callback", "or", "service", "execution" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Http/Input/Request.php#L325-L369
train
Hnto/nuki
src/Handlers/Http/Input/Request.php
Request.buildProcess
private function buildProcess(string $process, string $fullServiceName) { $methods = array_flip(get_class_methods($fullServiceName)); if (!array_key_exists(($process), $methods)) { throw new \Nuki\Exceptions\Base('No available process is found for the provided service'); } return $process; }
php
private function buildProcess(string $process, string $fullServiceName) { $methods = array_flip(get_class_methods($fullServiceName)); if (!array_key_exists(($process), $methods)) { throw new \Nuki\Exceptions\Base('No available process is found for the provided service'); } return $process; }
[ "private", "function", "buildProcess", "(", "string", "$", "process", ",", "string", "$", "fullServiceName", ")", "{", "$", "methods", "=", "array_flip", "(", "get_class_methods", "(", "$", "fullServiceName", ")", ")", ";", "if", "(", "!", "array_key_exists", "(", "(", "$", "process", ")", ",", "$", "methods", ")", ")", "{", "throw", "new", "\\", "Nuki", "\\", "Exceptions", "\\", "Base", "(", "'No available process is found for the provided service'", ")", ";", "}", "return", "$", "process", ";", "}" ]
Build process name @param string $process @param string $fullServiceName @return string @throws \Nuki\Exceptions\Base
[ "Build", "process", "name" ]
c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c
https://github.com/Hnto/nuki/blob/c3fb16244e8d611c335a88e3b9c9ee7d81fafc0c/src/Handlers/Http/Input/Request.php#L379-L388
train
modulusphp/utility
Events.php
Events.triggerGroup
public function triggerGroup(?array $events = [], ?array $args = null) { foreach($events as $callback) { if (is_callable($callback)) { call_user_func_array($callback, isset($args) ? $args : []); } else if (is_string($callback)) { $call = new $callback; call_user_func_array([$call, 'persist'], $args ?? []); } } }
php
public function triggerGroup(?array $events = [], ?array $args = null) { foreach($events as $callback) { if (is_callable($callback)) { call_user_func_array($callback, isset($args) ? $args : []); } else if (is_string($callback)) { $call = new $callback; call_user_func_array([$call, 'persist'], $args ?? []); } } }
[ "public", "function", "triggerGroup", "(", "?", "array", "$", "events", "=", "[", "]", ",", "?", "array", "$", "args", "=", "null", ")", "{", "foreach", "(", "$", "events", "as", "$", "callback", ")", "{", "if", "(", "is_callable", "(", "$", "callback", ")", ")", "{", "call_user_func_array", "(", "$", "callback", ",", "isset", "(", "$", "args", ")", "?", "$", "args", ":", "[", "]", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "callback", ")", ")", "{", "$", "call", "=", "new", "$", "callback", ";", "call_user_func_array", "(", "[", "$", "call", ",", "'persist'", "]", ",", "$", "args", "??", "[", "]", ")", ";", "}", "}", "}" ]
Trigger a grouped event @param mixed ?array @param mixed ?array @return void
[ "Trigger", "a", "grouped", "event" ]
c1e127539b13d3ec8381e41c64b881e0701807f5
https://github.com/modulusphp/utility/blob/c1e127539b13d3ec8381e41c64b881e0701807f5/Events.php#L69-L80
train
gplcart/cli
controllers/commands/City.php
City.cmdGetCity
public function cmdGetCity() { $result = $this->getListCity(); $this->outputFormat($result); $this->outputFormatTableCity($result); $this->output(); }
php
public function cmdGetCity() { $result = $this->getListCity(); $this->outputFormat($result); $this->outputFormatTableCity($result); $this->output(); }
[ "public", "function", "cmdGetCity", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getListCity", "(", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "result", ")", ";", "$", "this", "->", "outputFormatTableCity", "(", "$", "result", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "city-get" command
[ "Callback", "for", "city", "-", "get", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/City.php#L40-L46
train
gplcart/cli
controllers/commands/City.php
City.cmdDeleteCity
public function cmdDeleteCity() { $id = $this->getParam(0); if (empty($id)) { $this->errorAndExit($this->text('Invalid argument')); } $options = null; if ($this->getParam('state')) { $options = array('state_id' => $id); } else if ($this->getParam('country')) { $options = array('country' => $id); } if (isset($options)) { $deleted = $count = 0; foreach ($this->city->getList($options) as $item) { $count++; $deleted += (int) $this->city->delete($item['city_id']); } $result = $count && $count == $deleted; } else { $result = $this->city->delete($id); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
php
public function cmdDeleteCity() { $id = $this->getParam(0); if (empty($id)) { $this->errorAndExit($this->text('Invalid argument')); } $options = null; if ($this->getParam('state')) { $options = array('state_id' => $id); } else if ($this->getParam('country')) { $options = array('country' => $id); } if (isset($options)) { $deleted = $count = 0; foreach ($this->city->getList($options) as $item) { $count++; $deleted += (int) $this->city->delete($item['city_id']); } $result = $count && $count == $deleted; } else { $result = $this->city->delete($id); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } $this->output(); }
[ "public", "function", "cmdDeleteCity", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "options", "=", "null", ";", "if", "(", "$", "this", "->", "getParam", "(", "'state'", ")", ")", "{", "$", "options", "=", "array", "(", "'state_id'", "=>", "$", "id", ")", ";", "}", "else", "if", "(", "$", "this", "->", "getParam", "(", "'country'", ")", ")", "{", "$", "options", "=", "array", "(", "'country'", "=>", "$", "id", ")", ";", "}", "if", "(", "isset", "(", "$", "options", ")", ")", "{", "$", "deleted", "=", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "city", "->", "getList", "(", "$", "options", ")", "as", "$", "item", ")", "{", "$", "count", "++", ";", "$", "deleted", "+=", "(", "int", ")", "$", "this", "->", "city", "->", "delete", "(", "$", "item", "[", "'city_id'", "]", ")", ";", "}", "$", "result", "=", "$", "count", "&&", "$", "count", "==", "$", "deleted", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "city", "->", "delete", "(", "$", "id", ")", ";", "}", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "city-delete" command
[ "Callback", "for", "city", "-", "delete", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/City.php#L51-L85
train
gplcart/cli
controllers/commands/City.php
City.cmdUpdateCity
public function cmdUpdateCity() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmitted('update', $params[0]); $this->validateComponent('city'); $this->updateCity($params[0]); $this->output(); }
php
public function cmdUpdateCity() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmitted('update', $params[0]); $this->validateComponent('city'); $this->updateCity($params[0]); $this->output(); }
[ "public", "function", "cmdUpdateCity", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getParam", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "0", "]", ")", "||", "count", "(", "$", "params", ")", "<", "2", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "params", "[", "0", "]", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "params", ")", ";", "$", "this", "->", "setSubmitted", "(", "'update'", ",", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "validateComponent", "(", "'city'", ")", ";", "$", "this", "->", "updateCity", "(", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "city-update" command
[ "Callback", "for", "city", "-", "update", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/City.php#L104-L122
train
gplcart/cli
controllers/commands/City.php
City.getListCity
protected function getListCity() { $id = $this->getParam(0); if (!isset($id)) { return $this->city->getList(array('limit' => $this->getLimit())); } if ($this->getParam('state')) { return $this->city->getList(array('state_id' => $id, 'limit' => $this->getLimit())); } if ($this->getParam('country')) { return $this->city->getList(array('country' => $id, 'limit' => $this->getLimit())); } if (!is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->city->get($id); if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } return array($result); }
php
protected function getListCity() { $id = $this->getParam(0); if (!isset($id)) { return $this->city->getList(array('limit' => $this->getLimit())); } if ($this->getParam('state')) { return $this->city->getList(array('state_id' => $id, 'limit' => $this->getLimit())); } if ($this->getParam('country')) { return $this->city->getList(array('country' => $id, 'limit' => $this->getLimit())); } if (!is_numeric($id)) { $this->errorAndExit($this->text('Invalid argument')); } $result = $this->city->get($id); if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } return array($result); }
[ "protected", "function", "getListCity", "(", ")", "{", "$", "id", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "if", "(", "!", "isset", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "city", "->", "getList", "(", "array", "(", "'limit'", "=>", "$", "this", "->", "getLimit", "(", ")", ")", ")", ";", "}", "if", "(", "$", "this", "->", "getParam", "(", "'state'", ")", ")", "{", "return", "$", "this", "->", "city", "->", "getList", "(", "array", "(", "'state_id'", "=>", "$", "id", ",", "'limit'", "=>", "$", "this", "->", "getLimit", "(", ")", ")", ")", ";", "}", "if", "(", "$", "this", "->", "getParam", "(", "'country'", ")", ")", "{", "return", "$", "this", "->", "city", "->", "getList", "(", "array", "(", "'country'", "=>", "$", "id", ",", "'limit'", "=>", "$", "this", "->", "getLimit", "(", ")", ")", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "result", "=", "$", "this", "->", "city", "->", "get", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "return", "array", "(", "$", "result", ")", ";", "}" ]
Returns an array of cities @return array
[ "Returns", "an", "array", "of", "cities" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/City.php#L128-L155
train
gplcart/cli
controllers/commands/City.php
City.addCity
protected function addCity() { if (!$this->isError()) { $id = $this->city->add($this->getSubmitted()); if (empty($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($id); } }
php
protected function addCity() { if (!$this->isError()) { $id = $this->city->add($this->getSubmitted()); if (empty($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($id); } }
[ "protected", "function", "addCity", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isError", "(", ")", ")", "{", "$", "id", "=", "$", "this", "->", "city", "->", "add", "(", "$", "this", "->", "getSubmitted", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "line", "(", "$", "id", ")", ";", "}", "}" ]
Add a new city
[ "Add", "a", "new", "city" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/City.php#L191-L200
train
gplcart/cli
controllers/commands/City.php
City.submitAddCity
protected function submitAddCity() { $this->setSubmitted(null, $this->getParam()); $this->validateComponent('city'); $this->addCity(); }
php
protected function submitAddCity() { $this->setSubmitted(null, $this->getParam()); $this->validateComponent('city'); $this->addCity(); }
[ "protected", "function", "submitAddCity", "(", ")", "{", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "this", "->", "getParam", "(", ")", ")", ";", "$", "this", "->", "validateComponent", "(", "'city'", ")", ";", "$", "this", "->", "addCity", "(", ")", ";", "}" ]
Add a new city at once
[ "Add", "a", "new", "city", "at", "once" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/City.php#L216-L221
train
gplcart/cli
controllers/commands/City.php
City.wizardAddCity
protected function wizardAddCity() { $this->validatePrompt('name', $this->text('Name'), 'city'); $this->validatePrompt('state_id', $this->text('Country state'), 'city'); $this->validatePrompt('country', $this->text('Country'), 'city'); $this->validatePrompt('zone_id', $this->text('Zone'), 'city', 0); $this->validatePrompt('status', $this->text('Status'), 'city', 0); $this->validateComponent('city'); $this->addCity(); }
php
protected function wizardAddCity() { $this->validatePrompt('name', $this->text('Name'), 'city'); $this->validatePrompt('state_id', $this->text('Country state'), 'city'); $this->validatePrompt('country', $this->text('Country'), 'city'); $this->validatePrompt('zone_id', $this->text('Zone'), 'city', 0); $this->validatePrompt('status', $this->text('Status'), 'city', 0); $this->validateComponent('city'); $this->addCity(); }
[ "protected", "function", "wizardAddCity", "(", ")", "{", "$", "this", "->", "validatePrompt", "(", "'name'", ",", "$", "this", "->", "text", "(", "'Name'", ")", ",", "'city'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'state_id'", ",", "$", "this", "->", "text", "(", "'Country state'", ")", ",", "'city'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'country'", ",", "$", "this", "->", "text", "(", "'Country'", ")", ",", "'city'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'zone_id'", ",", "$", "this", "->", "text", "(", "'Zone'", ")", ",", "'city'", ",", "0", ")", ";", "$", "this", "->", "validatePrompt", "(", "'status'", ",", "$", "this", "->", "text", "(", "'Status'", ")", ",", "'city'", ",", "0", ")", ";", "$", "this", "->", "validateComponent", "(", "'city'", ")", ";", "$", "this", "->", "addCity", "(", ")", ";", "}" ]
Add a new city step by step
[ "Add", "a", "new", "city", "step", "by", "step" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/City.php#L226-L236
train
covex-nn/JooS_Stream
src/JooS/Stream/Wrapper/FS.php
Wrapper_FS.commit
public static function commit($protocol) { if (isset(self::$_partitions[$protocol])) { $partition = self::$_partitions[$protocol]; /* @var $partition Wrapper_FS_Partition */ $partition->commit(); $result = true; } else { $result = false; } return $result; }
php
public static function commit($protocol) { if (isset(self::$_partitions[$protocol])) { $partition = self::$_partitions[$protocol]; /* @var $partition Wrapper_FS_Partition */ $partition->commit(); $result = true; } else { $result = false; } return $result; }
[ "public", "static", "function", "commit", "(", "$", "protocol", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "_partitions", "[", "$", "protocol", "]", ")", ")", "{", "$", "partition", "=", "self", "::", "$", "_partitions", "[", "$", "protocol", "]", ";", "/* @var $partition Wrapper_FS_Partition */", "$", "partition", "->", "commit", "(", ")", ";", "$", "result", "=", "true", ";", "}", "else", "{", "$", "result", "=", "false", ";", "}", "return", "$", "result", ";", "}" ]
Commit all changes to real FS @param string $protocol Protocol name @return boolean
[ "Commit", "all", "changes", "to", "real", "FS" ]
e9841b804190a9f624b9e44caa0af7a18f3816d1
https://github.com/covex-nn/JooS_Stream/blob/e9841b804190a9f624b9e44caa0af7a18f3816d1/src/JooS/Stream/Wrapper/FS.php#L355-L368
train
covex-nn/JooS_Stream
src/JooS/Stream/Wrapper/FS.php
Wrapper_FS.getPartition
protected static function getPartition($url) { $urlParts = explode("://", $url); $protocol = array_shift($urlParts); return self::$_partitions[$protocol]; }
php
protected static function getPartition($url) { $urlParts = explode("://", $url); $protocol = array_shift($urlParts); return self::$_partitions[$protocol]; }
[ "protected", "static", "function", "getPartition", "(", "$", "url", ")", "{", "$", "urlParts", "=", "explode", "(", "\"://\"", ",", "$", "url", ")", ";", "$", "protocol", "=", "array_shift", "(", "$", "urlParts", ")", ";", "return", "self", "::", "$", "_partitions", "[", "$", "protocol", "]", ";", "}" ]
Return partition by file url @param string $url Url @return Wrapper_FS_Partition
[ "Return", "partition", "by", "file", "url" ]
e9841b804190a9f624b9e44caa0af7a18f3816d1
https://github.com/covex-nn/JooS_Stream/blob/e9841b804190a9f624b9e44caa0af7a18f3816d1/src/JooS/Stream/Wrapper/FS.php#L391-L397
train
covex-nn/JooS_Stream
src/JooS/Stream/Wrapper/FS.php
Wrapper_FS.getRelativePath
public static function getRelativePath($url) { $urlParts = explode("://", $url); array_shift($urlParts); $urlPath = implode("://", $urlParts); return Entity::fixPath($urlPath); }
php
public static function getRelativePath($url) { $urlParts = explode("://", $url); array_shift($urlParts); $urlPath = implode("://", $urlParts); return Entity::fixPath($urlPath); }
[ "public", "static", "function", "getRelativePath", "(", "$", "url", ")", "{", "$", "urlParts", "=", "explode", "(", "\"://\"", ",", "$", "url", ")", ";", "array_shift", "(", "$", "urlParts", ")", ";", "$", "urlPath", "=", "implode", "(", "\"://\"", ",", "$", "urlParts", ")", ";", "return", "Entity", "::", "fixPath", "(", "$", "urlPath", ")", ";", "}" ]
Return urlPath of url @param string $url Url @return string
[ "Return", "urlPath", "of", "url" ]
e9841b804190a9f624b9e44caa0af7a18f3816d1
https://github.com/covex-nn/JooS_Stream/blob/e9841b804190a9f624b9e44caa0af7a18f3816d1/src/JooS/Stream/Wrapper/FS.php#L406-L413
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.create
public function create($options = []) { $capsule = $this->_database->getCapsule(); if (empty($options) || !is_array($options)) { throw new \Exception('Create options must not be empty and must be an instance of an array!'); } // filter out options not given in fillable array $this->filter($options); $options['created_at'] = date('Y-m-d h:i:s'); $options['updated_at'] = $options['created_at']; if ($capsule->table($this->table)->insert($options)) { return true; } else { return false; } }
php
public function create($options = []) { $capsule = $this->_database->getCapsule(); if (empty($options) || !is_array($options)) { throw new \Exception('Create options must not be empty and must be an instance of an array!'); } // filter out options not given in fillable array $this->filter($options); $options['created_at'] = date('Y-m-d h:i:s'); $options['updated_at'] = $options['created_at']; if ($capsule->table($this->table)->insert($options)) { return true; } else { return false; } }
[ "public", "function", "create", "(", "$", "options", "=", "[", "]", ")", "{", "$", "capsule", "=", "$", "this", "->", "_database", "->", "getCapsule", "(", ")", ";", "if", "(", "empty", "(", "$", "options", ")", "||", "!", "is_array", "(", "$", "options", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Create options must not be empty and must be an instance of an array!'", ")", ";", "}", "// filter out options not given in fillable array", "$", "this", "->", "filter", "(", "$", "options", ")", ";", "$", "options", "[", "'created_at'", "]", "=", "date", "(", "'Y-m-d h:i:s'", ")", ";", "$", "options", "[", "'updated_at'", "]", "=", "$", "options", "[", "'created_at'", "]", ";", "if", "(", "$", "capsule", "->", "table", "(", "$", "this", "->", "table", ")", "->", "insert", "(", "$", "options", ")", ")", "{", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Creates a new table row. @return bool
[ "Creates", "a", "new", "table", "row", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L79-L97
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.find
public function find($id) { $capsule = $this->_database->getCapsule(); $this->_model = $capsule->table($this->table)->where('id', '=', $id); return $this->_model->first(); }
php
public function find($id) { $capsule = $this->_database->getCapsule(); $this->_model = $capsule->table($this->table)->where('id', '=', $id); return $this->_model->first(); }
[ "public", "function", "find", "(", "$", "id", ")", "{", "$", "capsule", "=", "$", "this", "->", "_database", "->", "getCapsule", "(", ")", ";", "$", "this", "->", "_model", "=", "$", "capsule", "->", "table", "(", "$", "this", "->", "table", ")", "->", "where", "(", "'id'", ",", "'='", ",", "$", "id", ")", ";", "return", "$", "this", "->", "_model", "->", "first", "(", ")", ";", "}" ]
Finds an item by it's id. @param int $id @return stdClass
[ "Finds", "an", "item", "by", "it", "s", "id", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L120-L127
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.where
public function where($column, $operator, $value) { $capsule = $this->_database->getCapsule(); if (empty($column)) { throw new \Exception('You must provide the column to look up!'); } if (empty($operator)) { throw new \Exception('You must provide an operator!'); } if (empty($value)) { throw new \Exception('You must provide the value!'); } $this->_model = $capsule->table($this->table)->where($column, $operator, $value); return $this->_model; }
php
public function where($column, $operator, $value) { $capsule = $this->_database->getCapsule(); if (empty($column)) { throw new \Exception('You must provide the column to look up!'); } if (empty($operator)) { throw new \Exception('You must provide an operator!'); } if (empty($value)) { throw new \Exception('You must provide the value!'); } $this->_model = $capsule->table($this->table)->where($column, $operator, $value); return $this->_model; }
[ "public", "function", "where", "(", "$", "column", ",", "$", "operator", ",", "$", "value", ")", "{", "$", "capsule", "=", "$", "this", "->", "_database", "->", "getCapsule", "(", ")", ";", "if", "(", "empty", "(", "$", "column", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'You must provide the column to look up!'", ")", ";", "}", "if", "(", "empty", "(", "$", "operator", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'You must provide an operator!'", ")", ";", "}", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'You must provide the value!'", ")", ";", "}", "$", "this", "->", "_model", "=", "$", "capsule", "->", "table", "(", "$", "this", "->", "table", ")", "->", "where", "(", "$", "column", ",", "$", "operator", ",", "$", "value", ")", ";", "return", "$", "this", "->", "_model", ";", "}" ]
Searches for something in the database. @param string $column - The column to search @param string $operator - The operator for searching with @param string $value - The value you're looking for @return \Illuminate\Database\Query\Builder
[ "Searches", "for", "something", "in", "the", "database", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L138-L155
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.count
public function count() { if (is_array($this->_model)) { return count($this->_model); } else { return $this->_model->count(); } }
php
public function count() { if (is_array($this->_model)) { return count($this->_model); } else { return $this->_model->count(); } }
[ "public", "function", "count", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_model", ")", ")", "{", "return", "count", "(", "$", "this", "->", "_model", ")", ";", "}", "else", "{", "return", "$", "this", "->", "_model", "->", "count", "(", ")", ";", "}", "}" ]
Gets the number of results. @return int
[ "Gets", "the", "number", "of", "results", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L162-L169
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.all
public function all($order = 'ASC') { $capsule = $this->_database->getCapsule(); $this->_model = $capsule->table($this->table)->orderBy('id', $order)->get(); return $this->_model; }
php
public function all($order = 'ASC') { $capsule = $this->_database->getCapsule(); $this->_model = $capsule->table($this->table)->orderBy('id', $order)->get(); return $this->_model; }
[ "public", "function", "all", "(", "$", "order", "=", "'ASC'", ")", "{", "$", "capsule", "=", "$", "this", "->", "_database", "->", "getCapsule", "(", ")", ";", "$", "this", "->", "_model", "=", "$", "capsule", "->", "table", "(", "$", "this", "->", "table", ")", "->", "orderBy", "(", "'id'", ",", "$", "order", ")", "->", "get", "(", ")", ";", "return", "$", "this", "->", "_model", ";", "}" ]
Gets all results from the database. @param string $order - The order of the results @return \Illuminate\Database\Query\Builder
[ "Gets", "all", "results", "from", "the", "database", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L178-L185
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.select
public function select($capsule = null, $limit = null, $offset = null, $columns = []) { if (is_null($capsule)) { $capsule = $this->_database->getCapsule()->table($this->table); } if (empty($columns)) { $columns = '*'; } else { $cstring = ''; foreach ($columns as $column) { $cstring .= "{$column}, "; } $columns = rtrim($cstring, ', '); } $sql = $capsule->select("{$columns}"); if (!is_null($limit)) { $sql->limit($limit); } if (!is_null($offset)) { $sql->offset($offset); } return $sql; }
php
public function select($capsule = null, $limit = null, $offset = null, $columns = []) { if (is_null($capsule)) { $capsule = $this->_database->getCapsule()->table($this->table); } if (empty($columns)) { $columns = '*'; } else { $cstring = ''; foreach ($columns as $column) { $cstring .= "{$column}, "; } $columns = rtrim($cstring, ', '); } $sql = $capsule->select("{$columns}"); if (!is_null($limit)) { $sql->limit($limit); } if (!is_null($offset)) { $sql->offset($offset); } return $sql; }
[ "public", "function", "select", "(", "$", "capsule", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "offset", "=", "null", ",", "$", "columns", "=", "[", "]", ")", "{", "if", "(", "is_null", "(", "$", "capsule", ")", ")", "{", "$", "capsule", "=", "$", "this", "->", "_database", "->", "getCapsule", "(", ")", "->", "table", "(", "$", "this", "->", "table", ")", ";", "}", "if", "(", "empty", "(", "$", "columns", ")", ")", "{", "$", "columns", "=", "'*'", ";", "}", "else", "{", "$", "cstring", "=", "''", ";", "foreach", "(", "$", "columns", "as", "$", "column", ")", "{", "$", "cstring", ".=", "\"{$column}, \"", ";", "}", "$", "columns", "=", "rtrim", "(", "$", "cstring", ",", "', '", ")", ";", "}", "$", "sql", "=", "$", "capsule", "->", "select", "(", "\"{$columns}\"", ")", ";", "if", "(", "!", "is_null", "(", "$", "limit", ")", ")", "{", "$", "sql", "->", "limit", "(", "$", "limit", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "offset", ")", ")", "{", "$", "sql", "->", "offset", "(", "$", "offset", ")", ";", "}", "return", "$", "sql", ";", "}" ]
Selects from the database table via custom SQL command. @param \Illuminate\Database\Query\Builder $capsule - Capsule instance @param int $limit - Selection limit @param int $offset - Selection offset @param array $columns - Columns to select from @return \Illuminate\Database\Query\Builder
[ "Selects", "from", "the", "database", "table", "via", "custom", "SQL", "command", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L197-L222
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.paginate
public function paginate($limit) { $capsule = $this->_database->getCapsule(); $this->_model = $capsule->table($this->table); $paginator = new Pagination(); $paginator->setLimit($limit)->setModel($this, $this->_model); return $paginator->paginate(); }
php
public function paginate($limit) { $capsule = $this->_database->getCapsule(); $this->_model = $capsule->table($this->table); $paginator = new Pagination(); $paginator->setLimit($limit)->setModel($this, $this->_model); return $paginator->paginate(); }
[ "public", "function", "paginate", "(", "$", "limit", ")", "{", "$", "capsule", "=", "$", "this", "->", "_database", "->", "getCapsule", "(", ")", ";", "$", "this", "->", "_model", "=", "$", "capsule", "->", "table", "(", "$", "this", "->", "table", ")", ";", "$", "paginator", "=", "new", "Pagination", "(", ")", ";", "$", "paginator", "->", "setLimit", "(", "$", "limit", ")", "->", "setModel", "(", "$", "this", ",", "$", "this", "->", "_model", ")", ";", "return", "$", "paginator", "->", "paginate", "(", ")", ";", "}" ]
Does like all, but creates pagination for results. @param int $limit - The number of results to limit by @return \Scara\Pagination\Pagination
[ "Does", "like", "all", "but", "creates", "pagination", "for", "results", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L231-L239
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.save
public function save($options) { $gcc = get_called_class(); $class = $gcc::init(); $cap = $this->_database->getCapsule(); $params = (array) $options; $this->filter($params); return $cap->table($this->table)->update($params); }
php
public function save($options) { $gcc = get_called_class(); $class = $gcc::init(); $cap = $this->_database->getCapsule(); $params = (array) $options; $this->filter($params); return $cap->table($this->table)->update($params); }
[ "public", "function", "save", "(", "$", "options", ")", "{", "$", "gcc", "=", "get_called_class", "(", ")", ";", "$", "class", "=", "$", "gcc", "::", "init", "(", ")", ";", "$", "cap", "=", "$", "this", "->", "_database", "->", "getCapsule", "(", ")", ";", "$", "params", "=", "(", "array", ")", "$", "options", ";", "$", "this", "->", "filter", "(", "$", "params", ")", ";", "return", "$", "cap", "->", "table", "(", "$", "this", "->", "table", ")", "->", "update", "(", "$", "params", ")", ";", "}" ]
Saves changes to a model. @param mixed $options @return bool
[ "Saves", "changes", "to", "a", "model", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L248-L257
train
ScaraMVC/Framework
src/Scara/Http/Model.php
Model.filter
private function filter(&$options) { foreach ($options as $key => $value) { if (!in_array($key, $this->fillable)) { unset($options[$key]); } } }
php
private function filter(&$options) { foreach ($options as $key => $value) { if (!in_array($key, $this->fillable)) { unset($options[$key]); } } }
[ "private", "function", "filter", "(", "&", "$", "options", ")", "{", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "$", "this", "->", "fillable", ")", ")", "{", "unset", "(", "$", "options", "[", "$", "key", "]", ")", ";", "}", "}", "}" ]
Filters out options that are not included in a model's fillable array. @param array &$options - Options array reference @return void
[ "Filters", "out", "options", "that", "are", "not", "included", "in", "a", "model", "s", "fillable", "array", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Http/Model.php#L278-L285
train
DreadLabs/VantomasWebsite
src/Disqus/Resource.php
Resource.parseResourceSignature
protected function parseResourceSignature() { list($topic, $actionAndFormat) = explode('/', $this->signature); list($action, $format) = explode('.', $actionAndFormat); $this->topic = ucfirst($topic); $this->action = ucfirst($action); $this->format = $format; }
php
protected function parseResourceSignature() { list($topic, $actionAndFormat) = explode('/', $this->signature); list($action, $format) = explode('.', $actionAndFormat); $this->topic = ucfirst($topic); $this->action = ucfirst($action); $this->format = $format; }
[ "protected", "function", "parseResourceSignature", "(", ")", "{", "list", "(", "$", "topic", ",", "$", "actionAndFormat", ")", "=", "explode", "(", "'/'", ",", "$", "this", "->", "signature", ")", ";", "list", "(", "$", "action", ",", "$", "format", ")", "=", "explode", "(", "'.'", ",", "$", "actionAndFormat", ")", ";", "$", "this", "->", "topic", "=", "ucfirst", "(", "$", "topic", ")", ";", "$", "this", "->", "action", "=", "ucfirst", "(", "$", "action", ")", ";", "$", "this", "->", "format", "=", "$", "format", ";", "}" ]
parses a resource signature The format must be something like foo/bar.json @return void
[ "parses", "a", "resource", "signature" ]
7f85f2b45bdf5ed9fa9d320c805c416bf99cd668
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/Disqus/Resource.php#L106-L114
train
DreadLabs/VantomasWebsite
src/Disqus/Resource.php
Resource.initializeConcreteResource
protected function initializeConcreteResource() { $this->concreteResource = $this->resourceResolver->resolve($this->topic, $this->action); }
php
protected function initializeConcreteResource() { $this->concreteResource = $this->resourceResolver->resolve($this->topic, $this->action); }
[ "protected", "function", "initializeConcreteResource", "(", ")", "{", "$", "this", "->", "concreteResource", "=", "$", "this", "->", "resourceResolver", "->", "resolve", "(", "$", "this", "->", "topic", ",", "$", "this", "->", "action", ")", ";", "}" ]
initializes a concrete resource implementation @return void
[ "initializes", "a", "concrete", "resource", "implementation" ]
7f85f2b45bdf5ed9fa9d320c805c416bf99cd668
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/Disqus/Resource.php#L121-L124
train
EXSyst/IO
StringSourceState.php
StringSourceState.restore
public function restore() { $this->offsetRef = $this->offset; $this->lineRef = $this->line; $this->rowRef = $this->row; }
php
public function restore() { $this->offsetRef = $this->offset; $this->lineRef = $this->line; $this->rowRef = $this->row; }
[ "public", "function", "restore", "(", ")", "{", "$", "this", "->", "offsetRef", "=", "$", "this", "->", "offset", ";", "$", "this", "->", "lineRef", "=", "$", "this", "->", "line", ";", "$", "this", "->", "rowRef", "=", "$", "this", "->", "row", ";", "}" ]
Restores the source to which this state belongs to this state.
[ "Restores", "the", "source", "to", "which", "this", "state", "belongs", "to", "this", "state", "." ]
4c30ba79b09d2cc41d0a7cd340255a87cac54326
https://github.com/EXSyst/IO/blob/4c30ba79b09d2cc41d0a7cd340255a87cac54326/StringSourceState.php#L48-L53
train
Facebook-Anonymous-Publisher/wordfilter
src/Replace/Chinese.php
Chinese.replace
public static function replace(array $words, $replacement, $text) { $self = new self; $length = $self->wordsLength($words); $blocks = array_unique($length); $min = end($blocks); $chars = $self->splitText($text); $index = $self->index($chars); $pinyins = $self->pinyin->convert($text); $len = count($pinyins) - $min + 1; for ($i = 0; $i < $len; ++$i) { foreach ($blocks as $block) { if ($i + $block >= $len + $min) { continue; } $hash = md5(implode(' ', array_slice($pinyins, $i, $block))); if (isset($length[$hash])) { for ($c = 0; $c < $block; ++$c) { $chars[$index[$i + $c]] = $replacement; } $i += $block - 1; break; } } } return implode('', $chars); }
php
public static function replace(array $words, $replacement, $text) { $self = new self; $length = $self->wordsLength($words); $blocks = array_unique($length); $min = end($blocks); $chars = $self->splitText($text); $index = $self->index($chars); $pinyins = $self->pinyin->convert($text); $len = count($pinyins) - $min + 1; for ($i = 0; $i < $len; ++$i) { foreach ($blocks as $block) { if ($i + $block >= $len + $min) { continue; } $hash = md5(implode(' ', array_slice($pinyins, $i, $block))); if (isset($length[$hash])) { for ($c = 0; $c < $block; ++$c) { $chars[$index[$i + $c]] = $replacement; } $i += $block - 1; break; } } } return implode('', $chars); }
[ "public", "static", "function", "replace", "(", "array", "$", "words", ",", "$", "replacement", ",", "$", "text", ")", "{", "$", "self", "=", "new", "self", ";", "$", "length", "=", "$", "self", "->", "wordsLength", "(", "$", "words", ")", ";", "$", "blocks", "=", "array_unique", "(", "$", "length", ")", ";", "$", "min", "=", "end", "(", "$", "blocks", ")", ";", "$", "chars", "=", "$", "self", "->", "splitText", "(", "$", "text", ")", ";", "$", "index", "=", "$", "self", "->", "index", "(", "$", "chars", ")", ";", "$", "pinyins", "=", "$", "self", "->", "pinyin", "->", "convert", "(", "$", "text", ")", ";", "$", "len", "=", "count", "(", "$", "pinyins", ")", "-", "$", "min", "+", "1", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "len", ";", "++", "$", "i", ")", "{", "foreach", "(", "$", "blocks", "as", "$", "block", ")", "{", "if", "(", "$", "i", "+", "$", "block", ">=", "$", "len", "+", "$", "min", ")", "{", "continue", ";", "}", "$", "hash", "=", "md5", "(", "implode", "(", "' '", ",", "array_slice", "(", "$", "pinyins", ",", "$", "i", ",", "$", "block", ")", ")", ")", ";", "if", "(", "isset", "(", "$", "length", "[", "$", "hash", "]", ")", ")", "{", "for", "(", "$", "c", "=", "0", ";", "$", "c", "<", "$", "block", ";", "++", "$", "c", ")", "{", "$", "chars", "[", "$", "index", "[", "$", "i", "+", "$", "c", "]", "]", "=", "$", "replacement", ";", "}", "$", "i", "+=", "$", "block", "-", "1", ";", "break", ";", "}", "}", "}", "return", "implode", "(", "''", ",", "$", "chars", ")", ";", "}" ]
Replace words with replacements in a text. @param array $words @param string $replacement @param string $text @return string
[ "Replace", "words", "with", "replacements", "in", "a", "text", "." ]
0a2ce766a509650ac622eeaa809391ebf304885e
https://github.com/Facebook-Anonymous-Publisher/wordfilter/blob/0a2ce766a509650ac622eeaa809391ebf304885e/src/Replace/Chinese.php#L46-L85
train
Facebook-Anonymous-Publisher/wordfilter
src/Replace/Chinese.php
Chinese.wordsLength
protected function wordsLength(array $words) { $length = []; foreach ($words as $word) { $pinyin = $this->pinyin->sentence($word); $length[md5($pinyin)] = ($pinyin === $word) ? 1 : mb_strlen($word); } arsort($length); return $length; }
php
protected function wordsLength(array $words) { $length = []; foreach ($words as $word) { $pinyin = $this->pinyin->sentence($word); $length[md5($pinyin)] = ($pinyin === $word) ? 1 : mb_strlen($word); } arsort($length); return $length; }
[ "protected", "function", "wordsLength", "(", "array", "$", "words", ")", "{", "$", "length", "=", "[", "]", ";", "foreach", "(", "$", "words", "as", "$", "word", ")", "{", "$", "pinyin", "=", "$", "this", "->", "pinyin", "->", "sentence", "(", "$", "word", ")", ";", "$", "length", "[", "md5", "(", "$", "pinyin", ")", "]", "=", "(", "$", "pinyin", "===", "$", "word", ")", "?", "1", ":", "mb_strlen", "(", "$", "word", ")", ";", "}", "arsort", "(", "$", "length", ")", ";", "return", "$", "length", ";", "}" ]
Get echo word length and use md5 as key. @param array $words @return array
[ "Get", "echo", "word", "length", "and", "use", "md5", "as", "key", "." ]
0a2ce766a509650ac622eeaa809391ebf304885e
https://github.com/Facebook-Anonymous-Publisher/wordfilter/blob/0a2ce766a509650ac622eeaa809391ebf304885e/src/Replace/Chinese.php#L94-L109
train
Facebook-Anonymous-Publisher/wordfilter
src/Replace/Chinese.php
Chinese.splitText
protected function splitText($text) { $punctuations = preg_quote(implode('', $this->punctuations), '/'); $text = preg_replace('/([^\p{Han}\s'.$punctuations.']+)/u', "\t\t\t$1\t\t", $text); $array = []; foreach (preg_split('/\t\t/u', $text, -1, PREG_SPLIT_NO_EMPTY) as $item) { $array[] = ("\t" === $item[0]) ? substr($item, 1) : preg_split('//u', $item, -1, PREG_SPLIT_NO_EMPTY); } return $this->flatten($array); }
php
protected function splitText($text) { $punctuations = preg_quote(implode('', $this->punctuations), '/'); $text = preg_replace('/([^\p{Han}\s'.$punctuations.']+)/u', "\t\t\t$1\t\t", $text); $array = []; foreach (preg_split('/\t\t/u', $text, -1, PREG_SPLIT_NO_EMPTY) as $item) { $array[] = ("\t" === $item[0]) ? substr($item, 1) : preg_split('//u', $item, -1, PREG_SPLIT_NO_EMPTY); } return $this->flatten($array); }
[ "protected", "function", "splitText", "(", "$", "text", ")", "{", "$", "punctuations", "=", "preg_quote", "(", "implode", "(", "''", ",", "$", "this", "->", "punctuations", ")", ",", "'/'", ")", ";", "$", "text", "=", "preg_replace", "(", "'/([^\\p{Han}\\s'", ".", "$", "punctuations", ".", "']+)/u'", ",", "\"\\t\\t\\t$1\\t\\t\"", ",", "$", "text", ")", ";", "$", "array", "=", "[", "]", ";", "foreach", "(", "preg_split", "(", "'/\\t\\t/u'", ",", "$", "text", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", "as", "$", "item", ")", "{", "$", "array", "[", "]", "=", "(", "\"\\t\"", "===", "$", "item", "[", "0", "]", ")", "?", "substr", "(", "$", "item", ",", "1", ")", ":", "preg_split", "(", "'//u'", ",", "$", "item", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "}", "return", "$", "this", "->", "flatten", "(", "$", "array", ")", ";", "}" ]
Spilt text to array. @param string $text @return array
[ "Spilt", "text", "to", "array", "." ]
0a2ce766a509650ac622eeaa809391ebf304885e
https://github.com/Facebook-Anonymous-Publisher/wordfilter/blob/0a2ce766a509650ac622eeaa809391ebf304885e/src/Replace/Chinese.php#L118-L133
train
Facebook-Anonymous-Publisher/wordfilter
src/Replace/Chinese.php
Chinese.index
protected function index(array $chars) { $index = []; foreach ($chars as $key => $char) { if (preg_match('/[\p{Han}\w]+/u', $char)) { $index[] = $key; } } return $index; }
php
protected function index(array $chars) { $index = []; foreach ($chars as $key => $char) { if (preg_match('/[\p{Han}\w]+/u', $char)) { $index[] = $key; } } return $index; }
[ "protected", "function", "index", "(", "array", "$", "chars", ")", "{", "$", "index", "=", "[", "]", ";", "foreach", "(", "$", "chars", "as", "$", "key", "=>", "$", "char", ")", "{", "if", "(", "preg_match", "(", "'/[\\p{Han}\\w]+/u'", ",", "$", "char", ")", ")", "{", "$", "index", "[", "]", "=", "$", "key", ";", "}", "}", "return", "$", "index", ";", "}" ]
Build words index. @param array $chars @return array
[ "Build", "words", "index", "." ]
0a2ce766a509650ac622eeaa809391ebf304885e
https://github.com/Facebook-Anonymous-Publisher/wordfilter/blob/0a2ce766a509650ac622eeaa809391ebf304885e/src/Replace/Chinese.php#L160-L171
train
ekyna/Table
Http/ParametersHelper.php
ParametersHelper.setData
public function setData(array $data = []) { $this->default = empty($data); $this->data = array_replace([ static::VISIBLE_COLUMNS => [], static::MAX_PER_PAGE => null, static::CONFIG => null, static::PAGE_NUM => null, static::SORT => null, static::ADD_FILTER => null, static::REMOVE_FILTER => null, static::IDENTIFIERS => [], static::ALL => null, static::BATCH => null, static::ACTION => null, static::EXPORT => null, static::FORMAT => null, static::PROFILE => [], ], $data); }
php
public function setData(array $data = []) { $this->default = empty($data); $this->data = array_replace([ static::VISIBLE_COLUMNS => [], static::MAX_PER_PAGE => null, static::CONFIG => null, static::PAGE_NUM => null, static::SORT => null, static::ADD_FILTER => null, static::REMOVE_FILTER => null, static::IDENTIFIERS => [], static::ALL => null, static::BATCH => null, static::ACTION => null, static::EXPORT => null, static::FORMAT => null, static::PROFILE => [], ], $data); }
[ "public", "function", "setData", "(", "array", "$", "data", "=", "[", "]", ")", "{", "$", "this", "->", "default", "=", "empty", "(", "$", "data", ")", ";", "$", "this", "->", "data", "=", "array_replace", "(", "[", "static", "::", "VISIBLE_COLUMNS", "=>", "[", "]", ",", "static", "::", "MAX_PER_PAGE", "=>", "null", ",", "static", "::", "CONFIG", "=>", "null", ",", "static", "::", "PAGE_NUM", "=>", "null", ",", "static", "::", "SORT", "=>", "null", ",", "static", "::", "ADD_FILTER", "=>", "null", ",", "static", "::", "REMOVE_FILTER", "=>", "null", ",", "static", "::", "IDENTIFIERS", "=>", "[", "]", ",", "static", "::", "ALL", "=>", "null", ",", "static", "::", "BATCH", "=>", "null", ",", "static", "::", "ACTION", "=>", "null", ",", "static", "::", "EXPORT", "=>", "null", ",", "static", "::", "FORMAT", "=>", "null", ",", "static", "::", "PROFILE", "=>", "[", "]", ",", "]", ",", "$", "data", ")", ";", "}" ]
Sets the data. @param array $data
[ "Sets", "the", "data", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Http/ParametersHelper.php#L74-L94
train
ekyna/Table
Http/ParametersHelper.php
ParametersHelper.getSortHref
public function getSortHref(ColumnInterface $column) { $parameter = $this->getSortName(); $dir = ($column->getSortDirection() === ColumnSort::ASC ? ColumnSort::DESC : ColumnSort::ASC); return '?' . $parameter . '[by]=' . $column->getName() . '&' . $parameter . '[dir]=' . $dir; }
php
public function getSortHref(ColumnInterface $column) { $parameter = $this->getSortName(); $dir = ($column->getSortDirection() === ColumnSort::ASC ? ColumnSort::DESC : ColumnSort::ASC); return '?' . $parameter . '[by]=' . $column->getName() . '&' . $parameter . '[dir]=' . $dir; }
[ "public", "function", "getSortHref", "(", "ColumnInterface", "$", "column", ")", "{", "$", "parameter", "=", "$", "this", "->", "getSortName", "(", ")", ";", "$", "dir", "=", "(", "$", "column", "->", "getSortDirection", "(", ")", "===", "ColumnSort", "::", "ASC", "?", "ColumnSort", "::", "DESC", ":", "ColumnSort", "::", "ASC", ")", ";", "return", "'?'", ".", "$", "parameter", ".", "'[by]='", ".", "$", "column", "->", "getName", "(", ")", ".", "'&'", ".", "$", "parameter", ".", "'[dir]='", ".", "$", "dir", ";", "}" ]
Returns the sort column href. @param ColumnInterface $column @return string
[ "Returns", "the", "sort", "column", "href", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Http/ParametersHelper.php#L213-L219
train
ekyna/Table
Http/ParametersHelper.php
ParametersHelper.getIdentifiersName
public function getIdentifiersName() { $name = $this->tableName . '[' . static::IDENTIFIERS . ']'; if ($this->selectionMode == Config::SELECTION_MULTIPLE) { $name .= '[]'; } return $name; }
php
public function getIdentifiersName() { $name = $this->tableName . '[' . static::IDENTIFIERS . ']'; if ($this->selectionMode == Config::SELECTION_MULTIPLE) { $name .= '[]'; } return $name; }
[ "public", "function", "getIdentifiersName", "(", ")", "{", "$", "name", "=", "$", "this", "->", "tableName", ".", "'['", ".", "static", "::", "IDENTIFIERS", ".", "']'", ";", "if", "(", "$", "this", "->", "selectionMode", "==", "Config", "::", "SELECTION_MULTIPLE", ")", "{", "$", "name", ".=", "'[]'", ";", "}", "return", "$", "name", ";", "}" ]
Returns the identifiers parameter name. @return string
[ "Returns", "the", "identifiers", "parameter", "name", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Http/ParametersHelper.php#L290-L299
train
ekyna/Table
Http/ParametersHelper.php
ParametersHelper.getProfileValue
private function getProfileValue($name) { if (isset($this->data[static::PROFILE][$name])) { return $this->data[static::PROFILE][$name]; } return null; }
php
private function getProfileValue($name) { if (isset($this->data[static::PROFILE][$name])) { return $this->data[static::PROFILE][$name]; } return null; }
[ "private", "function", "getProfileValue", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "static", "::", "PROFILE", "]", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "data", "[", "static", "::", "PROFILE", "]", "[", "$", "name", "]", ";", "}", "return", "null", ";", "}" ]
Returns the profile parameter value. @param string $name The profile parameter name @return string|null
[ "Returns", "the", "profile", "parameter", "value", "." ]
6f06e8fd8a3248d52f3a91f10508471344db311a
https://github.com/ekyna/Table/blob/6f06e8fd8a3248d52f3a91f10508471344db311a/Http/ParametersHelper.php#L551-L558
train
locomotivemtl/charcoal-config
src/Charcoal/Config/AbstractConfig.php
AbstractConfig.offsetExists
public function offsetExists($key) { if (is_numeric($key)) { throw new InvalidArgumentException( 'Entity array access only supports non-numeric keys' ); } if ($this->separator && strstr($key, $this->separator)) { return $this->hasWithSeparator($key); } $key = $this->camelize($key); /** @internal Edge Case: "_" → "" */ if ($key === '') { return false; } if (is_callable([ $this, $key ])) { $value = $this->{$key}(); } else { if (!isset($this->{$key})) { return $this->hasInDelegates($key); } $value = $this->{$key}; } return ($value !== null); }
php
public function offsetExists($key) { if (is_numeric($key)) { throw new InvalidArgumentException( 'Entity array access only supports non-numeric keys' ); } if ($this->separator && strstr($key, $this->separator)) { return $this->hasWithSeparator($key); } $key = $this->camelize($key); /** @internal Edge Case: "_" → "" */ if ($key === '') { return false; } if (is_callable([ $this, $key ])) { $value = $this->{$key}(); } else { if (!isset($this->{$key})) { return $this->hasInDelegates($key); } $value = $this->{$key}; } return ($value !== null); }
[ "public", "function", "offsetExists", "(", "$", "key", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Entity array access only supports non-numeric keys'", ")", ";", "}", "if", "(", "$", "this", "->", "separator", "&&", "strstr", "(", "$", "key", ",", "$", "this", "->", "separator", ")", ")", "{", "return", "$", "this", "->", "hasWithSeparator", "(", "$", "key", ")", ";", "}", "$", "key", "=", "$", "this", "->", "camelize", "(", "$", "key", ")", ";", "/** @internal Edge Case: \"_\" → \"\" */", "if", "(", "$", "key", "===", "''", ")", "{", "return", "false", ";", "}", "if", "(", "is_callable", "(", "[", "$", "this", ",", "$", "key", "]", ")", ")", "{", "$", "value", "=", "$", "this", "->", "{", "$", "key", "}", "(", ")", ";", "}", "else", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "{", "$", "key", "}", ")", ")", "{", "return", "$", "this", "->", "hasInDelegates", "(", "$", "key", ")", ";", "}", "$", "value", "=", "$", "this", "->", "{", "$", "key", "}", ";", "}", "return", "(", "$", "value", "!==", "null", ")", ";", "}" ]
Determines if this store contains the specified key and if its value is not NULL. Routine: - If the data key is {@see SeparatorAwareTrait::$separator nested}, the data-tree is traversed until the endpoint is found, if any; - If the data key does NOT exist on the store, a lookup is performed on each delegate store until a key is found, if any. @see \ArrayAccess @uses SeparatorAwareTrait::hasWithSeparator() @uses DelegatesAwareTrait::hasInDelegates() @param string $key The data key to check. @throws InvalidArgumentException If the $key is not a string or is a numeric value. @return boolean TRUE if $key exists and has a value other than NULL, FALSE otherwise.
[ "Determines", "if", "this", "store", "contains", "the", "specified", "key", "and", "if", "its", "value", "is", "not", "NULL", "." ]
722b34955360c287dea8fffb3b5491866ce5f6cb
https://github.com/locomotivemtl/charcoal-config/blob/722b34955360c287dea8fffb3b5491866ce5f6cb/src/Charcoal/Config/AbstractConfig.php#L135-L164
train
locomotivemtl/charcoal-config
src/Charcoal/Config/AbstractConfig.php
AbstractConfig.offsetReplace
public function offsetReplace($key, $value) { if (is_numeric($key)) { throw new InvalidArgumentException( 'Entity array access only supports non-numeric keys' ); } $key = $this->camelize($key); /** @internal Edge Case: "_" → "" */ if ($key === '') { return; } if (is_array($value) && isset($this[$key])) { $data = $this[$key]; if (is_array($data)) { $value = array_replace_recursive($data, $value); } } $this[$key] = $value; }
php
public function offsetReplace($key, $value) { if (is_numeric($key)) { throw new InvalidArgumentException( 'Entity array access only supports non-numeric keys' ); } $key = $this->camelize($key); /** @internal Edge Case: "_" → "" */ if ($key === '') { return; } if (is_array($value) && isset($this[$key])) { $data = $this[$key]; if (is_array($data)) { $value = array_replace_recursive($data, $value); } } $this[$key] = $value; }
[ "public", "function", "offsetReplace", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_numeric", "(", "$", "key", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Entity array access only supports non-numeric keys'", ")", ";", "}", "$", "key", "=", "$", "this", "->", "camelize", "(", "$", "key", ")", ";", "/** @internal Edge Case: \"_\" → \"\" */", "if", "(", "$", "key", "===", "''", ")", "{", "return", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", "&&", "isset", "(", "$", "this", "[", "$", "key", "]", ")", ")", "{", "$", "data", "=", "$", "this", "[", "$", "key", "]", ";", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "$", "value", "=", "array_replace_recursive", "(", "$", "data", ",", "$", "value", ")", ";", "}", "}", "$", "this", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Replaces the value from the specified key. Routine: - When the value in the Config and the new value are both arrays, the method will replace their respective value recursively. - Then or otherwise, the new value is {@see self::offsetSet() assigned} to the Config. @uses self::offsetSet() @uses array_replace_recursive() @param string $key The data key to assign or merge $value to. @param mixed $value The data value to assign to or merge with $key. @throws InvalidArgumentException If the $key is not a string or is a numeric value. @return void
[ "Replaces", "the", "value", "from", "the", "specified", "key", "." ]
722b34955360c287dea8fffb3b5491866ce5f6cb
https://github.com/locomotivemtl/charcoal-config/blob/722b34955360c287dea8fffb3b5491866ce5f6cb/src/Charcoal/Config/AbstractConfig.php#L271-L294
train
locomotivemtl/charcoal-config
src/Charcoal/Config/AbstractConfig.php
AbstractConfig.addFile
public function addFile($path) { $config = $this->loadFile($path); if (is_array($config)) { $this->merge($config); } return $this; }
php
public function addFile($path) { $config = $this->loadFile($path); if (is_array($config)) { $this->merge($config); } return $this; }
[ "public", "function", "addFile", "(", "$", "path", ")", "{", "$", "config", "=", "$", "this", "->", "loadFile", "(", "$", "path", ")", ";", "if", "(", "is_array", "(", "$", "config", ")", ")", "{", "$", "this", "->", "merge", "(", "$", "config", ")", ";", "}", "return", "$", "this", ";", "}" ]
Adds a configuration file to the configset. Natively supported file formats: INI, JSON, PHP. @uses FileAwareTrait::loadFile() @param string $path The file to load and add. @return self
[ "Adds", "a", "configuration", "file", "to", "the", "configset", "." ]
722b34955360c287dea8fffb3b5491866ce5f6cb
https://github.com/locomotivemtl/charcoal-config/blob/722b34955360c287dea8fffb3b5491866ce5f6cb/src/Charcoal/Config/AbstractConfig.php#L305-L312
train
stellaqua/Waltz.Stagehand
src/Waltz/Stagehand/ClassUtility/CommentObject/PhpDocCommentObject.php
PhpDocCommentObject.ltrim
public static function ltrim ( $docComment ) { $regexp = array( '|^[\s\t]*(/\*\*)|um' => '\\1', '|^[\s\t]*([ ]\*/)|um' => '\\1', '|^[\s\t]*([ ]\*[ ]*)|um' => '\\1', ); $patterns = array_keys($regexp); $replacements = array_values($regexp); $docComment = preg_replace($patterns, $replacements, $docComment); $docComment = trim($docComment); return $docComment; }
php
public static function ltrim ( $docComment ) { $regexp = array( '|^[\s\t]*(/\*\*)|um' => '\\1', '|^[\s\t]*([ ]\*/)|um' => '\\1', '|^[\s\t]*([ ]\*[ ]*)|um' => '\\1', ); $patterns = array_keys($regexp); $replacements = array_values($regexp); $docComment = preg_replace($patterns, $replacements, $docComment); $docComment = trim($docComment); return $docComment; }
[ "public", "static", "function", "ltrim", "(", "$", "docComment", ")", "{", "$", "regexp", "=", "array", "(", "'|^[\\s\\t]*(/\\*\\*)|um'", "=>", "'\\\\1'", ",", "'|^[\\s\\t]*([ ]\\*/)|um'", "=>", "'\\\\1'", ",", "'|^[\\s\\t]*([ ]\\*[ ]*)|um'", "=>", "'\\\\1'", ",", ")", ";", "$", "patterns", "=", "array_keys", "(", "$", "regexp", ")", ";", "$", "replacements", "=", "array_values", "(", "$", "regexp", ")", ";", "$", "docComment", "=", "preg_replace", "(", "$", "patterns", ",", "$", "replacements", ",", "$", "docComment", ")", ";", "$", "docComment", "=", "trim", "(", "$", "docComment", ")", ";", "return", "$", "docComment", ";", "}" ]
Trim spaces and tabs on the left @param string $docComment @return string Trimmed DocComment
[ "Trim", "spaces", "and", "tabs", "on", "the", "left" ]
01df286751f5b9a5c90c47138dca3709e5bc383b
https://github.com/stellaqua/Waltz.Stagehand/blob/01df286751f5b9a5c90c47138dca3709e5bc383b/src/Waltz/Stagehand/ClassUtility/CommentObject/PhpDocCommentObject.php#L44-L55
train
benjamindulau/AnoDataGrid
src/Ano/DataGrid/Twig/Extension/DataGridExtension.php
DataGridExtension.renderColumnBody
public function renderColumnBody(ColumnView $view, array $variables = array()) { return $this->render($view, 'column_' . $view->get('type'), $variables); }
php
public function renderColumnBody(ColumnView $view, array $variables = array()) { return $this->render($view, 'column_' . $view->get('type'), $variables); }
[ "public", "function", "renderColumnBody", "(", "ColumnView", "$", "view", ",", "array", "$", "variables", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "render", "(", "$", "view", ",", "'column_'", ".", "$", "view", "->", "get", "(", "'type'", ")", ",", "$", "variables", ")", ";", "}" ]
Renders column body. @param ColumnView $view The view to render @param array $variables An array of variables @return string The html markup
[ "Renders", "column", "body", "." ]
69b31803929b04e9d6e807bb2213b9b3477d0367
https://github.com/benjamindulau/AnoDataGrid/blob/69b31803929b04e9d6e807bb2213b9b3477d0367/src/Ano/DataGrid/Twig/Extension/DataGridExtension.php#L96-L99
train
benjamindulau/AnoDataGrid
src/Ano/DataGrid/Twig/Extension/DataGridExtension.php
DataGridExtension.getBlocks
protected function getBlocks(DataGridView $view) { if (!$this->blocks->contains($view)) { $templates = $this->resources; if (isset($this->themes[$view])) { $templates = array_merge($templates, $this->themes[$view]); } $blocks = array(); foreach ($templates as $template) { if (!$template instanceof \Twig_Template) { $template = $this->environment->loadTemplate($template); } $templateBlocks = array(); do { $templateBlocks = array_merge($template->getBlocks(), $templateBlocks); } while (false !== $template = $template->getParent(array())); $blocks = array_merge($blocks, $templateBlocks); } $this->blocks->attach($view, $blocks); } else { $blocks = $this->blocks[$view]; } return $blocks; }
php
protected function getBlocks(DataGridView $view) { if (!$this->blocks->contains($view)) { $templates = $this->resources; if (isset($this->themes[$view])) { $templates = array_merge($templates, $this->themes[$view]); } $blocks = array(); foreach ($templates as $template) { if (!$template instanceof \Twig_Template) { $template = $this->environment->loadTemplate($template); } $templateBlocks = array(); do { $templateBlocks = array_merge($template->getBlocks(), $templateBlocks); } while (false !== $template = $template->getParent(array())); $blocks = array_merge($blocks, $templateBlocks); } $this->blocks->attach($view, $blocks); } else { $blocks = $this->blocks[$view]; } return $blocks; }
[ "protected", "function", "getBlocks", "(", "DataGridView", "$", "view", ")", "{", "if", "(", "!", "$", "this", "->", "blocks", "->", "contains", "(", "$", "view", ")", ")", "{", "$", "templates", "=", "$", "this", "->", "resources", ";", "if", "(", "isset", "(", "$", "this", "->", "themes", "[", "$", "view", "]", ")", ")", "{", "$", "templates", "=", "array_merge", "(", "$", "templates", ",", "$", "this", "->", "themes", "[", "$", "view", "]", ")", ";", "}", "$", "blocks", "=", "array", "(", ")", ";", "foreach", "(", "$", "templates", "as", "$", "template", ")", "{", "if", "(", "!", "$", "template", "instanceof", "\\", "Twig_Template", ")", "{", "$", "template", "=", "$", "this", "->", "environment", "->", "loadTemplate", "(", "$", "template", ")", ";", "}", "$", "templateBlocks", "=", "array", "(", ")", ";", "do", "{", "$", "templateBlocks", "=", "array_merge", "(", "$", "template", "->", "getBlocks", "(", ")", ",", "$", "templateBlocks", ")", ";", "}", "while", "(", "false", "!==", "$", "template", "=", "$", "template", "->", "getParent", "(", "array", "(", ")", ")", ")", ";", "$", "blocks", "=", "array_merge", "(", "$", "blocks", ",", "$", "templateBlocks", ")", ";", "}", "$", "this", "->", "blocks", "->", "attach", "(", "$", "view", ",", "$", "blocks", ")", ";", "}", "else", "{", "$", "blocks", "=", "$", "this", "->", "blocks", "[", "$", "view", "]", ";", "}", "return", "$", "blocks", ";", "}" ]
Returns the blocks used to render the view. Templates are looked for in the resources in the following order: * resources from the themes (and its parents) * resources from the themes of parent views (up to the root view) * default resources @param DataGridView $view The view @return array An array of Twig_TemplateInterface instances
[ "Returns", "the", "blocks", "used", "to", "render", "the", "view", "." ]
69b31803929b04e9d6e807bb2213b9b3477d0367
https://github.com/benjamindulau/AnoDataGrid/blob/69b31803929b04e9d6e807bb2213b9b3477d0367/src/Ano/DataGrid/Twig/Extension/DataGridExtension.php#L220-L249
train
Subscribo/omnipay-subscribo-shared
src/Shared/CreditCard.php
CreditCard.getShippingContactDifferences
public function getShippingContactDifferences($mode = self::MODE_FILTER_EMPTY_WHEN_STRING_VALUES) { $difference = []; foreach ($this->getContactParameterNames() as $parameterName) { $billingGetter = 'getBilling'.ucfirst($parameterName); $shippingGetter = 'getShipping'.ucfirst($parameterName); $billingValue = $this->$billingGetter(); $shippingValue = $this->$shippingGetter(); if ($billingValue !== $shippingValue) { $difference[$parameterName] = $shippingValue; } } if ($mode === self::MODE_FILTER_EMPTY_WHEN_STRING_VALUES) { $result = array_filter($difference, 'strlen'); } elseif ($mode === self::MODE_FILTER_EMPTY_VALUES) { $result = array_filter($difference); } else { $result = $difference; } return $result; }
php
public function getShippingContactDifferences($mode = self::MODE_FILTER_EMPTY_WHEN_STRING_VALUES) { $difference = []; foreach ($this->getContactParameterNames() as $parameterName) { $billingGetter = 'getBilling'.ucfirst($parameterName); $shippingGetter = 'getShipping'.ucfirst($parameterName); $billingValue = $this->$billingGetter(); $shippingValue = $this->$shippingGetter(); if ($billingValue !== $shippingValue) { $difference[$parameterName] = $shippingValue; } } if ($mode === self::MODE_FILTER_EMPTY_WHEN_STRING_VALUES) { $result = array_filter($difference, 'strlen'); } elseif ($mode === self::MODE_FILTER_EMPTY_VALUES) { $result = array_filter($difference); } else { $result = $difference; } return $result; }
[ "public", "function", "getShippingContactDifferences", "(", "$", "mode", "=", "self", "::", "MODE_FILTER_EMPTY_WHEN_STRING_VALUES", ")", "{", "$", "difference", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getContactParameterNames", "(", ")", "as", "$", "parameterName", ")", "{", "$", "billingGetter", "=", "'getBilling'", ".", "ucfirst", "(", "$", "parameterName", ")", ";", "$", "shippingGetter", "=", "'getShipping'", ".", "ucfirst", "(", "$", "parameterName", ")", ";", "$", "billingValue", "=", "$", "this", "->", "$", "billingGetter", "(", ")", ";", "$", "shippingValue", "=", "$", "this", "->", "$", "shippingGetter", "(", ")", ";", "if", "(", "$", "billingValue", "!==", "$", "shippingValue", ")", "{", "$", "difference", "[", "$", "parameterName", "]", "=", "$", "shippingValue", ";", "}", "}", "if", "(", "$", "mode", "===", "self", "::", "MODE_FILTER_EMPTY_WHEN_STRING_VALUES", ")", "{", "$", "result", "=", "array_filter", "(", "$", "difference", ",", "'strlen'", ")", ";", "}", "elseif", "(", "$", "mode", "===", "self", "::", "MODE_FILTER_EMPTY_VALUES", ")", "{", "$", "result", "=", "array_filter", "(", "$", "difference", ")", ";", "}", "else", "{", "$", "result", "=", "$", "difference", ";", "}", "return", "$", "result", ";", "}" ]
Returns those shipping contact parameters which are different for shipping and billing Keys are camel cased parameter names without shipping prefix, values are shipping contact parameter values @param string $mode Filtering mode (if any): By default this methods filters out values, which are empty when converted to string @return array
[ "Returns", "those", "shipping", "contact", "parameters", "which", "are", "different", "for", "shipping", "and", "billing", "Keys", "are", "camel", "cased", "parameter", "names", "without", "shipping", "prefix", "values", "are", "shipping", "contact", "parameter", "values" ]
aa9fa115ef8324b50fe5c91d3593d5632f53b669
https://github.com/Subscribo/omnipay-subscribo-shared/blob/aa9fa115ef8324b50fe5c91d3593d5632f53b669/src/Shared/CreditCard.php#L42-L64
train
squareproton/Bond
lib/underscore.php
__.chain
public function chain($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); $__ = (isset($this) && isset($this->_chained) && $this->_chained) ? $this : __($item); $__->_chained = true; return $__; }
php
public function chain($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); $__ = (isset($this) && isset($this->_chained) && $this->_chained) ? $this : __($item); $__->_chained = true; return $__; }
[ "public", "function", "chain", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "__", "=", "(", "isset", "(", "$", "this", ")", "&&", "isset", "(", "$", "this", "->", "_chained", ")", "&&", "$", "this", "->", "_chained", ")", "?", "$", "this", ":", "__", "(", "$", "item", ")", ";", "$", "__", "->", "_chained", "=", "true", ";", "return", "$", "__", ";", "}" ]
Are we in a chain?
[ "Are", "we", "in", "a", "chain?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L24-L30
train
squareproton/Bond
lib/underscore.php
__.each
public function each($collection=null, $iterator=null) { list($collection, $iterator) = self::_wrapArgs(func_get_args(), 2); if(is_null($collection)) return self::_wrap(null); $collection = (array) self::_collection($collection); if(count($collection) === 0) return self::_wrap(null); foreach($collection as $k=>$v) { call_user_func($iterator, $v, $k, $collection); } return self::_wrap(null); }
php
public function each($collection=null, $iterator=null) { list($collection, $iterator) = self::_wrapArgs(func_get_args(), 2); if(is_null($collection)) return self::_wrap(null); $collection = (array) self::_collection($collection); if(count($collection) === 0) return self::_wrap(null); foreach($collection as $k=>$v) { call_user_func($iterator, $v, $k, $collection); } return self::_wrap(null); }
[ "public", "function", "each", "(", "$", "collection", "=", "null", ",", "$", "iterator", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "iterator", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "if", "(", "is_null", "(", "$", "collection", ")", ")", "return", "self", "::", "_wrap", "(", "null", ")", ";", "$", "collection", "=", "(", "array", ")", "self", "::", "_collection", "(", "$", "collection", ")", ";", "if", "(", "count", "(", "$", "collection", ")", "===", "0", ")", "return", "self", "::", "_wrap", "(", "null", ")", ";", "foreach", "(", "$", "collection", "as", "$", "k", "=>", "$", "v", ")", "{", "call_user_func", "(", "$", "iterator", ",", "$", "v", ",", "$", "k", ",", "$", "collection", ")", ";", "}", "return", "self", "::", "_wrap", "(", "null", ")", ";", "}" ]
Invoke the iterator on each item in the collection
[ "Invoke", "the", "iterator", "on", "each", "item", "in", "the", "collection" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L40-L52
train
squareproton/Bond
lib/underscore.php
__.invoke
public function invoke($collection=null, $function_name=null, $arguments=null) { $args = self::_wrapArgs(func_get_args(), 2); $__ = new self; list($collection, $function_name) = $__->first($args, 2); $arguments = $__->rest(func_get_args(), 2); // If passed an array or string, return an array // If passed an object, return an object $is_obj = is_object($collection); $result = (empty($arguments)) ? array_map($function_name, (array) $collection) : array_map($function_name, (array) $collection, $arguments); if($is_obj) $result = (object) $result; return self::_wrap($result); }
php
public function invoke($collection=null, $function_name=null, $arguments=null) { $args = self::_wrapArgs(func_get_args(), 2); $__ = new self; list($collection, $function_name) = $__->first($args, 2); $arguments = $__->rest(func_get_args(), 2); // If passed an array or string, return an array // If passed an object, return an object $is_obj = is_object($collection); $result = (empty($arguments)) ? array_map($function_name, (array) $collection) : array_map($function_name, (array) $collection, $arguments); if($is_obj) $result = (object) $result; return self::_wrap($result); }
[ "public", "function", "invoke", "(", "$", "collection", "=", "null", ",", "$", "function_name", "=", "null", ",", "$", "arguments", "=", "null", ")", "{", "$", "args", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "__", "=", "new", "self", ";", "list", "(", "$", "collection", ",", "$", "function_name", ")", "=", "$", "__", "->", "first", "(", "$", "args", ",", "2", ")", ";", "$", "arguments", "=", "$", "__", "->", "rest", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "// If passed an array or string, return an array", "// If passed an object, return an object", "$", "is_obj", "=", "is_object", "(", "$", "collection", ")", ";", "$", "result", "=", "(", "empty", "(", "$", "arguments", ")", ")", "?", "array_map", "(", "$", "function_name", ",", "(", "array", ")", "$", "collection", ")", ":", "array_map", "(", "$", "function_name", ",", "(", "array", ")", "$", "collection", ",", "$", "arguments", ")", ";", "if", "(", "$", "is_obj", ")", "$", "result", "=", "(", "object", ")", "$", "result", ";", "return", "self", "::", "_wrap", "(", "$", "result", ")", ";", "}" ]
Invoke the named function over each item in the collection, optionally passing arguments to the function
[ "Invoke", "the", "named", "function", "over", "each", "item", "in", "the", "collection", "optionally", "passing", "arguments", "to", "the", "function" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L137-L150
train
squareproton/Bond
lib/underscore.php
__.size
public function size($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); $collection = self::_collection($collection); return self::_wrap(count((array) $collection)); }
php
public function size($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); $collection = self::_collection($collection); return self::_wrap(count((array) $collection)); }
[ "public", "function", "size", "(", "$", "collection", "=", "null", ")", "{", "list", "(", "$", "collection", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "collection", "=", "self", "::", "_collection", "(", "$", "collection", ")", ";", "return", "self", "::", "_wrap", "(", "count", "(", "(", "array", ")", "$", "collection", ")", ")", ";", "}" ]
How many items are in this collection?
[ "How", "many", "items", "are", "in", "this", "collection?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L232-L238
train
squareproton/Bond
lib/underscore.php
__.initial
public function initial($collection=null, $n=null) { list($collection, $n) = self::_wrapArgs(func_get_args(), 2); $collection = (array) self::_collection($collection); if(is_null($n)) $n = 1; $first_index = count($collection) - $n; $__ = new self; return self::_wrap($__->first($collection, $first_index)); }
php
public function initial($collection=null, $n=null) { list($collection, $n) = self::_wrapArgs(func_get_args(), 2); $collection = (array) self::_collection($collection); if(is_null($n)) $n = 1; $first_index = count($collection) - $n; $__ = new self; return self::_wrap($__->first($collection, $first_index)); }
[ "public", "function", "initial", "(", "$", "collection", "=", "null", ",", "$", "n", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "n", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "collection", "=", "(", "array", ")", "self", "::", "_collection", "(", "$", "collection", ")", ";", "if", "(", "is_null", "(", "$", "n", ")", ")", "$", "n", "=", "1", ";", "$", "first_index", "=", "count", "(", "$", "collection", ")", "-", "$", "n", ";", "$", "__", "=", "new", "self", ";", "return", "self", "::", "_wrap", "(", "$", "__", "->", "first", "(", "$", "collection", ",", "$", "first_index", ")", ")", ";", "}" ]
Return everything but the last array element. Passing n excludes the last n elements.
[ "Return", "everything", "but", "the", "last", "array", "element", ".", "Passing", "n", "excludes", "the", "last", "n", "elements", "." ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L268-L277
train
squareproton/Bond
lib/underscore.php
__.compact
public function compact($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); $collection = self::_collection($collection); $__ = new self; return self::_wrap($__->select($collection, function($val) { return (bool) $val; })); }
php
public function compact($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); $collection = self::_collection($collection); $__ = new self; return self::_wrap($__->select($collection, function($val) { return (bool) $val; })); }
[ "public", "function", "compact", "(", "$", "collection", "=", "null", ")", "{", "list", "(", "$", "collection", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "collection", "=", "self", "::", "_collection", "(", "$", "collection", ")", ";", "$", "__", "=", "new", "self", ";", "return", "self", "::", "_wrap", "(", "$", "__", "->", "select", "(", "$", "collection", ",", "function", "(", "$", "val", ")", "{", "return", "(", "bool", ")", "$", "val", ";", "}", ")", ")", ";", "}" ]
Return a copy of the array with falsy values removed
[ "Return", "a", "copy", "of", "the", "array", "with", "falsy", "values", "removed" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L297-L306
train
squareproton/Bond
lib/underscore.php
__.flatten
public function flatten($collection=null, $shallow=null) { list($collection, $shallow) = self::_wrapArgs(func_get_args(), 2); $collection = self::_collection($collection); $return = array(); if(count($collection) > 0) { foreach($collection as $item) { if(is_array($item)) { $__ = new self; $return = array_merge($return, ($shallow) ? $item : $__->flatten($item)); } else $return[] = $item; } } return self::_wrap($return); }
php
public function flatten($collection=null, $shallow=null) { list($collection, $shallow) = self::_wrapArgs(func_get_args(), 2); $collection = self::_collection($collection); $return = array(); if(count($collection) > 0) { foreach($collection as $item) { if(is_array($item)) { $__ = new self; $return = array_merge($return, ($shallow) ? $item : $__->flatten($item)); } else $return[] = $item; } } return self::_wrap($return); }
[ "public", "function", "flatten", "(", "$", "collection", "=", "null", ",", "$", "shallow", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "shallow", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "collection", "=", "self", "::", "_collection", "(", "$", "collection", ")", ";", "$", "return", "=", "array", "(", ")", ";", "if", "(", "count", "(", "$", "collection", ")", ">", "0", ")", "{", "foreach", "(", "$", "collection", "as", "$", "item", ")", "{", "if", "(", "is_array", "(", "$", "item", ")", ")", "{", "$", "__", "=", "new", "self", ";", "$", "return", "=", "array_merge", "(", "$", "return", ",", "(", "$", "shallow", ")", "?", "$", "item", ":", "$", "__", "->", "flatten", "(", "$", "item", ")", ")", ";", "}", "else", "$", "return", "[", "]", "=", "$", "item", ";", "}", "}", "return", "self", "::", "_wrap", "(", "$", "return", ")", ";", "}" ]
Flattens a multidimensional array
[ "Flattens", "a", "multidimensional", "array" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L310-L326
train
squareproton/Bond
lib/underscore.php
__.without
public function without($collection=null, $val=null) { $args = self::_wrapArgs(func_get_args(), 1); $collection = $args[0]; $collection = self::_collection($collection); $num_args = count($args); if($num_args === 1) return self::_wrap($collection); if(count($collection) === 0) return self::_wrap($collection); $__ = new self; $removes = $__->rest($args); foreach($removes as $remove) { $remove_keys = array_keys($collection, $remove, true); if(count($remove_keys) > 0) { foreach($remove_keys as $key) { unset($collection[$key]); } } } return self::_wrap($collection); }
php
public function without($collection=null, $val=null) { $args = self::_wrapArgs(func_get_args(), 1); $collection = $args[0]; $collection = self::_collection($collection); $num_args = count($args); if($num_args === 1) return self::_wrap($collection); if(count($collection) === 0) return self::_wrap($collection); $__ = new self; $removes = $__->rest($args); foreach($removes as $remove) { $remove_keys = array_keys($collection, $remove, true); if(count($remove_keys) > 0) { foreach($remove_keys as $key) { unset($collection[$key]); } } } return self::_wrap($collection); }
[ "public", "function", "without", "(", "$", "collection", "=", "null", ",", "$", "val", "=", "null", ")", "{", "$", "args", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "collection", "=", "$", "args", "[", "0", "]", ";", "$", "collection", "=", "self", "::", "_collection", "(", "$", "collection", ")", ";", "$", "num_args", "=", "count", "(", "$", "args", ")", ";", "if", "(", "$", "num_args", "===", "1", ")", "return", "self", "::", "_wrap", "(", "$", "collection", ")", ";", "if", "(", "count", "(", "$", "collection", ")", "===", "0", ")", "return", "self", "::", "_wrap", "(", "$", "collection", ")", ";", "$", "__", "=", "new", "self", ";", "$", "removes", "=", "$", "__", "->", "rest", "(", "$", "args", ")", ";", "foreach", "(", "$", "removes", "as", "$", "remove", ")", "{", "$", "remove_keys", "=", "array_keys", "(", "$", "collection", ",", "$", "remove", ",", "true", ")", ";", "if", "(", "count", "(", "$", "remove_keys", ")", ">", "0", ")", "{", "foreach", "(", "$", "remove_keys", "as", "$", "key", ")", "{", "unset", "(", "$", "collection", "[", "$", "key", "]", ")", ";", "}", "}", "}", "return", "self", "::", "_wrap", "(", "$", "collection", ")", ";", "}" ]
Returns a copy of the array with all instances of val removed
[ "Returns", "a", "copy", "of", "the", "array", "with", "all", "instances", "of", "val", "removed" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L330-L350
train
squareproton/Bond
lib/underscore.php
__.intersection
public function intersection($array=null) { $arrays = self::_wrapArgs(func_get_args(), 1); if(count($arrays) === 1) return self::_wrap($array); $__ = new self; $return = $__->first($arrays); foreach($__->rest($arrays) as $next) { if(!$__->isArray($next)) $next = str_split((string) $next); $return = array_intersect($return, $next); } return self::_wrap(array_values($return)); }
php
public function intersection($array=null) { $arrays = self::_wrapArgs(func_get_args(), 1); if(count($arrays) === 1) return self::_wrap($array); $__ = new self; $return = $__->first($arrays); foreach($__->rest($arrays) as $next) { if(!$__->isArray($next)) $next = str_split((string) $next); $return = array_intersect($return, $next); } return self::_wrap(array_values($return)); }
[ "public", "function", "intersection", "(", "$", "array", "=", "null", ")", "{", "$", "arrays", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "if", "(", "count", "(", "$", "arrays", ")", "===", "1", ")", "return", "self", "::", "_wrap", "(", "$", "array", ")", ";", "$", "__", "=", "new", "self", ";", "$", "return", "=", "$", "__", "->", "first", "(", "$", "arrays", ")", ";", "foreach", "(", "$", "__", "->", "rest", "(", "$", "arrays", ")", "as", "$", "next", ")", "{", "if", "(", "!", "$", "__", "->", "isArray", "(", "$", "next", ")", ")", "$", "next", "=", "str_split", "(", "(", "string", ")", "$", "next", ")", ";", "$", "return", "=", "array_intersect", "(", "$", "return", ",", "$", "next", ")", ";", "}", "return", "self", "::", "_wrap", "(", "array_values", "(", "$", "return", ")", ")", ";", "}" ]
Returns an array containing the intersection of all the arrays
[ "Returns", "an", "array", "containing", "the", "intersection", "of", "all", "the", "arrays" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L378-L392
train
squareproton/Bond
lib/underscore.php
__.union
public function union($array=null) { $arrays = self::_wrapArgs(func_get_args(), 1); if(count($arrays) === 1) return self::_wrap($array); $__ = new self; return self::_wrap($__->flatten(array_values(array_unique(call_user_func_array('array_merge', $arrays))))); }
php
public function union($array=null) { $arrays = self::_wrapArgs(func_get_args(), 1); if(count($arrays) === 1) return self::_wrap($array); $__ = new self; return self::_wrap($__->flatten(array_values(array_unique(call_user_func_array('array_merge', $arrays))))); }
[ "public", "function", "union", "(", "$", "array", "=", "null", ")", "{", "$", "arrays", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "if", "(", "count", "(", "$", "arrays", ")", "===", "1", ")", "return", "self", "::", "_wrap", "(", "$", "array", ")", ";", "$", "__", "=", "new", "self", ";", "return", "self", "::", "_wrap", "(", "$", "__", "->", "flatten", "(", "array_values", "(", "array_unique", "(", "call_user_func_array", "(", "'array_merge'", ",", "$", "arrays", ")", ")", ")", ")", ")", ";", "}" ]
Merge together multiple arrays
[ "Merge", "together", "multiple", "arrays" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L396-L403
train
squareproton/Bond
lib/underscore.php
__.difference
public function difference($array_one=null, $array_two=null) { $arrays = self::_wrapArgs(func_get_args(), 1); return self::_wrap(array_values(call_user_func_array('array_diff', $arrays))); }
php
public function difference($array_one=null, $array_two=null) { $arrays = self::_wrapArgs(func_get_args(), 1); return self::_wrap(array_values(call_user_func_array('array_diff', $arrays))); }
[ "public", "function", "difference", "(", "$", "array_one", "=", "null", ",", "$", "array_two", "=", "null", ")", "{", "$", "arrays", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "array_values", "(", "call_user_func_array", "(", "'array_diff'", ",", "$", "arrays", ")", ")", ")", ";", "}" ]
Get the difference between two arrays
[ "Get", "the", "difference", "between", "two", "arrays" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L407-L411
train
squareproton/Bond
lib/underscore.php
__.indexOf
public function indexOf($collection=null, $item=null) { list($collection, $item) = self::_wrapArgs(func_get_args(), 2); $collection = self::_collection($collection); $key = array_search($item, $collection, true); return self::_wrap((is_bool($key)) ? -1 : $key); }
php
public function indexOf($collection=null, $item=null) { list($collection, $item) = self::_wrapArgs(func_get_args(), 2); $collection = self::_collection($collection); $key = array_search($item, $collection, true); return self::_wrap((is_bool($key)) ? -1 : $key); }
[ "public", "function", "indexOf", "(", "$", "collection", "=", "null", ",", "$", "item", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "collection", "=", "self", "::", "_collection", "(", "$", "collection", ")", ";", "$", "key", "=", "array_search", "(", "$", "item", ",", "$", "collection", ",", "true", ")", ";", "return", "self", "::", "_wrap", "(", "(", "is_bool", "(", "$", "key", ")", ")", "?", "-", "1", ":", "$", "key", ")", ";", "}" ]
Get the index of the first match
[ "Get", "the", "index", "of", "the", "first", "match" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L415-L422
train
squareproton/Bond
lib/underscore.php
__.lastIndexOf
public function lastIndexOf($collection=null, $item=null) { list($collection, $item) = self::_wrapArgs(func_get_args(), 2); $collection = self::_collection($collection); krsort($collection); $__ = new self; return self::_wrap($__->indexOf($collection, $item)); }
php
public function lastIndexOf($collection=null, $item=null) { list($collection, $item) = self::_wrapArgs(func_get_args(), 2); $collection = self::_collection($collection); krsort($collection); $__ = new self; return self::_wrap($__->indexOf($collection, $item)); }
[ "public", "function", "lastIndexOf", "(", "$", "collection", "=", "null", ",", "$", "item", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "collection", "=", "self", "::", "_collection", "(", "$", "collection", ")", ";", "krsort", "(", "$", "collection", ")", ";", "$", "__", "=", "new", "self", ";", "return", "self", "::", "_wrap", "(", "$", "__", "->", "indexOf", "(", "$", "collection", ",", "$", "item", ")", ")", ";", "}" ]
Get the index of the last match
[ "Get", "the", "index", "of", "the", "last", "match" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L426-L434
train
squareproton/Bond
lib/underscore.php
__.max
public function max($collection=null, $iterator=null) { list($collection, $iterator) = self::_wrapArgs(func_get_args(), 2); if(is_null($iterator)) return self::_wrap(max($collection)); $results = array(); foreach($collection as $k=>$item) { $results[$k] = $iterator($item); } arsort($results); $__ = new self; $first_key = $__->first(array_keys($results)); return $collection[$first_key]; }
php
public function max($collection=null, $iterator=null) { list($collection, $iterator) = self::_wrapArgs(func_get_args(), 2); if(is_null($iterator)) return self::_wrap(max($collection)); $results = array(); foreach($collection as $k=>$item) { $results[$k] = $iterator($item); } arsort($results); $__ = new self; $first_key = $__->first(array_keys($results)); return $collection[$first_key]; }
[ "public", "function", "max", "(", "$", "collection", "=", "null", ",", "$", "iterator", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "iterator", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "if", "(", "is_null", "(", "$", "iterator", ")", ")", "return", "self", "::", "_wrap", "(", "max", "(", "$", "collection", ")", ")", ";", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "k", "=>", "$", "item", ")", "{", "$", "results", "[", "$", "k", "]", "=", "$", "iterator", "(", "$", "item", ")", ";", "}", "arsort", "(", "$", "results", ")", ";", "$", "__", "=", "new", "self", ";", "$", "first_key", "=", "$", "__", "->", "first", "(", "array_keys", "(", "$", "results", ")", ")", ";", "return", "$", "collection", "[", "$", "first_key", "]", ";", "}" ]
Get the max value in the collection
[ "Get", "the", "max", "value", "in", "the", "collection" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L493-L506
train
squareproton/Bond
lib/underscore.php
__.sortedIndex
public function sortedIndex($collection=null, $value=null, $iterator=null) { list($collection, $value, $iterator) = self::_wrapArgs(func_get_args(), 3); $collection = (array) self::_collection($collection); $__ = new self; $calculated_value = (!is_null($iterator)) ? $iterator($value) : $value; while(count($collection) > 1) { $midpoint = floor(count($collection) / 2); $midpoint_values = array_slice($collection, $midpoint, 1); $midpoint_value = $midpoint_values[0]; $midpoint_calculated_value = (!is_null($iterator)) ? $iterator($midpoint_value) : $midpoint_value; $collection = ($calculated_value < $midpoint_calculated_value) ? array_slice($collection, 0, $midpoint, true) : array_slice($collection, $midpoint, null, true); } $keys = array_keys($collection); return self::_wrap(current($keys) + 1); }
php
public function sortedIndex($collection=null, $value=null, $iterator=null) { list($collection, $value, $iterator) = self::_wrapArgs(func_get_args(), 3); $collection = (array) self::_collection($collection); $__ = new self; $calculated_value = (!is_null($iterator)) ? $iterator($value) : $value; while(count($collection) > 1) { $midpoint = floor(count($collection) / 2); $midpoint_values = array_slice($collection, $midpoint, 1); $midpoint_value = $midpoint_values[0]; $midpoint_calculated_value = (!is_null($iterator)) ? $iterator($midpoint_value) : $midpoint_value; $collection = ($calculated_value < $midpoint_calculated_value) ? array_slice($collection, 0, $midpoint, true) : array_slice($collection, $midpoint, null, true); } $keys = array_keys($collection); return self::_wrap(current($keys) + 1); }
[ "public", "function", "sortedIndex", "(", "$", "collection", "=", "null", ",", "$", "value", "=", "null", ",", "$", "iterator", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "value", ",", "$", "iterator", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "3", ")", ";", "$", "collection", "=", "(", "array", ")", "self", "::", "_collection", "(", "$", "collection", ")", ";", "$", "__", "=", "new", "self", ";", "$", "calculated_value", "=", "(", "!", "is_null", "(", "$", "iterator", ")", ")", "?", "$", "iterator", "(", "$", "value", ")", ":", "$", "value", ";", "while", "(", "count", "(", "$", "collection", ")", ">", "1", ")", "{", "$", "midpoint", "=", "floor", "(", "count", "(", "$", "collection", ")", "/", "2", ")", ";", "$", "midpoint_values", "=", "array_slice", "(", "$", "collection", ",", "$", "midpoint", ",", "1", ")", ";", "$", "midpoint_value", "=", "$", "midpoint_values", "[", "0", "]", ";", "$", "midpoint_calculated_value", "=", "(", "!", "is_null", "(", "$", "iterator", ")", ")", "?", "$", "iterator", "(", "$", "midpoint_value", ")", ":", "$", "midpoint_value", ";", "$", "collection", "=", "(", "$", "calculated_value", "<", "$", "midpoint_calculated_value", ")", "?", "array_slice", "(", "$", "collection", ",", "0", ",", "$", "midpoint", ",", "true", ")", ":", "array_slice", "(", "$", "collection", ",", "$", "midpoint", ",", "null", ",", "true", ")", ";", "}", "$", "keys", "=", "array_keys", "(", "$", "collection", ")", ";", "return", "self", "::", "_wrap", "(", "current", "(", "$", "keys", ")", "+", "1", ")", ";", "}" ]
Returns the index at which the value should be inserted into the sorted collection
[ "Returns", "the", "index", "at", "which", "the", "value", "should", "be", "inserted", "into", "the", "sorted", "collection" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L558-L577
train
squareproton/Bond
lib/underscore.php
__.shuffle
public function shuffle($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); $collection = (array) self::_collection($collection); shuffle($collection); return self::_wrap($collection); }
php
public function shuffle($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); $collection = (array) self::_collection($collection); shuffle($collection); return self::_wrap($collection); }
[ "public", "function", "shuffle", "(", "$", "collection", "=", "null", ")", "{", "list", "(", "$", "collection", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "collection", "=", "(", "array", ")", "self", "::", "_collection", "(", "$", "collection", ")", ";", "shuffle", "(", "$", "collection", ")", ";", "return", "self", "::", "_wrap", "(", "$", "collection", ")", ";", "}" ]
Shuffle the array
[ "Shuffle", "the", "array" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L580-L587
train
squareproton/Bond
lib/underscore.php
__.keys
public function keys($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); if(!is_object($collection) && !is_array($collection)) throw new Exception('Invalid object'); return self::_wrap(array_keys((array) $collection)); }
php
public function keys($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); if(!is_object($collection) && !is_array($collection)) throw new Exception('Invalid object'); return self::_wrap(array_keys((array) $collection)); }
[ "public", "function", "keys", "(", "$", "collection", "=", "null", ")", "{", "list", "(", "$", "collection", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "if", "(", "!", "is_object", "(", "$", "collection", ")", "&&", "!", "is_array", "(", "$", "collection", ")", ")", "throw", "new", "Exception", "(", "'Invalid object'", ")", ";", "return", "self", "::", "_wrap", "(", "array_keys", "(", "(", "array", ")", "$", "collection", ")", ")", ";", "}" ]
Get the collection's keys
[ "Get", "the", "collection", "s", "keys" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L597-L603
train
squareproton/Bond
lib/underscore.php
__.values
public function values($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(array_values((array) $collection)); }
php
public function values($collection=null) { list($collection) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(array_values((array) $collection)); }
[ "public", "function", "values", "(", "$", "collection", "=", "null", ")", "{", "list", "(", "$", "collection", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "array_values", "(", "(", "array", ")", "$", "collection", ")", ")", ";", "}" ]
Get the collection's values
[ "Get", "the", "collection", "s", "values" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L607-L611
train
squareproton/Bond
lib/underscore.php
__.extend
public function extend($object=null) { $args = self::_wrapArgs(func_get_args(), 1); $num_args = func_num_args(); if($num_args === 1) return $object; $is_object = is_object($object); $array = (array) $object; $__ = new self; $extensions = $__->rest(func_get_args()); foreach($extensions as $extension) { $extension = (array) $extension; $array = array_merge($array, $extension); } return self::_wrap(($is_object) ? (object) $array : $array); }
php
public function extend($object=null) { $args = self::_wrapArgs(func_get_args(), 1); $num_args = func_num_args(); if($num_args === 1) return $object; $is_object = is_object($object); $array = (array) $object; $__ = new self; $extensions = $__->rest(func_get_args()); foreach($extensions as $extension) { $extension = (array) $extension; $array = array_merge($array, $extension); } return self::_wrap(($is_object) ? (object) $array : $array); }
[ "public", "function", "extend", "(", "$", "object", "=", "null", ")", "{", "$", "args", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "num_args", "=", "func_num_args", "(", ")", ";", "if", "(", "$", "num_args", "===", "1", ")", "return", "$", "object", ";", "$", "is_object", "=", "is_object", "(", "$", "object", ")", ";", "$", "array", "=", "(", "array", ")", "$", "object", ";", "$", "__", "=", "new", "self", ";", "$", "extensions", "=", "$", "__", "->", "rest", "(", "func_get_args", "(", ")", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "$", "extension", "=", "(", "array", ")", "$", "extension", ";", "$", "array", "=", "array_merge", "(", "$", "array", ",", "$", "extension", ")", ";", "}", "return", "self", "::", "_wrap", "(", "(", "$", "is_object", ")", "?", "(", "object", ")", "$", "array", ":", "$", "array", ")", ";", "}" ]
Copy all properties from the source objects into the destination object
[ "Copy", "all", "properties", "from", "the", "source", "objects", "into", "the", "destination", "object" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L615-L630
train
squareproton/Bond
lib/underscore.php
__.defaults
public function defaults($object=null) { $args = self::_wrapArgs(func_get_args(), 1); list($object) = $args; $num_args = count($args); if($num_args === 1) return $object; $is_object = is_object($object); $array = (array) $object; $__ = new self; $extensions = $__->rest($args); foreach($extensions as $extension) { $extension = (array) $extension; $array = array_merge($extension, $array); } return self::_wrap(($is_object) ? (object) $array : $array); }
php
public function defaults($object=null) { $args = self::_wrapArgs(func_get_args(), 1); list($object) = $args; $num_args = count($args); if($num_args === 1) return $object; $is_object = is_object($object); $array = (array) $object; $__ = new self; $extensions = $__->rest($args); foreach($extensions as $extension) { $extension = (array) $extension; $array = array_merge($extension, $array); } return self::_wrap(($is_object) ? (object) $array : $array); }
[ "public", "function", "defaults", "(", "$", "object", "=", "null", ")", "{", "$", "args", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "list", "(", "$", "object", ")", "=", "$", "args", ";", "$", "num_args", "=", "count", "(", "$", "args", ")", ";", "if", "(", "$", "num_args", "===", "1", ")", "return", "$", "object", ";", "$", "is_object", "=", "is_object", "(", "$", "object", ")", ";", "$", "array", "=", "(", "array", ")", "$", "object", ";", "$", "__", "=", "new", "self", ";", "$", "extensions", "=", "$", "__", "->", "rest", "(", "$", "args", ")", ";", "foreach", "(", "$", "extensions", "as", "$", "extension", ")", "{", "$", "extension", "=", "(", "array", ")", "$", "extension", ";", "$", "array", "=", "array_merge", "(", "$", "extension", ",", "$", "array", ")", ";", "}", "return", "self", "::", "_wrap", "(", "(", "$", "is_object", ")", "?", "(", "object", ")", "$", "array", ":", "$", "array", ")", ";", "}" ]
Returns the object with any missing values filled in using the defaults.
[ "Returns", "the", "object", "with", "any", "missing", "values", "filled", "in", "using", "the", "defaults", "." ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L634-L650
train
squareproton/Bond
lib/underscore.php
__.clon
public function clon(&$object=null) { list($object) = self::_wrapArgs(func_get_args(), 1); $clone = null; if(is_array($object)) $clone = (array) clone (object) $object; elseif(!is_object($object)) $clone = $object; elseif(!$clone) $clone = clone $object; // shallow copy object if(is_object($clone) && count($clone) > 0) { foreach($clone as $k=>$v) { if(is_array($v) || is_object($v)) $clone->$k =& $object->$k; } } // shallow copy array elseif(is_array($clone) && count($clone) > 0) { foreach($clone as $k=>$v) { if(is_array($v) || is_object($v)) $clone[$k] =& $object[$k]; } } return self::_wrap($clone); }
php
public function clon(&$object=null) { list($object) = self::_wrapArgs(func_get_args(), 1); $clone = null; if(is_array($object)) $clone = (array) clone (object) $object; elseif(!is_object($object)) $clone = $object; elseif(!$clone) $clone = clone $object; // shallow copy object if(is_object($clone) && count($clone) > 0) { foreach($clone as $k=>$v) { if(is_array($v) || is_object($v)) $clone->$k =& $object->$k; } } // shallow copy array elseif(is_array($clone) && count($clone) > 0) { foreach($clone as $k=>$v) { if(is_array($v) || is_object($v)) $clone[$k] =& $object[$k]; } } return self::_wrap($clone); }
[ "public", "function", "clon", "(", "&", "$", "object", "=", "null", ")", "{", "list", "(", "$", "object", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "$", "clone", "=", "null", ";", "if", "(", "is_array", "(", "$", "object", ")", ")", "$", "clone", "=", "(", "array", ")", "clone", "(", "object", ")", "$", "object", ";", "elseif", "(", "!", "is_object", "(", "$", "object", ")", ")", "$", "clone", "=", "$", "object", ";", "elseif", "(", "!", "$", "clone", ")", "$", "clone", "=", "clone", "$", "object", ";", "// shallow copy object", "if", "(", "is_object", "(", "$", "clone", ")", "&&", "count", "(", "$", "clone", ")", ">", "0", ")", "{", "foreach", "(", "$", "clone", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", "||", "is_object", "(", "$", "v", ")", ")", "$", "clone", "->", "$", "k", "=", "&", "$", "object", "->", "$", "k", ";", "}", "}", "// shallow copy array", "elseif", "(", "is_array", "(", "$", "clone", ")", "&&", "count", "(", "$", "clone", ")", ">", "0", ")", "{", "foreach", "(", "$", "clone", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "is_array", "(", "$", "v", ")", "||", "is_object", "(", "$", "v", ")", ")", "$", "clone", "[", "$", "k", "]", "=", "&", "$", "object", "[", "$", "k", "]", ";", "}", "}", "return", "self", "::", "_wrap", "(", "$", "clone", ")", ";", "}" ]
Returns a shallow copy of the object
[ "Returns", "a", "shallow", "copy", "of", "the", "object" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L664-L686
train
squareproton/Bond
lib/underscore.php
__.tap
public function tap($object=null, $interceptor=null) { list($object, $interceptor) = self::_wrapArgs(func_get_args(), 2); $interceptor($object); return self::_wrap($object); }
php
public function tap($object=null, $interceptor=null) { list($object, $interceptor) = self::_wrapArgs(func_get_args(), 2); $interceptor($object); return self::_wrap($object); }
[ "public", "function", "tap", "(", "$", "object", "=", "null", ",", "$", "interceptor", "=", "null", ")", "{", "list", "(", "$", "object", ",", "$", "interceptor", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "interceptor", "(", "$", "object", ")", ";", "return", "self", "::", "_wrap", "(", "$", "object", ")", ";", "}" ]
Invokes the interceptor on the object, then returns the object
[ "Invokes", "the", "interceptor", "on", "the", "object", "then", "returns", "the", "object" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L690-L695
train
squareproton/Bond
lib/underscore.php
__.has
public function has($collection=null, $key=null) { list($collection, $key) = self::_wrapArgs(func_get_args(), 2); $collection = (array) self::_collection($collection); return self::_wrap(array_key_exists($key, $collection)); }
php
public function has($collection=null, $key=null) { list($collection, $key) = self::_wrapArgs(func_get_args(), 2); $collection = (array) self::_collection($collection); return self::_wrap(array_key_exists($key, $collection)); }
[ "public", "function", "has", "(", "$", "collection", "=", "null", ",", "$", "key", "=", "null", ")", "{", "list", "(", "$", "collection", ",", "$", "key", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "collection", "=", "(", "array", ")", "self", "::", "_collection", "(", "$", "collection", ")", ";", "return", "self", "::", "_wrap", "(", "array_key_exists", "(", "$", "key", ",", "$", "collection", ")", ")", ";", "}" ]
Does the given key exist?
[ "Does", "the", "given", "key", "exist?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L699-L705
train
squareproton/Bond
lib/underscore.php
__.isEqual
public function isEqual($a=null, $b=null) { list($a, $b) = self::_wrapArgs(func_get_args(), 2); if(isset($this) && isset($this->_chained) && $this->_chained) $a =& $this; if($a === $b) return self::_wrap(true); if(gettype($a) !== gettype($b)) return self::_wrap(false); if(is_callable($a) !== is_callable($b)) return self::_wrap(false); if($a == $b) return self::_wrap(true); // Objects and arrays compared by values if(is_object($a) || is_array($a)) { // Do either implement isEqual()? if(is_object($a) && isset($a->isEqual)) return self::_wrap($a->isEqual($b)); if(is_object($b) && isset($b->isEqual)) return self::_wrap($b->isEqual($a)); if(is_array($a) && array_key_exists('isEqual', $a)) return self::_wrap($a['isEqual']($b)); if(is_array($b) && array_key_exists('isEqual', $b)) return self::_wrap($b['isEqual']($a)); if(count($a) !== count($b)) return self::_wrap(false); $__ = new self; $keys_equal = $__->isEqual($__->keys($a), $__->keys($b)); $values_equal = $__->isEqual($__->values($a), $__->values($b)); return self::_wrap($keys_equal && $values_equal); } return self::_wrap(false); }
php
public function isEqual($a=null, $b=null) { list($a, $b) = self::_wrapArgs(func_get_args(), 2); if(isset($this) && isset($this->_chained) && $this->_chained) $a =& $this; if($a === $b) return self::_wrap(true); if(gettype($a) !== gettype($b)) return self::_wrap(false); if(is_callable($a) !== is_callable($b)) return self::_wrap(false); if($a == $b) return self::_wrap(true); // Objects and arrays compared by values if(is_object($a) || is_array($a)) { // Do either implement isEqual()? if(is_object($a) && isset($a->isEqual)) return self::_wrap($a->isEqual($b)); if(is_object($b) && isset($b->isEqual)) return self::_wrap($b->isEqual($a)); if(is_array($a) && array_key_exists('isEqual', $a)) return self::_wrap($a['isEqual']($b)); if(is_array($b) && array_key_exists('isEqual', $b)) return self::_wrap($b['isEqual']($a)); if(count($a) !== count($b)) return self::_wrap(false); $__ = new self; $keys_equal = $__->isEqual($__->keys($a), $__->keys($b)); $values_equal = $__->isEqual($__->values($a), $__->values($b)); return self::_wrap($keys_equal && $values_equal); } return self::_wrap(false); }
[ "public", "function", "isEqual", "(", "$", "a", "=", "null", ",", "$", "b", "=", "null", ")", "{", "list", "(", "$", "a", ",", "$", "b", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "if", "(", "isset", "(", "$", "this", ")", "&&", "isset", "(", "$", "this", "->", "_chained", ")", "&&", "$", "this", "->", "_chained", ")", "$", "a", "=", "&", "$", "this", ";", "if", "(", "$", "a", "===", "$", "b", ")", "return", "self", "::", "_wrap", "(", "true", ")", ";", "if", "(", "gettype", "(", "$", "a", ")", "!==", "gettype", "(", "$", "b", ")", ")", "return", "self", "::", "_wrap", "(", "false", ")", ";", "if", "(", "is_callable", "(", "$", "a", ")", "!==", "is_callable", "(", "$", "b", ")", ")", "return", "self", "::", "_wrap", "(", "false", ")", ";", "if", "(", "$", "a", "==", "$", "b", ")", "return", "self", "::", "_wrap", "(", "true", ")", ";", "// Objects and arrays compared by values", "if", "(", "is_object", "(", "$", "a", ")", "||", "is_array", "(", "$", "a", ")", ")", "{", "// Do either implement isEqual()?", "if", "(", "is_object", "(", "$", "a", ")", "&&", "isset", "(", "$", "a", "->", "isEqual", ")", ")", "return", "self", "::", "_wrap", "(", "$", "a", "->", "isEqual", "(", "$", "b", ")", ")", ";", "if", "(", "is_object", "(", "$", "b", ")", "&&", "isset", "(", "$", "b", "->", "isEqual", ")", ")", "return", "self", "::", "_wrap", "(", "$", "b", "->", "isEqual", "(", "$", "a", ")", ")", ";", "if", "(", "is_array", "(", "$", "a", ")", "&&", "array_key_exists", "(", "'isEqual'", ",", "$", "a", ")", ")", "return", "self", "::", "_wrap", "(", "$", "a", "[", "'isEqual'", "]", "(", "$", "b", ")", ")", ";", "if", "(", "is_array", "(", "$", "b", ")", "&&", "array_key_exists", "(", "'isEqual'", ",", "$", "b", ")", ")", "return", "self", "::", "_wrap", "(", "$", "b", "[", "'isEqual'", "]", "(", "$", "a", ")", ")", ";", "if", "(", "count", "(", "$", "a", ")", "!==", "count", "(", "$", "b", ")", ")", "return", "self", "::", "_wrap", "(", "false", ")", ";", "$", "__", "=", "new", "self", ";", "$", "keys_equal", "=", "$", "__", "->", "isEqual", "(", "$", "__", "->", "keys", "(", "$", "a", ")", ",", "$", "__", "->", "keys", "(", "$", "b", ")", ")", ";", "$", "values_equal", "=", "$", "__", "->", "isEqual", "(", "$", "__", "->", "values", "(", "$", "a", ")", ",", "$", "__", "->", "values", "(", "$", "b", ")", ")", ";", "return", "self", "::", "_wrap", "(", "$", "keys_equal", "&&", "$", "values_equal", ")", ";", "}", "return", "self", "::", "_wrap", "(", "false", ")", ";", "}" ]
Are these items equal?
[ "Are", "these", "items", "equal?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L709-L738
train
squareproton/Bond
lib/underscore.php
__.isEmpty
public function isEmpty($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_array($item) || is_object($item)) ? !((bool) count((array) $item)) : (!(bool) $item); }
php
public function isEmpty($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_array($item) || is_object($item)) ? !((bool) count((array) $item)) : (!(bool) $item); }
[ "public", "function", "isEmpty", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "is_array", "(", "$", "item", ")", "||", "is_object", "(", "$", "item", ")", ")", "?", "!", "(", "(", "bool", ")", "count", "(", "(", "array", ")", "$", "item", ")", ")", ":", "(", "!", "(", "bool", ")", "$", "item", ")", ";", "}" ]
Is this item empty?
[ "Is", "this", "item", "empty?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L742-L746
train
squareproton/Bond
lib/underscore.php
__.isObject
public function isObject($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_object($item)); }
php
public function isObject($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_object($item)); }
[ "public", "function", "isObject", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "is_object", "(", "$", "item", ")", ")", ";", "}" ]
Is this item an object?
[ "Is", "this", "item", "an", "object?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L750-L753
train
squareproton/Bond
lib/underscore.php
__.isArray
public function isArray($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_array($item)); }
php
public function isArray($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_array($item)); }
[ "public", "function", "isArray", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "is_array", "(", "$", "item", ")", ")", ";", "}" ]
Is this item an array?
[ "Is", "this", "item", "an", "array?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L757-L760
train
squareproton/Bond
lib/underscore.php
__.isString
public function isString($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_string($item)); }
php
public function isString($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_string($item)); }
[ "public", "function", "isString", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "is_string", "(", "$", "item", ")", ")", ";", "}" ]
Is this item a string?
[ "Is", "this", "item", "a", "string?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L764-L767
train
squareproton/Bond
lib/underscore.php
__.isNumber
public function isNumber($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap((is_int($item) || is_float($item)) && !is_nan($item) && !is_infinite($item)); }
php
public function isNumber($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap((is_int($item) || is_float($item)) && !is_nan($item) && !is_infinite($item)); }
[ "public", "function", "isNumber", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "(", "is_int", "(", "$", "item", ")", "||", "is_float", "(", "$", "item", ")", ")", "&&", "!", "is_nan", "(", "$", "item", ")", "&&", "!", "is_infinite", "(", "$", "item", ")", ")", ";", "}" ]
Is this item a number?
[ "Is", "this", "item", "a", "number?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L771-L774
train
squareproton/Bond
lib/underscore.php
__.isBoolean
public function isBoolean($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_bool($item)); }
php
public function isBoolean($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_bool($item)); }
[ "public", "function", "isBoolean", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "is_bool", "(", "$", "item", ")", ")", ";", "}" ]
Is this item a bool?
[ "Is", "this", "item", "a", "bool?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L778-L781
train
squareproton/Bond
lib/underscore.php
__.isDate
public function isDate($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_object($item) && get_class($item) === 'DateTime'); }
php
public function isDate($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_object($item) && get_class($item) === 'DateTime'); }
[ "public", "function", "isDate", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "is_object", "(", "$", "item", ")", "&&", "get_class", "(", "$", "item", ")", "===", "'DateTime'", ")", ";", "}" ]
Is this item an instance of DateTime?
[ "Is", "this", "item", "an", "instance", "of", "DateTime?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L792-L795
train
squareproton/Bond
lib/underscore.php
__.isNaN
public function isNaN($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_nan($item)); }
php
public function isNaN($item=null) { list($item) = self::_wrapArgs(func_get_args(), 1); return self::_wrap(is_nan($item)); }
[ "public", "function", "isNaN", "(", "$", "item", "=", "null", ")", "{", "list", "(", "$", "item", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "is_nan", "(", "$", "item", ")", ")", ";", "}" ]
Is this item a NaN value?
[ "Is", "this", "item", "a", "NaN", "value?" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L799-L802
train
squareproton/Bond
lib/underscore.php
__.identity
public function identity() { $args = self::_wrapArgs(func_get_args(), 1); if(is_array($args)) return self::_wrap($args[0]); return self::_wrap(function($x) { return $x; }); }
php
public function identity() { $args = self::_wrapArgs(func_get_args(), 1); if(is_array($args)) return self::_wrap($args[0]); return self::_wrap(function($x) { return $x; }); }
[ "public", "function", "identity", "(", ")", "{", "$", "args", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "if", "(", "is_array", "(", "$", "args", ")", ")", "return", "self", "::", "_wrap", "(", "$", "args", "[", "0", "]", ")", ";", "return", "self", "::", "_wrap", "(", "function", "(", "$", "x", ")", "{", "return", "$", "x", ";", "}", ")", ";", "}" ]
Returns the same value passed as the argument
[ "Returns", "the", "same", "value", "passed", "as", "the", "argument" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L806-L814
train
squareproton/Bond
lib/underscore.php
__.times
public function times($n=null, $iterator=null) { list($n, $iterator) = self::_wrapArgs(func_get_args(), 2); if(is_null($n)) $n = 0; for($i=0; $i<$n; $i++) $iterator($i); return self::_wrap(null); }
php
public function times($n=null, $iterator=null) { list($n, $iterator) = self::_wrapArgs(func_get_args(), 2); if(is_null($n)) $n = 0; for($i=0; $i<$n; $i++) $iterator($i); return self::_wrap(null); }
[ "public", "function", "times", "(", "$", "n", "=", "null", ",", "$", "iterator", "=", "null", ")", "{", "list", "(", "$", "n", ",", "$", "iterator", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "if", "(", "is_null", "(", "$", "n", ")", ")", "$", "n", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "n", ";", "$", "i", "++", ")", "$", "iterator", "(", "$", "i", ")", ";", "return", "self", "::", "_wrap", "(", "null", ")", ";", "}" ]
Invokes the iterator n times
[ "Invokes", "the", "iterator", "n", "times" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L830-L836
train
squareproton/Bond
lib/underscore.php
__.templateSettings
public function templateSettings($settings=null) { $_template_settings =& self::getInstance()->_template_settings; if(is_null($settings)) { $_template_settings = array( 'evaluate' => self::TEMPLATE_DEFAULT_EVALUATE, 'interpolate' => self::TEMPLATE_DEFAULT_INTERPOLATE, 'escape' => self::TEMPLATE_DEFAULT_ESCAPE ); return true; } foreach($settings as $k=>$v) { if(!array_key_exists($k, $_template_settings)) continue; $_template_settings[$k] = $v; } return true; }
php
public function templateSettings($settings=null) { $_template_settings =& self::getInstance()->_template_settings; if(is_null($settings)) { $_template_settings = array( 'evaluate' => self::TEMPLATE_DEFAULT_EVALUATE, 'interpolate' => self::TEMPLATE_DEFAULT_INTERPOLATE, 'escape' => self::TEMPLATE_DEFAULT_ESCAPE ); return true; } foreach($settings as $k=>$v) { if(!array_key_exists($k, $_template_settings)) continue; $_template_settings[$k] = $v; } return true; }
[ "public", "function", "templateSettings", "(", "$", "settings", "=", "null", ")", "{", "$", "_template_settings", "=", "&", "self", "::", "getInstance", "(", ")", "->", "_template_settings", ";", "if", "(", "is_null", "(", "$", "settings", ")", ")", "{", "$", "_template_settings", "=", "array", "(", "'evaluate'", "=>", "self", "::", "TEMPLATE_DEFAULT_EVALUATE", ",", "'interpolate'", "=>", "self", "::", "TEMPLATE_DEFAULT_INTERPOLATE", ",", "'escape'", "=>", "self", "::", "TEMPLATE_DEFAULT_ESCAPE", ")", ";", "return", "true", ";", "}", "foreach", "(", "$", "settings", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "k", ",", "$", "_template_settings", ")", ")", "continue", ";", "$", "_template_settings", "[", "$", "k", "]", "=", "$", "v", ";", "}", "return", "true", ";", "}" ]
Set template settings
[ "Set", "template", "settings" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L882-L900
train
squareproton/Bond
lib/underscore.php
__.template
public function template($code=null, $context=null) { list($code, $context) = self::_wrapArgs(func_get_args(), 2); $class_name = __CLASS__; $return = self::_wrap(function($context=null) use ($code, $class_name) { $ts = $class_name::getInstance()->_template_settings; // Wrap escaped, interpolated, and evaluated blocks inside PHP tags extract((array) $context); preg_match_all($ts['escape'], $code, $vars, PREG_SET_ORDER); if(count($vars) > 0) { foreach($vars as $var) { $echo = $class_name::TEMPLATE_OPEN_TAG . ' echo htmlentities(' . trim($var[1]) . '); ' . $class_name::TEMPLATE_CLOSE_TAG; $code = str_replace($var[0], $echo, $code); } } preg_match_all($ts['interpolate'], $code, $vars, PREG_SET_ORDER); if(count($vars) > 0) { foreach($vars as $var) { $echo = $class_name::TEMPLATE_OPEN_TAG . ' echo ' . trim($var[1]) . '; ' . $class_name::TEMPLATE_CLOSE_TAG; $code = str_replace($var[0], $echo, $code); } } preg_match_all($ts['evaluate'], $code, $vars, PREG_SET_ORDER); if(count($vars) > 0) { foreach($vars as $var) { $echo = $class_name::TEMPLATE_OPEN_TAG . trim($var[1]) . $class_name::TEMPLATE_CLOSE_TAG; $code = str_replace($var[0], $echo, $code); } } $code = str_replace($class_name::TEMPLATE_OPEN_TAG, '<?php ', $code); $code = str_replace($class_name::TEMPLATE_CLOSE_TAG, '?>', $code); // Use the output buffer to grab the return value $code = 'ob_start(); extract($context); ?>' . $code . '<?php return ob_get_clean();'; $func = create_function('$context', $code); return $func((array) $context); }); // Return function or call function depending on context return self::_wrap(((isset($this) && isset($this->_wrapped) && $this->_wrapped) || !is_null($context)) ? $return($context) : $return); }
php
public function template($code=null, $context=null) { list($code, $context) = self::_wrapArgs(func_get_args(), 2); $class_name = __CLASS__; $return = self::_wrap(function($context=null) use ($code, $class_name) { $ts = $class_name::getInstance()->_template_settings; // Wrap escaped, interpolated, and evaluated blocks inside PHP tags extract((array) $context); preg_match_all($ts['escape'], $code, $vars, PREG_SET_ORDER); if(count($vars) > 0) { foreach($vars as $var) { $echo = $class_name::TEMPLATE_OPEN_TAG . ' echo htmlentities(' . trim($var[1]) . '); ' . $class_name::TEMPLATE_CLOSE_TAG; $code = str_replace($var[0], $echo, $code); } } preg_match_all($ts['interpolate'], $code, $vars, PREG_SET_ORDER); if(count($vars) > 0) { foreach($vars as $var) { $echo = $class_name::TEMPLATE_OPEN_TAG . ' echo ' . trim($var[1]) . '; ' . $class_name::TEMPLATE_CLOSE_TAG; $code = str_replace($var[0], $echo, $code); } } preg_match_all($ts['evaluate'], $code, $vars, PREG_SET_ORDER); if(count($vars) > 0) { foreach($vars as $var) { $echo = $class_name::TEMPLATE_OPEN_TAG . trim($var[1]) . $class_name::TEMPLATE_CLOSE_TAG; $code = str_replace($var[0], $echo, $code); } } $code = str_replace($class_name::TEMPLATE_OPEN_TAG, '<?php ', $code); $code = str_replace($class_name::TEMPLATE_CLOSE_TAG, '?>', $code); // Use the output buffer to grab the return value $code = 'ob_start(); extract($context); ?>' . $code . '<?php return ob_get_clean();'; $func = create_function('$context', $code); return $func((array) $context); }); // Return function or call function depending on context return self::_wrap(((isset($this) && isset($this->_wrapped) && $this->_wrapped) || !is_null($context)) ? $return($context) : $return); }
[ "public", "function", "template", "(", "$", "code", "=", "null", ",", "$", "context", "=", "null", ")", "{", "list", "(", "$", "code", ",", "$", "context", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "$", "class_name", "=", "__CLASS__", ";", "$", "return", "=", "self", "::", "_wrap", "(", "function", "(", "$", "context", "=", "null", ")", "use", "(", "$", "code", ",", "$", "class_name", ")", "{", "$", "ts", "=", "$", "class_name", "::", "getInstance", "(", ")", "->", "_template_settings", ";", "// Wrap escaped, interpolated, and evaluated blocks inside PHP tags", "extract", "(", "(", "array", ")", "$", "context", ")", ";", "preg_match_all", "(", "$", "ts", "[", "'escape'", "]", ",", "$", "code", ",", "$", "vars", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "count", "(", "$", "vars", ")", ">", "0", ")", "{", "foreach", "(", "$", "vars", "as", "$", "var", ")", "{", "$", "echo", "=", "$", "class_name", "::", "TEMPLATE_OPEN_TAG", ".", "' echo htmlentities('", ".", "trim", "(", "$", "var", "[", "1", "]", ")", ".", "'); '", ".", "$", "class_name", "::", "TEMPLATE_CLOSE_TAG", ";", "$", "code", "=", "str_replace", "(", "$", "var", "[", "0", "]", ",", "$", "echo", ",", "$", "code", ")", ";", "}", "}", "preg_match_all", "(", "$", "ts", "[", "'interpolate'", "]", ",", "$", "code", ",", "$", "vars", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "count", "(", "$", "vars", ")", ">", "0", ")", "{", "foreach", "(", "$", "vars", "as", "$", "var", ")", "{", "$", "echo", "=", "$", "class_name", "::", "TEMPLATE_OPEN_TAG", ".", "' echo '", ".", "trim", "(", "$", "var", "[", "1", "]", ")", ".", "'; '", ".", "$", "class_name", "::", "TEMPLATE_CLOSE_TAG", ";", "$", "code", "=", "str_replace", "(", "$", "var", "[", "0", "]", ",", "$", "echo", ",", "$", "code", ")", ";", "}", "}", "preg_match_all", "(", "$", "ts", "[", "'evaluate'", "]", ",", "$", "code", ",", "$", "vars", ",", "PREG_SET_ORDER", ")", ";", "if", "(", "count", "(", "$", "vars", ")", ">", "0", ")", "{", "foreach", "(", "$", "vars", "as", "$", "var", ")", "{", "$", "echo", "=", "$", "class_name", "::", "TEMPLATE_OPEN_TAG", ".", "trim", "(", "$", "var", "[", "1", "]", ")", ".", "$", "class_name", "::", "TEMPLATE_CLOSE_TAG", ";", "$", "code", "=", "str_replace", "(", "$", "var", "[", "0", "]", ",", "$", "echo", ",", "$", "code", ")", ";", "}", "}", "$", "code", "=", "str_replace", "(", "$", "class_name", "::", "TEMPLATE_OPEN_TAG", ",", "'<?php '", ",", "$", "code", ")", ";", "$", "code", "=", "str_replace", "(", "$", "class_name", "::", "TEMPLATE_CLOSE_TAG", ",", "'?>'", ",", "$", "code", ")", ";", "// Use the output buffer to grab the return value", "$", "code", "=", "'ob_start(); extract($context); ?>'", ".", "$", "code", ".", "'<?php return ob_get_clean();'", ";", "$", "func", "=", "create_function", "(", "'$context'", ",", "$", "code", ")", ";", "return", "$", "func", "(", "(", "array", ")", "$", "context", ")", ";", "}", ")", ";", "// Return function or call function depending on context", "return", "self", "::", "_wrap", "(", "(", "(", "isset", "(", "$", "this", ")", "&&", "isset", "(", "$", "this", "->", "_wrapped", ")", "&&", "$", "this", "->", "_wrapped", ")", "||", "!", "is_null", "(", "$", "context", ")", ")", "?", "$", "return", "(", "$", "context", ")", ":", "$", "return", ")", ";", "}" ]
Compile templates into functions that can be evaluated for rendering
[ "Compile", "templates", "into", "functions", "that", "can", "be", "evaluated", "for", "rendering" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L904-L947
train
squareproton/Bond
lib/underscore.php
__.wrap
public function wrap($function=null, $wrapper=null) { list($function, $wrapper) = self::_wrapArgs(func_get_args(), 2); return self::_wrap(function() use ($wrapper, $function) { $args = array_merge(array($function), func_get_args()); return call_user_func_array($wrapper, $args); }); }
php
public function wrap($function=null, $wrapper=null) { list($function, $wrapper) = self::_wrapArgs(func_get_args(), 2); return self::_wrap(function() use ($wrapper, $function) { $args = array_merge(array($function), func_get_args()); return call_user_func_array($wrapper, $args); }); }
[ "public", "function", "wrap", "(", "$", "function", "=", "null", ",", "$", "wrapper", "=", "null", ")", "{", "list", "(", "$", "function", ",", "$", "wrapper", ")", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "2", ")", ";", "return", "self", "::", "_wrap", "(", "function", "(", ")", "use", "(", "$", "wrapper", ",", "$", "function", ")", "{", "$", "args", "=", "array_merge", "(", "array", "(", "$", "function", ")", ",", "func_get_args", "(", ")", ")", ";", "return", "call_user_func_array", "(", "$", "wrapper", ",", "$", "args", ")", ";", "}", ")", ";", "}" ]
Wraps the function inside the wrapper function, passing it as the first argument
[ "Wraps", "the", "function", "inside", "the", "wrapper", "function", "passing", "it", "as", "the", "first", "argument" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L1033-L1040
train
squareproton/Bond
lib/underscore.php
__.compose
public function compose() { $functions = self::_wrapArgs(func_get_args(), 1); return self::_wrap(function() use ($functions) { $args = func_get_args(); foreach($functions as $function) { $args[0] = call_user_func_array($function, $args); } return $args[0]; }); }
php
public function compose() { $functions = self::_wrapArgs(func_get_args(), 1); return self::_wrap(function() use ($functions) { $args = func_get_args(); foreach($functions as $function) { $args[0] = call_user_func_array($function, $args); } return $args[0]; }); }
[ "public", "function", "compose", "(", ")", "{", "$", "functions", "=", "self", "::", "_wrapArgs", "(", "func_get_args", "(", ")", ",", "1", ")", ";", "return", "self", "::", "_wrap", "(", "function", "(", ")", "use", "(", "$", "functions", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "foreach", "(", "$", "functions", "as", "$", "function", ")", "{", "$", "args", "[", "0", "]", "=", "call_user_func_array", "(", "$", "function", ",", "$", "args", ")", ";", "}", "return", "$", "args", "[", "0", "]", ";", "}", ")", ";", "}" ]
Returns the composition of the functions
[ "Returns", "the", "composition", "of", "the", "functions" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L1044-L1054
train
squareproton/Bond
lib/underscore.php
__._wrap
private function _wrap($val) { if(isset($this) && isset($this->_chained) && $this->_chained) { $this->_wrapped = $val; return $this; } return $val; }
php
private function _wrap($val) { if(isset($this) && isset($this->_chained) && $this->_chained) { $this->_wrapped = $val; return $this; } return $val; }
[ "private", "function", "_wrap", "(", "$", "val", ")", "{", "if", "(", "isset", "(", "$", "this", ")", "&&", "isset", "(", "$", "this", "->", "_chained", ")", "&&", "$", "this", "->", "_chained", ")", "{", "$", "this", "->", "_wrapped", "=", "$", "val", ";", "return", "$", "this", ";", "}", "return", "$", "val", ";", "}" ]
Value passed from one chained method to the next
[ "Value", "passed", "from", "one", "chained", "method", "to", "the", "next" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L1089-L1095
train
squareproton/Bond
lib/underscore.php
__._wrapArgs
private function _wrapArgs($caller_args, $num_args=null) { $num_args = (is_null($num_args)) ? count($caller_args) - 1 : $num_args; $filled_args = array(); if(isset($this) && isset($this->_wrapped)) { $filled_args[] =& $this->_wrapped; } if(count($caller_args) > 0) { foreach($caller_args as $k=>$v) { $filled_args[] = $v; } } return array_pad($filled_args, $num_args, null); }
php
private function _wrapArgs($caller_args, $num_args=null) { $num_args = (is_null($num_args)) ? count($caller_args) - 1 : $num_args; $filled_args = array(); if(isset($this) && isset($this->_wrapped)) { $filled_args[] =& $this->_wrapped; } if(count($caller_args) > 0) { foreach($caller_args as $k=>$v) { $filled_args[] = $v; } } return array_pad($filled_args, $num_args, null); }
[ "private", "function", "_wrapArgs", "(", "$", "caller_args", ",", "$", "num_args", "=", "null", ")", "{", "$", "num_args", "=", "(", "is_null", "(", "$", "num_args", ")", ")", "?", "count", "(", "$", "caller_args", ")", "-", "1", ":", "$", "num_args", ";", "$", "filled_args", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", ")", "&&", "isset", "(", "$", "this", "->", "_wrapped", ")", ")", "{", "$", "filled_args", "[", "]", "=", "&", "$", "this", "->", "_wrapped", ";", "}", "if", "(", "count", "(", "$", "caller_args", ")", ">", "0", ")", "{", "foreach", "(", "$", "caller_args", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "filled_args", "[", "]", "=", "$", "v", ";", "}", "}", "return", "array_pad", "(", "$", "filled_args", ",", "$", "num_args", ",", "null", ")", ";", "}" ]
because this function understands both OO-style and functional calls
[ "because", "this", "function", "understands", "both", "OO", "-", "style", "and", "functional", "calls" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L1100-L1114
train
squareproton/Bond
lib/underscore.php
__._collection
private function _collection($collection) { return (!is_array($collection) && !is_object($collection)) ? str_split((string) $collection) : $collection; }
php
private function _collection($collection) { return (!is_array($collection) && !is_object($collection)) ? str_split((string) $collection) : $collection; }
[ "private", "function", "_collection", "(", "$", "collection", ")", "{", "return", "(", "!", "is_array", "(", "$", "collection", ")", "&&", "!", "is_object", "(", "$", "collection", ")", ")", "?", "str_split", "(", "(", "string", ")", "$", "collection", ")", ":", "$", "collection", ";", "}" ]
Get a collection in a way that supports strings
[ "Get", "a", "collection", "in", "a", "way", "that", "supports", "strings" ]
a04ad9dd1a35adeaec98237716c2a41ce02b4f1a
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/lib/underscore.php#L1118-L1120
train
jabernardo/console.php
src/Console/Input.php
Input.hasFlag
public function hasFlag($flag) { if (!is_string($flag)) { throw new \Console\Exception\InvalidArgument('Parameter must be string.'); } return in_array($flag, $this->_flags); }
php
public function hasFlag($flag) { if (!is_string($flag)) { throw new \Console\Exception\InvalidArgument('Parameter must be string.'); } return in_array($flag, $this->_flags); }
[ "public", "function", "hasFlag", "(", "$", "flag", ")", "{", "if", "(", "!", "is_string", "(", "$", "flag", ")", ")", "{", "throw", "new", "\\", "Console", "\\", "Exception", "\\", "InvalidArgument", "(", "'Parameter must be string.'", ")", ";", "}", "return", "in_array", "(", "$", "flag", ",", "$", "this", "->", "_flags", ")", ";", "}" ]
Check if flag exists @access public @param string $flag Flag to be checked @return boolean True / False @throws \Console\Exception\InvalidArgument Parameter must be string
[ "Check", "if", "flag", "exists" ]
a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c
https://github.com/jabernardo/console.php/blob/a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c/src/Console/Input.php#L110-L116
train
jabernardo/console.php
src/Console/Input.php
Input.hasOption
public function hasOption($option) { if (!is_string($option)) { throw new \Console\Exception\InvalidArgument('Parameter must be string.'); } return isset($this->_options[$option]); }
php
public function hasOption($option) { if (!is_string($option)) { throw new \Console\Exception\InvalidArgument('Parameter must be string.'); } return isset($this->_options[$option]); }
[ "public", "function", "hasOption", "(", "$", "option", ")", "{", "if", "(", "!", "is_string", "(", "$", "option", ")", ")", "{", "throw", "new", "\\", "Console", "\\", "Exception", "\\", "InvalidArgument", "(", "'Parameter must be string.'", ")", ";", "}", "return", "isset", "(", "$", "this", "->", "_options", "[", "$", "option", "]", ")", ";", "}" ]
Check if option exists @access public @param string $option Option name @return boolean True / False @throws \Console\Exception\InvalidArgument Parameter must be string
[ "Check", "if", "option", "exists" ]
a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c
https://github.com/jabernardo/console.php/blob/a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c/src/Console/Input.php#L126-L132
train
jabernardo/console.php
src/Console/Input.php
Input.hasOptions
public function hasOptions(array $options) { $all = true; foreach ($options as $option) { if (!isset($this->_options[$option])) { $all = false; } } return $all; }
php
public function hasOptions(array $options) { $all = true; foreach ($options as $option) { if (!isset($this->_options[$option])) { $all = false; } } return $all; }
[ "public", "function", "hasOptions", "(", "array", "$", "options", ")", "{", "$", "all", "=", "true", ";", "foreach", "(", "$", "options", "as", "$", "option", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_options", "[", "$", "option", "]", ")", ")", "{", "$", "all", "=", "false", ";", "}", "}", "return", "$", "all", ";", "}" ]
Check if multiple options are given in the command-line arguments @access public @param array $options Options to be check @return boolean True / False
[ "Check", "if", "multiple", "options", "are", "given", "in", "the", "command", "-", "line", "arguments" ]
a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c
https://github.com/jabernardo/console.php/blob/a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c/src/Console/Input.php#L141-L151
train
jabernardo/console.php
src/Console/Input.php
Input.getOption
public function getOption($option) { return isset($this->_options[$option]) ? $this->_options[$option] : null; }
php
public function getOption($option) { return isset($this->_options[$option]) ? $this->_options[$option] : null; }
[ "public", "function", "getOption", "(", "$", "option", ")", "{", "return", "isset", "(", "$", "this", "->", "_options", "[", "$", "option", "]", ")", "?", "$", "this", "->", "_options", "[", "$", "option", "]", ":", "null", ";", "}" ]
Get option value @access public @param string $option Option name @return mixed
[ "Get", "option", "value" ]
a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c
https://github.com/jabernardo/console.php/blob/a526458f4d1a525d0ccff62cd9cfcfbc5526bc9c/src/Console/Input.php#L160-L164
train
makinacorpus/drupal-apubsub
src/Notification/AbstractNotificationFormatter.php
AbstractNotificationFormatter.getUserAccountName
protected function getUserAccountName(NotificationInterface $notification, $keyInData = 'uid') { $names = []; $count = 0; if (isset($notification[$keyInData])) { $uidList = $notification[$keyInData]; $count = count($uidList); if (!is_array($uidList)) { $uidList = [$uidList]; } $names = array_map('format_username', user_load_multiple($uidList)); } if (empty($names)) { return; } if ($count) { return $this->getTitleString($names, $count); } }
php
protected function getUserAccountName(NotificationInterface $notification, $keyInData = 'uid') { $names = []; $count = 0; if (isset($notification[$keyInData])) { $uidList = $notification[$keyInData]; $count = count($uidList); if (!is_array($uidList)) { $uidList = [$uidList]; } $names = array_map('format_username', user_load_multiple($uidList)); } if (empty($names)) { return; } if ($count) { return $this->getTitleString($names, $count); } }
[ "protected", "function", "getUserAccountName", "(", "NotificationInterface", "$", "notification", ",", "$", "keyInData", "=", "'uid'", ")", "{", "$", "names", "=", "[", "]", ";", "$", "count", "=", "0", ";", "if", "(", "isset", "(", "$", "notification", "[", "$", "keyInData", "]", ")", ")", "{", "$", "uidList", "=", "$", "notification", "[", "$", "keyInData", "]", ";", "$", "count", "=", "count", "(", "$", "uidList", ")", ";", "if", "(", "!", "is_array", "(", "$", "uidList", ")", ")", "{", "$", "uidList", "=", "[", "$", "uidList", "]", ";", "}", "$", "names", "=", "array_map", "(", "'format_username'", ",", "user_load_multiple", "(", "$", "uidList", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "names", ")", ")", "{", "return", ";", "}", "if", "(", "$", "count", ")", "{", "return", "$", "this", "->", "getTitleString", "(", "$", "names", ",", "$", "count", ")", ";", "}", "}" ]
Return user account name for given uid @param NotificationInterface $notification @param string $keyInData Key in notification data in which to search for user names @return string
[ "Return", "user", "account", "name", "for", "given", "uid" ]
534fbecf67c880996ae02210c0bfdb3e0d3699b6
https://github.com/makinacorpus/drupal-apubsub/blob/534fbecf67c880996ae02210c0bfdb3e0d3699b6/src/Notification/AbstractNotificationFormatter.php#L90-L114
train
makinacorpus/drupal-apubsub
src/Notification/AbstractNotificationFormatter.php
AbstractNotificationFormatter.getTitleString
protected function getTitleString($titles, $count) { $limit = $this->getLimit(); $okCount = count($titles); $missing = $count - $okCount; $andCount = max([0, $okCount - $limit]) + $missing; if (!$okCount) { list($singular, $plural) = $this->getTypeLabelVariations($count); return $this->formatPlural($count, $singular, $plural); } if ($count < 2) { return reset($titles); } if ($okCount === 2 && !$andCount) { return $this->t("@name1 and @name2", array_combine(['@name1', '@name2'], $titles)); } if ($limit < $okCount) { $titles = array_slice($titles, 0, $limit); } $ret = implode(", ", $titles); if ($andCount) { $ret .= ' ' . $this->formatPlural($andCount, "and @count more", "and @count more"); } return $ret; }
php
protected function getTitleString($titles, $count) { $limit = $this->getLimit(); $okCount = count($titles); $missing = $count - $okCount; $andCount = max([0, $okCount - $limit]) + $missing; if (!$okCount) { list($singular, $plural) = $this->getTypeLabelVariations($count); return $this->formatPlural($count, $singular, $plural); } if ($count < 2) { return reset($titles); } if ($okCount === 2 && !$andCount) { return $this->t("@name1 and @name2", array_combine(['@name1', '@name2'], $titles)); } if ($limit < $okCount) { $titles = array_slice($titles, 0, $limit); } $ret = implode(", ", $titles); if ($andCount) { $ret .= ' ' . $this->formatPlural($andCount, "and @count more", "and @count more"); } return $ret; }
[ "protected", "function", "getTitleString", "(", "$", "titles", ",", "$", "count", ")", "{", "$", "limit", "=", "$", "this", "->", "getLimit", "(", ")", ";", "$", "okCount", "=", "count", "(", "$", "titles", ")", ";", "$", "missing", "=", "$", "count", "-", "$", "okCount", ";", "$", "andCount", "=", "max", "(", "[", "0", ",", "$", "okCount", "-", "$", "limit", "]", ")", "+", "$", "missing", ";", "if", "(", "!", "$", "okCount", ")", "{", "list", "(", "$", "singular", ",", "$", "plural", ")", "=", "$", "this", "->", "getTypeLabelVariations", "(", "$", "count", ")", ";", "return", "$", "this", "->", "formatPlural", "(", "$", "count", ",", "$", "singular", ",", "$", "plural", ")", ";", "}", "if", "(", "$", "count", "<", "2", ")", "{", "return", "reset", "(", "$", "titles", ")", ";", "}", "if", "(", "$", "okCount", "===", "2", "&&", "!", "$", "andCount", ")", "{", "return", "$", "this", "->", "t", "(", "\"@name1 and @name2\"", ",", "array_combine", "(", "[", "'@name1'", ",", "'@name2'", "]", ",", "$", "titles", ")", ")", ";", "}", "if", "(", "$", "limit", "<", "$", "okCount", ")", "{", "$", "titles", "=", "array_slice", "(", "$", "titles", ",", "0", ",", "$", "limit", ")", ";", "}", "$", "ret", "=", "implode", "(", "\", \"", ",", "$", "titles", ")", ";", "if", "(", "$", "andCount", ")", "{", "$", "ret", ".=", "' '", ".", "$", "this", "->", "formatPlural", "(", "$", "andCount", ",", "\"and @count more\"", ",", "\"and @count more\"", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Get title string @param string $titles @param int $count @return string
[ "Get", "title", "string" ]
534fbecf67c880996ae02210c0bfdb3e0d3699b6
https://github.com/makinacorpus/drupal-apubsub/blob/534fbecf67c880996ae02210c0bfdb3e0d3699b6/src/Notification/AbstractNotificationFormatter.php#L135-L164
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/validation/Errors.php
Errors.addFieldError
public function addFieldError($failureCode, $fieldResolved, $fieldType, $fieldTitle, $value, $defaultErrorMessage) { $this->errors[] = new FieldValidationError($failureCode, $fieldResolved, $fieldType, $fieldTitle, $value, $defaultErrorMessage); return $this; }
php
public function addFieldError($failureCode, $fieldResolved, $fieldType, $fieldTitle, $value, $defaultErrorMessage) { $this->errors[] = new FieldValidationError($failureCode, $fieldResolved, $fieldType, $fieldTitle, $value, $defaultErrorMessage); return $this; }
[ "public", "function", "addFieldError", "(", "$", "failureCode", ",", "$", "fieldResolved", ",", "$", "fieldType", ",", "$", "fieldTitle", ",", "$", "value", ",", "$", "defaultErrorMessage", ")", "{", "$", "this", "->", "errors", "[", "]", "=", "new", "FieldValidationError", "(", "$", "failureCode", ",", "$", "fieldResolved", ",", "$", "fieldType", ",", "$", "fieldTitle", ",", "$", "value", ",", "$", "defaultErrorMessage", ")", ";", "return", "$", "this", ";", "}" ]
Adds an error that is associated with a form field. @param string $failureCode The code or slug that identifies this error's failure cause @param string $fieldResolved The machine-readable error code that uniquely identifies the error @param string $fieldType Can be 'field', 'meta', or 'tag' to determine the type of error field @param string $fieldTitle The title or human readable name for the failing field @param string $value The value that was invalid @param string $defaultErrorMessage A default error message to display if we can't Lookup another one using the failureCode @return this
[ "Adds", "an", "error", "that", "is", "associated", "with", "a", "form", "field", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/validation/Errors.php#L93-L97
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/validation/Errors.php
Errors.addErrors
public function addErrors(array $errors) { foreach ($errors as $error) { if (!$error instanceof ValidationError) throw new Exception('Error was not instance of ValidationError: '.$error); if (!in_array($error, $this->errors)) $this->errors[] = $error; } return $this; }
php
public function addErrors(array $errors) { foreach ($errors as $error) { if (!$error instanceof ValidationError) throw new Exception('Error was not instance of ValidationError: '.$error); if (!in_array($error, $this->errors)) $this->errors[] = $error; } return $this; }
[ "public", "function", "addErrors", "(", "array", "$", "errors", ")", "{", "foreach", "(", "$", "errors", "as", "$", "error", ")", "{", "if", "(", "!", "$", "error", "instanceof", "ValidationError", ")", "throw", "new", "Exception", "(", "'Error was not instance of ValidationError: '", ".", "$", "error", ")", ";", "if", "(", "!", "in_array", "(", "$", "error", ",", "$", "this", "->", "errors", ")", ")", "$", "this", "->", "errors", "[", "]", "=", "$", "error", ";", "}", "return", "$", "this", ";", "}" ]
Adds more than one error to the collection of errors @param array $errors Each object in the array must be of type ValidationError @return this
[ "Adds", "more", "than", "one", "error", "to", "the", "collection", "of", "errors" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/validation/Errors.php#L119-L129
train