repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.createQueue
public function createQueue($queueName) { $queueDir = $this->getQueueDirectory($queueName); if (is_dir($queueDir)) { return; } mkdir($queueDir, 0755, true); }
php
public function createQueue($queueName) { $queueDir = $this->getQueueDirectory($queueName); if (is_dir($queueDir)) { return; } mkdir($queueDir, 0755, true); }
[ "public", "function", "createQueue", "(", "$", "queueName", ")", "{", "$", "queueDir", "=", "$", "this", "->", "getQueueDirectory", "(", "$", "queueName", ")", ";", "if", "(", "is_dir", "(", "$", "queueDir", ")", ")", "{", "return", ";", "}", "mkdir", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L50-L59
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.countMessages
public function countMessages($queueName) { $iterator = new \RecursiveDirectoryIterator( $this->getQueueDirectory($queueName), \FilesystemIterator::SKIP_DOTS ); $iterator = new \RecursiveIteratorIterator($iterator); $iterator = new \RegexIterator($iterator, '#\.job$#'); return iterator_count($iterator); }
php
public function countMessages($queueName) { $iterator = new \RecursiveDirectoryIterator( $this->getQueueDirectory($queueName), \FilesystemIterator::SKIP_DOTS ); $iterator = new \RecursiveIteratorIterator($iterator); $iterator = new \RegexIterator($iterator, '#\.job$#'); return iterator_count($iterator); }
[ "public", "function", "countMessages", "(", "$", "queueName", ")", "{", "$", "iterator", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "this", "->", "getQueueDirectory", "(", "$", "queueName", ")", ",", "\\", "FilesystemIterator", "::", "SKIP_DOTS", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L64-L74
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.pushMessage
public function pushMessage($queueName, $message) { $queueDir = $this->getQueueDirectory($queueName); $filename = $this->getJobFilename($queueName); file_put_contents($queueDir.DIRECTORY_SEPARATOR.$filename, $message); chmod($queueDir.DIRECTORY_SEPARATOR.$filename, $this->permissions); }
php
public function pushMessage($queueName, $message) { $queueDir = $this->getQueueDirectory($queueName); $filename = $this->getJobFilename($queueName); file_put_contents($queueDir.DIRECTORY_SEPARATOR.$filename, $message); chmod($queueDir.DIRECTORY_SEPARATOR.$filename, $this->permissions); }
[ "public", "function", "pushMessage", "(", "$", "queueName", ",", "$", "message", ")", "{", "$", "queueDir", "=", "$", "this", "->", "getQueueDirectory", "(", "$", "queueName", ")", ";", "$", "filename", "=", "$", "this", "->", "getJobFilename", "(", "$",...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L79-L87
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.popMessage
public function popMessage($queueName, $duration = 5) { $runtime = microtime(true) + $duration; $queueDir = $this->getQueueDirectory($queueName); $it = new \GlobIterator($queueDir.DIRECTORY_SEPARATOR.'*.job', \FilesystemIterator::KEY_AS_FILENAME); $files = array_keys(iterator_to_array($it)); natsort($files); while (microtime(true) < $runtime) { if ($files) { $id = array_pop($files); if (@rename($queueDir.DIRECTORY_SEPARATOR.$id, $queueDir.DIRECTORY_SEPARATOR.$id.'.proceed')) { return [file_get_contents($queueDir.DIRECTORY_SEPARATOR.$id.'.proceed'), $id]; } return $this->processFileOrFail($queueDir, $id); } usleep(1000); } return [null, null]; }
php
public function popMessage($queueName, $duration = 5) { $runtime = microtime(true) + $duration; $queueDir = $this->getQueueDirectory($queueName); $it = new \GlobIterator($queueDir.DIRECTORY_SEPARATOR.'*.job', \FilesystemIterator::KEY_AS_FILENAME); $files = array_keys(iterator_to_array($it)); natsort($files); while (microtime(true) < $runtime) { if ($files) { $id = array_pop($files); if (@rename($queueDir.DIRECTORY_SEPARATOR.$id, $queueDir.DIRECTORY_SEPARATOR.$id.'.proceed')) { return [file_get_contents($queueDir.DIRECTORY_SEPARATOR.$id.'.proceed'), $id]; } return $this->processFileOrFail($queueDir, $id); } usleep(1000); } return [null, null]; }
[ "public", "function", "popMessage", "(", "$", "queueName", ",", "$", "duration", "=", "5", ")", "{", "$", "runtime", "=", "microtime", "(", "true", ")", "+", "$", "duration", ";", "$", "queueDir", "=", "$", "this", "->", "getQueueDirectory", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L92-L116
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.processFileOrFail
private function processFileOrFail($queueDir, $id) { $name = $queueDir.DIRECTORY_SEPARATOR.$id; $newName = $name.'.proceed'; if (!@rename($name, $newName)) { throw new InsufficientPermissionsException('Unable to process file: '.$name); } return [file_get_contents($newName), $id]; }
php
private function processFileOrFail($queueDir, $id) { $name = $queueDir.DIRECTORY_SEPARATOR.$id; $newName = $name.'.proceed'; if (!@rename($name, $newName)) { throw new InsufficientPermissionsException('Unable to process file: '.$name); } return [file_get_contents($newName), $id]; }
[ "private", "function", "processFileOrFail", "(", "$", "queueDir", ",", "$", "id", ")", "{", "$", "name", "=", "$", "queueDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "id", ";", "$", "newName", "=", "$", "name", ".", "'.proceed'", ";", "if", "(", "!", ...
@param string $queueDir @param string $id @return array
[ "@param", "string", "$queueDir", "@param", "string", "$id" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L124-L133
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.acknowledgeMessage
public function acknowledgeMessage($queueName, $receipt) { $queueDir = $this->getQueueDirectory($queueName); $path = $queueDir.DIRECTORY_SEPARATOR.$receipt.'.proceed'; if (!is_file($path)) { return; } unlink($path); }
php
public function acknowledgeMessage($queueName, $receipt) { $queueDir = $this->getQueueDirectory($queueName); $path = $queueDir.DIRECTORY_SEPARATOR.$receipt.'.proceed'; if (!is_file($path)) { return; } unlink($path); }
[ "public", "function", "acknowledgeMessage", "(", "$", "queueName", ",", "$", "receipt", ")", "{", "$", "queueDir", "=", "$", "this", "->", "getQueueDirectory", "(", "$", "queueName", ")", ";", "$", "path", "=", "$", "queueDir", ".", "DIRECTORY_SEPARATOR", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L138-L148
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.peekQueue
public function peekQueue($queueName, $index = 0, $limit = 20) { $queueDir = $this->getQueueDirectory($queueName); $it = new \GlobIterator($queueDir.DIRECTORY_SEPARATOR.'*.job', \FilesystemIterator::KEY_AS_FILENAME); $files = array_keys(iterator_to_array($it)); natsort($files); $files = array_reverse($files); $files = array_slice($files, $index, $limit); $messages = []; foreach ($files as $file) { array_push($messages, file_get_contents($queueDir.DIRECTORY_SEPARATOR.$file)); } return $messages; }
php
public function peekQueue($queueName, $index = 0, $limit = 20) { $queueDir = $this->getQueueDirectory($queueName); $it = new \GlobIterator($queueDir.DIRECTORY_SEPARATOR.'*.job', \FilesystemIterator::KEY_AS_FILENAME); $files = array_keys(iterator_to_array($it)); natsort($files); $files = array_reverse($files); $files = array_slice($files, $index, $limit); $messages = []; foreach ($files as $file) { array_push($messages, file_get_contents($queueDir.DIRECTORY_SEPARATOR.$file)); } return $messages; }
[ "public", "function", "peekQueue", "(", "$", "queueName", ",", "$", "index", "=", "0", ",", "$", "limit", "=", "20", ")", "{", "$", "queueDir", "=", "$", "this", "->", "getQueueDirectory", "(", "$", "queueName", ")", ";", "$", "it", "=", "new", "\\...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L153-L172
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.removeQueue
public function removeQueue($queueName) { $iterator = new \RecursiveDirectoryIterator( $this->getQueueDirectory($queueName), \FilesystemIterator::SKIP_DOTS ); $iterator = new \RecursiveIteratorIterator($iterator); $iterator = new \RegexIterator($iterator, '#\.job(.proceed)?$#'); foreach ($iterator as $file) { /* @var $file \DirectoryIterator */ unlink($file->getRealPath()); } rmdir($this->getQueueDirectory($queueName)); }
php
public function removeQueue($queueName) { $iterator = new \RecursiveDirectoryIterator( $this->getQueueDirectory($queueName), \FilesystemIterator::SKIP_DOTS ); $iterator = new \RecursiveIteratorIterator($iterator); $iterator = new \RegexIterator($iterator, '#\.job(.proceed)?$#'); foreach ($iterator as $file) { /* @var $file \DirectoryIterator */ unlink($file->getRealPath()); } rmdir($this->getQueueDirectory($queueName)); }
[ "public", "function", "removeQueue", "(", "$", "queueName", ")", "{", "$", "iterator", "=", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "this", "->", "getQueueDirectory", "(", "$", "queueName", ")", ",", "\\", "FilesystemIterator", "::", "SKIP_DOTS", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L177-L192
bernardphp/bernard
src/Driver/FlatFile/Driver.php
Driver.getJobFilename
private function getJobFilename($queueName) { $path = $this->baseDirectory.'/bernard.meta'; if (!is_file($path)) { touch($path); chmod($path, $this->permissions); } $file = new \SplFileObject($path, 'r+'); $file->flock(LOCK_EX); $meta = unserialize($file->fgets()); $id = isset($meta[$queueName]) ? $meta[$queueName] : 0; ++$id; $filename = sprintf('%d.job', $id); $meta[$queueName] = $id; $content = serialize($meta); $file->fseek(0); $file->fwrite($content, strlen($content)); $file->flock(LOCK_UN); return $filename; }
php
private function getJobFilename($queueName) { $path = $this->baseDirectory.'/bernard.meta'; if (!is_file($path)) { touch($path); chmod($path, $this->permissions); } $file = new \SplFileObject($path, 'r+'); $file->flock(LOCK_EX); $meta = unserialize($file->fgets()); $id = isset($meta[$queueName]) ? $meta[$queueName] : 0; ++$id; $filename = sprintf('%d.job', $id); $meta[$queueName] = $id; $content = serialize($meta); $file->fseek(0); $file->fwrite($content, strlen($content)); $file->flock(LOCK_UN); return $filename; }
[ "private", "function", "getJobFilename", "(", "$", "queueName", ")", "{", "$", "path", "=", "$", "this", "->", "baseDirectory", ".", "'/bernard.meta'", ";", "if", "(", "!", "is_file", "(", "$", "path", ")", ")", "{", "touch", "(", "$", "path", ")", "...
Generates a uuid. @param string $queueName @return string
[ "Generates", "a", "uuid", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/FlatFile/Driver.php#L219-L246
bernardphp/bernard
src/QueueFactory/InMemoryFactory.php
InMemoryFactory.create
public function create($queueName) { if (!$this->exists($queueName)) { $this->queues[$queueName] = new InMemoryQueue($queueName); } return $this->queues[$queueName]; }
php
public function create($queueName) { if (!$this->exists($queueName)) { $this->queues[$queueName] = new InMemoryQueue($queueName); } return $this->queues[$queueName]; }
[ "public", "function", "create", "(", "$", "queueName", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "queueName", ")", ")", "{", "$", "this", "->", "queues", "[", "$", "queueName", "]", "=", "new", "InMemoryQueue", "(", "$", "que...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/QueueFactory/InMemoryFactory.php#L18-L25
bernardphp/bernard
src/QueueFactory/InMemoryFactory.php
InMemoryFactory.remove
public function remove($queueName) { if ($this->exists($queueName)) { $this->queues[$queueName]->close(); unset($this->queues[$queueName]); } }
php
public function remove($queueName) { if ($this->exists($queueName)) { $this->queues[$queueName]->close(); unset($this->queues[$queueName]); } }
[ "public", "function", "remove", "(", "$", "queueName", ")", "{", "if", "(", "$", "this", "->", "exists", "(", "$", "queueName", ")", ")", "{", "$", "this", "->", "queues", "[", "$", "queueName", "]", "->", "close", "(", ")", ";", "unset", "(", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/QueueFactory/InMemoryFactory.php#L54-L61
bernardphp/bernard
src/Driver/IronMQ/Driver.php
Driver.listQueues
public function listQueues() { $queueNames = []; $page = 0; while ($queues = $this->ironmq->getQueues($page, 100)) { $queueNames += $this->pluck($queues, 'name'); // If we get 100 results the probability of another page is high. if (count($queues) < 100) { break; } ++$page; } return $queueNames; }
php
public function listQueues() { $queueNames = []; $page = 0; while ($queues = $this->ironmq->getQueues($page, 100)) { $queueNames += $this->pluck($queues, 'name'); // If we get 100 results the probability of another page is high. if (count($queues) < 100) { break; } ++$page; } return $queueNames; }
[ "public", "function", "listQueues", "(", ")", "{", "$", "queueNames", "=", "[", "]", ";", "$", "page", "=", "0", ";", "while", "(", "$", "queues", "=", "$", "this", "->", "ironmq", "->", "getQueues", "(", "$", "page", ",", "100", ")", ")", "{", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/IronMQ/Driver.php#L30-L47
bernardphp/bernard
src/Driver/IronMQ/Driver.php
Driver.popMessage
public function popMessage($queueName, $duration = 5) { if ($message = $this->cache->pop($queueName)) { return $message; } $timeout = IronMQ::GET_MESSAGE_TIMEOUT; $messages = $this->ironmq->getMessages($queueName, $this->prefetch, $timeout, $duration); if (!$messages) { return [null, null]; } foreach ($messages as $message) { $this->cache->push($queueName, [$message->body, $message->id]); } return $this->cache->pop($queueName); }
php
public function popMessage($queueName, $duration = 5) { if ($message = $this->cache->pop($queueName)) { return $message; } $timeout = IronMQ::GET_MESSAGE_TIMEOUT; $messages = $this->ironmq->getMessages($queueName, $this->prefetch, $timeout, $duration); if (!$messages) { return [null, null]; } foreach ($messages as $message) { $this->cache->push($queueName, [$message->body, $message->id]); } return $this->cache->pop($queueName); }
[ "public", "function", "popMessage", "(", "$", "queueName", ",", "$", "duration", "=", "5", ")", "{", "if", "(", "$", "message", "=", "$", "this", "->", "cache", "->", "pop", "(", "$", "queueName", ")", ")", "{", "return", "$", "message", ";", "}", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/IronMQ/Driver.php#L77-L96
bernardphp/bernard
src/Driver/IronMQ/Driver.php
Driver.peekQueue
public function peekQueue($queueName, $index = 0, $limit = 20) { if ($messages = $this->ironmq->peekMessages($queueName, $limit)) { return $this->pluck($messages, 'body'); } return []; }
php
public function peekQueue($queueName, $index = 0, $limit = 20) { if ($messages = $this->ironmq->peekMessages($queueName, $limit)) { return $this->pluck($messages, 'body'); } return []; }
[ "public", "function", "peekQueue", "(", "$", "queueName", ",", "$", "index", "=", "0", ",", "$", "limit", "=", "20", ")", "{", "if", "(", "$", "messages", "=", "$", "this", "->", "ironmq", "->", "peekMessages", "(", "$", "queueName", ",", "$", "lim...
IronMQ does not support an offset when peeking messages. {@inheritdoc}
[ "IronMQ", "does", "not", "support", "an", "offset", "when", "peeking", "messages", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/IronMQ/Driver.php#L111-L118
bernardphp/bernard
src/Driver/Interop/Driver.php
Driver.createQueue
public function createQueue($queueName) { if ($this->context instanceof AmqpContext) { $this->context->declareQueue($this->createAmqpQueue($queueName)); } }
php
public function createQueue($queueName) { if ($this->context instanceof AmqpContext) { $this->context->declareQueue($this->createAmqpQueue($queueName)); } }
[ "public", "function", "createQueue", "(", "$", "queueName", ")", "{", "if", "(", "$", "this", "->", "context", "instanceof", "AmqpContext", ")", "{", "$", "this", "->", "context", "->", "declareQueue", "(", "$", "this", "->", "createAmqpQueue", "(", "$", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Interop/Driver.php#L43-L48
bernardphp/bernard
src/Driver/Interop/Driver.php
Driver.countMessages
public function countMessages($queueName) { if ($this->context instanceof AmqpContext) { return $this->context->declareQueue($this->createAmqpQueue($queueName)); } return 0; }
php
public function countMessages($queueName) { if ($this->context instanceof AmqpContext) { return $this->context->declareQueue($this->createAmqpQueue($queueName)); } return 0; }
[ "public", "function", "countMessages", "(", "$", "queueName", ")", "{", "if", "(", "$", "this", "->", "context", "instanceof", "AmqpContext", ")", "{", "return", "$", "this", "->", "context", "->", "declareQueue", "(", "$", "this", "->", "createAmqpQueue", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Interop/Driver.php#L53-L60
bernardphp/bernard
src/Driver/Interop/Driver.php
Driver.pushMessage
public function pushMessage($queueName, $message) { $queue = $this->context->createQueue($queueName); $message = $this->context->createMessage($message); $this->context->createProducer()->send($queue, $message); }
php
public function pushMessage($queueName, $message) { $queue = $this->context->createQueue($queueName); $message = $this->context->createMessage($message); $this->context->createProducer()->send($queue, $message); }
[ "public", "function", "pushMessage", "(", "$", "queueName", ",", "$", "message", ")", "{", "$", "queue", "=", "$", "this", "->", "context", "->", "createQueue", "(", "$", "queueName", ")", ";", "$", "message", "=", "$", "this", "->", "context", "->", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Interop/Driver.php#L65-L71
bernardphp/bernard
src/Driver/Interop/Driver.php
Driver.popMessage
public function popMessage($queueName, $duration = 5) { if ($message = $this->getQueueConsumer($queueName)->receive($duration * 1000)) { return [$message->getBody(), $message]; } }
php
public function popMessage($queueName, $duration = 5) { if ($message = $this->getQueueConsumer($queueName)->receive($duration * 1000)) { return [$message->getBody(), $message]; } }
[ "public", "function", "popMessage", "(", "$", "queueName", ",", "$", "duration", "=", "5", ")", "{", "if", "(", "$", "message", "=", "$", "this", "->", "getQueueConsumer", "(", "$", "queueName", ")", "->", "receive", "(", "$", "duration", "*", "1000", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Interop/Driver.php#L76-L81
bernardphp/bernard
src/Driver/Interop/Driver.php
Driver.removeQueue
public function removeQueue($queueName) { if ($this->context instanceof AmqpContext) { $queue = $this->createAmqpQueue($queueName); $this->context->deleteQueue($queue); } }
php
public function removeQueue($queueName) { if ($this->context instanceof AmqpContext) { $queue = $this->createAmqpQueue($queueName); $this->context->deleteQueue($queue); } }
[ "public", "function", "removeQueue", "(", "$", "queueName", ")", "{", "if", "(", "$", "this", "->", "context", "instanceof", "AmqpContext", ")", "{", "$", "queue", "=", "$", "this", "->", "createAmqpQueue", "(", "$", "queueName", ")", ";", "$", "this", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Interop/Driver.php#L102-L109
bernardphp/bernard
src/Driver/Interop/Driver.php
Driver.getQueueConsumer
private function getQueueConsumer($queueName) { if (false == array_key_exists($queueName, $this->consumers)) { $queue = $this->context->createQueue($queueName); $this->consumers[$queueName] = $this->context->createConsumer($queue); } return $this->consumers[$queueName]; }
php
private function getQueueConsumer($queueName) { if (false == array_key_exists($queueName, $this->consumers)) { $queue = $this->context->createQueue($queueName); $this->consumers[$queueName] = $this->context->createConsumer($queue); } return $this->consumers[$queueName]; }
[ "private", "function", "getQueueConsumer", "(", "$", "queueName", ")", "{", "if", "(", "false", "==", "array_key_exists", "(", "$", "queueName", ",", "$", "this", "->", "consumers", ")", ")", "{", "$", "queue", "=", "$", "this", "->", "context", "->", ...
@param string $queueName @return PsrConsumer
[ "@param", "string", "$queueName" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Interop/Driver.php#L124-L133
bernardphp/bernard
src/Driver/Interop/Driver.php
Driver.createAmqpQueue
private function createAmqpQueue($queueName) { /** @var AmqpContext $context */ $context = $this->context; $queue = $context->createQueue($queueName); $queue->addFlag(AmqpQueue::FLAG_DURABLE); return $queue; }
php
private function createAmqpQueue($queueName) { /** @var AmqpContext $context */ $context = $this->context; $queue = $context->createQueue($queueName); $queue->addFlag(AmqpQueue::FLAG_DURABLE); return $queue; }
[ "private", "function", "createAmqpQueue", "(", "$", "queueName", ")", "{", "/** @var AmqpContext $context */", "$", "context", "=", "$", "this", "->", "context", ";", "$", "queue", "=", "$", "context", "->", "createQueue", "(", "$", "queueName", ")", ";", "$...
@param string $queueName @return AmqpQueue
[ "@param", "string", "$queueName" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Interop/Driver.php#L140-L149
bernardphp/bernard
src/Driver/Doctrine/Driver.php
Driver.listQueues
public function listQueues() { $statement = $this->connection->prepare('SELECT name FROM bernard_queues'); $statement->execute(); return $statement->fetchAll(\PDO::FETCH_COLUMN); }
php
public function listQueues() { $statement = $this->connection->prepare('SELECT name FROM bernard_queues'); $statement->execute(); return $statement->fetchAll(\PDO::FETCH_COLUMN); }
[ "public", "function", "listQueues", "(", ")", "{", "$", "statement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "'SELECT name FROM bernard_queues'", ")", ";", "$", "statement", "->", "execute", "(", ")", ";", "return", "$", "statement", "->"...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/Driver.php#L25-L31
bernardphp/bernard
src/Driver/Doctrine/Driver.php
Driver.countMessages
public function countMessages($queueName) { $query = 'SELECT COUNT(id) FROM bernard_messages WHERE queue = :queue AND visible = :visible'; return (int) $this->connection->fetchColumn($query, [ 'queue' => $queueName, 'visible' => true, ]); }
php
public function countMessages($queueName) { $query = 'SELECT COUNT(id) FROM bernard_messages WHERE queue = :queue AND visible = :visible'; return (int) $this->connection->fetchColumn($query, [ 'queue' => $queueName, 'visible' => true, ]); }
[ "public", "function", "countMessages", "(", "$", "queueName", ")", "{", "$", "query", "=", "'SELECT COUNT(id) FROM bernard_messages WHERE queue = :queue AND visible = :visible'", ";", "return", "(", "int", ")", "$", "this", "->", "connection", "->", "fetchColumn", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/Driver.php#L49-L57
bernardphp/bernard
src/Driver/Doctrine/Driver.php
Driver.pushMessage
public function pushMessage($queueName, $message) { $types = ['string', 'string', 'datetime']; $data = [ 'queue' => $queueName, 'message' => $message, 'sentAt' => new \DateTime(), ]; $this->createQueue($queueName); $this->connection->insert('bernard_messages', $data, $types); }
php
public function pushMessage($queueName, $message) { $types = ['string', 'string', 'datetime']; $data = [ 'queue' => $queueName, 'message' => $message, 'sentAt' => new \DateTime(), ]; $this->createQueue($queueName); $this->connection->insert('bernard_messages', $data, $types); }
[ "public", "function", "pushMessage", "(", "$", "queueName", ",", "$", "message", ")", "{", "$", "types", "=", "[", "'string'", ",", "'string'", ",", "'datetime'", "]", ";", "$", "data", "=", "[", "'queue'", "=>", "$", "queueName", ",", "'message'", "=>...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/Driver.php#L62-L73
bernardphp/bernard
src/Driver/Doctrine/Driver.php
Driver.popMessage
public function popMessage($queueName, $duration = 5) { $runtime = microtime(true) + $duration; while (microtime(true) < $runtime) { $this->connection->beginTransaction(); try { $message = $this->doPopMessage($queueName); $this->connection->commit(); } catch (\Exception $e) { $this->connection->rollback(); } if (isset($message)) { return $message; } //sleep for 10 ms usleep(10000); } }
php
public function popMessage($queueName, $duration = 5) { $runtime = microtime(true) + $duration; while (microtime(true) < $runtime) { $this->connection->beginTransaction(); try { $message = $this->doPopMessage($queueName); $this->connection->commit(); } catch (\Exception $e) { $this->connection->rollback(); } if (isset($message)) { return $message; } //sleep for 10 ms usleep(10000); } }
[ "public", "function", "popMessage", "(", "$", "queueName", ",", "$", "duration", "=", "5", ")", "{", "$", "runtime", "=", "microtime", "(", "true", ")", "+", "$", "duration", ";", "while", "(", "microtime", "(", "true", ")", "<", "$", "runtime", ")",...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/Driver.php#L78-L100
bernardphp/bernard
src/Driver/Doctrine/Driver.php
Driver.peekQueue
public function peekQueue($queueName, $index = 0, $limit = 20) { $parameters = [$queueName, true, $limit, $index]; $types = ['string', 'boolean', 'integer', 'integer']; $query = 'SELECT message FROM bernard_messages WHERE queue = ? AND visible = ? ORDER BY sentAt LIMIT ? OFFSET ?'; return $this ->connection ->executeQuery($query, $parameters, $types) ->fetchAll(\PDO::FETCH_COLUMN) ; }
php
public function peekQueue($queueName, $index = 0, $limit = 20) { $parameters = [$queueName, true, $limit, $index]; $types = ['string', 'boolean', 'integer', 'integer']; $query = 'SELECT message FROM bernard_messages WHERE queue = ? AND visible = ? ORDER BY sentAt LIMIT ? OFFSET ?'; return $this ->connection ->executeQuery($query, $parameters, $types) ->fetchAll(\PDO::FETCH_COLUMN) ; }
[ "public", "function", "peekQueue", "(", "$", "queueName", ",", "$", "index", "=", "0", ",", "$", "limit", "=", "20", ")", "{", "$", "parameters", "=", "[", "$", "queueName", ",", "true", ",", "$", "limit", ",", "$", "index", "]", ";", "$", "types...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/Driver.php#L113-L125
bernardphp/bernard
src/Driver/Doctrine/Driver.php
Driver.removeQueue
public function removeQueue($queueName) { $this->connection->delete('bernard_messages', ['queue' => $queueName]); $this->connection->delete('bernard_queues', ['name' => $queueName]); }
php
public function removeQueue($queueName) { $this->connection->delete('bernard_messages', ['queue' => $queueName]); $this->connection->delete('bernard_queues', ['name' => $queueName]); }
[ "public", "function", "removeQueue", "(", "$", "queueName", ")", "{", "$", "this", "->", "connection", "->", "delete", "(", "'bernard_messages'", ",", "[", "'queue'", "=>", "$", "queueName", "]", ")", ";", "$", "this", "->", "connection", "->", "delete", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/Driver.php#L130-L134
bernardphp/bernard
src/Driver/Doctrine/Driver.php
Driver.doPopMessage
private function doPopMessage($queueName) { $query = 'SELECT id, message FROM bernard_messages WHERE queue = :queue AND visible = :visible ORDER BY sentAt LIMIT 1 '.$this->connection->getDatabasePlatform()->getForUpdateSql(); list($id, $message) = $this->connection->fetchArray($query, [ 'queue' => $queueName, 'visible' => true, ]); if ($id) { $this->connection->update('bernard_messages', ['visible' => 0], compact('id')); return [$message, $id]; } }
php
private function doPopMessage($queueName) { $query = 'SELECT id, message FROM bernard_messages WHERE queue = :queue AND visible = :visible ORDER BY sentAt LIMIT 1 '.$this->connection->getDatabasePlatform()->getForUpdateSql(); list($id, $message) = $this->connection->fetchArray($query, [ 'queue' => $queueName, 'visible' => true, ]); if ($id) { $this->connection->update('bernard_messages', ['visible' => 0], compact('id')); return [$message, $id]; } }
[ "private", "function", "doPopMessage", "(", "$", "queueName", ")", "{", "$", "query", "=", "'SELECT id, message FROM bernard_messages\n WHERE queue = :queue AND visible = :visible\n ORDER BY sentAt LIMIT 1 '", ".", "$", "this", "->", "connection", ...
Execute the actual query and process the response. @param string $queueName @return array|null
[ "Execute", "the", "actual", "query", "and", "process", "the", "response", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/Driver.php#L155-L171
bernardphp/bernard
src/Driver/Doctrine/MessagesSchema.php
MessagesSchema.createQueueTable
protected static function createQueueTable(Schema $schema) { $table = $schema->createTable('bernard_queues'); $table->addColumn('name', 'string'); $table->setPrimaryKey(['name']); }
php
protected static function createQueueTable(Schema $schema) { $table = $schema->createTable('bernard_queues'); $table->addColumn('name', 'string'); $table->setPrimaryKey(['name']); }
[ "protected", "static", "function", "createQueueTable", "(", "Schema", "$", "schema", ")", "{", "$", "table", "=", "$", "schema", "->", "createTable", "(", "'bernard_queues'", ")", ";", "$", "table", "->", "addColumn", "(", "'name'", ",", "'string'", ")", "...
Creates queue table on the current schema given. @param Schema $schema
[ "Creates", "queue", "table", "on", "the", "current", "schema", "given", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/MessagesSchema.php#L25-L30
bernardphp/bernard
src/Driver/Doctrine/MessagesSchema.php
MessagesSchema.createMessagesTable
protected static function createMessagesTable(Schema $schema) { $table = $schema->createTable('bernard_messages'); $table->addColumn('id', 'integer', [ 'autoincrement' => true, 'unsigned' => true, 'notnull' => true, ]); $table->addColumn('queue', 'string'); $table->addColumn('message', 'text'); $table->addColumn('visible', 'boolean', ['default' => true]); $table->addColumn('sentAt', 'datetime'); $table->setPrimaryKey(['id']); $table->addIndex(['queue', 'sentAt', 'visible']); }
php
protected static function createMessagesTable(Schema $schema) { $table = $schema->createTable('bernard_messages'); $table->addColumn('id', 'integer', [ 'autoincrement' => true, 'unsigned' => true, 'notnull' => true, ]); $table->addColumn('queue', 'string'); $table->addColumn('message', 'text'); $table->addColumn('visible', 'boolean', ['default' => true]); $table->addColumn('sentAt', 'datetime'); $table->setPrimaryKey(['id']); $table->addIndex(['queue', 'sentAt', 'visible']); }
[ "protected", "static", "function", "createMessagesTable", "(", "Schema", "$", "schema", ")", "{", "$", "table", "=", "$", "schema", "->", "createTable", "(", "'bernard_messages'", ")", ";", "$", "table", "->", "addColumn", "(", "'id'", ",", "'integer'", ",",...
Creates message table on the current schema given. @param Schema $schema
[ "Creates", "message", "table", "on", "the", "current", "schema", "given", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Doctrine/MessagesSchema.php#L37-L52
bernardphp/bernard
src/Command/ProduceCommand.php
ProduceCommand.execute
public function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); $queue = $input->getOption('queue'); $message = []; if ($input->getArgument('message')) { $message = json_decode($input->getArgument('message'), true); if (json_last_error()) { throw new \RuntimeException('Could not decode invalid JSON ['.json_last_error().']'); } } $this->producer->produce(new PlainMessage($name, $message), $queue); }
php
public function execute(InputInterface $input, OutputInterface $output) { $name = $input->getArgument('name'); $queue = $input->getOption('queue'); $message = []; if ($input->getArgument('message')) { $message = json_decode($input->getArgument('message'), true); if (json_last_error()) { throw new \RuntimeException('Could not decode invalid JSON ['.json_last_error().']'); } } $this->producer->produce(new PlainMessage($name, $message), $queue); }
[ "public", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "name", "=", "$", "input", "->", "getArgument", "(", "'name'", ")", ";", "$", "queue", "=", "$", "input", "->", "getOption", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Command/ProduceCommand.php#L41-L56
bernardphp/bernard
src/Driver/Predis/Driver.php
Driver.popMessage
public function popMessage($queueName, $duration = 5) { list(, $message) = $this->redis->blpop($this->resolveKey($queueName), $duration) ?: null; return [$message, null]; }
php
public function popMessage($queueName, $duration = 5) { list(, $message) = $this->redis->blpop($this->resolveKey($queueName), $duration) ?: null; return [$message, null]; }
[ "public", "function", "popMessage", "(", "$", "queueName", ",", "$", "duration", "=", "5", ")", "{", "list", "(", ",", "$", "message", ")", "=", "$", "this", "->", "redis", "->", "blpop", "(", "$", "this", "->", "resolveKey", "(", "$", "queueName", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Predis/Driver.php#L20-L25
bernardphp/bernard
src/Driver/Predis/Driver.php
Driver.info
public function info() { // Temporarily change the command use to get info as earlier and newer redis // versions breaks it into sections. $commandClass = $this->redis->getProfile()->getCommandClass('info'); $this->redis->getProfile()->defineCommand('info', 'Predis\Command\ServerInfo'); $info = $this->redis->info(); $this->redis->getProfile()->defineCommand('info', $commandClass); return $info; }
php
public function info() { // Temporarily change the command use to get info as earlier and newer redis // versions breaks it into sections. $commandClass = $this->redis->getProfile()->getCommandClass('info'); $this->redis->getProfile()->defineCommand('info', 'Predis\Command\ServerInfo'); $info = $this->redis->info(); $this->redis->getProfile()->defineCommand('info', $commandClass); return $info; }
[ "public", "function", "info", "(", ")", "{", "// Temporarily change the command use to get info as earlier and newer redis", "// versions breaks it into sections.", "$", "commandClass", "=", "$", "this", "->", "redis", "->", "getProfile", "(", ")", "->", "getCommandClass", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Predis/Driver.php#L30-L42
bernardphp/bernard
src/Consumer.php
Consumer.consume
public function consume(Queue $queue, array $options = []) { declare(ticks=1); $this->bind(); while ($this->tick($queue, $options)) { // NO op } }
php
public function consume(Queue $queue, array $options = []) { declare(ticks=1); $this->bind(); while ($this->tick($queue, $options)) { // NO op } }
[ "public", "function", "consume", "(", "Queue", "$", "queue", ",", "array", "$", "options", "=", "[", "]", ")", "{", "declare", "(", "ticks", "=", "1", ")", ";", "$", "this", "->", "bind", "(", ")", ";", "while", "(", "$", "this", "->", "tick", ...
Starts an infinite loop calling Consumer::tick();. @param Queue $queue @param array $options
[ "Starts", "an", "infinite", "loop", "calling", "Consumer", "::", "tick", "()", ";", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Consumer.php#L40-L49
bernardphp/bernard
src/Consumer.php
Consumer.tick
public function tick(Queue $queue, array $options = []) { $this->configure($options); if ($this->shutdown) { return false; } if (microtime(true) > $this->options['max-runtime']) { return false; } if ($this->pause) { return true; } $this->dispatcher->dispatch(BernardEvents::PING, new PingEvent($queue)); if (!$envelope = $queue->dequeue()) { return !$this->options['stop-when-empty']; } $this->invoke($envelope, $queue); if (null === $this->options['max-messages']) { return true; } return (bool) --$this->options['max-messages']; }
php
public function tick(Queue $queue, array $options = []) { $this->configure($options); if ($this->shutdown) { return false; } if (microtime(true) > $this->options['max-runtime']) { return false; } if ($this->pause) { return true; } $this->dispatcher->dispatch(BernardEvents::PING, new PingEvent($queue)); if (!$envelope = $queue->dequeue()) { return !$this->options['stop-when-empty']; } $this->invoke($envelope, $queue); if (null === $this->options['max-messages']) { return true; } return (bool) --$this->options['max-messages']; }
[ "public", "function", "tick", "(", "Queue", "$", "queue", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "configure", "(", "$", "options", ")", ";", "if", "(", "$", "this", "->", "shutdown", ")", "{", "return", "false", ...
Returns true do indicate it should be run again or false to indicate it should not be run again. @param Queue $queue @param array $options @return bool
[ "Returns", "true", "do", "indicate", "it", "should", "be", "run", "again", "or", "false", "to", "indicate", "it", "should", "not", "be", "run", "again", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Consumer.php#L60-L89
bernardphp/bernard
src/Consumer.php
Consumer.invoke
public function invoke(Envelope $envelope, Queue $queue) { try { $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue)); $receiver = $this->router->route($envelope); $receiver->receive($envelope->getMessage()); // We successfully processed the message. $queue->acknowledge($envelope); $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue)); } catch (\Throwable $error) { $this->rejectDispatch($error, $envelope, $queue); } catch (\Exception $exception) { $this->rejectDispatch($exception, $envelope, $queue); } }
php
public function invoke(Envelope $envelope, Queue $queue) { try { $this->dispatcher->dispatch(BernardEvents::INVOKE, new EnvelopeEvent($envelope, $queue)); $receiver = $this->router->route($envelope); $receiver->receive($envelope->getMessage()); // We successfully processed the message. $queue->acknowledge($envelope); $this->dispatcher->dispatch(BernardEvents::ACKNOWLEDGE, new EnvelopeEvent($envelope, $queue)); } catch (\Throwable $error) { $this->rejectDispatch($error, $envelope, $queue); } catch (\Exception $exception) { $this->rejectDispatch($exception, $envelope, $queue); } }
[ "public", "function", "invoke", "(", "Envelope", "$", "envelope", ",", "Queue", "$", "queue", ")", "{", "try", "{", "$", "this", "->", "dispatcher", "->", "dispatch", "(", "BernardEvents", "::", "INVOKE", ",", "new", "EnvelopeEvent", "(", "$", "envelope", ...
Until there is a real extension point to doing invoked stuff, this can be used by wrapping the invoke method. @param Envelope $envelope @param Queue $queue @throws \Exception @throws \Throwable
[ "Until", "there", "is", "a", "real", "extension", "point", "to", "doing", "invoked", "stuff", "this", "can", "be", "used", "by", "wrapping", "the", "invoke", "method", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Consumer.php#L125-L142
bernardphp/bernard
src/Consumer.php
Consumer.bind
protected function bind() { if (function_exists('pcntl_signal')) { pcntl_signal(SIGTERM, [$this, 'shutdown']); pcntl_signal(SIGINT, [$this, 'shutdown']); pcntl_signal(SIGQUIT, [$this, 'shutdown']); pcntl_signal(SIGUSR2, [$this, 'pause']); pcntl_signal(SIGCONT, [$this, 'resume']); } }
php
protected function bind() { if (function_exists('pcntl_signal')) { pcntl_signal(SIGTERM, [$this, 'shutdown']); pcntl_signal(SIGINT, [$this, 'shutdown']); pcntl_signal(SIGQUIT, [$this, 'shutdown']); pcntl_signal(SIGUSR2, [$this, 'pause']); pcntl_signal(SIGCONT, [$this, 'resume']); } }
[ "protected", "function", "bind", "(", ")", "{", "if", "(", "function_exists", "(", "'pcntl_signal'", ")", ")", "{", "pcntl_signal", "(", "SIGTERM", ",", "[", "$", "this", ",", "'shutdown'", "]", ")", ";", "pcntl_signal", "(", "SIGINT", ",", "[", "$", "...
Setup signal handlers for unix signals. If the process control extension does not exist (e.g. on Windows), ignore the signal handlers. The difference is that when terminating the consumer, running processes will not stop gracefully and will terminate immediately.
[ "Setup", "signal", "handlers", "for", "unix", "signals", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Consumer.php#L165-L174
bernardphp/bernard
src/Consumer.php
Consumer.rejectDispatch
private function rejectDispatch($exception, Envelope $envelope, Queue $queue) { // Make sure the exception is not interfering. // Previously failing jobs handling have been moved to a middleware. // // Emit an event to let others log that exception $this->dispatcher->dispatch(BernardEvents::REJECT, new RejectEnvelopeEvent($envelope, $queue, $exception)); if ($this->options['stop-on-error']) { throw $exception; } }
php
private function rejectDispatch($exception, Envelope $envelope, Queue $queue) { // Make sure the exception is not interfering. // Previously failing jobs handling have been moved to a middleware. // // Emit an event to let others log that exception $this->dispatcher->dispatch(BernardEvents::REJECT, new RejectEnvelopeEvent($envelope, $queue, $exception)); if ($this->options['stop-on-error']) { throw $exception; } }
[ "private", "function", "rejectDispatch", "(", "$", "exception", ",", "Envelope", "$", "envelope", ",", "Queue", "$", "queue", ")", "{", "// Make sure the exception is not interfering.", "// Previously failing jobs handling have been moved to a middleware.", "//", "// Emit an ev...
@param \Throwable|\Exception $exception note that the type-hint is missing due to PHP 5.x compat @param Envelope $envelope @param Queue $queue @throws \Exception @throws \Throwable
[ "@param", "\\", "Throwable|", "\\", "Exception", "$exception", "note", "that", "the", "type", "-", "hint", "is", "missing", "due", "to", "PHP", "5", ".", "x", "compat", "@param", "Envelope", "$envelope", "@param", "Queue", "$queue" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Consumer.php#L184-L195
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.listQueues
public function listQueues() { $result = $this->sqs->listQueues(); if (!$queueUrls = $result->get('QueueUrls')) { return array_keys($this->queueUrls); } foreach ($queueUrls as $queueUrl) { if (in_array($queueUrl, $this->queueUrls)) { continue; } $queueName = current(array_reverse(explode('/', $queueUrl))); $this->queueUrls[$queueName] = $queueUrl; } return array_keys($this->queueUrls); }
php
public function listQueues() { $result = $this->sqs->listQueues(); if (!$queueUrls = $result->get('QueueUrls')) { return array_keys($this->queueUrls); } foreach ($queueUrls as $queueUrl) { if (in_array($queueUrl, $this->queueUrls)) { continue; } $queueName = current(array_reverse(explode('/', $queueUrl))); $this->queueUrls[$queueName] = $queueUrl; } return array_keys($this->queueUrls); }
[ "public", "function", "listQueues", "(", ")", "{", "$", "result", "=", "$", "this", "->", "sqs", "->", "listQueues", "(", ")", ";", "if", "(", "!", "$", "queueUrls", "=", "$", "result", "->", "get", "(", "'QueueUrls'", ")", ")", "{", "return", "arr...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L39-L57
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.createQueue
public function createQueue($queueName) { if ($this->queueExists($queueName)) { return; } $parameters = [ 'QueueName' => $queueName, ]; if ($this->isFifoQueue($queueName)) { $parameters['Attributes'] = [ 'FifoQueue' => 'true', ]; } $result = $this->sqs->createQueue($parameters); $this->queueUrls[$queueName] = $result['QueueUrl']; }
php
public function createQueue($queueName) { if ($this->queueExists($queueName)) { return; } $parameters = [ 'QueueName' => $queueName, ]; if ($this->isFifoQueue($queueName)) { $parameters['Attributes'] = [ 'FifoQueue' => 'true', ]; } $result = $this->sqs->createQueue($parameters); $this->queueUrls[$queueName] = $result['QueueUrl']; }
[ "public", "function", "createQueue", "(", "$", "queueName", ")", "{", "if", "(", "$", "this", "->", "queueExists", "(", "$", "queueName", ")", ")", "{", "return", ";", "}", "$", "parameters", "=", "[", "'QueueName'", "=>", "$", "queueName", ",", "]", ...
{@inheritdoc} @see http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-sqs-2012-11-05.html#createqueue @throws SqsException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L66-L85
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.queueExists
private function queueExists($queueName) { try { $this->resolveUrl($queueName); return true; } catch (\InvalidArgumentException $exception) { return false; } catch (SqsException $exception) { if ($previousException = $exception->getPrevious()) { switch ($previousException->getCode()) { case self::AWS_SQS_EXCEPTION_BAD_REQUEST: case self::AWS_SQS_EXCEPTION_NOT_FOUND: return false; } } throw $exception; } }
php
private function queueExists($queueName) { try { $this->resolveUrl($queueName); return true; } catch (\InvalidArgumentException $exception) { return false; } catch (SqsException $exception) { if ($previousException = $exception->getPrevious()) { switch ($previousException->getCode()) { case self::AWS_SQS_EXCEPTION_BAD_REQUEST: case self::AWS_SQS_EXCEPTION_NOT_FOUND: return false; } } throw $exception; } }
[ "private", "function", "queueExists", "(", "$", "queueName", ")", "{", "try", "{", "$", "this", "->", "resolveUrl", "(", "$", "queueName", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "exception", ")", "{", "...
@param string $queueName @return bool @throws SqsException
[ "@param", "string", "$queueName" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L94-L113
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.endsWith
private function endsWith($haystack, $needle) { $length = strlen($needle); if ($length === 0) { return true; } return substr($haystack, -$length) === $needle; }
php
private function endsWith($haystack, $needle) { $length = strlen($needle); if ($length === 0) { return true; } return substr($haystack, -$length) === $needle; }
[ "private", "function", "endsWith", "(", "$", "haystack", ",", "$", "needle", ")", "{", "$", "length", "=", "strlen", "(", "$", "needle", ")", ";", "if", "(", "$", "length", "===", "0", ")", "{", "return", "true", ";", "}", "return", "substr", "(", ...
@param string $haystack @param string $needle @return bool
[ "@param", "string", "$haystack", "@param", "string", "$needle" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L131-L139
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.countMessages
public function countMessages($queueName) { $queueUrl = $this->resolveUrl($queueName); $result = $this->sqs->getQueueAttributes([ 'QueueUrl' => $queueUrl, 'AttributeNames' => ['ApproximateNumberOfMessages'], ]); if (isset($result['Attributes']['ApproximateNumberOfMessages'])) { return (int) $result['Attributes']['ApproximateNumberOfMessages']; } return 0; }
php
public function countMessages($queueName) { $queueUrl = $this->resolveUrl($queueName); $result = $this->sqs->getQueueAttributes([ 'QueueUrl' => $queueUrl, 'AttributeNames' => ['ApproximateNumberOfMessages'], ]); if (isset($result['Attributes']['ApproximateNumberOfMessages'])) { return (int) $result['Attributes']['ApproximateNumberOfMessages']; } return 0; }
[ "public", "function", "countMessages", "(", "$", "queueName", ")", "{", "$", "queueUrl", "=", "$", "this", "->", "resolveUrl", "(", "$", "queueName", ")", ";", "$", "result", "=", "$", "this", "->", "sqs", "->", "getQueueAttributes", "(", "[", "'QueueUrl...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L144-L158
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.pushMessage
public function pushMessage($queueName, $message) { $queueUrl = $this->resolveUrl($queueName); $parameters = [ 'QueueUrl' => $queueUrl, 'MessageBody' => $message, ]; if ($this->isFifoQueue($queueName)) { $parameters['MessageGroupId'] = __METHOD__; $parameters['MessageDeduplicationId'] = md5($message); } $this->sqs->sendMessage($parameters); }
php
public function pushMessage($queueName, $message) { $queueUrl = $this->resolveUrl($queueName); $parameters = [ 'QueueUrl' => $queueUrl, 'MessageBody' => $message, ]; if ($this->isFifoQueue($queueName)) { $parameters['MessageGroupId'] = __METHOD__; $parameters['MessageDeduplicationId'] = md5($message); } $this->sqs->sendMessage($parameters); }
[ "public", "function", "pushMessage", "(", "$", "queueName", ",", "$", "message", ")", "{", "$", "queueUrl", "=", "$", "this", "->", "resolveUrl", "(", "$", "queueName", ")", ";", "$", "parameters", "=", "[", "'QueueUrl'", "=>", "$", "queueUrl", ",", "'...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L163-L178
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.popMessage
public function popMessage($queueName, $duration = 5) { if ($message = $this->cache->pop($queueName)) { return $message; } $queueUrl = $this->resolveUrl($queueName); $result = $this->sqs->receiveMessage([ 'QueueUrl' => $queueUrl, 'MaxNumberOfMessages' => $this->prefetch, 'WaitTimeSeconds' => $duration, ]); if (!$result || !$messages = $result->get('Messages')) { return [null, null]; } foreach ($messages as $message) { $this->cache->push($queueName, [$message['Body'], $message['ReceiptHandle']]); } return $this->cache->pop($queueName); }
php
public function popMessage($queueName, $duration = 5) { if ($message = $this->cache->pop($queueName)) { return $message; } $queueUrl = $this->resolveUrl($queueName); $result = $this->sqs->receiveMessage([ 'QueueUrl' => $queueUrl, 'MaxNumberOfMessages' => $this->prefetch, 'WaitTimeSeconds' => $duration, ]); if (!$result || !$messages = $result->get('Messages')) { return [null, null]; } foreach ($messages as $message) { $this->cache->push($queueName, [$message['Body'], $message['ReceiptHandle']]); } return $this->cache->pop($queueName); }
[ "public", "function", "popMessage", "(", "$", "queueName", ",", "$", "duration", "=", "5", ")", "{", "if", "(", "$", "message", "=", "$", "this", "->", "cache", "->", "pop", "(", "$", "queueName", ")", ")", "{", "return", "$", "message", ";", "}", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L183-L206
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.acknowledgeMessage
public function acknowledgeMessage($queueName, $receipt) { $queueUrl = $this->resolveUrl($queueName); $this->sqs->deleteMessage([ 'QueueUrl' => $queueUrl, 'ReceiptHandle' => $receipt, ]); }
php
public function acknowledgeMessage($queueName, $receipt) { $queueUrl = $this->resolveUrl($queueName); $this->sqs->deleteMessage([ 'QueueUrl' => $queueUrl, 'ReceiptHandle' => $receipt, ]); }
[ "public", "function", "acknowledgeMessage", "(", "$", "queueName", ",", "$", "receipt", ")", "{", "$", "queueUrl", "=", "$", "this", "->", "resolveUrl", "(", "$", "queueName", ")", ";", "$", "this", "->", "sqs", "->", "deleteMessage", "(", "[", "'QueueUr...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L211-L219
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.removeQueue
public function removeQueue($queueName) { $queueUrl = $this->resolveUrl($queueName); $this->sqs->deleteQueue([ 'QueueUrl' => $queueUrl, ]); }
php
public function removeQueue($queueName) { $queueUrl = $this->resolveUrl($queueName); $this->sqs->deleteQueue([ 'QueueUrl' => $queueUrl, ]); }
[ "public", "function", "removeQueue", "(", "$", "queueName", ")", "{", "$", "queueUrl", "=", "$", "this", "->", "resolveUrl", "(", "$", "queueName", ")", ";", "$", "this", "->", "sqs", "->", "deleteQueue", "(", "[", "'QueueUrl'", "=>", "$", "queueUrl", ...
{@inheritdoc} @see http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-sqs-2012-11-05.html#deletequeue
[ "{", "@inheritdoc", "}" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L234-L241
bernardphp/bernard
src/Driver/Sqs/Driver.php
Driver.resolveUrl
private function resolveUrl($queueName) { if (isset($this->queueUrls[$queueName])) { return $this->queueUrls[$queueName]; } $result = $this->sqs->getQueueUrl(['QueueName' => $queueName]); if ($result && $queueUrl = $result->get('QueueUrl')) { return $this->queueUrls[$queueName] = $queueUrl; } throw new \InvalidArgumentException('Queue "'.$queueName.'" cannot be resolved to an url.'); }
php
private function resolveUrl($queueName) { if (isset($this->queueUrls[$queueName])) { return $this->queueUrls[$queueName]; } $result = $this->sqs->getQueueUrl(['QueueName' => $queueName]); if ($result && $queueUrl = $result->get('QueueUrl')) { return $this->queueUrls[$queueName] = $queueUrl; } throw new \InvalidArgumentException('Queue "'.$queueName.'" cannot be resolved to an url.'); }
[ "private", "function", "resolveUrl", "(", "$", "queueName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "queueUrls", "[", "$", "queueName", "]", ")", ")", "{", "return", "$", "this", "->", "queueUrls", "[", "$", "queueName", "]", ";", "}", ...
AWS works with queue URLs rather than queue names. Returns either queue URL (if queue exists) for given name or null if not. @param string $queueName @return mixed @throws SqsException
[ "AWS", "works", "with", "queue", "URLs", "rather", "than", "queue", "names", ".", "Returns", "either", "queue", "URL", "(", "if", "queue", "exists", ")", "for", "given", "name", "or", "null", "if", "not", "." ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/Sqs/Driver.php#L262-L275
bernardphp/bernard
src/Driver/AppEngine/Driver.php
Driver.pushMessage
public function pushMessage($queueName, $message) { $task = new PushTask($this->resolveEndpoint($queueName), compact('message')); $task->add($queueName); }
php
public function pushMessage($queueName, $message) { $task = new PushTask($this->resolveEndpoint($queueName), compact('message')); $task->add($queueName); }
[ "public", "function", "pushMessage", "(", "$", "queueName", ",", "$", "message", ")", "{", "$", "task", "=", "new", "PushTask", "(", "$", "this", "->", "resolveEndpoint", "(", "$", "queueName", ")", ",", "compact", "(", "'message'", ")", ")", ";", "$",...
{@inheritdoc}
[ "{" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/AppEngine/Driver.php#L49-L53
bernardphp/bernard
src/Driver/AppEngine/Driver.php
Driver.resolveEndpoint
private function resolveEndpoint($queueName) { if (isset($this->queueMap[$queueName])) { return $this->queueMap[$queueName]; } return '/_ah/queue/'.$queueName; }
php
private function resolveEndpoint($queueName) { if (isset($this->queueMap[$queueName])) { return $this->queueMap[$queueName]; } return '/_ah/queue/'.$queueName; }
[ "private", "function", "resolveEndpoint", "(", "$", "queueName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "queueMap", "[", "$", "queueName", "]", ")", ")", "{", "return", "$", "this", "->", "queueMap", "[", "$", "queueName", "]", ";", "}...
@param string $queueName @return string
[ "@param", "string", "$queueName" ]
train
https://github.com/bernardphp/bernard/blob/3ff88921bea87186d1baffc93708dd7aee4e963e/src/Driver/AppEngine/Driver.php#L97-L104
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.visit
public function visit($url) { $this->client->request('GET', $this->prepareUrl($url), array(), array(), $this->serverParameters); $this->forms = array(); }
php
public function visit($url) { $this->client->request('GET', $this->prepareUrl($url), array(), array(), $this->serverParameters); $this->forms = array(); }
[ "public", "function", "visit", "(", "$", "url", ")", "{", "$", "this", "->", "client", "->", "request", "(", "'GET'", ",", "$", "this", "->", "prepareUrl", "(", "$", "url", ")", ",", "array", "(", ")", ",", "array", "(", ")", ",", "$", "this", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L143-L147
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getCurrentUrl
public function getCurrentUrl() { // This should be encapsulated in `getRequest` method if any other method needs the request try { $request = $this->client->getInternalRequest(); } catch (BadMethodCallException $e) { // Handling Symfony 5+ behaviour $request = null; } if ($request === null) { throw new DriverException('Unable to access the request before visiting a page'); } return $request->getUri(); }
php
public function getCurrentUrl() { // This should be encapsulated in `getRequest` method if any other method needs the request try { $request = $this->client->getInternalRequest(); } catch (BadMethodCallException $e) { // Handling Symfony 5+ behaviour $request = null; } if ($request === null) { throw new DriverException('Unable to access the request before visiting a page'); } return $request->getUri(); }
[ "public", "function", "getCurrentUrl", "(", ")", "{", "// This should be encapsulated in `getRequest` method if any other method needs the request", "try", "{", "$", "request", "=", "$", "this", "->", "client", "->", "getInternalRequest", "(", ")", ";", "}", "catch", "(...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L152-L167
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.setBasicAuth
public function setBasicAuth($user, $password) { if (false === $user) { unset($this->serverParameters['PHP_AUTH_USER'], $this->serverParameters['PHP_AUTH_PW']); return; } $this->serverParameters['PHP_AUTH_USER'] = $user; $this->serverParameters['PHP_AUTH_PW'] = $password; }
php
public function setBasicAuth($user, $password) { if (false === $user) { unset($this->serverParameters['PHP_AUTH_USER'], $this->serverParameters['PHP_AUTH_PW']); return; } $this->serverParameters['PHP_AUTH_USER'] = $user; $this->serverParameters['PHP_AUTH_PW'] = $password; }
[ "public", "function", "setBasicAuth", "(", "$", "user", ",", "$", "password", ")", "{", "if", "(", "false", "===", "$", "user", ")", "{", "unset", "(", "$", "this", "->", "serverParameters", "[", "'PHP_AUTH_USER'", "]", ",", "$", "this", "->", "serverP...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L199-L209
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.setRequestHeader
public function setRequestHeader($name, $value) { $contentHeaders = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); $name = str_replace('-', '_', strtoupper($name)); // CONTENT_* are not prefixed with HTTP_ in PHP when building $_SERVER if (!isset($contentHeaders[$name])) { $name = 'HTTP_' . $name; } $this->serverParameters[$name] = $value; }
php
public function setRequestHeader($name, $value) { $contentHeaders = array('CONTENT_LENGTH' => true, 'CONTENT_MD5' => true, 'CONTENT_TYPE' => true); $name = str_replace('-', '_', strtoupper($name)); // CONTENT_* are not prefixed with HTTP_ in PHP when building $_SERVER if (!isset($contentHeaders[$name])) { $name = 'HTTP_' . $name; } $this->serverParameters[$name] = $value; }
[ "public", "function", "setRequestHeader", "(", "$", "name", ",", "$", "value", ")", "{", "$", "contentHeaders", "=", "array", "(", "'CONTENT_LENGTH'", "=>", "true", ",", "'CONTENT_MD5'", "=>", "true", ",", "'CONTENT_TYPE'", "=>", "true", ")", ";", "$", "na...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L214-L225
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.setCookie
public function setCookie($name, $value = null) { if (null === $value) { $this->deleteCookie($name); return; } $jar = $this->client->getCookieJar(); $jar->set(new Cookie($name, $value)); }
php
public function setCookie($name, $value = null) { if (null === $value) { $this->deleteCookie($name); return; } $jar = $this->client->getCookieJar(); $jar->set(new Cookie($name, $value)); }
[ "public", "function", "setCookie", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "$", "this", "->", "deleteCookie", "(", "$", "name", ")", ";", "return", ";", "}", "$", "jar", "=", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L238-L248
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.deleteCookie
private function deleteCookie($name) { $path = $this->getCookiePath(); $jar = $this->client->getCookieJar(); do { if (null !== $jar->get($name, $path)) { $jar->expire($name, $path); } $path = preg_replace('/.$/', '', $path); } while ($path); }
php
private function deleteCookie($name) { $path = $this->getCookiePath(); $jar = $this->client->getCookieJar(); do { if (null !== $jar->get($name, $path)) { $jar->expire($name, $path); } $path = preg_replace('/.$/', '', $path); } while ($path); }
[ "private", "function", "deleteCookie", "(", "$", "name", ")", "{", "$", "path", "=", "$", "this", "->", "getCookiePath", "(", ")", ";", "$", "jar", "=", "$", "this", "->", "client", "->", "getCookieJar", "(", ")", ";", "do", "{", "if", "(", "null",...
Deletes a cookie by name. @param string $name Cookie name.
[ "Deletes", "a", "cookie", "by", "name", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L255-L267
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getCookiePath
private function getCookiePath() { $path = dirname(parse_url($this->getCurrentUrl(), PHP_URL_PATH)); if ('\\' === DIRECTORY_SEPARATOR) { $path = str_replace('\\', '/', $path); } return $path; }
php
private function getCookiePath() { $path = dirname(parse_url($this->getCurrentUrl(), PHP_URL_PATH)); if ('\\' === DIRECTORY_SEPARATOR) { $path = str_replace('\\', '/', $path); } return $path; }
[ "private", "function", "getCookiePath", "(", ")", "{", "$", "path", "=", "dirname", "(", "parse_url", "(", "$", "this", "->", "getCurrentUrl", "(", ")", ",", "PHP_URL_PATH", ")", ")", ";", "if", "(", "'\\\\'", "===", "DIRECTORY_SEPARATOR", ")", "{", "$",...
Returns current cookie path. @return string
[ "Returns", "current", "cookie", "path", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L274-L283
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getCookie
public function getCookie($name) { // Note that the following doesn't work well because // Symfony\Component\BrowserKit\CookieJar stores cookies by name, // path, AND domain and if you don't fill them all in correctly then // you won't get the value that you're expecting. // // $jar = $this->client->getCookieJar(); // // if (null !== $cookie = $jar->get($name)) { // return $cookie->getValue(); // } $allValues = $this->client->getCookieJar()->allValues($this->getCurrentUrl()); if (isset($allValues[$name])) { return $allValues[$name]; } return null; }
php
public function getCookie($name) { // Note that the following doesn't work well because // Symfony\Component\BrowserKit\CookieJar stores cookies by name, // path, AND domain and if you don't fill them all in correctly then // you won't get the value that you're expecting. // // $jar = $this->client->getCookieJar(); // // if (null !== $cookie = $jar->get($name)) { // return $cookie->getValue(); // } $allValues = $this->client->getCookieJar()->allValues($this->getCurrentUrl()); if (isset($allValues[$name])) { return $allValues[$name]; } return null; }
[ "public", "function", "getCookie", "(", "$", "name", ")", "{", "// Note that the following doesn't work well because", "// Symfony\\Component\\BrowserKit\\CookieJar stores cookies by name,", "// path, AND domain and if you don't fill them all in correctly then", "// you won't get the value tha...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L288-L308
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.findElementXpaths
public function findElementXpaths($xpath) { $nodes = $this->getCrawler()->filterXPath($xpath); $elements = array(); foreach ($nodes as $i => $node) { $elements[] = sprintf('(%s)[%d]', $xpath, $i + 1); } return $elements; }
php
public function findElementXpaths($xpath) { $nodes = $this->getCrawler()->filterXPath($xpath); $elements = array(); foreach ($nodes as $i => $node) { $elements[] = sprintf('(%s)[%d]', $xpath, $i + 1); } return $elements; }
[ "public", "function", "findElementXpaths", "(", "$", "xpath", ")", "{", "$", "nodes", "=", "$", "this", "->", "getCrawler", "(", ")", "->", "filterXPath", "(", "$", "xpath", ")", ";", "$", "elements", "=", "array", "(", ")", ";", "foreach", "(", "$",...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L329-L339
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getText
public function getText($xpath) { $text = $this->getFilteredCrawler($xpath)->text(); $text = str_replace("\n", ' ', $text); $text = preg_replace('/ {2,}/', ' ', $text); return trim($text); }
php
public function getText($xpath) { $text = $this->getFilteredCrawler($xpath)->text(); $text = str_replace("\n", ' ', $text); $text = preg_replace('/ {2,}/', ' ', $text); return trim($text); }
[ "public", "function", "getText", "(", "$", "xpath", ")", "{", "$", "text", "=", "$", "this", "->", "getFilteredCrawler", "(", "$", "xpath", ")", "->", "text", "(", ")", ";", "$", "text", "=", "str_replace", "(", "\"\\n\"", ",", "' '", ",", "$", "te...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L352-L359
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getOuterHtml
public function getOuterHtml($xpath) { $node = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); return $node->ownerDocument->saveHTML($node); }
php
public function getOuterHtml($xpath) { $node = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); return $node->ownerDocument->saveHTML($node); }
[ "public", "function", "getOuterHtml", "(", "$", "xpath", ")", "{", "$", "node", "=", "$", "this", "->", "getCrawlerNode", "(", "$", "this", "->", "getFilteredCrawler", "(", "$", "xpath", ")", ")", ";", "return", "$", "node", "->", "ownerDocument", "->", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L373-L378
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getAttribute
public function getAttribute($xpath, $name) { $node = $this->getFilteredCrawler($xpath); if ($this->getCrawlerNode($node)->hasAttribute($name)) { return $node->attr($name); } return null; }
php
public function getAttribute($xpath, $name) { $node = $this->getFilteredCrawler($xpath); if ($this->getCrawlerNode($node)->hasAttribute($name)) { return $node->attr($name); } return null; }
[ "public", "function", "getAttribute", "(", "$", "xpath", ",", "$", "name", ")", "{", "$", "node", "=", "$", "this", "->", "getFilteredCrawler", "(", "$", "xpath", ")", ";", "if", "(", "$", "this", "->", "getCrawlerNode", "(", "$", "node", ")", "->", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L383-L392
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getValue
public function getValue($xpath) { if (in_array($this->getAttribute($xpath, 'type'), array('submit', 'image', 'button'), true)) { return $this->getAttribute($xpath, 'value'); } $node = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); if ('option' === $node->tagName) { return $this->getOptionValue($node); } try { $field = $this->getFormField($xpath); } catch (\InvalidArgumentException $e) { return $this->getAttribute($xpath, 'value'); } return $field->getValue(); }
php
public function getValue($xpath) { if (in_array($this->getAttribute($xpath, 'type'), array('submit', 'image', 'button'), true)) { return $this->getAttribute($xpath, 'value'); } $node = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); if ('option' === $node->tagName) { return $this->getOptionValue($node); } try { $field = $this->getFormField($xpath); } catch (\InvalidArgumentException $e) { return $this->getAttribute($xpath, 'value'); } return $field->getValue(); }
[ "public", "function", "getValue", "(", "$", "xpath", ")", "{", "if", "(", "in_array", "(", "$", "this", "->", "getAttribute", "(", "$", "xpath", ",", "'type'", ")", ",", "array", "(", "'submit'", ",", "'image'", ",", "'button'", ")", ",", "true", ")"...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L397-L416
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.selectOption
public function selectOption($xpath, $value, $multiple = false) { $field = $this->getFormField($xpath); if (!$field instanceof ChoiceFormField) { throw new DriverException(sprintf('Impossible to select an option on the element with XPath "%s" as it is not a select or radio input', $xpath)); } if ($multiple) { $oldValue = (array) $field->getValue(); $oldValue[] = $value; $value = $oldValue; } $field->select($value); }
php
public function selectOption($xpath, $value, $multiple = false) { $field = $this->getFormField($xpath); if (!$field instanceof ChoiceFormField) { throw new DriverException(sprintf('Impossible to select an option on the element with XPath "%s" as it is not a select or radio input', $xpath)); } if ($multiple) { $oldValue = (array) $field->getValue(); $oldValue[] = $value; $value = $oldValue; } $field->select($value); }
[ "public", "function", "selectOption", "(", "$", "xpath", ",", "$", "value", ",", "$", "multiple", "=", "false", ")", "{", "$", "field", "=", "$", "this", "->", "getFormField", "(", "$", "xpath", ")", ";", "if", "(", "!", "$", "field", "instanceof", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L445-L460
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.isSelected
public function isSelected($xpath) { $optionValue = $this->getOptionValue($this->getCrawlerNode($this->getFilteredCrawler($xpath))); $selectField = $this->getFormField('(' . $xpath . ')/ancestor-or-self::*[local-name()="select"]'); $selectValue = $selectField->getValue(); return is_array($selectValue) ? in_array($optionValue, $selectValue, true) : $optionValue === $selectValue; }
php
public function isSelected($xpath) { $optionValue = $this->getOptionValue($this->getCrawlerNode($this->getFilteredCrawler($xpath))); $selectField = $this->getFormField('(' . $xpath . ')/ancestor-or-self::*[local-name()="select"]'); $selectValue = $selectField->getValue(); return is_array($selectValue) ? in_array($optionValue, $selectValue, true) : $optionValue === $selectValue; }
[ "public", "function", "isSelected", "(", "$", "xpath", ")", "{", "$", "optionValue", "=", "$", "this", "->", "getOptionValue", "(", "$", "this", "->", "getCrawlerNode", "(", "$", "this", "->", "getFilteredCrawler", "(", "$", "xpath", ")", ")", ")", ";", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L465-L472
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.click
public function click($xpath) { $crawler = $this->getFilteredCrawler($xpath); $node = $this->getCrawlerNode($crawler); $tagName = $node->nodeName; if ('a' === $tagName) { $this->client->click($crawler->link()); $this->forms = array(); } elseif ($this->canSubmitForm($node)) { $this->submit($crawler->form()); } elseif ($this->canResetForm($node)) { $this->resetForm($node); } else { $message = sprintf('%%s supports clicking on links and submit or reset buttons only. But "%s" provided', $tagName); throw new UnsupportedDriverActionException($message, $this); } }
php
public function click($xpath) { $crawler = $this->getFilteredCrawler($xpath); $node = $this->getCrawlerNode($crawler); $tagName = $node->nodeName; if ('a' === $tagName) { $this->client->click($crawler->link()); $this->forms = array(); } elseif ($this->canSubmitForm($node)) { $this->submit($crawler->form()); } elseif ($this->canResetForm($node)) { $this->resetForm($node); } else { $message = sprintf('%%s supports clicking on links and submit or reset buttons only. But "%s" provided', $tagName); throw new UnsupportedDriverActionException($message, $this); } }
[ "public", "function", "click", "(", "$", "xpath", ")", "{", "$", "crawler", "=", "$", "this", "->", "getFilteredCrawler", "(", "$", "xpath", ")", ";", "$", "node", "=", "$", "this", "->", "getCrawlerNode", "(", "$", "crawler", ")", ";", "$", "tagName...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L477-L495
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.isChecked
public function isChecked($xpath) { $field = $this->getFormField($xpath); if (!$field instanceof ChoiceFormField || 'select' === $field->getType()) { throw new DriverException(sprintf('Impossible to get the checked state of the element with XPath "%s" as it is not a checkbox or radio input', $xpath)); } if ('checkbox' === $field->getType()) { return $field->hasValue(); } $radio = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); return $radio->getAttribute('value') === $field->getValue(); }
php
public function isChecked($xpath) { $field = $this->getFormField($xpath); if (!$field instanceof ChoiceFormField || 'select' === $field->getType()) { throw new DriverException(sprintf('Impossible to get the checked state of the element with XPath "%s" as it is not a checkbox or radio input', $xpath)); } if ('checkbox' === $field->getType()) { return $field->hasValue(); } $radio = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); return $radio->getAttribute('value') === $field->getValue(); }
[ "public", "function", "isChecked", "(", "$", "xpath", ")", "{", "$", "field", "=", "$", "this", "->", "getFormField", "(", "$", "xpath", ")", ";", "if", "(", "!", "$", "field", "instanceof", "ChoiceFormField", "||", "'select'", "===", "$", "field", "->...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L500-L515
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.attachFile
public function attachFile($xpath, $path) { $field = $this->getFormField($xpath); if (!$field instanceof FileFormField) { throw new DriverException(sprintf('Impossible to attach a file on the element with XPath "%s" as it is not a file input', $xpath)); } $field->upload($path); }
php
public function attachFile($xpath, $path) { $field = $this->getFormField($xpath); if (!$field instanceof FileFormField) { throw new DriverException(sprintf('Impossible to attach a file on the element with XPath "%s" as it is not a file input', $xpath)); } $field->upload($path); }
[ "public", "function", "attachFile", "(", "$", "xpath", ",", "$", "path", ")", "{", "$", "field", "=", "$", "this", "->", "getFormField", "(", "$", "xpath", ")", ";", "if", "(", "!", "$", "field", "instanceof", "FileFormField", ")", "{", "throw", "new...
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L520-L529
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.submitForm
public function submitForm($xpath) { $crawler = $this->getFilteredCrawler($xpath); $this->submit($crawler->form()); }
php
public function submitForm($xpath) { $crawler = $this->getFilteredCrawler($xpath); $this->submit($crawler->form()); }
[ "public", "function", "submitForm", "(", "$", "xpath", ")", "{", "$", "crawler", "=", "$", "this", "->", "getFilteredCrawler", "(", "$", "xpath", ")", ";", "$", "this", "->", "submit", "(", "$", "crawler", "->", "form", "(", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L534-L539
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getResponse
protected function getResponse() { try { $response = $this->client->getInternalResponse(); } catch (BadMethodCallException $e) { // Handling Symfony 5+ behaviour $response = null; } if (null === $response) { throw new DriverException('Unable to access the response before visiting a page'); } return $response; }
php
protected function getResponse() { try { $response = $this->client->getInternalResponse(); } catch (BadMethodCallException $e) { // Handling Symfony 5+ behaviour $response = null; } if (null === $response) { throw new DriverException('Unable to access the response before visiting a page'); } return $response; }
[ "protected", "function", "getResponse", "(", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "client", "->", "getInternalResponse", "(", ")", ";", "}", "catch", "(", "BadMethodCallException", "$", "e", ")", "{", "// Handling Symfony 5+ behaviour...
@return Response @throws DriverException If there is not response yet
[ "@return", "Response" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L546-L560
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.prepareUrl
protected function prepareUrl($url) { $replacement = ($this->removeHostFromUrl ? '' : '$1') . ($this->removeScriptFromUrl ? '' : '$2'); return preg_replace('#(https?\://[^/]+)(/[^/\.]+\.php)?#', $replacement, $url); }
php
protected function prepareUrl($url) { $replacement = ($this->removeHostFromUrl ? '' : '$1') . ($this->removeScriptFromUrl ? '' : '$2'); return preg_replace('#(https?\://[^/]+)(/[^/\.]+\.php)?#', $replacement, $url); }
[ "protected", "function", "prepareUrl", "(", "$", "url", ")", "{", "$", "replacement", "=", "(", "$", "this", "->", "removeHostFromUrl", "?", "''", ":", "'$1'", ")", ".", "(", "$", "this", "->", "removeScriptFromUrl", "?", "''", ":", "'$2'", ")", ";", ...
Prepares URL for visiting. Removes "*.php/" from urls and then passes it to BrowserKitDriver::visit(). @param string $url @return string
[ "Prepares", "URL", "for", "visiting", ".", "Removes", "*", ".", "php", "/", "from", "urls", "and", "then", "passes", "it", "to", "BrowserKitDriver", "::", "visit", "()", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L570-L575
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getFormField
protected function getFormField($xpath) { $fieldNode = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); $fieldName = str_replace('[]', '', $fieldNode->getAttribute('name')); $formNode = $this->getFormNode($fieldNode); $formId = $this->getFormNodeId($formNode); if (!isset($this->forms[$formId])) { $this->forms[$formId] = new Form($formNode, $this->getCurrentUrl()); } if (is_array($this->forms[$formId][$fieldName])) { return $this->forms[$formId][$fieldName][$this->getFieldPosition($fieldNode)]; } return $this->forms[$formId][$fieldName]; }
php
protected function getFormField($xpath) { $fieldNode = $this->getCrawlerNode($this->getFilteredCrawler($xpath)); $fieldName = str_replace('[]', '', $fieldNode->getAttribute('name')); $formNode = $this->getFormNode($fieldNode); $formId = $this->getFormNodeId($formNode); if (!isset($this->forms[$formId])) { $this->forms[$formId] = new Form($formNode, $this->getCurrentUrl()); } if (is_array($this->forms[$formId][$fieldName])) { return $this->forms[$formId][$fieldName][$this->getFieldPosition($fieldNode)]; } return $this->forms[$formId][$fieldName]; }
[ "protected", "function", "getFormField", "(", "$", "xpath", ")", "{", "$", "fieldNode", "=", "$", "this", "->", "getCrawlerNode", "(", "$", "this", "->", "getFilteredCrawler", "(", "$", "xpath", ")", ")", ";", "$", "fieldName", "=", "str_replace", "(", "...
Returns form field from XPath query. @param string $xpath @return FormField @throws DriverException
[ "Returns", "form", "field", "from", "XPath", "query", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L586-L603
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getCheckboxField
private function getCheckboxField($xpath) { $field = $this->getFormField($xpath); if (!$field instanceof ChoiceFormField) { throw new DriverException(sprintf('Impossible to check the element with XPath "%s" as it is not a checkbox', $xpath)); } return $field; }
php
private function getCheckboxField($xpath) { $field = $this->getFormField($xpath); if (!$field instanceof ChoiceFormField) { throw new DriverException(sprintf('Impossible to check the element with XPath "%s" as it is not a checkbox', $xpath)); } return $field; }
[ "private", "function", "getCheckboxField", "(", "$", "xpath", ")", "{", "$", "field", "=", "$", "this", "->", "getFormField", "(", "$", "xpath", ")", ";", "if", "(", "!", "$", "field", "instanceof", "ChoiceFormField", ")", "{", "throw", "new", "DriverExc...
Returns the checkbox field from xpath query, ensuring it is valid. @param string $xpath @return ChoiceFormField @throws DriverException when the field is not a checkbox
[ "Returns", "the", "checkbox", "field", "from", "xpath", "query", "ensuring", "it", "is", "valid", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L614-L623
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getFormNode
private function getFormNode(\DOMElement $element) { if ($element->hasAttribute('form')) { $formId = $element->getAttribute('form'); $formNode = $element->ownerDocument->getElementById($formId); if (null === $formNode || 'form' !== $formNode->nodeName) { throw new DriverException(sprintf('The selected node has an invalid form attribute (%s).', $formId)); } return $formNode; } $formNode = $element; do { // use the ancestor form element if (null === $formNode = $formNode->parentNode) { throw new DriverException('The selected node does not have a form ancestor.'); } } while ('form' !== $formNode->nodeName); return $formNode; }
php
private function getFormNode(\DOMElement $element) { if ($element->hasAttribute('form')) { $formId = $element->getAttribute('form'); $formNode = $element->ownerDocument->getElementById($formId); if (null === $formNode || 'form' !== $formNode->nodeName) { throw new DriverException(sprintf('The selected node has an invalid form attribute (%s).', $formId)); } return $formNode; } $formNode = $element; do { // use the ancestor form element if (null === $formNode = $formNode->parentNode) { throw new DriverException('The selected node does not have a form ancestor.'); } } while ('form' !== $formNode->nodeName); return $formNode; }
[ "private", "function", "getFormNode", "(", "\\", "DOMElement", "$", "element", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'form'", ")", ")", "{", "$", "formId", "=", "$", "element", "->", "getAttribute", "(", "'form'", ")", ";", "...
@param \DOMElement $element @return \DOMElement @throws DriverException if the form node cannot be found
[ "@param", "\\", "DOMElement", "$element" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L632-L655
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getFieldPosition
private function getFieldPosition(\DOMElement $fieldNode) { $elements = $this->getCrawler()->filterXPath('//*[@name=\''.$fieldNode->getAttribute('name').'\']'); if (count($elements) > 1) { // more than one element contains this name ! // so we need to find the position of $fieldNode foreach ($elements as $key => $element) { /** @var \DOMElement $element */ if ($element->getNodePath() === $fieldNode->getNodePath()) { return $key; } } } return 0; }
php
private function getFieldPosition(\DOMElement $fieldNode) { $elements = $this->getCrawler()->filterXPath('//*[@name=\''.$fieldNode->getAttribute('name').'\']'); if (count($elements) > 1) { // more than one element contains this name ! // so we need to find the position of $fieldNode foreach ($elements as $key => $element) { /** @var \DOMElement $element */ if ($element->getNodePath() === $fieldNode->getNodePath()) { return $key; } } } return 0; }
[ "private", "function", "getFieldPosition", "(", "\\", "DOMElement", "$", "fieldNode", ")", "{", "$", "elements", "=", "$", "this", "->", "getCrawler", "(", ")", "->", "filterXPath", "(", "'//*[@name=\\''", ".", "$", "fieldNode", "->", "getAttribute", "(", "'...
Gets the position of the field node among elements with the same name BrowserKit uses the field name as index to find the field in its Form object. When multiple fields have the same name (checkboxes for instance), it will return an array of elements in the order they appear in the DOM. @param \DOMElement $fieldNode @return integer
[ "Gets", "the", "position", "of", "the", "field", "node", "among", "elements", "with", "the", "same", "name" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L668-L684
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.canSubmitForm
private function canSubmitForm(\DOMElement $node) { $type = $node->hasAttribute('type') ? $node->getAttribute('type') : null; if ('input' === $node->nodeName && in_array($type, array('submit', 'image'), true)) { return true; } return 'button' === $node->nodeName && (null === $type || 'submit' === $type); }
php
private function canSubmitForm(\DOMElement $node) { $type = $node->hasAttribute('type') ? $node->getAttribute('type') : null; if ('input' === $node->nodeName && in_array($type, array('submit', 'image'), true)) { return true; } return 'button' === $node->nodeName && (null === $type || 'submit' === $type); }
[ "private", "function", "canSubmitForm", "(", "\\", "DOMElement", "$", "node", ")", "{", "$", "type", "=", "$", "node", "->", "hasAttribute", "(", "'type'", ")", "?", "$", "node", "->", "getAttribute", "(", "'type'", ")", ":", "null", ";", "if", "(", ...
Determines if a node can submit a form. @param \DOMElement $node Node. @return boolean
[ "Determines", "if", "a", "node", "can", "submit", "a", "form", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L727-L736
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.canResetForm
private function canResetForm(\DOMElement $node) { $type = $node->hasAttribute('type') ? $node->getAttribute('type') : null; return in_array($node->nodeName, array('input', 'button'), true) && 'reset' === $type; }
php
private function canResetForm(\DOMElement $node) { $type = $node->hasAttribute('type') ? $node->getAttribute('type') : null; return in_array($node->nodeName, array('input', 'button'), true) && 'reset' === $type; }
[ "private", "function", "canResetForm", "(", "\\", "DOMElement", "$", "node", ")", "{", "$", "type", "=", "$", "node", "->", "hasAttribute", "(", "'type'", ")", "?", "$", "node", "->", "getAttribute", "(", "'type'", ")", ":", "null", ";", "return", "in_...
Determines if a node can reset a form. @param \DOMElement $node Node. @return boolean
[ "Determines", "if", "a", "node", "can", "reset", "a", "form", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L745-L750
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getFormNodeId
private function getFormNodeId(\DOMElement $form) { return md5($form->getLineNo() . $form->getNodePath() . $form->nodeValue); }
php
private function getFormNodeId(\DOMElement $form) { return md5($form->getLineNo() . $form->getNodePath() . $form->nodeValue); }
[ "private", "function", "getFormNodeId", "(", "\\", "DOMElement", "$", "form", ")", "{", "return", "md5", "(", "$", "form", "->", "getLineNo", "(", ")", ".", "$", "form", "->", "getNodePath", "(", ")", ".", "$", "form", "->", "nodeValue", ")", ";", "}...
Returns form node unique identifier. @param \DOMElement $form @return string
[ "Returns", "form", "node", "unique", "identifier", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L759-L762
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getOptionValue
private function getOptionValue(\DOMElement $option) { if ($option->hasAttribute('value')) { return $option->getAttribute('value'); } if (!empty($option->nodeValue)) { return $option->nodeValue; } return '1'; // DomCrawler uses 1 by default if there is no text in the option }
php
private function getOptionValue(\DOMElement $option) { if ($option->hasAttribute('value')) { return $option->getAttribute('value'); } if (!empty($option->nodeValue)) { return $option->nodeValue; } return '1'; // DomCrawler uses 1 by default if there is no text in the option }
[ "private", "function", "getOptionValue", "(", "\\", "DOMElement", "$", "option", ")", "{", "if", "(", "$", "option", "->", "hasAttribute", "(", "'value'", ")", ")", "{", "return", "$", "option", "->", "getAttribute", "(", "'value'", ")", ";", "}", "if", ...
Gets the value of an option element @param \DOMElement $option @return string @see \Symfony\Component\DomCrawler\Field\ChoiceFormField::buildOptionValue
[ "Gets", "the", "value", "of", "an", "option", "element" ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L773-L784
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.mergeForms
private function mergeForms(Form $to, Form $from) { foreach ($from->all() as $name => $field) { $fieldReflection = new \ReflectionObject($field); $nodeReflection = $fieldReflection->getProperty('node'); $valueReflection = $fieldReflection->getProperty('value'); $nodeReflection->setAccessible(true); $valueReflection->setAccessible(true); $isIgnoredField = $field instanceof InputFormField && in_array($nodeReflection->getValue($field)->getAttribute('type'), array('submit', 'button', 'image'), true); if (!$isIgnoredField) { $valueReflection->setValue($to[$name], $valueReflection->getValue($field)); } } }
php
private function mergeForms(Form $to, Form $from) { foreach ($from->all() as $name => $field) { $fieldReflection = new \ReflectionObject($field); $nodeReflection = $fieldReflection->getProperty('node'); $valueReflection = $fieldReflection->getProperty('value'); $nodeReflection->setAccessible(true); $valueReflection->setAccessible(true); $isIgnoredField = $field instanceof InputFormField && in_array($nodeReflection->getValue($field)->getAttribute('type'), array('submit', 'button', 'image'), true); if (!$isIgnoredField) { $valueReflection->setValue($to[$name], $valueReflection->getValue($field)); } } }
[ "private", "function", "mergeForms", "(", "Form", "$", "to", ",", "Form", "$", "from", ")", "{", "foreach", "(", "$", "from", "->", "all", "(", ")", "as", "$", "name", "=>", "$", "field", ")", "{", "$", "fieldReflection", "=", "new", "\\", "Reflect...
Merges second form values into first one. @param Form $to merging target @param Form $from merging source
[ "Merges", "second", "form", "values", "into", "first", "one", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L792-L809
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getCrawlerNode
private function getCrawlerNode(Crawler $crawler) { $node = null; if ($crawler instanceof \Iterator) { // for symfony 2.3 compatibility as getNode is not public before symfony 2.4 $crawler->rewind(); $node = $crawler->current(); } else { $node = $crawler->getNode(0); } if (null !== $node) { return $node; } throw new DriverException('The element does not exist'); }
php
private function getCrawlerNode(Crawler $crawler) { $node = null; if ($crawler instanceof \Iterator) { // for symfony 2.3 compatibility as getNode is not public before symfony 2.4 $crawler->rewind(); $node = $crawler->current(); } else { $node = $crawler->getNode(0); } if (null !== $node) { return $node; } throw new DriverException('The element does not exist'); }
[ "private", "function", "getCrawlerNode", "(", "Crawler", "$", "crawler", ")", "{", "$", "node", "=", "null", ";", "if", "(", "$", "crawler", "instanceof", "\\", "Iterator", ")", "{", "// for symfony 2.3 compatibility as getNode is not public before symfony 2.4", "$", ...
Returns DOMElement from crawler instance. @param Crawler $crawler @return \DOMElement @throws DriverException when the node does not exist
[ "Returns", "DOMElement", "from", "crawler", "instance", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L820-L837
minkphp/MinkBrowserKitDriver
src/BrowserKitDriver.php
BrowserKitDriver.getFilteredCrawler
private function getFilteredCrawler($xpath) { if (!count($crawler = $this->getCrawler()->filterXPath($xpath))) { throw new DriverException(sprintf('There is no element matching XPath "%s"', $xpath)); } return $crawler; }
php
private function getFilteredCrawler($xpath) { if (!count($crawler = $this->getCrawler()->filterXPath($xpath))) { throw new DriverException(sprintf('There is no element matching XPath "%s"', $xpath)); } return $crawler; }
[ "private", "function", "getFilteredCrawler", "(", "$", "xpath", ")", "{", "if", "(", "!", "count", "(", "$", "crawler", "=", "$", "this", "->", "getCrawler", "(", ")", "->", "filterXPath", "(", "$", "xpath", ")", ")", ")", "{", "throw", "new", "Drive...
Returns a crawler filtered for the given XPath, requiring at least 1 result. @param string $xpath @return Crawler @throws DriverException when no matching elements are found
[ "Returns", "a", "crawler", "filtered", "for", "the", "given", "XPath", "requiring", "at", "least", "1", "result", "." ]
train
https://github.com/minkphp/MinkBrowserKitDriver/blob/4a0b453c8da1f6035f526a8532c293bba742d00d/src/BrowserKitDriver.php#L848-L855
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/Client.php
Client.doRequest
public function doRequest($request, $location, $action, $version, $one_way) { return $this->__doRequest($request, $location, $action, $version, $one_way); }
php
public function doRequest($request, $location, $action, $version, $one_way) { return $this->__doRequest($request, $location, $action, $version, $one_way); }
[ "public", "function", "doRequest", "(", "$", "request", ",", "$", "location", ",", "$", "action", ",", "$", "version", ",", "$", "one_way", ")", "{", "return", "$", "this", "->", "__doRequest", "(", "$", "request", ",", "$", "location", ",", "$", "ac...
Do soap request @param string $request @param string $location @param string $action @param string $version @param string $one_way @return mixed
[ "Do", "soap", "request" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/Client.php#L154-L157
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/Client.php
Client.SoapCall
public function SoapCall($function, array $params, array $options = null, $inputHeader = null, &$outputHeaders = null ) { return $this->__soapCall($function, $params, $options, $inputHeader, $outputHeaders); }
php
public function SoapCall($function, array $params, array $options = null, $inputHeader = null, &$outputHeaders = null ) { return $this->__soapCall($function, $params, $options, $inputHeader, $outputHeaders); }
[ "public", "function", "SoapCall", "(", "$", "function", ",", "array", "$", "params", ",", "array", "$", "options", "=", "null", ",", "$", "inputHeader", "=", "null", ",", "&", "$", "outputHeaders", "=", "null", ")", "{", "return", "$", "this", "->", ...
Allias to do a soap call on the webservice client @param string $function @param array $params @param array $options @param null $inputHeader @param null $outputHeaders @return mixed
[ "Allias", "to", "do", "a", "soap", "call", "on", "the", "webservice", "client" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/Client.php#L183-L190
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/ServiceProvider.php
ServiceProvider.register
public function register() { $soapWrapper = new SoapWrapper(); if (is_array($this->app['config']['soapwrapper'])) { $soapWrapper->addByArray($this->app['config']['soapwrapper']); } $this->app->bindIf(SoapWrapper::class, function () use ($soapWrapper) { return $soapWrapper; }); }
php
public function register() { $soapWrapper = new SoapWrapper(); if (is_array($this->app['config']['soapwrapper'])) { $soapWrapper->addByArray($this->app['config']['soapwrapper']); } $this->app->bindIf(SoapWrapper::class, function () use ($soapWrapper) { return $soapWrapper; }); }
[ "public", "function", "register", "(", ")", "{", "$", "soapWrapper", "=", "new", "SoapWrapper", "(", ")", ";", "if", "(", "is_array", "(", "$", "this", "->", "app", "[", "'config'", "]", "[", "'soapwrapper'", "]", ")", ")", "{", "$", "soapWrapper", "...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/ServiceProvider.php#L24-L35
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/SoapWrapper.php
SoapWrapper.add
public function add($name, Closure $closure) { if (!$this->has($name)) { $service = new Service(); $closure($service); $this->services[$name] = $service; return $this; } throw new ServiceAlreadyExists("Service '" . $name . "' already exists."); }
php
public function add($name, Closure $closure) { if (!$this->has($name)) { $service = new Service(); $closure($service); $this->services[$name] = $service; return $this; } throw new ServiceAlreadyExists("Service '" . $name . "' already exists."); }
[ "public", "function", "add", "(", "$", "name", ",", "Closure", "$", "closure", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "$", "service", "=", "new", "Service", "(", ")", ";", "$", "closure", "(", "$", ...
Add a new service to the wrapper @param string $name @param Closure $closure @return $this @throws ServiceAlreadyExists
[ "Add", "a", "new", "service", "to", "the", "wrapper" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/SoapWrapper.php#L35-L48
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/SoapWrapper.php
SoapWrapper.addByArray
public function addByArray(array $services = []) { if (!empty($services)) { foreach ($services as $name => $methods) { if (!$this->has($name)) { $service = new Service(); foreach ($methods as $method => $value) { if (method_exists($service, $method)) { $service->{$method}($value); } else { throw new ServiceMethodNotExists(sprintf( "Method '%s' does not exists on the %s service.", $method, $name )); } } $this->services[$name] = $service; continue; } throw new ServiceAlreadyExists(sprintf( "Service '%s' already exists.", $name )); } } return $this; }
php
public function addByArray(array $services = []) { if (!empty($services)) { foreach ($services as $name => $methods) { if (!$this->has($name)) { $service = new Service(); foreach ($methods as $method => $value) { if (method_exists($service, $method)) { $service->{$method}($value); } else { throw new ServiceMethodNotExists(sprintf( "Method '%s' does not exists on the %s service.", $method, $name )); } } $this->services[$name] = $service; continue; } throw new ServiceAlreadyExists(sprintf( "Service '%s' already exists.", $name )); } } return $this; }
[ "public", "function", "addByArray", "(", "array", "$", "services", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "services", ")", ")", "{", "foreach", "(", "$", "services", "as", "$", "name", "=>", "$", "methods", ")", "{", "if", "(...
Add services by array @param array $services @return $this @throws ServiceAlreadyExists @throws ServiceMethodNotExists
[ "Add", "services", "by", "array" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/SoapWrapper.php#L60-L92
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/SoapWrapper.php
SoapWrapper.client
public function client($name, Closure $closure = null) { if ($this->has($name)) { /** @var Service $service */ $service = $this->services[$name]; if (is_null($service->getClient())) { $client = new Client($service->getWsdl(), $service->getOptions(), $service->getHeaders()); $service->client($client); } else { $client = $service->getClient(); } return $closure($client); } throw new ServiceNotFound("Service '" . $name . "' not found."); }
php
public function client($name, Closure $closure = null) { if ($this->has($name)) { /** @var Service $service */ $service = $this->services[$name]; if (is_null($service->getClient())) { $client = new Client($service->getWsdl(), $service->getOptions(), $service->getHeaders()); $service->client($client); } else { $client = $service->getClient(); } return $closure($client); } throw new ServiceNotFound("Service '" . $name . "' not found."); }
[ "public", "function", "client", "(", "$", "name", ",", "Closure", "$", "closure", "=", "null", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "name", ")", ")", "{", "/** @var Service $service */", "$", "service", "=", "$", "this", "->", "se...
Get the client @param string $name @param Closure $closure @return mixed @throws ServiceNotFound
[ "Get", "the", "client" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/SoapWrapper.php#L103-L121
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/SoapWrapper.php
SoapWrapper.call
public function call($call, $data = [], $options = []) { list($name, $function) = explode('.', $call, 2); return $this->client($name, function ($client) use ($function, $data, $options) { /** @var Client $client */ return $client->SoapCall($function, $data, $options); }); }
php
public function call($call, $data = [], $options = []) { list($name, $function) = explode('.', $call, 2); return $this->client($name, function ($client) use ($function, $data, $options) { /** @var Client $client */ return $client->SoapCall($function, $data, $options); }); }
[ "public", "function", "call", "(", "$", "call", ",", "$", "data", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "list", "(", "$", "name", ",", "$", "function", ")", "=", "explode", "(", "'.'", ",", "$", "call", ",", "2", ")", ...
A easy access call method @param string $call @param array $data @return mixed
[ "A", "easy", "access", "call", "method" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/SoapWrapper.php#L131-L139
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/Service.php
Service.getClassmap
public function getClassmap() { $classmap = $this->classmap; $classes = [] ; if (!empty($classmap)) { foreach ($classmap as $class) { // Can't use end because of strict mode :( $name = current(array_slice(explode('\\', $class), -1, 1, true)); $classes[$name] = $class; } } return $classes; }
php
public function getClassmap() { $classmap = $this->classmap; $classes = [] ; if (!empty($classmap)) { foreach ($classmap as $class) { // Can't use end because of strict mode :( $name = current(array_slice(explode('\\', $class), -1, 1, true)); $classes[$name] = $class; } } return $classes; }
[ "public", "function", "getClassmap", "(", ")", "{", "$", "classmap", "=", "$", "this", "->", "classmap", ";", "$", "classes", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "classmap", ")", ")", "{", "foreach", "(", "$", "classmap", "as", ...
Get the classmap @return array
[ "Get", "the", "classmap" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/Service.php#L176-L191
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/Service.php
Service.getOptions
public function getOptions() { $options = [ 'trace' => $this->getTrace(), 'cache_wsdl' => $this->getCache(), 'classmap' => $this->getClassmap(), ]; if ($this->certificate) { $options['local_cert'] = $this->certificate; } $this->options = array_merge($options, $this->options); return $this->options; }
php
public function getOptions() { $options = [ 'trace' => $this->getTrace(), 'cache_wsdl' => $this->getCache(), 'classmap' => $this->getClassmap(), ]; if ($this->certificate) { $options['local_cert'] = $this->certificate; } $this->options = array_merge($options, $this->options); return $this->options; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "options", "=", "[", "'trace'", "=>", "$", "this", "->", "getTrace", "(", ")", ",", "'cache_wsdl'", "=>", "$", "this", "->", "getCache", "(", ")", ",", "'classmap'", "=>", "$", "this", "->", "ge...
Get the extra options @return array
[ "Get", "the", "extra", "options" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/Service.php#L212-L227
artisaninweb/laravel-soap
src/Artisaninweb/SoapWrapper/Service.php
Service.header
public function header($namespace, $name, $data = null, $mustUnderstand = false, $actor = null) { if ($actor) { $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand, $actor); } else { $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand); } return $this; }
php
public function header($namespace, $name, $data = null, $mustUnderstand = false, $actor = null) { if ($actor) { $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand, $actor); } else { $this->headers[] = new SoapHeader($namespace, $name, $data, $mustUnderstand); } return $this; }
[ "public", "function", "header", "(", "$", "namespace", ",", "$", "name", ",", "$", "data", "=", "null", ",", "$", "mustUnderstand", "=", "false", ",", "$", "actor", "=", "null", ")", "{", "if", "(", "$", "actor", ")", "{", "$", "this", "->", "hea...
Create a new SoapHeader @param string $namespace @param string $name @param null $data @param bool $mustUnderstand @param null $actor @return $this
[ "Create", "a", "new", "SoapHeader" ]
train
https://github.com/artisaninweb/laravel-soap/blob/48f16b0d56c565bbe776d3242865e4b5c47d53e4/src/Artisaninweb/SoapWrapper/Service.php#L266-L275
spatie/laravel-menu
src/View.php
View.create
public static function create(string $name, array $data = []) { $view = new static($name, $data); if (array_key_exists('url', $data)) { $view->setUrl($data['url']); } return $view; }
php
public static function create(string $name, array $data = []) { $view = new static($name, $data); if (array_key_exists('url', $data)) { $view->setUrl($data['url']); } return $view; }
[ "public", "static", "function", "create", "(", "string", "$", "name", ",", "array", "$", "data", "=", "[", "]", ")", "{", "$", "view", "=", "new", "static", "(", "$", "name", ",", "$", "data", ")", ";", "if", "(", "array_key_exists", "(", "'url'", ...
@param string $name @param array $data @return static
[ "@param", "string", "$name", "@param", "array", "$data" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/View.php#L45-L54
spatie/laravel-menu
src/Link.php
Link.toUrl
public static function toUrl(string $path, string $text, $parameters = [], $secure = null) { return static::to(url($path, $parameters, $secure), $text); }
php
public static function toUrl(string $path, string $text, $parameters = [], $secure = null) { return static::to(url($path, $parameters, $secure), $text); }
[ "public", "static", "function", "toUrl", "(", "string", "$", "path", ",", "string", "$", "text", ",", "$", "parameters", "=", "[", "]", ",", "$", "secure", "=", "null", ")", "{", "return", "static", "::", "to", "(", "url", "(", "$", "path", ",", ...
@param string $path @param string $text @param mixed $parameters @param bool|null $secure @return static
[ "@param", "string", "$path", "@param", "string", "$text", "@param", "mixed", "$parameters", "@param", "bool|null", "$secure" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Link.php#L20-L23
spatie/laravel-menu
src/Link.php
Link.toAction
public static function toAction($action, string $text, $parameters = [], bool $absolute = true) { if (is_array($action)) { $action = implode('@', $action); } return static::to(action($action, $parameters, $absolute), $text); }
php
public static function toAction($action, string $text, $parameters = [], bool $absolute = true) { if (is_array($action)) { $action = implode('@', $action); } return static::to(action($action, $parameters, $absolute), $text); }
[ "public", "static", "function", "toAction", "(", "$", "action", ",", "string", "$", "text", ",", "$", "parameters", "=", "[", "]", ",", "bool", "$", "absolute", "=", "true", ")", "{", "if", "(", "is_array", "(", "$", "action", ")", ")", "{", "$", ...
@param string|array $action @param string $text @param mixed $parameters @param bool $absolute @return static
[ "@param", "string|array", "$action", "@param", "string", "$text", "@param", "mixed", "$parameters", "@param", "bool", "$absolute" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Link.php#L33-L40
spatie/laravel-menu
src/Link.php
Link.toRoute
public static function toRoute(string $name, string $text, $parameters = [], $absolute = true) { return static::to(route($name, $parameters, $absolute), $text); }
php
public static function toRoute(string $name, string $text, $parameters = [], $absolute = true) { return static::to(route($name, $parameters, $absolute), $text); }
[ "public", "static", "function", "toRoute", "(", "string", "$", "name", ",", "string", "$", "text", ",", "$", "parameters", "=", "[", "]", ",", "$", "absolute", "=", "true", ")", "{", "return", "static", "::", "to", "(", "route", "(", "$", "name", "...
@param string $name @param string $text @param mixed $parameters @param bool $absolute @return static
[ "@param", "string", "$name", "@param", "string", "$text", "@param", "mixed", "$parameters", "@param", "bool", "$absolute" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Link.php#L50-L53
spatie/laravel-menu
src/Menu.php
Menu.url
public function url(string $path, string $text, $parameters = [], $secure = null) { return $this->add(Link::toUrl($path, $text, $parameters, $secure)); }
php
public function url(string $path, string $text, $parameters = [], $secure = null) { return $this->add(Link::toUrl($path, $text, $parameters, $secure)); }
[ "public", "function", "url", "(", "string", "$", "path", ",", "string", "$", "text", ",", "$", "parameters", "=", "[", "]", ",", "$", "secure", "=", "null", ")", "{", "return", "$", "this", "->", "add", "(", "Link", "::", "toUrl", "(", "$", "path...
@param string $path @param string $text @param mixed $parameters @param bool|null $secure @return $this
[ "@param", "string", "$path", "@param", "string", "$text", "@param", "mixed", "$parameters", "@param", "bool|null", "$secure" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L43-L46
spatie/laravel-menu
src/Menu.php
Menu.action
public function action($action, string $text, $parameters = [], bool $absolute = true) { return $this->add(Link::toAction($action, $text, $parameters, $absolute)); }
php
public function action($action, string $text, $parameters = [], bool $absolute = true) { return $this->add(Link::toAction($action, $text, $parameters, $absolute)); }
[ "public", "function", "action", "(", "$", "action", ",", "string", "$", "text", ",", "$", "parameters", "=", "[", "]", ",", "bool", "$", "absolute", "=", "true", ")", "{", "return", "$", "this", "->", "add", "(", "Link", "::", "toAction", "(", "$",...
@param string|array $action @param string $text @param mixed $parameters @param bool $absolute @return $this
[ "@param", "string|array", "$action", "@param", "string", "$text", "@param", "mixed", "$parameters", "@param", "bool", "$absolute" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L56-L59
spatie/laravel-menu
src/Menu.php
Menu.route
public function route(string $name, string $text, $parameters = [], bool $absolute = true) { return $this->add(Link::toRoute($name, $text, $parameters, $absolute)); }
php
public function route(string $name, string $text, $parameters = [], bool $absolute = true) { return $this->add(Link::toRoute($name, $text, $parameters, $absolute)); }
[ "public", "function", "route", "(", "string", "$", "name", ",", "string", "$", "text", ",", "$", "parameters", "=", "[", "]", ",", "bool", "$", "absolute", "=", "true", ")", "{", "return", "$", "this", "->", "add", "(", "Link", "::", "toRoute", "("...
@param string $name @param string $text @param mixed $parameters @param bool $absolute @return $this
[ "@param", "string", "$name", "@param", "string", "$text", "@param", "mixed", "$parameters", "@param", "bool", "$absolute" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L69-L72
spatie/laravel-menu
src/Menu.php
Menu.view
public function view(string $name, array $data = []) { return $this->add(View::create($name, $data)); }
php
public function view(string $name, array $data = []) { return $this->add(View::create($name, $data)); }
[ "public", "function", "view", "(", "string", "$", "name", ",", "array", "$", "data", "=", "[", "]", ")", "{", "return", "$", "this", "->", "add", "(", "View", "::", "create", "(", "$", "name", ",", "$", "data", ")", ")", ";", "}" ]
@param string $name @param array $data @return $this
[ "@param", "string", "$name", "@param", "array", "$data" ]
train
https://github.com/spatie/laravel-menu/blob/235eaf5aad88f4f7f76862ae9d8aa768be76626d/src/Menu.php#L80-L83