repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
phingofficial/phing
classes/phing/tasks/ext/XmlLintTask.php
XmlLintTask.errorHandler
public function errorHandler($level, $message, $file, $line, $context) { $matches = []; preg_match('/^.*\(\): (.*)$/', $message, $matches); $this->log($matches[1], Project::MSG_ERR); }
php
public function errorHandler($level, $message, $file, $line, $context) { $matches = []; preg_match('/^.*\(\): (.*)$/', $message, $matches); $this->log($matches[1], Project::MSG_ERR); }
[ "public", "function", "errorHandler", "(", "$", "level", ",", "$", "message", ",", "$", "file", ",", "$", "line", ",", "$", "context", ")", "{", "$", "matches", "=", "[", "]", ";", "preg_match", "(", "'/^.*\\(\\): (.*)$/'", ",", "$", "message", ",", ...
Local error handler to catch validation errors and log them through Phing @param int $level @param string $message @param string $file @param int $line @param mixed $context @return void
[ "Local", "error", "handler", "to", "catch", "validation", "errors", "and", "log", "them", "through", "Phing" ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/XmlLintTask.php#L186-L191
train
phingofficial/phing
classes/phing/tasks/system/condition/FilesMatch.php
FilesMatch.evaluate
public function evaluate() { if ($this->file1 == null || $this->file2 == null) { throw new BuildException("both file1 and file2 are required in filesmatch"); } $fu = new FileUtils; return $fu->contentEquals($this->file1, $this->file2); }
php
public function evaluate() { if ($this->file1 == null || $this->file2 == null) { throw new BuildException("both file1 and file2 are required in filesmatch"); } $fu = new FileUtils; return $fu->contentEquals($this->file1, $this->file2); }
[ "public", "function", "evaluate", "(", ")", "{", "if", "(", "$", "this", "->", "file1", "==", "null", "||", "$", "this", "->", "file2", "==", "null", ")", "{", "throw", "new", "BuildException", "(", "\"both file1 and file2 are required in filesmatch\"", ")", ...
comparison method of the interface @return bool if the files are equal @throws BuildException if it all went pear-shaped
[ "comparison", "method", "of", "the", "interface" ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/condition/FilesMatch.php#L61-L70
train
phingofficial/phing
classes/phing/tasks/ext/ioncube/IoncubeEncoderTask.php
IoncubeEncoderTask.constructArguments
private function constructArguments() { $arguments = ''; foreach ($this->ionSwitches as $name => $value) { if ($value) { $arguments .= "--$name "; } } foreach ($this->ionOptions as $name => $value) { /** * action-if-no-loader value is a php source snippet so it is * better to handle it this way to prevent quote problems! */ if ($name == 'action-if-no-loader') { $arguments .= "--$name \"$value\" "; } else { $arguments .= "--$name '$value' "; } } foreach ($this->ionOptionsXS as $name => $value) { foreach (explode(' ', $value) as $arg) { $arguments .= "--$name '$arg' "; } } foreach ($this->comments as $comment) { $arguments .= "--add-comment '" . $comment->getValue() . "' "; } if (!empty($this->targetOption)) { switch ($this->targetOption) { case "replace": case "merge": case "update": case "rename": $arguments .= "--" . $this->targetOption . "-target "; break; default: throw new BuildException("Unknown target option '" . $this->targetOption . "'"); } } if ($this->fromDir != '') { $arguments .= $this->fromDir . ' '; } if ($this->toDir != '') { $arguments .= "-o " . $this->toDir . ' '; } return $arguments; }
php
private function constructArguments() { $arguments = ''; foreach ($this->ionSwitches as $name => $value) { if ($value) { $arguments .= "--$name "; } } foreach ($this->ionOptions as $name => $value) { /** * action-if-no-loader value is a php source snippet so it is * better to handle it this way to prevent quote problems! */ if ($name == 'action-if-no-loader') { $arguments .= "--$name \"$value\" "; } else { $arguments .= "--$name '$value' "; } } foreach ($this->ionOptionsXS as $name => $value) { foreach (explode(' ', $value) as $arg) { $arguments .= "--$name '$arg' "; } } foreach ($this->comments as $comment) { $arguments .= "--add-comment '" . $comment->getValue() . "' "; } if (!empty($this->targetOption)) { switch ($this->targetOption) { case "replace": case "merge": case "update": case "rename": $arguments .= "--" . $this->targetOption . "-target "; break; default: throw new BuildException("Unknown target option '" . $this->targetOption . "'"); } } if ($this->fromDir != '') { $arguments .= $this->fromDir . ' '; } if ($this->toDir != '') { $arguments .= "-o " . $this->toDir . ' '; } return $arguments; }
[ "private", "function", "constructArguments", "(", ")", "{", "$", "arguments", "=", "''", ";", "foreach", "(", "$", "this", "->", "ionSwitches", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "arguments", ".="...
Constructs an argument string for the ionCube encoder
[ "Constructs", "an", "argument", "string", "for", "the", "ionCube", "encoder" ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/ioncube/IoncubeEncoderTask.php#L624-L678
train
phingofficial/phing
classes/phing/system/io/InputStream.php
InputStream.mark
public function mark() { if (!$this->markSupported()) { throw new IOException(get_class($this) . " does not support mark() and reset() methods."); } $this->mark = $this->currentPosition; }
php
public function mark() { if (!$this->markSupported()) { throw new IOException(get_class($this) . " does not support mark() and reset() methods."); } $this->mark = $this->currentPosition; }
[ "public", "function", "mark", "(", ")", "{", "if", "(", "!", "$", "this", "->", "markSupported", "(", ")", ")", "{", "throw", "new", "IOException", "(", "get_class", "(", "$", "this", ")", ".", "\" does not support mark() and reset() methods.\"", ")", ";", ...
Marks the current position in this input stream. @throws IOException - if the underlying stream doesn't support this method.
[ "Marks", "the", "current", "position", "in", "this", "input", "stream", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/InputStream.php#L114-L120
train
phingofficial/phing
classes/phing/system/io/InputStream.php
InputStream.reset
public function reset() { if (!$this->markSupported()) { throw new IOException(get_class($this) . " does not support mark() and reset() methods."); } // goes back to last mark, by default this would be 0 (i.e. rewind file). fseek($this->stream, SEEK_SET, $this->mark); $this->mark = 0; }
php
public function reset() { if (!$this->markSupported()) { throw new IOException(get_class($this) . " does not support mark() and reset() methods."); } // goes back to last mark, by default this would be 0 (i.e. rewind file). fseek($this->stream, SEEK_SET, $this->mark); $this->mark = 0; }
[ "public", "function", "reset", "(", ")", "{", "if", "(", "!", "$", "this", "->", "markSupported", "(", ")", ")", "{", "throw", "new", "IOException", "(", "get_class", "(", "$", "this", ")", ".", "\" does not support mark() and reset() methods.\"", ")", ";", ...
Repositions this stream to the position at the time the mark method was last called on this input stream. @throws IOException - if the underlying stream doesn't support this method.
[ "Repositions", "this", "stream", "to", "the", "position", "at", "the", "time", "the", "mark", "method", "was", "last", "called", "on", "this", "input", "stream", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/InputStream.php#L137-L145
train
phingofficial/phing
classes/phing/system/io/InputStream.php
InputStream.close
public function close() { if ($this->stream === null) { return; } if (false === @fclose($this->stream)) { // FAILED. $msg = "Cannot fclose " . $this->__toString() . " $php_errormsg"; throw new IOException($msg); } $this->stream = null; }
php
public function close() { if ($this->stream === null) { return; } if (false === @fclose($this->stream)) { // FAILED. $msg = "Cannot fclose " . $this->__toString() . " $php_errormsg"; throw new IOException($msg); } $this->stream = null; }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "stream", "===", "null", ")", "{", "return", ";", "}", "if", "(", "false", "===", "@", "fclose", "(", "$", "this", "->", "stream", ")", ")", "{", "// FAILED.", "$", "msg"...
Closes stream. @throws IOException if stream cannot be closed (note that calling close() on an already-closed stream will not raise an exception)
[ "Closes", "stream", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/system/io/InputStream.php#L152-L163
train
phingofficial/phing
classes/phing/tasks/system/AppendTask/TextElement.php
TextElement.setFile
public function setFile(PhingFile $file) { // non-existing files are not allowed if (!$file->exists()) { throw new BuildException("File " . $file . " does not exist."); } $reader = null; try { if ($this->encoding == null) { $reader = new BufferedReader(new FileReader($file)); } else { $reader = new BufferedReader( new InputStreamReader(new FileInputStream($file)) ); } $this->value = $reader->read(); } catch (IOException $ex) { $reader->close(); throw new BuildException($ex); } $reader->close(); }
php
public function setFile(PhingFile $file) { // non-existing files are not allowed if (!$file->exists()) { throw new BuildException("File " . $file . " does not exist."); } $reader = null; try { if ($this->encoding == null) { $reader = new BufferedReader(new FileReader($file)); } else { $reader = new BufferedReader( new InputStreamReader(new FileInputStream($file)) ); } $this->value = $reader->read(); } catch (IOException $ex) { $reader->close(); throw new BuildException($ex); } $reader->close(); }
[ "public", "function", "setFile", "(", "PhingFile", "$", "file", ")", "{", "// non-existing files are not allowed", "if", "(", "!", "$", "file", "->", "exists", "(", ")", ")", "{", "throw", "new", "BuildException", "(", "\"File \"", ".", "$", "file", ".", "...
set the text using a file @param PhingFile $file the file to use @throws BuildException if the file does not exist, or cannot be read
[ "set", "the", "text", "using", "a", "file" ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/AppendTask/TextElement.php#L62-L84
train
phingofficial/phing
classes/phing/tasks/ext/phpmd/PHPMDFormatterElement.php
PHPMDFormatterElement.getRenderer
public function getRenderer() { if (!class_exists('\\PHPMD\\Writer\\StreamWriter')) { $renderClass = 'PHP_PMD_RENDERER_' . $this->className; $writerClass = 'PHP_PMD_Writer_Stream'; include_once 'PHP/PMD/Renderer/' . $this->className . '.php'; include_once 'PHP/PMD/Writer/Stream.php'; } else { $renderClass = 'PHPMD\Renderer\\' . $this->className; $writerClass = '\PHPMD\Writer\StreamWriter'; } $renderer = new $renderClass(); // Create a report stream if ($this->getUseFile() === false || $this->getOutfile() === null) { $stream = STDOUT; } else { $stream = fopen($this->getOutfile()->getAbsoluteFile(), 'wb'); } $renderer->setWriter(new $writerClass($stream)); return $renderer; }
php
public function getRenderer() { if (!class_exists('\\PHPMD\\Writer\\StreamWriter')) { $renderClass = 'PHP_PMD_RENDERER_' . $this->className; $writerClass = 'PHP_PMD_Writer_Stream'; include_once 'PHP/PMD/Renderer/' . $this->className . '.php'; include_once 'PHP/PMD/Writer/Stream.php'; } else { $renderClass = 'PHPMD\Renderer\\' . $this->className; $writerClass = '\PHPMD\Writer\StreamWriter'; } $renderer = new $renderClass(); // Create a report stream if ($this->getUseFile() === false || $this->getOutfile() === null) { $stream = STDOUT; } else { $stream = fopen($this->getOutfile()->getAbsoluteFile(), 'wb'); } $renderer->setWriter(new $writerClass($stream)); return $renderer; }
[ "public", "function", "getRenderer", "(", ")", "{", "if", "(", "!", "class_exists", "(", "'\\\\PHPMD\\\\Writer\\\\StreamWriter'", ")", ")", "{", "$", "renderClass", "=", "'PHP_PMD_RENDERER_'", ".", "$", "this", "->", "className", ";", "$", "writerClass", "=", ...
Creates a report renderer instance based on the formatter type. @return PHP_PMD_AbstractRenderer @throws BuildException When the specified renderer does not exist.
[ "Creates", "a", "report", "renderer", "instance", "based", "on", "the", "formatter", "type", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/phpmd/PHPMDFormatterElement.php#L144-L168
train
phingofficial/phing
classes/phing/tasks/ext/SymfonyConsole/SymfonyConsoleTask.php
SymfonyConsoleTask.getCmdString
public function getCmdString() { // Add no-debug arg if it isn't already present if (!$this->debug && !$this->isNoDebugArgPresent()) { $this->createArg()->setName("no-debug"); } $cmd = [ Commandline::quoteArgument($this->console), $this->command, implode(' ', $this->args) ]; $cmd = implode(' ', $cmd); return $cmd; }
php
public function getCmdString() { // Add no-debug arg if it isn't already present if (!$this->debug && !$this->isNoDebugArgPresent()) { $this->createArg()->setName("no-debug"); } $cmd = [ Commandline::quoteArgument($this->console), $this->command, implode(' ', $this->args) ]; $cmd = implode(' ', $cmd); return $cmd; }
[ "public", "function", "getCmdString", "(", ")", "{", "// Add no-debug arg if it isn't already present", "if", "(", "!", "$", "this", "->", "debug", "&&", "!", "$", "this", "->", "isNoDebugArgPresent", "(", ")", ")", "{", "$", "this", "->", "createArg", "(", ...
Gets the command string to be executed @return string
[ "Gets", "the", "command", "string", "to", "be", "executed" ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/SymfonyConsole/SymfonyConsoleTask.php#L215-L229
train
phingofficial/phing
classes/phing/tasks/ext/SymfonyConsole/SymfonyConsoleTask.php
SymfonyConsoleTask.main
public function main() { $cmd = $this->getCmdString(); $this->silent ?: $this->log("executing $cmd"); $return = null; $output = []; exec($cmd, $output, $return); $lines = implode("\r\n", $output); $this->silent ?: $this->log($lines, Project::MSG_INFO); if ($this->propertyName != null) { $this->project->setProperty($this->propertyName, $lines); } if ($return != 0 && $this->checkreturn) { $this->log('Task exited with code: ' . $return, Project::MSG_ERR); throw new BuildException("SymfonyConsole execution failed"); } }
php
public function main() { $cmd = $this->getCmdString(); $this->silent ?: $this->log("executing $cmd"); $return = null; $output = []; exec($cmd, $output, $return); $lines = implode("\r\n", $output); $this->silent ?: $this->log($lines, Project::MSG_INFO); if ($this->propertyName != null) { $this->project->setProperty($this->propertyName, $lines); } if ($return != 0 && $this->checkreturn) { $this->log('Task exited with code: ' . $return, Project::MSG_ERR); throw new BuildException("SymfonyConsole execution failed"); } }
[ "public", "function", "main", "(", ")", "{", "$", "cmd", "=", "$", "this", "->", "getCmdString", "(", ")", ";", "$", "this", "->", "silent", "?", ":", "$", "this", "->", "log", "(", "\"executing $cmd\"", ")", ";", "$", "return", "=", "null", ";", ...
executes the synfony console application
[ "executes", "the", "synfony", "console", "application" ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/SymfonyConsole/SymfonyConsoleTask.php#L234-L255
train
phingofficial/phing
classes/phing/tasks/ext/MailTask.php
MailTask.setBackendParams
public function setBackendParams($backendParams) { $params = explode(',', $backendParams); foreach ($params as $param) { $values = explode('=', $param); if (count($values) < 1) { continue; } if (count($values) == 1) { $this->backendParams[] = $values[0]; } else { $key = $values[0]; $value = $values[1]; $this->backendParams[$key] = $value; } } }
php
public function setBackendParams($backendParams) { $params = explode(',', $backendParams); foreach ($params as $param) { $values = explode('=', $param); if (count($values) < 1) { continue; } if (count($values) == 1) { $this->backendParams[] = $values[0]; } else { $key = $values[0]; $value = $values[1]; $this->backendParams[$key] = $value; } } }
[ "public", "function", "setBackendParams", "(", "$", "backendParams", ")", "{", "$", "params", "=", "explode", "(", "','", ",", "$", "backendParams", ")", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "values", "=", "explode", "...
Sets PEAR Mail backend params to use @param $backendParams
[ "Sets", "PEAR", "Mail", "backend", "params", "to", "use" ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/MailTask.php#L188-L207
train
phingofficial/phing
classes/phing/types/selectors/BaseSelector.php
BaseSelector.setError
public function setError($msg, Exception $cause = null) { if ($this->errmsg === null) { $this->errmsg = $msg; $this->cause = $cause; } }
php
public function setError($msg, Exception $cause = null) { if ($this->errmsg === null) { $this->errmsg = $msg; $this->cause = $cause; } }
[ "public", "function", "setError", "(", "$", "msg", ",", "Exception", "$", "cause", "=", "null", ")", "{", "if", "(", "$", "this", "->", "errmsg", "===", "null", ")", "{", "$", "this", "->", "errmsg", "=", "$", "msg", ";", "$", "this", "->", "caus...
Allows all selectors to indicate a setup error. Note that only the first error message is recorded. @param string $msg The error message any BuildException should throw. @param Exception $cause
[ "Allows", "all", "selectors", "to", "indicate", "a", "setup", "error", ".", "Note", "that", "only", "the", "first", "error", "message", "is", "recorded", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/types/selectors/BaseSelector.php#L51-L57
train
phingofficial/phing
classes/phing/tasks/ext/apigen/ApiGenTask.php
ApiGenTask.main
public function main() { if ('apigen' !== $this->executable && !is_file($this->executable)) { throw new BuildException(sprintf('Executable %s not found', $this->executable), $this->getLocation()); } if (!empty($this->options['config'])) { // Config check if (!is_file($this->options['config'])) { throw new BuildException( sprintf( 'Config file %s doesn\'t exist', $this->options['config'] ), $this->getLocation() ); } } else { // Source check if (empty($this->options['source'])) { throw new BuildException('Source is not set', $this->getLocation()); } // Destination check if (empty($this->options['destination'])) { throw new BuildException('Destination is not set', $this->getLocation()); } } // Source check if (!empty($this->options['source'])) { foreach ($this->options['source'] as $source) { if (!file_exists($source)) { throw new BuildException(sprintf('Source %s doesn\'t exist', $source), $this->getLocation()); } } } // Execute ApiGen exec( escapeshellcmd($this->executable) . ' ' . escapeshellcmd($this->action) . ' ' . $this->constructArguments(), $output, $return ); $logType = 0 === $return ? Project::MSG_INFO : Project::MSG_ERR; foreach ($output as $line) { $this->log($line, $logType); } }
php
public function main() { if ('apigen' !== $this->executable && !is_file($this->executable)) { throw new BuildException(sprintf('Executable %s not found', $this->executable), $this->getLocation()); } if (!empty($this->options['config'])) { // Config check if (!is_file($this->options['config'])) { throw new BuildException( sprintf( 'Config file %s doesn\'t exist', $this->options['config'] ), $this->getLocation() ); } } else { // Source check if (empty($this->options['source'])) { throw new BuildException('Source is not set', $this->getLocation()); } // Destination check if (empty($this->options['destination'])) { throw new BuildException('Destination is not set', $this->getLocation()); } } // Source check if (!empty($this->options['source'])) { foreach ($this->options['source'] as $source) { if (!file_exists($source)) { throw new BuildException(sprintf('Source %s doesn\'t exist', $source), $this->getLocation()); } } } // Execute ApiGen exec( escapeshellcmd($this->executable) . ' ' . escapeshellcmd($this->action) . ' ' . $this->constructArguments(), $output, $return ); $logType = 0 === $return ? Project::MSG_INFO : Project::MSG_ERR; foreach ($output as $line) { $this->log($line, $logType); } }
[ "public", "function", "main", "(", ")", "{", "if", "(", "'apigen'", "!==", "$", "this", "->", "executable", "&&", "!", "is_file", "(", "$", "this", "->", "executable", ")", ")", "{", "throw", "new", "BuildException", "(", "sprintf", "(", "'Executable %s ...
Runs ApiGen. @throws BuildException If something is wrong. @see Task::main()
[ "Runs", "ApiGen", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/apigen/ApiGenTask.php#L370-L418
train
phingofficial/phing
classes/phing/tasks/ext/apigen/ApiGenTask.php
ApiGenTask.constructArguments
protected function constructArguments() { $args = []; foreach ($this->options as $option => $value) { if (is_bool($value)) { $args[] = '--' . $option . '=' . ($value ? 'yes' : 'no'); } elseif (is_array($value)) { foreach ($value as $v) { $args[] = '--' . $option . '=' . escapeshellarg($v); } } else { $args[] = '--' . $option . '=' . escapeshellarg($value); } } return implode(' ', $args); }
php
protected function constructArguments() { $args = []; foreach ($this->options as $option => $value) { if (is_bool($value)) { $args[] = '--' . $option . '=' . ($value ? 'yes' : 'no'); } elseif (is_array($value)) { foreach ($value as $v) { $args[] = '--' . $option . '=' . escapeshellarg($v); } } else { $args[] = '--' . $option . '=' . escapeshellarg($value); } } return implode(' ', $args); }
[ "protected", "function", "constructArguments", "(", ")", "{", "$", "args", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "options", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", ...
Generates command line arguments for the ApiGen executable. @return string
[ "Generates", "command", "line", "arguments", "for", "the", "ApiGen", "executable", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/ext/apigen/ApiGenTask.php#L425-L441
train
phingofficial/phing
classes/phing/tasks/system/Retry.php
Retry.addTask
public function addTask(Task $t) { if ($this->nestedTask !== null) { throw new BuildException( 'The retry task container accepts a single nested task' . ' (which may be a sequential task container)' ); } $this->nestedTask = $t; }
php
public function addTask(Task $t) { if ($this->nestedTask !== null) { throw new BuildException( 'The retry task container accepts a single nested task' . ' (which may be a sequential task container)' ); } $this->nestedTask = $t; }
[ "public", "function", "addTask", "(", "Task", "$", "t", ")", "{", "if", "(", "$", "this", "->", "nestedTask", "!==", "null", ")", "{", "throw", "new", "BuildException", "(", "'The retry task container accepts a single nested task'", ".", "' (which may be a sequentia...
Set the task. @param Task $t the task to retry. @throws BuildException
[ "Set", "the", "task", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/Retry.php#L56-L65
train
phingofficial/phing
classes/phing/tasks/system/Retry.php
Retry.main
public function main() { $errorMessages = ''; for ($i = 0; $i <= $this->retryCount; $i++) { try { $this->nestedTask->perform(); break; } catch (Exception $e) { $errorMessages .= $e->getMessage(); if ($i >= $this->retryCount) { $taskName = $this->nestedTask->getTaskName(); $exceptionMessage = <<<EXCEPTION_MESSAGE Task [{$taskName}] failed after [{$this->retryCount}] attempts; giving up Error messages: $errorMessages EXCEPTION_MESSAGE; throw new BuildException( $exceptionMessage, $this->getLocation() ); } if ($this->retryDelay > 0) { $msg = sprintf( 'Attempt [%s]: error occurred; retrying after %s s...', $i, $this->retryDelay ); } else { $msg = sprintf( 'Attempt [%s]: error occurred; retrying...', $i ); } $this->log($msg, Project::MSG_INFO); $errorMessages .= PHP_EOL; if ($this->retryDelay > 0) { sleep($this->retryDelay); } } } }
php
public function main() { $errorMessages = ''; for ($i = 0; $i <= $this->retryCount; $i++) { try { $this->nestedTask->perform(); break; } catch (Exception $e) { $errorMessages .= $e->getMessage(); if ($i >= $this->retryCount) { $taskName = $this->nestedTask->getTaskName(); $exceptionMessage = <<<EXCEPTION_MESSAGE Task [{$taskName}] failed after [{$this->retryCount}] attempts; giving up Error messages: $errorMessages EXCEPTION_MESSAGE; throw new BuildException( $exceptionMessage, $this->getLocation() ); } if ($this->retryDelay > 0) { $msg = sprintf( 'Attempt [%s]: error occurred; retrying after %s s...', $i, $this->retryDelay ); } else { $msg = sprintf( 'Attempt [%s]: error occurred; retrying...', $i ); } $this->log($msg, Project::MSG_INFO); $errorMessages .= PHP_EOL; if ($this->retryDelay > 0) { sleep($this->retryDelay); } } } }
[ "public", "function", "main", "(", ")", "{", "$", "errorMessages", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "$", "this", "->", "retryCount", ";", "$", "i", "++", ")", "{", "try", "{", "$", "this", "->", "nestedTask",...
Perform the work. @throws BuildException if there is an error.
[ "Perform", "the", "work", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/Retry.php#L99-L142
train
phingofficial/phing
classes/phing/tasks/system/condition/ReferenceExistsCondition.php
ReferenceExistsCondition.evaluate
public function evaluate() { if ($this->refid === null) { throw new BuildException( "No ref attribute specified for reference-exists " . "condition" ); } $refs = $this->project->getReferences(); return !($refs[$this->refid] instanceof UnknownElement) && isset($refs[$this->refid]); }
php
public function evaluate() { if ($this->refid === null) { throw new BuildException( "No ref attribute specified for reference-exists " . "condition" ); } $refs = $this->project->getReferences(); return !($refs[$this->refid] instanceof UnknownElement) && isset($refs[$this->refid]); }
[ "public", "function", "evaluate", "(", ")", "{", "if", "(", "$", "this", "->", "refid", "===", "null", ")", "{", "throw", "new", "BuildException", "(", "\"No ref attribute specified for reference-exists \"", ".", "\"condition\"", ")", ";", "}", "$", "refs", "=...
Check whether the reference exists. @throws BuildException
[ "Check", "whether", "the", "reference", "exists", "." ]
4b1797694dc65505af496ca2e1a3470efb9e35e1
https://github.com/phingofficial/phing/blob/4b1797694dc65505af496ca2e1a3470efb9e35e1/classes/phing/tasks/system/condition/ReferenceExistsCondition.php#L43-L54
train
laravel-doctrine/orm
src/Loggers/Clockwork/DoctrineDataSource.php
DoctrineDataSource.resolve
public function resolve(Request $request) { $request->databaseQueries = array_merge($request->databaseQueries, $this->getDatabaseQueries()); return $request; }
php
public function resolve(Request $request) { $request->databaseQueries = array_merge($request->databaseQueries, $this->getDatabaseQueries()); return $request; }
[ "public", "function", "resolve", "(", "Request", "$", "request", ")", "{", "$", "request", "->", "databaseQueries", "=", "array_merge", "(", "$", "request", "->", "databaseQueries", ",", "$", "this", "->", "getDatabaseQueries", "(", ")", ")", ";", "return", ...
Adds ran database queries to the request @param Request $request @return Request
[ "Adds", "ran", "database", "queries", "to", "the", "request" ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Loggers/Clockwork/DoctrineDataSource.php#L48-L53
train
laravel-doctrine/orm
src/Loggers/Clockwork/DoctrineDataSource.php
DoctrineDataSource.getDatabaseQueries
protected function getDatabaseQueries() { $queries = []; foreach ($this->logger->queries as $query) { $queries[] = [ 'query' => $this->formatter->format($this->connection->getDatabasePlatform(), $query['sql'], $query['params']), 'duration' => $query['executionMS'] * 1000, 'connection' => $this->connection->getDriver()->getName() ]; } return $queries; }
php
protected function getDatabaseQueries() { $queries = []; foreach ($this->logger->queries as $query) { $queries[] = [ 'query' => $this->formatter->format($this->connection->getDatabasePlatform(), $query['sql'], $query['params']), 'duration' => $query['executionMS'] * 1000, 'connection' => $this->connection->getDriver()->getName() ]; } return $queries; }
[ "protected", "function", "getDatabaseQueries", "(", ")", "{", "$", "queries", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "logger", "->", "queries", "as", "$", "query", ")", "{", "$", "queries", "[", "]", "=", "[", "'query'", "=>", "$", ...
Returns an array of runnable queries and their durations from the internal array
[ "Returns", "an", "array", "of", "runnable", "queries", "and", "their", "durations", "from", "the", "internal", "array" ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Loggers/Clockwork/DoctrineDataSource.php#L58-L70
train
laravel-doctrine/orm
src/DoctrineServiceProvider.php
DoctrineServiceProvider.registerPresenceVerifierProvider
protected function registerPresenceVerifierProvider() { if ($this->isLumen()) { $this->app->singleton('validator', function () { $this->app->register(PresenceVerifierProvider::class); return $this->app->make('validator'); }); } else { $this->app->register(PresenceVerifierProvider::class); } }
php
protected function registerPresenceVerifierProvider() { if ($this->isLumen()) { $this->app->singleton('validator', function () { $this->app->register(PresenceVerifierProvider::class); return $this->app->make('validator'); }); } else { $this->app->register(PresenceVerifierProvider::class); } }
[ "protected", "function", "registerPresenceVerifierProvider", "(", ")", "{", "if", "(", "$", "this", "->", "isLumen", "(", ")", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'validator'", ",", "function", "(", ")", "{", "$", "this", "->", ...
Register the deferred service provider for the validation presence verifier
[ "Register", "the", "deferred", "service", "provider", "for", "the", "validation", "presence", "verifier" ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/DoctrineServiceProvider.php#L227-L238
train
laravel-doctrine/orm
src/DoctrineServiceProvider.php
DoctrineServiceProvider.bootExtensionManager
protected function bootExtensionManager() { $manager = $this->app->make(ExtensionManager::class); if ($manager->needsBooting()) { $this->app['events']->dispatch('doctrine.extensions.booting'); $this->app->make(ExtensionManager::class)->boot( $this->app['registry'] ); $this->app['events']->dispatch('doctrine.extensions.booted'); } }
php
protected function bootExtensionManager() { $manager = $this->app->make(ExtensionManager::class); if ($manager->needsBooting()) { $this->app['events']->dispatch('doctrine.extensions.booting'); $this->app->make(ExtensionManager::class)->boot( $this->app['registry'] ); $this->app['events']->dispatch('doctrine.extensions.booted'); } }
[ "protected", "function", "bootExtensionManager", "(", ")", "{", "$", "manager", "=", "$", "this", "->", "app", "->", "make", "(", "ExtensionManager", "::", "class", ")", ";", "if", "(", "$", "manager", "->", "needsBooting", "(", ")", ")", "{", "$", "th...
Boots the extension manager at the appropriate time depending on if the app is running as Laravel HTTP, Lumen HTTP or in a console environment
[ "Boots", "the", "extension", "manager", "at", "the", "appropriate", "time", "depending", "on", "if", "the", "app", "is", "running", "as", "Laravel", "HTTP", "Lumen", "HTTP", "or", "in", "a", "console", "environment" ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/DoctrineServiceProvider.php#L276-L289
train
laravel-doctrine/orm
src/DoctrineServiceProvider.php
DoctrineServiceProvider.extendNotificationChannel
public function extendNotificationChannel() { if ($this->app->bound(ChannelManager::class)) { $channel = $this->app['config']->get('doctrine.notifications.channel', 'database'); $this->app->make(ChannelManager::class)->extend($channel, function ($app) { return new DoctrineChannel($app['registry']); }); } }
php
public function extendNotificationChannel() { if ($this->app->bound(ChannelManager::class)) { $channel = $this->app['config']->get('doctrine.notifications.channel', 'database'); $this->app->make(ChannelManager::class)->extend($channel, function ($app) { return new DoctrineChannel($app['registry']); }); } }
[ "public", "function", "extendNotificationChannel", "(", ")", "{", "if", "(", "$", "this", "->", "app", "->", "bound", "(", "ChannelManager", "::", "class", ")", ")", "{", "$", "channel", "=", "$", "this", "->", "app", "[", "'config'", "]", "->", "get",...
Extend the database channel
[ "Extend", "the", "database", "channel" ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/DoctrineServiceProvider.php#L294-L303
train
laravel-doctrine/orm
src/DoctrineServiceProvider.php
DoctrineServiceProvider.registerEntityFactory
protected function registerEntityFactory() { $this->app->singleton(FakerGenerator::class, function () { return FakerFactory::create(); }); $this->app->singleton(EntityFactory::class, function ($app) { return EntityFactory::construct( $app->make(FakerGenerator::class), $app->make('registry'), database_path('factories') ); }); }
php
protected function registerEntityFactory() { $this->app->singleton(FakerGenerator::class, function () { return FakerFactory::create(); }); $this->app->singleton(EntityFactory::class, function ($app) { return EntityFactory::construct( $app->make(FakerGenerator::class), $app->make('registry'), database_path('factories') ); }); }
[ "protected", "function", "registerEntityFactory", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "FakerGenerator", "::", "class", ",", "function", "(", ")", "{", "return", "FakerFactory", "::", "create", "(", ")", ";", "}", ")", ";", "$...
Register the Entity factory instance in the container. @return void
[ "Register", "the", "Entity", "factory", "instance", "in", "the", "container", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/DoctrineServiceProvider.php#L310-L323
train
laravel-doctrine/orm
src/DoctrineServiceProvider.php
DoctrineServiceProvider.registerProxyAutoloader
public function registerProxyAutoloader() { $this->app->afterResolving(ManagerRegistry::class, function (ManagerRegistry $registry) { /** @var EntityManagerInterface $manager */ foreach ($registry->getManagers() as $manager) { Autoloader::register( $manager->getConfiguration()->getProxyDir(), $manager->getConfiguration()->getProxyNamespace() ); } }); }
php
public function registerProxyAutoloader() { $this->app->afterResolving(ManagerRegistry::class, function (ManagerRegistry $registry) { /** @var EntityManagerInterface $manager */ foreach ($registry->getManagers() as $manager) { Autoloader::register( $manager->getConfiguration()->getProxyDir(), $manager->getConfiguration()->getProxyNamespace() ); } }); }
[ "public", "function", "registerProxyAutoloader", "(", ")", "{", "$", "this", "->", "app", "->", "afterResolving", "(", "ManagerRegistry", "::", "class", ",", "function", "(", "ManagerRegistry", "$", "registry", ")", "{", "/** @var EntityManagerInterface $manager */", ...
Register proxy autoloader @return void
[ "Register", "proxy", "autoloader" ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/DoctrineServiceProvider.php#L330-L341
train
laravel-doctrine/orm
src/Configuration/LaravelNamingStrategy.php
LaravelNamingStrategy.joinColumnName
public function joinColumnName($propertyName) { return $this->str->snake($this->str->singular($propertyName)) . '_' . $this->referenceColumnName(); }
php
public function joinColumnName($propertyName) { return $this->str->snake($this->str->singular($propertyName)) . '_' . $this->referenceColumnName(); }
[ "public", "function", "joinColumnName", "(", "$", "propertyName", ")", "{", "return", "$", "this", "->", "str", "->", "snake", "(", "$", "this", "->", "str", "->", "singular", "(", "$", "propertyName", ")", ")", ".", "'_'", ".", "$", "this", "->", "r...
Returns a join column name for a property. @param string $propertyName A property name. @return string A join column name.
[ "Returns", "a", "join", "column", "name", "for", "a", "property", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Configuration/LaravelNamingStrategy.php#L64-L67
train
laravel-doctrine/orm
src/Configuration/LaravelNamingStrategy.php
LaravelNamingStrategy.joinTableName
public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) { $names = [ $this->classToFieldName($sourceEntity), $this->classToFieldName($targetEntity) ]; sort($names); return implode('_', $names); }
php
public function joinTableName($sourceEntity, $targetEntity, $propertyName = null) { $names = [ $this->classToFieldName($sourceEntity), $this->classToFieldName($targetEntity) ]; sort($names); return implode('_', $names); }
[ "public", "function", "joinTableName", "(", "$", "sourceEntity", ",", "$", "targetEntity", ",", "$", "propertyName", "=", "null", ")", "{", "$", "names", "=", "[", "$", "this", "->", "classToFieldName", "(", "$", "sourceEntity", ")", ",", "$", "this", "-...
Returns a join table name. @param string $sourceEntity The source entity. @param string $targetEntity The target entity. @param string|null $propertyName A property name. @return string A join table name.
[ "Returns", "a", "join", "table", "name", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Configuration/LaravelNamingStrategy.php#L78-L88
train
laravel-doctrine/orm
src/Configuration/LaravelNamingStrategy.php
LaravelNamingStrategy.joinKeyColumnName
public function joinKeyColumnName($entityName, $referencedColumnName = null) { return $this->classToFieldName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName()); }
php
public function joinKeyColumnName($entityName, $referencedColumnName = null) { return $this->classToFieldName($entityName) . '_' . ($referencedColumnName ?: $this->referenceColumnName()); }
[ "public", "function", "joinKeyColumnName", "(", "$", "entityName", ",", "$", "referencedColumnName", "=", "null", ")", "{", "return", "$", "this", "->", "classToFieldName", "(", "$", "entityName", ")", ".", "'_'", ".", "(", "$", "referencedColumnName", "?", ...
Returns the foreign key column name for the given parameters. @param string $entityName An entity. @param string|null $referencedColumnName A property. @return string A join column name.
[ "Returns", "the", "foreign", "key", "column", "name", "for", "the", "given", "parameters", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Configuration/LaravelNamingStrategy.php#L98-L102
train
laravel-doctrine/orm
src/EntityManagerFactory.php
EntityManagerFactory.hasValidMasterSlaveConfig
private function hasValidMasterSlaveConfig(array $driverConfig) { if (!isset($driverConfig['read'])) { throw new \InvalidArgumentException("Parameter 'read' must be set for read/write config."); } $slaves = $driverConfig['read']; if (!is_array($slaves) || in_array(false, array_map('is_array', $slaves))) { throw new \InvalidArgumentException("Parameter 'read' must be an array containing multiple arrays."); } if (($key = array_search(0, array_map('count', $slaves))) !== false) { throw new \InvalidArgumentException("Parameter 'read' config no. {$key} is empty."); } }
php
private function hasValidMasterSlaveConfig(array $driverConfig) { if (!isset($driverConfig['read'])) { throw new \InvalidArgumentException("Parameter 'read' must be set for read/write config."); } $slaves = $driverConfig['read']; if (!is_array($slaves) || in_array(false, array_map('is_array', $slaves))) { throw new \InvalidArgumentException("Parameter 'read' must be an array containing multiple arrays."); } if (($key = array_search(0, array_map('count', $slaves))) !== false) { throw new \InvalidArgumentException("Parameter 'read' config no. {$key} is empty."); } }
[ "private", "function", "hasValidMasterSlaveConfig", "(", "array", "$", "driverConfig", ")", "{", "if", "(", "!", "isset", "(", "$", "driverConfig", "[", "'read'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Parameter 'read' must...
Check if slave configuration is valid. @param array $driverConfig
[ "Check", "if", "slave", "configuration", "is", "valid", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/EntityManagerFactory.php#L482-L497
train
laravel-doctrine/orm
src/Middleware/SubstituteBindings.php
SubstituteBindings.substituteImplicitBindings
protected function substituteImplicitBindings(Route $route) { $parameters = $route->parameters(); foreach ($this->signatureParameters($route) as $parameter) { $id = $parameters[$parameter->name]; $class = $parameter->getClass()->getName(); if ($repository = $this->registry->getRepository($class)) { if ($parameter->getClass()->implementsInterface(UrlRoutable::class)) { $name = call_user_func([$class, 'getRouteKeyName']); $entity = $repository->findOneBy([ $name => $id ]); } else { $entity = $repository->find($id); } if (is_null($entity) && !$parameter->isDefaultValueAvailable()) { throw EntityNotFoundException::fromClassNameAndIdentifier($class, ['id' => $id]); } $route->setParameter($parameter->name, $entity); } } }
php
protected function substituteImplicitBindings(Route $route) { $parameters = $route->parameters(); foreach ($this->signatureParameters($route) as $parameter) { $id = $parameters[$parameter->name]; $class = $parameter->getClass()->getName(); if ($repository = $this->registry->getRepository($class)) { if ($parameter->getClass()->implementsInterface(UrlRoutable::class)) { $name = call_user_func([$class, 'getRouteKeyName']); $entity = $repository->findOneBy([ $name => $id ]); } else { $entity = $repository->find($id); } if (is_null($entity) && !$parameter->isDefaultValueAvailable()) { throw EntityNotFoundException::fromClassNameAndIdentifier($class, ['id' => $id]); } $route->setParameter($parameter->name, $entity); } } }
[ "protected", "function", "substituteImplicitBindings", "(", "Route", "$", "route", ")", "{", "$", "parameters", "=", "$", "route", "->", "parameters", "(", ")", ";", "foreach", "(", "$", "this", "->", "signatureParameters", "(", "$", "route", ")", "as", "$...
Substitute the implicit Doctrine entity bindings for the route. @param Route $route @throws EntityNotFoundException
[ "Substitute", "the", "implicit", "Doctrine", "entity", "bindings", "for", "the", "route", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Middleware/SubstituteBindings.php#L62-L88
train
laravel-doctrine/orm
src/Auth/Passwords/DoctrineTokenRepository.php
DoctrineTokenRepository.getTable
protected function getTable() { $schema = $this->connection->getSchemaManager(); if (!$schema->tablesExist($this->table)) { $schema->createTable($this->getTableDefinition()); } return $this->getConnection()->createQueryBuilder(); }
php
protected function getTable() { $schema = $this->connection->getSchemaManager(); if (!$schema->tablesExist($this->table)) { $schema->createTable($this->getTableDefinition()); } return $this->getConnection()->createQueryBuilder(); }
[ "protected", "function", "getTable", "(", ")", "{", "$", "schema", "=", "$", "this", "->", "connection", "->", "getSchemaManager", "(", ")", ";", "if", "(", "!", "$", "schema", "->", "tablesExist", "(", "$", "this", "->", "table", ")", ")", "{", "$",...
Begin a new database query against the table. @return \Doctrine\DBAL\Query\QueryBuilder
[ "Begin", "a", "new", "database", "query", "against", "the", "table", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Auth/Passwords/DoctrineTokenRepository.php#L184-L193
train
laravel-doctrine/orm
src/Configuration/Connections/MasterSlaveConnection.php
MasterSlaveConnection.getSlavesConfig
public function getSlavesConfig(array $slaves, $driver) { $handledSlaves = []; foreach ($slaves as $slave) { $handledSlaves[] = $this->getConnectionData($slave, $driver); } return $handledSlaves; }
php
public function getSlavesConfig(array $slaves, $driver) { $handledSlaves = []; foreach ($slaves as $slave) { $handledSlaves[] = $this->getConnectionData($slave, $driver); } return $handledSlaves; }
[ "public", "function", "getSlavesConfig", "(", "array", "$", "slaves", ",", "$", "driver", ")", "{", "$", "handledSlaves", "=", "[", "]", ";", "foreach", "(", "$", "slaves", "as", "$", "slave", ")", "{", "$", "handledSlaves", "[", "]", "=", "$", "this...
Returns config for slave connections. @param array $slaves @param string $driver @return array
[ "Returns", "config", "for", "slave", "connections", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/Configuration/Connections/MasterSlaveConnection.php#L59-L67
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getDefaultConnectionName
public function getDefaultConnectionName() { if (isset($this->connections[$this->defaultConnection])) { return $this->defaultConnection; } return head($this->connections); }
php
public function getDefaultConnectionName() { if (isset($this->connections[$this->defaultConnection])) { return $this->defaultConnection; } return head($this->connections); }
[ "public", "function", "getDefaultConnectionName", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "connections", "[", "$", "this", "->", "defaultConnection", "]", ")", ")", "{", "return", "$", "this", "->", "defaultConnection", ";", "}", "return...
Gets the default connection name. @return string The default connection name.
[ "Gets", "the", "default", "connection", "name", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L107-L114
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getConnection
public function getConnection($name = null) { $name = $name ?: $this->getDefaultConnectionName(); if (!$this->connectionExists($name)) { throw new InvalidArgumentException(sprintf('Doctrine Connection named "%s" does not exist.', $name)); } if (isset($this->connectionsMap[$name])) { return $this->connectionsMap[$name]; } return $this->connectionsMap[$name] = $this->getService( $this->getConnectionBindingName($this->connections[$name]) ); }
php
public function getConnection($name = null) { $name = $name ?: $this->getDefaultConnectionName(); if (!$this->connectionExists($name)) { throw new InvalidArgumentException(sprintf('Doctrine Connection named "%s" does not exist.', $name)); } if (isset($this->connectionsMap[$name])) { return $this->connectionsMap[$name]; } return $this->connectionsMap[$name] = $this->getService( $this->getConnectionBindingName($this->connections[$name]) ); }
[ "public", "function", "getConnection", "(", "$", "name", "=", "null", ")", "{", "$", "name", "=", "$", "name", "?", ":", "$", "this", "->", "getDefaultConnectionName", "(", ")", ";", "if", "(", "!", "$", "this", "->", "connectionExists", "(", "$", "n...
Gets the named connection. @param string $name The connection name (null for the default one). @return object
[ "Gets", "the", "named", "connection", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L123-L138
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getConnections
public function getConnections() { $connections = []; foreach ($this->getConnectionNames() as $name) { $connections[$name] = $this->getConnection($name); } return $connections; }
php
public function getConnections() { $connections = []; foreach ($this->getConnectionNames() as $name) { $connections[$name] = $this->getConnection($name); } return $connections; }
[ "public", "function", "getConnections", "(", ")", "{", "$", "connections", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getConnectionNames", "(", ")", "as", "$", "name", ")", "{", "$", "connections", "[", "$", "name", "]", "=", "$", "this"...
Gets an array of all registered connections. @return array An array of Connection instances.
[ "Gets", "an", "array", "of", "all", "registered", "connections", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L155-L163
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getDefaultManagerName
public function getDefaultManagerName() { if (isset($this->managers[$this->defaultManager])) { return $this->defaultManager; } return head($this->managers); }
php
public function getDefaultManagerName() { if (isset($this->managers[$this->defaultManager])) { return $this->defaultManager; } return head($this->managers); }
[ "public", "function", "getDefaultManagerName", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "managers", "[", "$", "this", "->", "defaultManager", "]", ")", ")", "{", "return", "$", "this", "->", "defaultManager", ";", "}", "return", "head",...
Gets the default object manager name. @return string The default object manager name.
[ "Gets", "the", "default", "object", "manager", "name", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L180-L187
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getManager
public function getManager($name = null) { $name = $name ?: $this->getDefaultManagerName(); if (!$this->managerExists($name)) { throw new InvalidArgumentException(sprintf('Doctrine Manager named "%s" does not exist.', $name)); } if (isset($this->managersMap[$name])) { return $this->managersMap[$name]; } return $this->managersMap[$name] = $this->getService( $this->getManagerBindingName($this->managers[$name]) ); }
php
public function getManager($name = null) { $name = $name ?: $this->getDefaultManagerName(); if (!$this->managerExists($name)) { throw new InvalidArgumentException(sprintf('Doctrine Manager named "%s" does not exist.', $name)); } if (isset($this->managersMap[$name])) { return $this->managersMap[$name]; } return $this->managersMap[$name] = $this->getService( $this->getManagerBindingName($this->managers[$name]) ); }
[ "public", "function", "getManager", "(", "$", "name", "=", "null", ")", "{", "$", "name", "=", "$", "name", "?", ":", "$", "this", "->", "getDefaultManagerName", "(", ")", ";", "if", "(", "!", "$", "this", "->", "managerExists", "(", "$", "name", "...
Gets a named object manager. @param string $name The object manager name (null for the default one). @return \Doctrine\Common\Persistence\ObjectManager
[ "Gets", "a", "named", "object", "manager", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L196-L211
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getManagers
public function getManagers() { $managers = []; foreach ($this->getManagerNames() as $name) { $managers[$name] = $this->getManager($name); } return $managers; }
php
public function getManagers() { $managers = []; foreach ($this->getManagerNames() as $name) { $managers[$name] = $this->getManager($name); } return $managers; }
[ "public", "function", "getManagers", "(", ")", "{", "$", "managers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getManagerNames", "(", ")", "as", "$", "name", ")", "{", "$", "managers", "[", "$", "name", "]", "=", "$", "this", "->", ...
Gets an array of all registered object managers. @return \Doctrine\Common\Persistence\ObjectManager[] An array of ObjectManager instances
[ "Gets", "an", "array", "of", "all", "registered", "object", "managers", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L238-L246
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.closeManager
public function closeManager($name = null) { $name = $name ?: $this->getDefaultManagerName(); if (!$this->managerExists($name)) { throw new InvalidArgumentException(sprintf('Doctrine Manager named "%s" does not exist.', $name)); } // force the creation of a new document manager // if the current one is closed $this->resetService( $this->getManagerBindingName($this->managers[$name]) ); $this->resetService( $this->getConnectionBindingName($this->connections[$name]) ); unset($this->managersMap[$name]); unset($this->connectionsMap[$name]); }
php
public function closeManager($name = null) { $name = $name ?: $this->getDefaultManagerName(); if (!$this->managerExists($name)) { throw new InvalidArgumentException(sprintf('Doctrine Manager named "%s" does not exist.', $name)); } // force the creation of a new document manager // if the current one is closed $this->resetService( $this->getManagerBindingName($this->managers[$name]) ); $this->resetService( $this->getConnectionBindingName($this->connections[$name]) ); unset($this->managersMap[$name]); unset($this->connectionsMap[$name]); }
[ "public", "function", "closeManager", "(", "$", "name", "=", "null", ")", "{", "$", "name", "=", "$", "name", "?", ":", "$", "this", "->", "getDefaultManagerName", "(", ")", ";", "if", "(", "!", "$", "this", "->", "managerExists", "(", "$", "name", ...
Close an existing object manager. @param string|null $name The object manager name (null for the default one).
[ "Close", "an", "existing", "object", "manager", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L252-L272
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.purgeManager
public function purgeManager($name = null) { $name = $name ?: $this->getDefaultManagerName(); $this->closeManager($name); unset($this->managers[$name]); unset($this->connections[$name]); }
php
public function purgeManager($name = null) { $name = $name ?: $this->getDefaultManagerName(); $this->closeManager($name); unset($this->managers[$name]); unset($this->connections[$name]); }
[ "public", "function", "purgeManager", "(", "$", "name", "=", "null", ")", "{", "$", "name", "=", "$", "name", "?", ":", "$", "this", "->", "getDefaultManagerName", "(", ")", ";", "$", "this", "->", "closeManager", "(", "$", "name", ")", ";", "unset",...
Purge a named object manager. This method can be used if you wish to close an object manager manually, without opening a new one. This can be useful if you wish to open a new manager later (but maybe with different settings). @param string|null $name The object manager name (null for the default one).
[ "Purge", "a", "named", "object", "manager", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L282-L289
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getAliasNamespace
public function getAliasNamespace($alias) { foreach ($this->getManagerNames() as $name) { try { return $this->getManager($name)->getConfiguration()->getEntityNamespace($alias); } catch (ORMException $e) { } } throw ORMException::unknownEntityNamespace($alias); }
php
public function getAliasNamespace($alias) { foreach ($this->getManagerNames() as $name) { try { return $this->getManager($name)->getConfiguration()->getEntityNamespace($alias); } catch (ORMException $e) { } } throw ORMException::unknownEntityNamespace($alias); }
[ "public", "function", "getAliasNamespace", "(", "$", "alias", ")", "{", "foreach", "(", "$", "this", "->", "getManagerNames", "(", ")", "as", "$", "name", ")", "{", "try", "{", "return", "$", "this", "->", "getManager", "(", "$", "name", ")", "->", "...
Resolves a registered namespace alias to the full namespace. This method looks for the alias in all registered object managers. @param string $alias The alias. @throws ORMException @return string The full namespace.
[ "Resolves", "a", "registered", "namespace", "alias", "to", "the", "full", "namespace", ".", "This", "method", "looks", "for", "the", "alias", "in", "all", "registered", "object", "managers", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L322-L332
train
laravel-doctrine/orm
src/IlluminateRegistry.php
IlluminateRegistry.getManagerForClass
public function getManagerForClass($class) { // Check for namespace alias if (strpos($class, ':') !== false) { list($namespaceAlias, $simpleClassName) = explode(':', $class, 2); $class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName; } $proxyClass = new ReflectionClass($class); if ($proxyClass->implementsInterface(Proxy::class)) { $class = $proxyClass->getParentClass()->getName(); } $managerNames = $this->getManagerNames(); if (count($managerNames) === 1) { return $this->getManager(reset($managerNames)); } foreach ($managerNames as $name) { $manager = $this->getManager($name); if (!$manager->getMetadataFactory()->isTransient($class)) { foreach ($manager->getMetadataFactory()->getAllMetadata() as $metadata) { if ($metadata->getName() === $class) { return $manager; } } } } }
php
public function getManagerForClass($class) { // Check for namespace alias if (strpos($class, ':') !== false) { list($namespaceAlias, $simpleClassName) = explode(':', $class, 2); $class = $this->getAliasNamespace($namespaceAlias) . '\\' . $simpleClassName; } $proxyClass = new ReflectionClass($class); if ($proxyClass->implementsInterface(Proxy::class)) { $class = $proxyClass->getParentClass()->getName(); } $managerNames = $this->getManagerNames(); if (count($managerNames) === 1) { return $this->getManager(reset($managerNames)); } foreach ($managerNames as $name) { $manager = $this->getManager($name); if (!$manager->getMetadataFactory()->isTransient($class)) { foreach ($manager->getMetadataFactory()->getAllMetadata() as $metadata) { if ($metadata->getName() === $class) { return $manager; } } } } }
[ "public", "function", "getManagerForClass", "(", "$", "class", ")", "{", "// Check for namespace alias", "if", "(", "strpos", "(", "$", "class", ",", "':'", ")", "!==", "false", ")", "{", "list", "(", "$", "namespaceAlias", ",", "$", "simpleClassName", ")", ...
Gets the object manager associated with a given class. @param string $class A persistent object class name. @return \Doctrine\Common\Persistence\ObjectManager|null
[ "Gets", "the", "object", "manager", "associated", "with", "a", "given", "class", "." ]
7b45d97b8345d532747b8b946c36eb0926018fcc
https://github.com/laravel-doctrine/orm/blob/7b45d97b8345d532747b8b946c36eb0926018fcc/src/IlluminateRegistry.php#L354-L384
train
php-vcr/php-vcr
src/VCR/Cassette.php
Cassette.playback
public function playback(Request $request) { foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); if ($storedRequest->matches($request, $this->getRequestMatchers())) { return Response::fromArray($recording['response']); } } return null; }
php
public function playback(Request $request) { foreach ($this->storage as $recording) { $storedRequest = Request::fromArray($recording['request']); if ($storedRequest->matches($request, $this->getRequestMatchers())) { return Response::fromArray($recording['response']); } } return null; }
[ "public", "function", "playback", "(", "Request", "$", "request", ")", "{", "foreach", "(", "$", "this", "->", "storage", "as", "$", "recording", ")", "{", "$", "storedRequest", "=", "Request", "::", "fromArray", "(", "$", "recording", "[", "'request'", ...
Returns a response for given request or null if not found. @param Request $request Request. @return Response|null Response for specified request.
[ "Returns", "a", "response", "for", "given", "request", "or", "null", "if", "not", "found", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Cassette.php#L69-L79
train
php-vcr/php-vcr
src/VCR/Cassette.php
Cassette.record
public function record(Request $request, Response $response) { if ($this->hasResponse($request)) { return; } $recording = array( 'request' => $request->toArray(), 'response' => $response->toArray() ); $this->storage->storeRecording($recording); }
php
public function record(Request $request, Response $response) { if ($this->hasResponse($request)) { return; } $recording = array( 'request' => $request->toArray(), 'response' => $response->toArray() ); $this->storage->storeRecording($recording); }
[ "public", "function", "record", "(", "Request", "$", "request", ",", "Response", "$", "response", ")", "{", "if", "(", "$", "this", "->", "hasResponse", "(", "$", "request", ")", ")", "{", "return", ";", "}", "$", "recording", "=", "array", "(", "'re...
Records a request and response pair. @param Request $request Request to record. @param Response $response Response to record. @return void
[ "Records", "a", "request", "and", "response", "pair", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Cassette.php#L89-L101
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.setBlackList
public function setBlackList($paths) { $paths = (is_array($paths)) ? $paths : array($paths); $this->blackList = $paths; return $this; }
php
public function setBlackList($paths) { $paths = (is_array($paths)) ? $paths : array($paths); $this->blackList = $paths; return $this; }
[ "public", "function", "setBlackList", "(", "$", "paths", ")", "{", "$", "paths", "=", "(", "is_array", "(", "$", "paths", ")", ")", "?", "$", "paths", ":", "array", "(", "$", "paths", ")", ";", "$", "this", "->", "blackList", "=", "$", "paths", "...
Sets one or more paths to blacklist. @param string|string[] $paths Path(s) to blacklist. @return Configuration
[ "Sets", "one", "or", "more", "paths", "to", "blacklist", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L163-L170
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.getLibraryHooks
public function getLibraryHooks() { if (is_null($this->enabledLibraryHooks)) { return array_values($this->availableLibraryHooks); } return array_values(array_intersect_key( $this->availableLibraryHooks, array_flip($this->enabledLibraryHooks) )); }
php
public function getLibraryHooks() { if (is_null($this->enabledLibraryHooks)) { return array_values($this->availableLibraryHooks); } return array_values(array_intersect_key( $this->availableLibraryHooks, array_flip($this->enabledLibraryHooks) )); }
[ "public", "function", "getLibraryHooks", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "enabledLibraryHooks", ")", ")", "{", "return", "array_values", "(", "$", "this", "->", "availableLibraryHooks", ")", ";", "}", "return", "array_values", "(...
Returns a list of enabled LibraryHook class names. Only class names are returned, any object creation happens in the VCRFactory. @return string[] List of LibraryHook class names.
[ "Returns", "a", "list", "of", "enabled", "LibraryHook", "class", "names", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L208-L218
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.getRequestMatchers
public function getRequestMatchers() { if (is_null($this->enabledRequestMatchers)) { return array_values($this->availableRequestMatchers); } return array_values(array_intersect_key( $this->availableRequestMatchers, array_flip($this->enabledRequestMatchers) )); }
php
public function getRequestMatchers() { if (is_null($this->enabledRequestMatchers)) { return array_values($this->availableRequestMatchers); } return array_values(array_intersect_key( $this->availableRequestMatchers, array_flip($this->enabledRequestMatchers) )); }
[ "public", "function", "getRequestMatchers", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "enabledRequestMatchers", ")", ")", "{", "return", "array_values", "(", "$", "this", "->", "availableRequestMatchers", ")", ";", "}", "return", "array_valu...
Returns a list of enabled RequestMatcher callbacks. @return array List of enabled RequestMatcher callbacks.
[ "Returns", "a", "list", "of", "enabled", "RequestMatcher", "callbacks", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L256-L266
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.addRequestMatcher
public function addRequestMatcher($name, $callback) { Assertion::minLength($name, 1, "A request matchers name must be at least one character long. Found '{$name}'"); Assertion::isCallable($callback, "Request matcher '{$name}' is not callable."); $this->availableRequestMatchers[$name] = $callback; return $this; }
php
public function addRequestMatcher($name, $callback) { Assertion::minLength($name, 1, "A request matchers name must be at least one character long. Found '{$name}'"); Assertion::isCallable($callback, "Request matcher '{$name}' is not callable."); $this->availableRequestMatchers[$name] = $callback; return $this; }
[ "public", "function", "addRequestMatcher", "(", "$", "name", ",", "$", "callback", ")", "{", "Assertion", "::", "minLength", "(", "$", "name", ",", "1", ",", "\"A request matchers name must be at least one character long. Found '{$name}'\"", ")", ";", "Assertion", "::...
Adds a new RequestMatcher callback. @param string $name Name of the RequestMatcher. @param callable $callback A callback taking two Request objects as parameters and returns true if those match. @return Configuration @throws VCRException If specified parameters are invalid.
[ "Adds", "a", "new", "RequestMatcher", "callback", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L277-L284
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.enableRequestMatchers
public function enableRequestMatchers(array $matchers) { $invalidMatchers = array_diff($matchers, array_keys($this->availableRequestMatchers)); if ($invalidMatchers) { throw new \InvalidArgumentException("Request matchers don't exist: " . join(', ', $invalidMatchers)); } $this->enabledRequestMatchers = $matchers; return $this; }
php
public function enableRequestMatchers(array $matchers) { $invalidMatchers = array_diff($matchers, array_keys($this->availableRequestMatchers)); if ($invalidMatchers) { throw new \InvalidArgumentException("Request matchers don't exist: " . join(', ', $invalidMatchers)); } $this->enabledRequestMatchers = $matchers; return $this; }
[ "public", "function", "enableRequestMatchers", "(", "array", "$", "matchers", ")", "{", "$", "invalidMatchers", "=", "array_diff", "(", "$", "matchers", ",", "array_keys", "(", "$", "this", "->", "availableRequestMatchers", ")", ")", ";", "if", "(", "$", "in...
Enables specified RequestMatchers by its name. @param array $matchers List of RequestMatcher names to enable. @return Configuration @throws \InvalidArgumentException If a specified request matcher does not exist.
[ "Enables", "specified", "RequestMatchers", "by", "its", "name", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L295-L304
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.setStorage
public function setStorage($storageName) { Assertion::keyExists($this->availableStorages, $storageName, "Storage '{$storageName}' not available."); $this->enabledStorage = $storageName; return $this; }
php
public function setStorage($storageName) { Assertion::keyExists($this->availableStorages, $storageName, "Storage '{$storageName}' not available."); $this->enabledStorage = $storageName; return $this; }
[ "public", "function", "setStorage", "(", "$", "storageName", ")", "{", "Assertion", "::", "keyExists", "(", "$", "this", "->", "availableStorages", ",", "$", "storageName", ",", "\"Storage '{$storageName}' not available.\"", ")", ";", "$", "this", "->", "enabledSt...
Enables a storage by name. @param string $storageName Name of the storage to enable. @return $this @throws VCRException If a invalid storage name is given.
[ "Enables", "a", "storage", "by", "name", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L314-L320
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.setWhiteList
public function setWhiteList($paths) { $paths = (is_array($paths)) ? $paths : array($paths); $this->whiteList = $paths; return $this; }
php
public function setWhiteList($paths) { $paths = (is_array($paths)) ? $paths : array($paths); $this->whiteList = $paths; return $this; }
[ "public", "function", "setWhiteList", "(", "$", "paths", ")", "{", "$", "paths", "=", "(", "is_array", "(", "$", "paths", ")", ")", "?", "$", "paths", ":", "array", "(", "$", "paths", ")", ";", "$", "this", "->", "whiteList", "=", "$", "paths", "...
Sets a list of paths to whitelist when processing in the StreamProcessor. @param string|array $paths Single path or list of path which are whitelisted. @return Configuration
[ "Sets", "a", "list", "of", "paths", "to", "whitelist", "when", "processing", "in", "the", "StreamProcessor", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L339-L346
train
php-vcr/php-vcr
src/VCR/Configuration.php
Configuration.setMode
public function setMode($mode) { Assertion::choice($mode, $this->availableModes, "Mode '{$mode}' does not exist."); $this->mode = $mode; return $this; }
php
public function setMode($mode) { Assertion::choice($mode, $this->availableModes, "Mode '{$mode}' does not exist."); $this->mode = $mode; return $this; }
[ "public", "function", "setMode", "(", "$", "mode", ")", "{", "Assertion", "::", "choice", "(", "$", "mode", ",", "$", "this", "->", "availableModes", ",", "\"Mode '{$mode}' does not exist.\"", ")", ";", "$", "this", "->", "mode", "=", "$", "mode", ";", "...
Sets the current mode. @param string $mode The mode to set VCR to @return Configuration
[ "Sets", "the", "current", "mode", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Configuration.php#L365-L371
train
php-vcr/php-vcr
src/VCR/Util/SoapClient.php
SoapClient.realDoRequest
protected function realDoRequest($request, $location, $action, $version, $one_way = 0) { return parent::__doRequest($request, $location, $action, $version, $one_way); }
php
protected function realDoRequest($request, $location, $action, $version, $one_way = 0) { return parent::__doRequest($request, $location, $action, $version, $one_way); }
[ "protected", "function", "realDoRequest", "(", "$", "request", ",", "$", "location", ",", "$", "action", ",", "$", "version", ",", "$", "one_way", "=", "0", ")", "{", "return", "parent", "::", "__doRequest", "(", "$", "request", ",", "$", "location", "...
Performs a real SOAP request over HTTP. @codeCoverageIgnore @param string $request The XML SOAP request. @param string $location The URL to request. @param string $action The SOAP action. @param integer $version The SOAP version. @param integer $one_way If one_way is set to 1, this method returns nothing. Use this where a response is not expected. @return string The XML SOAP response.
[ "Performs", "a", "real", "SOAP", "request", "over", "HTTP", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/SoapClient.php#L105-L108
train
php-vcr/php-vcr
src/VCR/Util/SoapClient.php
SoapClient.getLibraryHook
protected function getLibraryHook() { if (empty($this->soapHook)) { $this->soapHook = VCRFactory::get('VCR\LibraryHooks\SoapHook'); } return $this->soapHook; }
php
protected function getLibraryHook() { if (empty($this->soapHook)) { $this->soapHook = VCRFactory::get('VCR\LibraryHooks\SoapHook'); } return $this->soapHook; }
[ "protected", "function", "getLibraryHook", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "soapHook", ")", ")", "{", "$", "this", "->", "soapHook", "=", "VCRFactory", "::", "get", "(", "'VCR\\LibraryHooks\\SoapHook'", ")", ";", "}", "return", ...
Returns currently used SOAP library hook. If no library hook is set, a new one is created. @return SoapHook SOAP library hook.
[ "Returns", "currently", "used", "SOAP", "library", "hook", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/SoapClient.php#L117-L124
train
php-vcr/php-vcr
src/VCR/Response.php
Response.toArray
public function toArray() { $body = $this->getBody(); // Base64 encode when binary if (strpos($this->getContentType(), 'application/x-gzip') !== false || $this->getHeader('Content-Transfer-Encoding') == 'binary' ) { $body = base64_encode($body); } return array_filter( array( 'status' => $this->status, 'headers' => $this->getHeaders(), 'body' => $body ) ); }
php
public function toArray() { $body = $this->getBody(); // Base64 encode when binary if (strpos($this->getContentType(), 'application/x-gzip') !== false || $this->getHeader('Content-Transfer-Encoding') == 'binary' ) { $body = base64_encode($body); } return array_filter( array( 'status' => $this->status, 'headers' => $this->getHeaders(), 'body' => $body ) ); }
[ "public", "function", "toArray", "(", ")", "{", "$", "body", "=", "$", "this", "->", "getBody", "(", ")", ";", "// Base64 encode when binary", "if", "(", "strpos", "(", "$", "this", "->", "getContentType", "(", ")", ",", "'application/x-gzip'", ")", "!==",...
Returns an array representation of this Response. @return array Array representation of this Request.
[ "Returns", "an", "array", "representation", "of", "this", "Response", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Response.php#L54-L71
train
php-vcr/php-vcr
src/VCR/Response.php
Response.fromArray
public static function fromArray(array $response) { $body = isset($response['body']) ? $response['body'] : null; $gzip = isset($response['headers']['Content-Type']) && strpos($response['headers']['Content-Type'], 'application/x-gzip') !== false; $binary = isset($response['headers']['Content-Transfer-Encoding']) && $response['headers']['Content-Transfer-Encoding'] == 'binary'; // Base64 decode when binary if ($gzip || $binary) { $body = base64_decode($response['body']); } return new static( isset($response['status']) ? $response['status'] : 200, isset($response['headers']) ? $response['headers'] : array(), $body ); }
php
public static function fromArray(array $response) { $body = isset($response['body']) ? $response['body'] : null; $gzip = isset($response['headers']['Content-Type']) && strpos($response['headers']['Content-Type'], 'application/x-gzip') !== false; $binary = isset($response['headers']['Content-Transfer-Encoding']) && $response['headers']['Content-Transfer-Encoding'] == 'binary'; // Base64 decode when binary if ($gzip || $binary) { $body = base64_decode($response['body']); } return new static( isset($response['status']) ? $response['status'] : 200, isset($response['headers']) ? $response['headers'] : array(), $body ); }
[ "public", "static", "function", "fromArray", "(", "array", "$", "response", ")", "{", "$", "body", "=", "isset", "(", "$", "response", "[", "'body'", "]", ")", "?", "$", "response", "[", "'body'", "]", ":", "null", ";", "$", "gzip", "=", "isset", "...
Creates a new Response from a specified array. @param array $response Array representation of a Response. @return Response A new Response from a specified array
[ "Creates", "a", "new", "Response", "from", "a", "specified", "array", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Response.php#L79-L99
train
php-vcr/php-vcr
src/VCR/Util/CurlHelper.php
CurlHelper.handleOutput
public static function handleOutput(Response $response, array $curlOptions, $ch) { // If there is a header function set, feed the http status and headers to it. if (isset($curlOptions[CURLOPT_HEADERFUNCTION])) { $headerList = array(HttpUtil::formatAsStatusString($response)); $headerList = array_merge($headerList, HttpUtil::formatHeadersForCurl($response->getHeaders())); $headerList[] = ''; foreach ($headerList as $header) { call_user_func($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header); } } $body = $response->getBody(); if (!empty($curlOptions[CURLOPT_HEADER])) { $body = HttpUtil::formatAsStatusWithHeadersString($response) . $body; } if (isset($curlOptions[CURLOPT_WRITEFUNCTION])) { call_user_func($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body); } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && $curlOptions[CURLOPT_RETURNTRANSFER] == true) { return $body; } elseif (isset($curlOptions[CURLOPT_FILE])) { $fp = $curlOptions[CURLOPT_FILE]; fwrite($fp, $body); fflush($fp); } else { echo $body; } }
php
public static function handleOutput(Response $response, array $curlOptions, $ch) { // If there is a header function set, feed the http status and headers to it. if (isset($curlOptions[CURLOPT_HEADERFUNCTION])) { $headerList = array(HttpUtil::formatAsStatusString($response)); $headerList = array_merge($headerList, HttpUtil::formatHeadersForCurl($response->getHeaders())); $headerList[] = ''; foreach ($headerList as $header) { call_user_func($curlOptions[CURLOPT_HEADERFUNCTION], $ch, $header); } } $body = $response->getBody(); if (!empty($curlOptions[CURLOPT_HEADER])) { $body = HttpUtil::formatAsStatusWithHeadersString($response) . $body; } if (isset($curlOptions[CURLOPT_WRITEFUNCTION])) { call_user_func($curlOptions[CURLOPT_WRITEFUNCTION], $ch, $body); } elseif (isset($curlOptions[CURLOPT_RETURNTRANSFER]) && $curlOptions[CURLOPT_RETURNTRANSFER] == true) { return $body; } elseif (isset($curlOptions[CURLOPT_FILE])) { $fp = $curlOptions[CURLOPT_FILE]; fwrite($fp, $body); fflush($fp); } else { echo $body; } }
[ "public", "static", "function", "handleOutput", "(", "Response", "$", "response", ",", "array", "$", "curlOptions", ",", "$", "ch", ")", "{", "// If there is a header function set, feed the http status and headers to it.", "if", "(", "isset", "(", "$", "curlOptions", ...
Outputs a response depending on the set cURL option. The response body can be written to a file, returned, echoed or passed to a custom function. The response header might be passed to a custom function. @param Response $response Response which contains the response body. @param array $curlOptions cURL options which are not stored within the Response. @param resource $ch cURL handle to add headers if needed. @return null|string
[ "Outputs", "a", "response", "depending", "on", "the", "set", "cURL", "option", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/CurlHelper.php#L56-L85
train
php-vcr/php-vcr
src/VCR/Util/CurlHelper.php
CurlHelper.getCurlOptionFromResponse
public static function getCurlOptionFromResponse(Response $response, $option = 0) { switch ($option) { case 0: // 0 == array of all curl options $info = array(); foreach (self::$curlInfoList as $option => $key) { $info[$key] = $response->getCurlInfo($key); } break; case CURLINFO_HTTP_CODE: $info = (int)$response->getStatusCode(); break; case CURLINFO_SIZE_DOWNLOAD: $info = $response->getHeader('Content-Length'); break; case CURLINFO_HEADER_SIZE: $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; default: $info = $response->getCurlInfo($option); break; } if (!is_null($info)) { return $info; } $constants = get_defined_constants(true); $constantNames = array_flip($constants['curl']); throw new \BadMethodCallException("Not implemented: {$constantNames[$option]} ({$option}) "); }
php
public static function getCurlOptionFromResponse(Response $response, $option = 0) { switch ($option) { case 0: // 0 == array of all curl options $info = array(); foreach (self::$curlInfoList as $option => $key) { $info[$key] = $response->getCurlInfo($key); } break; case CURLINFO_HTTP_CODE: $info = (int)$response->getStatusCode(); break; case CURLINFO_SIZE_DOWNLOAD: $info = $response->getHeader('Content-Length'); break; case CURLINFO_HEADER_SIZE: $info = mb_strlen(HttpUtil::formatAsStatusWithHeadersString($response), 'ISO-8859-1'); break; default: $info = $response->getCurlInfo($option); break; } if (!is_null($info)) { return $info; } $constants = get_defined_constants(true); $constantNames = array_flip($constants['curl']); throw new \BadMethodCallException("Not implemented: {$constantNames[$option]} ({$option}) "); }
[ "public", "static", "function", "getCurlOptionFromResponse", "(", "Response", "$", "response", ",", "$", "option", "=", "0", ")", "{", "switch", "(", "$", "option", ")", "{", "case", "0", ":", "// 0 == array of all curl options", "$", "info", "=", "array", "...
Returns a cURL option from a Response. @param Response $response Response to get cURL option from. @param integer $option cURL option to get. @throws \BadMethodCallException @return mixed Value of the cURL option.
[ "Returns", "a", "cURL", "option", "from", "a", "Response", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/CurlHelper.php#L96-L126
train
php-vcr/php-vcr
src/VCR/Util/CurlHelper.php
CurlHelper.setCurlOptionOnRequest
public static function setCurlOptionOnRequest(Request $request, $option, $value, $curlHandle = null) { switch ($option) { case CURLOPT_URL: $request->setUrl($value); break; case CURLOPT_CUSTOMREQUEST: $request->setCurlOption(CURLOPT_CUSTOMREQUEST, $value); break; case CURLOPT_POST: if ($value == true) { $request->setMethod('POST'); } break; case CURLOPT_POSTFIELDS: // todo: check for file @ if (is_array($value)) { foreach ($value as $name => $fieldValue) { $request->setPostField($name, $fieldValue); } if (count($value) == 0) { $request->removeHeader('Content-Type'); } } elseif (!empty($value)) { // Empty values are ignored to be consistent with how requests are read out of // storage using \VCR\Request::fromArray(array $request). $request->setBody($value); } $request->setMethod('POST'); break; case CURLOPT_HTTPHEADER: foreach ($value as $header) { $headerParts = explode(': ', $header, 2); if (!isset($headerParts[1])) { $headerParts[0] = rtrim($headerParts[0], ':'); $headerParts[1] = null; } $request->setHeader($headerParts[0], $headerParts[1]); } break; case CURLOPT_FILE: case CURLOPT_HEADER: case CURLOPT_WRITEFUNCTION: case CURLOPT_HEADERFUNCTION: case CURLOPT_UPLOAD: // Ignore header, file and writer functions. // These options are stored and will be handled later in handleOutput(). break; default: $request->setCurlOption($option, $value); break; } }
php
public static function setCurlOptionOnRequest(Request $request, $option, $value, $curlHandle = null) { switch ($option) { case CURLOPT_URL: $request->setUrl($value); break; case CURLOPT_CUSTOMREQUEST: $request->setCurlOption(CURLOPT_CUSTOMREQUEST, $value); break; case CURLOPT_POST: if ($value == true) { $request->setMethod('POST'); } break; case CURLOPT_POSTFIELDS: // todo: check for file @ if (is_array($value)) { foreach ($value as $name => $fieldValue) { $request->setPostField($name, $fieldValue); } if (count($value) == 0) { $request->removeHeader('Content-Type'); } } elseif (!empty($value)) { // Empty values are ignored to be consistent with how requests are read out of // storage using \VCR\Request::fromArray(array $request). $request->setBody($value); } $request->setMethod('POST'); break; case CURLOPT_HTTPHEADER: foreach ($value as $header) { $headerParts = explode(': ', $header, 2); if (!isset($headerParts[1])) { $headerParts[0] = rtrim($headerParts[0], ':'); $headerParts[1] = null; } $request->setHeader($headerParts[0], $headerParts[1]); } break; case CURLOPT_FILE: case CURLOPT_HEADER: case CURLOPT_WRITEFUNCTION: case CURLOPT_HEADERFUNCTION: case CURLOPT_UPLOAD: // Ignore header, file and writer functions. // These options are stored and will be handled later in handleOutput(). break; default: $request->setCurlOption($option, $value); break; } }
[ "public", "static", "function", "setCurlOptionOnRequest", "(", "Request", "$", "request", ",", "$", "option", ",", "$", "value", ",", "$", "curlHandle", "=", "null", ")", "{", "switch", "(", "$", "option", ")", "{", "case", "CURLOPT_URL", ":", "$", "requ...
Sets a cURL option on a Request. @param Request $request Request to set cURL option to. @param integer $option cURL option to set. @param mixed $value Value of the cURL option. @param resource $curlHandle cURL handle where this option is set on (optional).
[ "Sets", "a", "cURL", "option", "on", "a", "Request", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/CurlHelper.php#L136-L189
train
php-vcr/php-vcr
src/VCR/Util/CurlHelper.php
CurlHelper.validateCurlPOSTBody
public static function validateCurlPOSTBody(Request $request, $curlHandle = null) { $readFunction = $request->getCurlOption(CURLOPT_READFUNCTION); if (is_null($readFunction)) { return; } // Guzzle 4 sometimes sets the post body in CURLOPT_POSTFIELDS even if // they have already set CURLOPT_READFUNCTION. if ($request->getBody()) { return; } $bodySize = $request->getCurlOption(CURLOPT_INFILESIZE); Assertion::notEmpty($bodySize, 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); $body = call_user_func_array($readFunction, array($curlHandle, fopen('php://memory', 'r'), $bodySize)); $request->setBody($body); }
php
public static function validateCurlPOSTBody(Request $request, $curlHandle = null) { $readFunction = $request->getCurlOption(CURLOPT_READFUNCTION); if (is_null($readFunction)) { return; } // Guzzle 4 sometimes sets the post body in CURLOPT_POSTFIELDS even if // they have already set CURLOPT_READFUNCTION. if ($request->getBody()) { return; } $bodySize = $request->getCurlOption(CURLOPT_INFILESIZE); Assertion::notEmpty($bodySize, 'To set a CURLOPT_READFUNCTION, CURLOPT_INFILESIZE must be set.'); $body = call_user_func_array($readFunction, array($curlHandle, fopen('php://memory', 'r'), $bodySize)); $request->setBody($body); }
[ "public", "static", "function", "validateCurlPOSTBody", "(", "Request", "$", "request", ",", "$", "curlHandle", "=", "null", ")", "{", "$", "readFunction", "=", "$", "request", "->", "getCurlOption", "(", "CURLOPT_READFUNCTION", ")", ";", "if", "(", "is_null",...
Makes sure we've properly handled the POST body, such as ensuring that CURLOPT_INFILESIZE is set if CURLOPT_READFUNCTION is set. @param Request $request Request to set cURL option to. @param resource $curlHandle cURL handle associated with the request.
[ "Makes", "sure", "we", "ve", "properly", "handled", "the", "POST", "body", "such", "as", "ensuring", "that", "CURLOPT_INFILESIZE", "is", "set", "if", "CURLOPT_READFUNCTION", "is", "set", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/CurlHelper.php#L198-L215
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlInit
public static function curlInit($url = null) { $curlHandle = \curl_init($url); self::$requests[(int) $curlHandle] = new Request('GET', $url); self::$curlOptions[(int) $curlHandle] = array(); return $curlHandle; }
php
public static function curlInit($url = null) { $curlHandle = \curl_init($url); self::$requests[(int) $curlHandle] = new Request('GET', $url); self::$curlOptions[(int) $curlHandle] = array(); return $curlHandle; }
[ "public", "static", "function", "curlInit", "(", "$", "url", "=", "null", ")", "{", "$", "curlHandle", "=", "\\", "curl_init", "(", "$", "url", ")", ";", "self", "::", "$", "requests", "[", "(", "int", ")", "$", "curlHandle", "]", "=", "new", "Requ...
Initialize a cURL session. @link http://www.php.net/manual/en/function.curl-init.php @param string $url (Optional) url. @return resource cURL handle.
[ "Initialize", "a", "cURL", "session", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L165-L172
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlReset
public static function curlReset($curlHandle) { \curl_reset($curlHandle); self::$requests[(int) $curlHandle] = new Request('GET', null); self::$curlOptions[(int) $curlHandle] = array(); unset(self::$responses[(int) $curlHandle]); }
php
public static function curlReset($curlHandle) { \curl_reset($curlHandle); self::$requests[(int) $curlHandle] = new Request('GET', null); self::$curlOptions[(int) $curlHandle] = array(); unset(self::$responses[(int) $curlHandle]); }
[ "public", "static", "function", "curlReset", "(", "$", "curlHandle", ")", "{", "\\", "curl_reset", "(", "$", "curlHandle", ")", ";", "self", "::", "$", "requests", "[", "(", "int", ")", "$", "curlHandle", "]", "=", "new", "Request", "(", "'GET'", ",", ...
Reset a cURL session. @link http://www.php.net/manual/en/function.curl-reset.php @param resource $curlHandle A cURL handle returned by curl_init().
[ "Reset", "a", "cURL", "session", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L180-L186
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlExec
public static function curlExec($curlHandle) { $request = self::$requests[(int) $curlHandle]; CurlHelper::validateCurlPOSTBody($request, $curlHandle); $requestCallback = self::$requestCallback; self::$responses[(int) $curlHandle] = $requestCallback($request); return CurlHelper::handleOutput( self::$responses[(int) $curlHandle], self::$curlOptions[(int) $curlHandle], $curlHandle ); }
php
public static function curlExec($curlHandle) { $request = self::$requests[(int) $curlHandle]; CurlHelper::validateCurlPOSTBody($request, $curlHandle); $requestCallback = self::$requestCallback; self::$responses[(int) $curlHandle] = $requestCallback($request); return CurlHelper::handleOutput( self::$responses[(int) $curlHandle], self::$curlOptions[(int) $curlHandle], $curlHandle ); }
[ "public", "static", "function", "curlExec", "(", "$", "curlHandle", ")", "{", "$", "request", "=", "self", "::", "$", "requests", "[", "(", "int", ")", "$", "curlHandle", "]", ";", "CurlHelper", "::", "validateCurlPOSTBody", "(", "$", "request", ",", "$"...
Perform a cURL session. @link http://www.php.net/manual/en/function.curl-exec.php @param resource $curlHandle A cURL handle returned by curl_init(). @return mixed Returns TRUE on success or FALSE on failure. However, if the CURLOPT_RETURNTRANSFER option is set, it will return the result on success, FALSE on failure.
[ "Perform", "a", "cURL", "session", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L198-L211
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlMultiAddHandle
public static function curlMultiAddHandle($multiHandle, $curlHandle) { if (!isset(self::$multiHandles[(int) $multiHandle])) { self::$multiHandles[(int) $multiHandle] = array(); } self::$multiHandles[(int) $multiHandle][(int) $curlHandle] = $curlHandle; }
php
public static function curlMultiAddHandle($multiHandle, $curlHandle) { if (!isset(self::$multiHandles[(int) $multiHandle])) { self::$multiHandles[(int) $multiHandle] = array(); } self::$multiHandles[(int) $multiHandle][(int) $curlHandle] = $curlHandle; }
[ "public", "static", "function", "curlMultiAddHandle", "(", "$", "multiHandle", ",", "$", "curlHandle", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "multiHandles", "[", "(", "int", ")", "$", "multiHandle", "]", ")", ")", "{", "self", "::"...
Add a normal cURL handle to a cURL multi handle. @link http://www.php.net/manual/en/function.curl-multi-add-handle.php @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). @param resource $curlHandle A cURL handle returned by curl_init().
[ "Add", "a", "normal", "cURL", "handle", "to", "a", "cURL", "multi", "handle", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L220-L227
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlMultiRemoveHandle
public static function curlMultiRemoveHandle($multiHandle, $curlHandle) { if (isset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle])) { unset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle]); } }
php
public static function curlMultiRemoveHandle($multiHandle, $curlHandle) { if (isset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle])) { unset(self::$multiHandles[(int) $multiHandle][(int) $curlHandle]); } }
[ "public", "static", "function", "curlMultiRemoveHandle", "(", "$", "multiHandle", ",", "$", "curlHandle", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "multiHandles", "[", "(", "int", ")", "$", "multiHandle", "]", "[", "(", "int", ")", "$", "c...
Remove a multi handle from a set of cURL handles. @link http://www.php.net/manual/en/function.curl-multi-remove-handle.php @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). @param resource $curlHandle A cURL handle returned by curl_init().
[ "Remove", "a", "multi", "handle", "from", "a", "set", "of", "cURL", "handles", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L236-L241
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlMultiExec
public static function curlMultiExec($multiHandle, &$stillRunning) { if (isset(self::$multiHandles[(int) $multiHandle])) { foreach (self::$multiHandles[(int) $multiHandle] as $curlHandle) { if (!isset(self::$responses[(int) $curlHandle])) { self::$multiExecLastChs[] = $curlHandle; self::curlExec($curlHandle); } } } return CURLM_OK; }
php
public static function curlMultiExec($multiHandle, &$stillRunning) { if (isset(self::$multiHandles[(int) $multiHandle])) { foreach (self::$multiHandles[(int) $multiHandle] as $curlHandle) { if (!isset(self::$responses[(int) $curlHandle])) { self::$multiExecLastChs[] = $curlHandle; self::curlExec($curlHandle); } } } return CURLM_OK; }
[ "public", "static", "function", "curlMultiExec", "(", "$", "multiHandle", ",", "&", "$", "stillRunning", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "multiHandles", "[", "(", "int", ")", "$", "multiHandle", "]", ")", ")", "{", "foreach", "(",...
Run the sub-connections of the current cURL handle. @link http://www.php.net/manual/en/function.curl-multi-exec.php @param resource $multiHandle A cURL multi handle returned by curl_multi_init(). @param integer $stillRunning A reference to a flag to tell whether the operations are still running. @return integer A cURL code defined in the cURL Predefined Constants.
[ "Run", "the", "sub", "-", "connections", "of", "the", "current", "cURL", "handle", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L252-L264
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlMultiInfoRead
public static function curlMultiInfoRead() { if (!empty(self::$multiExecLastChs)) { $info = array( 'msg' => CURLMSG_DONE, 'handle' => array_pop(self::$multiExecLastChs), 'result' => CURLE_OK ); return $info; } return false; }
php
public static function curlMultiInfoRead() { if (!empty(self::$multiExecLastChs)) { $info = array( 'msg' => CURLMSG_DONE, 'handle' => array_pop(self::$multiExecLastChs), 'result' => CURLE_OK ); return $info; } return false; }
[ "public", "static", "function", "curlMultiInfoRead", "(", ")", "{", "if", "(", "!", "empty", "(", "self", "::", "$", "multiExecLastChs", ")", ")", "{", "$", "info", "=", "array", "(", "'msg'", "=>", "CURLMSG_DONE", ",", "'handle'", "=>", "array_pop", "("...
Get information about the current transfers. @link http://www.php.net/manual/en/function.curl-multi-info-read.php @return array|bool On success, returns an associative array for the message, FALSE on failure.
[ "Get", "information", "about", "the", "current", "transfers", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L273-L286
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlSetopt
public static function curlSetopt($curlHandle, $option, $value) { CurlHelper::setCurlOptionOnRequest(self::$requests[(int) $curlHandle], $option, $value, $curlHandle); static::$curlOptions[(int) $curlHandle][$option] = $value; return \curl_setopt($curlHandle, $option, $value); }
php
public static function curlSetopt($curlHandle, $option, $value) { CurlHelper::setCurlOptionOnRequest(self::$requests[(int) $curlHandle], $option, $value, $curlHandle); static::$curlOptions[(int) $curlHandle][$option] = $value; return \curl_setopt($curlHandle, $option, $value); }
[ "public", "static", "function", "curlSetopt", "(", "$", "curlHandle", ",", "$", "option", ",", "$", "value", ")", "{", "CurlHelper", "::", "setCurlOptionOnRequest", "(", "self", "::", "$", "requests", "[", "(", "int", ")", "$", "curlHandle", "]", ",", "$...
Set an option for a cURL transfer. @link http://www.php.net/manual/en/function.curl-setopt.php @param resource $curlHandle A cURL handle returned by curl_init(). @param integer $option The CURLOPT_XXX option to set. @param mixed $value The value to be set on option. @return boolean Returns TRUE on success or FALSE on failure.
[ "Set", "an", "option", "for", "a", "cURL", "transfer", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L315-L322
train
php-vcr/php-vcr
src/VCR/LibraryHooks/CurlHook.php
CurlHook.curlSetoptArray
public static function curlSetoptArray($curlHandle, $options) { if (is_array($options)) { foreach ($options as $option => $value) { static::curlSetopt($curlHandle, $option, $value); } } }
php
public static function curlSetoptArray($curlHandle, $options) { if (is_array($options)) { foreach ($options as $option => $value) { static::curlSetopt($curlHandle, $option, $value); } } }
[ "public", "static", "function", "curlSetoptArray", "(", "$", "curlHandle", ",", "$", "options", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "foreach", "(", "$", "options", "as", "$", "option", "=>", "$", "value", ")", "{", "s...
Set multiple options for a cURL transfer. @link http://www.php.net/manual/en/function.curl-setopt-array.php @param resource $curlHandle A cURL handle returned by curl_init(). @param array $options An array specifying which options to set and their values.
[ "Set", "multiple", "options", "for", "a", "cURL", "transfer", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/LibraryHooks/CurlHook.php#L331-L338
train
php-vcr/php-vcr
src/VCR/RequestMatcher.php
RequestMatcher.matchHeaders
public static function matchHeaders(Request $first, Request $second) { // Use array_filter to ignore headers which are null. return array_filter($first->getHeaders()) === array_filter($second->getHeaders()); }
php
public static function matchHeaders(Request $first, Request $second) { // Use array_filter to ignore headers which are null. return array_filter($first->getHeaders()) === array_filter($second->getHeaders()); }
[ "public", "static", "function", "matchHeaders", "(", "Request", "$", "first", ",", "Request", "$", "second", ")", "{", "// Use array_filter to ignore headers which are null.", "return", "array_filter", "(", "$", "first", "->", "getHeaders", "(", ")", ")", "===", "...
Returns true if the headers of both specified requests match. @param Request $first First request to match. @param Request $second Second request to match. @return boolean True if the headers of both specified requests match.
[ "Returns", "true", "if", "the", "headers", "of", "both", "specified", "requests", "match", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/RequestMatcher.php#L57-L62
train
php-vcr/php-vcr
src/VCR/Util/HttpUtil.php
HttpUtil.parseHeaders
public static function parseHeaders(array $headers) { $headerGroups = array(); $headerList = array(); // Collect matching headers into groups foreach ($headers as $line) { list($key, $value) = explode(': ', $line, 2); if (!isset($headerGroups[$key])) { $headerGroups[$key] = array(); } $headerGroups[$key][] = $value; } // Collapse groups foreach ($headerGroups as $key => $values) { $headerList[$key] = implode(', ', $values); } return $headerList; }
php
public static function parseHeaders(array $headers) { $headerGroups = array(); $headerList = array(); // Collect matching headers into groups foreach ($headers as $line) { list($key, $value) = explode(': ', $line, 2); if (!isset($headerGroups[$key])) { $headerGroups[$key] = array(); } $headerGroups[$key][] = $value; } // Collapse groups foreach ($headerGroups as $key => $values) { $headerList[$key] = implode(', ', $values); } return $headerList; }
[ "public", "static", "function", "parseHeaders", "(", "array", "$", "headers", ")", "{", "$", "headerGroups", "=", "array", "(", ")", ";", "$", "headerList", "=", "array", "(", ")", ";", "// Collect matching headers into groups", "foreach", "(", "$", "headers",...
Returns key value pairs of response headers. @param array $headers List of headers. Example: ['Content-Type: text/html', '...'] @return array Key/value pairs of headers, e.g. ['Content-Type' => 'text/html']
[ "Returns", "key", "value", "pairs", "of", "response", "headers", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/HttpUtil.php#L15-L35
train
php-vcr/php-vcr
src/VCR/Util/HttpUtil.php
HttpUtil.parseStatus
public static function parseStatus($status) { Assertion::startsWith( $status, 'HTTP/', "Invalid HTTP status '$status', expected format like: 'HTTP/1.1 200 OK'." ); $part = explode(' ', $status, 3); return array( 'http_version' => substr(strrchr($part[0], '/'), 1), 'code' => $part[1], 'message' => isset($part[2]) ? $part[2] : '' ); }
php
public static function parseStatus($status) { Assertion::startsWith( $status, 'HTTP/', "Invalid HTTP status '$status', expected format like: 'HTTP/1.1 200 OK'." ); $part = explode(' ', $status, 3); return array( 'http_version' => substr(strrchr($part[0], '/'), 1), 'code' => $part[1], 'message' => isset($part[2]) ? $part[2] : '' ); }
[ "public", "static", "function", "parseStatus", "(", "$", "status", ")", "{", "Assertion", "::", "startsWith", "(", "$", "status", ",", "'HTTP/'", ",", "\"Invalid HTTP status '$status', expected format like: 'HTTP/1.1 200 OK'.\"", ")", ";", "$", "part", "=", "explode",...
Returns http_version, code and message from a HTTP status line. @param string $status HTTP status line, e.g. HTTP/1.1 200 OK @return array Parsed 'http_version', 'code' and 'message'.
[ "Returns", "http_version", "code", "and", "message", "from", "a", "HTTP", "status", "line", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/HttpUtil.php#L43-L58
train
php-vcr/php-vcr
src/VCR/Util/HttpUtil.php
HttpUtil.parseResponse
public static function parseResponse($response) { $response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response); list($rawHeader, $rawBody) = explode("\r\n\r\n", $response, 2); // Parse headers and status. $headers = self::parseRawHeader($rawHeader); $status = array_shift($headers); return array($status, $headers, $rawBody); }
php
public static function parseResponse($response) { $response = str_replace("HTTP/1.1 100 Continue\r\n\r\n", '', $response); list($rawHeader, $rawBody) = explode("\r\n\r\n", $response, 2); // Parse headers and status. $headers = self::parseRawHeader($rawHeader); $status = array_shift($headers); return array($status, $headers, $rawBody); }
[ "public", "static", "function", "parseResponse", "(", "$", "response", ")", "{", "$", "response", "=", "str_replace", "(", "\"HTTP/1.1 100 Continue\\r\\n\\r\\n\"", ",", "''", ",", "$", "response", ")", ";", "list", "(", "$", "rawHeader", ",", "$", "rawBody", ...
Returns status, headers and body from a HTTP response string. @param string $response Response including header and body. @return array Status, headers and body as strings.
[ "Returns", "status", "headers", "and", "body", "from", "a", "HTTP", "response", "string", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/HttpUtil.php#L66-L77
train
php-vcr/php-vcr
src/VCR/Util/HttpUtil.php
HttpUtil.formatAsStatusWithHeadersString
public static function formatAsStatusWithHeadersString(Response $response) { $headers = self::formatHeadersForCurl($response->getHeaders()); array_unshift($headers, self::formatAsStatusString($response)); return join("\r\n", $headers) . "\r\n\r\n"; }
php
public static function formatAsStatusWithHeadersString(Response $response) { $headers = self::formatHeadersForCurl($response->getHeaders()); array_unshift($headers, self::formatAsStatusString($response)); return join("\r\n", $headers) . "\r\n\r\n"; }
[ "public", "static", "function", "formatAsStatusWithHeadersString", "(", "Response", "$", "response", ")", "{", "$", "headers", "=", "self", "::", "formatHeadersForCurl", "(", "$", "response", "->", "getHeaders", "(", ")", ")", ";", "array_unshift", "(", "$", "...
Returns a HTTP status line with headers from specified response. @param Response $response @return string HTTP status line.
[ "Returns", "a", "HTTP", "status", "line", "with", "headers", "from", "specified", "response", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/HttpUtil.php#L126-L131
train
php-vcr/php-vcr
src/VCR/CodeTransform/AbstractCodeTransform.php
AbstractCodeTransform.register
public function register() { if (!$this->isRegistered) { $this->isRegistered = stream_filter_register(static::NAME, get_called_class()); } return $this->isRegistered; }
php
public function register() { if (!$this->isRegistered) { $this->isRegistered = stream_filter_register(static::NAME, get_called_class()); } return $this->isRegistered; }
[ "public", "function", "register", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isRegistered", ")", "{", "$", "this", "->", "isRegistered", "=", "stream_filter_register", "(", "static", "::", "NAME", ",", "get_called_class", "(", ")", ")", ";", "}",...
Attaches the current filter to a stream. @return bool true on success or false on failure.
[ "Attaches", "the", "current", "filter", "to", "a", "stream", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/CodeTransform/AbstractCodeTransform.php#L26-L33
train
php-vcr/php-vcr
src/VCR/CodeTransform/AbstractCodeTransform.php
AbstractCodeTransform.filter
public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = $this->transformCode($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; }
php
public function filter($in, $out, &$consumed, $closing) { while ($bucket = stream_bucket_make_writeable($in)) { $bucket->data = $this->transformCode($bucket->data); $consumed += $bucket->datalen; stream_bucket_append($out, $bucket); } return PSFS_PASS_ON; }
[ "public", "function", "filter", "(", "$", "in", ",", "$", "out", ",", "&", "$", "consumed", ",", "$", "closing", ")", "{", "while", "(", "$", "bucket", "=", "stream_bucket_make_writeable", "(", "$", "in", ")", ")", "{", "$", "bucket", "->", "data", ...
Applies the current filter to a provided stream. @param resource $in @param resource $out @param int $consumed @param bool $closing @return int PSFS_PASS_ON @link http://www.php.net/manual/en/php-user-filter.filter.php
[ "Applies", "the", "current", "filter", "to", "a", "provided", "stream", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/CodeTransform/AbstractCodeTransform.php#L47-L56
train
php-vcr/php-vcr
src/VCR/Videorecorder.php
Videorecorder.turnOn
public function turnOn() { if ($this->isOn) { $this->turnOff(); } $this->enableLibraryHooks(); $this->isOn = true; }
php
public function turnOn() { if ($this->isOn) { $this->turnOff(); } $this->enableLibraryHooks(); $this->isOn = true; }
[ "public", "function", "turnOn", "(", ")", "{", "if", "(", "$", "this", "->", "isOn", ")", "{", "$", "this", "->", "turnOff", "(", ")", ";", "}", "$", "this", "->", "enableLibraryHooks", "(", ")", ";", "$", "this", "->", "isOn", "=", "true", ";", ...
Turns on this videorecorder. This enables configured library hooks. @api @return void
[ "Turns", "on", "this", "videorecorder", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Videorecorder.php#L116-L124
train
php-vcr/php-vcr
src/VCR/Videorecorder.php
Videorecorder.turnOff
public function turnOff() { if ($this->isOn) { $this->disableLibraryHooks(); $this->eject(); $this->isOn = false; } }
php
public function turnOff() { if ($this->isOn) { $this->disableLibraryHooks(); $this->eject(); $this->isOn = false; } }
[ "public", "function", "turnOff", "(", ")", "{", "if", "(", "$", "this", "->", "isOn", ")", "{", "$", "this", "->", "disableLibraryHooks", "(", ")", ";", "$", "this", "->", "eject", "(", ")", ";", "$", "this", "->", "isOn", "=", "false", ";", "}",...
Turns off this videorecorder. Library hooks will be disabled and cassettes ejected. @api @return void
[ "Turns", "off", "this", "videorecorder", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Videorecorder.php#L135-L142
train
php-vcr/php-vcr
src/VCR/Videorecorder.php
Videorecorder.insertCassette
public function insertCassette($cassetteName) { Assertion::true($this->isOn, 'Please turn on VCR before inserting a cassette, use: VCR::turnOn().'); if (!is_null($this->cassette)) { $this->eject(); } $storage = $this->factory->get('Storage', array($cassetteName)); $this->cassette = new Cassette($cassetteName, $this->config, $storage); $this->enableLibraryHooks(); }
php
public function insertCassette($cassetteName) { Assertion::true($this->isOn, 'Please turn on VCR before inserting a cassette, use: VCR::turnOn().'); if (!is_null($this->cassette)) { $this->eject(); } $storage = $this->factory->get('Storage', array($cassetteName)); $this->cassette = new Cassette($cassetteName, $this->config, $storage); $this->enableLibraryHooks(); }
[ "public", "function", "insertCassette", "(", "$", "cassetteName", ")", "{", "Assertion", "::", "true", "(", "$", "this", "->", "isOn", ",", "'Please turn on VCR before inserting a cassette, use: VCR::turnOn().'", ")", ";", "if", "(", "!", "is_null", "(", "$", "thi...
Inserts a cassette to record responses and requests on. @api @param string $cassetteName Name of the cassette (used for the cassette filename). @return void @throws VCRException If videorecorder is turned off when inserting a cassette.
[ "Inserts", "a", "cassette", "to", "record", "responses", "and", "requests", "on", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Videorecorder.php#L169-L181
train
php-vcr/php-vcr
src/VCR/Videorecorder.php
Videorecorder.handleRequest
public function handleRequest(Request $request) { if ($this->cassette === null) { throw new \BadMethodCallException( 'Invalid http request. No cassette inserted. ' . 'Please make sure to insert a cassette in your unit test using ' . "VCR::insertCassette('name');" ); } $event = new BeforePlaybackEvent($request, $this->cassette); $this->dispatch(VCREvents::VCR_BEFORE_PLAYBACK, $event); $response = $this->cassette->playback($request); // Playback succeeded and the recorded response can be returned. if (!empty($response)) { $event = new AfterPlaybackEvent($request, $response, $this->cassette); $this->dispatch(VCREvents::VCR_AFTER_PLAYBACK, $event); return $response; } if (VCR::MODE_NONE === $this->config->getMode() || VCR::MODE_ONCE === $this->config->getMode() && $this->cassette->isNew() === false ) { throw new \LogicException( sprintf( "The request does not match a previously recorded request and the 'mode' is set to '%s'. " . "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'. " . 'Please see http://php-vcr.github.io/documentation/configuration/#record-modes.' . "\nCassette: %s \n Request: %s", $this->config->getMode(), $this->cassette->getName(), print_r($request->toArray(), true) ) ); } $this->disableLibraryHooks(); $this->dispatch(VCREvents::VCR_BEFORE_HTTP_REQUEST, new BeforeHttpRequestEvent($request)); $response = $this->client->send($request); $this->dispatch(VCREvents::VCR_AFTER_HTTP_REQUEST, new AfterHttpRequestEvent($request, $response)); $this->dispatch(VCREvents::VCR_BEFORE_RECORD, new BeforeRecordEvent($request, $response, $this->cassette)); $this->cassette->record($request, $response); $this->enableLibraryHooks(); return $response; }
php
public function handleRequest(Request $request) { if ($this->cassette === null) { throw new \BadMethodCallException( 'Invalid http request. No cassette inserted. ' . 'Please make sure to insert a cassette in your unit test using ' . "VCR::insertCassette('name');" ); } $event = new BeforePlaybackEvent($request, $this->cassette); $this->dispatch(VCREvents::VCR_BEFORE_PLAYBACK, $event); $response = $this->cassette->playback($request); // Playback succeeded and the recorded response can be returned. if (!empty($response)) { $event = new AfterPlaybackEvent($request, $response, $this->cassette); $this->dispatch(VCREvents::VCR_AFTER_PLAYBACK, $event); return $response; } if (VCR::MODE_NONE === $this->config->getMode() || VCR::MODE_ONCE === $this->config->getMode() && $this->cassette->isNew() === false ) { throw new \LogicException( sprintf( "The request does not match a previously recorded request and the 'mode' is set to '%s'. " . "If you want to send the request anyway, make sure your 'mode' is set to 'new_episodes'. " . 'Please see http://php-vcr.github.io/documentation/configuration/#record-modes.' . "\nCassette: %s \n Request: %s", $this->config->getMode(), $this->cassette->getName(), print_r($request->toArray(), true) ) ); } $this->disableLibraryHooks(); $this->dispatch(VCREvents::VCR_BEFORE_HTTP_REQUEST, new BeforeHttpRequestEvent($request)); $response = $this->client->send($request); $this->dispatch(VCREvents::VCR_AFTER_HTTP_REQUEST, new AfterHttpRequestEvent($request, $response)); $this->dispatch(VCREvents::VCR_BEFORE_RECORD, new BeforeRecordEvent($request, $response, $this->cassette)); $this->cassette->record($request, $response); $this->enableLibraryHooks(); return $response; }
[ "public", "function", "handleRequest", "(", "Request", "$", "request", ")", "{", "if", "(", "$", "this", "->", "cassette", "===", "null", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "'Invalid http request. No cassette inserted. '", ".", "'Please...
Records, sends or plays back a intercepted request. If a request was already recorded on a cassette it's response is returned, otherwise the request is issued and it's response recorded (and returned). @api @param Request $request Intercepted request. @return Response Response for the intercepted request. @throws \BadMethodCallException If there was no cassette inserted. @throws \LogicException If the mode is set to none or once and the cassette did not have a matching response.
[ "Records", "sends", "or", "plays", "back", "a", "intercepted", "request", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Videorecorder.php#L210-L260
train
php-vcr/php-vcr
src/VCR/Videorecorder.php
Videorecorder.disableLibraryHooks
protected function disableLibraryHooks() { foreach ($this->config->getLibraryHooks() as $hookClass) { $hook = $this->factory->get($hookClass); $hook->disable(); } }
php
protected function disableLibraryHooks() { foreach ($this->config->getLibraryHooks() as $hookClass) { $hook = $this->factory->get($hookClass); $hook->disable(); } }
[ "protected", "function", "disableLibraryHooks", "(", ")", "{", "foreach", "(", "$", "this", "->", "config", "->", "getLibraryHooks", "(", ")", "as", "$", "hookClass", ")", "{", "$", "hook", "=", "$", "this", "->", "factory", "->", "get", "(", "$", "hoo...
Disables all library hooks. @api @return void
[ "Disables", "all", "library", "hooks", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Videorecorder.php#L269-L275
train
php-vcr/php-vcr
src/VCR/Videorecorder.php
Videorecorder.enableLibraryHooks
protected function enableLibraryHooks() { $self = $this; foreach ($this->config->getLibraryHooks() as $hookClass) { $hook = $this->factory->get($hookClass); $hook->enable( function (Request $request) use ($self) { return $self->handleRequest($request); } ); } }
php
protected function enableLibraryHooks() { $self = $this; foreach ($this->config->getLibraryHooks() as $hookClass) { $hook = $this->factory->get($hookClass); $hook->enable( function (Request $request) use ($self) { return $self->handleRequest($request); } ); } }
[ "protected", "function", "enableLibraryHooks", "(", ")", "{", "$", "self", "=", "$", "this", ";", "foreach", "(", "$", "this", "->", "config", "->", "getLibraryHooks", "(", ")", "as", "$", "hookClass", ")", "{", "$", "hook", "=", "$", "this", "->", "...
Enables configured library hooks. @api @return void
[ "Enables", "configured", "library", "hooks", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Videorecorder.php#L284-L295
train
php-vcr/php-vcr
src/VCR/Util/StreamProcessor.php
StreamProcessor.intercept
public function intercept() { if (!$this->isIntercepting) { stream_wrapper_unregister(self::PROTOCOL); $this->isIntercepting = stream_wrapper_register(self::PROTOCOL, __CLASS__); } }
php
public function intercept() { if (!$this->isIntercepting) { stream_wrapper_unregister(self::PROTOCOL); $this->isIntercepting = stream_wrapper_register(self::PROTOCOL, __CLASS__); } }
[ "public", "function", "intercept", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isIntercepting", ")", "{", "stream_wrapper_unregister", "(", "self", "::", "PROTOCOL", ")", ";", "$", "this", "->", "isIntercepting", "=", "stream_wrapper_register", "(", "...
Registers current class as the PHP file stream wrapper. @return void
[ "Registers", "current", "class", "as", "the", "PHP", "file", "stream", "wrapper", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/StreamProcessor.php#L72-L78
train
php-vcr/php-vcr
src/VCR/Util/StreamProcessor.php
StreamProcessor.isWhitelisted
protected function isWhitelisted($uri) { $whiteList = static::$configuration->getWhiteList(); if (empty($whiteList)) { return true; } $uri = $this->normalizePath($uri); foreach ($whiteList as $path) { if (strpos($uri, $path) !== false) { return true; } } return false; }
php
protected function isWhitelisted($uri) { $whiteList = static::$configuration->getWhiteList(); if (empty($whiteList)) { return true; } $uri = $this->normalizePath($uri); foreach ($whiteList as $path) { if (strpos($uri, $path) !== false) { return true; } } return false; }
[ "protected", "function", "isWhitelisted", "(", "$", "uri", ")", "{", "$", "whiteList", "=", "static", "::", "$", "configuration", "->", "getWhiteList", "(", ")", ";", "if", "(", "empty", "(", "$", "whiteList", ")", ")", "{", "return", "true", ";", "}",...
Determines that the provided url is member of a url whitelist. @param string $uri @return bool True if the specified url is whitelisted, false otherwise.
[ "Determines", "that", "the", "provided", "url", "is", "member", "of", "a", "url", "whitelist", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/StreamProcessor.php#L97-L114
train
php-vcr/php-vcr
src/VCR/Util/StreamProcessor.php
StreamProcessor.isBlacklisted
protected function isBlacklisted($uri) { $uri = $this->normalizePath($uri); foreach (static::$configuration->getBlackList() as $path) { if (strpos($uri, $path) !== false) { return true; } } return false; }
php
protected function isBlacklisted($uri) { $uri = $this->normalizePath($uri); foreach (static::$configuration->getBlackList() as $path) { if (strpos($uri, $path) !== false) { return true; } } return false; }
[ "protected", "function", "isBlacklisted", "(", "$", "uri", ")", "{", "$", "uri", "=", "$", "this", "->", "normalizePath", "(", "$", "uri", ")", ";", "foreach", "(", "static", "::", "$", "configuration", "->", "getBlackList", "(", ")", "as", "$", "path"...
Determines that the provided url is member of a url blacklist. @param string $uri @return bool True if the provided url is blacklisted, false otherwise.
[ "Determines", "that", "the", "provided", "url", "is", "member", "of", "a", "url", "blacklist", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/StreamProcessor.php#L123-L134
train
php-vcr/php-vcr
src/VCR/Util/StreamProcessor.php
StreamProcessor.stream_open
public function stream_open($path, $mode, $options, &$openedPath) { // file_exists catches paths like /dev/urandom that are missed by is_file. if ('r' === substr($mode, 0, 1) && !file_exists($path)) { return false; } $this->restore(); if (isset($this->context)) { $this->resource = fopen($path, $mode, $options & STREAM_USE_PATH, $this->context); } else { $this->resource = fopen($path, $mode, $options & STREAM_USE_PATH); } if ($options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { $this->appendFiltersToStream($this->resource); } $this->intercept(); return $this->resource !== false; }
php
public function stream_open($path, $mode, $options, &$openedPath) { // file_exists catches paths like /dev/urandom that are missed by is_file. if ('r' === substr($mode, 0, 1) && !file_exists($path)) { return false; } $this->restore(); if (isset($this->context)) { $this->resource = fopen($path, $mode, $options & STREAM_USE_PATH, $this->context); } else { $this->resource = fopen($path, $mode, $options & STREAM_USE_PATH); } if ($options & self::STREAM_OPEN_FOR_INCLUDE && $this->shouldProcess($path)) { $this->appendFiltersToStream($this->resource); } $this->intercept(); return $this->resource !== false; }
[ "public", "function", "stream_open", "(", "$", "path", ",", "$", "mode", ",", "$", "options", ",", "&", "$", "openedPath", ")", "{", "// file_exists catches paths like /dev/urandom that are missed by is_file.", "if", "(", "'r'", "===", "substr", "(", "$", "mode", ...
Opens a stream and attaches registered filters. @param string $path Specifies the URL that was passed to the original function. @param string $mode The mode used to open the file, as detailed for fopen(). @param integer $options Holds additional flags set by the streams API. It can hold one or more of the following values OR'd together. @param string $openedPath If the path is opened successfully, and STREAM_USE_PATH is set in options, opened_path should be set to the full path of the file/resource that was actually opened. @return boolean Returns TRUE on success or FALSE on failure.
[ "Opens", "a", "stream", "and", "attaches", "registered", "filters", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/StreamProcessor.php#L172-L194
train
php-vcr/php-vcr
src/VCR/Util/StreamProcessor.php
StreamProcessor.detachCodeTransformer
public function detachCodeTransformer(AbstractCodeTransform $codeTransformer) { if (!empty(static::$codeTransformers[$codeTransformer::NAME])) { unset(static::$codeTransformers[$codeTransformer::NAME]); } }
php
public function detachCodeTransformer(AbstractCodeTransform $codeTransformer) { if (!empty(static::$codeTransformers[$codeTransformer::NAME])) { unset(static::$codeTransformers[$codeTransformer::NAME]); } }
[ "public", "function", "detachCodeTransformer", "(", "AbstractCodeTransform", "$", "codeTransformer", ")", "{", "if", "(", "!", "empty", "(", "static", "::", "$", "codeTransformers", "[", "$", "codeTransformer", "::", "NAME", "]", ")", ")", "{", "unset", "(", ...
Removes a code transformer from the stream processor. @param AbstractCodeTransform $codeTransformer @return void
[ "Removes", "a", "code", "transformer", "from", "the", "stream", "processor", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/StreamProcessor.php#L614-L619
train
php-vcr/php-vcr
src/VCR/Util/StreamProcessor.php
StreamProcessor.appendFiltersToStream
protected function appendFiltersToStream($stream) { foreach (static::$codeTransformers as $codeTransformer) { stream_filter_append($stream, $codeTransformer::NAME, STREAM_FILTER_READ); } }
php
protected function appendFiltersToStream($stream) { foreach (static::$codeTransformers as $codeTransformer) { stream_filter_append($stream, $codeTransformer::NAME, STREAM_FILTER_READ); } }
[ "protected", "function", "appendFiltersToStream", "(", "$", "stream", ")", "{", "foreach", "(", "static", "::", "$", "codeTransformers", "as", "$", "codeTransformer", ")", "{", "stream_filter_append", "(", "$", "stream", ",", "$", "codeTransformer", "::", "NAME"...
Appends the current set of php_user_filter to the provided stream. @param resource $stream
[ "Appends", "the", "current", "set", "of", "php_user_filter", "to", "the", "provided", "stream", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/StreamProcessor.php#L626-L631
train
php-vcr/php-vcr
src/VCR/Storage/Yaml.php
Yaml.next
public function next() { $recording = $this->yamlParser->parse($this->readNextRecord()); $this->current = $recording[0]; ++$this->position; }
php
public function next() { $recording = $this->yamlParser->parse($this->readNextRecord()); $this->current = $recording[0]; ++$this->position; }
[ "public", "function", "next", "(", ")", "{", "$", "recording", "=", "$", "this", "->", "yamlParser", "->", "parse", "(", "$", "this", "->", "readNextRecord", "(", ")", ")", ";", "$", "this", "->", "current", "=", "$", "recording", "[", "0", "]", ";...
Parses the next record. @return void
[ "Parses", "the", "next", "record", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Storage/Yaml.php#L58-L63
train
php-vcr/php-vcr
src/VCR/Storage/Yaml.php
Yaml.rewind
public function rewind() { rewind($this->handle); $this->isEOF = false; $this->isValidPosition = true; $this->position = 0; }
php
public function rewind() { rewind($this->handle); $this->isEOF = false; $this->isValidPosition = true; $this->position = 0; }
[ "public", "function", "rewind", "(", ")", "{", "rewind", "(", "$", "this", "->", "handle", ")", ";", "$", "this", "->", "isEOF", "=", "false", ";", "$", "this", "->", "isValidPosition", "=", "true", ";", "$", "this", "->", "position", "=", "0", ";"...
Resets the storage to the beginning. @return void
[ "Resets", "the", "storage", "to", "the", "beginning", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Storage/Yaml.php#L108-L114
train
php-vcr/php-vcr
src/VCR/Storage/Yaml.php
Yaml.valid
public function valid() { if (is_null($this->current)) { $this->next(); } return ! is_null($this->current) && $this->isValidPosition; }
php
public function valid() { if (is_null($this->current)) { $this->next(); } return ! is_null($this->current) && $this->isValidPosition; }
[ "public", "function", "valid", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "current", ")", ")", "{", "$", "this", "->", "next", "(", ")", ";", "}", "return", "!", "is_null", "(", "$", "this", "->", "current", ")", "&&", "$", "t...
Returns true if the current record is valid. @return boolean True if the current record is valid.
[ "Returns", "true", "if", "the", "current", "record", "is", "valid", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Storage/Yaml.php#L121-L128
train
php-vcr/php-vcr
src/VCR/VCRFactory.php
VCRFactory.getOrCreate
public function getOrCreate($className, $params = array()) { $key = $className . join('-', $params); if (isset($this->mapping[$key])) { return $this->mapping[$key]; } if (method_exists($this, $this->getMethodName($className))) { $callback = array($this, $this->getMethodName($className)); $instance = call_user_func_array($callback, $params); } else { $instance = new $className; } return $this->mapping[$key] = $instance; }
php
public function getOrCreate($className, $params = array()) { $key = $className . join('-', $params); if (isset($this->mapping[$key])) { return $this->mapping[$key]; } if (method_exists($this, $this->getMethodName($className))) { $callback = array($this, $this->getMethodName($className)); $instance = call_user_func_array($callback, $params); } else { $instance = new $className; } return $this->mapping[$key] = $instance; }
[ "public", "function", "getOrCreate", "(", "$", "className", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "key", "=", "$", "className", ".", "join", "(", "'-'", ",", "$", "params", ")", ";", "if", "(", "isset", "(", "$", "this", "->"...
Returns an instance for specified classname and parameters. @param string $className Class name to get a instance for. @param array $params Constructor arguments for this class. @return mixed
[ "Returns", "an", "instance", "for", "specified", "classname", "and", "parameters", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/VCRFactory.php#L109-L125
train
php-vcr/php-vcr
src/VCR/Util/StreamHelper.php
StreamHelper.createRequestFromStreamContext
public static function createRequestFromStreamContext($context, $path, Request $existing = null) { $http = self::getHttpOptionsFromContext($context); $request = $existing; if (empty($request)) { $method = !empty($http['method']) ? $http['method'] : 'GET'; $request = new Request($method, $path, array()); } if (!empty($http['header'])) { $headers = HttpUtil::parseHeaders(HttpUtil::parseRawHeader($http['header'])); foreach ($headers as $key => $value) { $request->setHeader($key, $value); } } if (!empty($http['content'])) { $request->setBody($http['content']); } if (!empty($http['user_agent'])) { $request->setHeader('User-Agent', $http['user_agent']); } if (isset($http['follow_location'])) { $request->setCurlOption(CURLOPT_FOLLOWLOCATION, (bool) $http['follow_location']); } if (isset($http['max_redirects'])) { $request->setCurlOption(CURLOPT_MAXREDIRS, $http['max_redirects']); } if (isset($http['timeout'])) { $request->setCurlOption(CURLOPT_TIMEOUT, $http['timeout']); } // TODO: protocol_version return $request; }
php
public static function createRequestFromStreamContext($context, $path, Request $existing = null) { $http = self::getHttpOptionsFromContext($context); $request = $existing; if (empty($request)) { $method = !empty($http['method']) ? $http['method'] : 'GET'; $request = new Request($method, $path, array()); } if (!empty($http['header'])) { $headers = HttpUtil::parseHeaders(HttpUtil::parseRawHeader($http['header'])); foreach ($headers as $key => $value) { $request->setHeader($key, $value); } } if (!empty($http['content'])) { $request->setBody($http['content']); } if (!empty($http['user_agent'])) { $request->setHeader('User-Agent', $http['user_agent']); } if (isset($http['follow_location'])) { $request->setCurlOption(CURLOPT_FOLLOWLOCATION, (bool) $http['follow_location']); } if (isset($http['max_redirects'])) { $request->setCurlOption(CURLOPT_MAXREDIRS, $http['max_redirects']); } if (isset($http['timeout'])) { $request->setCurlOption(CURLOPT_TIMEOUT, $http['timeout']); } // TODO: protocol_version return $request; }
[ "public", "static", "function", "createRequestFromStreamContext", "(", "$", "context", ",", "$", "path", ",", "Request", "$", "existing", "=", "null", ")", "{", "$", "http", "=", "self", "::", "getHttpOptionsFromContext", "(", "$", "context", ")", ";", "$", ...
Returns a Request from specified stream context and path. If an existing Request is given, the stream context options are set on the specified Request object. @param resource $context Stream context resource. @param string $path Path to use as url. @param Request $existing Optional, existing request. @return Request
[ "Returns", "a", "Request", "from", "specified", "stream", "context", "and", "path", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/StreamHelper.php#L24-L64
train
php-vcr/php-vcr
src/VCR/Util/HttpClient.php
HttpClient.send
public function send(Request $request) { $ch = curl_init($request->getUrl()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod()); curl_setopt($ch, CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); if (!is_null($request->getBody())) { curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getBody()); } curl_setopt_array($ch, $request->getCurlOptions()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_HEADER, true); list($status, $headers, $body) = HttpUtil::parseResponse(curl_exec($ch)); return new Response( HttpUtil::parseStatus($status), HttpUtil::parseHeaders($headers), $body, curl_getinfo($ch) ); }
php
public function send(Request $request) { $ch = curl_init($request->getUrl()); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $request->getMethod()); curl_setopt($ch, CURLOPT_HTTPHEADER, HttpUtil::formatHeadersForCurl($request->getHeaders())); if (!is_null($request->getBody())) { curl_setopt($ch, CURLOPT_POSTFIELDS, $request->getBody()); } curl_setopt_array($ch, $request->getCurlOptions()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FAILONERROR, false); curl_setopt($ch, CURLOPT_HEADER, true); list($status, $headers, $body) = HttpUtil::parseResponse(curl_exec($ch)); return new Response( HttpUtil::parseStatus($status), HttpUtil::parseHeaders($headers), $body, curl_getinfo($ch) ); }
[ "public", "function", "send", "(", "Request", "$", "request", ")", "{", "$", "ch", "=", "curl_init", "(", "$", "request", "->", "getUrl", "(", ")", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_CUSTOMREQUEST", ",", "$", "request", "->", "getMe...
Returns a response for specified HTTP request. @param Request $request HTTP Request to send. @return Response Response for specified request.
[ "Returns", "a", "response", "for", "specified", "HTTP", "request", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Util/HttpClient.php#L20-L43
train
php-vcr/php-vcr
src/VCR/Request.php
Request.matches
public function matches(Request $request, array $requestMatchers) { foreach ($requestMatchers as $matcher) { if (!is_callable($matcher)) { throw new \BadFunctionCallException( 'Matcher could not be executed. ' . print_r($matcher, true) ); } if (call_user_func_array($matcher, array($this, $request)) === false) { return false; } } return true; }
php
public function matches(Request $request, array $requestMatchers) { foreach ($requestMatchers as $matcher) { if (!is_callable($matcher)) { throw new \BadFunctionCallException( 'Matcher could not be executed. ' . print_r($matcher, true) ); } if (call_user_func_array($matcher, array($this, $request)) === false) { return false; } } return true; }
[ "public", "function", "matches", "(", "Request", "$", "request", ",", "array", "$", "requestMatchers", ")", "{", "foreach", "(", "$", "requestMatchers", "as", "$", "matcher", ")", "{", "if", "(", "!", "is_callable", "(", "$", "matcher", ")", ")", "{", ...
Returns true if specified request matches the current one with specified request matcher callbacks. @param Request $request Request to check if it matches the current one. @param \callable[] $requestMatchers Request matcher callbacks. @throws \BadFunctionCallException If one of the specified request matchers is not callable. @return boolean True if specified request matches the current one.
[ "Returns", "true", "if", "specified", "request", "matches", "the", "current", "one", "with", "specified", "request", "matcher", "callbacks", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Request.php#L61-L76
train
php-vcr/php-vcr
src/VCR/Request.php
Request.toArray
public function toArray() { return array_filter( array( 'method' => $this->getMethod(), 'url' => $this->getUrl(), 'headers' => $this->getHeaders(), 'body' => $this->getBody(), 'post_files' => $this->getPostFiles(), 'post_fields' => $this->getPostFields(), ) ); }
php
public function toArray() { return array_filter( array( 'method' => $this->getMethod(), 'url' => $this->getUrl(), 'headers' => $this->getHeaders(), 'body' => $this->getBody(), 'post_files' => $this->getPostFiles(), 'post_fields' => $this->getPostFields(), ) ); }
[ "public", "function", "toArray", "(", ")", "{", "return", "array_filter", "(", "array", "(", "'method'", "=>", "$", "this", "->", "getMethod", "(", ")", ",", "'url'", "=>", "$", "this", "->", "getUrl", "(", ")", ",", "'headers'", "=>", "$", "this", "...
Returns an array representation of this request. @return array Array representation of this request.
[ "Returns", "an", "array", "representation", "of", "this", "request", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Request.php#L83-L95
train
php-vcr/php-vcr
src/VCR/Request.php
Request.fromArray
public static function fromArray(array $request) { $requestObject = new Request( $request['method'], $request['url'], isset($request['headers']) ? $request['headers'] : array() ); if (!empty($request['post_fields']) && is_array($request['post_fields'])) { $requestObject->setPostFields($request['post_fields']); } if (!empty($request['post_files']) && is_array($request['post_files'])) { foreach ($request['post_files'] as $file) { $requestObject->addPostFile($file); } } if (!empty($request['body'])) { $requestObject->setBody((string)$request['body']); } return $requestObject; }
php
public static function fromArray(array $request) { $requestObject = new Request( $request['method'], $request['url'], isset($request['headers']) ? $request['headers'] : array() ); if (!empty($request['post_fields']) && is_array($request['post_fields'])) { $requestObject->setPostFields($request['post_fields']); } if (!empty($request['post_files']) && is_array($request['post_files'])) { foreach ($request['post_files'] as $file) { $requestObject->addPostFile($file); } } if (!empty($request['body'])) { $requestObject->setBody((string)$request['body']); } return $requestObject; }
[ "public", "static", "function", "fromArray", "(", "array", "$", "request", ")", "{", "$", "requestObject", "=", "new", "Request", "(", "$", "request", "[", "'method'", "]", ",", "$", "request", "[", "'url'", "]", ",", "isset", "(", "$", "request", "[",...
Creates a new Request from a specified array. @param array $request Request represented as an array. @return Request A new Request from specified array.
[ "Creates", "a", "new", "Request", "from", "a", "specified", "array", "." ]
41f532155456521a80d66801b09ecba994f9d004
https://github.com/php-vcr/php-vcr/blob/41f532155456521a80d66801b09ecba994f9d004/src/VCR/Request.php#L104-L127
train
geekcom/validator-docs
src/validator-docs/Validator.php
Validator.validateFormatoCpfCnpj
protected function validateFormatoCpfCnpj($attribute, $value) { return $this->validateFormatoCpf($attribute, $value) || $this->validateFormatoCnpj($attribute, $value); }
php
protected function validateFormatoCpfCnpj($attribute, $value) { return $this->validateFormatoCpf($attribute, $value) || $this->validateFormatoCnpj($attribute, $value); }
[ "protected", "function", "validateFormatoCpfCnpj", "(", "$", "attribute", ",", "$", "value", ")", "{", "return", "$", "this", "->", "validateFormatoCpf", "(", "$", "attribute", ",", "$", "value", ")", "||", "$", "this", "->", "validateFormatoCnpj", "(", "$",...
Valida o formato do cpf ou cnpj @param string $attribute @param string $value @return boolean
[ "Valida", "o", "formato", "do", "cpf", "ou", "cnpj" ]
652f36f3f49ec8d7ca112d39f967f0bdf4b4a196
https://github.com/geekcom/validator-docs/blob/652f36f3f49ec8d7ca112d39f967f0bdf4b4a196/src/validator-docs/Validator.php#L42-L45
train
geekcom/validator-docs
src/validator-docs/Validator.php
Validator.validateCpfCnpj
protected function validateCpfCnpj($attribute, $value) { return ($this->validateCpf($attribute, $value) || $this->validateCnpj($attribute, $value)); }
php
protected function validateCpfCnpj($attribute, $value) { return ($this->validateCpf($attribute, $value) || $this->validateCnpj($attribute, $value)); }
[ "protected", "function", "validateCpfCnpj", "(", "$", "attribute", ",", "$", "value", ")", "{", "return", "(", "$", "this", "->", "validateCpf", "(", "$", "attribute", ",", "$", "value", ")", "||", "$", "this", "->", "validateCnpj", "(", "$", "attribute"...
Valida CNPJ ou CPF @param string $attribute @param string $value @return boolean
[ "Valida", "CNPJ", "ou", "CPF" ]
652f36f3f49ec8d7ca112d39f967f0bdf4b4a196
https://github.com/geekcom/validator-docs/blob/652f36f3f49ec8d7ca112d39f967f0bdf4b4a196/src/validator-docs/Validator.php#L127-L130
train
geekcom/validator-docs
src/validator-docs/Validator.php
Validator.validateTituloEleitor
protected function validateTituloEleitor($attribute, $value) { $input = preg_replace('/[^\d]/', '', $value); $uf = substr($input, -4, 2); if (((strlen($input) < 5) || (strlen($input) > 13)) || (str_repeat($input[1], strlen($input)) == $input) || ($uf < 1 || $uf > 28)) { return false; } $dv = substr($input, -2); $base = 2; $sequencia = substr($input, 0, -4); for ($i = 0; $i < 2; $i++) { $fator = 9; $soma = 0; for ($j = (strlen($sequencia) - 1); $j > -1; $j--) { $soma += $sequencia[$j] * $fator; if ($fator == $base) { $fator = 10; } $fator--; } $digito = $soma % 11; if (($digito == 0) and ($uf < 3)) { $digito = 1; } elseif ($digito == 10) { $digito = 0; } if ($dv[$i] != $digito) { return false; } switch ($i) { case '0': $sequencia = $uf . $digito; break; } } return true; }
php
protected function validateTituloEleitor($attribute, $value) { $input = preg_replace('/[^\d]/', '', $value); $uf = substr($input, -4, 2); if (((strlen($input) < 5) || (strlen($input) > 13)) || (str_repeat($input[1], strlen($input)) == $input) || ($uf < 1 || $uf > 28)) { return false; } $dv = substr($input, -2); $base = 2; $sequencia = substr($input, 0, -4); for ($i = 0; $i < 2; $i++) { $fator = 9; $soma = 0; for ($j = (strlen($sequencia) - 1); $j > -1; $j--) { $soma += $sequencia[$j] * $fator; if ($fator == $base) { $fator = 10; } $fator--; } $digito = $soma % 11; if (($digito == 0) and ($uf < 3)) { $digito = 1; } elseif ($digito == 10) { $digito = 0; } if ($dv[$i] != $digito) { return false; } switch ($i) { case '0': $sequencia = $uf . $digito; break; } } return true; }
[ "protected", "function", "validateTituloEleitor", "(", "$", "attribute", ",", "$", "value", ")", "{", "$", "input", "=", "preg_replace", "(", "'/[^\\d]/'", ",", "''", ",", "$", "value", ")", ";", "$", "uf", "=", "substr", "(", "$", "input", ",", "-", ...
Valida Titulo de Eleitor @param string $attribute @param string $value @return boolean
[ "Valida", "Titulo", "de", "Eleitor" ]
652f36f3f49ec8d7ca112d39f967f0bdf4b4a196
https://github.com/geekcom/validator-docs/blob/652f36f3f49ec8d7ca112d39f967f0bdf4b4a196/src/validator-docs/Validator.php#L184-L237
train
WsdlToPhp/PackageGenerator
src/File/Validation/ItemTypeRule.php
ItemTypeRule.getItemSanityCheck
protected function getItemSanityCheck($itemName) { $model = $this->getFile()->getModelFromStructAttribute($this->getAttribute()); $sanityCheck = 'false'; if ($model instanceof Struct && !$model->isList() && ($model->isStruct() || ($model->isArray() && $model->getInheritanceStruct() instanceof Struct))) { $sanityCheck = sprintf('!$%s instanceof %s', $itemName, $this->getFile()->getStructAttributeType($this->getAttribute(), true)); } else { $type = AbstractModelFile::getPhpType($this->getFile()->getStructAttributeType($this->getAttribute())); if ($rule = $this->getRules()->getRule($type)) { $sanityCheck = $rule->testConditions($itemName, null, true); } } return $sanityCheck; }
php
protected function getItemSanityCheck($itemName) { $model = $this->getFile()->getModelFromStructAttribute($this->getAttribute()); $sanityCheck = 'false'; if ($model instanceof Struct && !$model->isList() && ($model->isStruct() || ($model->isArray() && $model->getInheritanceStruct() instanceof Struct))) { $sanityCheck = sprintf('!$%s instanceof %s', $itemName, $this->getFile()->getStructAttributeType($this->getAttribute(), true)); } else { $type = AbstractModelFile::getPhpType($this->getFile()->getStructAttributeType($this->getAttribute())); if ($rule = $this->getRules()->getRule($type)) { $sanityCheck = $rule->testConditions($itemName, null, true); } } return $sanityCheck; }
[ "protected", "function", "getItemSanityCheck", "(", "$", "itemName", ")", "{", "$", "model", "=", "$", "this", "->", "getFile", "(", ")", "->", "getModelFromStructAttribute", "(", "$", "this", "->", "getAttribute", "(", ")", ")", ";", "$", "sanityCheck", "...
The second case which used PHP native functions is volontary limited by the native functions provided by PHP, and the possible types defined in xsd_types.yml @param string $itemName @return string
[ "The", "second", "case", "which", "used", "PHP", "native", "functions", "is", "volontary", "limited", "by", "the", "native", "functions", "provided", "by", "PHP", "and", "the", "possible", "types", "defined", "in", "xsd_types", ".", "yml" ]
cdd62433018fba5027c39e46c49379af1f95f5e3
https://github.com/WsdlToPhp/PackageGenerator/blob/cdd62433018fba5027c39e46c49379af1f95f5e3/src/File/Validation/ItemTypeRule.php#L47-L60
train