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
Talesoft/tale-jade
Filter.php
Filter.filterMarkdown
public static function filterMarkdown(Node $node, $indent, $newLine) { if (!class_exists('Parsedown')) throw new Compiler\Exception( "Failed to compile Markdown: " ."Please install the erusev/parsedown composer package" ); $parsedown = new \Parsedown(); return $parsedown->text($node->text()); }
php
public static function filterMarkdown(Node $node, $indent, $newLine) { if (!class_exists('Parsedown')) throw new Compiler\Exception( "Failed to compile Markdown: " ."Please install the erusev/parsedown composer package" ); $parsedown = new \Parsedown(); return $parsedown->text($node->text()); }
[ "public", "static", "function", "filterMarkdown", "(", "Node", "$", "node", ",", "$", "indent", ",", "$", "newLine", ")", "{", "if", "(", "!", "class_exists", "(", "'Parsedown'", ")", ")", "throw", "new", "Compiler", "\\", "Exception", "(", "\"Failed to compile Markdown: \"", ".", "\"Please install the erusev/parsedown composer package\"", ")", ";", "$", "parsedown", "=", "new", "\\", "Parsedown", "(", ")", ";", "return", "$", "parsedown", "->", "text", "(", "$", "node", "->", "text", "(", ")", ")", ";", "}" ]
Compiles the markdown content to HTML. @param Node $node the node to be compiled @param string $indent the indentation to use on each child @param string $newLine the new-line to append after each line @return string the wrapped HTML-string @throws Compiler\Exception when the Parsedown package is not installed
[ "Compiles", "the", "markdown", "content", "to", "HTML", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Filter.php#L196-L208
train
Talesoft/tale-jade
Filter.php
Filter.filterCoffeeScript
public static function filterCoffeeScript(Node $node, $indent, $newLine) { if (!class_exists('CoffeeScript\\Compiler')) throw new Compiler\Exception( "Failed to compile CoffeeScript: " ."Please install the coffeescript/coffeescript composer package" ); $js = \CoffeeScript\Compiler::compile($node->text(), [ 'header' => '', 'filename' => 'Imported-at-('.$node->line.':'.$node->offset.').coffee' ]); return '<script>'.$newLine.$indent.$js.$newLine.$indent.'</script>'; }
php
public static function filterCoffeeScript(Node $node, $indent, $newLine) { if (!class_exists('CoffeeScript\\Compiler')) throw new Compiler\Exception( "Failed to compile CoffeeScript: " ."Please install the coffeescript/coffeescript composer package" ); $js = \CoffeeScript\Compiler::compile($node->text(), [ 'header' => '', 'filename' => 'Imported-at-('.$node->line.':'.$node->offset.').coffee' ]); return '<script>'.$newLine.$indent.$js.$newLine.$indent.'</script>'; }
[ "public", "static", "function", "filterCoffeeScript", "(", "Node", "$", "node", ",", "$", "indent", ",", "$", "newLine", ")", "{", "if", "(", "!", "class_exists", "(", "'CoffeeScript\\\\Compiler'", ")", ")", "throw", "new", "Compiler", "\\", "Exception", "(", "\"Failed to compile CoffeeScript: \"", ".", "\"Please install the coffeescript/coffeescript composer package\"", ")", ";", "$", "js", "=", "\\", "CoffeeScript", "\\", "Compiler", "::", "compile", "(", "$", "node", "->", "text", "(", ")", ",", "[", "'header'", "=>", "''", ",", "'filename'", "=>", "'Imported-at-('", ".", "$", "node", "->", "line", ".", "':'", ".", "$", "node", "->", "offset", ".", "').coffee'", "]", ")", ";", "return", "'<script>'", ".", "$", "newLine", ".", "$", "indent", ".", "$", "js", ".", "$", "newLine", ".", "$", "indent", ".", "'</script>'", ";", "}" ]
Compiles the CoffeeScript content to JavaScript @param Node $node the node to be compiled @param string $indent the indentation to use on each child @param string $newLine the new-line to append after each line @return string the wrapped JavaScript-HTML-string @throws Compiler\Exception when the CoffeeScript package is not installed
[ "Compiles", "the", "CoffeeScript", "content", "to", "JavaScript" ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Filter.php#L221-L236
train
Talesoft/tale-jade
Filter.php
Filter.filterLess
public static function filterLess(Node $node, $indent, $newLine) { if (!class_exists('lessc')) throw new Compiler\Exception( "Failed to compile LESS: " ."Please install the leafo/lessphp composer package" ); $less = new \lessc; $css = $less->compile($node->text()); return '<style>'.$newLine.$indent.$css.$newLine.$indent.'</style>'; }
php
public static function filterLess(Node $node, $indent, $newLine) { if (!class_exists('lessc')) throw new Compiler\Exception( "Failed to compile LESS: " ."Please install the leafo/lessphp composer package" ); $less = new \lessc; $css = $less->compile($node->text()); return '<style>'.$newLine.$indent.$css.$newLine.$indent.'</style>'; }
[ "public", "static", "function", "filterLess", "(", "Node", "$", "node", ",", "$", "indent", ",", "$", "newLine", ")", "{", "if", "(", "!", "class_exists", "(", "'lessc'", ")", ")", "throw", "new", "Compiler", "\\", "Exception", "(", "\"Failed to compile LESS: \"", ".", "\"Please install the leafo/lessphp composer package\"", ")", ";", "$", "less", "=", "new", "\\", "lessc", ";", "$", "css", "=", "$", "less", "->", "compile", "(", "$", "node", "->", "text", "(", ")", ")", ";", "return", "'<style>'", ".", "$", "newLine", ".", "$", "indent", ".", "$", "css", ".", "$", "newLine", ".", "$", "indent", ".", "'</style>'", ";", "}" ]
Compiles the LESS content to CSS @param Node $node the node to be compiled @param string $indent the indentation to use on each child @param string $newLine the new-line to append after each line @return string the wrapped Less-CSS-string @throws Compiler\Exception when the LESS package is not installed
[ "Compiles", "the", "LESS", "content", "to", "CSS" ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Filter.php#L248-L261
train
Talesoft/tale-jade
Filter.php
Filter.filterStylus
public static function filterStylus(Node $node, $indent, $newLine) { if (!class_exists('Stylus\\Stylus')) throw new Compiler\Exception( "Failed to compile Stylus: " ."Please install the neemzy/stylus composer package" ); $stylus = new \Stylus\Stylus; $css = $stylus->fromString($node->text())->toString(); return '<style>'.$newLine.$indent.$css.$newLine.$indent.'</style>'; }
php
public static function filterStylus(Node $node, $indent, $newLine) { if (!class_exists('Stylus\\Stylus')) throw new Compiler\Exception( "Failed to compile Stylus: " ."Please install the neemzy/stylus composer package" ); $stylus = new \Stylus\Stylus; $css = $stylus->fromString($node->text())->toString(); return '<style>'.$newLine.$indent.$css.$newLine.$indent.'</style>'; }
[ "public", "static", "function", "filterStylus", "(", "Node", "$", "node", ",", "$", "indent", ",", "$", "newLine", ")", "{", "if", "(", "!", "class_exists", "(", "'Stylus\\\\Stylus'", ")", ")", "throw", "new", "Compiler", "\\", "Exception", "(", "\"Failed to compile Stylus: \"", ".", "\"Please install the neemzy/stylus composer package\"", ")", ";", "$", "stylus", "=", "new", "\\", "Stylus", "\\", "Stylus", ";", "$", "css", "=", "$", "stylus", "->", "fromString", "(", "$", "node", "->", "text", "(", ")", ")", "->", "toString", "(", ")", ";", "return", "'<style>'", ".", "$", "newLine", ".", "$", "indent", ".", "$", "css", ".", "$", "newLine", ".", "$", "indent", ".", "'</style>'", ";", "}" ]
Compiles the Stylus content to CSS @param Node $node the node to be compiled @param string $indent the indentation to use on each child @param string $newLine the new-line to append after each line @return string the wrapped Stylus-CSS-string @throws Compiler\Exception when the Stylus package is not installed
[ "Compiles", "the", "Stylus", "content", "to", "CSS" ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Filter.php#L273-L286
train
Talesoft/tale-jade
Filter.php
Filter.filterSass
public static function filterSass(Node $node, $indent, $newLine) { if (!class_exists('Leafo\\ScssPhp\\Compiler')) throw new Compiler\Exception( "Failed to compile SASS: " ."Please install the leafo/scssphp composer package" ); $sass = new \Leafo\ScssPhp\Compiler; $css = $sass->compile($node->text()); return '<style>'.$newLine.$indent.$css.$newLine.$indent.'</style>'; }
php
public static function filterSass(Node $node, $indent, $newLine) { if (!class_exists('Leafo\\ScssPhp\\Compiler')) throw new Compiler\Exception( "Failed to compile SASS: " ."Please install the leafo/scssphp composer package" ); $sass = new \Leafo\ScssPhp\Compiler; $css = $sass->compile($node->text()); return '<style>'.$newLine.$indent.$css.$newLine.$indent.'</style>'; }
[ "public", "static", "function", "filterSass", "(", "Node", "$", "node", ",", "$", "indent", ",", "$", "newLine", ")", "{", "if", "(", "!", "class_exists", "(", "'Leafo\\\\ScssPhp\\\\Compiler'", ")", ")", "throw", "new", "Compiler", "\\", "Exception", "(", "\"Failed to compile SASS: \"", ".", "\"Please install the leafo/scssphp composer package\"", ")", ";", "$", "sass", "=", "new", "\\", "Leafo", "\\", "ScssPhp", "\\", "Compiler", ";", "$", "css", "=", "$", "sass", "->", "compile", "(", "$", "node", "->", "text", "(", ")", ")", ";", "return", "'<style>'", ".", "$", "newLine", ".", "$", "indent", ".", "$", "css", ".", "$", "newLine", ".", "$", "indent", ".", "'</style>'", ";", "}" ]
Compiles the SASS content to CSS @param Node $node the node to be compiled @param string $indent the indentation to use on each child @param string $newLine the new-line to append after each line @return string the wrapped SASS-CSS-string @throws Compiler\Exception when the Stylus package is not installed
[ "Compiles", "the", "SASS", "content", "to", "CSS" ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Filter.php#L298-L311
train
Talesoft/tale-jade
Renderer/Adapter/Stream/Wrapper.php
Wrapper.stream_open
public function stream_open($uri, $mode, $options, &$opened_path) { //Abstract mb_* functions to get UTF-8 working correctly in this bitch $substr = function_exists('mb_substr') ? 'mb_substr' : 'substr'; $strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; $strpos = function_exists('mb_strpos') ? 'mb_strpos' : 'strpos'; //Our data URI could look like this: // tale-jade://data;<base64-encoded-phtml> //We strip everything behind th first ;, the result would be only // <base64-encoded-phtml> //We decode that and $_data will contain only the pure, compiled PHTML //ready for inclusion $this->data = base64_decode($substr($uri, $strpos($uri, ';') + 1)); $this->position = 0; $this->length = $strlen($this->data); return true; }
php
public function stream_open($uri, $mode, $options, &$opened_path) { //Abstract mb_* functions to get UTF-8 working correctly in this bitch $substr = function_exists('mb_substr') ? 'mb_substr' : 'substr'; $strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; $strpos = function_exists('mb_strpos') ? 'mb_strpos' : 'strpos'; //Our data URI could look like this: // tale-jade://data;<base64-encoded-phtml> //We strip everything behind th first ;, the result would be only // <base64-encoded-phtml> //We decode that and $_data will contain only the pure, compiled PHTML //ready for inclusion $this->data = base64_decode($substr($uri, $strpos($uri, ';') + 1)); $this->position = 0; $this->length = $strlen($this->data); return true; }
[ "public", "function", "stream_open", "(", "$", "uri", ",", "$", "mode", ",", "$", "options", ",", "&", "$", "opened_path", ")", "{", "//Abstract mb_* functions to get UTF-8 working correctly in this bitch", "$", "substr", "=", "function_exists", "(", "'mb_substr'", ")", "?", "'mb_substr'", ":", "'substr'", ";", "$", "strlen", "=", "function_exists", "(", "'mb_strlen'", ")", "?", "'mb_strlen'", ":", "'strlen'", ";", "$", "strpos", "=", "function_exists", "(", "'mb_strpos'", ")", "?", "'mb_strpos'", ":", "'strpos'", ";", "//Our data URI could look like this:", "// tale-jade://data;<base64-encoded-phtml>", "//We strip everything behind th first ;, the result would be only", "// <base64-encoded-phtml>", "//We decode that and $_data will contain only the pure, compiled PHTML", "//ready for inclusion", "$", "this", "->", "data", "=", "base64_decode", "(", "$", "substr", "(", "$", "uri", ",", "$", "strpos", "(", "$", "uri", ",", "';'", ")", "+", "1", ")", ")", ";", "$", "this", "->", "position", "=", "0", ";", "$", "this", "->", "length", "=", "$", "strlen", "(", "$", "this", "->", "data", ")", ";", "return", "true", ";", "}" ]
This gets called when a url-stream is opened with the wrapper-scheme. (e.g. fopen('tale-jade://data;...'), INCLUDE('tale-jade://data;...') @param string $uri the Data-URI this stream was opened with @param string $mode the stream read/write-mode (useless here) @param int $options the flags for this stream instance (useless here) @param string &$opened_path the path that got actually opened (useless here) @return bool
[ "This", "gets", "called", "when", "a", "url", "-", "stream", "is", "opened", "with", "the", "wrapper", "-", "scheme", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Renderer/Adapter/Stream/Wrapper.php#L85-L105
train
Talesoft/tale-jade
Renderer/Adapter/Stream/Wrapper.php
Wrapper.stream_read
public function stream_read($length) { //Abstract mb_* functions $substr = function_exists('mb_substr') ? 'mb_substr' : 'substr'; $strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; //Read that stuff chunk by chunk (whatever buffersize there is) $result = $substr($this->data, $this->position, $length); $this->position += $strlen($result); return $result; }
php
public function stream_read($length) { //Abstract mb_* functions $substr = function_exists('mb_substr') ? 'mb_substr' : 'substr'; $strlen = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; //Read that stuff chunk by chunk (whatever buffersize there is) $result = $substr($this->data, $this->position, $length); $this->position += $strlen($result); return $result; }
[ "public", "function", "stream_read", "(", "$", "length", ")", "{", "//Abstract mb_* functions", "$", "substr", "=", "function_exists", "(", "'mb_substr'", ")", "?", "'mb_substr'", ":", "'substr'", ";", "$", "strlen", "=", "function_exists", "(", "'mb_strlen'", ")", "?", "'mb_strlen'", ":", "'strlen'", ";", "//Read that stuff chunk by chunk (whatever buffersize there is)", "$", "result", "=", "$", "substr", "(", "$", "this", "->", "data", ",", "$", "this", "->", "position", ",", "$", "length", ")", ";", "$", "this", "->", "position", "+=", "$", "strlen", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
This gets called when anything tries to read from this. (opened) stream (e.g. fread, fgets, fgetcsv, INCLUDE(!!!) etc.) We return the fitting chunk of our PHTML and add that length of that to our current position so that the next call will read the next chunk, rinse and repeat @param int $length the length of the chunk to read @return string
[ "This", "gets", "called", "when", "anything", "tries", "to", "read", "from", "this", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Renderer/Adapter/Stream/Wrapper.php#L120-L132
train
Talesoft/tale-jade
Lexer.php
Lexer.dump
public function dump($input) { foreach ($this->lex($input) as $token) { $type = $token['type']; $line = $token['line']; $offset = $token['offset']; unset($token['type'], $token['line'], $token['offset']); echo "[$type($line:$offset)"; $vals = implode(', ', array_map(function ($key, $value) { return "$key=$value"; }, array_keys($token), $token)); if (!empty($vals)) echo " $vals"; echo ']'; if ($type === 'newLine') echo "\n"; } }
php
public function dump($input) { foreach ($this->lex($input) as $token) { $type = $token['type']; $line = $token['line']; $offset = $token['offset']; unset($token['type'], $token['line'], $token['offset']); echo "[$type($line:$offset)"; $vals = implode(', ', array_map(function ($key, $value) { return "$key=$value"; }, array_keys($token), $token)); if (!empty($vals)) echo " $vals"; echo ']'; if ($type === 'newLine') echo "\n"; } }
[ "public", "function", "dump", "(", "$", "input", ")", "{", "foreach", "(", "$", "this", "->", "lex", "(", "$", "input", ")", "as", "$", "token", ")", "{", "$", "type", "=", "$", "token", "[", "'type'", "]", ";", "$", "line", "=", "$", "token", "[", "'line'", "]", ";", "$", "offset", "=", "$", "token", "[", "'offset'", "]", ";", "unset", "(", "$", "token", "[", "'type'", "]", ",", "$", "token", "[", "'line'", "]", ",", "$", "token", "[", "'offset'", "]", ")", ";", "echo", "\"[$type($line:$offset)\"", ";", "$", "vals", "=", "implode", "(", "', '", ",", "array_map", "(", "function", "(", "$", "key", ",", "$", "value", ")", "{", "return", "\"$key=$value\"", ";", "}", ",", "array_keys", "(", "$", "token", ")", ",", "$", "token", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "vals", ")", ")", "echo", "\" $vals\"", ";", "echo", "']'", ";", "if", "(", "$", "type", "===", "'newLine'", ")", "echo", "\"\\n\"", ";", "}", "}" ]
Dumps jade-input into a set of string-represented tokens. This makes debugging the lexer easier. @param string $input the jade input to dump the tokens of
[ "Dumps", "jade", "-", "input", "into", "a", "set", "of", "string", "-", "represented", "tokens", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L388-L412
train
Talesoft/tale-jade
Lexer.php
Lexer.peek
protected function peek($length = 1) { $this->lastPeekResult = $this->substr($this->input, 0, $length); return $this->lastPeekResult; }
php
protected function peek($length = 1) { $this->lastPeekResult = $this->substr($this->input, 0, $length); return $this->lastPeekResult; }
[ "protected", "function", "peek", "(", "$", "length", "=", "1", ")", "{", "$", "this", "->", "lastPeekResult", "=", "$", "this", "->", "substr", "(", "$", "this", "->", "input", ",", "0", ",", "$", "length", ")", ";", "return", "$", "this", "->", "lastPeekResult", ";", "}" ]
Shows the next characters in our input. Pass a $length to get more than one character. The character's _won't_ be consumed here, they are just shown. The position pointer won't be moved forward The result gets saved in $_lastPeekResult @param int $length the length of the string we want to peek on @return string the peeked string
[ "Shows", "the", "next", "characters", "in", "our", "input", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L438-L444
train
Talesoft/tale-jade
Lexer.php
Lexer.consume
protected function consume($length = null) { if ($length === null) { if ($this->lastPeekResult === null) $this->throwException( "Failed to consume: Nothing has been peeked and you" ." didnt pass a length to consume" ); $length = $this->strlen($this->lastPeekResult); } $this->input = $this->substr($this->input, $length); $this->position += $length; $this->offset += $length; return $this; }
php
protected function consume($length = null) { if ($length === null) { if ($this->lastPeekResult === null) $this->throwException( "Failed to consume: Nothing has been peeked and you" ." didnt pass a length to consume" ); $length = $this->strlen($this->lastPeekResult); } $this->input = $this->substr($this->input, $length); $this->position += $length; $this->offset += $length; return $this; }
[ "protected", "function", "consume", "(", "$", "length", "=", "null", ")", "{", "if", "(", "$", "length", "===", "null", ")", "{", "if", "(", "$", "this", "->", "lastPeekResult", "===", "null", ")", "$", "this", "->", "throwException", "(", "\"Failed to consume: Nothing has been peeked and you\"", ".", "\" didnt pass a length to consume\"", ")", ";", "$", "length", "=", "$", "this", "->", "strlen", "(", "$", "this", "->", "lastPeekResult", ")", ";", "}", "$", "this", "->", "input", "=", "$", "this", "->", "substr", "(", "$", "this", "->", "input", ",", "$", "length", ")", ";", "$", "this", "->", "position", "+=", "$", "length", ";", "$", "this", "->", "offset", "+=", "$", "length", ";", "return", "$", "this", ";", "}" ]
Consumes a length or the length of the last peeked string. Internally $input = substr($input, $length) is done, so everything _before_ the consumed length will be cut off and removed from the RAM (since we probably tokenized it already, remember? sequential shit etc.?) @see Lexer->peek @param int|null $length the length to consume or null, to use the length of the last peeked string @return $this @throws Exception
[ "Consumes", "a", "length", "or", "the", "length", "of", "the", "last", "peeked", "string", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L461-L480
train
Talesoft/tale-jade
Lexer.php
Lexer.read
protected function read($callback, $length = 1) { if (!is_callable($callback)) throw new \InvalidArgumentException( "Argument 1 passed to peekWhile needs to be callback" ); $result = ''; while (!$this->isAtEnd() && $callback($this->peek($length))) { //Keep $_line and $_offset updated $newLines = $this->substr_count($this->lastPeekResult, "\n"); $this->line += $newLines; if ($newLines) { if (strlen($this->lastPeekResult) === 1) $this->offset = 0; else { $parts = explode("\n", $this->lastPeekResult); $this->offset = strlen($parts[count($parts) - 1]) - 1; } } $this->consume(); $result .= $this->lastPeekResult; } return $result; }
php
protected function read($callback, $length = 1) { if (!is_callable($callback)) throw new \InvalidArgumentException( "Argument 1 passed to peekWhile needs to be callback" ); $result = ''; while (!$this->isAtEnd() && $callback($this->peek($length))) { //Keep $_line and $_offset updated $newLines = $this->substr_count($this->lastPeekResult, "\n"); $this->line += $newLines; if ($newLines) { if (strlen($this->lastPeekResult) === 1) $this->offset = 0; else { $parts = explode("\n", $this->lastPeekResult); $this->offset = strlen($parts[count($parts) - 1]) - 1; } } $this->consume(); $result .= $this->lastPeekResult; } return $result; }
[ "protected", "function", "read", "(", "$", "callback", ",", "$", "length", "=", "1", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callback", ")", ")", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Argument 1 passed to peekWhile needs to be callback\"", ")", ";", "$", "result", "=", "''", ";", "while", "(", "!", "$", "this", "->", "isAtEnd", "(", ")", "&&", "$", "callback", "(", "$", "this", "->", "peek", "(", "$", "length", ")", ")", ")", "{", "//Keep $_line and $_offset updated", "$", "newLines", "=", "$", "this", "->", "substr_count", "(", "$", "this", "->", "lastPeekResult", ",", "\"\\n\"", ")", ";", "$", "this", "->", "line", "+=", "$", "newLines", ";", "if", "(", "$", "newLines", ")", "{", "if", "(", "strlen", "(", "$", "this", "->", "lastPeekResult", ")", "===", "1", ")", "$", "this", "->", "offset", "=", "0", ";", "else", "{", "$", "parts", "=", "explode", "(", "\"\\n\"", ",", "$", "this", "->", "lastPeekResult", ")", ";", "$", "this", "->", "offset", "=", "strlen", "(", "$", "parts", "[", "count", "(", "$", "parts", ")", "-", "1", "]", ")", "-", "1", ";", "}", "}", "$", "this", "->", "consume", "(", ")", ";", "$", "result", ".=", "$", "this", "->", "lastPeekResult", ";", "}", "return", "$", "result", ";", "}" ]
Peeks and consumes chars until the passed callback returns false. The callback takes the current character as the first argument. This works great with ctype_*-functions If the last character doesn't match, it also won't be consumed You can always go on reading right after a call to ->read() e.g. $alNumString = $this->read('ctype_alnum') $spaces = $this->read('ctype_space') @param callable $callback the callback to check the current character against @param int $length the length to peek. This will also increase the length of the characters passed to the callback @return string the read string @throws \Exception
[ "Peeks", "and", "consumes", "chars", "until", "the", "passed", "callback", "returns", "false", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L502-L533
train
Talesoft/tale-jade
Lexer.php
Lexer.readBracketContents
protected function readBracketContents(array $breakChars = null) { $breakChars = $breakChars ? $breakChars : []; $value = ''; $prev = null; $char = null; $level = 0; $inString = false; $stringType = null; $finished = false; while (!$this->isAtEnd() && !$finished) { if ($this->isAtEnd()) break; $prev = $char; $char = $this->peek(); switch ($char) { case '"': case '\'': if ($inString && $stringType === $char && $prev !== '\\') $inString = false; else if (!$inString) { $inString = true; $stringType = $char; } break; case '(': case '[': case '{': if (!$inString) $level++; break; case ')': case ']': case '}': if ($inString) break; if ($level === 0) { $finished = true; break; } $level--; break; } if (in_array($char, $breakChars, true) && !$inString && $level === 0) $finished = true; if (!$finished) { $value .= $char; $this->consume(); } } return trim($value); }
php
protected function readBracketContents(array $breakChars = null) { $breakChars = $breakChars ? $breakChars : []; $value = ''; $prev = null; $char = null; $level = 0; $inString = false; $stringType = null; $finished = false; while (!$this->isAtEnd() && !$finished) { if ($this->isAtEnd()) break; $prev = $char; $char = $this->peek(); switch ($char) { case '"': case '\'': if ($inString && $stringType === $char && $prev !== '\\') $inString = false; else if (!$inString) { $inString = true; $stringType = $char; } break; case '(': case '[': case '{': if (!$inString) $level++; break; case ')': case ']': case '}': if ($inString) break; if ($level === 0) { $finished = true; break; } $level--; break; } if (in_array($char, $breakChars, true) && !$inString && $level === 0) $finished = true; if (!$finished) { $value .= $char; $this->consume(); } } return trim($value); }
[ "protected", "function", "readBracketContents", "(", "array", "$", "breakChars", "=", "null", ")", "{", "$", "breakChars", "=", "$", "breakChars", "?", "$", "breakChars", ":", "[", "]", ";", "$", "value", "=", "''", ";", "$", "prev", "=", "null", ";", "$", "char", "=", "null", ";", "$", "level", "=", "0", ";", "$", "inString", "=", "false", ";", "$", "stringType", "=", "null", ";", "$", "finished", "=", "false", ";", "while", "(", "!", "$", "this", "->", "isAtEnd", "(", ")", "&&", "!", "$", "finished", ")", "{", "if", "(", "$", "this", "->", "isAtEnd", "(", ")", ")", "break", ";", "$", "prev", "=", "$", "char", ";", "$", "char", "=", "$", "this", "->", "peek", "(", ")", ";", "switch", "(", "$", "char", ")", "{", "case", "'\"'", ":", "case", "'\\''", ":", "if", "(", "$", "inString", "&&", "$", "stringType", "===", "$", "char", "&&", "$", "prev", "!==", "'\\\\'", ")", "$", "inString", "=", "false", ";", "else", "if", "(", "!", "$", "inString", ")", "{", "$", "inString", "=", "true", ";", "$", "stringType", "=", "$", "char", ";", "}", "break", ";", "case", "'('", ":", "case", "'['", ":", "case", "'{'", ":", "if", "(", "!", "$", "inString", ")", "$", "level", "++", ";", "break", ";", "case", "')'", ":", "case", "']'", ":", "case", "'}'", ":", "if", "(", "$", "inString", ")", "break", ";", "if", "(", "$", "level", "===", "0", ")", "{", "$", "finished", "=", "true", ";", "break", ";", "}", "$", "level", "--", ";", "break", ";", "}", "if", "(", "in_array", "(", "$", "char", ",", "$", "breakChars", ",", "true", ")", "&&", "!", "$", "inString", "&&", "$", "level", "===", "0", ")", "$", "finished", "=", "true", ";", "if", "(", "!", "$", "finished", ")", "{", "$", "value", ".=", "$", "char", ";", "$", "this", "->", "consume", "(", ")", ";", "}", "}", "return", "trim", "(", "$", "value", ")", ";", "}" ]
Reads a "value", 'value' or value style string really gracefully. It will stop on all chars passed to $breakChars as well as a closing ')' when _not_ inside an expression initiated with either ", ', (, [ or {. $breakChars might be [','] as an example to read sequential arguments into an array. Scan for ',', skip spaces, repeat readBracketContents Brackets are counted, strings are respected. Inside a " string, \" escaping is possible, inside a ' string, \' escaping is possible As soon as a ) is found and we're outside a string and outside any kind of bracket, the reading will stop and the value, including any quotes, will be returned Examples: ('`' marks the parts that are read, understood and returned by this function) <samp> (arg1=`abc`, arg2=`"some expression"`, `'some string expression'`) some-mixin(`'some arg'`, `[1, 2, 3, 4]`, `(isset($complex) ? $complex : 'complex')`) and even some-mixin(callback=`function($input) { return trim($input, '\'"'); }`) </samp> @param array|null $breakChars the chars to break on. @return string the (possibly quote-enclosed) result string
[ "Reads", "a", "value", "value", "or", "value", "style", "string", "really", "gracefully", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L585-L651
train
Talesoft/tale-jade
Lexer.php
Lexer.scanFor
protected function scanFor(array $scans, $throwException = false) { while (!$this->isAtEnd()) { $found = false; foreach ($scans as $name) { foreach (call_user_func([$this, 'scan'.ucfirst($name)]) as $token) { $found = true; yield $token; } if ($found) continue 2; } $spaces = $this->readSpaces(); if (!empty($spaces) && !$this->isAtEnd()) continue; if ($throwException) { $this->throwException( 'Unexpected `'.htmlentities($this->peek(20), \ENT_QUOTES).'`, ' .implode(', ', $scans).' expected' ); } else return; } }
php
protected function scanFor(array $scans, $throwException = false) { while (!$this->isAtEnd()) { $found = false; foreach ($scans as $name) { foreach (call_user_func([$this, 'scan'.ucfirst($name)]) as $token) { $found = true; yield $token; } if ($found) continue 2; } $spaces = $this->readSpaces(); if (!empty($spaces) && !$this->isAtEnd()) continue; if ($throwException) { $this->throwException( 'Unexpected `'.htmlentities($this->peek(20), \ENT_QUOTES).'`, ' .implode(', ', $scans).' expected' ); } else return; } }
[ "protected", "function", "scanFor", "(", "array", "$", "scans", ",", "$", "throwException", "=", "false", ")", "{", "while", "(", "!", "$", "this", "->", "isAtEnd", "(", ")", ")", "{", "$", "found", "=", "false", ";", "foreach", "(", "$", "scans", "as", "$", "name", ")", "{", "foreach", "(", "call_user_func", "(", "[", "$", "this", ",", "'scan'", ".", "ucfirst", "(", "$", "name", ")", "]", ")", "as", "$", "token", ")", "{", "$", "found", "=", "true", ";", "yield", "$", "token", ";", "}", "if", "(", "$", "found", ")", "continue", "2", ";", "}", "$", "spaces", "=", "$", "this", "->", "readSpaces", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "spaces", ")", "&&", "!", "$", "this", "->", "isAtEnd", "(", ")", ")", "continue", ";", "if", "(", "$", "throwException", ")", "{", "$", "this", "->", "throwException", "(", "'Unexpected `'", ".", "htmlentities", "(", "$", "this", "->", "peek", "(", "20", ")", ",", "\\", "ENT_QUOTES", ")", ".", "'`, '", ".", "implode", "(", "', '", ",", "$", "scans", ")", ".", "' expected'", ")", ";", "}", "else", "return", ";", "}", "}" ]
Keeps scanning for all types of tokens passed as the first argument. If one token is encountered that's not in $scans, the function breaks or throws an exception, if the second argument is true The passed scans get converted to methods e.g. newLine => scanNewLine, blockExpansion => scanBlockExpansion etc. @param array $scans the scans to perform @param bool|false $throwException throw an exception if no tokens in $scans found anymore @return \Generator the generator yielding all tokens found @throws Exception
[ "Keeps", "scanning", "for", "all", "types", "of", "tokens", "passed", "as", "the", "first", "argument", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L727-L758
train
Talesoft/tale-jade
Lexer.php
Lexer.scanToken
protected function scanToken($type, $pattern, $modifiers = '') { if (!$this->match($pattern, $modifiers)) return; $this->consumeMatch(); $token = $this->createToken($type); foreach ($this->lastMatches as $key => $value) { //We append all STRING-Matches (?<name>) to the token if (is_string($key)) { $token[$key] = empty($value) ? null : $value; } } yield $token; }
php
protected function scanToken($type, $pattern, $modifiers = '') { if (!$this->match($pattern, $modifiers)) return; $this->consumeMatch(); $token = $this->createToken($type); foreach ($this->lastMatches as $key => $value) { //We append all STRING-Matches (?<name>) to the token if (is_string($key)) { $token[$key] = empty($value) ? null : $value; } } yield $token; }
[ "protected", "function", "scanToken", "(", "$", "type", ",", "$", "pattern", ",", "$", "modifiers", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "match", "(", "$", "pattern", ",", "$", "modifiers", ")", ")", "return", ";", "$", "this", "->", "consumeMatch", "(", ")", ";", "$", "token", "=", "$", "this", "->", "createToken", "(", "$", "type", ")", ";", "foreach", "(", "$", "this", "->", "lastMatches", "as", "$", "key", "=>", "$", "value", ")", "{", "//We append all STRING-Matches (?<name>) to the token", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "token", "[", "$", "key", "]", "=", "empty", "(", "$", "value", ")", "?", "null", ":", "$", "value", ";", "}", "}", "yield", "$", "token", ";", "}" ]
Scans for a specific token-type based on a pattern and converts it to a valid token automatically. All matches that have a name (RegEx (?<name>...)-directive will directly get a key with that name and value on the token array For matching, ->match() is used internally @see Lexer->match @param string $type the token type to create, if matched @param string $pattern the pattern to match @param string $modifiers the regex-modifiers for the pattern @return \Generator
[ "Scans", "for", "a", "specific", "token", "-", "type", "based", "on", "a", "pattern", "and", "converts", "it", "to", "a", "valid", "token", "automatically", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L806-L824
train
Talesoft/tale-jade
Lexer.php
Lexer.scanTextLine
protected function scanTextLine() { if (!$this->match('([!]?)\|')) return; $this->consumeMatch(); foreach ($this->scanTextBlock($this->getMatch(1) === '!') as $token) yield $token; }
php
protected function scanTextLine() { if (!$this->match('([!]?)\|')) return; $this->consumeMatch(); foreach ($this->scanTextBlock($this->getMatch(1) === '!') as $token) yield $token; }
[ "protected", "function", "scanTextLine", "(", ")", "{", "if", "(", "!", "$", "this", "->", "match", "(", "'([!]?)\\|'", ")", ")", "return", ";", "$", "this", "->", "consumeMatch", "(", ")", ";", "foreach", "(", "$", "this", "->", "scanTextBlock", "(", "$", "this", "->", "getMatch", "(", "1", ")", "===", "'!'", ")", "as", "$", "token", ")", "yield", "$", "token", ";", "}" ]
Scans for a |-style text-line and yields it along with a text-block, if it has any. @return \Generator
[ "Scans", "for", "a", "|", "-", "style", "text", "-", "line", "and", "yields", "it", "along", "with", "a", "text", "-", "block", "if", "it", "has", "any", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L1014-L1024
train
Talesoft/tale-jade
Lexer.php
Lexer.scanControlStatement
protected function scanControlStatement($type, array $names, $nameAttribute = null) { foreach ($names as $name) { if (!$this->match("{$name}[:\t \n]")) continue; $this->consumeMatch(); $this->readSpaces(); $token = $this->createToken($type); if ($nameAttribute) $token[$nameAttribute] = str_replace(' ', '', $name); $token['subject'] = null; //each is a special little unicorn if ($name === 'each') { if (!$this->match( '\$?(?<itemName>[a-zA-Z_][a-zA-Z0-9_]*)(?:[\t ]*,[\t ]*\$?(?<keyName>[a-zA-Z_][a-zA-Z0-9_]*))?[\t ]+in[\t ]+' )) { $this->throwException( "The syntax for each is `each [$]itemName[, [$]keyName]] in [subject]`, not ".$this->peek(20) ); } $this->consumeMatch(); $token['itemName'] = $this->getMatch('itemName'); $token['keyName'] = $this->getMatch('keyName'); $this->readSpaces(); } if ($this->peek() === '(') { $this->consume(); $token['subject'] = $this->readBracketContents(); if ($this->peek() !== ')') $this->throwException( "A closing [`)`] is missing in a control statement subject" ); $this->consume(); } elseif ($this->match("([^:\n]+)")) { $this->consumeMatch(); $token['subject'] = trim($this->getMatch(1)); } yield $token; foreach ($this->scanSub() as $subToken) yield $subToken; } }
php
protected function scanControlStatement($type, array $names, $nameAttribute = null) { foreach ($names as $name) { if (!$this->match("{$name}[:\t \n]")) continue; $this->consumeMatch(); $this->readSpaces(); $token = $this->createToken($type); if ($nameAttribute) $token[$nameAttribute] = str_replace(' ', '', $name); $token['subject'] = null; //each is a special little unicorn if ($name === 'each') { if (!$this->match( '\$?(?<itemName>[a-zA-Z_][a-zA-Z0-9_]*)(?:[\t ]*,[\t ]*\$?(?<keyName>[a-zA-Z_][a-zA-Z0-9_]*))?[\t ]+in[\t ]+' )) { $this->throwException( "The syntax for each is `each [$]itemName[, [$]keyName]] in [subject]`, not ".$this->peek(20) ); } $this->consumeMatch(); $token['itemName'] = $this->getMatch('itemName'); $token['keyName'] = $this->getMatch('keyName'); $this->readSpaces(); } if ($this->peek() === '(') { $this->consume(); $token['subject'] = $this->readBracketContents(); if ($this->peek() !== ')') $this->throwException( "A closing [`)`] is missing in a control statement subject" ); $this->consume(); } elseif ($this->match("([^:\n]+)")) { $this->consumeMatch(); $token['subject'] = trim($this->getMatch(1)); } yield $token; foreach ($this->scanSub() as $subToken) yield $subToken; } }
[ "protected", "function", "scanControlStatement", "(", "$", "type", ",", "array", "$", "names", ",", "$", "nameAttribute", "=", "null", ")", "{", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "!", "$", "this", "->", "match", "(", "\"{$name}[:\\t \\n]\"", ")", ")", "continue", ";", "$", "this", "->", "consumeMatch", "(", ")", ";", "$", "this", "->", "readSpaces", "(", ")", ";", "$", "token", "=", "$", "this", "->", "createToken", "(", "$", "type", ")", ";", "if", "(", "$", "nameAttribute", ")", "$", "token", "[", "$", "nameAttribute", "]", "=", "str_replace", "(", "' '", ",", "''", ",", "$", "name", ")", ";", "$", "token", "[", "'subject'", "]", "=", "null", ";", "//each is a special little unicorn", "if", "(", "$", "name", "===", "'each'", ")", "{", "if", "(", "!", "$", "this", "->", "match", "(", "'\\$?(?<itemName>[a-zA-Z_][a-zA-Z0-9_]*)(?:[\\t ]*,[\\t ]*\\$?(?<keyName>[a-zA-Z_][a-zA-Z0-9_]*))?[\\t ]+in[\\t ]+'", ")", ")", "{", "$", "this", "->", "throwException", "(", "\"The syntax for each is `each [$]itemName[, [$]keyName]] in [subject]`, not \"", ".", "$", "this", "->", "peek", "(", "20", ")", ")", ";", "}", "$", "this", "->", "consumeMatch", "(", ")", ";", "$", "token", "[", "'itemName'", "]", "=", "$", "this", "->", "getMatch", "(", "'itemName'", ")", ";", "$", "token", "[", "'keyName'", "]", "=", "$", "this", "->", "getMatch", "(", "'keyName'", ")", ";", "$", "this", "->", "readSpaces", "(", ")", ";", "}", "if", "(", "$", "this", "->", "peek", "(", ")", "===", "'('", ")", "{", "$", "this", "->", "consume", "(", ")", ";", "$", "token", "[", "'subject'", "]", "=", "$", "this", "->", "readBracketContents", "(", ")", ";", "if", "(", "$", "this", "->", "peek", "(", ")", "!==", "')'", ")", "$", "this", "->", "throwException", "(", "\"A closing [`)`] is missing in a control statement subject\"", ")", ";", "$", "this", "->", "consume", "(", ")", ";", "}", "elseif", "(", "$", "this", "->", "match", "(", "\"([^:\\n]+)\"", ")", ")", "{", "$", "this", "->", "consumeMatch", "(", ")", ";", "$", "token", "[", "'subject'", "]", "=", "trim", "(", "$", "this", "->", "getMatch", "(", "1", ")", ")", ";", "}", "yield", "$", "token", ";", "foreach", "(", "$", "this", "->", "scanSub", "(", ")", "as", "$", "subToken", ")", "yield", "$", "subToken", ";", "}", "}" ]
Scans for a control-statement-kind of token. e.g. control-statement-name ($expression) Since the <each>-statement is a special little unicorn, it get's handled very specifically inside this function (But correctly!) If the condition can have a subject, the subject will be set as the "subject"-value of the token @todo Avoid block parsing on <do>-loops @param string $type The token type that should be created if scan is successful @param array $names The names the statement can have (e.g. do, while, if, else etc.) @param string|null $nameAttribute The attribute the name gets saved into, if wanted @return \Generator @throws \Tale\Jade\Lexer\Exception
[ "Scans", "for", "a", "control", "-", "statement", "-", "kind", "of", "token", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L1228-L1283
train
Talesoft/tale-jade
Lexer.php
Lexer.scanExpression
protected function scanExpression() { foreach ($this->scanToken( 'expression', "([?]?[!]?[=])[\t ]*(?<value>[^\n]*)" ) as $token) { $token['escaped'] = strstr($this->getMatch(1), '!') ? false : true; $token['unchecked'] = strstr($this->getMatch(1), '?') ? true : false; yield $token; } }
php
protected function scanExpression() { foreach ($this->scanToken( 'expression', "([?]?[!]?[=])[\t ]*(?<value>[^\n]*)" ) as $token) { $token['escaped'] = strstr($this->getMatch(1), '!') ? false : true; $token['unchecked'] = strstr($this->getMatch(1), '?') ? true : false; yield $token; } }
[ "protected", "function", "scanExpression", "(", ")", "{", "foreach", "(", "$", "this", "->", "scanToken", "(", "'expression'", ",", "\"([?]?[!]?[=])[\\t ]*(?<value>[^\\n]*)\"", ")", "as", "$", "token", ")", "{", "$", "token", "[", "'escaped'", "]", "=", "strstr", "(", "$", "this", "->", "getMatch", "(", "1", ")", ",", "'!'", ")", "?", "false", ":", "true", ";", "$", "token", "[", "'unchecked'", "]", "=", "strstr", "(", "$", "this", "->", "getMatch", "(", "1", ")", ",", "'?'", ")", "?", "true", ":", "false", ";", "yield", "$", "token", ";", "}", "}" ]
Scans for !=-style expression. e.g. != expr = expr Expression-tokens always have: escaped, which indicates that the expression result should be escaped value, which is the code of the expression @return \Generator
[ "Scans", "for", "!", "=", "-", "style", "expression", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Lexer.php#L1371-L1383
train
Talesoft/tale-jade
Parser/Node.php
Node.prev
public function prev() { $index = $this->parent->indexOf($this) - 1; return isset($this->parent->children[$index]) ? $this->parent->children[$index] : null; }
php
public function prev() { $index = $this->parent->indexOf($this) - 1; return isset($this->parent->children[$index]) ? $this->parent->children[$index] : null; }
[ "public", "function", "prev", "(", ")", "{", "$", "index", "=", "$", "this", "->", "parent", "->", "indexOf", "(", "$", "this", ")", "-", "1", ";", "return", "isset", "(", "$", "this", "->", "parent", "->", "children", "[", "$", "index", "]", ")", "?", "$", "this", "->", "parent", "->", "children", "[", "$", "index", "]", ":", "null", ";", "}" ]
Returns the previous sibling of this element or null, if if there isn't any. [element:a] (0)[element:b] (1)[element:c] [element:c]->prev() === [element:b] @return Node|null
[ "Returns", "the", "previous", "sibling", "of", "this", "element", "or", "null", "if", "if", "there", "isn", "t", "any", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L151-L157
train
Talesoft/tale-jade
Parser/Node.php
Node.next
public function next() { $index = $this->parent->indexOf($this) + 1; return isset($this->parent->children[$index]) ? $this->parent->children[$index] : null; }
php
public function next() { $index = $this->parent->indexOf($this) + 1; return isset($this->parent->children[$index]) ? $this->parent->children[$index] : null; }
[ "public", "function", "next", "(", ")", "{", "$", "index", "=", "$", "this", "->", "parent", "->", "indexOf", "(", "$", "this", ")", "+", "1", ";", "return", "isset", "(", "$", "this", "->", "parent", "->", "children", "[", "$", "index", "]", ")", "?", "$", "this", "->", "parent", "->", "children", "[", "$", "index", "]", ":", "null", ";", "}" ]
Returns the next sibling of this element or null, if if there isn't any. [element:a] (0)[element:b] (1)[element:c] [element:b]->next() === [element:c] @return Node|null
[ "Returns", "the", "next", "sibling", "of", "this", "element", "or", "null", "if", "if", "there", "isn", "t", "any", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L170-L176
train
Talesoft/tale-jade
Parser/Node.php
Node.append
public function append(Node $node) { $this->children[] = $node; $node->parent = $this; return $this; }
php
public function append(Node $node) { $this->children[] = $node; $node->parent = $this; return $this; }
[ "public", "function", "append", "(", "Node", "$", "node", ")", "{", "$", "this", "->", "children", "[", "]", "=", "$", "node", ";", "$", "node", "->", "parent", "=", "$", "this", ";", "return", "$", "this", ";", "}" ]
Appends the given node to this node's children. This also sets the parent of the given child to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->append([element:d]) [element:a] (0)[element:b] (1)[element:c] (2)[element:d] @param Node $node the new child node to be appended @return $this
[ "Appends", "the", "given", "node", "to", "this", "node", "s", "children", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L198-L205
train
Talesoft/tale-jade
Parser/Node.php
Node.prepend
public function prepend(Node $node) { array_unshift($this->children, $node); $node->parent = $this; return $this; }
php
public function prepend(Node $node) { array_unshift($this->children, $node); $node->parent = $this; return $this; }
[ "public", "function", "prepend", "(", "Node", "$", "node", ")", "{", "array_unshift", "(", "$", "this", "->", "children", ",", "$", "node", ")", ";", "$", "node", "->", "parent", "=", "$", "this", ";", "return", "$", "this", ";", "}" ]
Prepends the given node to this node's children. This also sets the parent of the given child to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->prepend([element:d]) [element:a] (0)[element:d] (1)[element:b] (2)[element:c] @param Node $node the new child node to be prepended @return $this
[ "Prepends", "the", "given", "node", "to", "this", "node", "s", "children", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L227-L234
train
Talesoft/tale-jade
Parser/Node.php
Node.remove
public function remove(Node $node) { $index = $this->indexOf($node); if ($index !== false) { $this->children[$index]->parent = null; array_splice($this->children, $index, 1); } return $this; }
php
public function remove(Node $node) { $index = $this->indexOf($node); if ($index !== false) { $this->children[$index]->parent = null; array_splice($this->children, $index, 1); } return $this; }
[ "public", "function", "remove", "(", "Node", "$", "node", ")", "{", "$", "index", "=", "$", "this", "->", "indexOf", "(", "$", "node", ")", ";", "if", "(", "$", "index", "!==", "false", ")", "{", "$", "this", "->", "children", "[", "$", "index", "]", "->", "parent", "=", "null", ";", "array_splice", "(", "$", "this", "->", "children", ",", "$", "index", ",", "1", ")", ";", "}", "return", "$", "this", ";", "}" ]
Removes the given child node from this node's children. The parent of the given child node will be set to null [element:a] (0)[element:b] (1)[element:c] (2)[element:d] [element:a]->remove([element:c]) [element:a] (0)[element:b] (1)[element:d] @param Node $node the node to remove from this node's children @return $this
[ "Removes", "the", "given", "child", "node", "from", "this", "node", "s", "children", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L256-L268
train
Talesoft/tale-jade
Parser/Node.php
Node.insertAfter
public function insertAfter(Node $node, Node $newNode) { $index = $this->indexOf($node); if ($index === false) return $this->append($newNode); array_splice($this->children, $index + 1, 0, [$newNode]); $newNode->parent = $this; return $this; }
php
public function insertAfter(Node $node, Node $newNode) { $index = $this->indexOf($node); if ($index === false) return $this->append($newNode); array_splice($this->children, $index + 1, 0, [$newNode]); $newNode->parent = $this; return $this; }
[ "public", "function", "insertAfter", "(", "Node", "$", "node", ",", "Node", "$", "newNode", ")", "{", "$", "index", "=", "$", "this", "->", "indexOf", "(", "$", "node", ")", ";", "if", "(", "$", "index", "===", "false", ")", "return", "$", "this", "->", "append", "(", "$", "newNode", ")", ";", "array_splice", "(", "$", "this", "->", "children", ",", "$", "index", "+", "1", ",", "0", ",", "[", "$", "newNode", "]", ")", ";", "$", "newNode", "->", "parent", "=", "$", "this", ";", "return", "$", "this", ";", "}" ]
Inserts the second given node after the first given node inside this node's children. This allows fine control over the node's children The new nodes parent will be set to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->insertAfter([element:b], [element:d]) [element:a] (0)[element:b] (1)[element:d] (2)[element:c] @param Node $node the child node of this node's children the new node will be inserted after @param Node $newNode the new node that will be inserted after the first node @return $this
[ "Inserts", "the", "second", "given", "node", "after", "the", "first", "given", "node", "inside", "this", "node", "s", "children", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L296-L308
train
Talesoft/tale-jade
Parser/Node.php
Node.insertBefore
public function insertBefore(Node $node, Node $newNode) { $index = $this->indexOf($node); if ($index === false) return $this->prepend($newNode); array_splice($this->children, $index, 0, [$newNode]); $newNode->parent = $this; return $this; }
php
public function insertBefore(Node $node, Node $newNode) { $index = $this->indexOf($node); if ($index === false) return $this->prepend($newNode); array_splice($this->children, $index, 0, [$newNode]); $newNode->parent = $this; return $this; }
[ "public", "function", "insertBefore", "(", "Node", "$", "node", ",", "Node", "$", "newNode", ")", "{", "$", "index", "=", "$", "this", "->", "indexOf", "(", "$", "node", ")", ";", "if", "(", "$", "index", "===", "false", ")", "return", "$", "this", "->", "prepend", "(", "$", "newNode", ")", ";", "array_splice", "(", "$", "this", "->", "children", ",", "$", "index", ",", "0", ",", "[", "$", "newNode", "]", ")", ";", "$", "newNode", "->", "parent", "=", "$", "this", ";", "return", "$", "this", ";", "}" ]
Inserts the second given node before the first given node inside this node's children. This allows fine control over the node's children The new nodes parent will be set to this node [element:a] (0)[element:b] (1)[element:c] [element:a]->insertBefore([element:c], [element:d]) [element:a] (0)[element:b] (1)[element:d] (2)[element:c] @param Node $node the child node of this node's children the new node will be inserted before @param Node $newNode the new node that will be inserted before the first node @return $this
[ "Inserts", "the", "second", "given", "node", "before", "the", "first", "given", "node", "inside", "this", "node", "s", "children", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L336-L348
train
Talesoft/tale-jade
Parser/Node.php
Node.find
public function find($type) { foreach ($this->children as $node) { if ($node->type === $type) yield $node; foreach ($node->find($type) as $subNode) yield $subNode; } }
php
public function find($type) { foreach ($this->children as $node) { if ($node->type === $type) yield $node; foreach ($node->find($type) as $subNode) yield $subNode; } }
[ "public", "function", "find", "(", "$", "type", ")", "{", "foreach", "(", "$", "this", "->", "children", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "type", "===", "$", "type", ")", "yield", "$", "node", ";", "foreach", "(", "$", "node", "->", "find", "(", "$", "type", ")", "as", "$", "subNode", ")", "yield", "$", "subNode", ";", "}", "}" ]
Finds nodes with the given type inside this nodes children. Plus all it's children-children recursively and returns a generator providing them This is used to collect all blocks, imports and mixins and handle them in a special way If you need a normal array, use ->findArray() instead instead @param string $type the node type to search for @return \Generator a generator of the found children
[ "Finds", "nodes", "with", "the", "given", "type", "inside", "this", "nodes", "children", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L365-L376
train
Talesoft/tale-jade
Parser/Node.php
Node.text
public function text($indentStyle = ' ', $newLine = "\n", $level = 0) { $indent = str_repeat($indentStyle, $level); $texts = []; foreach ($this->children as $child) { if ($child->type === 'text') { $texts[] = $indent.$child->value; $texts[] = $child->text($indentStyle, $newLine, $level + 1); } } return implode($newLine, $texts); }
php
public function text($indentStyle = ' ', $newLine = "\n", $level = 0) { $indent = str_repeat($indentStyle, $level); $texts = []; foreach ($this->children as $child) { if ($child->type === 'text') { $texts[] = $indent.$child->value; $texts[] = $child->text($indentStyle, $newLine, $level + 1); } } return implode($newLine, $texts); }
[ "public", "function", "text", "(", "$", "indentStyle", "=", "' '", ",", "$", "newLine", "=", "\"\\n\"", ",", "$", "level", "=", "0", ")", "{", "$", "indent", "=", "str_repeat", "(", "$", "indentStyle", ",", "$", "level", ")", ";", "$", "texts", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "{", "if", "(", "$", "child", "->", "type", "===", "'text'", ")", "{", "$", "texts", "[", "]", "=", "$", "indent", ".", "$", "child", "->", "value", ";", "$", "texts", "[", "]", "=", "$", "child", "->", "text", "(", "$", "indentStyle", ",", "$", "newLine", ",", "$", "level", "+", "1", ")", ";", "}", "}", "return", "implode", "(", "$", "newLine", ",", "$", "texts", ")", ";", "}" ]
Returns all text and child-texts in a single text. You can control the text-style with the arguments @param string $indentStyle the indentation to use (multiplies with level) @param string $newLine the new-line style to use @param int $level the initial indentation level @return string the compiled text-block
[ "Returns", "all", "text", "and", "child", "-", "texts", "in", "a", "single", "text", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L409-L424
train
Talesoft/tale-jade
Parser/Node.php
Node.dump
public function dump($level = 0) { $export = implode(' ', array_map(function ($key, $value) { $str = ''; if (!is_numeric($key)) $str .= "$key="; if ($value) $str .= !is_array($value) ? $value : '{'.implode(', ', array_map('trim', array_map('strval', $value))).'}'; return $str; }, array_keys($this->data), $this->data)); $indent = str_repeat(' ', $level); $str = $indent.'['.$this->type.(empty($export) ? '' : " $export").']'."\n"; foreach ($this->children as $child) $str .= $child->dump($level + 1); return trim($str); }
php
public function dump($level = 0) { $export = implode(' ', array_map(function ($key, $value) { $str = ''; if (!is_numeric($key)) $str .= "$key="; if ($value) $str .= !is_array($value) ? $value : '{'.implode(', ', array_map('trim', array_map('strval', $value))).'}'; return $str; }, array_keys($this->data), $this->data)); $indent = str_repeat(' ', $level); $str = $indent.'['.$this->type.(empty($export) ? '' : " $export").']'."\n"; foreach ($this->children as $child) $str .= $child->dump($level + 1); return trim($str); }
[ "public", "function", "dump", "(", "$", "level", "=", "0", ")", "{", "$", "export", "=", "implode", "(", "' '", ",", "array_map", "(", "function", "(", "$", "key", ",", "$", "value", ")", "{", "$", "str", "=", "''", ";", "if", "(", "!", "is_numeric", "(", "$", "key", ")", ")", "$", "str", ".=", "\"$key=\"", ";", "if", "(", "$", "value", ")", "$", "str", ".=", "!", "is_array", "(", "$", "value", ")", "?", "$", "value", ":", "'{'", ".", "implode", "(", "', '", ",", "array_map", "(", "'trim'", ",", "array_map", "(", "'strval'", ",", "$", "value", ")", ")", ")", ".", "'}'", ";", "return", "$", "str", ";", "}", ",", "array_keys", "(", "$", "this", "->", "data", ")", ",", "$", "this", "->", "data", ")", ")", ";", "$", "indent", "=", "str_repeat", "(", "' '", ",", "$", "level", ")", ";", "$", "str", "=", "$", "indent", ".", "'['", ".", "$", "this", "->", "type", ".", "(", "empty", "(", "$", "export", ")", "?", "''", ":", "\" $export\"", ")", ".", "']'", ".", "\"\\n\"", ";", "foreach", "(", "$", "this", "->", "children", "as", "$", "child", ")", "$", "str", ".=", "$", "child", "->", "dump", "(", "$", "level", "+", "1", ")", ";", "return", "trim", "(", "$", "str", ")", ";", "}" ]
Dumps the node as a string to ease up debugging. This is also the default-action for __toString on every node The result will look like this: [element tag=a expands=[element tag=b]] [element tag=c attributes={[attribute name=d name=e]}] @param int $level the initial indentation level @return string the string to debug the node-tree
[ "Dumps", "the", "node", "as", "a", "string", "to", "ease", "up", "debugging", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser/Node.php#L441-L464
train
Talesoft/tale-jade
Parser.php
Parser.handleToken
protected function handleToken(array $token = null) { $token = $token ? $token : $this->getToken(); //Put together the method name $method = 'handle'.ucfirst($token['type']); //If the token has no handler, we throw an error if (!method_exists($this, $method)) { $this->throwException( "Unexpected token `{$token['type']}` encountered, no handler $method found. ". "It seems you added custom tokens. Please extend the Parser and add a $method-method for that token", $token ); } else { //Call the handler method and pass the token array as the first argument call_user_func([$this, $method], $token); } }
php
protected function handleToken(array $token = null) { $token = $token ? $token : $this->getToken(); //Put together the method name $method = 'handle'.ucfirst($token['type']); //If the token has no handler, we throw an error if (!method_exists($this, $method)) { $this->throwException( "Unexpected token `{$token['type']}` encountered, no handler $method found. ". "It seems you added custom tokens. Please extend the Parser and add a $method-method for that token", $token ); } else { //Call the handler method and pass the token array as the first argument call_user_func([$this, $method], $token); } }
[ "protected", "function", "handleToken", "(", "array", "$", "token", "=", "null", ")", "{", "$", "token", "=", "$", "token", "?", "$", "token", ":", "$", "this", "->", "getToken", "(", ")", ";", "//Put together the method name", "$", "method", "=", "'handle'", ".", "ucfirst", "(", "$", "token", "[", "'type'", "]", ")", ";", "//If the token has no handler, we throw an error", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "$", "this", "->", "throwException", "(", "\"Unexpected token `{$token['type']}` encountered, no handler $method found. \"", ".", "\"It seems you added custom tokens. Please extend the Parser and add a $method-method for that token\"", ",", "$", "token", ")", ";", "}", "else", "{", "//Call the handler method and pass the token array as the first argument", "call_user_func", "(", "[", "$", "this", ",", "$", "method", "]", ",", "$", "token", ")", ";", "}", "}" ]
Handles any kind of token returned by the lexer dynamically. The token-type will be translated into a method name e.g. newLine => handleNewLine attribute => handleAttribute tag => handleTag First argument of that method will always be the token array If no token is passed, it will take the current token in the lexer's token generator @param array|null $token a token or the current lexer's generator token @throws Exception when no token handler has been found
[ "Handles", "any", "kind", "of", "token", "returned", "by", "the", "lexer", "dynamically", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser.php#L259-L279
train
Talesoft/tale-jade
Parser.php
Parser.expectEnd
protected function expectEnd(array $relatedToken = null) { foreach ($this->lookUpNext(['newLine']) as $token) { $this->handleToken($token); return; } if (!$this->expectNext(['newLine'])) { $this->throwException( "Nothing should be following this statement, the end of line is expected.", $relatedToken ); } else $this->handleToken(); }
php
protected function expectEnd(array $relatedToken = null) { foreach ($this->lookUpNext(['newLine']) as $token) { $this->handleToken($token); return; } if (!$this->expectNext(['newLine'])) { $this->throwException( "Nothing should be following this statement, the end of line is expected.", $relatedToken ); } else $this->handleToken(); }
[ "protected", "function", "expectEnd", "(", "array", "$", "relatedToken", "=", "null", ")", "{", "foreach", "(", "$", "this", "->", "lookUpNext", "(", "[", "'newLine'", "]", ")", "as", "$", "token", ")", "{", "$", "this", "->", "handleToken", "(", "$", "token", ")", ";", "return", ";", "}", "if", "(", "!", "$", "this", "->", "expectNext", "(", "[", "'newLine'", "]", ")", ")", "{", "$", "this", "->", "throwException", "(", "\"Nothing should be following this statement, the end of line is expected.\"", ",", "$", "relatedToken", ")", ";", "}", "else", "$", "this", "->", "handleToken", "(", ")", ";", "}" ]
Throws an exception if the next token is not a newLine token. This states that "a line of instructions should end here" Notice that if the next token is _not_ a newLine, it gets handled through handleToken automatically @param array|null $relatedToken the token to relate the exception to @throws Exception when the next token is not a newLine token
[ "Throws", "an", "exception", "if", "the", "next", "token", "is", "not", "a", "newLine", "token", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser.php#L372-L390
train
Talesoft/tale-jade
Parser.php
Parser.createElement
protected function createElement(array $token = null) { $node = $this->createNode('element', $token); $node->tag = null; $node->attributes = []; $node->assignments = []; return $node; }
php
protected function createElement(array $token = null) { $node = $this->createNode('element', $token); $node->tag = null; $node->attributes = []; $node->assignments = []; return $node; }
[ "protected", "function", "createElement", "(", "array", "$", "token", "=", "null", ")", "{", "$", "node", "=", "$", "this", "->", "createNode", "(", "'element'", ",", "$", "token", ")", ";", "$", "node", "->", "tag", "=", "null", ";", "$", "node", "->", "attributes", "=", "[", "]", ";", "$", "node", "->", "assignments", "=", "[", "]", ";", "return", "$", "node", ";", "}" ]
Creates an element-node with the properties it should have consistently. This will create the following properties on the Node instance: @todo Do this for a bunch of other elements as well, maybe all, maybe a centralized way? @param array|null $token the token to relate this element to @return Node the newly created element-node
[ "Creates", "an", "element", "-", "node", "with", "the", "properties", "it", "should", "have", "consistently", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser.php#L476-L485
train
Talesoft/tale-jade
Parser.php
Parser.throwException
protected function throwException($message, array $relatedToken = null) { if ($relatedToken) $message .= "\n(".$relatedToken['type'] .' at '.$relatedToken['line'] .':'.$relatedToken['offset'].')'; throw new Exception( "Failed to parse Jade: $message" ); }
php
protected function throwException($message, array $relatedToken = null) { if ($relatedToken) $message .= "\n(".$relatedToken['type'] .' at '.$relatedToken['line'] .':'.$relatedToken['offset'].')'; throw new Exception( "Failed to parse Jade: $message" ); }
[ "protected", "function", "throwException", "(", "$", "message", ",", "array", "$", "relatedToken", "=", "null", ")", "{", "if", "(", "$", "relatedToken", ")", "$", "message", ".=", "\"\\n(\"", ".", "$", "relatedToken", "[", "'type'", "]", ".", "' at '", ".", "$", "relatedToken", "[", "'line'", "]", ".", "':'", ".", "$", "relatedToken", "[", "'offset'", "]", ".", "')'", ";", "throw", "new", "Exception", "(", "\"Failed to parse Jade: $message\"", ")", ";", "}" ]
Throws a Parser-Exception. If a related token is passed, it will also append the location in the input of that token @param string $message a meaningful error-message @param array|null $relatedToken the token related to this error @throws Exception
[ "Throws", "a", "Parser", "-", "Exception", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Parser.php#L1193-L1204
train
Talesoft/tale-jade
Renderer.php
Renderer.getAdapter
public function getAdapter() { if (!isset($this->adapter)) { $adapter = $this->options['adapter']; $className = strpos($adapter, '\\') === false ? __NAMESPACE__.'\\Renderer\\Adapter\\'.ucfirst($this->options['adapter']) : $adapter; if (!class_exists($className)) throw new \RuntimeException( "The passed adapter $className doesn't exist" ); if (!is_subclass_of($className, __NAMESPACE__.'\\Renderer\\AdapterBase')) throw new \RuntimeException( "The passed adapter $className doesn't extend Tale\\Jade\\Renderer\\AdapterBase" ); $this->adapter = new $className($this, $this->options['adapter_options']); } return $this->adapter; }
php
public function getAdapter() { if (!isset($this->adapter)) { $adapter = $this->options['adapter']; $className = strpos($adapter, '\\') === false ? __NAMESPACE__.'\\Renderer\\Adapter\\'.ucfirst($this->options['adapter']) : $adapter; if (!class_exists($className)) throw new \RuntimeException( "The passed adapter $className doesn't exist" ); if (!is_subclass_of($className, __NAMESPACE__.'\\Renderer\\AdapterBase')) throw new \RuntimeException( "The passed adapter $className doesn't extend Tale\\Jade\\Renderer\\AdapterBase" ); $this->adapter = new $className($this, $this->options['adapter_options']); } return $this->adapter; }
[ "public", "function", "getAdapter", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "adapter", ")", ")", "{", "$", "adapter", "=", "$", "this", "->", "options", "[", "'adapter'", "]", ";", "$", "className", "=", "strpos", "(", "$", "adapter", ",", "'\\\\'", ")", "===", "false", "?", "__NAMESPACE__", ".", "'\\\\Renderer\\\\Adapter\\\\'", ".", "ucfirst", "(", "$", "this", "->", "options", "[", "'adapter'", "]", ")", ":", "$", "adapter", ";", "if", "(", "!", "class_exists", "(", "$", "className", ")", ")", "throw", "new", "\\", "RuntimeException", "(", "\"The passed adapter $className doesn't exist\"", ")", ";", "if", "(", "!", "is_subclass_of", "(", "$", "className", ",", "__NAMESPACE__", ".", "'\\\\Renderer\\\\AdapterBase'", ")", ")", "throw", "new", "\\", "RuntimeException", "(", "\"The passed adapter $className doesn't extend Tale\\\\Jade\\\\Renderer\\\\AdapterBase\"", ")", ";", "$", "this", "->", "adapter", "=", "new", "$", "className", "(", "$", "this", ",", "$", "this", "->", "options", "[", "'adapter_options'", "]", ")", ";", "}", "return", "$", "this", "->", "adapter", ";", "}" ]
Returns the adapter that actually renders the files. This is lazy, meaning that the adapter gets created and stored as soon as the method is called the first time. After that all calls will return the same adapter instance @return AdapterBase
[ "Returns", "the", "adapter", "that", "actually", "renders", "the", "files", "." ]
e9405e0f4f6b252514cbb27431e13e04cf44614e
https://github.com/Talesoft/tale-jade/blob/e9405e0f4f6b252514cbb27431e13e04cf44614e/Renderer.php#L245-L269
train
heyday/silverstripe-cacheinclude
src/SilverStripe/InvalidationExtension.php
InvalidationExtension.invalidate
protected function invalidate($name, $message, $logger = null) { // Flush in both draft + live Versioned::withVersionedMode(function () use ($name) { foreach ([Versioned::LIVE, Versioned::DRAFT] as $stage) { Versioned::set_stage($stage); $this->cache->flushByName($name); } }); if ($logger) { $logger->info($message); } }
php
protected function invalidate($name, $message, $logger = null) { // Flush in both draft + live Versioned::withVersionedMode(function () use ($name) { foreach ([Versioned::LIVE, Versioned::DRAFT] as $stage) { Versioned::set_stage($stage); $this->cache->flushByName($name); } }); if ($logger) { $logger->info($message); } }
[ "protected", "function", "invalidate", "(", "$", "name", ",", "$", "message", ",", "$", "logger", "=", "null", ")", "{", "// Flush in both draft + live", "Versioned", "::", "withVersionedMode", "(", "function", "(", ")", "use", "(", "$", "name", ")", "{", "foreach", "(", "[", "Versioned", "::", "LIVE", ",", "Versioned", "::", "DRAFT", "]", "as", "$", "stage", ")", "{", "Versioned", "::", "set_stage", "(", "$", "stage", ")", ";", "$", "this", "->", "cache", "->", "flushByName", "(", "$", "name", ")", ";", "}", "}", ")", ";", "if", "(", "$", "logger", ")", "{", "$", "logger", "->", "info", "(", "$", "message", ")", ";", "}", "}" ]
Invalidates a cache by a certain name, and logs if available @param $name @param $message @param \Psr\Log\LoggerInterface|null $logger
[ "Invalidates", "a", "cache", "by", "a", "certain", "name", "and", "logs", "if", "available" ]
2cdebb0dfeebdb3b2090a233755944ef8ca7ae67
https://github.com/heyday/silverstripe-cacheinclude/blob/2cdebb0dfeebdb3b2090a233755944ef8ca7ae67/src/SilverStripe/InvalidationExtension.php#L164-L177
train
contributte/event-dispatcher
src/DI/EventDispatcherExtension.php
EventDispatcherExtension.doBeforeCompile
private function doBeforeCompile(): void { $builder = $this->getContainerBuilder(); $dispatcher = $builder->getDefinition($this->prefix('dispatcher')); $subscribers = $builder->findByType(EventSubscriberInterface::class); foreach ($subscribers as $name => $subscriber) { $dispatcher->addSetup('addSubscriber', [$subscriber]); } }
php
private function doBeforeCompile(): void { $builder = $this->getContainerBuilder(); $dispatcher = $builder->getDefinition($this->prefix('dispatcher')); $subscribers = $builder->findByType(EventSubscriberInterface::class); foreach ($subscribers as $name => $subscriber) { $dispatcher->addSetup('addSubscriber', [$subscriber]); } }
[ "private", "function", "doBeforeCompile", "(", ")", ":", "void", "{", "$", "builder", "=", "$", "this", "->", "getContainerBuilder", "(", ")", ";", "$", "dispatcher", "=", "$", "builder", "->", "getDefinition", "(", "$", "this", "->", "prefix", "(", "'dispatcher'", ")", ")", ";", "$", "subscribers", "=", "$", "builder", "->", "findByType", "(", "EventSubscriberInterface", "::", "class", ")", ";", "foreach", "(", "$", "subscribers", "as", "$", "name", "=>", "$", "subscriber", ")", "{", "$", "dispatcher", "->", "addSetup", "(", "'addSubscriber'", ",", "[", "$", "subscriber", "]", ")", ";", "}", "}" ]
Collect listeners and subscribers
[ "Collect", "listeners", "and", "subscribers" ]
59d68450656b8bda5f15aa0aaa01c1eba2ede223
https://github.com/contributte/event-dispatcher/blob/59d68450656b8bda5f15aa0aaa01c1eba2ede223/src/DI/EventDispatcherExtension.php#L56-L65
train
contributte/event-dispatcher
src/DI/EventDispatcherExtension.php
EventDispatcherExtension.doBeforeCompileLaziness
private function doBeforeCompileLaziness(): void { $builder = $this->getContainerBuilder(); $dispatcher = $builder->getDefinition($this->prefix('dispatcher')); $subscribers = $builder->findByType(EventSubscriberInterface::class); foreach ($subscribers as $name => $subscriber) { $events = call_user_func([$subscriber->getEntity(), 'getSubscribedEvents']); /** * ['eventName' => 'methodName'] * ['eventName' => ['methodName', $priority]] * ['eventName' => [['methodName1', $priority], ['methodName2']]] */ foreach ($events as $event => $args) { if (is_string($args)) { if (!method_exists((string) $subscriber->getType(), $args)) { throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args)); } $dispatcher->addSetup('addSubscriberLazy', [$event, $name]); } elseif (is_string($args[0])) { if (!method_exists((string) $subscriber->getType(), $args[0])) { throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args[0])); } $dispatcher->addSetup('addSubscriberLazy', [$event, $name]); } else { foreach ($args as $arg) { if (!method_exists((string) $subscriber->getType(), $arg[0])) { throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $arg[0])); } $dispatcher->addSetup('addSubscriberLazy', [$event, $name]); } } } } }
php
private function doBeforeCompileLaziness(): void { $builder = $this->getContainerBuilder(); $dispatcher = $builder->getDefinition($this->prefix('dispatcher')); $subscribers = $builder->findByType(EventSubscriberInterface::class); foreach ($subscribers as $name => $subscriber) { $events = call_user_func([$subscriber->getEntity(), 'getSubscribedEvents']); /** * ['eventName' => 'methodName'] * ['eventName' => ['methodName', $priority]] * ['eventName' => [['methodName1', $priority], ['methodName2']]] */ foreach ($events as $event => $args) { if (is_string($args)) { if (!method_exists((string) $subscriber->getType(), $args)) { throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args)); } $dispatcher->addSetup('addSubscriberLazy', [$event, $name]); } elseif (is_string($args[0])) { if (!method_exists((string) $subscriber->getType(), $args[0])) { throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $args[0])); } $dispatcher->addSetup('addSubscriberLazy', [$event, $name]); } else { foreach ($args as $arg) { if (!method_exists((string) $subscriber->getType(), $arg[0])) { throw new ServiceCreationException(sprintf('Event listener %s does not have callable method %s', $subscriber->getType(), $arg[0])); } $dispatcher->addSetup('addSubscriberLazy', [$event, $name]); } } } } }
[ "private", "function", "doBeforeCompileLaziness", "(", ")", ":", "void", "{", "$", "builder", "=", "$", "this", "->", "getContainerBuilder", "(", ")", ";", "$", "dispatcher", "=", "$", "builder", "->", "getDefinition", "(", "$", "this", "->", "prefix", "(", "'dispatcher'", ")", ")", ";", "$", "subscribers", "=", "$", "builder", "->", "findByType", "(", "EventSubscriberInterface", "::", "class", ")", ";", "foreach", "(", "$", "subscribers", "as", "$", "name", "=>", "$", "subscriber", ")", "{", "$", "events", "=", "call_user_func", "(", "[", "$", "subscriber", "->", "getEntity", "(", ")", ",", "'getSubscribedEvents'", "]", ")", ";", "/**\n\t\t\t * ['eventName' => 'methodName']\n\t\t\t * ['eventName' => ['methodName', $priority]]\n\t\t\t * ['eventName' => [['methodName1', $priority], ['methodName2']]]\n\t\t\t */", "foreach", "(", "$", "events", "as", "$", "event", "=>", "$", "args", ")", "{", "if", "(", "is_string", "(", "$", "args", ")", ")", "{", "if", "(", "!", "method_exists", "(", "(", "string", ")", "$", "subscriber", "->", "getType", "(", ")", ",", "$", "args", ")", ")", "{", "throw", "new", "ServiceCreationException", "(", "sprintf", "(", "'Event listener %s does not have callable method %s'", ",", "$", "subscriber", "->", "getType", "(", ")", ",", "$", "args", ")", ")", ";", "}", "$", "dispatcher", "->", "addSetup", "(", "'addSubscriberLazy'", ",", "[", "$", "event", ",", "$", "name", "]", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "args", "[", "0", "]", ")", ")", "{", "if", "(", "!", "method_exists", "(", "(", "string", ")", "$", "subscriber", "->", "getType", "(", ")", ",", "$", "args", "[", "0", "]", ")", ")", "{", "throw", "new", "ServiceCreationException", "(", "sprintf", "(", "'Event listener %s does not have callable method %s'", ",", "$", "subscriber", "->", "getType", "(", ")", ",", "$", "args", "[", "0", "]", ")", ")", ";", "}", "$", "dispatcher", "->", "addSetup", "(", "'addSubscriberLazy'", ",", "[", "$", "event", ",", "$", "name", "]", ")", ";", "}", "else", "{", "foreach", "(", "$", "args", "as", "$", "arg", ")", "{", "if", "(", "!", "method_exists", "(", "(", "string", ")", "$", "subscriber", "->", "getType", "(", ")", ",", "$", "arg", "[", "0", "]", ")", ")", "{", "throw", "new", "ServiceCreationException", "(", "sprintf", "(", "'Event listener %s does not have callable method %s'", ",", "$", "subscriber", "->", "getType", "(", ")", ",", "$", "arg", "[", "0", "]", ")", ")", ";", "}", "$", "dispatcher", "->", "addSetup", "(", "'addSubscriberLazy'", ",", "[", "$", "event", ",", "$", "name", "]", ")", ";", "}", "}", "}", "}", "}" ]
Collect listeners and subscribers in lazy-way
[ "Collect", "listeners", "and", "subscribers", "in", "lazy", "-", "way" ]
59d68450656b8bda5f15aa0aaa01c1eba2ede223
https://github.com/contributte/event-dispatcher/blob/59d68450656b8bda5f15aa0aaa01c1eba2ede223/src/DI/EventDispatcherExtension.php#L70-L108
train
heyday/silverstripe-cacheinclude
src/CacheInclude.php
CacheInclude.getCombinedConfig
public function getCombinedConfig($name) { $config = $this->defaultConfig; if (isset($this->config[$name]) && is_array($this->config[$name])) { $config = $this->config[$name] + $config; } else { throw new RuntimeException("Config '$name' doesn't exist, please check your config"); } return $config; }
php
public function getCombinedConfig($name) { $config = $this->defaultConfig; if (isset($this->config[$name]) && is_array($this->config[$name])) { $config = $this->config[$name] + $config; } else { throw new RuntimeException("Config '$name' doesn't exist, please check your config"); } return $config; }
[ "public", "function", "getCombinedConfig", "(", "$", "name", ")", "{", "$", "config", "=", "$", "this", "->", "defaultConfig", ";", "if", "(", "isset", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", "&&", "is_array", "(", "$", "this", "->", "config", "[", "$", "name", "]", ")", ")", "{", "$", "config", "=", "$", "this", "->", "config", "[", "$", "name", "]", "+", "$", "config", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Config '$name' doesn't exist, please check your config\"", ")", ";", "}", "return", "$", "config", ";", "}" ]
Get the default config combined with the provided config @param $name @return mixed @throws \RuntimeException
[ "Get", "the", "default", "config", "combined", "with", "the", "provided", "config" ]
2cdebb0dfeebdb3b2090a233755944ef8ca7ae67
https://github.com/heyday/silverstripe-cacheinclude/blob/2cdebb0dfeebdb3b2090a233755944ef8ca7ae67/src/CacheInclude.php#L142-L152
train
heyday/silverstripe-cacheinclude
src/CacheInclude.php
CacheInclude.flushByName
public function flushByName($name) { $this->lockCacheAndRun(function() use ($name) { $keys = (array) $this->cache->get($name); foreach (array_keys($keys) as $key) { $this->cache->delete($key); } $this->cache->set($name, []); }); }
php
public function flushByName($name) { $this->lockCacheAndRun(function() use ($name) { $keys = (array) $this->cache->get($name); foreach (array_keys($keys) as $key) { $this->cache->delete($key); } $this->cache->set($name, []); }); }
[ "public", "function", "flushByName", "(", "$", "name", ")", "{", "$", "this", "->", "lockCacheAndRun", "(", "function", "(", ")", "use", "(", "$", "name", ")", "{", "$", "keys", "=", "(", "array", ")", "$", "this", "->", "cache", "->", "get", "(", "$", "name", ")", ";", "foreach", "(", "array_keys", "(", "$", "keys", ")", "as", "$", "key", ")", "{", "$", "this", "->", "cache", "->", "delete", "(", "$", "key", ")", ";", "}", "$", "this", "->", "cache", "->", "set", "(", "$", "name", ",", "[", "]", ")", ";", "}", ")", ";", "}" ]
Flush the named cache block @param $name
[ "Flush", "the", "named", "cache", "block" ]
2cdebb0dfeebdb3b2090a233755944ef8ca7ae67
https://github.com/heyday/silverstripe-cacheinclude/blob/2cdebb0dfeebdb3b2090a233755944ef8ca7ae67/src/CacheInclude.php#L362-L371
train
UseMuffin/Throttle
src/ThrottleTrait.php
ThrottleTrait._setIdentifier
protected function _setIdentifier($request) { $key = $this->getConfig('identifier'); if (!is_callable($this->getConfig('identifier'))) { throw new \InvalidArgumentException('Throttle identifier option must be a callable'); } $this->_identifier = $key($request); }
php
protected function _setIdentifier($request) { $key = $this->getConfig('identifier'); if (!is_callable($this->getConfig('identifier'))) { throw new \InvalidArgumentException('Throttle identifier option must be a callable'); } $this->_identifier = $key($request); }
[ "protected", "function", "_setIdentifier", "(", "$", "request", ")", "{", "$", "key", "=", "$", "this", "->", "getConfig", "(", "'identifier'", ")", ";", "if", "(", "!", "is_callable", "(", "$", "this", "->", "getConfig", "(", "'identifier'", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Throttle identifier option must be a callable'", ")", ";", "}", "$", "this", "->", "_identifier", "=", "$", "key", "(", "$", "request", ")", ";", "}" ]
Sets the identifier class property. Uses Throttle default IP address based identifier unless a callable alternative is passed. @param \Psr\Http\Message\ServerRequestInterface|\Cake\Http\Request $request RequestInterface instance @return void @throws \InvalidArgumentException
[ "Sets", "the", "identifier", "class", "property", ".", "Uses", "Throttle", "default", "IP", "address", "based", "identifier", "unless", "a", "callable", "alternative", "is", "passed", "." ]
9eef7ed2f23a44297df4580a4fcb76d804db6a81
https://github.com/UseMuffin/Throttle/blob/9eef7ed2f23a44297df4580a4fcb76d804db6a81/src/ThrottleTrait.php#L79-L86
train
UseMuffin/Throttle
src/ThrottleTrait.php
ThrottleTrait._initCache
protected function _initCache() { if (!Cache::getConfig(static::$cacheConfig)) { Cache::setConfig(static::$cacheConfig, [ 'className' => $this->_getDefaultCacheConfigClassName(), 'prefix' => static::$cacheConfig . '_' . $this->_identifier, 'duration' => $this->getConfig('interval'), ]); } }
php
protected function _initCache() { if (!Cache::getConfig(static::$cacheConfig)) { Cache::setConfig(static::$cacheConfig, [ 'className' => $this->_getDefaultCacheConfigClassName(), 'prefix' => static::$cacheConfig . '_' . $this->_identifier, 'duration' => $this->getConfig('interval'), ]); } }
[ "protected", "function", "_initCache", "(", ")", "{", "if", "(", "!", "Cache", "::", "getConfig", "(", "static", "::", "$", "cacheConfig", ")", ")", "{", "Cache", "::", "setConfig", "(", "static", "::", "$", "cacheConfig", ",", "[", "'className'", "=>", "$", "this", "->", "_getDefaultCacheConfigClassName", "(", ")", ",", "'prefix'", "=>", "static", "::", "$", "cacheConfig", ".", "'_'", ".", "$", "this", "->", "_identifier", ",", "'duration'", "=>", "$", "this", "->", "getConfig", "(", "'interval'", ")", ",", "]", ")", ";", "}", "}" ]
Initializes cache configuration. @return void
[ "Initializes", "cache", "configuration", "." ]
9eef7ed2f23a44297df4580a4fcb76d804db6a81
https://github.com/UseMuffin/Throttle/blob/9eef7ed2f23a44297df4580a4fcb76d804db6a81/src/ThrottleTrait.php#L93-L102
train
UseMuffin/Throttle
src/ThrottleTrait.php
ThrottleTrait._touch
protected function _touch() { if (Cache::read($this->_identifier, static::$cacheConfig) === false) { Cache::write($this->_identifier, 0, static::$cacheConfig); Cache::write( $this->_getCacheExpirationKey(), strtotime($this->getConfig('interval'), time()), static::$cacheConfig ); } return Cache::increment($this->_identifier, 1, static::$cacheConfig); }
php
protected function _touch() { if (Cache::read($this->_identifier, static::$cacheConfig) === false) { Cache::write($this->_identifier, 0, static::$cacheConfig); Cache::write( $this->_getCacheExpirationKey(), strtotime($this->getConfig('interval'), time()), static::$cacheConfig ); } return Cache::increment($this->_identifier, 1, static::$cacheConfig); }
[ "protected", "function", "_touch", "(", ")", "{", "if", "(", "Cache", "::", "read", "(", "$", "this", "->", "_identifier", ",", "static", "::", "$", "cacheConfig", ")", "===", "false", ")", "{", "Cache", "::", "write", "(", "$", "this", "->", "_identifier", ",", "0", ",", "static", "::", "$", "cacheConfig", ")", ";", "Cache", "::", "write", "(", "$", "this", "->", "_getCacheExpirationKey", "(", ")", ",", "strtotime", "(", "$", "this", "->", "getConfig", "(", "'interval'", ")", ",", "time", "(", ")", ")", ",", "static", "::", "$", "cacheConfig", ")", ";", "}", "return", "Cache", "::", "increment", "(", "$", "this", "->", "_identifier", ",", "1", ",", "static", "::", "$", "cacheConfig", ")", ";", "}" ]
Atomically updates cache using default CakePHP increment offset 1. Please note that the cache key needs to be initialized to prevent increment() failing on 0. A separate cache key is created to store the interval expiration time in epoch. @return mixed
[ "Atomically", "updates", "cache", "using", "default", "CakePHP", "increment", "offset", "1", "." ]
9eef7ed2f23a44297df4580a4fcb76d804db6a81
https://github.com/UseMuffin/Throttle/blob/9eef7ed2f23a44297df4580a4fcb76d804db6a81/src/ThrottleTrait.php#L135-L147
train
UseMuffin/Throttle
src/ThrottleTrait.php
ThrottleTrait._setHeaders
protected function _setHeaders($response) { $headers = $this->getConfig('headers'); if (!is_array($headers)) { return $response; } return $response ->withHeader($headers['limit'], (string)$this->getConfig('limit')) ->withHeader($headers['remaining'], (string)$this->_getRemainingConnections()) ->withHeader( $headers['reset'], (string)Cache::read($this->_getCacheExpirationKey(), static::$cacheConfig) ); }
php
protected function _setHeaders($response) { $headers = $this->getConfig('headers'); if (!is_array($headers)) { return $response; } return $response ->withHeader($headers['limit'], (string)$this->getConfig('limit')) ->withHeader($headers['remaining'], (string)$this->_getRemainingConnections()) ->withHeader( $headers['reset'], (string)Cache::read($this->_getCacheExpirationKey(), static::$cacheConfig) ); }
[ "protected", "function", "_setHeaders", "(", "$", "response", ")", "{", "$", "headers", "=", "$", "this", "->", "getConfig", "(", "'headers'", ")", ";", "if", "(", "!", "is_array", "(", "$", "headers", ")", ")", "{", "return", "$", "response", ";", "}", "return", "$", "response", "->", "withHeader", "(", "$", "headers", "[", "'limit'", "]", ",", "(", "string", ")", "$", "this", "->", "getConfig", "(", "'limit'", ")", ")", "->", "withHeader", "(", "$", "headers", "[", "'remaining'", "]", ",", "(", "string", ")", "$", "this", "->", "_getRemainingConnections", "(", ")", ")", "->", "withHeader", "(", "$", "headers", "[", "'reset'", "]", ",", "(", "string", ")", "Cache", "::", "read", "(", "$", "this", "->", "_getCacheExpirationKey", "(", ")", ",", "static", "::", "$", "cacheConfig", ")", ")", ";", "}" ]
Extends response with X-headers containing rate limiting information. @param \Psr\Http\Message\ResponseInterface|\Cake\Network\Response $response ResponseInterface instance @return \Psr\Http\Message\ResponseInterface
[ "Extends", "response", "with", "X", "-", "headers", "containing", "rate", "limiting", "information", "." ]
9eef7ed2f23a44297df4580a4fcb76d804db6a81
https://github.com/UseMuffin/Throttle/blob/9eef7ed2f23a44297df4580a4fcb76d804db6a81/src/ThrottleTrait.php#L165-L180
train
auraphp/Aura.Html
src/Helper/Styles.php
Styles.style
protected function style($css, array $attr = null) { $attr = $this->fixInternalAttr($attr); $attr = $this->escaper->attr($attr); return "<style $attr>$css</style>"; }
php
protected function style($css, array $attr = null) { $attr = $this->fixInternalAttr($attr); $attr = $this->escaper->attr($attr); return "<style $attr>$css</style>"; }
[ "protected", "function", "style", "(", "$", "css", ",", "array", "$", "attr", "=", "null", ")", "{", "$", "attr", "=", "$", "this", "->", "fixInternalAttr", "(", "$", "attr", ")", ";", "$", "attr", "=", "$", "this", "->", "escaper", "->", "attr", "(", "$", "attr", ")", ";", "return", "\"<style $attr>$css</style>\"", ";", "}" ]
Returns a "style" tag @param mixed $css The source CSS @param array $attr The attributes for the tag @return string @access protected
[ "Returns", "a", "style", "tag" ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Styles.php#L88-L93
train
auraphp/Aura.Html
src/Helper/Styles.php
Styles.endInternal
public function endInternal() { $params = array_pop($this->capture); $css = ob_get_clean(); if (isset($params['cond'])) { return $this->addCondInternal( $params['cond'], $css, $params['attr'], $params['pos'] ); } return $this->addInternal( $css, $params['attr'], $params['pos'] ); }
php
public function endInternal() { $params = array_pop($this->capture); $css = ob_get_clean(); if (isset($params['cond'])) { return $this->addCondInternal( $params['cond'], $css, $params['attr'], $params['pos'] ); } return $this->addInternal( $css, $params['attr'], $params['pos'] ); }
[ "public", "function", "endInternal", "(", ")", "{", "$", "params", "=", "array_pop", "(", "$", "this", "->", "capture", ")", ";", "$", "css", "=", "ob_get_clean", "(", ")", ";", "if", "(", "isset", "(", "$", "params", "[", "'cond'", "]", ")", ")", "{", "return", "$", "this", "->", "addCondInternal", "(", "$", "params", "[", "'cond'", "]", ",", "$", "css", ",", "$", "params", "[", "'attr'", "]", ",", "$", "params", "[", "'pos'", "]", ")", ";", "}", "return", "$", "this", "->", "addInternal", "(", "$", "css", ",", "$", "params", "[", "'attr'", "]", ",", "$", "params", "[", "'pos'", "]", ")", ";", "}" ]
Ends buffering and retains output for the most-recent internal. @return self @access public
[ "Ends", "buffering", "and", "retains", "output", "for", "the", "most", "-", "recent", "internal", "." ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Styles.php#L188-L207
train
auraphp/Aura.Html
src/Helper/Styles.php
Styles.fixInternalAttr
protected function fixInternalAttr(array $attr = null) { $attr = (array) $attr; $base = array( 'type' => 'text/css', 'media' => 'screen', ); unset($attr['rel']); unset($attr['href']); return array_merge($base, (array) $attr); }
php
protected function fixInternalAttr(array $attr = null) { $attr = (array) $attr; $base = array( 'type' => 'text/css', 'media' => 'screen', ); unset($attr['rel']); unset($attr['href']); return array_merge($base, (array) $attr); }
[ "protected", "function", "fixInternalAttr", "(", "array", "$", "attr", "=", "null", ")", "{", "$", "attr", "=", "(", "array", ")", "$", "attr", ";", "$", "base", "=", "array", "(", "'type'", "=>", "'text/css'", ",", "'media'", "=>", "'screen'", ",", ")", ";", "unset", "(", "$", "attr", "[", "'rel'", "]", ")", ";", "unset", "(", "$", "attr", "[", "'href'", "]", ")", ";", "return", "array_merge", "(", "$", "base", ",", "(", "array", ")", "$", "attr", ")", ";", "}" ]
Fixes the attributes for the internal stylesheet. @param array $attr Additional attributes for the <style> tag. @return array @access protected
[ "Fixes", "the", "attributes", "for", "the", "internal", "stylesheet", "." ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Styles.php#L218-L231
train
auraphp/Aura.Html
src/Helper/Scripts.php
Scripts.addInternal
public function addInternal($script, $pos = 100, array $attr = array()) { $attr = $this->attr(null, $attr); $tag = "<script $attr>$script</script>"; $this->addElement($pos, $tag); return $this; }
php
public function addInternal($script, $pos = 100, array $attr = array()) { $attr = $this->attr(null, $attr); $tag = "<script $attr>$script</script>"; $this->addElement($pos, $tag); return $this; }
[ "public", "function", "addInternal", "(", "$", "script", ",", "$", "pos", "=", "100", ",", "array", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "attr", "=", "$", "this", "->", "attr", "(", "null", ",", "$", "attr", ")", ";", "$", "tag", "=", "\"<script $attr>$script</script>\"", ";", "$", "this", "->", "addElement", "(", "$", "pos", ",", "$", "tag", ")", ";", "return", "$", "this", ";", "}" ]
Adds internal script @param mixed $script The script @param int $pos The script position in the stack. @param array $attr The additional attributes @return self @access public
[ "Adds", "internal", "script" ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Scripts.php#L88-L94
train
auraphp/Aura.Html
src/Helper/Scripts.php
Scripts.addCondInternal
public function addCondInternal($cond, $script, $pos = 100, array $attr = array()) { $cond = $this->escaper->html($cond); $attr = $this->attr(null, $attr); $tag = "<!--[if $cond]><script $attr>$script</script><![endif]-->"; $this->addElement($pos, $tag); return $this; }
php
public function addCondInternal($cond, $script, $pos = 100, array $attr = array()) { $cond = $this->escaper->html($cond); $attr = $this->attr(null, $attr); $tag = "<!--[if $cond]><script $attr>$script</script><![endif]-->"; $this->addElement($pos, $tag); return $this; }
[ "public", "function", "addCondInternal", "(", "$", "cond", ",", "$", "script", ",", "$", "pos", "=", "100", ",", "array", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "cond", "=", "$", "this", "->", "escaper", "->", "html", "(", "$", "cond", ")", ";", "$", "attr", "=", "$", "this", "->", "attr", "(", "null", ",", "$", "attr", ")", ";", "$", "tag", "=", "\"<!--[if $cond]><script $attr>$script</script><![endif]-->\"", ";", "$", "this", "->", "addElement", "(", "$", "pos", ",", "$", "tag", ")", ";", "return", "$", "this", ";", "}" ]
Add Conditional internal script @param mixed $cond The conditional expression for the script. @param mixed $script The script @param int $pos The script position in the stack. @param array $attr The additional attributes @return self @access public
[ "Add", "Conditional", "internal", "script" ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Scripts.php#L108-L116
train
auraphp/Aura.Html
src/Helper/Scripts.php
Scripts.beginCondInternal
public function beginCondInternal($cond, $pos = 100, array $attr = array()) { $this->capture[] = array($cond, $pos, $attr); ob_start(); }
php
public function beginCondInternal($cond, $pos = 100, array $attr = array()) { $this->capture[] = array($cond, $pos, $attr); ob_start(); }
[ "public", "function", "beginCondInternal", "(", "$", "cond", ",", "$", "pos", "=", "100", ",", "array", "$", "attr", "=", "array", "(", ")", ")", "{", "$", "this", "->", "capture", "[", "]", "=", "array", "(", "$", "cond", ",", "$", "pos", ",", "$", "attr", ")", ";", "ob_start", "(", ")", ";", "}" ]
Begin Conditional Internal Capture @param mixed $cond condition @param int $pos position @param array $attr The additional attributes @return null @access public
[ "Begin", "Conditional", "Internal", "Capture" ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Scripts.php#L146-L150
train
auraphp/Aura.Html
src/Helper/Scripts.php
Scripts.endInternal
public function endInternal() { $script = ob_get_clean(); $params = array_pop($this->capture); if (count($params) > 2) { return $this->addCondInternal( $params[0], $script, $params[1], $params[2] ); } return $this->addInternal($script, $params[0], $params[1]); }
php
public function endInternal() { $script = ob_get_clean(); $params = array_pop($this->capture); if (count($params) > 2) { return $this->addCondInternal( $params[0], $script, $params[1], $params[2] ); } return $this->addInternal($script, $params[0], $params[1]); }
[ "public", "function", "endInternal", "(", ")", "{", "$", "script", "=", "ob_get_clean", "(", ")", ";", "$", "params", "=", "array_pop", "(", "$", "this", "->", "capture", ")", ";", "if", "(", "count", "(", "$", "params", ")", ">", "2", ")", "{", "return", "$", "this", "->", "addCondInternal", "(", "$", "params", "[", "0", "]", ",", "$", "script", ",", "$", "params", "[", "1", "]", ",", "$", "params", "[", "2", "]", ")", ";", "}", "return", "$", "this", "->", "addInternal", "(", "$", "script", ",", "$", "params", "[", "0", "]", ",", "$", "params", "[", "1", "]", ")", ";", "}" ]
End internal script capture @return mixed @access public
[ "End", "internal", "script", "capture" ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Scripts.php#L159-L172
train
auraphp/Aura.Html
src/Helper/Scripts.php
Scripts.attr
protected function attr($src = null, array $attr = array()) { if (null !== $src) { $attr['src'] = $src; } $attr['type'] = 'text/javascript'; return $this->escaper->attr($attr); }
php
protected function attr($src = null, array $attr = array()) { if (null !== $src) { $attr['src'] = $src; } $attr['type'] = 'text/javascript'; return $this->escaper->attr($attr); }
[ "protected", "function", "attr", "(", "$", "src", "=", "null", ",", "array", "$", "attr", "=", "array", "(", ")", ")", "{", "if", "(", "null", "!==", "$", "src", ")", "{", "$", "attr", "[", "'src'", "]", "=", "$", "src", ";", "}", "$", "attr", "[", "'type'", "]", "=", "'text/javascript'", ";", "return", "$", "this", "->", "escaper", "->", "attr", "(", "$", "attr", ")", ";", "}" ]
Fix and escape script attributes @param mixed $src script source @param array $attr additional attributes @return string @access protected
[ "Fix", "and", "escape", "script", "attributes" ]
eda14b491f45fe2e1d1fec3364b1c783d7b7da31
https://github.com/auraphp/Aura.Html/blob/eda14b491f45fe2e1d1fec3364b1c783d7b7da31/src/Helper/Scripts.php#L184-L191
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ResponsiveContext.php
ResponsiveContext.getDeviceResolution
protected function getDeviceResolution($name) { Assert::keyExists($this->devices, $name, "Device '{$name}' not found."); $service = $this->getContainer()->get('drupal.behat.component.resolution'); $service->parse($this->devices[$name]); return $service; }
php
protected function getDeviceResolution($name) { Assert::keyExists($this->devices, $name, "Device '{$name}' not found."); $service = $this->getContainer()->get('drupal.behat.component.resolution'); $service->parse($this->devices[$name]); return $service; }
[ "protected", "function", "getDeviceResolution", "(", "$", "name", ")", "{", "Assert", "::", "keyExists", "(", "$", "this", "->", "devices", ",", "$", "name", ",", "\"Device '{$name}' not found.\"", ")", ";", "$", "service", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'drupal.behat.component.resolution'", ")", ";", "$", "service", "->", "parse", "(", "$", "this", "->", "devices", "[", "$", "name", "]", ")", ";", "return", "$", "service", ";", "}" ]
Get device resolution. @param string $name Device name. @return \NuvoleWeb\Drupal\DrupalExtension\Component\ResolutionComponent Resolution object.
[ "Get", "device", "resolution", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ResponsiveContext.php#L55-L60
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ResponsiveContext.php
ResponsiveContext.assertDeviceScreenResize
public function assertDeviceScreenResize($device) { $resolution = $this->getDeviceResolution($device); $this->getSession()->resizeWindow((int) $resolution->getWidth(), (int) $resolution->getHeight(), 'current'); }
php
public function assertDeviceScreenResize($device) { $resolution = $this->getDeviceResolution($device); $this->getSession()->resizeWindow((int) $resolution->getWidth(), (int) $resolution->getHeight(), 'current'); }
[ "public", "function", "assertDeviceScreenResize", "(", "$", "device", ")", "{", "$", "resolution", "=", "$", "this", "->", "getDeviceResolution", "(", "$", "device", ")", ";", "$", "this", "->", "getSession", "(", ")", "->", "resizeWindow", "(", "(", "int", ")", "$", "resolution", "->", "getWidth", "(", ")", ",", "(", "int", ")", "$", "resolution", "->", "getHeight", "(", ")", ",", "'current'", ")", ";", "}" ]
Resize browser window according to the specified device. @param string $device Device name as specified in behat.yml. @Given I view the site on a :device device
[ "Resize", "browser", "window", "according", "to", "the", "specified", "device", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ResponsiveContext.php#L70-L73
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ResponsiveContext.php
ResponsiveContext.assertBrowserWindowWidth
public function assertBrowserWindowWidth($size) { $actual = $this->getSession()->evaluateScript('return window.innerWidth;'); if ($actual != $size) { throw new ExpectationException("Browser window width expected to be {$size} but it is {$actual} instead.", $this->getSession()); } }
php
public function assertBrowserWindowWidth($size) { $actual = $this->getSession()->evaluateScript('return window.innerWidth;'); if ($actual != $size) { throw new ExpectationException("Browser window width expected to be {$size} but it is {$actual} instead.", $this->getSession()); } }
[ "public", "function", "assertBrowserWindowWidth", "(", "$", "size", ")", "{", "$", "actual", "=", "$", "this", "->", "getSession", "(", ")", "->", "evaluateScript", "(", "'return window.innerWidth;'", ")", ";", "if", "(", "$", "actual", "!=", "$", "size", ")", "{", "throw", "new", "ExpectationException", "(", "\"Browser window width expected to be {$size} but it is {$actual} instead.\"", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}" ]
Resize browser window width. @param string $size Size in pixel. @throws \Behat\Mink\Exception\ExpectationException @Then the browser window width should be :size
[ "Resize", "browser", "window", "width", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ResponsiveContext.php#L85-L90
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ResponsiveContext.php
ResponsiveContext.assertBrowserWindowHeight
public function assertBrowserWindowHeight($size) { $actual = $this->getSession()->evaluateScript('return window.outerHeight;'); if ($actual != $size) { throw new ExpectationException("Browser window height expected to be {$size} but it is {$actual} instead.", $this->getSession()); } }
php
public function assertBrowserWindowHeight($size) { $actual = $this->getSession()->evaluateScript('return window.outerHeight;'); if ($actual != $size) { throw new ExpectationException("Browser window height expected to be {$size} but it is {$actual} instead.", $this->getSession()); } }
[ "public", "function", "assertBrowserWindowHeight", "(", "$", "size", ")", "{", "$", "actual", "=", "$", "this", "->", "getSession", "(", ")", "->", "evaluateScript", "(", "'return window.outerHeight;'", ")", ";", "if", "(", "$", "actual", "!=", "$", "size", ")", "{", "throw", "new", "ExpectationException", "(", "\"Browser window height expected to be {$size} but it is {$actual} instead.\"", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}" ]
Resize browser window height. @param string $size Size in pixel. @throws \Behat\Mink\Exception\ExpectationException @Then the browser window height should be :size
[ "Resize", "browser", "window", "height", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ResponsiveContext.php#L102-L107
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ScreenShotContext.php
ScreenShotContext.takeScreenshot
public function takeScreenshot($name = NULL) { $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $name; $message = "Screenshot created in @file_name"; $this->createScreenshot($file_name, $message, FALSE); }
php
public function takeScreenshot($name = NULL) { $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . $name; $message = "Screenshot created in @file_name"; $this->createScreenshot($file_name, $message, FALSE); }
[ "public", "function", "takeScreenshot", "(", "$", "name", "=", "NULL", ")", "{", "$", "file_name", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "$", "name", ";", "$", "message", "=", "\"Screenshot created in @file_name\"", ";", "$", "this", "->", "createScreenshot", "(", "$", "file_name", ",", "$", "message", ",", "FALSE", ")", ";", "}" ]
Save screenshot with a specific name. @Then (I )take a screenshot :name
[ "Save", "screenshot", "with", "a", "specific", "name", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ScreenShotContext.php#L22-L26
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ScreenShotContext.php
ScreenShotContext.screenshotForPhpNotices
public function screenshotForPhpNotices(AfterStepScope $event) { $environment = $event->getEnvironment(); // Make sure the environment has the MessageContext. $class = 'Drupal\DrupalExtension\Context\MessageContext'; if ($environment instanceof InitializedContextEnvironment && $environment->hasContextClass($class)) { /** @var \Drupal\DrupalExtension\Context\MessageContext $context */ $context = $environment->getContext($class); // Only check if the session is started. try { if ($context->getMink()->isSessionStarted()) { try { $context->assertNotWarningMessage('Notice:'); } catch (\Exception $e) { // Use the step test in the filename. $step = $event->getStep(); if (function_exists('transliteration_clean_filename')) { $file_name = transliteration_clean_filename($step->getKeyword() . '_' . $step->getText()); } else { $file_name = str_replace(' ', '_', $step->getKeyword() . '_' . $step->getText()); $file_name = preg_replace('![^0-9A-Za-z_.-]!', '', $file_name); } $file_name = substr($file_name, 0, 30); $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-notice__' . $file_name; $message = "Screenshot for behat notice in step created in @file_name"; $this->createScreenshot($file_name, $message); // We don't throw $e any more because we don't fail on the notice. } } } catch (DriverException $driver_exception) { } } }
php
public function screenshotForPhpNotices(AfterStepScope $event) { $environment = $event->getEnvironment(); // Make sure the environment has the MessageContext. $class = 'Drupal\DrupalExtension\Context\MessageContext'; if ($environment instanceof InitializedContextEnvironment && $environment->hasContextClass($class)) { /** @var \Drupal\DrupalExtension\Context\MessageContext $context */ $context = $environment->getContext($class); // Only check if the session is started. try { if ($context->getMink()->isSessionStarted()) { try { $context->assertNotWarningMessage('Notice:'); } catch (\Exception $e) { // Use the step test in the filename. $step = $event->getStep(); if (function_exists('transliteration_clean_filename')) { $file_name = transliteration_clean_filename($step->getKeyword() . '_' . $step->getText()); } else { $file_name = str_replace(' ', '_', $step->getKeyword() . '_' . $step->getText()); $file_name = preg_replace('![^0-9A-Za-z_.-]!', '', $file_name); } $file_name = substr($file_name, 0, 30); $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-notice__' . $file_name; $message = "Screenshot for behat notice in step created in @file_name"; $this->createScreenshot($file_name, $message); // We don't throw $e any more because we don't fail on the notice. } } } catch (DriverException $driver_exception) { } } }
[ "public", "function", "screenshotForPhpNotices", "(", "AfterStepScope", "$", "event", ")", "{", "$", "environment", "=", "$", "event", "->", "getEnvironment", "(", ")", ";", "// Make sure the environment has the MessageContext.", "$", "class", "=", "'Drupal\\DrupalExtension\\Context\\MessageContext'", ";", "if", "(", "$", "environment", "instanceof", "InitializedContextEnvironment", "&&", "$", "environment", "->", "hasContextClass", "(", "$", "class", ")", ")", "{", "/** @var \\Drupal\\DrupalExtension\\Context\\MessageContext $context */", "$", "context", "=", "$", "environment", "->", "getContext", "(", "$", "class", ")", ";", "// Only check if the session is started.", "try", "{", "if", "(", "$", "context", "->", "getMink", "(", ")", "->", "isSessionStarted", "(", ")", ")", "{", "try", "{", "$", "context", "->", "assertNotWarningMessage", "(", "'Notice:'", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "// Use the step test in the filename.", "$", "step", "=", "$", "event", "->", "getStep", "(", ")", ";", "if", "(", "function_exists", "(", "'transliteration_clean_filename'", ")", ")", "{", "$", "file_name", "=", "transliteration_clean_filename", "(", "$", "step", "->", "getKeyword", "(", ")", ".", "'_'", ".", "$", "step", "->", "getText", "(", ")", ")", ";", "}", "else", "{", "$", "file_name", "=", "str_replace", "(", "' '", ",", "'_'", ",", "$", "step", "->", "getKeyword", "(", ")", ".", "'_'", ".", "$", "step", "->", "getText", "(", ")", ")", ";", "$", "file_name", "=", "preg_replace", "(", "'![^0-9A-Za-z_.-]!'", ",", "''", ",", "$", "file_name", ")", ";", "}", "$", "file_name", "=", "substr", "(", "$", "file_name", ",", "0", ",", "30", ")", ";", "$", "file_name", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'behat-notice__'", ".", "$", "file_name", ";", "$", "message", "=", "\"Screenshot for behat notice in step created in @file_name\"", ";", "$", "this", "->", "createScreenshot", "(", "$", "file_name", ",", "$", "message", ")", ";", "// We don't throw $e any more because we don't fail on the notice.", "}", "}", "}", "catch", "(", "DriverException", "$", "driver_exception", ")", "{", "}", "}", "}" ]
Make sure there is no PHP notice on the screen during tests. @AfterStep
[ "Make", "sure", "there", "is", "no", "PHP", "notice", "on", "the", "screen", "during", "tests", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ScreenShotContext.php#L44-L79
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ScreenShotContext.php
ScreenShotContext.takeScreenshotAfterFailedStep
public function takeScreenshotAfterFailedStep(AfterStepScope $event) { if ($event->getTestResult()->isPassed()) { // Not a failed step. return; } try { $step = $event->getStep(); if (function_exists('transliteration_clean_filename')) { $file_name = transliteration_clean_filename($step->getKeyword() . '_' . $step->getText()); } else { $file_name = str_replace(' ', '_', $step->getKeyword() . '_' . $step->getText()); $file_name = preg_replace('![^0-9A-Za-z_.-]!', '', $file_name); } $file_name = substr($file_name, 0, 30); $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-failed__' . $file_name; $message = "Screenshot for failed step created in @file_name"; $this->createScreenshot($file_name, $message); } catch (DriverException $e) { } }
php
public function takeScreenshotAfterFailedStep(AfterStepScope $event) { if ($event->getTestResult()->isPassed()) { // Not a failed step. return; } try { $step = $event->getStep(); if (function_exists('transliteration_clean_filename')) { $file_name = transliteration_clean_filename($step->getKeyword() . '_' . $step->getText()); } else { $file_name = str_replace(' ', '_', $step->getKeyword() . '_' . $step->getText()); $file_name = preg_replace('![^0-9A-Za-z_.-]!', '', $file_name); } $file_name = substr($file_name, 0, 30); $file_name = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'behat-failed__' . $file_name; $message = "Screenshot for failed step created in @file_name"; $this->createScreenshot($file_name, $message); } catch (DriverException $e) { } }
[ "public", "function", "takeScreenshotAfterFailedStep", "(", "AfterStepScope", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getTestResult", "(", ")", "->", "isPassed", "(", ")", ")", "{", "// Not a failed step.", "return", ";", "}", "try", "{", "$", "step", "=", "$", "event", "->", "getStep", "(", ")", ";", "if", "(", "function_exists", "(", "'transliteration_clean_filename'", ")", ")", "{", "$", "file_name", "=", "transliteration_clean_filename", "(", "$", "step", "->", "getKeyword", "(", ")", ".", "'_'", ".", "$", "step", "->", "getText", "(", ")", ")", ";", "}", "else", "{", "$", "file_name", "=", "str_replace", "(", "' '", ",", "'_'", ",", "$", "step", "->", "getKeyword", "(", ")", ".", "'_'", ".", "$", "step", "->", "getText", "(", ")", ")", ";", "$", "file_name", "=", "preg_replace", "(", "'![^0-9A-Za-z_.-]!'", ",", "''", ",", "$", "file_name", ")", ";", "}", "$", "file_name", "=", "substr", "(", "$", "file_name", ",", "0", ",", "30", ")", ";", "$", "file_name", "=", "sys_get_temp_dir", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "'behat-failed__'", ".", "$", "file_name", ";", "$", "message", "=", "\"Screenshot for failed step created in @file_name\"", ";", "$", "this", "->", "createScreenshot", "(", "$", "file_name", ",", "$", "message", ")", ";", "}", "catch", "(", "DriverException", "$", "e", ")", "{", "}", "}" ]
Take a screenshot after failed steps or save the HTML for non js drivers. @AfterStep
[ "Take", "a", "screenshot", "after", "failed", "steps", "or", "save", "the", "HTML", "for", "non", "js", "drivers", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ScreenShotContext.php#L86-L108
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ScreenShotContext.php
ScreenShotContext.createScreenshot
public function createScreenshot($file_name, $message, $ext = TRUE) { if ($this->getSession()->getDriver() instanceof Selenium2Driver) { if ($ext) { $file_name .= '.png'; } $screenshot = $this->getSession()->getDriver()->getScreenshot(); file_put_contents($file_name, $screenshot); } else { if ($ext) { $file_name .= '.html'; } $html_data = $this->getSession()->getDriver()->getContent(); file_put_contents($file_name, $html_data); } if ($message) { print strtr($message, ['@file_name' => $file_name]); } }
php
public function createScreenshot($file_name, $message, $ext = TRUE) { if ($this->getSession()->getDriver() instanceof Selenium2Driver) { if ($ext) { $file_name .= '.png'; } $screenshot = $this->getSession()->getDriver()->getScreenshot(); file_put_contents($file_name, $screenshot); } else { if ($ext) { $file_name .= '.html'; } $html_data = $this->getSession()->getDriver()->getContent(); file_put_contents($file_name, $html_data); } if ($message) { print strtr($message, ['@file_name' => $file_name]); } }
[ "public", "function", "createScreenshot", "(", "$", "file_name", ",", "$", "message", ",", "$", "ext", "=", "TRUE", ")", "{", "if", "(", "$", "this", "->", "getSession", "(", ")", "->", "getDriver", "(", ")", "instanceof", "Selenium2Driver", ")", "{", "if", "(", "$", "ext", ")", "{", "$", "file_name", ".=", "'.png'", ";", "}", "$", "screenshot", "=", "$", "this", "->", "getSession", "(", ")", "->", "getDriver", "(", ")", "->", "getScreenshot", "(", ")", ";", "file_put_contents", "(", "$", "file_name", ",", "$", "screenshot", ")", ";", "}", "else", "{", "if", "(", "$", "ext", ")", "{", "$", "file_name", ".=", "'.html'", ";", "}", "$", "html_data", "=", "$", "this", "->", "getSession", "(", ")", "->", "getDriver", "(", ")", "->", "getContent", "(", ")", ";", "file_put_contents", "(", "$", "file_name", ",", "$", "html_data", ")", ";", "}", "if", "(", "$", "message", ")", "{", "print", "strtr", "(", "$", "message", ",", "[", "'@file_name'", "=>", "$", "file_name", "]", ")", ";", "}", "}" ]
Create a screenshot or save the html. @param string $file_name The filename of the screenshot (complete). @param string $message The message to be printed. @file_name will be replaced with $file name. @param bool|true $ext Whether to add .png or .html to the name of the screenshot.
[ "Create", "a", "screenshot", "or", "save", "the", "html", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ScreenShotContext.php#L120-L138
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ChosenFieldContext.php
ChosenFieldContext.iSetChosenElement
public function iSetChosenElement($locator, $value) { $session = $this->getSession(); $el = $session->getPage()->findField($locator); if (empty($el)) { throw new ExpectationException('No such select element ' . $locator, $session); } $element_id = str_replace('-', '_', $el->getAttribute('id')) . '_chosen'; $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']"); if ($el->hasClass('chosen-container-single')) { // This is a single select element. $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']/a[@class='chosen-single']"); $el->click(); } elseif ($el->hasClass('chosen-container-multi')) { // This is a multi select element. $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']/ul[@class='chosen-choices']/li[@class='search-field']/input"); $el->click(); } $selector = "//div[@id='{$element_id}']/div[@class='chosen-drop']/ul[@class='chosen-results']/li[text() = '{$value}']"; $el = $session->getPage()->find('xpath', $selector); if (empty($el)) { throw new ExpectationException('No such option ' . $value . ' in ' . $locator, $session); } $el->click(); }
php
public function iSetChosenElement($locator, $value) { $session = $this->getSession(); $el = $session->getPage()->findField($locator); if (empty($el)) { throw new ExpectationException('No such select element ' . $locator, $session); } $element_id = str_replace('-', '_', $el->getAttribute('id')) . '_chosen'; $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']"); if ($el->hasClass('chosen-container-single')) { // This is a single select element. $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']/a[@class='chosen-single']"); $el->click(); } elseif ($el->hasClass('chosen-container-multi')) { // This is a multi select element. $el = $session->getPage()->find('xpath', "//div[@id='{$element_id}']/ul[@class='chosen-choices']/li[@class='search-field']/input"); $el->click(); } $selector = "//div[@id='{$element_id}']/div[@class='chosen-drop']/ul[@class='chosen-results']/li[text() = '{$value}']"; $el = $session->getPage()->find('xpath', $selector); if (empty($el)) { throw new ExpectationException('No such option ' . $value . ' in ' . $locator, $session); } $el->click(); }
[ "public", "function", "iSetChosenElement", "(", "$", "locator", ",", "$", "value", ")", "{", "$", "session", "=", "$", "this", "->", "getSession", "(", ")", ";", "$", "el", "=", "$", "session", "->", "getPage", "(", ")", "->", "findField", "(", "$", "locator", ")", ";", "if", "(", "empty", "(", "$", "el", ")", ")", "{", "throw", "new", "ExpectationException", "(", "'No such select element '", ".", "$", "locator", ",", "$", "session", ")", ";", "}", "$", "element_id", "=", "str_replace", "(", "'-'", ",", "'_'", ",", "$", "el", "->", "getAttribute", "(", "'id'", ")", ")", ".", "'_chosen'", ";", "$", "el", "=", "$", "session", "->", "getPage", "(", ")", "->", "find", "(", "'xpath'", ",", "\"//div[@id='{$element_id}']\"", ")", ";", "if", "(", "$", "el", "->", "hasClass", "(", "'chosen-container-single'", ")", ")", "{", "// This is a single select element.", "$", "el", "=", "$", "session", "->", "getPage", "(", ")", "->", "find", "(", "'xpath'", ",", "\"//div[@id='{$element_id}']/a[@class='chosen-single']\"", ")", ";", "$", "el", "->", "click", "(", ")", ";", "}", "elseif", "(", "$", "el", "->", "hasClass", "(", "'chosen-container-multi'", ")", ")", "{", "// This is a multi select element.", "$", "el", "=", "$", "session", "->", "getPage", "(", ")", "->", "find", "(", "'xpath'", ",", "\"//div[@id='{$element_id}']/ul[@class='chosen-choices']/li[@class='search-field']/input\"", ")", ";", "$", "el", "->", "click", "(", ")", ";", "}", "$", "selector", "=", "\"//div[@id='{$element_id}']/div[@class='chosen-drop']/ul[@class='chosen-results']/li[text() = '{$value}']\"", ";", "$", "el", "=", "$", "session", "->", "getPage", "(", ")", "->", "find", "(", "'xpath'", ",", "$", "selector", ")", ";", "if", "(", "empty", "(", "$", "el", ")", ")", "{", "throw", "new", "ExpectationException", "(", "'No such option '", ".", "$", "value", ".", "' in '", ".", "$", "locator", ",", "$", "session", ")", ";", "}", "$", "el", "->", "click", "(", ")", ";", "}" ]
This is from a patch which is very much work-in-progress. @link https://www.drupal.org/node/2562805. @When /^I set the chosen element "([^"]*)" to "([^"]*)"$/
[ "This", "is", "from", "a", "patch", "which", "is", "very", "much", "work", "-", "in", "-", "progress", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ChosenFieldContext.php#L54-L85
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/VisibilityContext.php
VisibilityContext.assertElementVisibility
public function assertElementVisibility($tag, $text) { $element = $this->getSession()->getPage(); /** @var \Behat\Mink\Element\NodeElement[] $nodes */ $nodes = $element->findAll('css', $tag); foreach ($nodes as $node) { if ($node->getText() === $text) { $this->assertElementVisible($text, $node); } } }
php
public function assertElementVisibility($tag, $text) { $element = $this->getSession()->getPage(); /** @var \Behat\Mink\Element\NodeElement[] $nodes */ $nodes = $element->findAll('css', $tag); foreach ($nodes as $node) { if ($node->getText() === $text) { $this->assertElementVisible($text, $node); } } }
[ "public", "function", "assertElementVisibility", "(", "$", "tag", ",", "$", "text", ")", "{", "$", "element", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "/** @var \\Behat\\Mink\\Element\\NodeElement[] $nodes */", "$", "nodes", "=", "$", "element", "->", "findAll", "(", "'css'", ",", "$", "tag", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "getText", "(", ")", "===", "$", "text", ")", "{", "$", "this", "->", "assertElementVisible", "(", "$", "text", ",", "$", "node", ")", ";", "}", "}", "}" ]
Assert presence of given element on the page. @Then the element :tag with text :text should be visible
[ "Assert", "presence", "of", "given", "element", "on", "the", "page", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/VisibilityContext.php#L21-L30
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/VisibilityContext.php
VisibilityContext.assertElementNonVisibility
public function assertElementNonVisibility($tag, $text) { $element = $this->getSession()->getPage(); /** @var \Behat\Mink\Element\NodeElement[] $nodes */ $nodes = $element->findAll('css', $tag); foreach ($nodes as $node) { if ($node->getText() === $text) { $this->assertElementNotVisible($text, $node); } } }
php
public function assertElementNonVisibility($tag, $text) { $element = $this->getSession()->getPage(); /** @var \Behat\Mink\Element\NodeElement[] $nodes */ $nodes = $element->findAll('css', $tag); foreach ($nodes as $node) { if ($node->getText() === $text) { $this->assertElementNotVisible($text, $node); } } }
[ "public", "function", "assertElementNonVisibility", "(", "$", "tag", ",", "$", "text", ")", "{", "$", "element", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "/** @var \\Behat\\Mink\\Element\\NodeElement[] $nodes */", "$", "nodes", "=", "$", "element", "->", "findAll", "(", "'css'", ",", "$", "tag", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "$", "node", "->", "getText", "(", ")", "===", "$", "text", ")", "{", "$", "this", "->", "assertElementNotVisible", "(", "$", "text", ",", "$", "node", ")", ";", "}", "}", "}" ]
Assert absence of given element on the page. @Then the element :tag with text :text should not be visible
[ "Assert", "absence", "of", "given", "element", "on", "the", "page", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/VisibilityContext.php#L37-L46
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/VisibilityContext.php
VisibilityContext.iShouldSeeTheField
public function iShouldSeeTheField($field) { $element = $this->getSession()->getPage(); $result = $element->findField($field); $this->assertElementVisible($field, $result); }
php
public function iShouldSeeTheField($field) { $element = $this->getSession()->getPage(); $result = $element->findField($field); $this->assertElementVisible($field, $result); }
[ "public", "function", "iShouldSeeTheField", "(", "$", "field", ")", "{", "$", "element", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "$", "result", "=", "$", "element", "->", "findField", "(", "$", "field", ")", ";", "$", "this", "->", "assertElementVisible", "(", "$", "field", ",", "$", "result", ")", ";", "}" ]
Assert presence of given field on the page. @Then I should see the field :field
[ "Assert", "presence", "of", "given", "field", "on", "the", "page", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/VisibilityContext.php#L53-L57
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/VisibilityContext.php
VisibilityContext.iShouldNotSeeTheField
public function iShouldNotSeeTheField($field) { $element = $this->getSession()->getPage(); $this->assertElementNotVisible($field, $element->findField($field)); }
php
public function iShouldNotSeeTheField($field) { $element = $this->getSession()->getPage(); $this->assertElementNotVisible($field, $element->findField($field)); }
[ "public", "function", "iShouldNotSeeTheField", "(", "$", "field", ")", "{", "$", "element", "=", "$", "this", "->", "getSession", "(", ")", "->", "getPage", "(", ")", ";", "$", "this", "->", "assertElementNotVisible", "(", "$", "field", ",", "$", "element", "->", "findField", "(", "$", "field", ")", ")", ";", "}" ]
Assert absence of given field. @Then I should not see the field :field
[ "Assert", "absence", "of", "given", "field", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/VisibilityContext.php#L64-L67
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/VisibilityContext.php
VisibilityContext.assertElementVisible
protected function assertElementVisible($element, NodeElement $node) { try { if ($node && !$node->isVisible()) { throw new ExpectationException(sprintf("The element '%s' is not present on the page %s", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } catch (UnsupportedDriverActionException $e) { // We catch the UnsupportedDriverActionException exception in case // this step is not being performed by a driver that supports javascript. // All other exceptions are valid. if (empty($node)) { throw new ExpectationException(sprintf("The element '%s' is not present on the page %s", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } }
php
protected function assertElementVisible($element, NodeElement $node) { try { if ($node && !$node->isVisible()) { throw new ExpectationException(sprintf("The element '%s' is not present on the page %s", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } catch (UnsupportedDriverActionException $e) { // We catch the UnsupportedDriverActionException exception in case // this step is not being performed by a driver that supports javascript. // All other exceptions are valid. if (empty($node)) { throw new ExpectationException(sprintf("The element '%s' is not present on the page %s", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } }
[ "protected", "function", "assertElementVisible", "(", "$", "element", ",", "NodeElement", "$", "node", ")", "{", "try", "{", "if", "(", "$", "node", "&&", "!", "$", "node", "->", "isVisible", "(", ")", ")", "{", "throw", "new", "ExpectationException", "(", "sprintf", "(", "\"The element '%s' is not present on the page %s\"", ",", "$", "element", ",", "$", "this", "->", "getSession", "(", ")", "->", "getCurrentUrl", "(", ")", ")", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}", "catch", "(", "UnsupportedDriverActionException", "$", "e", ")", "{", "// We catch the UnsupportedDriverActionException exception in case", "// this step is not being performed by a driver that supports javascript.", "// All other exceptions are valid.", "if", "(", "empty", "(", "$", "node", ")", ")", "{", "throw", "new", "ExpectationException", "(", "sprintf", "(", "\"The element '%s' is not present on the page %s\"", ",", "$", "element", ",", "$", "this", "->", "getSession", "(", ")", "->", "getCurrentUrl", "(", ")", ")", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}", "}" ]
Assert visibility of an element. @param string $element Element selector or a string that describes it. @param \Behat\Mink\Element\NodeElement $node Node representing the element above, if any. @throws \Behat\Mink\Exception\ExpectationException Throws exception if element not found.
[ "Assert", "visibility", "of", "an", "element", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/VisibilityContext.php#L80-L94
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/VisibilityContext.php
VisibilityContext.assertElementNotVisible
protected function assertElementNotVisible($element, NodeElement $node) { try { if ($node && $node->isVisible()) { throw new ExpectationException(sprintf("The field '%s' was present on the page %s and was not supposed to be", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } catch (UnsupportedDriverActionException $e) { // We catch the UnsupportedDriverActionException exception in case // this step is not being performed by a driver that supports javascript. // All other exceptions are valid. if ($node) { throw new ExpectationException(sprintf("The field '%s' was present on the page %s and was not supposed to be", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } }
php
protected function assertElementNotVisible($element, NodeElement $node) { try { if ($node && $node->isVisible()) { throw new ExpectationException(sprintf("The field '%s' was present on the page %s and was not supposed to be", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } catch (UnsupportedDriverActionException $e) { // We catch the UnsupportedDriverActionException exception in case // this step is not being performed by a driver that supports javascript. // All other exceptions are valid. if ($node) { throw new ExpectationException(sprintf("The field '%s' was present on the page %s and was not supposed to be", $element, $this->getSession()->getCurrentUrl()), $this->getSession()); } } }
[ "protected", "function", "assertElementNotVisible", "(", "$", "element", ",", "NodeElement", "$", "node", ")", "{", "try", "{", "if", "(", "$", "node", "&&", "$", "node", "->", "isVisible", "(", ")", ")", "{", "throw", "new", "ExpectationException", "(", "sprintf", "(", "\"The field '%s' was present on the page %s and was not supposed to be\"", ",", "$", "element", ",", "$", "this", "->", "getSession", "(", ")", "->", "getCurrentUrl", "(", ")", ")", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}", "catch", "(", "UnsupportedDriverActionException", "$", "e", ")", "{", "// We catch the UnsupportedDriverActionException exception in case", "// this step is not being performed by a driver that supports javascript.", "// All other exceptions are valid.", "if", "(", "$", "node", ")", "{", "throw", "new", "ExpectationException", "(", "sprintf", "(", "\"The field '%s' was present on the page %s and was not supposed to be\"", ",", "$", "element", ",", "$", "this", "->", "getSession", "(", ")", "->", "getCurrentUrl", "(", ")", ")", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}", "}" ]
Assert non visibility of an element. @param string $element Element selector or a string that describes it. @param \Behat\Mink\Element\NodeElement $node Node representing the element above, if any. @throws \Behat\Mink\Exception\ExpectationException Throws exception if element is found.
[ "Assert", "non", "visibility", "of", "an", "element", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/VisibilityContext.php#L107-L121
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Manager/Laravel.php
Laravel.get
public function get( $name ) { $key = $this->getConfig( $name ); if( is_string( $key ) ) { if( !isset( $this->objects[$key] ) ) { $this->objects[$key] = new \Aimeos\MW\Filesystem\Laravel( $this->fsm->disk( $key ), $this->tempdir ); } return $this->objects[$key]; } return parent::get( $name ); }
php
public function get( $name ) { $key = $this->getConfig( $name ); if( is_string( $key ) ) { if( !isset( $this->objects[$key] ) ) { $this->objects[$key] = new \Aimeos\MW\Filesystem\Laravel( $this->fsm->disk( $key ), $this->tempdir ); } return $this->objects[$key]; } return parent::get( $name ); }
[ "public", "function", "get", "(", "$", "name", ")", "{", "$", "key", "=", "$", "this", "->", "getConfig", "(", "$", "name", ")", ";", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "objects", "[", "$", "key", "]", ")", ")", "{", "$", "this", "->", "objects", "[", "$", "key", "]", "=", "new", "\\", "Aimeos", "\\", "MW", "\\", "Filesystem", "\\", "Laravel", "(", "$", "this", "->", "fsm", "->", "disk", "(", "$", "key", ")", ",", "$", "this", "->", "tempdir", ")", ";", "}", "return", "$", "this", "->", "objects", "[", "$", "key", "]", ";", "}", "return", "parent", "::", "get", "(", "$", "name", ")", ";", "}" ]
Returns the file system for the given name @param string $name Key for the file system @return \Aimeos\MW\Filesystem\Iface File system object @throws \Aimeos\MW\Filesystem\Exception If an no configuration for that name is found
[ "Returns", "the", "file", "system", "for", "the", "given", "name" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Manager/Laravel.php#L74-L88
train
aimeos/ai-laravel
lib/custom/src/MShop/Customer/Manager/Laravel.php
Laravel.getSearchAttributes
public function getSearchAttributes( $withsub = true ) { $path = 'mshop/customer/manager/submanagers'; return $this->getSearchAttributesBase( $this->searchConfig, $path, ['address'], $withsub ); }
php
public function getSearchAttributes( $withsub = true ) { $path = 'mshop/customer/manager/submanagers'; return $this->getSearchAttributesBase( $this->searchConfig, $path, ['address'], $withsub ); }
[ "public", "function", "getSearchAttributes", "(", "$", "withsub", "=", "true", ")", "{", "$", "path", "=", "'mshop/customer/manager/submanagers'", ";", "return", "$", "this", "->", "getSearchAttributesBase", "(", "$", "this", "->", "searchConfig", ",", "$", "path", ",", "[", "'address'", "]", ",", "$", "withsub", ")", ";", "}" ]
Returns the list attributes that can be used for searching. @param boolean $withsub Return also attributes of sub-managers if true @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
[ "Returns", "the", "list", "attributes", "that", "can", "be", "used", "for", "searching", "." ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MShop/Customer/Manager/Laravel.php#L350-L354
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ServiceContainerContext.php
ServiceContainerContext.resetParameters
public function resetParameters() { if (\Drupal::state()->get('nuvole_web.drupal_extension.parameter_overrides')) { \Drupal::state()->set('nuvole_web.drupal_extension.parameter_overrides', []); \Drupal::service('kernel')->rebuildContainer(); } }
php
public function resetParameters() { if (\Drupal::state()->get('nuvole_web.drupal_extension.parameter_overrides')) { \Drupal::state()->set('nuvole_web.drupal_extension.parameter_overrides', []); \Drupal::service('kernel')->rebuildContainer(); } }
[ "public", "function", "resetParameters", "(", ")", "{", "if", "(", "\\", "Drupal", "::", "state", "(", ")", "->", "get", "(", "'nuvole_web.drupal_extension.parameter_overrides'", ")", ")", "{", "\\", "Drupal", "::", "state", "(", ")", "->", "set", "(", "'nuvole_web.drupal_extension.parameter_overrides'", ",", "[", "]", ")", ";", "\\", "Drupal", "::", "service", "(", "'kernel'", ")", "->", "rebuildContainer", "(", ")", ";", "}", "}" ]
Rebuild container on after scenario. @AfterScenario
[ "Rebuild", "container", "on", "after", "scenario", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ServiceContainerContext.php#L31-L36
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ServiceContainerContext.php
ServiceContainerContext.assertParameters
public function assertParameters($name, $expected) { $value = \Drupal::getContainer()->getParameter($name); Assert::eq($value, $this->castParameter($expected)); }
php
public function assertParameters($name, $expected) { $value = \Drupal::getContainer()->getParameter($name); Assert::eq($value, $this->castParameter($expected)); }
[ "public", "function", "assertParameters", "(", "$", "name", ",", "$", "expected", ")", "{", "$", "value", "=", "\\", "Drupal", "::", "getContainer", "(", ")", "->", "getParameter", "(", "$", "name", ")", ";", "Assert", "::", "eq", "(", "$", "value", ",", "$", "this", "->", "castParameter", "(", "$", "expected", ")", ")", ";", "}" ]
Assert given service parameter has given value. @Then the service parameter :name should be set to :expected
[ "Assert", "given", "service", "parameter", "has", "given", "value", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ServiceContainerContext.php#L43-L46
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ServiceContainerContext.php
ServiceContainerContext.negateParameters
public function negateParameters($name, $expected) { try { $value = \Drupal::getContainer()->getParameter($name); Assert::notEq($value, $this->castParameter($expected)); } catch (ParameterNotFoundException $e) { } }
php
public function negateParameters($name, $expected) { try { $value = \Drupal::getContainer()->getParameter($name); Assert::notEq($value, $this->castParameter($expected)); } catch (ParameterNotFoundException $e) { } }
[ "public", "function", "negateParameters", "(", "$", "name", ",", "$", "expected", ")", "{", "try", "{", "$", "value", "=", "\\", "Drupal", "::", "getContainer", "(", ")", "->", "getParameter", "(", "$", "name", ")", ";", "Assert", "::", "notEq", "(", "$", "value", ",", "$", "this", "->", "castParameter", "(", "$", "expected", ")", ")", ";", "}", "catch", "(", "ParameterNotFoundException", "$", "e", ")", "{", "}", "}" ]
Assert given service parameter has not given value. @Then the service parameter :name should not be set to :expected
[ "Assert", "given", "service", "parameter", "has", "not", "given", "value", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ServiceContainerContext.php#L53-L60
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/ServiceContainerContext.php
ServiceContainerContext.overrideParameters
public function overrideParameters(array $parameters) { $this->setServiceProvider(); // Cast service parameters. foreach ($parameters as $name => $value) { $parameters[$name] = $this->castParameter($value); } \Drupal::state()->set('nuvole_web.drupal_extension.parameter_overrides', $parameters); \Drupal::service('kernel')->rebuildContainer(); }
php
public function overrideParameters(array $parameters) { $this->setServiceProvider(); // Cast service parameters. foreach ($parameters as $name => $value) { $parameters[$name] = $this->castParameter($value); } \Drupal::state()->set('nuvole_web.drupal_extension.parameter_overrides', $parameters); \Drupal::service('kernel')->rebuildContainer(); }
[ "public", "function", "overrideParameters", "(", "array", "$", "parameters", ")", "{", "$", "this", "->", "setServiceProvider", "(", ")", ";", "// Cast service parameters.", "foreach", "(", "$", "parameters", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "parameters", "[", "$", "name", "]", "=", "$", "this", "->", "castParameter", "(", "$", "value", ")", ";", "}", "\\", "Drupal", "::", "state", "(", ")", "->", "set", "(", "'nuvole_web.drupal_extension.parameter_overrides'", ",", "$", "parameters", ")", ";", "\\", "Drupal", "::", "service", "(", "'kernel'", ")", "->", "rebuildContainer", "(", ")", ";", "}" ]
Apply parameters overrides and rebuild container. @param array $parameters List of parameters to be overridden.
[ "Apply", "parameters", "overrides", "and", "rebuild", "container", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/ServiceContainerContext.php#L68-L78
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/RawMinkContext.php
RawMinkContext.assertElementType
public function assertElementType(NodeElement $element, $type) { if ($element->getTagName() !== $type) { throw new ExpectationException("The element is not a '$type'' field.", $this->getSession()); } }
php
public function assertElementType(NodeElement $element, $type) { if ($element->getTagName() !== $type) { throw new ExpectationException("The element is not a '$type'' field.", $this->getSession()); } }
[ "public", "function", "assertElementType", "(", "NodeElement", "$", "element", ",", "$", "type", ")", "{", "if", "(", "$", "element", "->", "getTagName", "(", ")", "!==", "$", "type", ")", "{", "throw", "new", "ExpectationException", "(", "\"The element is not a '$type'' field.\"", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}" ]
Checks that the given element is of the given type. @param \Behat\Mink\Element\NodeElement $element The element to check. @param string $type The expected type. @throws ExpectationException Thrown when the given element is not of the expected type.
[ "Checks", "that", "the", "given", "element", "is", "of", "the", "given", "type", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/RawMinkContext.php#L50-L54
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/MenuContext.php
MenuContext.assertMenuStructureForContent
public function assertMenuStructureForContent($menu_name, TableNode $table) { $menu_items = $table->getColumnsHash(); foreach ($menu_items as $key => $menu_item) { $node = $this->getCore()->loadNodeByName($menu_item['title']); $menu_items[$key]['uri'] = "entity:node/{$this->getCore()->getNodeId($node)}"; } try { $this->menuLinks = array_merge($this->menuLinks, $this->getCore()->createMenuStructure($menu_name, $menu_items)); } catch (\InvalidArgumentException $e) { throw new ExpectationException($e->getMessage(), $this->getSession()); } }
php
public function assertMenuStructureForContent($menu_name, TableNode $table) { $menu_items = $table->getColumnsHash(); foreach ($menu_items as $key => $menu_item) { $node = $this->getCore()->loadNodeByName($menu_item['title']); $menu_items[$key]['uri'] = "entity:node/{$this->getCore()->getNodeId($node)}"; } try { $this->menuLinks = array_merge($this->menuLinks, $this->getCore()->createMenuStructure($menu_name, $menu_items)); } catch (\InvalidArgumentException $e) { throw new ExpectationException($e->getMessage(), $this->getSession()); } }
[ "public", "function", "assertMenuStructureForContent", "(", "$", "menu_name", ",", "TableNode", "$", "table", ")", "{", "$", "menu_items", "=", "$", "table", "->", "getColumnsHash", "(", ")", ";", "foreach", "(", "$", "menu_items", "as", "$", "key", "=>", "$", "menu_item", ")", "{", "$", "node", "=", "$", "this", "->", "getCore", "(", ")", "->", "loadNodeByName", "(", "$", "menu_item", "[", "'title'", "]", ")", ";", "$", "menu_items", "[", "$", "key", "]", "[", "'uri'", "]", "=", "\"entity:node/{$this->getCore()->getNodeId($node)}\"", ";", "}", "try", "{", "$", "this", "->", "menuLinks", "=", "array_merge", "(", "$", "this", "->", "menuLinks", ",", "$", "this", "->", "getCore", "(", ")", "->", "createMenuStructure", "(", "$", "menu_name", ",", "$", "menu_items", ")", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "throw", "new", "ExpectationException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}" ]
Create menu structure for nodes. @param string $menu_name Menu machine name. @param \Behat\Gherkin\Node\TableNode $table Table representing the menu structure to be specified as follows: | title | parent | | Page 1 | | | Page 2 | Page 1 | | Page 3 | Page 2 |. @throws \Behat\Mink\Exception\ExpectationException Throws exception if menu not found. @Given the following :menu_name menu structure for content:
[ "Create", "menu", "structure", "for", "nodes", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/MenuContext.php#L41-L54
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/MenuContext.php
MenuContext.assertMenuStructure
public function assertMenuStructure($menu_name, TableNode $table) { try { $this->menuLinks = array_merge($this->menuLinks, $this->getCore()->createMenuStructure($menu_name, $table->getColumnsHash())); } catch (\InvalidArgumentException $e) { throw new ExpectationException($e->getMessage(), $this->getSession()); } }
php
public function assertMenuStructure($menu_name, TableNode $table) { try { $this->menuLinks = array_merge($this->menuLinks, $this->getCore()->createMenuStructure($menu_name, $table->getColumnsHash())); } catch (\InvalidArgumentException $e) { throw new ExpectationException($e->getMessage(), $this->getSession()); } }
[ "public", "function", "assertMenuStructure", "(", "$", "menu_name", ",", "TableNode", "$", "table", ")", "{", "try", "{", "$", "this", "->", "menuLinks", "=", "array_merge", "(", "$", "this", "->", "menuLinks", ",", "$", "this", "->", "getCore", "(", ")", "->", "createMenuStructure", "(", "$", "menu_name", ",", "$", "table", "->", "getColumnsHash", "(", ")", ")", ")", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "throw", "new", "ExpectationException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "this", "->", "getSession", "(", ")", ")", ";", "}", "}" ]
Create menu structure my adding menu links. @param string $menu_name Menu machine name. @param \Behat\Gherkin\Node\TableNode $table Table representing the menu structure to be specified as follows: | title | uri | parent | | Link 1 | internal:/ | | | Link 2 | internal:/ | Link 1 | | Link 3 | internal:/ | Link 1 |. @throws \Behat\Mink\Exception\ExpectationException Throws exception if menu not found. @Given the following :menu_name menu structure:
[ "Create", "menu", "structure", "my", "adding", "menu", "links", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/MenuContext.php#L73-L81
train
nuvoleweb/drupal-behat
src/DrupalExtension/Context/MenuContext.php
MenuContext.deleteMenuLinks
public function deleteMenuLinks(AfterScenarioScope $event) { if ($this->menuLinks) { foreach ($this->menuLinks as $menu_link) { $this->getCore()->entityDelete($menu_link); } $this->getCore()->clearMenuCache(); } }
php
public function deleteMenuLinks(AfterScenarioScope $event) { if ($this->menuLinks) { foreach ($this->menuLinks as $menu_link) { $this->getCore()->entityDelete($menu_link); } $this->getCore()->clearMenuCache(); } }
[ "public", "function", "deleteMenuLinks", "(", "AfterScenarioScope", "$", "event", ")", "{", "if", "(", "$", "this", "->", "menuLinks", ")", "{", "foreach", "(", "$", "this", "->", "menuLinks", "as", "$", "menu_link", ")", "{", "$", "this", "->", "getCore", "(", ")", "->", "entityDelete", "(", "$", "menu_link", ")", ";", "}", "$", "this", "->", "getCore", "(", ")", "->", "clearMenuCache", "(", ")", ";", "}", "}" ]
Assert clean Watchdog after every step. @param \Behat\Behat\Hook\Scope\AfterScenarioScope $event Event object. @AfterScenario
[ "Assert", "clean", "Watchdog", "after", "every", "step", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/DrupalExtension/Context/MenuContext.php#L91-L99
train
aimeos/ai-laravel
lib/custom/setup/CustomerChangeAddressRefidParentidLaravel.php
CustomerChangeAddressRefidParentidLaravel.process
protected function process( array $stmts ) { $table = 'users_address'; $this->msg( sprintf( 'Rename "refid" to "parentid" in table "%1$s"', $table ), 0 ); $this->status( '' ); foreach( $stmts as $column => $stmts ) { $this->msg( sprintf( 'Checking column "%1$s"', $column ), 1 ); if( $this->schema->tableExists( $table ) && $this->schema->columnExists( $table, $column ) === true ) { $this->executeList( $stmts ); $this->status( 'done' ); } else { $this->status( 'OK' ); } } }
php
protected function process( array $stmts ) { $table = 'users_address'; $this->msg( sprintf( 'Rename "refid" to "parentid" in table "%1$s"', $table ), 0 ); $this->status( '' ); foreach( $stmts as $column => $stmts ) { $this->msg( sprintf( 'Checking column "%1$s"', $column ), 1 ); if( $this->schema->tableExists( $table ) && $this->schema->columnExists( $table, $column ) === true ) { $this->executeList( $stmts ); $this->status( 'done' ); } else { $this->status( 'OK' ); } } }
[ "protected", "function", "process", "(", "array", "$", "stmts", ")", "{", "$", "table", "=", "'users_address'", ";", "$", "this", "->", "msg", "(", "sprintf", "(", "'Rename \"refid\" to \"parentid\" in table \"%1$s\"'", ",", "$", "table", ")", ",", "0", ")", ";", "$", "this", "->", "status", "(", "''", ")", ";", "foreach", "(", "$", "stmts", "as", "$", "column", "=>", "$", "stmts", ")", "{", "$", "this", "->", "msg", "(", "sprintf", "(", "'Checking column \"%1$s\"'", ",", "$", "column", ")", ",", "1", ")", ";", "if", "(", "$", "this", "->", "schema", "->", "tableExists", "(", "$", "table", ")", "&&", "$", "this", "->", "schema", "->", "columnExists", "(", "$", "table", ",", "$", "column", ")", "===", "true", ")", "{", "$", "this", "->", "executeList", "(", "$", "stmts", ")", ";", "$", "this", "->", "status", "(", "'done'", ")", ";", "}", "else", "{", "$", "this", "->", "status", "(", "'OK'", ")", ";", "}", "}", "}" ]
Changes the column in table array string $stmts List of SQL statements for changing the columns
[ "Changes", "the", "column", "in", "table" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/setup/CustomerChangeAddressRefidParentidLaravel.php#L50-L68
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/BynderApi.php
BynderApi.create
public static function create($settings) { if (isset($settings) && ($settings = self::validateSettings($settings))) { $credentials = new Credentials( $settings['consumerKey'], $settings['consumerSecret'], $settings['token'], $settings['tokenSecret'] ); $stack = HandlerStack::create(new CurlHandler()); $stack->push( new Oauth1([ 'consumer_key' => $credentials->getConsumerKey(), 'consumer_secret' => $credentials->getConsumerSecret(), 'token' => $credentials->getToken(), 'token_secret' => $credentials->getTokenSecret(), 'request_method' => Oauth1::REQUEST_METHOD_HEADER, 'signature_method' => Oauth1::SIGNATURE_METHOD_HMAC ]) ); $requestOptions = [ 'base_uri' => $settings['baseUrl'], 'handler' => $stack, 'auth' => 'oauth', ]; // Configures request Client (adding proxy, etc.) if (isset($settings['requestOptions']) && is_array($settings['requestOptions'])) { $requestOptions += $settings['requestOptions']; } $requestClient = new Client($requestOptions); $requestHandler = OauthRequestHandler::create($credentials, $settings['baseUrl'], $requestClient); return new BynderApi($settings['baseUrl'], $requestHandler); } else { throw new InvalidArgumentException("Settings passed for BynderApi service creation are not valid."); } }
php
public static function create($settings) { if (isset($settings) && ($settings = self::validateSettings($settings))) { $credentials = new Credentials( $settings['consumerKey'], $settings['consumerSecret'], $settings['token'], $settings['tokenSecret'] ); $stack = HandlerStack::create(new CurlHandler()); $stack->push( new Oauth1([ 'consumer_key' => $credentials->getConsumerKey(), 'consumer_secret' => $credentials->getConsumerSecret(), 'token' => $credentials->getToken(), 'token_secret' => $credentials->getTokenSecret(), 'request_method' => Oauth1::REQUEST_METHOD_HEADER, 'signature_method' => Oauth1::SIGNATURE_METHOD_HMAC ]) ); $requestOptions = [ 'base_uri' => $settings['baseUrl'], 'handler' => $stack, 'auth' => 'oauth', ]; // Configures request Client (adding proxy, etc.) if (isset($settings['requestOptions']) && is_array($settings['requestOptions'])) { $requestOptions += $settings['requestOptions']; } $requestClient = new Client($requestOptions); $requestHandler = OauthRequestHandler::create($credentials, $settings['baseUrl'], $requestClient); return new BynderApi($settings['baseUrl'], $requestHandler); } else { throw new InvalidArgumentException("Settings passed for BynderApi service creation are not valid."); } }
[ "public", "static", "function", "create", "(", "$", "settings", ")", "{", "if", "(", "isset", "(", "$", "settings", ")", "&&", "(", "$", "settings", "=", "self", "::", "validateSettings", "(", "$", "settings", ")", ")", ")", "{", "$", "credentials", "=", "new", "Credentials", "(", "$", "settings", "[", "'consumerKey'", "]", ",", "$", "settings", "[", "'consumerSecret'", "]", ",", "$", "settings", "[", "'token'", "]", ",", "$", "settings", "[", "'tokenSecret'", "]", ")", ";", "$", "stack", "=", "HandlerStack", "::", "create", "(", "new", "CurlHandler", "(", ")", ")", ";", "$", "stack", "->", "push", "(", "new", "Oauth1", "(", "[", "'consumer_key'", "=>", "$", "credentials", "->", "getConsumerKey", "(", ")", ",", "'consumer_secret'", "=>", "$", "credentials", "->", "getConsumerSecret", "(", ")", ",", "'token'", "=>", "$", "credentials", "->", "getToken", "(", ")", ",", "'token_secret'", "=>", "$", "credentials", "->", "getTokenSecret", "(", ")", ",", "'request_method'", "=>", "Oauth1", "::", "REQUEST_METHOD_HEADER", ",", "'signature_method'", "=>", "Oauth1", "::", "SIGNATURE_METHOD_HMAC", "]", ")", ")", ";", "$", "requestOptions", "=", "[", "'base_uri'", "=>", "$", "settings", "[", "'baseUrl'", "]", ",", "'handler'", "=>", "$", "stack", ",", "'auth'", "=>", "'oauth'", ",", "]", ";", "// Configures request Client (adding proxy, etc.)", "if", "(", "isset", "(", "$", "settings", "[", "'requestOptions'", "]", ")", "&&", "is_array", "(", "$", "settings", "[", "'requestOptions'", "]", ")", ")", "{", "$", "requestOptions", "+=", "$", "settings", "[", "'requestOptions'", "]", ";", "}", "$", "requestClient", "=", "new", "Client", "(", "$", "requestOptions", ")", ";", "$", "requestHandler", "=", "OauthRequestHandler", "::", "create", "(", "$", "credentials", ",", "$", "settings", "[", "'baseUrl'", "]", ",", "$", "requestClient", ")", ";", "return", "new", "BynderApi", "(", "$", "settings", "[", "'baseUrl'", "]", ",", "$", "requestHandler", ")", ";", "}", "else", "{", "throw", "new", "InvalidArgumentException", "(", "\"Settings passed for BynderApi service creation are not valid.\"", ")", ";", "}", "}" ]
Creates an instance of BynderApi using the settings provided. @param array $settings Oauth credentials and settings to configure the BynderApi instance. @return BynderApi instance. @throws InvalidArgumentException Oauth settings not valid, consumer key or secret not in array.
[ "Creates", "an", "instance", "of", "BynderApi", "using", "the", "settings", "provided", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/BynderApi.php#L62-L102
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/BynderApi.php
BynderApi.getAssetBankManager
public function getAssetBankManager() { if (!isset($this->assetBankManager)) { $this->assetBankManager = new AssetBankManager($this->requestHandler); } return $this->assetBankManager; }
php
public function getAssetBankManager() { if (!isset($this->assetBankManager)) { $this->assetBankManager = new AssetBankManager($this->requestHandler); } return $this->assetBankManager; }
[ "public", "function", "getAssetBankManager", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "assetBankManager", ")", ")", "{", "$", "this", "->", "assetBankManager", "=", "new", "AssetBankManager", "(", "$", "this", "->", "requestHandler", ")", ";", "}", "return", "$", "this", "->", "assetBankManager", ";", "}" ]
Gets an instance of the asset bank manager to use for DAM queries. @return AssetBankManager An instance of the asset bank manager using the request handler previously created.
[ "Gets", "an", "instance", "of", "the", "asset", "bank", "manager", "to", "use", "for", "DAM", "queries", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/BynderApi.php#L109-L116
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/BynderApi.php
BynderApi.getAccessToken
public function getAccessToken() { return $this->requestHandler->sendRequestAsync('POST', 'api/v4/oauth/access_token/')->then( function ($tokenValues) { parse_str($tokenValues, $tokenArray); $token = $tokenArray['oauth_token']; $tokenSecret = $tokenArray['oauth_token_secret']; $this->requestHandler->setAccessTokenCredentials($token, $tokenSecret); return $tokenArray; } ); }
php
public function getAccessToken() { return $this->requestHandler->sendRequestAsync('POST', 'api/v4/oauth/access_token/')->then( function ($tokenValues) { parse_str($tokenValues, $tokenArray); $token = $tokenArray['oauth_token']; $tokenSecret = $tokenArray['oauth_token_secret']; $this->requestHandler->setAccessTokenCredentials($token, $tokenSecret); return $tokenArray; } ); }
[ "public", "function", "getAccessToken", "(", ")", "{", "return", "$", "this", "->", "requestHandler", "->", "sendRequestAsync", "(", "'POST'", ",", "'api/v4/oauth/access_token/'", ")", "->", "then", "(", "function", "(", "$", "tokenValues", ")", "{", "parse_str", "(", "$", "tokenValues", ",", "$", "tokenArray", ")", ";", "$", "token", "=", "$", "tokenArray", "[", "'oauth_token'", "]", ";", "$", "tokenSecret", "=", "$", "tokenArray", "[", "'oauth_token_secret'", "]", ";", "$", "this", "->", "requestHandler", "->", "setAccessTokenCredentials", "(", "$", "token", ",", "$", "tokenSecret", ")", ";", "return", "$", "tokenArray", ";", "}", ")", ";", "}" ]
Exchanges the authorised request token for a valid access token. If successful the request token is immediately expired and the access tokens are set in the credentials. @return \GuzzleHttp\Promise\PromiseInterface @throws \Exception
[ "Exchanges", "the", "authorised", "request", "token", "for", "a", "valid", "access", "token", ".", "If", "successful", "the", "request", "token", "is", "immediately", "expired", "and", "the", "access", "tokens", "are", "set", "in", "the", "credentials", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/BynderApi.php#L155-L166
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/BynderApi.php
BynderApi.userLogin
public function userLogin($username, $password) { return $this->requestHandler->sendRequestAsync('POST', 'api/v4/users/login/', [ 'form_params' => [ 'username' => $username, 'password' => $password ] ])->then( function ($result) { $this->requestHandler->setAccessTokenCredentials($result['tokenKey'], $result['tokenSecret']); return $result; } ); }
php
public function userLogin($username, $password) { return $this->requestHandler->sendRequestAsync('POST', 'api/v4/users/login/', [ 'form_params' => [ 'username' => $username, 'password' => $password ] ])->then( function ($result) { $this->requestHandler->setAccessTokenCredentials($result['tokenKey'], $result['tokenSecret']); return $result; } ); }
[ "public", "function", "userLogin", "(", "$", "username", ",", "$", "password", ")", "{", "return", "$", "this", "->", "requestHandler", "->", "sendRequestAsync", "(", "'POST'", ",", "'api/v4/users/login/'", ",", "[", "'form_params'", "=>", "[", "'username'", "=>", "$", "username", ",", "'password'", "=>", "$", "password", "]", "]", ")", "->", "then", "(", "function", "(", "$", "result", ")", "{", "$", "this", "->", "requestHandler", "->", "setAccessTokenCredentials", "(", "$", "result", "[", "'tokenKey'", "]", ",", "$", "result", "[", "'tokenSecret'", "]", ")", ";", "return", "$", "result", ";", "}", ")", ";", "}" ]
Log in a user with username and password. If successful the retrieves OAUTH access tokens. @deprecated @param $username @param $password @return \GuzzleHttp\Promise\PromiseInterface @throws \Exception
[ "Log", "in", "a", "user", "with", "username", "and", "password", ".", "If", "successful", "the", "retrieves", "OAUTH", "access", "tokens", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/BynderApi.php#L191-L205
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/BynderApi.php
BynderApi.validateSettings
protected static function validateSettings($settings) { if (!isset($settings['consumerKey']) || !isset($settings['consumerSecret'])) { return false; } $settings['token'] = isset($settings['token']) ? $settings['token'] : null; $settings['tokenSecret'] = isset($settings['tokenSecret']) ? $settings['tokenSecret'] : null; return $settings; }
php
protected static function validateSettings($settings) { if (!isset($settings['consumerKey']) || !isset($settings['consumerSecret'])) { return false; } $settings['token'] = isset($settings['token']) ? $settings['token'] : null; $settings['tokenSecret'] = isset($settings['tokenSecret']) ? $settings['tokenSecret'] : null; return $settings; }
[ "protected", "static", "function", "validateSettings", "(", "$", "settings", ")", "{", "if", "(", "!", "isset", "(", "$", "settings", "[", "'consumerKey'", "]", ")", "||", "!", "isset", "(", "$", "settings", "[", "'consumerSecret'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "settings", "[", "'token'", "]", "=", "isset", "(", "$", "settings", "[", "'token'", "]", ")", "?", "$", "settings", "[", "'token'", "]", ":", "null", ";", "$", "settings", "[", "'tokenSecret'", "]", "=", "isset", "(", "$", "settings", "[", "'tokenSecret'", "]", ")", "?", "$", "settings", "[", "'tokenSecret'", "]", ":", "null", ";", "return", "$", "settings", ";", "}" ]
Checks if the settings array passed is valid. @param $settings @return bool Whether the settings array is valid.
[ "Checks", "if", "the", "settings", "array", "passed", "is", "valid", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/BynderApi.php#L282-L291
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/Oauth/OauthRequestHandler.php
OauthRequestHandler.create
public static function create(Credentials $credentials, $baseUrl, Client $client = null) { $newOauthHandler = new OauthRequestHandler($credentials, $baseUrl); $newOauthHandler->initOauthRequestClient($client); return $newOauthHandler; }
php
public static function create(Credentials $credentials, $baseUrl, Client $client = null) { $newOauthHandler = new OauthRequestHandler($credentials, $baseUrl); $newOauthHandler->initOauthRequestClient($client); return $newOauthHandler; }
[ "public", "static", "function", "create", "(", "Credentials", "$", "credentials", ",", "$", "baseUrl", ",", "Client", "$", "client", "=", "null", ")", "{", "$", "newOauthHandler", "=", "new", "OauthRequestHandler", "(", "$", "credentials", ",", "$", "baseUrl", ")", ";", "$", "newOauthHandler", "->", "initOauthRequestClient", "(", "$", "client", ")", ";", "return", "$", "newOauthHandler", ";", "}" ]
Creates an instance of OauthRequestHandler using the settings provided. @param Credentials $credentials The Bynder oauth credentials. @param string $baseUrl Api base url used for all requests. @param Client $client Optional client passed for handler creation. @return OauthRequestHandler An instance of the request handler properly configured.
[ "Creates", "an", "instance", "of", "OauthRequestHandler", "using", "the", "settings", "provided", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Oauth/OauthRequestHandler.php#L63-L70
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/Oauth/OauthRequestHandler.php
OauthRequestHandler.setAccessTokenCredentials
public function setAccessTokenCredentials($token, $tokenSecret) { $this->credentials->setToken($token); $this->credentials->setTokenSecret($tokenSecret); $this->initOauthRequestClient(); }
php
public function setAccessTokenCredentials($token, $tokenSecret) { $this->credentials->setToken($token); $this->credentials->setTokenSecret($tokenSecret); $this->initOauthRequestClient(); }
[ "public", "function", "setAccessTokenCredentials", "(", "$", "token", ",", "$", "tokenSecret", ")", "{", "$", "this", "->", "credentials", "->", "setToken", "(", "$", "token", ")", ";", "$", "this", "->", "credentials", "->", "setTokenSecret", "(", "$", "tokenSecret", ")", ";", "$", "this", "->", "initOauthRequestClient", "(", ")", ";", "}" ]
Sets the Access token credentials and re-initialises the request client. @param $token @param $tokenSecret
[ "Sets", "the", "Access", "token", "credentials", "and", "re", "-", "initialises", "the", "request", "client", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Oauth/OauthRequestHandler.php#L88-L93
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/Oauth/OauthRequestHandler.php
OauthRequestHandler.sendRequestAsync
public function sendRequestAsync($type, $uri, $options = null) { $request = null; switch ($type) { case 'GET': $request = $this->oauthRequestClient ->getAsync($uri, $options); break; case 'POST': $request = $this->oauthRequestClient ->postAsync($uri, $options); break; case 'DELETE': $request = $this->oauthRequestClient ->deleteAsync($uri, $options); break; default : throw new Exception("The request type you entered is not valid."); break; } return $request->then( function (ResponseInterface $response) { $contentType = self::checkResponseContentType($response->getHeader('Content-Type')); switch ($contentType) { case 'json': return json_decode($response->getBody(), true); break; case 'string': return (string)$response->getBody(); break; case 'html': return $response; break; default: // If we don't know the response type but it was a successful request, it's probably okay. if($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) { return $response; } throw new Exception("The response type not recognized."); } } ); }
php
public function sendRequestAsync($type, $uri, $options = null) { $request = null; switch ($type) { case 'GET': $request = $this->oauthRequestClient ->getAsync($uri, $options); break; case 'POST': $request = $this->oauthRequestClient ->postAsync($uri, $options); break; case 'DELETE': $request = $this->oauthRequestClient ->deleteAsync($uri, $options); break; default : throw new Exception("The request type you entered is not valid."); break; } return $request->then( function (ResponseInterface $response) { $contentType = self::checkResponseContentType($response->getHeader('Content-Type')); switch ($contentType) { case 'json': return json_decode($response->getBody(), true); break; case 'string': return (string)$response->getBody(); break; case 'html': return $response; break; default: // If we don't know the response type but it was a successful request, it's probably okay. if($response->getStatusCode() >= 200 && $response->getStatusCode() < 300) { return $response; } throw new Exception("The response type not recognized."); } } ); }
[ "public", "function", "sendRequestAsync", "(", "$", "type", ",", "$", "uri", ",", "$", "options", "=", "null", ")", "{", "$", "request", "=", "null", ";", "switch", "(", "$", "type", ")", "{", "case", "'GET'", ":", "$", "request", "=", "$", "this", "->", "oauthRequestClient", "->", "getAsync", "(", "$", "uri", ",", "$", "options", ")", ";", "break", ";", "case", "'POST'", ":", "$", "request", "=", "$", "this", "->", "oauthRequestClient", "->", "postAsync", "(", "$", "uri", ",", "$", "options", ")", ";", "break", ";", "case", "'DELETE'", ":", "$", "request", "=", "$", "this", "->", "oauthRequestClient", "->", "deleteAsync", "(", "$", "uri", ",", "$", "options", ")", ";", "break", ";", "default", ":", "throw", "new", "Exception", "(", "\"The request type you entered is not valid.\"", ")", ";", "break", ";", "}", "return", "$", "request", "->", "then", "(", "function", "(", "ResponseInterface", "$", "response", ")", "{", "$", "contentType", "=", "self", "::", "checkResponseContentType", "(", "$", "response", "->", "getHeader", "(", "'Content-Type'", ")", ")", ";", "switch", "(", "$", "contentType", ")", "{", "case", "'json'", ":", "return", "json_decode", "(", "$", "response", "->", "getBody", "(", ")", ",", "true", ")", ";", "break", ";", "case", "'string'", ":", "return", "(", "string", ")", "$", "response", "->", "getBody", "(", ")", ";", "break", ";", "case", "'html'", ":", "return", "$", "response", ";", "break", ";", "default", ":", "// If we don't know the response type but it was a successful request, it's probably okay.", "if", "(", "$", "response", "->", "getStatusCode", "(", ")", ">=", "200", "&&", "$", "response", "->", "getStatusCode", "(", ")", "<", "300", ")", "{", "return", "$", "response", ";", "}", "throw", "new", "Exception", "(", "\"The response type not recognized.\"", ")", ";", "}", "}", ")", ";", "}" ]
Sends a request to the Bynder API. All requests are async for now and the query array is parsed as request filter. @param string $type @param string $uri @param array $options @return PromiseInterface @throws Exception
[ "Sends", "a", "request", "to", "the", "Bynder", "API", ".", "All", "requests", "are", "async", "for", "now", "and", "the", "query", "array", "is", "parsed", "as", "request", "filter", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Oauth/OauthRequestHandler.php#L140-L182
train
nuvoleweb/drupal-behat
src/Driver/Cores/Drupal8.php
Drupal8.getStubEntity
protected function getStubEntity($entity_type, array $values) { $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->create($values); if (!$entity instanceof ContentEntityInterface) { throw new EntityMalformedException("Only content entities are supported."); } return $entity; }
php
protected function getStubEntity($entity_type, array $values) { $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->create($values); if (!$entity instanceof ContentEntityInterface) { throw new EntityMalformedException("Only content entities are supported."); } return $entity; }
[ "protected", "function", "getStubEntity", "(", "$", "entity_type", ",", "array", "$", "values", ")", "{", "$", "entity", "=", "\\", "Drupal", "::", "entityTypeManager", "(", ")", "->", "getStorage", "(", "$", "entity_type", ")", "->", "create", "(", "$", "values", ")", ";", "if", "(", "!", "$", "entity", "instanceof", "ContentEntityInterface", ")", "{", "throw", "new", "EntityMalformedException", "(", "\"Only content entities are supported.\"", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Get stub entity. @param string $entity_type Entity type. @param array $values Entity values. @return \Drupal\Core\Entity\ContentEntityInterface Entity object. @throws \Drupal\Core\Entity\EntityMalformedException @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
[ "Get", "stub", "entity", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/Driver/Cores/Drupal8.php#L354-L360
train
nuvoleweb/drupal-behat
src/Driver/Cores/Drupal8.php
Drupal8.saveFile
protected function saveFile($source) { $name = basename($source); $path = realpath(DRUPAL_ROOT . '/' . $source); $uri = file_unmanaged_copy($path, 'public://' . $name, FILE_EXISTS_REPLACE); $file = File::create(['uri' => $uri]); $file->save(); return $file; }
php
protected function saveFile($source) { $name = basename($source); $path = realpath(DRUPAL_ROOT . '/' . $source); $uri = file_unmanaged_copy($path, 'public://' . $name, FILE_EXISTS_REPLACE); $file = File::create(['uri' => $uri]); $file->save(); return $file; }
[ "protected", "function", "saveFile", "(", "$", "source", ")", "{", "$", "name", "=", "basename", "(", "$", "source", ")", ";", "$", "path", "=", "realpath", "(", "DRUPAL_ROOT", ".", "'/'", ".", "$", "source", ")", ";", "$", "uri", "=", "file_unmanaged_copy", "(", "$", "path", ",", "'public://'", ".", "$", "name", ",", "FILE_EXISTS_REPLACE", ")", ";", "$", "file", "=", "File", "::", "create", "(", "[", "'uri'", "=>", "$", "uri", "]", ")", ";", "$", "file", "->", "save", "(", ")", ";", "return", "$", "file", ";", "}" ]
Save a file and return its id. @param string $source Source path relative to Drupal installation root. @return \Drupal\Core\Entity\EntityInterface Saved file object.
[ "Save", "a", "file", "and", "return", "its", "id", "." ]
0d6cc3f438a6c38c33abc8a059c5f7eead8713c8
https://github.com/nuvoleweb/drupal-behat/blob/0d6cc3f438a6c38c33abc8a059c5f7eead8713c8/src/Driver/Cores/Drupal8.php#L371-L378
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.isdir
public function isdir( $path ) { return in_array( basename( $path ), $this->fs->directories( dirname( $path ) ) ); }
php
public function isdir( $path ) { return in_array( basename( $path ), $this->fs->directories( dirname( $path ) ) ); }
[ "public", "function", "isdir", "(", "$", "path", ")", "{", "return", "in_array", "(", "basename", "(", "$", "path", ")", ",", "$", "this", "->", "fs", "->", "directories", "(", "dirname", "(", "$", "path", ")", ")", ")", ";", "}" ]
Tests if the given path is a directory @param string $path Path to the file or directory @return boolean True if directory, false if not @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Tests", "if", "the", "given", "path", "is", "a", "directory" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L46-L49
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.mkdir
public function mkdir( $path ) { try { $this->fs->makeDirectory( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function mkdir( $path ) { try { $this->fs->makeDirectory( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "mkdir", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "fs", "->", "makeDirectory", "(", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Creates a new directory for the given path @param string $path Path to the directory @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Creates", "a", "new", "directory", "for", "the", "given", "path" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L59-L66
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.rmdir
public function rmdir( $path ) { try { $this->fs->deleteDirectory( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function rmdir( $path ) { try { $this->fs->deleteDirectory( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "rmdir", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "fs", "->", "deleteDirectory", "(", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Deletes the directory for the given path @param string $path Path to the directory @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Deletes", "the", "directory", "for", "the", "given", "path" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L76-L83
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.scan
public function scan( $path = null ) { try { return array_merge( $this->fs->directories( $path ), $this->fs->files( $path ) ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function scan( $path = null ) { try { return array_merge( $this->fs->directories( $path ), $this->fs->files( $path ) ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "scan", "(", "$", "path", "=", "null", ")", "{", "try", "{", "return", "array_merge", "(", "$", "this", "->", "fs", "->", "directories", "(", "$", "path", ")", ",", "$", "this", "->", "fs", "->", "files", "(", "$", "path", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns an iterator over the entries in the given path {@inheritDoc} @param string $path Path to the filesystem or directory @return \Iterator|array Iterator over the entries or array with entries @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Returns", "an", "iterator", "over", "the", "entries", "in", "the", "given", "path" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L95-L102
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.size
public function size( $path ) { try { return $this->fs->size( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function size( $path ) { try { return $this->fs->size( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "size", "(", "$", "path", ")", "{", "try", "{", "return", "$", "this", "->", "fs", "->", "size", "(", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns the file size @param string $path Path to the file @return integer Size in bytes @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Returns", "the", "file", "size" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L112-L119
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.time
public function time( $path ) { try { return $this->fs->lastModified( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function time( $path ) { try { return $this->fs->lastModified( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "time", "(", "$", "path", ")", "{", "try", "{", "return", "$", "this", "->", "fs", "->", "lastModified", "(", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns the Unix time stamp for the file @param string $path Path to the file @return integer Unix time stamp in seconds @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Returns", "the", "Unix", "time", "stamp", "for", "the", "file" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L129-L136
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.rm
public function rm( $path ) { try { $this->fs->delete( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function rm( $path ) { try { $this->fs->delete( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "rm", "(", "$", "path", ")", "{", "try", "{", "$", "this", "->", "fs", "->", "delete", "(", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Deletes the file for the given path @param string $path Path to the file @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Deletes", "the", "file", "for", "the", "given", "path" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L146-L153
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.readf
public function readf( $path ) { if( ( $filename = tempnam( $this->tempdir, 'ai-' ) ) === false ) { throw new Exception( sprintf( 'Unable to create file in "%1$s"', $this->tempdir ) ); } if( @file_put_contents( $filename, $this->fs->get( $path ) ) === false ) { throw new Exception( sprintf( 'Couldn\'t write file "%1$s"', $filename ) ); } return $filename; }
php
public function readf( $path ) { if( ( $filename = tempnam( $this->tempdir, 'ai-' ) ) === false ) { throw new Exception( sprintf( 'Unable to create file in "%1$s"', $this->tempdir ) ); } if( @file_put_contents( $filename, $this->fs->get( $path ) ) === false ) { throw new Exception( sprintf( 'Couldn\'t write file "%1$s"', $filename ) ); } return $filename; }
[ "public", "function", "readf", "(", "$", "path", ")", "{", "if", "(", "(", "$", "filename", "=", "tempnam", "(", "$", "this", "->", "tempdir", ",", "'ai-'", ")", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Unable to create file in \"%1$s\"'", ",", "$", "this", "->", "tempdir", ")", ")", ";", "}", "if", "(", "@", "file_put_contents", "(", "$", "filename", ",", "$", "this", "->", "fs", "->", "get", "(", "$", "path", ")", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Couldn\\'t write file \"%1$s\"'", ",", "$", "filename", ")", ")", ";", "}", "return", "$", "filename", ";", "}" ]
Reads the content of the remote file and writes it to a local one @param string $path Path to the remote file @return string Path of the local file @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Reads", "the", "content", "of", "the", "remote", "file", "and", "writes", "it", "to", "a", "local", "one" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L194-L205
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.reads
public function reads( $path ) { try { $content = $this->fs->get( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } if( ( $stream = tmpfile() ) === false ) { throw new Exception( 'Couldn\'t create temporary file' ); } if( fwrite( $stream, $content ) === false ) { throw new Exception( 'Couldn\'t write to temporary file' ); } if( rewind( $stream ) === false ) { throw new Exception( 'Couldn\'t rewind temporary file' ); } return $stream; }
php
public function reads( $path ) { try { $content = $this->fs->get( $path ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } if( ( $stream = tmpfile() ) === false ) { throw new Exception( 'Couldn\'t create temporary file' ); } if( fwrite( $stream, $content ) === false ) { throw new Exception( 'Couldn\'t write to temporary file' ); } if( rewind( $stream ) === false ) { throw new Exception( 'Couldn\'t rewind temporary file' ); } return $stream; }
[ "public", "function", "reads", "(", "$", "path", ")", "{", "try", "{", "$", "content", "=", "$", "this", "->", "fs", "->", "get", "(", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "if", "(", "(", "$", "stream", "=", "tmpfile", "(", ")", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Couldn\\'t create temporary file'", ")", ";", "}", "if", "(", "fwrite", "(", "$", "stream", ",", "$", "content", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Couldn\\'t write to temporary file'", ")", ";", "}", "if", "(", "rewind", "(", "$", "stream", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'Couldn\\'t rewind temporary file'", ")", ";", "}", "return", "$", "stream", ";", "}" ]
Returns the stream descriptor for the file {@inheritDoc} @param string $path Path to the file @return resource File stream descriptor @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Returns", "the", "stream", "descriptor", "for", "the", "file" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L217-L238
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.write
public function write( $path, $content ) { try { $this->fs->put( $path, $content ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function write( $path, $content ) { try { $this->fs->put( $path, $content ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "write", "(", "$", "path", ",", "$", "content", ")", "{", "try", "{", "$", "this", "->", "fs", "->", "put", "(", "$", "path", ",", "$", "content", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Writes the given content to the file {@inheritDoc} @param string $path Path to the file @param string $content New file content @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Writes", "the", "given", "content", "to", "the", "file" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L251-L258
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.writef
public function writef( $path, $local ) { if( ( $content = @file_get_contents( $local ) ) === false ) { throw new Exception( sprintf( 'Couldn\'t read file "%1$s"', $local ) ); } $this->write( $path, $content ); }
php
public function writef( $path, $local ) { if( ( $content = @file_get_contents( $local ) ) === false ) { throw new Exception( sprintf( 'Couldn\'t read file "%1$s"', $local ) ); } $this->write( $path, $content ); }
[ "public", "function", "writef", "(", "$", "path", ",", "$", "local", ")", "{", "if", "(", "(", "$", "content", "=", "@", "file_get_contents", "(", "$", "local", ")", ")", "===", "false", ")", "{", "throw", "new", "Exception", "(", "sprintf", "(", "'Couldn\\'t read file \"%1$s\"'", ",", "$", "local", ")", ")", ";", "}", "$", "this", "->", "write", "(", "$", "path", ",", "$", "content", ")", ";", "}" ]
Writes the content of the local file to the remote path {@inheritDoc} @param string $path Path to the remote file @param string $local Path to the local file @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Writes", "the", "content", "of", "the", "local", "file", "to", "the", "remote", "path" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L271-L278
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.writes
public function writes( $path, $stream ) { if( ( $content = @fread( $stream, 0x7ffffffd ) ) === false ) { $error = error_get_last(); throw new Exception( $error['message'] ); } try { $this->fs->put( $path, $content ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function writes( $path, $stream ) { if( ( $content = @fread( $stream, 0x7ffffffd ) ) === false ) { $error = error_get_last(); throw new Exception( $error['message'] ); } try { $this->fs->put( $path, $content ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "writes", "(", "$", "path", ",", "$", "stream", ")", "{", "if", "(", "(", "$", "content", "=", "@", "fread", "(", "$", "stream", ",", "0x7ffffffd", ")", ")", "===", "false", ")", "{", "$", "error", "=", "error_get_last", "(", ")", ";", "throw", "new", "Exception", "(", "$", "error", "[", "'message'", "]", ")", ";", "}", "try", "{", "$", "this", "->", "fs", "->", "put", "(", "$", "path", ",", "$", "content", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Write the content of the stream descriptor into the remote file {@inheritDoc} @param string $path Path to the file @param resource $stream File stream descriptor @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Write", "the", "content", "of", "the", "stream", "descriptor", "into", "the", "remote", "file" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L291-L303
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.move
public function move( $from, $to ) { try { $this->fs->move( $from, $to ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function move( $from, $to ) { try { $this->fs->move( $from, $to ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "move", "(", "$", "from", ",", "$", "to", ")", "{", "try", "{", "$", "this", "->", "fs", "->", "move", "(", "$", "from", ",", "$", "to", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Renames a file, moves it to a new location or both at once @param string $from Path to the original file @param string $to Path to the new file @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Renames", "a", "file", "moves", "it", "to", "a", "new", "location", "or", "both", "at", "once" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L314-L321
train
aimeos/ai-laravel
lib/custom/src/MW/Filesystem/Laravel.php
Laravel.copy
public function copy( $from, $to ) { try { $this->fs->copy( $from, $to ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
php
public function copy( $from, $to ) { try { $this->fs->copy( $from, $to ); } catch( \Exception $e ) { throw new Exception( $e->getMessage(), 0, $e ); } }
[ "public", "function", "copy", "(", "$", "from", ",", "$", "to", ")", "{", "try", "{", "$", "this", "->", "fs", "->", "copy", "(", "$", "from", ",", "$", "to", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Copies a file to a new location @param string $from Path to the original file @param string $to Path to the new file @return void @throws \Aimeos\MW\Filesystem\Exception If an error occurs
[ "Copies", "a", "file", "to", "a", "new", "location" ]
55b833be51bcfd867d27e6c2e1d2efaa7246c481
https://github.com/aimeos/ai-laravel/blob/55b833be51bcfd867d27e6c2e1d2efaa7246c481/lib/custom/src/MW/Filesystem/Laravel.php#L332-L339
train
Bynder/bynder-php-sdk
src/Bynder/Api/Impl/Upload/FileUploader.php
FileUploader.uploadFile
public function uploadFile($data) { $uploadedFilePromise = $this->getClosestUploadEndpoint() ->then( function () use ($data) { return $this->requestUploadInformationAsync($data['filePath']); }) ->then( function ($uploadRequestInfo) use ($data) { if ($file = fopen($data['filePath'], 'rb')) { $fileSize = filesize($data['filePath']); $numberOfChunks = round(($fileSize + self::CHUNK_SIZE - 1) / self::CHUNK_SIZE); $chunkNumber = 0; // This is where the magic happens. We create all the promises via an Iterator function. $promises = $this->uploadChunkIterator($file, $data['filePath'], $uploadRequestInfo, $numberOfChunks, $chunkNumber); // After that we batch them all together using each_limit_all, which will guarantee all chunks have been uploaded properly. $eachPromises = Promise\each_limit_all($promises, self::MAX_CONCURRENT_CHUNKS); return $eachPromises->then( function ($value) use ($uploadRequestInfo, $chunkNumber) { return ['requestInfo' => $uploadRequestInfo, 'chunkNumber' => $chunkNumber]; }); } else { throw new Exception("File not Found"); } } ) ->then( function ($value) { return $this->finalizeUploadAsync($value['requestInfo'], $value['chunkNumber']); } ) ->then( function ($finalizeResponse) { return $this->hasFinishedSuccessfullyAsync($finalizeResponse) ->then( function ($response) use ($finalizeResponse) { return [ 'pollStatus' => $response, 'finalizeData' => $finalizeResponse ]; }); } ) ->then( function ($value) use ($data) { if ($value['pollStatus'] != false) { $data['importId'] = $value['finalizeData']['importId']; return $this->saveMediaAsync($data); } else { throw new Exception("Converter did not finish. Upload failed."); } } ); return $uploadedFilePromise; }
php
public function uploadFile($data) { $uploadedFilePromise = $this->getClosestUploadEndpoint() ->then( function () use ($data) { return $this->requestUploadInformationAsync($data['filePath']); }) ->then( function ($uploadRequestInfo) use ($data) { if ($file = fopen($data['filePath'], 'rb')) { $fileSize = filesize($data['filePath']); $numberOfChunks = round(($fileSize + self::CHUNK_SIZE - 1) / self::CHUNK_SIZE); $chunkNumber = 0; // This is where the magic happens. We create all the promises via an Iterator function. $promises = $this->uploadChunkIterator($file, $data['filePath'], $uploadRequestInfo, $numberOfChunks, $chunkNumber); // After that we batch them all together using each_limit_all, which will guarantee all chunks have been uploaded properly. $eachPromises = Promise\each_limit_all($promises, self::MAX_CONCURRENT_CHUNKS); return $eachPromises->then( function ($value) use ($uploadRequestInfo, $chunkNumber) { return ['requestInfo' => $uploadRequestInfo, 'chunkNumber' => $chunkNumber]; }); } else { throw new Exception("File not Found"); } } ) ->then( function ($value) { return $this->finalizeUploadAsync($value['requestInfo'], $value['chunkNumber']); } ) ->then( function ($finalizeResponse) { return $this->hasFinishedSuccessfullyAsync($finalizeResponse) ->then( function ($response) use ($finalizeResponse) { return [ 'pollStatus' => $response, 'finalizeData' => $finalizeResponse ]; }); } ) ->then( function ($value) use ($data) { if ($value['pollStatus'] != false) { $data['importId'] = $value['finalizeData']['importId']; return $this->saveMediaAsync($data); } else { throw new Exception("Converter did not finish. Upload failed."); } } ); return $uploadedFilePromise; }
[ "public", "function", "uploadFile", "(", "$", "data", ")", "{", "$", "uploadedFilePromise", "=", "$", "this", "->", "getClosestUploadEndpoint", "(", ")", "->", "then", "(", "function", "(", ")", "use", "(", "$", "data", ")", "{", "return", "$", "this", "->", "requestUploadInformationAsync", "(", "$", "data", "[", "'filePath'", "]", ")", ";", "}", ")", "->", "then", "(", "function", "(", "$", "uploadRequestInfo", ")", "use", "(", "$", "data", ")", "{", "if", "(", "$", "file", "=", "fopen", "(", "$", "data", "[", "'filePath'", "]", ",", "'rb'", ")", ")", "{", "$", "fileSize", "=", "filesize", "(", "$", "data", "[", "'filePath'", "]", ")", ";", "$", "numberOfChunks", "=", "round", "(", "(", "$", "fileSize", "+", "self", "::", "CHUNK_SIZE", "-", "1", ")", "/", "self", "::", "CHUNK_SIZE", ")", ";", "$", "chunkNumber", "=", "0", ";", "// This is where the magic happens. We create all the promises via an Iterator function.", "$", "promises", "=", "$", "this", "->", "uploadChunkIterator", "(", "$", "file", ",", "$", "data", "[", "'filePath'", "]", ",", "$", "uploadRequestInfo", ",", "$", "numberOfChunks", ",", "$", "chunkNumber", ")", ";", "// After that we batch them all together using each_limit_all, which will guarantee all chunks have been uploaded properly.", "$", "eachPromises", "=", "Promise", "\\", "each_limit_all", "(", "$", "promises", ",", "self", "::", "MAX_CONCURRENT_CHUNKS", ")", ";", "return", "$", "eachPromises", "->", "then", "(", "function", "(", "$", "value", ")", "use", "(", "$", "uploadRequestInfo", ",", "$", "chunkNumber", ")", "{", "return", "[", "'requestInfo'", "=>", "$", "uploadRequestInfo", ",", "'chunkNumber'", "=>", "$", "chunkNumber", "]", ";", "}", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"File not Found\"", ")", ";", "}", "}", ")", "->", "then", "(", "function", "(", "$", "value", ")", "{", "return", "$", "this", "->", "finalizeUploadAsync", "(", "$", "value", "[", "'requestInfo'", "]", ",", "$", "value", "[", "'chunkNumber'", "]", ")", ";", "}", ")", "->", "then", "(", "function", "(", "$", "finalizeResponse", ")", "{", "return", "$", "this", "->", "hasFinishedSuccessfullyAsync", "(", "$", "finalizeResponse", ")", "->", "then", "(", "function", "(", "$", "response", ")", "use", "(", "$", "finalizeResponse", ")", "{", "return", "[", "'pollStatus'", "=>", "$", "response", ",", "'finalizeData'", "=>", "$", "finalizeResponse", "]", ";", "}", ")", ";", "}", ")", "->", "then", "(", "function", "(", "$", "value", ")", "use", "(", "$", "data", ")", "{", "if", "(", "$", "value", "[", "'pollStatus'", "]", "!=", "false", ")", "{", "$", "data", "[", "'importId'", "]", "=", "$", "value", "[", "'finalizeData'", "]", "[", "'importId'", "]", ";", "return", "$", "this", "->", "saveMediaAsync", "(", "$", "data", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"Converter did not finish. Upload failed.\"", ")", ";", "}", "}", ")", ";", "return", "$", "uploadedFilePromise", ";", "}" ]
Uploads a file with the data specified in the data parameter. Client requests S3-upload endpoint information from the Bynder API. For each file the client needs to requests upload authorization from the Bynder API. The client uploads a file chunked with CORS directly to the Amazon S3 endpoint received in step 1. Each chunk is named "FIXED_PREFIX/p{PARTNUMBER}", the partnumber needs to be sequentially updated. Each chunk needs to be registered as completed using a request to Bynder. When the file is completely uploaded, the client sends a “finalise” request to Bynder. After the file is processed, the client sends a “save” call to save the file in Bynder. Additional information can be provided such as title, tags, metadata and description. @param $data array containing the file and media asset information. @return Promise\Promise file promise. @throws Exception
[ "Uploads", "a", "file", "with", "the", "data", "specified", "in", "the", "data", "parameter", "." ]
1ba47afff4c986d91a473b69183d4aa35fd913b6
https://github.com/Bynder/bynder-php-sdk/blob/1ba47afff4c986d91a473b69183d4aa35fd913b6/src/Bynder/Api/Impl/Upload/FileUploader.php#L102-L161
train