repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
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' => $message, 'routingKey' => $routingKey, 'flags' => $flags, 'attributes' => $attributes, ]; }
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' => $message, 'routingKey' => $routingKey, 'flags' => $flags, 'attributes' => $attributes, ]; }
[ "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
train
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
train
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
train
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
train
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; } // Get the token string from access token $token = \json_decode($accessToken)->access_token; $url = \sprintf('https://www.google.com/accounts/AuthSubTokenInfo?bearer_token=%s', $token); if (false === @\file_get_contents($url)) { return false; } // Retrieve HTTP status code list($version, $statusCode, $msg) = \explode(' ', $http_response_header[0], 3); return 200 === (int) $statusCode; }
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; } // Get the token string from access token $token = \json_decode($accessToken)->access_token; $url = \sprintf('https://www.google.com/accounts/AuthSubTokenInfo?bearer_token=%s', $token); if (false === @\file_get_contents($url)) { return false; } // Retrieve HTTP status code list($version, $statusCode, $msg) = \explode(' ', $http_response_header[0], 3); return 200 === (int) $statusCode; }
[ "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
train
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 = $this->pool->getItem($cacheKey)->set(new AccessToken($name, $accessToken)); $this->pool->save($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 = $this->pool->getItem($cacheKey)->set(new AccessToken($name, $accessToken)); $this->pool->save($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
train
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
train
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 true; } } catch (\Google_Auth_Exception $e) { } return false; }
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 true; } } catch (\Google_Auth_Exception $e) { } return false; }
[ "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
train
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->isInterrupted() or $node->isComment()) { continue; } $commands->each(function ($command) use ($node, $currentCommand) { $class = "\\Axiom\\Rivescript\\Cortex\\Commands\\$command"; $commandClass = new $class(); $result = $commandClass->parse($node, $currentCommand); if (isset($result['command'])) { $currentCommand = $result['command']; return false; } }); } }
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->isInterrupted() or $node->isComment()) { continue; } $commands->each(function ($command) use ($node, $currentCommand) { $class = "\\Axiom\\Rivescript\\Cortex\\Commands\\$command"; $commandClass = new $class(); $result = $commandClass->parse($node, $currentCommand); if (isset($result['command'])) { $currentCommand = $result['command']; return false; } }); } }
[ "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
train
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->isEmpty()) { $this->push($r->pop()); } }
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->isEmpty()) { $this->push($r->pop()); } }
[ "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
train
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
train
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 my mind) uglifies the code. @param $data @return bool
[ "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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 $result; } //if the number of elements in the array //is greater than 0, there are more elements //to build an permutation. // -------------------------------- //The length is decreased by each recursive function call for ($i = 0; $i < $length; $i++) { //new object in order to create the new prefix $object = $objects[$i]; //a new prefix is created. The prefix consists of the //actual prefix ("" at the beginning) and the next element //in the objects array $newPrefix = $prefix . $object; //since the ith element in objects is used as a prefix, //the remaining objects have to be sliced by exactly this //object in order to prevent a reoccurrence of the element in //the permutation $newObjects = \array_merge( \array_slice($objects, 0, $i), \array_slice($objects, $i + 1) ); //call the permute method with the new prefix and objects $result = $this->permute($newObjects, $newPrefix, $result); } return $result; }
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 $result; } //if the number of elements in the array //is greater than 0, there are more elements //to build an permutation. // -------------------------------- //The length is decreased by each recursive function call for ($i = 0; $i < $length; $i++) { //new object in order to create the new prefix $object = $objects[$i]; //a new prefix is created. The prefix consists of the //actual prefix ("" at the beginning) and the next element //in the objects array $newPrefix = $prefix . $object; //since the ith element in objects is used as a prefix, //the remaining objects have to be sliced by exactly this //object in order to prevent a reoccurrence of the element in //the permutation $newObjects = \array_merge( \array_slice($objects, 0, $i), \array_slice($objects, $i + 1) ); //call the permute method with the new prefix and objects $result = $this->permute($newObjects, $newPrefix, $result); } return $result; }
[ "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
train
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($hare->getNext()->getNext()); } else { $hare = $hare->getNext(); } } $tortoise = $tortoise->getNext(); } }
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($hare->getNext()->getNext()); } else { $hare = $hare->getNext(); } } $tortoise = $tortoise->getNext(); } }
[ "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
train
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 found then return it return $tmp; } $tmp = $tmp->getNext(); } return null; }
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 found then return it return $tmp; } $tmp = $tmp->getNext(); } return null; }
[ "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
train
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
train
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->getNext(); } return null; }
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->getNext(); } return null; }
[ "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
train
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
train
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 iterates over all nodes until the * value is found. */ while ($head !== null && $head->getKey() !== $key) { /* * since a node is going to be removed from the * node chain, the previous element has to be * on hold. * After previous is set to the actual element, * the current element pointer can moved to the * next one. * * If the value is found, $previous points to * the previous element of the value that is * searched and current points to the next element * after that one who should be deleted. */ $previous = $head; $head = $head->getNext(); $i++; } /* * If the value that should be deleted is not in the list, * this set instruction assigns the next node to the actual. * * If the while loop has ended early, the next node is * assigned to the previous node of the node that * should be deleted (if there is a node present). */ if ($head !== null) { $previous->setNext($head->getNext()); } return $i !== $headSize; }
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 iterates over all nodes until the * value is found. */ while ($head !== null && $head->getKey() !== $key) { /* * since a node is going to be removed from the * node chain, the previous element has to be * on hold. * After previous is set to the actual element, * the current element pointer can moved to the * next one. * * If the value is found, $previous points to * the previous element of the value that is * searched and current points to the next element * after that one who should be deleted. */ $previous = $head; $head = $head->getNext(); $i++; } /* * If the value that should be deleted is not in the list, * this set instruction assigns the next node to the actual. * * If the while loop has ended early, the next node is * assigned to the previous node of the node that * should be deleted (if there is a node present). */ if ($head !== null) { $previous->setNext($head->getNext()); } return $i !== $headSize; }
[ "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
train
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->getNext(); } return $replaced; }
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->getNext(); } return $replaced; }
[ "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
train
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())) { return true; } $tortoise = $tortoise->getNext(); } return false; }
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())) { return true; } $tortoise = $tortoise->getNext(); } return false; }
[ "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
train
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->getNext() ) { $p = $p->getNext(); $q = $q->getNext()->getNext(); } return $p; }
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->getNext() ) { $p = $p->getNext(); $q = $q->getNext()->getNext(); } return $p; }
[ "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
train
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
train
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); } } while (!$stack->isEmpty()) { $stringBuilder->append($stack->pop()); } } else { $queue = new Queue(); foreach ($arrayList as $item) { if (null !== $item) { $queue->enqueue($item); } } while (!$queue->isEmpty()) { $stringBuilder->append($queue->dequeue()); } } return $stringBuilder; }
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); } } while (!$stack->isEmpty()) { $stringBuilder->append($stack->pop()); } } else { $queue = new Queue(); foreach ($arrayList as $item) { if (null !== $item) { $queue->enqueue($item); } } while (!$queue->isEmpty()) { $stringBuilder->append($queue->dequeue()); } } return $stringBuilder; }
[ "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
train
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
train
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 (Comparator::lessThan($array[$j], $array[$min])) { $min = $j; } } $tmp = $array[$min]; $array[$min] = $array[$i]; $array[$i] = $tmp; } return $array; }
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 (Comparator::lessThan($array[$j], $array[$min])) { $min = $j; } } $tmp = $array[$min]; $array[$min] = $array[$i]; $array[$i] = $tmp; } return $array; }
[ "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
train
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(); } return $this->account; }
php
private function getResourceAccount() { if (!$this->account) { $payload = [ 'onlyReturnExisting' => true, ]; $this->requestResource('POST', ResourcesDirectory::NEW_ACCOUNT, $payload); $this->account = $this->getHttpClient()->getLastLocation(); } return $this->account; }
[ "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
train
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
train
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
train
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->replaceValue($key, $value); return true; } $list->add($key, $value); $this->bucket[$arrayIndex] = $list; return true; }
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->replaceValue($key, $value); return true; } $list->add($key, $value); $this->bucket[$arrayIndex] = $list; return true; }
[ "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
train
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); $arrayIndex = $this->getArrayIndex($hash); return $arrayIndex; }
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); $arrayIndex = $this->getArrayIndex($hash); return $arrayIndex; }
[ "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 be true. Solution: use universal hashing @param $key @return int @throws \doganoo\PHPAlgorithms\Common\Exception\InvalidKeyTypeException @throws \doganoo\PHPAlgorithms\Common\Exception\UnsupportedKeyTypeException
[ "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
train
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 null; } $list = $this->bucket[$arrayIndex]; if (!$list->containsKey($key)) { return null; } $node = $list->getNodeByKey($key); return $node; }
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 null; } $list = $this->bucket[$arrayIndex]; if (!$list->containsKey($key)) { return null; } $node = $list->getNodeByKey($key); return $node; }
[ "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
train
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
train
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 and each entry has zero * or one nodes which can have zero, one or multiple * successors. */ if ($list->containsValue($value)) { return true; } } /* * If no bucket contains the value then return false because * the searched value is not in the list. */ return false; }
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 and each entry has zero * or one nodes which can have zero, one or multiple * successors. */ if ($list->containsValue($value)) { return true; } } /* * If no bucket contains the value then return false because * the searched value is not in the list. */ return false; }
[ "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
train
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 bucket. The bucket * can contain max $maxSize entries and each entry has zero * or one nodes which can have zero, one or multiple * successors. */ if ($list->containsKey($key)) { return true; } } /* * If no bucket contains the value then return false because * the searched value is not in the list. */ return false; }
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 bucket. The bucket * can contain max $maxSize entries and each entry has zero * or one nodes which can have zero, one or multiple * successors. */ if ($list->containsKey($key)) { return true; } } /* * If no bucket contains the value then return false because * the searched value is not in the list. */ return false; }
[ "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
train
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 * that $key is not in the list. * False would indicate that there was an error * and the node is still in the list */ if (!isset($this->bucket[$arrayIndex])) { return true; } /** @var SinglyLinkedList $list */ $list = $this->bucket[$arrayIndex]; /** @var Node $head */ $head = $list->getHead(); /* * there is one special case for the HashMap: * if there is only one node in the bucket, then * check if the nodes key equals to the key that * should be deleted. * If this is the case, set the bucket to null * because the only one node is removed. * If this is not the key, return false as there * is no node to remove. */ if ($list->size() == 1 && $head->getKey() === $key) { //$this->bucket[$arrayIndex] = null; unset($this->bucket[$arrayIndex]); return true; } return $list->remove($key); }
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 * that $key is not in the list. * False would indicate that there was an error * and the node is still in the list */ if (!isset($this->bucket[$arrayIndex])) { return true; } /** @var SinglyLinkedList $list */ $list = $this->bucket[$arrayIndex]; /** @var Node $head */ $head = $list->getHead(); /* * there is one special case for the HashMap: * if there is only one node in the bucket, then * check if the nodes key equals to the key that * should be deleted. * If this is the case, set the bucket to null * because the only one node is removed. * If this is not the key, return false as there * is no node to remove. */ if ($list->size() == 1 && $head->getKey() === $key) { //$this->bucket[$arrayIndex] = null; unset($this->bucket[$arrayIndex]); return true; } return $list->remove($key); }
[ "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
train
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); // json data expected to be keyed with ints, over the usual strings if (isset($array[0])) { // replace array with exportable array list $array = new ArrayListExportable($array); } return $root ? var_export($array, true) : $array; }
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); // json data expected to be keyed with ints, over the usual strings if (isset($array[0])) { // replace array with exportable array list $array = new ArrayListExportable($array); } return $root ? var_export($array, true) : $array; }
[ "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
train
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
train
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
train
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
train
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
train
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; } if ($this->hashMap->size() >= $this->capacity) { $end = $this->getEnd(); if (null !== $end) { $this->unset($end); $this->hashMap->remove($end->getKey()); } } $node = new Node(); $node->setKey($key); $node->setValue($value); $this->updateHead($node); $this->hashMap->add($key, $value); 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; } if ($this->hashMap->size() >= $this->capacity) { $end = $this->getEnd(); if (null !== $end) { $this->unset($end); $this->hashMap->remove($end->getKey()); } } $node = new Node(); $node->setKey($key); $node->setValue($value); $this->updateHead($node); $this->hashMap->add($key, $value); 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
train
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
train
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())) { $this->unset($head); $this->hashMap->remove($key); return true; } $head = $head->getNext(); } return false; }
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())) { $this->unset($head); $this->hashMap->remove($key); return true; } $head = $head->getNext(); } return false; }
[ "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
train
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
train
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 later. */ $newNode = clone $node; $newNode->setPrevious(null); $newNode->setNext(null); if ($this->getHead() === null) { $this->setHead($newNode); return true; } $head = $this->getHead(); $head->setPrevious($newNode); $newNode->setNext($head); $this->setHead($newNode); return true; }
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 later. */ $newNode = clone $node; $newNode->setPrevious(null); $newNode->setNext(null); if ($this->getHead() === null) { $this->setHead($newNode); return true; } $head = $this->getHead(); $head->setPrevious($newNode); $newNode->setNext($head); $this->setHead($newNode); return true; }
[ "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
train
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->getRight()); } } }
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->getRight()); } } }
[ "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
train
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
train
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
train
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
train
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
train
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
train
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
train
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
train
doganoo/PHPAlgorithms
src/Datastructure/Lists/LinkedLists/SinglyLinkedList.php
SinglyLinkedList.prepend
public function prepend(?Node $node): bool { if ($node === null) { return false; } $node->setNext($this->getHead()); $this->setHead($node); return true; }
php
public function prepend(?Node $node): bool { if ($node === null) { return false; } $node->setNext($this->getHead()); $this->setHead($node); return true; }
[ "public", "function", "prepend", "(", "?", "Node", "$", "node", ")", ":", "bool", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "false", ";", "}", "$", "node", "->", "setNext", "(", "$", "this", "->", "getHead", "(", ")", ")", ...
the prepend method simply checks first if the node is still valid. If it does not equal to null, the next pointer of the new node is set to head and the head is set to the new node in order to create the new head. @param \doganoo\PHPAlgorithms\Datastructure\Lists\Node $node @return bool
[ "the", "prepend", "method", "simply", "checks", "first", "if", "the", "node", "is", "still", "valid", ".", "If", "it", "does", "not", "equal", "to", "null", "the", "next", "pointer", "of", "the", "new", "node", "is", "set", "to", "head", "and", "the", ...
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/LinkedLists/SinglyLinkedList.php#L78-L85
train
doganoo/PHPAlgorithms
src/Datastructure/Graph/Tree/Trie/Trie.php
Trie._countWords
private function _countWords(?Node $node): int { $result = 0; if (null === $node) return $result; if ($node->isEndOfWordNode()) $result++; for ($i = 0; $i < self::ALPHABET_SIZE; $i++) { if ($node->hasChild($i)) { $child = $node->getChildNode($i); $result += $this->_countWords($child); } } return $result; }
php
private function _countWords(?Node $node): int { $result = 0; if (null === $node) return $result; if ($node->isEndOfWordNode()) $result++; for ($i = 0; $i < self::ALPHABET_SIZE; $i++) { if ($node->hasChild($i)) { $child = $node->getChildNode($i); $result += $this->_countWords($child); } } return $result; }
[ "private", "function", "_countWords", "(", "?", "Node", "$", "node", ")", ":", "int", "{", "$", "result", "=", "0", ";", "if", "(", "null", "===", "$", "node", ")", "return", "$", "result", ";", "if", "(", "$", "node", "->", "isEndOfWordNode", "(",...
helper method for counting number of words in the trie @param Node $node @return int
[ "helper", "method", "for", "counting", "number", "of", "words", "in", "the", "trie" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/Trie/Trie.php#L136-L147
train
doganoo/PHPAlgorithms
src/Datastructure/Lists/Node.php
Node.size
public function size() { /** @var Node $node */ $node = $this->next; $size = 1; while ($node !== null) { $size++; $node = $node->getNext(); } return $size; }
php
public function size() { /** @var Node $node */ $node = $this->next; $size = 1; while ($node !== null) { $size++; $node = $node->getNext(); } return $size; }
[ "public", "function", "size", "(", ")", "{", "/** @var Node $node */", "$", "node", "=", "$", "this", "->", "next", ";", "$", "size", "=", "1", ";", "while", "(", "$", "node", "!==", "null", ")", "{", "$", "size", "++", ";", "$", "node", "=", "$"...
counts the number of nodes @return int
[ "counts", "the", "number", "of", "nodes" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Lists/Node.php#L68-L78
train
doganoo/PHPAlgorithms
src/Datastructure/Graph/Tree/BinarySearchTree.php
BinarySearchTree.createFromArrayWithMinimumHeight
public static function createFromArrayWithMinimumHeight(?array $array): ?BinarySearchTree { if (null === $array) { return null; } $tree = new BinarySearchTree(); if (0 === \count($array)) { return $tree; } $sort = new MergeSort(); $array = $sort->sort($array); $root = BinarySearchTree::_createFromArrayWithMinimumHeight($array, 0, \count($array) - 1); $tree = new BinarySearchTree(); $tree->setRoot($root); return $tree; }
php
public static function createFromArrayWithMinimumHeight(?array $array): ?BinarySearchTree { if (null === $array) { return null; } $tree = new BinarySearchTree(); if (0 === \count($array)) { return $tree; } $sort = new MergeSort(); $array = $sort->sort($array); $root = BinarySearchTree::_createFromArrayWithMinimumHeight($array, 0, \count($array) - 1); $tree = new BinarySearchTree(); $tree->setRoot($root); return $tree; }
[ "public", "static", "function", "createFromArrayWithMinimumHeight", "(", "?", "array", "$", "array", ")", ":", "?", "BinarySearchTree", "{", "if", "(", "null", "===", "$", "array", ")", "{", "return", "null", ";", "}", "$", "tree", "=", "new", "BinarySearc...
converts an array to a BST with minimum height. @param array|null $array @return BinarySearchTree|null
[ "converts", "an", "array", "to", "a", "BST", "with", "minimum", "height", "." ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/BinarySearchTree.php#L115-L129
train
doganoo/PHPAlgorithms
src/Datastructure/Graph/Tree/BinarySearchTree.php
BinarySearchTree.search
public function search($value): ?BinarySearchNode { /** @var BinarySearchNode $node */ $node = $this->getRoot(); while (null !== $node) { if (Comparator::equals($value, $node->getValue())) { return $node; } else if (Comparator::lessThan($value, $node->getValue())) { $node = $node->getLeft(); } else if (Comparator::greaterThan($value, $node->getValue())) { $node = $node->getRight(); } else { throw new InvalidSearchComparisionException("no comparision returned true. Maybe you passed different data types (scalar, object)?"); } } return null; }
php
public function search($value): ?BinarySearchNode { /** @var BinarySearchNode $node */ $node = $this->getRoot(); while (null !== $node) { if (Comparator::equals($value, $node->getValue())) { return $node; } else if (Comparator::lessThan($value, $node->getValue())) { $node = $node->getLeft(); } else if (Comparator::greaterThan($value, $node->getValue())) { $node = $node->getRight(); } else { throw new InvalidSearchComparisionException("no comparision returned true. Maybe you passed different data types (scalar, object)?"); } } return null; }
[ "public", "function", "search", "(", "$", "value", ")", ":", "?", "BinarySearchNode", "{", "/** @var BinarySearchNode $node */", "$", "node", "=", "$", "this", "->", "getRoot", "(", ")", ";", "while", "(", "null", "!==", "$", "node", ")", "{", "if", "(",...
searches a value @param $value @return BinarySearchNode|null @throws InvalidSearchComparisionException
[ "searches", "a", "value" ]
7d07d4b1970958defda3c88188b7683ec999735f
https://github.com/doganoo/PHPAlgorithms/blob/7d07d4b1970958defda3c88188b7683ec999735f/src/Datastructure/Graph/Tree/BinarySearchTree.php#L164-L179
train
ibrandcc/laravel-sms
src/Sms.php
Sms.checkAttempts
private function checkAttempts($code) { $maxAttempts = config('ibrand.sms.code.maxAttempts'); if ($code->expireAt > Carbon::now() && $code->attempts < $maxAttempts) { return false; } return true; }
php
private function checkAttempts($code) { $maxAttempts = config('ibrand.sms.code.maxAttempts'); if ($code->expireAt > Carbon::now() && $code->attempts < $maxAttempts) { return false; } return true; }
[ "private", "function", "checkAttempts", "(", "$", "code", ")", "{", "$", "maxAttempts", "=", "config", "(", "'ibrand.sms.code.maxAttempts'", ")", ";", "if", "(", "$", "code", "->", "expireAt", ">", "Carbon", "::", "now", "(", ")", "&&", "$", "code", "->"...
Check attempt times. @param $code @return bool
[ "Check", "attempt", "times", "." ]
6fd0325128721d0096faa6557e62e64886d6f737
https://github.com/ibrandcc/laravel-sms/blob/6fd0325128721d0096faa6557e62e64886d6f737/src/Sms.php#L173-L182
train
orchestral/kernel
src/Database/Console/Migrations/Packages.php
Packages.getPackageMigrationPaths
protected function getPackageMigrationPaths(string $package): array { return collect($this->option('path') ?: 'database/migrations') ->map(function ($path) use ($package) { return $this->packagePath.'/'.$package.'/'.$path; })->all(); }
php
protected function getPackageMigrationPaths(string $package): array { return collect($this->option('path') ?: 'database/migrations') ->map(function ($path) use ($package) { return $this->packagePath.'/'.$package.'/'.$path; })->all(); }
[ "protected", "function", "getPackageMigrationPaths", "(", "string", "$", "package", ")", ":", "array", "{", "return", "collect", "(", "$", "this", "->", "option", "(", "'path'", ")", "?", ":", "'database/migrations'", ")", "->", "map", "(", "function", "(", ...
Get the path to the package migration directory. @param string $package @return array
[ "Get", "the", "path", "to", "the", "package", "migration", "directory", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Database/Console/Migrations/Packages.php#L35-L41
train
melisplatform/melis-core
src/Controller/PlatformsController.php
PlatformsController.renderPlatformGenericFormAction
public function renderPlatformGenericFormAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY); $platformForm = $melisTool->getForm('meliscore_platform_generic_form'); $plfId = $this->params()->fromQuery('plf_id', ''); if ($plfId) { $platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform'); $platform = $platformTable->getEntryById($plfId)->current(); if (!empty($platform)) { $platformForm->bind($platform); if (getenv('MELIS_PLATFORM') == $platform->plf_name) { // Deactivating the platform name if the current platform is same to the requested platform $platformForm->get('plf_name')->setAttribute('disabled', true); } } } $view = new ViewModel(); $view->meliscore_platform_generic_form = $platformForm; $view->melisKey = $melisKey; $view->platformId = $plfId; return $view; }
php
public function renderPlatformGenericFormAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); // declare the Tool service that we will be using to completely create our tool. $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); // tell the Tool what configuration in the app.tool.php that will be used. $melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY); $platformForm = $melisTool->getForm('meliscore_platform_generic_form'); $plfId = $this->params()->fromQuery('plf_id', ''); if ($plfId) { $platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform'); $platform = $platformTable->getEntryById($plfId)->current(); if (!empty($platform)) { $platformForm->bind($platform); if (getenv('MELIS_PLATFORM') == $platform->plf_name) { // Deactivating the platform name if the current platform is same to the requested platform $platformForm->get('plf_name')->setAttribute('disabled', true); } } } $view = new ViewModel(); $view->meliscore_platform_generic_form = $platformForm; $view->melisKey = $melisKey; $view->platformId = $plfId; return $view; }
[ "public", "function", "renderPlatformGenericFormAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "// declare the Tool service that we will be using to completely create our to...
Renders the Generic form of the Platform for creating new and updating new platform @return \Zend\View\Model\ViewModel
[ "Renders", "the", "Generic", "form", "of", "the", "Platform", "for", "creating", "new", "and", "updating", "new", "platform" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformsController.php#L149-L186
train
melisplatform/melis-core
src/Controller/PlatformsController.php
PlatformsController.deletePlatformAction
public function deletePlatformAction() { $response = array(); $this->getEventManager()->trigger('meliscore_platform_delete_start', $this, $response); $translator = $this->getServiceLocator()->get('translator'); $platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform'); $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); $melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY); $textTitle = 'tr_meliscore_tool_platform_title'; $textMessage = 'tr_meliscore_tool_platform_prompts_delete_failed'; $id = 0; $success = 0; $platform = ''; if($this->getRequest()->isPost()) { $id = (int) $this->getRequest()->getPost('id'); if(is_numeric($id)) { $domainData = $platformTable->getEntryById($id); $domainData = $domainData->current(); if(!empty($domainData)) { $platform = $domainData->plf_name; $platformTable->deleteById($id); $textMessage = 'tr_meliscore_tool_platform_prompts_delete_success'; $success = 1; } } } $response = array( 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'success' => $success ); $eventData = array_merge($response, array( 'platform' => $platform, 'id' => $id, 'typeCode' => 'CORE_PLATFORM_DELETE', 'itemId' => $id )); $this->getEventManager()->trigger('meliscore_platform_delete_end', $this, $eventData); return new JsonModel($response); }
php
public function deletePlatformAction() { $response = array(); $this->getEventManager()->trigger('meliscore_platform_delete_start', $this, $response); $translator = $this->getServiceLocator()->get('translator'); $platformTable = $this->getServiceLocator()->get('MelisCoreTablePlatform'); $melisTool = $this->getServiceLocator()->get('MelisCoreTool'); $melisTool->setMelisToolKey(self::TOOL_INDEX, self::TOOL_KEY); $textTitle = 'tr_meliscore_tool_platform_title'; $textMessage = 'tr_meliscore_tool_platform_prompts_delete_failed'; $id = 0; $success = 0; $platform = ''; if($this->getRequest()->isPost()) { $id = (int) $this->getRequest()->getPost('id'); if(is_numeric($id)) { $domainData = $platformTable->getEntryById($id); $domainData = $domainData->current(); if(!empty($domainData)) { $platform = $domainData->plf_name; $platformTable->deleteById($id); $textMessage = 'tr_meliscore_tool_platform_prompts_delete_success'; $success = 1; } } } $response = array( 'textTitle' => $textTitle, 'textMessage' => $textMessage, 'success' => $success ); $eventData = array_merge($response, array( 'platform' => $platform, 'id' => $id, 'typeCode' => 'CORE_PLATFORM_DELETE', 'itemId' => $id )); $this->getEventManager()->trigger('meliscore_platform_delete_end', $this, $eventData); return new JsonModel($response); }
[ "public", "function", "deletePlatformAction", "(", ")", "{", "$", "response", "=", "array", "(", ")", ";", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "'meliscore_platform_delete_start'", ",", "$", "this", ",", "$", "response", ")",...
Deletion of the platform @return \Zend\View\Model\JsonModel
[ "Deletion", "of", "the", "platform" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformsController.php#L404-L453
train
melisplatform/melis-core
src/Controller/PlatformsController.php
PlatformsController.hasAccess
private function hasAccess($key): bool { $hasAccess = $this->getServiceLocator()->get('MelisCoreRights')->canAccess($key); return $hasAccess; }
php
private function hasAccess($key): bool { $hasAccess = $this->getServiceLocator()->get('MelisCoreRights')->canAccess($key); return $hasAccess; }
[ "private", "function", "hasAccess", "(", "$", "key", ")", ":", "bool", "{", "$", "hasAccess", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreRights'", ")", "->", "canAccess", "(", "$", "key", ")", ";", "return", "$"...
Checks whether the user has access to this tools or not @param $key @return bool
[ "Checks", "whether", "the", "user", "has", "access", "to", "this", "tools", "or", "not" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/PlatformsController.php#L489-L494
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.checkFormAction
public function checkFormAction() { $request = $this->getRequest(); $success = 0; $errors = []; if ($request->isPost()) { $formInputs = $this->getTool('meliscore', 'melis_core_gdpr_tool')->sanitizeRecursive(get_object_vars($request->getPost()), [], true); $formConfig = $this->getFormConfig('meliscore/tools/melis_core_gdpr_tool/forms/melis_core_gdpr_search_form', 'melis_core_gdpr_search_form'); $form = $this->getForm($formConfig); $form->setData($formInputs); if ($form->isValid()) { $success = 1; } else { $errors = $this->getFormErrors($form->getMessages(), $formConfig); $success = 0; } } return new JsonModel ([ 'success' => $success, 'errors' => $errors, ]); }
php
public function checkFormAction() { $request = $this->getRequest(); $success = 0; $errors = []; if ($request->isPost()) { $formInputs = $this->getTool('meliscore', 'melis_core_gdpr_tool')->sanitizeRecursive(get_object_vars($request->getPost()), [], true); $formConfig = $this->getFormConfig('meliscore/tools/melis_core_gdpr_tool/forms/melis_core_gdpr_search_form', 'melis_core_gdpr_search_form'); $form = $this->getForm($formConfig); $form->setData($formInputs); if ($form->isValid()) { $success = 1; } else { $errors = $this->getFormErrors($form->getMessages(), $formConfig); $success = 0; } } return new JsonModel ([ 'success' => $success, 'errors' => $errors, ]); }
[ "public", "function", "checkFormAction", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "success", "=", "0", ";", "$", "errors", "=", "[", "]", ";", "if", "(", "$", "request", "->", "isPost", "(", ")", ")...
This will get the data from the service which will get user info from modules that listens to the event. @return JsonModel
[ "This", "will", "get", "the", "data", "from", "the", "service", "which", "will", "get", "user", "info", "from", "modules", "that", "listens", "to", "the", "event", "." ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L25-L50
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.melisCoreGdprExtractSelectedAction
public function melisCoreGdprExtractSelectedAction() { $idsToBeExtracted = $this->getRequest()->getPost('id'); /** @var \MelisCore\Service\MelisCoreGdprService $melisCoreGdprService */ $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService'); $xml = $melisCoreGdprService->extractSelected($idsToBeExtracted); $name = "melisplatformgdpr.xml"; //$response = $this->downloadXml($name, $xml); $response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8'); $headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$name."\""); $headers->addHeaderLine('Accept-Ranges', 'bytes'); $headers->addHeaderLine('Content-Length', strlen($xml)); $headers->addHeaderLine('fileName', $name); $response->setContent($xml); $response->setStatusCode(200); $view = new ViewModel(); $view->setTerminal(true); $view->content = $response->getContent(); return $view; }
php
public function melisCoreGdprExtractSelectedAction() { $idsToBeExtracted = $this->getRequest()->getPost('id'); /** @var \MelisCore\Service\MelisCoreGdprService $melisCoreGdprService */ $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService'); $xml = $melisCoreGdprService->extractSelected($idsToBeExtracted); $name = "melisplatformgdpr.xml"; //$response = $this->downloadXml($name, $xml); $response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8'); $headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$name."\""); $headers->addHeaderLine('Accept-Ranges', 'bytes'); $headers->addHeaderLine('Content-Length', strlen($xml)); $headers->addHeaderLine('fileName', $name); $response->setContent($xml); $response->setStatusCode(200); $view = new ViewModel(); $view->setTerminal(true); $view->content = $response->getContent(); return $view; }
[ "public", "function", "melisCoreGdprExtractSelectedAction", "(", ")", "{", "$", "idsToBeExtracted", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getPost", "(", "'id'", ")", ";", "/** @var \\MelisCore\\Service\\MelisCoreGdprService $melisCoreGdprService */", "$",...
This will generate an xml file from the data based on the ids @return HttpResponse
[ "This", "will", "generate", "an", "xml", "file", "from", "the", "data", "based", "on", "the", "ids" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L56-L83
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.melisCoreGdprDeleteSelectedAction
public function melisCoreGdprDeleteSelectedAction() { $request = $this->getRequest(); $success = 0; if ($request->isPost()) { $idsToBeDeleted = get_object_vars($request->getPost()); $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService'); $finalData = $melisCoreGdprService->deleteSelected($idsToBeDeleted); $success = 1; foreach ($finalData as $key => $value) { if (!$value) { $success = 0; } } } return new JsonModel ([ 'success' => $success, ]); }
php
public function melisCoreGdprDeleteSelectedAction() { $request = $this->getRequest(); $success = 0; if ($request->isPost()) { $idsToBeDeleted = get_object_vars($request->getPost()); $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService'); $finalData = $melisCoreGdprService->deleteSelected($idsToBeDeleted); $success = 1; foreach ($finalData as $key => $value) { if (!$value) { $success = 0; } } } return new JsonModel ([ 'success' => $success, ]); }
[ "public", "function", "melisCoreGdprDeleteSelectedAction", "(", ")", "{", "$", "request", "=", "$", "this", "->", "getRequest", "(", ")", ";", "$", "success", "=", "0", ";", "if", "(", "$", "request", "->", "isPost", "(", ")", ")", "{", "$", "idsToBeDe...
This will delete the data based on the selected ids @return JsonModel
[ "This", "will", "delete", "the", "data", "based", "on", "the", "selected", "ids" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L90-L112
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.renderMelisCoreGdprContainerAction
public function renderMelisCoreGdprContainerAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
php
public function renderMelisCoreGdprContainerAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
[ "public", "function", "renderMelisCoreGdprContainerAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", ...
Container for the Gdpr page which will call all interface or zones inside of it which are header and content @return view model
[ "Container", "for", "the", "Gdpr", "page", "which", "will", "call", "all", "interface", "or", "zones", "inside", "of", "it", "which", "are", "header", "and", "content" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L121-L129
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.renderMelisCoreGdprHeaderAction
public function renderMelisCoreGdprHeaderAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
php
public function renderMelisCoreGdprHeaderAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
[ "public", "function", "renderMelisCoreGdprHeaderAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", "v...
Header for the Gdpr page displays the title and the description of the page @return view model
[ "Header", "for", "the", "Gdpr", "page", "displays", "the", "title", "and", "the", "description", "of", "the", "page" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L137-L145
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.renderMelisCoreGdprContentAction
public function renderMelisCoreGdprContentAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
php
public function renderMelisCoreGdprContentAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
[ "public", "function", "renderMelisCoreGdprContentAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", "...
Content of the Gdpr page which will call all the interfaces under it. which are search form and tabs @return ViewModel
[ "Content", "of", "the", "Gdpr", "page", "which", "will", "call", "all", "the", "interfaces", "under", "it", ".", "which", "are", "search", "form", "and", "tabs" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L154-L162
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.renderMelisCoreGdprSearchFormAction
public function renderMelisCoreGdprSearchFormAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $form = $this->getTool('meliscore', 'melis_core_gdpr_tool')->getForm('melis_core_gdpr_search_form'); $view = new ViewModel(); $view->melisKey = $melisKey; $view->form = $form; return $view; }
php
public function renderMelisCoreGdprSearchFormAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $form = $this->getTool('meliscore', 'melis_core_gdpr_tool')->getForm('melis_core_gdpr_search_form'); $view = new ViewModel(); $view->melisKey = $melisKey; $view->form = $form; return $view; }
[ "public", "function", "renderMelisCoreGdprSearchFormAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "form", "=", "$", "this", "->", "getTool", "(", "'mel...
Search form of the Gdpr page which will be used for the searching of user data @return view model
[ "Search", "form", "of", "the", "Gdpr", "page", "which", "will", "be", "used", "for", "the", "searching", "of", "user", "data" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L170-L181
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.renderMelisCoreGdprTabsAction
public function renderMelisCoreGdprTabsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $show = $this->params()->fromQuery('show', false); $formData = $this->params()->fromQuery('formData', []); if (!empty($formData)) { $finalData = []; foreach ($formData as $input) { $finalData[$input['name']] = $input['value']; } $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService'); $modulesData = $melisCoreGdprService->getUserInfo($finalData); } $view = new ViewModel(); $view->melisKey = $melisKey; $view->show = $show; if (isset($modulesData['results']) && !empty($modulesData['results'])) { $view->modules = $modulesData['results']; } return $view; }
php
public function renderMelisCoreGdprTabsAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $show = $this->params()->fromQuery('show', false); $formData = $this->params()->fromQuery('formData', []); if (!empty($formData)) { $finalData = []; foreach ($formData as $input) { $finalData[$input['name']] = $input['value']; } $melisCoreGdprService = $this->getServiceLocator()->get('MelisCoreGdprService'); $modulesData = $melisCoreGdprService->getUserInfo($finalData); } $view = new ViewModel(); $view->melisKey = $melisKey; $view->show = $show; if (isset($modulesData['results']) && !empty($modulesData['results'])) { $view->modules = $modulesData['results']; } return $view; }
[ "public", "function", "renderMelisCoreGdprTabsAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "show", "=", "$", "this", "->", "params", "(", ")", "->",...
The tabs that will show the records of user in every module @return view model
[ "The", "tabs", "that", "will", "show", "the", "records", "of", "user", "in", "every", "module" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L187-L212
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.getTool
private function getTool($pluginKey, $toolKey) { $tool = $this->getServiceLocator()->get('MelisCoreTool'); $tool->setMelisToolKey($pluginKey, $toolKey); return $tool; }
php
private function getTool($pluginKey, $toolKey) { $tool = $this->getServiceLocator()->get('MelisCoreTool'); $tool->setMelisToolKey($pluginKey, $toolKey); return $tool; }
[ "private", "function", "getTool", "(", "$", "pluginKey", ",", "$", "toolKey", ")", "{", "$", "tool", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreTool'", ")", ";", "$", "tool", "->", "setMelisToolKey", "(", "$", "...
Gets the tool @param plugin key @param tool key @return array|object
[ "Gets", "the", "tool" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L221-L227
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.getForm
private function getForm($formConfig) { $factory = new \Zend\Form\Factory(); $formElements = $this->serviceLocator->get('FormElementManager'); $factory->setFormElementManager($formElements); $form = $factory->createForm($formConfig); return $form; }
php
private function getForm($formConfig) { $factory = new \Zend\Form\Factory(); $formElements = $this->serviceLocator->get('FormElementManager'); $factory->setFormElementManager($formElements); $form = $factory->createForm($formConfig); return $form; }
[ "private", "function", "getForm", "(", "$", "formConfig", ")", "{", "$", "factory", "=", "new", "\\", "Zend", "\\", "Form", "\\", "Factory", "(", ")", ";", "$", "formElements", "=", "$", "this", "->", "serviceLocator", "->", "get", "(", "'FormElementMana...
Gets the form @param formConfig @return \Zend\Form\ElementInterface
[ "Gets", "the", "form" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L234-L242
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.getFormConfig
private function getFormConfig($formPath, $form) { $melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $appConfigForm = $melisCoreConfig->getFormMergedAndOrdered($formPath, $form); return $appConfigForm; }
php
private function getFormConfig($formPath, $form) { $melisCoreConfig = $this->getServiceLocator()->get('MelisCoreConfig'); $appConfigForm = $melisCoreConfig->getFormMergedAndOrdered($formPath, $form); return $appConfigForm; }
[ "private", "function", "getFormConfig", "(", "$", "formPath", ",", "$", "form", ")", "{", "$", "melisCoreConfig", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreConfig'", ")", ";", "$", "appConfigForm", "=", "$", "melis...
This will get the form config @param $formPath @param $form @return mixed
[ "This", "will", "get", "the", "form", "config" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L250-L256
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.downloadXml
private function downloadXml($fileName, $xml) { //$response = new HttpResponse(); $response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8'); $headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$fileName."\""); $headers->addHeaderLine('Accept-Ranges', 'bytes'); $headers->addHeaderLine('Content-Length', strlen($xml)); $headers->addHeaderLine('fileName', $fileName); $response->setContent($xml); $response->setStatusCode(200); return $response; }
php
private function downloadXml($fileName, $xml) { //$response = new HttpResponse(); $response = $this->getResponse(); $headers = $response->getHeaders(); $headers->addHeaderLine('Content-Type', 'text/xml; charset=utf-8'); $headers->addHeaderLine('Content-Disposition', "attachment; filename=\"".$fileName."\""); $headers->addHeaderLine('Accept-Ranges', 'bytes'); $headers->addHeaderLine('Content-Length', strlen($xml)); $headers->addHeaderLine('fileName', $fileName); $response->setContent($xml); $response->setStatusCode(200); return $response; }
[ "private", "function", "downloadXml", "(", "$", "fileName", ",", "$", "xml", ")", "{", "//$response = new HttpResponse();", "$", "response", "=", "$", "this", "->", "getResponse", "(", ")", ";", "$", "headers", "=", "$", "response", "->", "getHeaders", "(", ...
This will download the xml as a file @param file name @param xml @return HttpResponse
[ "This", "will", "download", "the", "xml", "as", "a", "file" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L264-L279
train
melisplatform/melis-core
src/Controller/MelisCoreGdprController.php
MelisCoreGdprController.getFormErrors
private function getFormErrors($errors, $formConfig) { foreach ($errors as $errorKey => $errorValue) { foreach ($formConfig['elements'] as $elementKey => $elementValue) { if ($elementValue['spec']['name'] == $errorKey && !empty($elementValue['spec']['options']['label'])) { $errors[$elementValue['spec']['options']['label']] = reset($errorValue); unset($errors[$errorKey]); } } } return $errors; }
php
private function getFormErrors($errors, $formConfig) { foreach ($errors as $errorKey => $errorValue) { foreach ($formConfig['elements'] as $elementKey => $elementValue) { if ($elementValue['spec']['name'] == $errorKey && !empty($elementValue['spec']['options']['label'])) { $errors[$elementValue['spec']['options']['label']] = reset($errorValue); unset($errors[$errorKey]); } } } return $errors; }
[ "private", "function", "getFormErrors", "(", "$", "errors", ",", "$", "formConfig", ")", "{", "foreach", "(", "$", "errors", "as", "$", "errorKey", "=>", "$", "errorValue", ")", "{", "foreach", "(", "$", "formConfig", "[", "'elements'", "]", "as", "$", ...
This will get the errors of the form @param $errors @param $formConfig @return mixed
[ "This", "will", "get", "the", "errors", "of", "the", "form" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/MelisCoreGdprController.php#L287-L299
train
UseMuffin/Tokenize
src/Model/Behavior/TokenizeBehavior.php
TokenizeBehavior.initialize
public function initialize(array $config) { $this->verifyConfig(); $this->_table->hasMany($this->getConfig('associationAlias'), [ 'className' => 'Muffin/Tokenize.Tokens', 'foreignKey' => 'foreign_key', 'conditions' => [ 'foreign_alias' => $this->_table->getAlias(), 'foreign_table' => $this->_table->getTable(), ], 'dependent' => true, ]); }
php
public function initialize(array $config) { $this->verifyConfig(); $this->_table->hasMany($this->getConfig('associationAlias'), [ 'className' => 'Muffin/Tokenize.Tokens', 'foreignKey' => 'foreign_key', 'conditions' => [ 'foreign_alias' => $this->_table->getAlias(), 'foreign_table' => $this->_table->getTable(), ], 'dependent' => true, ]); }
[ "public", "function", "initialize", "(", "array", "$", "config", ")", "{", "$", "this", "->", "verifyConfig", "(", ")", ";", "$", "this", "->", "_table", "->", "hasMany", "(", "$", "this", "->", "getConfig", "(", "'associationAlias'", ")", ",", "[", "'...
Verifies the configuration and associates the table to the `tokenize_tokens` table. @param array $config Config @return void
[ "Verifies", "the", "configuration", "and", "associates", "the", "table", "to", "the", "tokenize_tokens", "table", "." ]
a7ecf4114782abe12b0ab36e8a32504428fe91ec
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Behavior/TokenizeBehavior.php#L32-L45
train
UseMuffin/Tokenize
src/Model/Behavior/TokenizeBehavior.php
TokenizeBehavior.tokenize
public function tokenize($id, array $data = []) { $assoc = $this->getConfig('associationAlias'); $tokenData = [ 'foreign_alias' => $this->_table->getAlias(), 'foreign_table' => $this->_table->getTable(), 'foreign_key' => $id, 'foreign_data' => $data, ]; $tokenData = array_filter($tokenData); if (!isset($tokenData['foreign_data'])) { $tokenData['foreign_data'] = []; } $table = $this->_table->$assoc; $token = $table->newEntity($tokenData); if (!$table->save($token)) { throw new \RuntimeException(); } return $token; }
php
public function tokenize($id, array $data = []) { $assoc = $this->getConfig('associationAlias'); $tokenData = [ 'foreign_alias' => $this->_table->getAlias(), 'foreign_table' => $this->_table->getTable(), 'foreign_key' => $id, 'foreign_data' => $data, ]; $tokenData = array_filter($tokenData); if (!isset($tokenData['foreign_data'])) { $tokenData['foreign_data'] = []; } $table = $this->_table->$assoc; $token = $table->newEntity($tokenData); if (!$table->save($token)) { throw new \RuntimeException(); } return $token; }
[ "public", "function", "tokenize", "(", "$", "id", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "assoc", "=", "$", "this", "->", "getConfig", "(", "'associationAlias'", ")", ";", "$", "tokenData", "=", "[", "'foreign_alias'", "=>", "$", "t...
Creates a token for a data sample. @param int|string $id Id @param array $data Data @return mixed
[ "Creates", "a", "token", "for", "a", "data", "sample", "." ]
a7ecf4114782abe12b0ab36e8a32504428fe91ec
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Behavior/TokenizeBehavior.php#L96-L119
train
UseMuffin/Tokenize
src/Model/Behavior/TokenizeBehavior.php
TokenizeBehavior.fields
public function fields(EntityInterface $entity) { $fields = []; foreach ((array)$this->getConfig('fields') as $field) { if (!$entity->isDirty($field)) { continue; } $fields[$field] = $entity->$field; $entity->setDirty($field, false); } return $fields; }
php
public function fields(EntityInterface $entity) { $fields = []; foreach ((array)$this->getConfig('fields') as $field) { if (!$entity->isDirty($field)) { continue; } $fields[$field] = $entity->$field; $entity->setDirty($field, false); } return $fields; }
[ "public", "function", "fields", "(", "EntityInterface", "$", "entity", ")", "{", "$", "fields", "=", "[", "]", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "getConfig", "(", "'fields'", ")", "as", "$", "field", ")", "{", "if", "(", "!...
Returns fields that have been marked as protected. @param \Cake\Datasource\EntityInterface $entity Entity @return array
[ "Returns", "fields", "that", "have", "been", "marked", "as", "protected", "." ]
a7ecf4114782abe12b0ab36e8a32504428fe91ec
https://github.com/UseMuffin/Tokenize/blob/a7ecf4114782abe12b0ab36e8a32504428fe91ec/src/Model/Behavior/TokenizeBehavior.php#L127-L139
train
melisplatform/melis-core
src/Controller/DashboardController.php
DashboardController.leftmenuDashboardAction
public function leftmenuDashboardAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
php
public function leftmenuDashboardAction() { $melisKey = $this->params()->fromRoute('melisKey', ''); $view = new ViewModel(); $view->melisKey = $melisKey; return $view; }
[ "public", "function", "leftmenuDashboardAction", "(", ")", "{", "$", "melisKey", "=", "$", "this", "->", "params", "(", ")", "->", "fromRoute", "(", "'melisKey'", ",", "''", ")", ";", "$", "view", "=", "new", "ViewModel", "(", ")", ";", "$", "view", ...
Shows the leftmenu dasboard entry point @return \Zend\View\Model\ViewModel
[ "Shows", "the", "leftmenu", "dasboard", "entry", "point" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Controller/DashboardController.php#L28-L36
train
melisplatform/melis-core
src/Service/MelisCoreGeneralService.php
MelisCoreGeneralService.makeArrayFromParameters
public function makeArrayFromParameters($class_method, $parameterValues) { if (empty($class_method)) return array(); // Get the class name and the method name list($className, $methodName) = explode('::', $class_method); if (empty($className) || empty($methodName)) return array(); /** * Build an array from the parameters * Parameters' name will become keys * Values will be parameters' values or default values */ $parametersArray = array(); try { // Gets the data of class/method from Reflection object $reflectionMethod = new \ReflectionMethod($className, $methodName); $parameters = $reflectionMethod->getParameters(); // Loop on parameters foreach ($parameters as $keyParameter => $parameter) { // Check if we have a value given if (!empty($parameterValues[$keyParameter])) $parametersArray[$parameter->getName()] = $parameterValues[$keyParameter]; else // No value given, check if parameter has an optional value if ($parameter->isOptional()) $parametersArray[$parameter->getName()] = $parameter->getDefaultValue(); else // Else $parametersArray[$parameter->getName()] = null; } } catch (\Exception $e) { // Class or method were not found return array(); } return $parametersArray; }
php
public function makeArrayFromParameters($class_method, $parameterValues) { if (empty($class_method)) return array(); // Get the class name and the method name list($className, $methodName) = explode('::', $class_method); if (empty($className) || empty($methodName)) return array(); /** * Build an array from the parameters * Parameters' name will become keys * Values will be parameters' values or default values */ $parametersArray = array(); try { // Gets the data of class/method from Reflection object $reflectionMethod = new \ReflectionMethod($className, $methodName); $parameters = $reflectionMethod->getParameters(); // Loop on parameters foreach ($parameters as $keyParameter => $parameter) { // Check if we have a value given if (!empty($parameterValues[$keyParameter])) $parametersArray[$parameter->getName()] = $parameterValues[$keyParameter]; else // No value given, check if parameter has an optional value if ($parameter->isOptional()) $parametersArray[$parameter->getName()] = $parameter->getDefaultValue(); else // Else $parametersArray[$parameter->getName()] = null; } } catch (\Exception $e) { // Class or method were not found return array(); } return $parametersArray; }
[ "public", "function", "makeArrayFromParameters", "(", "$", "class_method", ",", "$", "parameterValues", ")", "{", "if", "(", "empty", "(", "$", "class_method", ")", ")", "return", "array", "(", ")", ";", "// Get the class name and the method name", "list", "(", ...
This method creates an array from the parameters, using parameters' name as keys and taking values or default values. It is used to prepare args for events listening. @param string $class_method @param mixed[] $parameterValues
[ "This", "method", "creates", "an", "array", "from", "the", "parameters", "using", "parameters", "name", "as", "keys", "and", "taking", "values", "or", "default", "values", ".", "It", "is", "used", "to", "prepare", "args", "for", "events", "listening", "." ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreGeneralService.php#L56-L100
train
melisplatform/melis-core
src/Service/MelisCoreGeneralService.php
MelisCoreGeneralService.splitData
public function splitData($prefix, $haystack = array()) { $data = array(); if($haystack) { foreach($haystack as $key => $value) { if(strpos($key, $prefix) !== false) { $data[$key] = $value; } } } return $data; }
php
public function splitData($prefix, $haystack = array()) { $data = array(); if($haystack) { foreach($haystack as $key => $value) { if(strpos($key, $prefix) !== false) { $data[$key] = $value; } } } return $data; }
[ "public", "function", "splitData", "(", "$", "prefix", ",", "$", "haystack", "=", "array", "(", ")", ")", "{", "$", "data", "=", "array", "(", ")", ";", "if", "(", "$", "haystack", ")", "{", "foreach", "(", "$", "haystack", "as", "$", "key", "=>"...
Used to split array data and return the data you need @param String $prefix of the array data @param array $haystack
[ "Used", "to", "split", "array", "data", "and", "return", "the", "data", "you", "need" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreGeneralService.php#L118-L134
train
melisplatform/melis-core
src/View/Helper/MelisGenericTable.php
MelisGenericTable.setColumns
public function setColumns($columnText, $css = null, $class = null) { $ctr = 0; $text = ''; $colCss = array(); $dataClass = ''; $thClass = ''; foreach($columnText as $values) { $text .= '<th '.$dataClass.' class="'.$class.'">' . $values . '</th>'; $ctr++; } $this->_columns .= $text; }
php
public function setColumns($columnText, $css = null, $class = null) { $ctr = 0; $text = ''; $colCss = array(); $dataClass = ''; $thClass = ''; foreach($columnText as $values) { $text .= '<th '.$dataClass.' class="'.$class.'">' . $values . '</th>'; $ctr++; } $this->_columns .= $text; }
[ "public", "function", "setColumns", "(", "$", "columnText", ",", "$", "css", "=", "null", ",", "$", "class", "=", "null", ")", "{", "$", "ctr", "=", "0", ";", "$", "text", "=", "''", ";", "$", "colCss", "=", "array", "(", ")", ";", "$", "dataCl...
Creates a configuration table column. @param Array $columnText @param Array $css @param String $class
[ "Creates", "a", "configuration", "table", "column", "." ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/View/Helper/MelisGenericTable.php#L52-L69
train
orchestral/kernel
src/Http/Providers/VersionServiceProvider.php
VersionServiceProvider.registerSupportedVersions
protected function registerSupportedVersions(VersionControl $version): void { foreach ($this->versions as $code => $namespace) { $version->addVersion($code, $namespace); } if (! is_null($this->defaultVersion)) { $version->setDefaultVersion($this->defaultVersion); } }
php
protected function registerSupportedVersions(VersionControl $version): void { foreach ($this->versions as $code => $namespace) { $version->addVersion($code, $namespace); } if (! is_null($this->defaultVersion)) { $version->setDefaultVersion($this->defaultVersion); } }
[ "protected", "function", "registerSupportedVersions", "(", "VersionControl", "$", "version", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "versions", "as", "$", "code", "=>", "$", "namespace", ")", "{", "$", "version", "->", "addVersion", "(", ...
Register supported version. @param \Orchestra\Http\VersionControl $version @return void
[ "Register", "supported", "version", "." ]
d4ebf0604e9aba6fe30813bc3446305157d93eb4
https://github.com/orchestral/kernel/blob/d4ebf0604e9aba6fe30813bc3446305157d93eb4/src/Http/Providers/VersionServiceProvider.php#L45-L54
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.addLostPassRequest
public function addLostPassRequest($login, $email) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $this->getPassRequestDataByLogin($email); $success = false; if(!$this->isDataExists($login)) { $table->save(array( 'rh_id' => null, 'rh_login' => $login, 'rh_email' => $email, 'rh_hash' => $this->generateHash(), 'rh_date' => date('Y-m-d H:i:s') )); // first email $success = $this->sendPasswordLostEmail($login, $email); } else { // resend email $table->update(array( 'rh_date' => date('Y-m-d H:i:s') ), 'rh_login', $login); $success = $this->sendPasswordLostEmail($login, $email); } return $success; }
php
public function addLostPassRequest($login, $email) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $this->getPassRequestDataByLogin($email); $success = false; if(!$this->isDataExists($login)) { $table->save(array( 'rh_id' => null, 'rh_login' => $login, 'rh_email' => $email, 'rh_hash' => $this->generateHash(), 'rh_date' => date('Y-m-d H:i:s') )); // first email $success = $this->sendPasswordLostEmail($login, $email); } else { // resend email $table->update(array( 'rh_date' => date('Y-m-d H:i:s') ), 'rh_login', $login); $success = $this->sendPasswordLostEmail($login, $email); } return $success; }
[ "public", "function", "addLostPassRequest", "(", "$", "login", ",", "$", "email", ")", "{", "$", "table", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisLostPasswordTable'", ")", ";", "$", "data", "=", "$", "this", "->", ...
Adds new record for lost password request @param String $url @param String $login @param String $email
[ "Adds", "new", "record", "for", "lost", "password", "request" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L32-L58
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.processUpdatePassword
public function processUpdatePassword($hash, $password) { $data = $this->getPasswordRequestData($hash); $login = ''; $success = false; foreach($data as $val) { $login = $val->rh_login; } if($this->isDataExists($login)) { $success = $this->updatePassword($login, $password); if($success) $this->deletePasswordRequestData($hash); } return $success; }
php
public function processUpdatePassword($hash, $password) { $data = $this->getPasswordRequestData($hash); $login = ''; $success = false; foreach($data as $val) { $login = $val->rh_login; } if($this->isDataExists($login)) { $success = $this->updatePassword($login, $password); if($success) $this->deletePasswordRequestData($hash); } return $success; }
[ "public", "function", "processUpdatePassword", "(", "$", "hash", ",", "$", "password", ")", "{", "$", "data", "=", "$", "this", "->", "getPasswordRequestData", "(", "$", "hash", ")", ";", "$", "login", "=", "''", ";", "$", "success", "=", "false", ";",...
Processes the password reset and deletes the existing record in the lost password table @param String $hash @param String $password @return boolean
[ "Processes", "the", "password", "reset", "and", "deletes", "the", "existing", "record", "in", "the", "lost", "password", "table" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L66-L85
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.userExists
public function userExists($login) { $userTable = $this->getServiceLocator()->get('MelisCoreTableUser'); $data = $userTable->getEntryByField('usr_login', $login); $user = ''; foreach($data as $val) { $user = $val->usr_login; } if(!empty($user)) { return true; } else { return false; } }
php
public function userExists($login) { $userTable = $this->getServiceLocator()->get('MelisCoreTableUser'); $data = $userTable->getEntryByField('usr_login', $login); $user = ''; foreach($data as $val) { $user = $val->usr_login; } if(!empty($user)) { return true; } else { return false; } }
[ "public", "function", "userExists", "(", "$", "login", ")", "{", "$", "userTable", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreTableUser'", ")", ";", "$", "data", "=", "$", "userTable", "->", "getEntryByField", "(", ...
Checks if the user exists @param String $login @return boolean
[ "Checks", "if", "the", "user", "exists" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L92-L110
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.hashExists
public function hashExists($hash) { $data = $this->getPasswordRequestData($hash); $h = ''; foreach($data as $val) { $h = $val->rh_login; //echo $h; } if(!empty($h)) { return true; } return false; }
php
public function hashExists($hash) { $data = $this->getPasswordRequestData($hash); $h = ''; foreach($data as $val) { $h = $val->rh_login; //echo $h; } if(!empty($h)) { return true; } return false; }
[ "public", "function", "hashExists", "(", "$", "hash", ")", "{", "$", "data", "=", "$", "this", "->", "getPasswordRequestData", "(", "$", "hash", ")", ";", "$", "h", "=", "''", ";", "foreach", "(", "$", "data", "as", "$", "val", ")", "{", "$", "h"...
Check if the provided hash exists @param String $hash @return boolean
[ "Check", "if", "the", "provided", "hash", "exists" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L117-L132
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.isDataExists
public function isDataExists($login) { $data = $this->getPassRequestDataByLogin($login); $login = ''; foreach($data as $val) { $login = $val->rh_login; } if(!empty($login)) { return true; } return false; }
php
public function isDataExists($login) { $data = $this->getPassRequestDataByLogin($login); $login = ''; foreach($data as $val) { $login = $val->rh_login; } if(!empty($login)) { return true; } return false; }
[ "public", "function", "isDataExists", "(", "$", "login", ")", "{", "$", "data", "=", "$", "this", "->", "getPassRequestDataByLogin", "(", "$", "login", ")", ";", "$", "login", "=", "''", ";", "foreach", "(", "$", "data", "as", "$", "val", ")", "{", ...
Checks if the username exists in the lost password table @param String $login @return boolean
[ "Checks", "if", "the", "username", "exists", "in", "the", "lost", "password", "table" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L139-L153
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.getPassRequestDataByLogin
public function getPassRequestDataByLogin($login) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $table->getEntryByField('rh_login', $login); if($data) return $data; }
php
public function getPassRequestDataByLogin($login) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $table->getEntryByField('rh_login', $login); if($data) return $data; }
[ "public", "function", "getPassRequestDataByLogin", "(", "$", "login", ")", "{", "$", "table", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisLostPasswordTable'", ")", ";", "$", "data", "=", "$", "table", "->", "getEntryByFiel...
Returns the data of the provided username @param String $login @return boolean
[ "Returns", "the", "data", "of", "the", "provided", "username" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L160-L167
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.getPasswordRequestData
public function getPasswordRequestData($hash) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $table->getEntryByField('rh_hash', $hash); if($data) return $data; }
php
public function getPasswordRequestData($hash) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $table->getEntryByField('rh_hash', $hash); if($data) return $data; }
[ "public", "function", "getPasswordRequestData", "(", "$", "hash", ")", "{", "$", "table", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisLostPasswordTable'", ")", ";", "$", "data", "=", "$", "table", "->", "getEntryByField", ...
Returns the data of the provided hash @param String $login @return boolean
[ "Returns", "the", "data", "of", "the", "provided", "hash" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L174-L181
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.updatePassword
protected function updatePassword($login, $newPass) { $success = false; $userTable = $this->getServiceLocator()->get('MelisCoreTableUser'); $melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth'); if($this->isDataExists($login)) { $userTable->update(array( 'usr_password' => $melisCoreAuth->encryptPassword($newPass) ),'usr_login', $login); $success = true; } return $success; }
php
protected function updatePassword($login, $newPass) { $success = false; $userTable = $this->getServiceLocator()->get('MelisCoreTableUser'); $melisCoreAuth = $this->serviceLocator->get('MelisCoreAuth'); if($this->isDataExists($login)) { $userTable->update(array( 'usr_password' => $melisCoreAuth->encryptPassword($newPass) ),'usr_login', $login); $success = true; } return $success; }
[ "protected", "function", "updatePassword", "(", "$", "login", ",", "$", "newPass", ")", "{", "$", "success", "=", "false", ";", "$", "userTable", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisCoreTableUser'", ")", ";", "...
Updates the user's password @param String $login @param String $newPass
[ "Updates", "the", "user", "s", "password" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L188-L204
train
melisplatform/melis-core
src/Service/MelisCoreLostPasswordService.php
MelisCoreLostPasswordService.deletePasswordRequestData
protected function deletePasswordRequestData($hash) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $this->getPasswordRequestData($hash); if($data) $table->deleteByField('rh_hash', $hash); }
php
protected function deletePasswordRequestData($hash) { $table = $this->getServiceLocator()->get('MelisLostPasswordTable'); $data = $this->getPasswordRequestData($hash); if($data) $table->deleteByField('rh_hash', $hash); }
[ "protected", "function", "deletePasswordRequestData", "(", "$", "hash", ")", "{", "$", "table", "=", "$", "this", "->", "getServiceLocator", "(", ")", "->", "get", "(", "'MelisLostPasswordTable'", ")", ";", "$", "data", "=", "$", "this", "->", "getPasswordRe...
Deletes a specific record in the lost password table @param unknown $hash
[ "Deletes", "a", "specific", "record", "in", "the", "lost", "password", "table" ]
f8b0648930e21d1f2b2e5b9300781c335bd34ea4
https://github.com/melisplatform/melis-core/blob/f8b0648930e21d1f2b2e5b9300781c335bd34ea4/src/Service/MelisCoreLostPasswordService.php#L210-L217
train