id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
27,100
drupal/core-utility
Html.php
Html.load
public static function load($html) { $document = <<<EOD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head> <body>!html</body> </ht...
php
public static function load($html) { $document = <<<EOD <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head> <body>!html</body> </ht...
[ "public", "static", "function", "load", "(", "$", "html", ")", "{", "$", "document", "=", " <<<EOD\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\">\n<head><meta http-equiv=\"Conte...
Parses an HTML snippet and returns it as a DOM object. This function loads the body part of a partial (X)HTML document and returns a full \DOMDocument object that represents this document. Use \Drupal\Component\Utility\Html::serialize() to serialize this \DOMDocument back to a string. @param string $html The partial...
[ "Parses", "an", "HTML", "snippet", "and", "returns", "it", "as", "a", "DOM", "object", "." ]
fb1c262da83fb691bcdf1680c3a69791a1d1a01a
https://github.com/drupal/core-utility/blob/fb1c262da83fb691bcdf1680c3a69791a1d1a01a/Html.php#L273-L291
27,101
drupal/core-utility
Html.php
Html.transformRootRelativeUrlsToAbsolute
public static function transformRootRelativeUrlsToAbsolute($html, $scheme_and_host) { assert('empty(array_diff(array_keys(parse_url($scheme_and_host)), ["scheme", "host", "port"]))', '$scheme_and_host contains scheme, host and port at most.'); assert('isset(parse_url($scheme_and_host)["scheme"])', '$scheme_and_...
php
public static function transformRootRelativeUrlsToAbsolute($html, $scheme_and_host) { assert('empty(array_diff(array_keys(parse_url($scheme_and_host)), ["scheme", "host", "port"]))', '$scheme_and_host contains scheme, host and port at most.'); assert('isset(parse_url($scheme_and_host)["scheme"])', '$scheme_and_...
[ "public", "static", "function", "transformRootRelativeUrlsToAbsolute", "(", "$", "html", ",", "$", "scheme_and_host", ")", "{", "assert", "(", "'empty(array_diff(array_keys(parse_url($scheme_and_host)), [\"scheme\", \"host\", \"port\"]))'", ",", "'$scheme_and_host contains scheme, ho...
Converts all root-relative URLs to absolute URLs. Does not change any existing protocol-relative or absolute URLs. Does not change other relative URLs because they would result in different absolute URLs depending on the current path. For example: when the same content containing such a relative URL (for example 'imag...
[ "Converts", "all", "root", "-", "relative", "URLs", "to", "absolute", "URLs", "." ]
fb1c262da83fb691bcdf1680c3a69791a1d1a01a
https://github.com/drupal/core-utility/blob/fb1c262da83fb691bcdf1680c3a69791a1d1a01a/Html.php#L453-L481
27,102
bitpressio/blade-extensions
src/Container/BladeRegistrar.php
BladeRegistrar.register
public static function register($extension, $concrete = null) { app()->singleton($extension, $concrete); app()->tag($extension, 'blade.extension'); }
php
public static function register($extension, $concrete = null) { app()->singleton($extension, $concrete); app()->tag($extension, 'blade.extension'); }
[ "public", "static", "function", "register", "(", "$", "extension", ",", "$", "concrete", "=", "null", ")", "{", "app", "(", ")", "->", "singleton", "(", "$", "extension", ",", "$", "concrete", ")", ";", "app", "(", ")", "->", "tag", "(", "$", "exte...
Register and tag a blade service in the container @param string|array $abstract @param \Closure|string|null $concrete
[ "Register", "and", "tag", "a", "blade", "service", "in", "the", "container" ]
eeb4f3acb7253ee28302530c0bd25c5113248507
https://github.com/bitpressio/blade-extensions/blob/eeb4f3acb7253ee28302530c0bd25c5113248507/src/Container/BladeRegistrar.php#L13-L17
27,103
axiom-labs/rivescript-php
src/Cortex/Tags/Tag.php
Tag.getMatches
protected function getMatches($source) { if ($this->hasMatches($source)) { preg_match_all($this->pattern, $source, $matches, PREG_SET_ORDER); return $matches; } }
php
protected function getMatches($source) { if ($this->hasMatches($source)) { preg_match_all($this->pattern, $source, $matches, PREG_SET_ORDER); return $matches; } }
[ "protected", "function", "getMatches", "(", "$", "source", ")", "{", "if", "(", "$", "this", "->", "hasMatches", "(", "$", "source", ")", ")", "{", "preg_match_all", "(", "$", "this", "->", "pattern", ",", "$", "source", ",", "$", "matches", ",", "PR...
Get the regular expression matches from the source. @param string $source @return array
[ "Get", "the", "regular", "expression", "matches", "from", "the", "source", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Tags/Tag.php#L60-L67
27,104
axiom-labs/rivescript-php
src/Cortex/Output.php
Output.process
public function process() { synapse()->brain->topic()->triggers()->each(function ($data, $trigger) { $this->searchTriggers($trigger); if ($this->output !== 'Error: Response could not be determined.') { return false; } }); return $this->ou...
php
public function process() { synapse()->brain->topic()->triggers()->each(function ($data, $trigger) { $this->searchTriggers($trigger); if ($this->output !== 'Error: Response could not be determined.') { return false; } }); return $this->ou...
[ "public", "function", "process", "(", ")", "{", "synapse", "(", ")", "->", "brain", "->", "topic", "(", ")", "->", "triggers", "(", ")", "->", "each", "(", "function", "(", "$", "data", ",", "$", "trigger", ")", "{", "$", "this", "->", "searchTrigg...
Process the correct output response by the interpreter. @return mixed
[ "Process", "the", "correct", "output", "response", "by", "the", "interpreter", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Output.php#L37-L48
27,105
axiom-labs/rivescript-php
src/Cortex/Output.php
Output.searchTriggers
protected function searchTriggers($trigger) { synapse()->triggers->each(function ($class) use ($trigger) { $triggerClass = "\\Axiom\\Rivescript\\Cortex\\Triggers\\$class"; $triggerClass = new $triggerClass(); $found = $triggerClass->parse($trigger, $this->input); ...
php
protected function searchTriggers($trigger) { synapse()->triggers->each(function ($class) use ($trigger) { $triggerClass = "\\Axiom\\Rivescript\\Cortex\\Triggers\\$class"; $triggerClass = new $triggerClass(); $found = $triggerClass->parse($trigger, $this->input); ...
[ "protected", "function", "searchTriggers", "(", "$", "trigger", ")", "{", "synapse", "(", ")", "->", "triggers", "->", "each", "(", "function", "(", "$", "class", ")", "use", "(", "$", "trigger", ")", "{", "$", "triggerClass", "=", "\"\\\\Axiom\\\\Rivescri...
Search through available triggers to find a possible match. @param string $trigger @return bool
[ "Search", "through", "available", "triggers", "to", "find", "a", "possible", "match", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Output.php#L57-L71
27,106
axiom-labs/rivescript-php
src/Cortex/Output.php
Output.getResponse
protected function getResponse($trigger) { $trigger = synapse()->brain->topic()->triggers()->get($trigger); if (isset($trigger['redirect'])) { return $this->getResponse($trigger['redirect']); } $key = array_rand($trigger['responses']); $this->output = $...
php
protected function getResponse($trigger) { $trigger = synapse()->brain->topic()->triggers()->get($trigger); if (isset($trigger['redirect'])) { return $this->getResponse($trigger['redirect']); } $key = array_rand($trigger['responses']); $this->output = $...
[ "protected", "function", "getResponse", "(", "$", "trigger", ")", "{", "$", "trigger", "=", "synapse", "(", ")", "->", "brain", "->", "topic", "(", ")", "->", "triggers", "(", ")", "->", "get", "(", "$", "trigger", ")", ";", "if", "(", "isset", "("...
Fetch a response from the found trigger. @param string $trigger; @return void
[ "Fetch", "a", "response", "from", "the", "found", "trigger", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Output.php#L80-L90
27,107
axiom-labs/rivescript-php
src/Rivescript.php
Rivescript.load
public function load($files) { $files = (! is_array($files)) ? (array) $files : $files; foreach ($files as $file) { synapse()->brain->teach($file); } }
php
public function load($files) { $files = (! is_array($files)) ? (array) $files : $files; foreach ($files as $file) { synapse()->brain->teach($file); } }
[ "public", "function", "load", "(", "$", "files", ")", "{", "$", "files", "=", "(", "!", "is_array", "(", "$", "files", ")", ")", "?", "(", "array", ")", "$", "files", ":", "$", "files", ";", "foreach", "(", "$", "files", "as", "$", "file", ")",...
Load RiveScript documents from files. @param array|string $files
[ "Load", "RiveScript", "documents", "from", "files", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Rivescript.php#L23-L30
27,108
axiom-labs/rivescript-php
src/Console/ChatCommand.php
ChatCommand.waitForUserInput
protected function waitForUserInput(InputInterface $input, OutputInterface $output) { $helper = $this->getHelper('question'); $question = new Question('<info>You > </info>'); $message = $helper->ask($input, $output, $question); $this->listenForConsoleCommands($input, $output, $me...
php
protected function waitForUserInput(InputInterface $input, OutputInterface $output) { $helper = $this->getHelper('question'); $question = new Question('<info>You > </info>'); $message = $helper->ask($input, $output, $question); $this->listenForConsoleCommands($input, $output, $me...
[ "protected", "function", "waitForUserInput", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "'question'", ")", ";", "$", "question", "=", "new", "Question", "(", ...
Wait and listen for user input. @param InputInterface $input @param OutputInterface $output @return null
[ "Wait", "and", "listen", "for", "user", "input", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Console/ChatCommand.php#L78-L88
27,109
axiom-labs/rivescript-php
src/Console/ChatCommand.php
ChatCommand.listenForConsoleCommands
protected function listenForConsoleCommands(InputInterface $input, OutputInterface $output, $message) { if ($message === '/quit') { $output->writeln('Exiting...'); die(); } if ($message === '/reload') { return $this->execute($input, $output); } ...
php
protected function listenForConsoleCommands(InputInterface $input, OutputInterface $output, $message) { if ($message === '/quit') { $output->writeln('Exiting...'); die(); } if ($message === '/reload') { return $this->execute($input, $output); } ...
[ "protected", "function", "listenForConsoleCommands", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "$", "message", ")", "{", "if", "(", "$", "message", "===", "'/quit'", ")", "{", "$", "output", "->", "writeln", "(", "'Exit...
Listen for console commands before passing message to interpreter. @param InputInterface $input @param OutputInterface $output @param string $message @return null
[ "Listen", "for", "console", "commands", "before", "passing", "message", "to", "interpreter", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Console/ChatCommand.php#L98-L124
27,110
axiom-labs/rivescript-php
src/Console/ChatCommand.php
ChatCommand.getBotResponse
protected function getBotResponse(InputInterface $input, OutputInterface $output, $message) { $bot = 'Bot > '; $reply = $this->rivescript->reply($message); $response = "<info>{$reply}</info>"; $output->writeln($bot.$response); $this->waitForUserInput($input, $output...
php
protected function getBotResponse(InputInterface $input, OutputInterface $output, $message) { $bot = 'Bot > '; $reply = $this->rivescript->reply($message); $response = "<info>{$reply}</info>"; $output->writeln($bot.$response); $this->waitForUserInput($input, $output...
[ "protected", "function", "getBotResponse", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "$", "message", ")", "{", "$", "bot", "=", "'Bot > '", ";", "$", "reply", "=", "$", "this", "->", "rivescript", "->", "reply", "(", ...
Pass along user message to interpreter and fetch a reply. @param InputInterface $input @param OutputInterface $output @param string $message @return null
[ "Pass", "along", "user", "message", "to", "interpreter", "and", "fetch", "a", "reply", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Console/ChatCommand.php#L134-L143
27,111
axiom-labs/rivescript-php
src/Console/ChatCommand.php
ChatCommand.loadFiles
private function loadFiles($files) { if (is_dir($files)) { $directory = realpath($files); $files = []; $brains = glob($directory.'/*.rive'); foreach ($brains as $brain) { $files[] = $brain; } return $files; ...
php
private function loadFiles($files) { if (is_dir($files)) { $directory = realpath($files); $files = []; $brains = glob($directory.'/*.rive'); foreach ($brains as $brain) { $files[] = $brain; } return $files; ...
[ "private", "function", "loadFiles", "(", "$", "files", ")", "{", "if", "(", "is_dir", "(", "$", "files", ")", ")", "{", "$", "directory", "=", "realpath", "(", "$", "files", ")", ";", "$", "files", "=", "[", "]", ";", "$", "brains", "=", "glob", ...
Load and return an array of files. @param string $files @return array
[ "Load", "and", "return", "an", "array", "of", "files", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Console/ChatCommand.php#L151-L166
27,112
axiom-labs/rivescript-php
src/Cortex/Memory.php
Memory.user
public function user($user = 0) { if (! $this->user->has($user)) { $data = new Collection([]); $this->user->put($user, $data); } return $this->user->get($user); }
php
public function user($user = 0) { if (! $this->user->has($user)) { $data = new Collection([]); $this->user->put($user, $data); } return $this->user->get($user); }
[ "public", "function", "user", "(", "$", "user", "=", "0", ")", "{", "if", "(", "!", "$", "this", "->", "user", "->", "has", "(", "$", "user", ")", ")", "{", "$", "data", "=", "new", "Collection", "(", "[", "]", ")", ";", "$", "this", "->", ...
Stored user data. @return Collection
[ "Stored", "user", "data", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Memory.php#L91-L100
27,113
axiom-labs/rivescript-php
src/Cortex/Node.php
Node.determineCommand
protected function determineCommand() { if (mb_strlen($this->source) === 0) { $this->isInterrupted = true; return; } $this->command = mb_substr($this->source, 0, 1); }
php
protected function determineCommand() { if (mb_strlen($this->source) === 0) { $this->isInterrupted = true; return; } $this->command = mb_substr($this->source, 0, 1); }
[ "protected", "function", "determineCommand", "(", ")", "{", "if", "(", "mb_strlen", "(", "$", "this", "->", "source", ")", "===", "0", ")", "{", "$", "this", "->", "isInterrupted", "=", "true", ";", "return", ";", "}", "$", "this", "->", "command", "...
Determine the command type of the node. @return void
[ "Determine", "the", "command", "type", "of", "the", "node", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Node.php#L108-L117
27,114
axiom-labs/rivescript-php
src/Cortex/Node.php
Node.determineComment
protected function determineComment() { if (starts_with($this->source, '//')) { $this->isInterrupted = true; } elseif (starts_with($this->source, '#')) { log_warning('Using the # symbol for comments is deprecated'); $this->isInterrupted = true; } elseif (s...
php
protected function determineComment() { if (starts_with($this->source, '//')) { $this->isInterrupted = true; } elseif (starts_with($this->source, '#')) { log_warning('Using the # symbol for comments is deprecated'); $this->isInterrupted = true; } elseif (s...
[ "protected", "function", "determineComment", "(", ")", "{", "if", "(", "starts_with", "(", "$", "this", "->", "source", ",", "'//'", ")", ")", "{", "$", "this", "->", "isInterrupted", "=", "true", ";", "}", "elseif", "(", "starts_with", "(", "$", "this...
Determine if the current node source is a comment. @return void
[ "Determine", "if", "the", "current", "node", "source", "is", "a", "comment", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Node.php#L124-L139
27,115
Happyr/GoogleSiteAuthenticatorBundle
Controller/AdminController.php
AdminController.authenticateAction
public function authenticateAction(Request $request, $name) { /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $client = $clientProvider->getClient($name); // This will allow us to get refresh the token $clie...
php
public function authenticateAction(Request $request, $name) { /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $client = $clientProvider->getClient($name); // This will allow us to get refresh the token $clie...
[ "public", "function", "authenticateAction", "(", "Request", "$", "request", ",", "$", "name", ")", "{", "/* @var \\Google_Client $client */", "$", "clientProvider", "=", "$", "this", "->", "get", "(", "'happyr.google_site_authenticator.client_provider'", ")", ";", "$"...
This action starts the authentication. @param Request $request @param $name @return Response
[ "This", "action", "starts", "the", "authentication", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Controller/AdminController.php#L41-L54
27,116
Happyr/GoogleSiteAuthenticatorBundle
Controller/AdminController.php
AdminController.revokeAction
public function revokeAction($name) { /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $client = $clientProvider->getClient($name); $client->revokeToken(); $clientProvider->setAccessToken(null, $name); ...
php
public function revokeAction($name) { /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $client = $clientProvider->getClient($name); $client->revokeToken(); $clientProvider->setAccessToken(null, $name); ...
[ "public", "function", "revokeAction", "(", "$", "name", ")", "{", "/* @var \\Google_Client $client */", "$", "clientProvider", "=", "$", "this", "->", "get", "(", "'happyr.google_site_authenticator.client_provider'", ")", ";", "$", "client", "=", "$", "clientProvider"...
This action revokes the authentication token. This make sure the token can not be used on any other site. @param Request $request @param $name @return Response
[ "This", "action", "revokes", "the", "authentication", "token", ".", "This", "make", "sure", "the", "token", "can", "not", "be", "used", "on", "any", "other", "site", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Controller/AdminController.php#L64-L76
27,117
Happyr/GoogleSiteAuthenticatorBundle
Controller/AdminController.php
AdminController.removeAction
public function removeAction($name) { /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $clientProvider->setAccessToken(null, $name); $this->get('session')->getFlashbag()->add('msg', 'Token was removed.'); re...
php
public function removeAction($name) { /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $clientProvider->setAccessToken(null, $name); $this->get('session')->getFlashbag()->add('msg', 'Token was removed.'); re...
[ "public", "function", "removeAction", "(", "$", "name", ")", "{", "/* @var \\Google_Client $client */", "$", "clientProvider", "=", "$", "this", "->", "get", "(", "'happyr.google_site_authenticator.client_provider'", ")", ";", "$", "clientProvider", "->", "setAccessToke...
This action removes the authentication token form the storage. @param Request $request @param $name @return Response
[ "This", "action", "removes", "the", "authentication", "token", "form", "the", "storage", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Controller/AdminController.php#L86-L95
27,118
Happyr/GoogleSiteAuthenticatorBundle
Controller/AdminController.php
AdminController.returnAction
public function returnAction(Request $request) { $name = $request->getSession()->get(self::SESSION_KEY, null); /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $client = $clientProvider->getClient($name); $f...
php
public function returnAction(Request $request) { $name = $request->getSession()->get(self::SESSION_KEY, null); /* @var \Google_Client $client */ $clientProvider = $this->get('happyr.google_site_authenticator.client_provider'); $client = $clientProvider->getClient($name); $f...
[ "public", "function", "returnAction", "(", "Request", "$", "request", ")", "{", "$", "name", "=", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "self", "::", "SESSION_KEY", ",", "null", ")", ";", "/* @var \\Google_Client $client */", "$", ...
This action is used when the user has authenticated with google. @param Request $request @return Response
[ "This", "action", "is", "used", "when", "the", "user", "has", "authenticated", "with", "google", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Controller/AdminController.php#L104-L127
27,119
Happyr/GoogleSiteAuthenticatorBundle
Model/TokenConfig.php
TokenConfig.getKey
public function getKey(string $key = null): string { if ($key === null) { return $this->defaultKey; } if (!isset($this->tokens[$key])) { throw new \LogicException(sprintf('Token with name %s could not be found', $key)); } return $key; }
php
public function getKey(string $key = null): string { if ($key === null) { return $this->defaultKey; } if (!isset($this->tokens[$key])) { throw new \LogicException(sprintf('Token with name %s could not be found', $key)); } return $key; }
[ "public", "function", "getKey", "(", "string", "$", "key", "=", "null", ")", ":", "string", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "$", "this", "->", "defaultKey", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->",...
Get the key from the argument or the default key.
[ "Get", "the", "key", "from", "the", "argument", "or", "the", "default", "key", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Model/TokenConfig.php#L38-L49
27,120
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.createCard
public function createCard(BasePaymentForm $paymentForm, Order $order = null): CreditCard { $card = new CreditCard; if ($paymentForm instanceof CreditCardPaymentForm) { $this->populateCard($card, $paymentForm); } if ($order) { if ($billingAddress = $order->getB...
php
public function createCard(BasePaymentForm $paymentForm, Order $order = null): CreditCard { $card = new CreditCard; if ($paymentForm instanceof CreditCardPaymentForm) { $this->populateCard($card, $paymentForm); } if ($order) { if ($billingAddress = $order->getB...
[ "public", "function", "createCard", "(", "BasePaymentForm", "$", "paymentForm", ",", "Order", "$", "order", "=", "null", ")", ":", "CreditCard", "{", "$", "card", "=", "new", "CreditCard", ";", "if", "(", "$", "paymentForm", "instanceof", "CreditCardPaymentFor...
Create a card object using the payment form and the optional order @param BasePaymentForm $paymentForm @param Order $order @return CreditCard
[ "Create", "a", "card", "object", "using", "the", "payment", "form", "and", "the", "optional", "order" ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L189-L246
27,121
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.populateCard
public function populateCard($card, CreditCardPaymentForm $paymentForm) { if (!$card instanceof CreditCard) { return; } $card->setFirstName($paymentForm->firstName); $card->setLastName($paymentForm->lastName); $card->setNumber($paymentForm->number); $card...
php
public function populateCard($card, CreditCardPaymentForm $paymentForm) { if (!$card instanceof CreditCard) { return; } $card->setFirstName($paymentForm->firstName); $card->setLastName($paymentForm->lastName); $card->setNumber($paymentForm->number); $card...
[ "public", "function", "populateCard", "(", "$", "card", ",", "CreditCardPaymentForm", "$", "paymentForm", ")", "{", "if", "(", "!", "$", "card", "instanceof", "CreditCard", ")", "{", "return", ";", "}", "$", "card", "->", "setFirstName", "(", "$", "payment...
Populate a credit card from the paymnent form. @param CreditCard $card The credit card to populate. @param CreditCardPaymentForm $paymentForm The payment form. @return void
[ "Populate", "a", "credit", "card", "from", "the", "paymnent", "form", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L320-L332
27,122
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.createItemBagForOrder
protected function createItemBagForOrder(Order $order) { if (!$this->sendCartInfo) { return null; } $items = $this->getItemListForOrder($order); $itemBagClassName = $this->getItemBagClassName(); return new $itemBagClassName($items); }
php
protected function createItemBagForOrder(Order $order) { if (!$this->sendCartInfo) { return null; } $items = $this->getItemListForOrder($order); $itemBagClassName = $this->getItemBagClassName(); return new $itemBagClassName($items); }
[ "protected", "function", "createItemBagForOrder", "(", "Order", "$", "order", ")", "{", "if", "(", "!", "$", "this", "->", "sendCartInfo", ")", "{", "return", "null", ";", "}", "$", "items", "=", "$", "this", "->", "getItemListForOrder", "(", "$", "order...
Create a gateway specific item bag for the order. @param Order $order The order. @return ItemBag|null
[ "Create", "a", "gateway", "specific", "item", "bag", "for", "the", "order", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L472-L482
27,123
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.createPaymentRequest
protected function createPaymentRequest(Transaction $transaction, $card = null, $itemBag = null): array { $params = ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash]; $request = [ 'amount' => $transaction->paymentAmount, 'currency...
php
protected function createPaymentRequest(Transaction $transaction, $card = null, $itemBag = null): array { $params = ['commerceTransactionId' => $transaction->id, 'commerceTransactionHash' => $transaction->hash]; $request = [ 'amount' => $transaction->paymentAmount, 'currency...
[ "protected", "function", "createPaymentRequest", "(", "Transaction", "$", "transaction", ",", "$", "card", "=", "null", ",", "$", "itemBag", "=", "null", ")", ":", "array", "{", "$", "params", "=", "[", "'commerceTransactionId'", "=>", "$", "transaction", "-...
Create the parameters for a payment request based on a trasaction and optional card and item list. @param Transaction $transaction The transaction that is basis for this request. @param CreditCard $card The credit card being used @param ItemBag $itemBag The item list. @return array @throws \yii\base\E...
[ "Create", "the", "parameters", "for", "a", "payment", "request", "based", "on", "a", "trasaction", "and", "optional", "card", "and", "item", "list", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L494-L542
27,124
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.createRequest
protected function createRequest(Transaction $transaction, BasePaymentForm $form = null) { // For authorize and capture we're referring to a transaction that already took place so no card or item shenanigans. if (in_array($transaction->type, [TransactionRecord::TYPE_REFUND, TransactionRecord::TYPE_C...
php
protected function createRequest(Transaction $transaction, BasePaymentForm $form = null) { // For authorize and capture we're referring to a transaction that already took place so no card or item shenanigans. if (in_array($transaction->type, [TransactionRecord::TYPE_REFUND, TransactionRecord::TYPE_C...
[ "protected", "function", "createRequest", "(", "Transaction", "$", "transaction", ",", "BasePaymentForm", "$", "form", "=", "null", ")", "{", "// For authorize and capture we're referring to a transaction that already took place so no card or item shenanigans.", "if", "(", "in_ar...
Prepare a request for execution by transaction and a populated payment form. @param Transaction $transaction @param BasePaymentForm $form Optional for capture/refund requests. @return mixed @throws \yii\base\Exception
[ "Prepare", "a", "request", "for", "execution", "by", "transaction", "and", "a", "populated", "payment", "form", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L554-L575
27,125
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.extractCardReference
protected function extractCardReference(ResponseInterface $response): string { if (!$response->isSuccessful()) { throw new PaymentException($response->getMessage()); } return (string) $response->getTransactionReference(); }
php
protected function extractCardReference(ResponseInterface $response): string { if (!$response->isSuccessful()) { throw new PaymentException($response->getMessage()); } return (string) $response->getTransactionReference(); }
[ "protected", "function", "extractCardReference", "(", "ResponseInterface", "$", "response", ")", ":", "string", "{", "if", "(", "!", "$", "response", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "PaymentException", "(", "$", "response", "->", "g...
Extract a card reference from a response @param ResponseInterface $response The response to use @return string @throws PaymentException on failure
[ "Extract", "a", "card", "reference", "from", "a", "response" ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L585-L592
27,126
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.getItemBagForOrder
protected function getItemBagForOrder(Order $order) { $itemBag = $this->createItemBagForOrder($order); $event = new ItemBagEvent([ 'items' => $itemBag, 'order' => $order ]); $this->trigger(self::EVENT_AFTER_CREATE_ITEM_BAG, $event); return $event->it...
php
protected function getItemBagForOrder(Order $order) { $itemBag = $this->createItemBagForOrder($order); $event = new ItemBagEvent([ 'items' => $itemBag, 'order' => $order ]); $this->trigger(self::EVENT_AFTER_CREATE_ITEM_BAG, $event); return $event->it...
[ "protected", "function", "getItemBagForOrder", "(", "Order", "$", "order", ")", "{", "$", "itemBag", "=", "$", "this", "->", "createItemBagForOrder", "(", "$", "order", ")", ";", "$", "event", "=", "new", "ItemBagEvent", "(", "[", "'items'", "=>", "$", "...
Get the item bag for the order. @param Order $order @return mixed
[ "Get", "the", "item", "bag", "for", "the", "order", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L641-L652
27,127
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.getItemListForOrder
protected function getItemListForOrder(Order $order): array { $items = []; $priceCheck = 0; $count = -1; /** @var LineItem $item */ foreach ($order->lineItems as $item) { $price = Currency::round($item->salePrice); // Can not accept zero amount items...
php
protected function getItemListForOrder(Order $order): array { $items = []; $priceCheck = 0; $count = -1; /** @var LineItem $item */ foreach ($order->lineItems as $item) { $price = Currency::round($item->salePrice); // Can not accept zero amount items...
[ "protected", "function", "getItemListForOrder", "(", "Order", "$", "order", ")", ":", "array", "{", "$", "items", "=", "[", "]", ";", "$", "priceCheck", "=", "0", ";", "$", "count", "=", "-", "1", ";", "/** @var LineItem $item */", "foreach", "(", "$", ...
Generate the item list for an Order. @param Order $order @return array
[ "Generate", "the", "item", "list", "for", "an", "Order", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L661-L722
27,128
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.performRequest
protected function performRequest($request, $transaction): RequestResponseInterface { //raising event $event = new GatewayRequestEvent([ 'type' => $transaction->type, 'request' => $request, 'transaction' => $transaction ]); // Raise 'beforeGateway...
php
protected function performRequest($request, $transaction): RequestResponseInterface { //raising event $event = new GatewayRequestEvent([ 'type' => $transaction->type, 'request' => $request, 'transaction' => $transaction ]); // Raise 'beforeGateway...
[ "protected", "function", "performRequest", "(", "$", "request", ",", "$", "transaction", ")", ":", "RequestResponseInterface", "{", "//raising event", "$", "event", "=", "new", "GatewayRequestEvent", "(", "[", "'type'", "=>", "$", "transaction", "->", "type", ",...
Perform a request and return the response. @param $request @param $transaction @return RequestResponseInterface @throws GatewayRequestCancelledException
[ "Perform", "a", "request", "and", "return", "the", "response", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L733-L748
27,129
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.prepareCaptureRequest
protected function prepareCaptureRequest($request, string $reference): RequestInterface { /** @var AbstractRequest $captureRequest */ $captureRequest = $this->gateway()->capture($request); $captureRequest->setTransactionReference($reference); return $captureRequest; }
php
protected function prepareCaptureRequest($request, string $reference): RequestInterface { /** @var AbstractRequest $captureRequest */ $captureRequest = $this->gateway()->capture($request); $captureRequest->setTransactionReference($reference); return $captureRequest; }
[ "protected", "function", "prepareCaptureRequest", "(", "$", "request", ",", "string", "$", "reference", ")", ":", "RequestInterface", "{", "/** @var AbstractRequest $captureRequest */", "$", "captureRequest", "=", "$", "this", "->", "gateway", "(", ")", "->", "captu...
Prepare a capture request from request data and reference of the transaction being captured. @param array $request @param string $reference @return RequestInterface
[ "Prepare", "a", "capture", "request", "from", "request", "data", "and", "reference", "of", "the", "transaction", "being", "captured", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L794-L801
27,130
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.prepareRefundRequest
protected function prepareRefundRequest($request, string $reference): RequestInterface { /** @var AbstractRequest $refundRequest */ $refundRequest = $this->gateway()->refund($request); $refundRequest->setTransactionReference($reference); return $refundRequest; }
php
protected function prepareRefundRequest($request, string $reference): RequestInterface { /** @var AbstractRequest $refundRequest */ $refundRequest = $this->gateway()->refund($request); $refundRequest->setTransactionReference($reference); return $refundRequest; }
[ "protected", "function", "prepareRefundRequest", "(", "$", "request", ",", "string", "$", "reference", ")", ":", "RequestInterface", "{", "/** @var AbstractRequest $refundRequest */", "$", "refundRequest", "=", "$", "this", "->", "gateway", "(", ")", "->", "refund",...
Prepare a refund request from request data and reference of the transaction being refunded. @param array $request @param string $reference @return RequestInterface
[ "Prepare", "a", "refund", "request", "from", "request", "data", "and", "reference", "of", "the", "transaction", "being", "refunded", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L837-L845
27,131
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.sendRequest
protected function sendRequest(RequestInterface $request): ResponseInterface { $data = $request->getData(); $event = new SendPaymentRequestEvent([ 'requestData' => $data ]); // Raise 'beforeSendPaymentRequest' event $this->trigger(self::EVENT_BEFORE_SEND_PAYMENT...
php
protected function sendRequest(RequestInterface $request): ResponseInterface { $data = $request->getData(); $event = new SendPaymentRequestEvent([ 'requestData' => $data ]); // Raise 'beforeSendPaymentRequest' event $this->trigger(self::EVENT_BEFORE_SEND_PAYMENT...
[ "protected", "function", "sendRequest", "(", "RequestInterface", "$", "request", ")", ":", "ResponseInterface", "{", "$", "data", "=", "$", "request", "->", "getData", "(", ")", ";", "$", "event", "=", "new", "SendPaymentRequestEvent", "(", "[", "'requestData'...
Send a request to the actual gateway. @param RequestInterface $request @return ResponseInterface
[ "Send", "a", "request", "to", "the", "actual", "gateway", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L854-L872
27,132
craftcms/commerce-omnipay
src/base/Gateway.php
Gateway.createOmnipayGateway
protected static function createOmnipayGateway(string $gatewayClassName): GatewayInterface { $craftClient = Craft::createGuzzleClient(); $adapter = new Client($craftClient); $httpClient = new OmnipayClient($adapter); return Omnipay::create($gatewayClassName, $httpClient); }
php
protected static function createOmnipayGateway(string $gatewayClassName): GatewayInterface { $craftClient = Craft::createGuzzleClient(); $adapter = new Client($craftClient); $httpClient = new OmnipayClient($adapter); return Omnipay::create($gatewayClassName, $httpClient); }
[ "protected", "static", "function", "createOmnipayGateway", "(", "string", "$", "gatewayClassName", ")", ":", "GatewayInterface", "{", "$", "craftClient", "=", "Craft", "::", "createGuzzleClient", "(", ")", ";", "$", "adapter", "=", "new", "Client", "(", "$", "...
Create the omnipay gateway. @param string $gatewayClassName @return GatewayInterface
[ "Create", "the", "omnipay", "gateway", "." ]
91fd24ebe3fc19a776915e7636e432a41d7deace
https://github.com/craftcms/commerce-omnipay/blob/91fd24ebe3fc19a776915e7636e432a41d7deace/src/base/Gateway.php#L880-L887
27,133
ddeboer/transcoder
src/Transcoder.php
Transcoder.create
public static function create($defaultEncoding = 'UTF-8') { if (isset(self::$chain[$defaultEncoding])) { return self::$chain[$defaultEncoding]; } $transcoders = []; try { $transcoders[] = new MbTranscoder($defaultEncoding); } catch (E...
php
public static function create($defaultEncoding = 'UTF-8') { if (isset(self::$chain[$defaultEncoding])) { return self::$chain[$defaultEncoding]; } $transcoders = []; try { $transcoders[] = new MbTranscoder($defaultEncoding); } catch (E...
[ "public", "static", "function", "create", "(", "$", "defaultEncoding", "=", "'UTF-8'", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "chain", "[", "$", "defaultEncoding", "]", ")", ")", "{", "return", "self", "::", "$", "chain", "[", "$", "de...
Create a transcoder @param string $defaultEncoding @return TranscoderInterface @throws ExtensionMissingException
[ "Create", "a", "transcoder" ]
e56652fe3b97908def6f53d97498952bbf13a9f6
https://github.com/ddeboer/transcoder/blob/e56652fe3b97908def6f53d97498952bbf13a9f6/src/Transcoder.php#L47-L71
27,134
axiom-labs/rivescript-php
src/Cortex/Tags/Bot.php
Bot.parse
public function parse($source, Input $input) { if (! $this->sourceAllowed()) { return $source; } if ($this->hasMatches($source)) { $matches = $this->getMatches($source); $variables = synapse()->memory->variables(); foreach ($matches as $mat...
php
public function parse($source, Input $input) { if (! $this->sourceAllowed()) { return $source; } if ($this->hasMatches($source)) { $matches = $this->getMatches($source); $variables = synapse()->memory->variables(); foreach ($matches as $mat...
[ "public", "function", "parse", "(", "$", "source", ",", "Input", "$", "input", ")", "{", "if", "(", "!", "$", "this", "->", "sourceAllowed", "(", ")", ")", "{", "return", "$", "source", ";", "}", "if", "(", "$", "this", "->", "hasMatches", "(", "...
Parse the source. @param string $source @return string
[ "Parse", "the", "source", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Tags/Bot.php#L28-L44
27,135
bitpressio/blade-extensions
src/BladeExtensionServiceProvider.php
BladeExtensionServiceProvider.defineBladeExtensions
protected function defineBladeExtensions() { foreach ($this->app->tagged('blade.extension') as $extension) { if (! $extension instanceof BladeExtension) { throw new InvalidBladeExtension($extension); } foreach ($extension->getDirectives() as $name => $cal...
php
protected function defineBladeExtensions() { foreach ($this->app->tagged('blade.extension') as $extension) { if (! $extension instanceof BladeExtension) { throw new InvalidBladeExtension($extension); } foreach ($extension->getDirectives() as $name => $cal...
[ "protected", "function", "defineBladeExtensions", "(", ")", "{", "foreach", "(", "$", "this", "->", "app", "->", "tagged", "(", "'blade.extension'", ")", "as", "$", "extension", ")", "{", "if", "(", "!", "$", "extension", "instanceof", "BladeExtension", ")",...
Register Blade Extension directives and conditionals with the blade compiler @return void
[ "Register", "Blade", "Extension", "directives", "and", "conditionals", "with", "the", "blade", "compiler" ]
eeb4f3acb7253ee28302530c0bd25c5113248507
https://github.com/bitpressio/blade-extensions/blob/eeb4f3acb7253ee28302530c0bd25c5113248507/src/BladeExtensionServiceProvider.php#L48-L63
27,136
axiom-labs/rivescript-php
src/Cortex/Commands/Trigger.php
Trigger.determineTriggerType
protected function determineTriggerType($trigger) { $wildcards = [ 'alphabetic' => '/_/', 'numeric' => '/#/', 'global' => '/\*/', ]; foreach ($wildcards as $type => $pattern) { if (@preg_match_all($pattern, $trigger, $stars)) { ...
php
protected function determineTriggerType($trigger) { $wildcards = [ 'alphabetic' => '/_/', 'numeric' => '/#/', 'global' => '/\*/', ]; foreach ($wildcards as $type => $pattern) { if (@preg_match_all($pattern, $trigger, $stars)) { ...
[ "protected", "function", "determineTriggerType", "(", "$", "trigger", ")", "{", "$", "wildcards", "=", "[", "'alphabetic'", "=>", "'/_/'", ",", "'numeric'", "=>", "'/#/'", ",", "'global'", "=>", "'/\\*/'", ",", "]", ";", "foreach", "(", "$", "wildcards", "...
Determine the type of trigger to aid in sorting. @param string $trigger @return string
[ "Determine", "the", "type", "of", "trigger", "to", "aid", "in", "sorting", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Commands/Trigger.php#L45-L60
27,137
axiom-labs/rivescript-php
src/Cortex/Commands/Trigger.php
Trigger.sortTriggers
protected function sortTriggers($triggers) { $triggers = $this->determineWordCount($triggers); $triggers = $this->determineTypeCount($triggers); $triggers = $triggers->sort(function ($current, $previous) { return ($current['order'] < $previous['order']) ? -1 : 1; })->rev...
php
protected function sortTriggers($triggers) { $triggers = $this->determineWordCount($triggers); $triggers = $this->determineTypeCount($triggers); $triggers = $triggers->sort(function ($current, $previous) { return ($current['order'] < $previous['order']) ? -1 : 1; })->rev...
[ "protected", "function", "sortTriggers", "(", "$", "triggers", ")", "{", "$", "triggers", "=", "$", "this", "->", "determineWordCount", "(", "$", "triggers", ")", ";", "$", "triggers", "=", "$", "this", "->", "determineTypeCount", "(", "$", "triggers", ")"...
Sort triggers based on type and word count from largest to smallest. @param Collection $triggers @return Collection
[ "Sort", "triggers", "based", "on", "type", "and", "word", "count", "from", "largest", "to", "smallest", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Commands/Trigger.php#L70-L80
27,138
axiom-labs/rivescript-php
src/Cortex/Commands/Trigger.php
Trigger.determineWordCount
protected function determineWordCount($triggers) { $triggers = $triggers->each(function ($data, $trigger) use ($triggers) { $data['order'] = count(explode(' ', $trigger)); $triggers->put($trigger, $data); }); return $triggers; }
php
protected function determineWordCount($triggers) { $triggers = $triggers->each(function ($data, $trigger) use ($triggers) { $data['order'] = count(explode(' ', $trigger)); $triggers->put($trigger, $data); }); return $triggers; }
[ "protected", "function", "determineWordCount", "(", "$", "triggers", ")", "{", "$", "triggers", "=", "$", "triggers", "->", "each", "(", "function", "(", "$", "data", ",", "$", "trigger", ")", "use", "(", "$", "triggers", ")", "{", "$", "data", "[", ...
Sort triggers based on word count from largest to smallest. @param Collection $triggers @return Collection
[ "Sort", "triggers", "based", "on", "word", "count", "from", "largest", "to", "smallest", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Commands/Trigger.php#L114-L123
27,139
axiom-labs/rivescript-php
src/Cortex/Input.php
Input.cleanOriginalSource
protected function cleanOriginalSource() { $patterns = synapse()->memory->substitute()->keys()->all(); $replacements = synapse()->memory->substitute()->values()->all(); $this->source = mb_strtolower($this->original); $this->source = preg_replace($patterns, $replacements, $this->...
php
protected function cleanOriginalSource() { $patterns = synapse()->memory->substitute()->keys()->all(); $replacements = synapse()->memory->substitute()->values()->all(); $this->source = mb_strtolower($this->original); $this->source = preg_replace($patterns, $replacements, $this->...
[ "protected", "function", "cleanOriginalSource", "(", ")", "{", "$", "patterns", "=", "synapse", "(", ")", "->", "memory", "->", "substitute", "(", ")", "->", "keys", "(", ")", "->", "all", "(", ")", ";", "$", "replacements", "=", "synapse", "(", ")", ...
Clean the source input, so its in a state easily readable by the interpreter. @return void
[ "Clean", "the", "source", "input", "so", "its", "in", "a", "state", "easily", "readable", "by", "the", "interpreter", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Input.php#L62-L71
27,140
GeniusesOfSymfony/ReactAMQP
src/Producer.php
Producer.publish
public function publish(string $message, string $routingKey, ?int $flags = null, $attributes = []): void { if ($this->closed) { throw new BadMethodCallException('This Producer object is closed and cannot send any more messages.'); } $this->messages[] = [ 'message' => ...
php
public function publish(string $message, string $routingKey, ?int $flags = null, $attributes = []): void { if ($this->closed) { throw new BadMethodCallException('This Producer object is closed and cannot send any more messages.'); } $this->messages[] = [ 'message' => ...
[ "public", "function", "publish", "(", "string", "$", "message", ",", "string", "$", "routingKey", ",", "?", "int", "$", "flags", "=", "null", ",", "$", "attributes", "=", "[", "]", ")", ":", "void", "{", "if", "(", "$", "this", "->", "closed", ")",...
Method to publish a message to an AMQP exchange. Has the same method signature as the exchange objects publish method. @param string $message Message @param string $routingKey Routing key @param int|null $flags Flags @param array $attributes Attributes @throws BadMethodCallException
[ "Method", "to", "publish", "a", "message", "to", "an", "AMQP", "exchange", ".", "Has", "the", "same", "method", "signature", "as", "the", "exchange", "objects", "publish", "method", "." ]
256fe50ab01cfb5baf24309bd9825a08c93c63df
https://github.com/GeniusesOfSymfony/ReactAMQP/blob/256fe50ab01cfb5baf24309bd9825a08c93c63df/src/Producer.php#L101-L112
27,141
GeniusesOfSymfony/ReactAMQP
src/Producer.php
Producer.close
public function close(): void { if ($this->closed) { return; } $this->emit('end', [$this]); $this->loop->cancelTimer($this->timer); $this->removeAllListeners(); $this->exchange = null; $this->closed = true; }
php
public function close(): void { if ($this->closed) { return; } $this->emit('end', [$this]); $this->loop->cancelTimer($this->timer); $this->removeAllListeners(); $this->exchange = null; $this->closed = true; }
[ "public", "function", "close", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "closed", ")", "{", "return", ";", "}", "$", "this", "->", "emit", "(", "'end'", ",", "[", "$", "this", "]", ")", ";", "$", "this", "->", "loop", "->", "...
Method to call when stopping listening to messages.
[ "Method", "to", "call", "when", "stopping", "listening", "to", "messages", "." ]
256fe50ab01cfb5baf24309bd9825a08c93c63df
https://github.com/GeniusesOfSymfony/ReactAMQP/blob/256fe50ab01cfb5baf24309bd9825a08c93c63df/src/Producer.php#L152-L163
27,142
axiom-labs/rivescript-php
src/Support/Str.php
Str.startsWith
public static function startsWith($haystack, $needle) { return $needle === '' or mb_strrpos($haystack, $needle, -mb_strlen($haystack)) !== false; }
php
public static function startsWith($haystack, $needle) { return $needle === '' or mb_strrpos($haystack, $needle, -mb_strlen($haystack)) !== false; }
[ "public", "static", "function", "startsWith", "(", "$", "haystack", ",", "$", "needle", ")", "{", "return", "$", "needle", "===", "''", "or", "mb_strrpos", "(", "$", "haystack", ",", "$", "needle", ",", "-", "mb_strlen", "(", "$", "haystack", ")", ")",...
Determine if string starts with the supplied needle. @param string $haystack @param string $needle @return bool
[ "Determine", "if", "string", "starts", "with", "the", "supplied", "needle", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Support/Str.php#L28-L31
27,143
axiom-labs/rivescript-php
src/Support/Str.php
Str.endsWith
public static function endsWith($haystack, $needle) { return $needle === '' or (($temp = mb_strlen($haystack) - mb_strlen($needle)) >= 0 and mb_strpos($haystack, $needle, $temp) !== false); }
php
public static function endsWith($haystack, $needle) { return $needle === '' or (($temp = mb_strlen($haystack) - mb_strlen($needle)) >= 0 and mb_strpos($haystack, $needle, $temp) !== false); }
[ "public", "static", "function", "endsWith", "(", "$", "haystack", ",", "$", "needle", ")", "{", "return", "$", "needle", "===", "''", "or", "(", "(", "$", "temp", "=", "mb_strlen", "(", "$", "haystack", ")", "-", "mb_strlen", "(", "$", "needle", ")",...
Determine if string ends with the supplied needle. @param string $haystack @param string $needle @return bool
[ "Determine", "if", "string", "ends", "with", "the", "supplied", "needle", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Support/Str.php#L41-L44
27,144
Happyr/GoogleSiteAuthenticatorBundle
Service/ClientProvider.php
ClientProvider.isTokenValid
public function isTokenValid(string $tokenName = null): bool { // We must fetch the client here. A client will automatically refresh the stored access token. $client = $this->getClient($tokenName); if (null === $accessToken = $client->getAccessToken()) { return false; } ...
php
public function isTokenValid(string $tokenName = null): bool { // We must fetch the client here. A client will automatically refresh the stored access token. $client = $this->getClient($tokenName); if (null === $accessToken = $client->getAccessToken()) { return false; } ...
[ "public", "function", "isTokenValid", "(", "string", "$", "tokenName", "=", "null", ")", ":", "bool", "{", "// We must fetch the client here. A client will automatically refresh the stored access token.", "$", "client", "=", "$", "this", "->", "getClient", "(", "$", "to...
Check if a token is valid. This is an expensive operation that makes multiple API calls.
[ "Check", "if", "a", "token", "is", "valid", ".", "This", "is", "an", "expensive", "operation", "that", "makes", "multiple", "API", "calls", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Service/ClientProvider.php#L56-L75
27,145
Happyr/GoogleSiteAuthenticatorBundle
Service/ClientProvider.php
ClientProvider.setAccessToken
public function setAccessToken(?string $accessToken, string $tokenName = null) { $name = $this->config->getKey($tokenName); $cacheKey = $this->creteCacheKey($name); if (null === $accessToken) { $this->pool->deleteItem($cacheKey); return; } $item = $...
php
public function setAccessToken(?string $accessToken, string $tokenName = null) { $name = $this->config->getKey($tokenName); $cacheKey = $this->creteCacheKey($name); if (null === $accessToken) { $this->pool->deleteItem($cacheKey); return; } $item = $...
[ "public", "function", "setAccessToken", "(", "?", "string", "$", "accessToken", ",", "string", "$", "tokenName", "=", "null", ")", "{", "$", "name", "=", "$", "this", "->", "config", "->", "getKey", "(", "$", "tokenName", ")", ";", "$", "cacheKey", "="...
Store the access token in the storage.
[ "Store", "the", "access", "token", "in", "the", "storage", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Service/ClientProvider.php#L80-L93
27,146
Happyr/GoogleSiteAuthenticatorBundle
Service/ClientProvider.php
ClientProvider.getAccessToken
protected function getAccessToken(string $tokenName = null): ?AccessToken { $cacheKey = $this->creteCacheKey($this->config->getKey($tokenName)); $item = $this->pool->getItem($cacheKey); if (!$item->isHit()) { return null; } return $item->get(); }
php
protected function getAccessToken(string $tokenName = null): ?AccessToken { $cacheKey = $this->creteCacheKey($this->config->getKey($tokenName)); $item = $this->pool->getItem($cacheKey); if (!$item->isHit()) { return null; } return $item->get(); }
[ "protected", "function", "getAccessToken", "(", "string", "$", "tokenName", "=", "null", ")", ":", "?", "AccessToken", "{", "$", "cacheKey", "=", "$", "this", "->", "creteCacheKey", "(", "$", "this", "->", "config", "->", "getKey", "(", "$", "tokenName", ...
Get access token from storage.
[ "Get", "access", "token", "from", "storage", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Service/ClientProvider.php#L98-L108
27,147
Happyr/GoogleSiteAuthenticatorBundle
Service/ClientProvider.php
ClientProvider.refreshToken
private function refreshToken(\Google_Client $client): bool { $accessToken = $client->getAccessToken(); $data = \json_decode($accessToken, true); try { if (isset($data['refresh_token'])) { $client->refreshToken($data['refresh_token']); return tru...
php
private function refreshToken(\Google_Client $client): bool { $accessToken = $client->getAccessToken(); $data = \json_decode($accessToken, true); try { if (isset($data['refresh_token'])) { $client->refreshToken($data['refresh_token']); return tru...
[ "private", "function", "refreshToken", "(", "\\", "Google_Client", "$", "client", ")", ":", "bool", "{", "$", "accessToken", "=", "$", "client", "->", "getAccessToken", "(", ")", ";", "$", "data", "=", "\\", "json_decode", "(", "$", "accessToken", ",", "...
If we got a refresh token, use it to retrieve a good access token.
[ "If", "we", "got", "a", "refresh", "token", "use", "it", "to", "retrieve", "a", "good", "access", "token", "." ]
dcf0f9706ab0864a37b7d8296531fb2971176c55
https://github.com/Happyr/GoogleSiteAuthenticatorBundle/blob/dcf0f9706ab0864a37b7d8296531fb2971176c55/Service/ClientProvider.php#L113-L128
27,148
axiom-labs/rivescript-php
src/Cortex/Brain.php
Brain.teach
public function teach($file) { $commands = synapse()->commands; $file = new SplFileObject($file); $lineNumber = 0; while (! $file->eof()) { $currentCommand = null; $node = new Node($file->fgets(), $lineNumber++); if ($node->isIn...
php
public function teach($file) { $commands = synapse()->commands; $file = new SplFileObject($file); $lineNumber = 0; while (! $file->eof()) { $currentCommand = null; $node = new Node($file->fgets(), $lineNumber++); if ($node->isIn...
[ "public", "function", "teach", "(", "$", "file", ")", "{", "$", "commands", "=", "synapse", "(", ")", "->", "commands", ";", "$", "file", "=", "new", "SplFileObject", "(", "$", "file", ")", ";", "$", "lineNumber", "=", "0", ";", "while", "(", "!", ...
Teach the brain contents of a new file source. @param string $file
[ "Teach", "the", "brain", "contents", "of", "a", "new", "file", "source", "." ]
44989e73556ab2cac9a68ec5f6fb340affd4c724
https://github.com/axiom-labs/rivescript-php/blob/44989e73556ab2cac9a68ec5f6fb340affd4c724/src/Cortex/Brain.php#L27-L54
27,149
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/Stack.php
Stack.sort
public function sort(): void { $r = new Stack(); while (!$r->isEmpty()) { $tmp = $this->pop(); while ((!$r->isEmpty()) && (Comparator::lessThan($r->peek(), $tmp))) { $this->push($r->pop()); } $r->push($tmp); } while (!$r->i...
php
public function sort(): void { $r = new Stack(); while (!$r->isEmpty()) { $tmp = $this->pop(); while ((!$r->isEmpty()) && (Comparator::lessThan($r->peek(), $tmp))) { $this->push($r->pop()); } $r->push($tmp); } while (!$r->i...
[ "public", "function", "sort", "(", ")", ":", "void", "{", "$", "r", "=", "new", "Stack", "(", ")", ";", "while", "(", "!", "$", "r", "->", "isEmpty", "(", ")", ")", "{", "$", "tmp", "=", "$", "this", "->", "pop", "(", ")", ";", "while", "("...
sorts the stack in descending order TODO add ascending order
[ "sorts", "the", "stack", "in", "descending", "order" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/Stack.php#L74-L87
27,150
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractGraph.php
AbstractGraph.numberOfSubGraph
public function numberOfSubGraph(): int { if (null === $this->getNodes()) return 0; $c = 0; $v = new ArrayList(); foreach ($this->getNodes() as $node) { if ($v->containsValue($node)) continue; $c++; $this->flood($node, $v); } return $c...
php
public function numberOfSubGraph(): int { if (null === $this->getNodes()) return 0; $c = 0; $v = new ArrayList(); foreach ($this->getNodes() as $node) { if ($v->containsValue($node)) continue; $c++; $this->flood($node, $v); } return $c...
[ "public", "function", "numberOfSubGraph", "(", ")", ":", "int", "{", "if", "(", "null", "===", "$", "this", "->", "getNodes", "(", ")", ")", "return", "0", ";", "$", "c", "=", "0", ";", "$", "v", "=", "new", "ArrayList", "(", ")", ";", "foreach",...
returns the number of sub graphs @return int
[ "returns", "the", "number", "of", "sub", "graphs" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractGraph.php#L181-L192
27,151
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/CircularBuffer.php
CircularBuffer.enqueue
public function enqueue($data): bool { if (null === $data) { return false; } if ($this->isFull()) { return false; } $this->head = $this->head % $this->size; $this->elements[$this->head] = $data; $this->head++; return true; }
php
public function enqueue($data): bool { if (null === $data) { return false; } if ($this->isFull()) { return false; } $this->head = $this->head % $this->size; $this->elements[$this->head] = $data; $this->head++; return true; }
[ "public", "function", "enqueue", "(", "$", "data", ")", ":", "bool", "{", "if", "(", "null", "===", "$", "data", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "isFull", "(", ")", ")", "{", "return", "false", ";", "}", "$"...
enqueues a data at the head of the circular buffer. If the buffer is full, the method will insert the data at the "beginning" without warning. important notice: this method wastes one slot in order to differentiate between full and empty. This wasting is not necessary, but requires an addition boolean flag which (in ...
[ "enqueues", "a", "data", "at", "the", "head", "of", "the", "circular", "buffer", ".", "If", "the", "buffer", "is", "full", "the", "method", "will", "insert", "the", "data", "at", "the", "beginning", "without", "warning", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/CircularBuffer.php#L77-L88
27,152
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/CircularBuffer.php
CircularBuffer.dequeue
public function dequeue() { if ($this->isEmpty()) { return false; } $this->tail = $this->tail % $this->size; $data = $this->elements[$this->tail]; $this->tail++; return $data; }
php
public function dequeue() { if ($this->isEmpty()) { return false; } $this->tail = $this->tail % $this->size; $data = $this->elements[$this->tail]; $this->tail++; return $data; }
[ "public", "function", "dequeue", "(", ")", "{", "if", "(", "$", "this", "->", "isEmpty", "(", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "tail", "=", "$", "this", "->", "tail", "%", "$", "this", "->", "size", ";", "$", "data...
dequeues a value from the tail of the circular buffer. @return mixed
[ "dequeues", "a", "value", "from", "the", "tail", "of", "the", "circular", "buffer", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/CircularBuffer.php#L110-L118
27,153
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/Queue.php
Queue.enqueue
public function enqueue($item): bool { if (!$this->isValid()) return false; $this->queue[$this->head] = $item; $this->head++; return true; }
php
public function enqueue($item): bool { if (!$this->isValid()) return false; $this->queue[$this->head] = $item; $this->head++; return true; }
[ "public", "function", "enqueue", "(", "$", "item", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "isValid", "(", ")", ")", "return", "false", ";", "$", "this", "->", "queue", "[", "$", "this", "->", "head", "]", "=", "$", "item", ";...
this methods adds an item to the queue to the last index @param $item @return bool
[ "this", "methods", "adds", "an", "item", "to", "the", "queue", "to", "the", "last", "index" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/Queue.php#L55-L61
27,154
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/Queue.php
Queue.dequeue
public function dequeue() { if (null === $this->queue) return null; if ($this->tail > $this->head) return null; $item = $this->queue[$this->tail]; $this->tail++; return $item; }
php
public function dequeue() { if (null === $this->queue) return null; if ($this->tail > $this->head) return null; $item = $this->queue[$this->tail]; $this->tail++; return $item; }
[ "public", "function", "dequeue", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "queue", ")", "return", "null", ";", "if", "(", "$", "this", "->", "tail", ">", "$", "this", "->", "head", ")", "return", "null", ";", "$", "item", "=", ...
this method removes the first element from the queue and returns it @return int
[ "this", "method", "removes", "the", "first", "element", "from", "the", "queue", "and", "returns", "it" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/Queue.php#L78-L84
27,155
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/Queue.php
Queue.front
public function front() { if (null === $this->queue) return null; if ($this->tail > $this->head) return null; return $this->queue[$this->tail]; }
php
public function front() { if (null === $this->queue) return null; if ($this->tail > $this->head) return null; return $this->queue[$this->tail]; }
[ "public", "function", "front", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "queue", ")", "return", "null", ";", "if", "(", "$", "this", "->", "tail", ">", "$", "this", "->", "head", ")", "return", "null", ";", "return", "$", "this...
returns the first element from the queue @return int
[ "returns", "the", "first", "element", "from", "the", "queue" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/Queue.php#L91-L95
27,156
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/Queue.php
Queue.rear
public function rear() { if (null === $this->queue) return null; if (!isset($this->queue[$this->head])) return null; return $this->queue[$this->head]; }
php
public function rear() { if (null === $this->queue) return null; if (!isset($this->queue[$this->head])) return null; return $this->queue[$this->head]; }
[ "public", "function", "rear", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "queue", ")", "return", "null", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "queue", "[", "$", "this", "->", "head", "]", ")", ")", "return", "n...
returns the last item from the queue @return int
[ "returns", "the", "last", "item", "from", "the", "queue" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/Queue.php#L102-L106
27,157
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/Queue.php
Queue.queueSize
public function queueSize(): int { if ($this->tail > $this->head) return 0; return $this->head - $this->tail; }
php
public function queueSize(): int { if ($this->tail > $this->head) return 0; return $this->head - $this->tail; }
[ "public", "function", "queueSize", "(", ")", ":", "int", "{", "if", "(", "$", "this", "->", "tail", ">", "$", "this", "->", "head", ")", "return", "0", ";", "return", "$", "this", "->", "head", "-", "$", "this", "->", "tail", ";", "}" ]
stores the number of items of the queue to the size member of this class and returns it @return int @deprecated
[ "stores", "the", "number", "of", "items", "of", "the", "queue", "to", "the", "size", "member", "of", "this", "class", "and", "returns", "it" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/Queue.php#L133-L136
27,158
doganoo/PHPAlgorithms
src/Algorithm/Various/Permutation.php
Permutation.permute
private function permute(array $objects, $prefix, array $result) { $length = \count($objects); //if there are no elements in the array, //a permutation is found. The permutation is //added to the array if (0 === $length) { $result[] = $prefix; return $resu...
php
private function permute(array $objects, $prefix, array $result) { $length = \count($objects); //if there are no elements in the array, //a permutation is found. The permutation is //added to the array if (0 === $length) { $result[] = $prefix; return $resu...
[ "private", "function", "permute", "(", "array", "$", "objects", ",", "$", "prefix", ",", "array", "$", "result", ")", "{", "$", "length", "=", "\\", "count", "(", "$", "objects", ")", ";", "//if there are no elements in the array,", "//a permutation is found. Th...
returns all permutations of an given array of objects @param array $objects @param $prefix @param array $result @return array
[ "returns", "all", "permutations", "of", "an", "given", "array", "of", "objects" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Algorithm/Various/Permutation.php#L67-L103
27,159
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.removeDuplicates
public function removeDuplicates() { $tortoise = $this->head; while ($tortoise !== null) { $hare = $tortoise; while ($hare->getNext() !== null) { if (Comparator::equals($hare->getNext()->getValue(), $tortoise->getValue())) { $hare->setNext($ha...
php
public function removeDuplicates() { $tortoise = $this->head; while ($tortoise !== null) { $hare = $tortoise; while ($hare->getNext() !== null) { if (Comparator::equals($hare->getNext()->getValue(), $tortoise->getValue())) { $hare->setNext($ha...
[ "public", "function", "removeDuplicates", "(", ")", "{", "$", "tortoise", "=", "$", "this", "->", "head", ";", "while", "(", "$", "tortoise", "!==", "null", ")", "{", "$", "hare", "=", "$", "tortoise", ";", "while", "(", "$", "hare", "->", "getNext",...
The method uses the runner technique in order to iterate over head twice. If the list contains duplicates, the next-next is set as the next node of the current node.
[ "The", "method", "uses", "the", "runner", "technique", "in", "order", "to", "iterate", "over", "head", "twice", ".", "If", "the", "list", "contains", "duplicates", "the", "next", "-", "next", "is", "set", "as", "the", "next", "node", "of", "the", "curren...
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L143-L157
27,160
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.getNodeByValue
public function getNodeByValue($value): ?Node { if (!$this->containsValue($value)) { return null; } $tmp = $this->getHead(); while ($tmp !== null) { $val = $tmp->getValue(); if (Comparator::equals($val, $value)) { //if the value is foun...
php
public function getNodeByValue($value): ?Node { if (!$this->containsValue($value)) { return null; } $tmp = $this->getHead(); while ($tmp !== null) { $val = $tmp->getValue(); if (Comparator::equals($val, $value)) { //if the value is foun...
[ "public", "function", "getNodeByValue", "(", "$", "value", ")", ":", "?", "Node", "{", "if", "(", "!", "$", "this", "->", "containsValue", "(", "$", "value", ")", ")", "{", "return", "null", ";", "}", "$", "tmp", "=", "$", "this", "->", "getHead", ...
searches the list for a node by a given key @param $value @return \doganoo\PHPAlgorithms\Datastructure\Lists\Node|null
[ "searches", "the", "list", "for", "a", "node", "by", "a", "given", "key" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L321-L335
27,161
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.containsValue
public function containsValue($value): bool { $node = $this->getHead(); while ($node !== null) { if (Comparator::equals($node->getValue(), $value)) { return true; } $node = $node->getNext(); } return false; }
php
public function containsValue($value): bool { $node = $this->getHead(); while ($node !== null) { if (Comparator::equals($node->getValue(), $value)) { return true; } $node = $node->getNext(); } return false; }
[ "public", "function", "containsValue", "(", "$", "value", ")", ":", "bool", "{", "$", "node", "=", "$", "this", "->", "getHead", "(", ")", ";", "while", "(", "$", "node", "!==", "null", ")", "{", "if", "(", "Comparator", "::", "equals", "(", "$", ...
searches the list for a given value @param $value @return bool
[ "searches", "the", "list", "for", "a", "given", "value" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L343-L352
27,162
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.getNodeByKey
public function getNodeByKey($key): ?Node { if (!$this->containsKey($key)) { return null; } $head = $this->getHead(); while ($head !== null) { if (Comparator::equals($head->getKey(), $key)) { return $head; } $head = $head->g...
php
public function getNodeByKey($key): ?Node { if (!$this->containsKey($key)) { return null; } $head = $this->getHead(); while ($head !== null) { if (Comparator::equals($head->getKey(), $key)) { return $head; } $head = $head->g...
[ "public", "function", "getNodeByKey", "(", "$", "key", ")", ":", "?", "Node", "{", "if", "(", "!", "$", "this", "->", "containsKey", "(", "$", "key", ")", ")", "{", "return", "null", ";", "}", "$", "head", "=", "$", "this", "->", "getHead", "(", ...
returns a node by a given key @param $key @return \doganoo\PHPAlgorithms\Datastructure\Lists\Node|null
[ "returns", "a", "node", "by", "a", "given", "key" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L360-L372
27,163
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.containsKey
public function containsKey($key): bool { $node = $this->getHead(); while (null !== $node) { if (Comparator::equals($node->getKey(), $key)) { return true; } $node = $node->getNext(); } return false; }
php
public function containsKey($key): bool { $node = $this->getHead(); while (null !== $node) { if (Comparator::equals($node->getKey(), $key)) { return true; } $node = $node->getNext(); } return false; }
[ "public", "function", "containsKey", "(", "$", "key", ")", ":", "bool", "{", "$", "node", "=", "$", "this", "->", "getHead", "(", ")", ";", "while", "(", "null", "!==", "$", "node", ")", "{", "if", "(", "Comparator", "::", "equals", "(", "$", "no...
searches the list for a given key @param $key @return bool
[ "searches", "the", "list", "for", "a", "given", "key" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L380-L389
27,164
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.remove
public function remove($key): bool { /** @var \doganoo\PHPAlgorithms\Datastructure\Lists\Node $previous */ $previous = $head = $this->getHead(); if ($head === null) { return true; } $i = 1; $headSize = $head->size(); /* * The while loop itera...
php
public function remove($key): bool { /** @var \doganoo\PHPAlgorithms\Datastructure\Lists\Node $previous */ $previous = $head = $this->getHead(); if ($head === null) { return true; } $i = 1; $headSize = $head->size(); /* * The while loop itera...
[ "public", "function", "remove", "(", "$", "key", ")", ":", "bool", "{", "/** @var \\doganoo\\PHPAlgorithms\\Datastructure\\Lists\\Node $previous */", "$", "previous", "=", "$", "head", "=", "$", "this", "->", "getHead", "(", ")", ";", "if", "(", "$", "head", "...
removes a node from the list by a given key @param $key @return bool
[ "removes", "a", "node", "from", "the", "list", "by", "a", "given", "key" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L397-L441
27,165
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.replaceValue
public function replaceValue($key, $value): bool { $replaced = false; $node = $this->getHead(); while ($node !== null) { if (Comparator::equals($node->getKey(), $key)) { $node->setValue($value); $replaced = true; } $node = $node...
php
public function replaceValue($key, $value): bool { $replaced = false; $node = $this->getHead(); while ($node !== null) { if (Comparator::equals($node->getKey(), $key)) { $node->setValue($value); $replaced = true; } $node = $node...
[ "public", "function", "replaceValue", "(", "$", "key", ",", "$", "value", ")", ":", "bool", "{", "$", "replaced", "=", "false", ";", "$", "node", "=", "$", "this", "->", "getHead", "(", ")", ";", "while", "(", "$", "node", "!==", "null", ")", "{"...
replaces a value for a key @param $key @param $value @return bool
[ "replaces", "a", "value", "for", "a", "key" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L450-L461
27,166
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.hasLoop
public function hasLoop(): bool { $tortoise = $this->getHead(); $hare = $this->getHead(); while ($tortoise !== null && $hare->getNext() !== null) { $hare = $hare->getNext()->getNext(); if (Comparator::equals($tortoise->getValue(), $hare->getValue())) { r...
php
public function hasLoop(): bool { $tortoise = $this->getHead(); $hare = $this->getHead(); while ($tortoise !== null && $hare->getNext() !== null) { $hare = $hare->getNext()->getNext(); if (Comparator::equals($tortoise->getValue(), $hare->getValue())) { r...
[ "public", "function", "hasLoop", "(", ")", ":", "bool", "{", "$", "tortoise", "=", "$", "this", "->", "getHead", "(", ")", ";", "$", "hare", "=", "$", "this", "->", "getHead", "(", ")", ";", "while", "(", "$", "tortoise", "!==", "null", "&&", "$"...
also known as the Runner Technique @return bool
[ "also", "known", "as", "the", "Runner", "Technique" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L481-L495
27,167
doganoo/PHPAlgorithms
src/Common/Abstracts/AbstractLinkedList.php
AbstractLinkedList.getMiddleNode
public function getMiddleNode(): ?IUnaryNode { $head = $this->getHead(); if (null === $head) return null; $p = $head; $q = $head; while (null !== $p && null !== $q && //actually not really necessary since $p and $q point to the same object null !== $q->...
php
public function getMiddleNode(): ?IUnaryNode { $head = $this->getHead(); if (null === $head) return null; $p = $head; $q = $head; while (null !== $p && null !== $q && //actually not really necessary since $p and $q point to the same object null !== $q->...
[ "public", "function", "getMiddleNode", "(", ")", ":", "?", "IUnaryNode", "{", "$", "head", "=", "$", "this", "->", "getHead", "(", ")", ";", "if", "(", "null", "===", "$", "head", ")", "return", "null", ";", "$", "p", "=", "$", "head", ";", "$", ...
returns the middle node of the linked list @return IUnaryNode|null
[ "returns", "the", "middle", "node", "of", "the", "linked", "list" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Abstracts/AbstractLinkedList.php#L502-L518
27,168
doganoo/PHPAlgorithms
src/Datastructure/Lists/ArrayLists/StringBuilder.php
StringBuilder.append
public function append(string $string) { for ($i = 0; $i < \strlen($string); $i++) { $this->arrayList->add($string[$i]); } }
php
public function append(string $string) { for ($i = 0; $i < \strlen($string); $i++) { $this->arrayList->add($string[$i]); } }
[ "public", "function", "append", "(", "string", "$", "string", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "\\", "strlen", "(", "$", "string", ")", ";", "$", "i", "++", ")", "{", "$", "this", "->", "arrayList", "->", "add", "...
appends a string to the list @param string $string
[ "appends", "a", "string", "to", "the", "list" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/ArrayLists/StringBuilder.php#L61-L65
27,169
doganoo/PHPAlgorithms
src/Datastructure/Lists/ArrayLists/StringBuilder.php
StringBuilder.arrayListToStringBuilder
private function arrayListToStringBuilder(ArrayList $arrayList, bool $reverse = false) { $stringBuilder = new StringBuilder(); if ($reverse) { $stack = new Stack(); foreach ($arrayList as $item) { if (null !== $item) { $stack->push($item); ...
php
private function arrayListToStringBuilder(ArrayList $arrayList, bool $reverse = false) { $stringBuilder = new StringBuilder(); if ($reverse) { $stack = new Stack(); foreach ($arrayList as $item) { if (null !== $item) { $stack->push($item); ...
[ "private", "function", "arrayListToStringBuilder", "(", "ArrayList", "$", "arrayList", ",", "bool", "$", "reverse", "=", "false", ")", "{", "$", "stringBuilder", "=", "new", "StringBuilder", "(", ")", ";", "if", "(", "$", "reverse", ")", "{", "$", "stack",...
converts a array list to a string builder @param ArrayList $arrayList @param bool $reverse @return StringBuilder
[ "converts", "a", "array", "list", "to", "a", "string", "builder" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/ArrayLists/StringBuilder.php#L155-L180
27,170
doganoo/PHPAlgorithms
src/Datastructure/Sets/HashSet.php
HashSet.containsAll
public function containsAll($elements): bool { $contains = false; if (\is_iterable($elements)) { foreach ($elements as $element) { $contains &= $this->contains($element); } } return $contains; }
php
public function containsAll($elements): bool { $contains = false; if (\is_iterable($elements)) { foreach ($elements as $element) { $contains &= $this->contains($element); } } return $contains; }
[ "public", "function", "containsAll", "(", "$", "elements", ")", ":", "bool", "{", "$", "contains", "=", "false", ";", "if", "(", "\\", "is_iterable", "(", "$", "elements", ")", ")", "{", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{"...
Returns true if this set contains all of the elements of the specified collection. @param $elements @return bool
[ "Returns", "true", "if", "this", "set", "contains", "all", "of", "the", "elements", "of", "the", "specified", "collection", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Sets/HashSet.php#L104-L112
27,171
doganoo/PHPAlgorithms
src/Algorithm/Sorting/SelectionSort.php
SelectionSort.sort
public function sort(array $array): array { $array = \array_values($array); $length = \count($array); if (0 === $length || 1 === $length) return $array; for ($i = 0; $i < $length; $i++) { $min = $i; for ($j = $i; $j < $length; $j++) { if (Compara...
php
public function sort(array $array): array { $array = \array_values($array); $length = \count($array); if (0 === $length || 1 === $length) return $array; for ($i = 0; $i < $length; $i++) { $min = $i; for ($j = $i; $j < $length; $j++) { if (Compara...
[ "public", "function", "sort", "(", "array", "$", "array", ")", ":", "array", "{", "$", "array", "=", "\\", "array_values", "(", "$", "array", ")", ";", "$", "length", "=", "\\", "count", "(", "$", "array", ")", ";", "if", "(", "0", "===", "$", ...
sorts an array with selection sort. Actually works only with numeric indices @param array $array @return array
[ "sorts", "an", "array", "with", "selection", "sort", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Algorithm/Sorting/SelectionSort.php#L47-L65
27,172
acmephp/core
AcmeClient.php
AcmeClient.getResourceAccount
private function getResourceAccount() { if (!$this->account) { $payload = [ 'onlyReturnExisting' => true, ]; $this->requestResource('POST', ResourcesDirectory::NEW_ACCOUNT, $payload); $this->account = $this->getHttpClient()->getLastLocation();...
php
private function getResourceAccount() { if (!$this->account) { $payload = [ 'onlyReturnExisting' => true, ]; $this->requestResource('POST', ResourcesDirectory::NEW_ACCOUNT, $payload); $this->account = $this->getHttpClient()->getLastLocation();...
[ "private", "function", "getResourceAccount", "(", ")", "{", "if", "(", "!", "$", "this", "->", "account", ")", "{", "$", "payload", "=", "[", "'onlyReturnExisting'", "=>", "true", ",", "]", ";", "$", "this", "->", "requestResource", "(", "'POST'", ",", ...
Retrieve the resource account. @return string
[ "Retrieve", "the", "resource", "account", "." ]
56af3e28926f4b7507397bfe7fb1ca5f83d73eb4
https://github.com/acmephp/core/blob/56af3e28926f4b7507397bfe7fb1ca5f83d73eb4/AcmeClient.php#L339-L351
27,173
acmephp/core
Challenge/Dns/DnsDataExtractor.php
DnsDataExtractor.getRecordValue
public function getRecordValue(AuthorizationChallenge $authorizationChallenge) { return $this->encoder->encode(hash('sha256', $authorizationChallenge->getPayload(), true)); }
php
public function getRecordValue(AuthorizationChallenge $authorizationChallenge) { return $this->encoder->encode(hash('sha256', $authorizationChallenge->getPayload(), true)); }
[ "public", "function", "getRecordValue", "(", "AuthorizationChallenge", "$", "authorizationChallenge", ")", "{", "return", "$", "this", "->", "encoder", "->", "encode", "(", "hash", "(", "'sha256'", ",", "$", "authorizationChallenge", "->", "getPayload", "(", ")", ...
Retrieves the value of the TXT record to register. @param AuthorizationChallenge $authorizationChallenge @return string
[ "Retrieves", "the", "value", "of", "the", "TXT", "record", "to", "register", "." ]
56af3e28926f4b7507397bfe7fb1ca5f83d73eb4
https://github.com/acmephp/core/blob/56af3e28926f4b7507397bfe7fb1ca5f83d73eb4/Challenge/Dns/DnsDataExtractor.php#L56-L59
27,174
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.addNode
public function addNode(Node $node): bool { $added = $this->add($node->getKey(), $node->getValue()); return $added; }
php
public function addNode(Node $node): bool { $added = $this->add($node->getKey(), $node->getValue()); return $added; }
[ "public", "function", "addNode", "(", "Node", "$", "node", ")", ":", "bool", "{", "$", "added", "=", "$", "this", "->", "add", "(", "$", "node", "->", "getKey", "(", ")", ",", "$", "node", "->", "getValue", "(", ")", ")", ";", "return", "$", "a...
adds a node to the hash map @param Node $node @return bool @throws \doganoo\PHPAlgorithms\common\Exception\InvalidKeyTypeException @throws \doganoo\PHPAlgorithms\common\Exception\UnsupportedKeyTypeException
[ "adds", "a", "node", "to", "the", "hash", "map" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L82-L85
27,175
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.add
public function add($key, $value): bool { $arrayIndex = $this->getBucketIndex($key); if (isset($this->bucket[$arrayIndex])) { $list = $this->bucket[$arrayIndex]; } else { $list = new SinglyLinkedList(); } if ($list->containsKey($key)) { $list->...
php
public function add($key, $value): bool { $arrayIndex = $this->getBucketIndex($key); if (isset($this->bucket[$arrayIndex])) { $list = $this->bucket[$arrayIndex]; } else { $list = new SinglyLinkedList(); } if ($list->containsKey($key)) { $list->...
[ "public", "function", "add", "(", "$", "key", ",", "$", "value", ")", ":", "bool", "{", "$", "arrayIndex", "=", "$", "this", "->", "getBucketIndex", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "bucket", "[", "$", "array...
adds a new value assigned to a key. The key has to be a scalar value otherwise the method throws an InvalidKeyTypeException. @param $key @param $value @return bool @throws \doganoo\PHPAlgorithms\Common\Exception\InvalidKeyTypeException @throws \doganoo\PHPAlgorithms\Common\Exception\UnsupportedKeyTypeException
[ "adds", "a", "new", "value", "assigned", "to", "a", "key", ".", "The", "key", "has", "to", "be", "a", "scalar", "value", "otherwise", "the", "method", "throws", "an", "InvalidKeyTypeException", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L97-L111
27,176
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.getBucketIndex
private function getBucketIndex($key) { /* * next, the keys hash is calculated by a * private method. Next, the array index * (bucket index) is calculated from this hash. * * Doing this avoids hash collisions. */ $hash = $this->getHash($key); ...
php
private function getBucketIndex($key) { /* * next, the keys hash is calculated by a * private method. Next, the array index * (bucket index) is calculated from this hash. * * Doing this avoids hash collisions. */ $hash = $this->getHash($key); ...
[ "private", "function", "getBucketIndex", "(", "$", "key", ")", "{", "/*\n * next, the keys hash is calculated by a\n * private method. Next, the array index\n * (bucket index) is calculated from this hash.\n *\n * Doing this avoids hash collisions.\n *...
returns the bucket array index by using the "division method". note that the division method has limitations: if the hash function calculates the hashes in a constant way, the way how keys are created can be chosen so that they hash to the same bucket. Thus, the worst-case scenario of having n nodes in one chain would...
[ "returns", "the", "bucket", "array", "index", "by", "using", "the", "division", "method", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L127-L138
27,177
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.getNodeByKey
public function getNodeByKey($key): ?Node { $arrayIndex = $this->getBucketIndex($key); /* * the list is requested from the array based on * the array index hash. */ /** @var SinglyLinkedList $list */ if (!isset($this->bucket[$arrayIndex])) { return ...
php
public function getNodeByKey($key): ?Node { $arrayIndex = $this->getBucketIndex($key); /* * the list is requested from the array based on * the array index hash. */ /** @var SinglyLinkedList $list */ if (!isset($this->bucket[$arrayIndex])) { return ...
[ "public", "function", "getNodeByKey", "(", "$", "key", ")", ":", "?", "Node", "{", "$", "arrayIndex", "=", "$", "this", "->", "getBucketIndex", "(", "$", "key", ")", ";", "/*\n * the list is requested from the array based on\n * the array index hash.\n ...
searches the hash map for a node by a given key. @param $key @return Node|null @throws \doganoo\PHPAlgorithms\common\Exception\InvalidKeyTypeException @throws \doganoo\PHPAlgorithms\common\Exception\UnsupportedKeyTypeException
[ "searches", "the", "hash", "map", "for", "a", "node", "by", "a", "given", "key", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L198-L214
27,178
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.size
public function size(): int { $size = 0; /** * @var string $hash * @var AbstractLinkedList $list */ foreach ($this->bucket as $hash => $list) { $size += $list->size(); } return $size; }
php
public function size(): int { $size = 0; /** * @var string $hash * @var AbstractLinkedList $list */ foreach ($this->bucket as $hash => $list) { $size += $list->size(); } return $size; }
[ "public", "function", "size", "(", ")", ":", "int", "{", "$", "size", "=", "0", ";", "/**\n * @var string $hash\n * @var AbstractLinkedList $list\n */", "foreach", "(", "$", "this", "->", "bucket", "as", "$", "hash", "=>", "$", "list", ")"...
returns the number of elements in the map @return int
[ "returns", "the", "number", "of", "elements", "in", "the", "map" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L222-L232
27,179
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.containsValue
public function containsValue($value): bool { /** * @var string $arrayIndex * @var SinglyLinkedList $list */ foreach ($this->bucket as $arrayIndex => $list) { /* $list is the first element in the bucket. The bucket * can contain max $maxSize entries a...
php
public function containsValue($value): bool { /** * @var string $arrayIndex * @var SinglyLinkedList $list */ foreach ($this->bucket as $arrayIndex => $list) { /* $list is the first element in the bucket. The bucket * can contain max $maxSize entries a...
[ "public", "function", "containsValue", "(", "$", "value", ")", ":", "bool", "{", "/**\n * @var string $arrayIndex\n * @var SinglyLinkedList $list\n */", "foreach", "(", "$", "this", "->", "bucket", "as", "$", "arrayIndex", "=>", "$", "list", ")",...
determines whether the HashMap contains a value. @param $value @return bool
[ "determines", "whether", "the", "HashMap", "contains", "a", "value", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L240-L261
27,180
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.containsKey
public function containsKey($key): bool { /** * @var string $arrayIndex * @var SinglyLinkedList $list */ foreach ($this->bucket as $arrayIndex => $list) { if (null === $list) { continue; } /* $list is the first element in the...
php
public function containsKey($key): bool { /** * @var string $arrayIndex * @var SinglyLinkedList $list */ foreach ($this->bucket as $arrayIndex => $list) { if (null === $list) { continue; } /* $list is the first element in the...
[ "public", "function", "containsKey", "(", "$", "key", ")", ":", "bool", "{", "/**\n * @var string $arrayIndex\n * @var SinglyLinkedList $list\n */", "foreach", "(", "$", "this", "->", "bucket", "as", "$", "arrayIndex", "=>", "$", "list", ")", "...
determines whether the HashMap contains a key. @param $key @return bool
[ "determines", "whether", "the", "HashMap", "contains", "a", "key", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L269-L292
27,181
doganoo/PHPAlgorithms
src/Datastructure/Maps/HashMap.php
HashMap.remove
public function remove($key): bool { //get the corresponding index to key $arrayIndex = $this->getBucketIndex($key); /* *if the array index is not available in the * bucket list, end the method and return true. * True due to the operation was successful, meaning ...
php
public function remove($key): bool { //get the corresponding index to key $arrayIndex = $this->getBucketIndex($key); /* *if the array index is not available in the * bucket list, end the method and return true. * True due to the operation was successful, meaning ...
[ "public", "function", "remove", "(", "$", "key", ")", ":", "bool", "{", "//get the corresponding index to key", "$", "arrayIndex", "=", "$", "this", "->", "getBucketIndex", "(", "$", "key", ")", ";", "/*\n *if the array index is not available in the\n * ...
removes a node by a given key @param $key @return bool @throws \doganoo\PHPAlgorithms\Common\Exception\InvalidKeyTypeException @throws \doganoo\PHPAlgorithms\Common\Exception\UnsupportedKeyTypeException
[ "removes", "a", "node", "by", "a", "given", "key" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Maps/HashMap.php#L333-L368
27,182
symbiote/silverstripe-components
src/Symbiote/Components/ComponentService.php
ComponentService.exportNestedDataForTemplates
private static function exportNestedDataForTemplates(array $array, $root = true) { // depth first foreach ($array as $prop => &$value) { if (is_array($value)) { $value = self::exportNestedDataForTemplates($value, false); } } unset($value); ...
php
private static function exportNestedDataForTemplates(array $array, $root = true) { // depth first foreach ($array as $prop => &$value) { if (is_array($value)) { $value = self::exportNestedDataForTemplates($value, false); } } unset($value); ...
[ "private", "static", "function", "exportNestedDataForTemplates", "(", "array", "$", "array", ",", "$", "root", "=", "true", ")", "{", "// depth first", "foreach", "(", "$", "array", "as", "$", "prop", "=>", "&", "$", "value", ")", "{", "if", "(", "is_arr...
Recursively replace nonassociative arrays with ArrayListExportable and output with 'var_export' to produce template logic for the nested data. @param array $array The nested data to export @param bool $root Ignore this @return string Executable template logic
[ "Recursively", "replace", "nonassociative", "arrays", "with", "ArrayListExportable", "and", "output", "with", "var_export", "to", "produce", "template", "logic", "for", "the", "nested", "data", "." ]
4c56b47242771816bdb46937543902290a4d753c
https://github.com/symbiote/silverstripe-components/blob/4c56b47242771816bdb46937543902290a4d753c/src/Symbiote/Components/ComponentService.php#L226-L241
27,183
doganoo/PHPAlgorithms
src/Datastructure/Graph/Tree/Heap/MinHeap.php
MinHeap.clear
public function clear(): bool { $this->heap = \array_fill(0, $this->maxSize, null); $this->heap[0] = \PHP_INT_MIN; return \count($this->heap) === 1 && $this->heap[0] === \PHP_INT_MIN; }
php
public function clear(): bool { $this->heap = \array_fill(0, $this->maxSize, null); $this->heap[0] = \PHP_INT_MIN; return \count($this->heap) === 1 && $this->heap[0] === \PHP_INT_MIN; }
[ "public", "function", "clear", "(", ")", ":", "bool", "{", "$", "this", "->", "heap", "=", "\\", "array_fill", "(", "0", ",", "$", "this", "->", "maxSize", ",", "null", ")", ";", "$", "this", "->", "heap", "[", "0", "]", "=", "\\", "PHP_INT_MIN",...
resets the heap @return bool
[ "resets", "the", "heap" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/Heap/MinHeap.php#L61-L65
27,184
doganoo/PHPAlgorithms
src/Datastructure/Graph/Tree/Heap/MinHeap.php
MinHeap.length
public function length(): int { $array = \array_filter($this->heap, function ($v, $k) { return $v !== null; }, \ARRAY_FILTER_USE_BOTH); return \count($array) - 1; }
php
public function length(): int { $array = \array_filter($this->heap, function ($v, $k) { return $v !== null; }, \ARRAY_FILTER_USE_BOTH); return \count($array) - 1; }
[ "public", "function", "length", "(", ")", ":", "int", "{", "$", "array", "=", "\\", "array_filter", "(", "$", "this", "->", "heap", ",", "function", "(", "$", "v", ",", "$", "k", ")", "{", "return", "$", "v", "!==", "null", ";", "}", ",", "\\",...
returns the number of elements in the heap @return int
[ "returns", "the", "number", "of", "elements", "in", "the", "heap" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/Heap/MinHeap.php#L101-L106
27,185
doganoo/PHPAlgorithms
src/Datastructure/Graph/Tree/Heap/MinHeap.php
MinHeap.swap
public function swap(int $current, int $parent): void { $tmp = $this->heap[$current]; $this->heap[$current] = $this->heap[$parent]; $this->heap[$parent] = $tmp; }
php
public function swap(int $current, int $parent): void { $tmp = $this->heap[$current]; $this->heap[$current] = $this->heap[$parent]; $this->heap[$parent] = $tmp; }
[ "public", "function", "swap", "(", "int", "$", "current", ",", "int", "$", "parent", ")", ":", "void", "{", "$", "tmp", "=", "$", "this", "->", "heap", "[", "$", "current", "]", ";", "$", "this", "->", "heap", "[", "$", "current", "]", "=", "$"...
swaps the value at the current position with the value at the parent position @param int $current @param int $parent
[ "swaps", "the", "value", "at", "the", "current", "position", "with", "the", "value", "at", "the", "parent", "position" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/Heap/MinHeap.php#L145-L149
27,186
doganoo/PHPAlgorithms
src/Datastructure/Graph/Tree/Heap/MinHeap.php
MinHeap.inHeap
public function inHeap(int $element): bool { foreach ($this->heap as $key => $value) { if (Comparator::equals($element, $value)) { return true; } } return false; }
php
public function inHeap(int $element): bool { foreach ($this->heap as $key => $value) { if (Comparator::equals($element, $value)) { return true; } } return false; }
[ "public", "function", "inHeap", "(", "int", "$", "element", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "heap", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "Comparator", "::", "equals", "(", "$", "element", ",", "$", ...
determines if a element is in the heap or not @param int $element @return bool
[ "determines", "if", "a", "element", "is", "in", "the", "heap", "or", "not" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/Heap/MinHeap.php#L157-L164
27,187
doganoo/PHPAlgorithms
src/Datastructure/Cache/LRUCache.php
LRUCache.put
public function put($key, $value): bool { if ($this->hashMap->containsKey($key)) { $node = $this->getNodeFromHead($key); $node->setKey($key); $node->setValue($value); $this->unset($node); $this->updateHead($node); return true; } ...
php
public function put($key, $value): bool { if ($this->hashMap->containsKey($key)) { $node = $this->getNodeFromHead($key); $node->setKey($key); $node->setValue($value); $this->unset($node); $this->updateHead($node); return true; } ...
[ "public", "function", "put", "(", "$", "key", ",", "$", "value", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "hashMap", "->", "containsKey", "(", "$", "key", ")", ")", "{", "$", "node", "=", "$", "this", "->", "getNodeFromHead", "(", "$"...
adds a new key value pair @param $key @param $value @return bool @throws \doganoo\PHPAlgorithms\common\Exception\InvalidKeyTypeException @throws \doganoo\PHPAlgorithms\common\Exception\UnsupportedKeyTypeException
[ "adds", "a", "new", "key", "value", "pair" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Cache/LRUCache.php#L65-L87
27,188
doganoo/PHPAlgorithms
src/Datastructure/Cache/LRUCache.php
LRUCache.get
public function get($key) { if ($this->hashMap->containsKey($key)) { $node = $this->getNodeFromHead($key); $this->unset($node); $this->updateHead($node); return $this->head->getValue(); } return null; }
php
public function get($key) { if ($this->hashMap->containsKey($key)) { $node = $this->getNodeFromHead($key); $this->unset($node); $this->updateHead($node); return $this->head->getValue(); } return null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "hashMap", "->", "containsKey", "(", "$", "key", ")", ")", "{", "$", "node", "=", "$", "this", "->", "getNodeFromHead", "(", "$", "key", ")", ";", "$", "this", ...
retrieves a value @param $key @return mixed
[ "retrieves", "a", "value" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Cache/LRUCache.php#L152-L160
27,189
doganoo/PHPAlgorithms
src/Datastructure/Cache/LRUCache.php
LRUCache.delete
public function delete($key): bool { $node = $this->getNodeFromHead($key); if (null === $node) { return false; } /** @var Node $head */ $head = $this->head; while (null !== $head) { if (Comparator::equals($head->getKey(), $node->getKey())) { ...
php
public function delete($key): bool { $node = $this->getNodeFromHead($key); if (null === $node) { return false; } /** @var Node $head */ $head = $this->head; while (null !== $head) { if (Comparator::equals($head->getKey(), $node->getKey())) { ...
[ "public", "function", "delete", "(", "$", "key", ")", ":", "bool", "{", "$", "node", "=", "$", "this", "->", "getNodeFromHead", "(", "$", "key", ")", ";", "if", "(", "null", "===", "$", "node", ")", "{", "return", "false", ";", "}", "/** @var Node ...
deletes a given key @param $key @return bool @throws \doganoo\PHPAlgorithms\common\Exception\InvalidKeyTypeException @throws \doganoo\PHPAlgorithms\common\Exception\UnsupportedKeyTypeException
[ "deletes", "a", "given", "key" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Cache/LRUCache.php#L179-L195
27,190
acmephp/core
Http/SecureHttpClientFactory.php
SecureHttpClientFactory.createSecureHttpClient
public function createSecureHttpClient(KeyPair $accountKeyPair) { return new SecureHttpClient( $accountKeyPair, $this->httpClient, $this->base64Encoder, $this->keyParser, $this->dataSigner, $this->errorHandler ); }
php
public function createSecureHttpClient(KeyPair $accountKeyPair) { return new SecureHttpClient( $accountKeyPair, $this->httpClient, $this->base64Encoder, $this->keyParser, $this->dataSigner, $this->errorHandler ); }
[ "public", "function", "createSecureHttpClient", "(", "KeyPair", "$", "accountKeyPair", ")", "{", "return", "new", "SecureHttpClient", "(", "$", "accountKeyPair", ",", "$", "this", "->", "httpClient", ",", "$", "this", "->", "base64Encoder", ",", "$", "this", "...
Create a SecureHttpClient using a given account KeyPair. @param KeyPair $accountKeyPair @return SecureHttpClient
[ "Create", "a", "SecureHttpClient", "using", "a", "given", "account", "KeyPair", "." ]
56af3e28926f4b7507397bfe7fb1ca5f83d73eb4
https://github.com/acmephp/core/blob/56af3e28926f4b7507397bfe7fb1ca5f83d73eb4/Http/SecureHttpClientFactory.php#L79-L89
27,191
doganoo/PHPAlgorithms
src/Datastructure/Lists/LinkedLists/DoublyLinkedList.php
DoublyLinkedList.prepend
public function prepend(?Node $node): bool { if ($node === null) { return false; } /* * need to clone the object otherwise the object * references are going crazy. * * Furthermore, setting previous and next to null * as they will be set la...
php
public function prepend(?Node $node): bool { if ($node === null) { return false; } /* * need to clone the object otherwise the object * references are going crazy. * * Furthermore, setting previous and next to null * as they will be set la...
[ "public", "function", "prepend", "(", "?", "Node", "$", "node", ")", ":", "bool", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "false", ";", "}", "/*\n * need to clone the object otherwise the object\n * references are going crazy.\n...
prepends a node on top of the list @param \doganoo\PHPAlgorithms\Datastructure\Lists\Node|null $node @return bool
[ "prepends", "a", "node", "on", "top", "of", "the", "list" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/LinkedLists/DoublyLinkedList.php#L76-L100
27,192
doganoo/PHPAlgorithms
src/Algorithm/Traversal/InOrder.php
InOrder._traverse
public function _traverse(?IBinaryNode $node) { if (null !== $node) { if (null !== $node->getLeft()) { $this->_traverse($node->getLeft()); } parent::visit($node->getValue()); if (null !== $node->getRight()) { $this->_traverse($node-...
php
public function _traverse(?IBinaryNode $node) { if (null !== $node) { if (null !== $node->getLeft()) { $this->_traverse($node->getLeft()); } parent::visit($node->getValue()); if (null !== $node->getRight()) { $this->_traverse($node-...
[ "public", "function", "_traverse", "(", "?", "IBinaryNode", "$", "node", ")", "{", "if", "(", "null", "!==", "$", "node", ")", "{", "if", "(", "null", "!==", "$", "node", "->", "getLeft", "(", ")", ")", "{", "$", "this", "->", "_traverse", "(", "...
helper method for traversing @param IBinaryNode|null $node
[ "helper", "method", "for", "traversing" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Algorithm/Traversal/InOrder.php#L63-L73
27,193
doganoo/PHPAlgorithms
src/Datastructure/Stackqueue/FixedQueue.php
FixedQueue.isValid
protected function isValid(): bool { $parent = parent::isValid(); $maxSize = parent::size() < $this->maxSize; return $parent && $maxSize; }
php
protected function isValid(): bool { $parent = parent::isValid(); $maxSize = parent::size() < $this->maxSize; return $parent && $maxSize; }
[ "protected", "function", "isValid", "(", ")", ":", "bool", "{", "$", "parent", "=", "parent", "::", "isValid", "(", ")", ";", "$", "maxSize", "=", "parent", "::", "size", "(", ")", "<", "$", "this", "->", "maxSize", ";", "return", "$", "parent", "&...
returns whether the element is valid or not. Checks among other things also the number of elements @return bool
[ "returns", "whether", "the", "element", "is", "valid", "or", "not", ".", "Checks", "among", "other", "things", "also", "the", "number", "of", "elements" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Stackqueue/FixedQueue.php#L66-L70
27,194
doganoo/PHPAlgorithms
src/Datastructure/Lists/ArrayLists/ArrayList.php
ArrayList.removeByValue
public function removeByValue($value): bool { if (!$this->containsValue($value)) { return true; } $key = $this->indexOf($value); $removed = $this->remove($key); return $removed; }
php
public function removeByValue($value): bool { if (!$this->containsValue($value)) { return true; } $key = $this->indexOf($value); $removed = $this->remove($key); return $removed; }
[ "public", "function", "removeByValue", "(", "$", "value", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "containsValue", "(", "$", "value", ")", ")", "{", "return", "true", ";", "}", "$", "key", "=", "$", "this", "->", "indexOf", "(", ...
removes a single value from the list @param $value @return bool
[ "removes", "a", "single", "value", "from", "the", "list" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/ArrayLists/ArrayList.php#L154-L161
27,195
doganoo/PHPAlgorithms
src/Datastructure/Lists/ArrayLists/ArrayList.php
ArrayList.addAllArray
public function addAllArray(array $array): bool { $added = true; foreach ($array as $value) { $added &= $this->add($value); } return $added; }
php
public function addAllArray(array $array): bool { $added = true; foreach ($array as $value) { $added &= $this->add($value); } return $added; }
[ "public", "function", "addAllArray", "(", "array", "$", "array", ")", ":", "bool", "{", "$", "added", "=", "true", ";", "foreach", "(", "$", "array", "as", "$", "value", ")", "{", "$", "added", "&=", "$", "this", "->", "add", "(", "$", "value", "...
adds all elements of an array to the list @param array $array @return bool
[ "adds", "all", "elements", "of", "an", "array", "to", "the", "list" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/ArrayLists/ArrayList.php#L325-L331
27,196
doganoo/PHPAlgorithms
src/Datastructure/Lists/ArrayLists/ArrayList.php
ArrayList.addAll
public function addAll(ArrayList $arrayList): bool { $added = false; foreach ($arrayList as $value) { $added |= $this->add($value); } return $added; }
php
public function addAll(ArrayList $arrayList): bool { $added = false; foreach ($arrayList as $value) { $added |= $this->add($value); } return $added; }
[ "public", "function", "addAll", "(", "ArrayList", "$", "arrayList", ")", ":", "bool", "{", "$", "added", "=", "false", ";", "foreach", "(", "$", "arrayList", "as", "$", "value", ")", "{", "$", "added", "|=", "$", "this", "->", "add", "(", "$", "val...
adds all elements of an array list to the list @param ArrayList $arrayList @return bool
[ "adds", "all", "elements", "of", "an", "array", "list", "to", "the", "list" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/ArrayLists/ArrayList.php#L367-L373
27,197
doganoo/PHPAlgorithms
src/Common/Util/MapUtil.php
MapUtil.stringToKey
public static function stringToKey(string $string): int { $key = 0; for ($i = 0; $i < \strlen($string); $i++) { $char = $string[$i]; $key += \ord($char); } return $key; }
php
public static function stringToKey(string $string): int { $key = 0; for ($i = 0; $i < \strlen($string); $i++) { $char = $string[$i]; $key += \ord($char); } return $key; }
[ "public", "static", "function", "stringToKey", "(", "string", "$", "string", ")", ":", "int", "{", "$", "key", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "\\", "strlen", "(", "$", "string", ")", ";", "$", "i", "++", ")...
converts a string to a hash map key by summing all ASCII values of each character. @param string $string @return int
[ "converts", "a", "string", "to", "a", "hash", "map", "key", "by", "summing", "all", "ASCII", "values", "of", "each", "character", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Util/MapUtil.php#L96-L103
27,198
doganoo/PHPAlgorithms
src/Common/Util/MapUtil.php
MapUtil.objectToString
public static function objectToString($object): string { //TODO do type hinting when possible if (!\is_object($object)) { throw new InvalidKeyTypeException("key has to be an object, " . \gettype($object) . "given"); } return \serialize($object); }
php
public static function objectToString($object): string { //TODO do type hinting when possible if (!\is_object($object)) { throw new InvalidKeyTypeException("key has to be an object, " . \gettype($object) . "given"); } return \serialize($object); }
[ "public", "static", "function", "objectToString", "(", "$", "object", ")", ":", "string", "{", "//TODO do type hinting when possible", "if", "(", "!", "\\", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "InvalidKeyTypeException", "(", "\"key ha...
This methods converts an object to a string using serialization @param $object @return string @throws InvalidKeyTypeException
[ "This", "methods", "converts", "an", "object", "to", "a", "string", "using", "serialization" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Util/MapUtil.php#L112-L118
27,199
doganoo/PHPAlgorithms
src/Common/Util/MapUtil.php
MapUtil.arrayToKey
public static function arrayToKey(array $array): string { $result = ""; \array_walk_recursive($array, function ($key, $value) use (&$result) { $result .= $key . $value; }); return $result; }
php
public static function arrayToKey(array $array): string { $result = ""; \array_walk_recursive($array, function ($key, $value) use (&$result) { $result .= $key . $value; }); return $result; }
[ "public", "static", "function", "arrayToKey", "(", "array", "$", "array", ")", ":", "string", "{", "$", "result", "=", "\"\"", ";", "\\", "array_walk_recursive", "(", "$", "array", ",", "function", "(", "$", "key", ",", "$", "value", ")", "use", "(", ...
converts an array to a valid key for HashMap @param array $array @return string
[ "converts", "an", "array", "to", "a", "valid", "key", "for", "HashMap" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Common/Util/MapUtil.php#L126-L132