id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
232,100
praxisnetau/silverware
src/Forms/ToggleGroup.php
ToggleGroup.collateDataFields
public function collateDataFields(&$list, $saveableOnly = false) { $list[$this->ToggleName] = $this->getToggleField(); parent::collateDataFields($list, $saveableOnly); }
php
public function collateDataFields(&$list, $saveableOnly = false) { $list[$this->ToggleName] = $this->getToggleField(); parent::collateDataFields($list, $saveableOnly); }
[ "public", "function", "collateDataFields", "(", "&", "$", "list", ",", "$", "saveableOnly", "=", "false", ")", "{", "$", "list", "[", "$", "this", "->", "ToggleName", "]", "=", "$", "this", "->", "getToggleField", "(", ")", ";", "parent", "::", "collateDataFields", "(", "$", "list", ",", "$", "saveableOnly", ")", ";", "}" ]
Collates all data fields within the receiver into the given list. @param array $list @param boolean $saveableOnly @return void
[ "Collates", "all", "data", "fields", "within", "the", "receiver", "into", "the", "given", "list", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/ToggleGroup.php#L246-L251
232,101
terra-ops/terra-cli
src/terra/Command/Environment/EnvironmentEnable.php
EnvironmentEnable.ensureProxy
protected function ensureProxy(InputInterface $input, OutputInterface $output) { // Get running containers. $cmd = 'docker ps'; $process = new Process($cmd); $process->run(); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } // Look for running instance of URL proxy in `docker ps` output. if (!strpos($process->getOutput(), 'jwilder/nginx-proxy')) { // If there's no running instance, offer to create one $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("URL proxy is not running, would you like to enable it now? [Y/n] ", true); if (!$helper->ask($input, $output, $question)) { $output->writeln('<error>Cancelled</error>'); } else { $output->writeln('Starting URL proxy...'); $command = $this->getApplication()->find('url-proxy:enable'); $proxyInput = new StringInput('url-proxy:enable'); $command->run($proxyInput, $output); } } }
php
protected function ensureProxy(InputInterface $input, OutputInterface $output) { // Get running containers. $cmd = 'docker ps'; $process = new Process($cmd); $process->run(); if (!$process->isSuccessful()) { throw new ProcessFailedException($process); } // Look for running instance of URL proxy in `docker ps` output. if (!strpos($process->getOutput(), 'jwilder/nginx-proxy')) { // If there's no running instance, offer to create one $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("URL proxy is not running, would you like to enable it now? [Y/n] ", true); if (!$helper->ask($input, $output, $question)) { $output->writeln('<error>Cancelled</error>'); } else { $output->writeln('Starting URL proxy...'); $command = $this->getApplication()->find('url-proxy:enable'); $proxyInput = new StringInput('url-proxy:enable'); $command->run($proxyInput, $output); } } }
[ "protected", "function", "ensureProxy", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// Get running containers.", "$", "cmd", "=", "'docker ps'", ";", "$", "process", "=", "new", "Process", "(", "$", "cmd", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "ProcessFailedException", "(", "$", "process", ")", ";", "}", "// Look for running instance of URL proxy in `docker ps` output.", "if", "(", "!", "strpos", "(", "$", "process", "->", "getOutput", "(", ")", ",", "'jwilder/nginx-proxy'", ")", ")", "{", "// If there's no running instance, offer to create one", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "'question'", ")", ";", "$", "question", "=", "new", "ConfirmationQuestion", "(", "\"URL proxy is not running, would you like to enable it now? [Y/n] \"", ",", "true", ")", ";", "if", "(", "!", "$", "helper", "->", "ask", "(", "$", "input", ",", "$", "output", ",", "$", "question", ")", ")", "{", "$", "output", "->", "writeln", "(", "'<error>Cancelled</error>'", ")", ";", "}", "else", "{", "$", "output", "->", "writeln", "(", "'Starting URL proxy...'", ")", ";", "$", "command", "=", "$", "this", "->", "getApplication", "(", ")", "->", "find", "(", "'url-proxy:enable'", ")", ";", "$", "proxyInput", "=", "new", "StringInput", "(", "'url-proxy:enable'", ")", ";", "$", "command", "->", "run", "(", "$", "proxyInput", ",", "$", "output", ")", ";", "}", "}", "}" ]
Ensure that URL proxy is running and if not offer to enable it. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output
[ "Ensure", "that", "URL", "proxy", "is", "running", "and", "if", "not", "offer", "to", "enable", "it", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Environment/EnvironmentEnable.php#L117-L142
232,102
i-am-tom/schemer
src/Formatter/Text.php
Text.replace
public function replace(string $regex, string $replacement) : Text { return $this->pipe( function (string $value) use ($regex, $replacement) { return preg_replace($regex, $replacement, $value); } ); }
php
public function replace(string $regex, string $replacement) : Text { return $this->pipe( function (string $value) use ($regex, $replacement) { return preg_replace($regex, $replacement, $value); } ); }
[ "public", "function", "replace", "(", "string", "$", "regex", ",", "string", "$", "replacement", ")", ":", "Text", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "string", "$", "value", ")", "use", "(", "$", "regex", ",", "$", "replacement", ")", "{", "return", "preg_replace", "(", "$", "regex", ",", "$", "replacement", ",", "$", "value", ")", ";", "}", ")", ";", "}" ]
Substrings will be replaced according to a regex. @param string $regex @param string $replacement @return Schemer\Formatter\Text
[ "Substrings", "will", "be", "replaced", "according", "to", "a", "regex", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Text.php#L37-L44
232,103
i-am-tom/schemer
src/Formatter/Text.php
Text.translate
public function translate(string $from, string $to) : Text { return $this->pipe( function (string $value) use ($from, $to) : string { return strtr($value, $from, $to); } ); }
php
public function translate(string $from, string $to) : Text { return $this->pipe( function (string $value) use ($from, $to) : string { return strtr($value, $from, $to); } ); }
[ "public", "function", "translate", "(", "string", "$", "from", ",", "string", "$", "to", ")", ":", "Text", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "string", "$", "value", ")", "use", "(", "$", "from", ",", "$", "to", ")", ":", "string", "{", "return", "strtr", "(", "$", "value", ",", "$", "from", ",", "$", "to", ")", ";", "}", ")", ";", "}" ]
Given characters will be translated. @param string $from @param string $to @return Schemer\Formatter\Text
[ "Given", "characters", "will", "be", "translated", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Text.php#L52-L59
232,104
i-am-tom/schemer
src/Formatter/Text.php
Text.trim
public function trim(string $mask = " \t\n\r\0\x0B") : Text { return $this->pipe( function (string $value) use ($mask) : string { return trim($value, $mask); } ); }
php
public function trim(string $mask = " \t\n\r\0\x0B") : Text { return $this->pipe( function (string $value) use ($mask) : string { return trim($value, $mask); } ); }
[ "public", "function", "trim", "(", "string", "$", "mask", "=", "\" \\t\\n\\r\\0\\x0B\"", ")", ":", "Text", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "string", "$", "value", ")", "use", "(", "$", "mask", ")", ":", "string", "{", "return", "trim", "(", "$", "value", ",", "$", "mask", ")", ";", "}", ")", ";", "}" ]
Given characters will be stripped from both string ends. @param string $mask @return Schemer\Formatter\Text
[ "Given", "characters", "will", "be", "stripped", "from", "both", "string", "ends", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Text.php#L66-L73
232,105
i-am-tom/schemer
src/Formatter/Text.php
Text.truncate
public function truncate(int $maximum) : Text { return $this->pipe( function (string $value) use ($maximum) : string { return strlen($value) > $maximum ? substr($value, 0, $maximum) : $value; } ); }
php
public function truncate(int $maximum) : Text { return $this->pipe( function (string $value) use ($maximum) : string { return strlen($value) > $maximum ? substr($value, 0, $maximum) : $value; } ); }
[ "public", "function", "truncate", "(", "int", "$", "maximum", ")", ":", "Text", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "string", "$", "value", ")", "use", "(", "$", "maximum", ")", ":", "string", "{", "return", "strlen", "(", "$", "value", ")", ">", "$", "maximum", "?", "substr", "(", "$", "value", ",", "0", ",", "$", "maximum", ")", ":", "$", "value", ";", "}", ")", ";", "}" ]
The string will be truncated at a given length. @param int $maximum @return Schemer\Formatter\Text
[ "The", "string", "will", "be", "truncated", "at", "a", "given", "length", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Text.php#L80-L89
232,106
terra-ops/terra-cli
src/terra/Config.php
Config.get
public function get($key, $name = null) { if ($name) { return array_key_exists($name, $this->config[$key]) ? $this->config[$key][$name] : null; } else { return $this->has($key) ? $this->config[$key] : null; } }
php
public function get($key, $name = null) { if ($name) { return array_key_exists($name, $this->config[$key]) ? $this->config[$key][$name] : null; } else { return $this->has($key) ? $this->config[$key] : null; } }
[ "public", "function", "get", "(", "$", "key", ",", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", ")", "{", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "config", "[", "$", "key", "]", ")", "?", "$", "this", "->", "config", "[", "$", "key", "]", "[", "$", "name", "]", ":", "null", ";", "}", "else", "{", "return", "$", "this", "->", "has", "(", "$", "key", ")", "?", "$", "this", "->", "config", "[", "$", "key", "]", ":", "null", ";", "}", "}" ]
Get a config param value. @param string $key Key of the param to get. @return mixed|null Value of the config param, or NULL if not present.
[ "Get", "a", "config", "param", "value", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Config.php#L108-L115
232,107
terra-ops/terra-cli
src/terra/Config.php
Config.add
public function add($key, $names, $val) { if (is_array($names)) { $array_piece = &$this->config[$key]; foreach ($names as $name_key) { $array_piece = &$array_piece[$name_key]; } return $array_piece = $val; } else { return $this->config[$key][$names] = $val; } }
php
public function add($key, $names, $val) { if (is_array($names)) { $array_piece = &$this->config[$key]; foreach ($names as $name_key) { $array_piece = &$array_piece[$name_key]; } return $array_piece = $val; } else { return $this->config[$key][$names] = $val; } }
[ "public", "function", "add", "(", "$", "key", ",", "$", "names", ",", "$", "val", ")", "{", "if", "(", "is_array", "(", "$", "names", ")", ")", "{", "$", "array_piece", "=", "&", "$", "this", "->", "config", "[", "$", "key", "]", ";", "foreach", "(", "$", "names", "as", "$", "name_key", ")", "{", "$", "array_piece", "=", "&", "$", "array_piece", "[", "$", "name_key", "]", ";", "}", "return", "$", "array_piece", "=", "$", "val", ";", "}", "else", "{", "return", "$", "this", "->", "config", "[", "$", "key", "]", "[", "$", "names", "]", "=", "$", "val", ";", "}", "}" ]
Add a config param value to a config array. @param string $key Key of the group to set to. @param string|array $names Name of the new object to set. @param mixed $val Value of the new object to set. @return bool
[ "Add", "a", "config", "param", "value", "to", "a", "config", "array", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Config.php#L169-L181
232,108
terra-ops/terra-cli
src/terra/Config.php
Config.saveEnvironment
public function saveEnvironment($environment) { $environment = (object) $environment; $environment_config = (array) $environment; unset($environment_config['app']); $this->config['apps'][$environment->app]['environments'][$environment->name] = $environment_config; }
php
public function saveEnvironment($environment) { $environment = (object) $environment; $environment_config = (array) $environment; unset($environment_config['app']); $this->config['apps'][$environment->app]['environments'][$environment->name] = $environment_config; }
[ "public", "function", "saveEnvironment", "(", "$", "environment", ")", "{", "$", "environment", "=", "(", "object", ")", "$", "environment", ";", "$", "environment_config", "=", "(", "array", ")", "$", "environment", ";", "unset", "(", "$", "environment_config", "[", "'app'", "]", ")", ";", "$", "this", "->", "config", "[", "'apps'", "]", "[", "$", "environment", "->", "app", "]", "[", "'environments'", "]", "[", "$", "environment", "->", "name", "]", "=", "$", "environment_config", ";", "}" ]
Saves an environment to the config class. Don't forget to call ::save() afterwards to save to file. @param $environment
[ "Saves", "an", "environment", "to", "the", "config", "class", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Config.php#L209-L215
232,109
terra-ops/terra-cli
src/terra/Config.php
Config.save
public function save() { // Create config folder if it does not exist. $fs = new Filesystem(); $dumper = new Dumper(); if (!$fs->exists(getenv('HOME').'/.terra')) { try { $fs->mkdir(getenv('HOME').'/.terra/apps'); } catch (IOExceptionInterface $e) { return false; } } try { $fs->dumpFile(getenv('HOME').'/.terra/terra', $dumper->dump($this->config, 10)); return true; } catch (IOExceptionInterface $e) { return false; } }
php
public function save() { // Create config folder if it does not exist. $fs = new Filesystem(); $dumper = new Dumper(); if (!$fs->exists(getenv('HOME').'/.terra')) { try { $fs->mkdir(getenv('HOME').'/.terra/apps'); } catch (IOExceptionInterface $e) { return false; } } try { $fs->dumpFile(getenv('HOME').'/.terra/terra', $dumper->dump($this->config, 10)); return true; } catch (IOExceptionInterface $e) { return false; } }
[ "public", "function", "save", "(", ")", "{", "// Create config folder if it does not exist.", "$", "fs", "=", "new", "Filesystem", "(", ")", ";", "$", "dumper", "=", "new", "Dumper", "(", ")", ";", "if", "(", "!", "$", "fs", "->", "exists", "(", "getenv", "(", "'HOME'", ")", ".", "'/.terra'", ")", ")", "{", "try", "{", "$", "fs", "->", "mkdir", "(", "getenv", "(", "'HOME'", ")", ".", "'/.terra/apps'", ")", ";", "}", "catch", "(", "IOExceptionInterface", "$", "e", ")", "{", "return", "false", ";", "}", "}", "try", "{", "$", "fs", "->", "dumpFile", "(", "getenv", "(", "'HOME'", ")", ".", "'/.terra/terra'", ",", "$", "dumper", "->", "dump", "(", "$", "this", "->", "config", ",", "10", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "IOExceptionInterface", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Saves the config class to file. @return bool
[ "Saves", "the", "config", "class", "to", "file", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Config.php#L221-L243
232,110
flagrow/flarum-ext-guardian
src/Abstracts/AbstractCheck.php
AbstractCheck.run
public function run() { $this->report['timing']['start'] = microtime(true); $this->execute(); $this->report['timing']['end'] = microtime(true); }
php
public function run() { $this->report['timing']['start'] = microtime(true); $this->execute(); $this->report['timing']['end'] = microtime(true); }
[ "public", "function", "run", "(", ")", "{", "$", "this", "->", "report", "[", "'timing'", "]", "[", "'start'", "]", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "execute", "(", ")", ";", "$", "this", "->", "report", "[", "'timing'", "]", "[", "'end'", "]", "=", "microtime", "(", "true", ")", ";", "}" ]
Runs the check.
[ "Runs", "the", "check", "." ]
fc5f1d19ad71578ff0f2323efbdb85a0864a7923
https://github.com/flagrow/flarum-ext-guardian/blob/fc5f1d19ad71578ff0f2323efbdb85a0864a7923/src/Abstracts/AbstractCheck.php#L45-L52
232,111
praxisnetau/silverware
src/Components/ScrollToTopButton.php
ScrollToTopButton.getButtonDimensions
public function getButtonDimensions() { // Initialise: $data = []; // Obtain Dimensions: $sizes = $this->dbObject('ButtonSize'); // Iterate Size Viewports: foreach ($sizes->getViewports() as $viewport) { if ($value = $sizes->getField($viewport)) { $data[$viewport]['Size'] = $value; $data[$viewport]['Breakpoint'] = $sizes->getBreakpoint($viewport); } } // Obtain Icon Dimensions: $iconSizes = $this->dbObject('IconSize'); // Iterate Icon Size Viewports: foreach ($iconSizes->getViewports() as $viewport) { if ($value = $iconSizes->getField($viewport)) { $data[$viewport]['IconSize'] = $value; $data[$viewport]['Breakpoint'] = $iconSizes->getBreakpoint($viewport); } } // Create Items List: $items = ArrayList::create(); // Create Data Items: foreach ($data as $item) { $items->push(ArrayData::create($item)); } // Answer Items List: return $items; }
php
public function getButtonDimensions() { // Initialise: $data = []; // Obtain Dimensions: $sizes = $this->dbObject('ButtonSize'); // Iterate Size Viewports: foreach ($sizes->getViewports() as $viewport) { if ($value = $sizes->getField($viewport)) { $data[$viewport]['Size'] = $value; $data[$viewport]['Breakpoint'] = $sizes->getBreakpoint($viewport); } } // Obtain Icon Dimensions: $iconSizes = $this->dbObject('IconSize'); // Iterate Icon Size Viewports: foreach ($iconSizes->getViewports() as $viewport) { if ($value = $iconSizes->getField($viewport)) { $data[$viewport]['IconSize'] = $value; $data[$viewport]['Breakpoint'] = $iconSizes->getBreakpoint($viewport); } } // Create Items List: $items = ArrayList::create(); // Create Data Items: foreach ($data as $item) { $items->push(ArrayData::create($item)); } // Answer Items List: return $items; }
[ "public", "function", "getButtonDimensions", "(", ")", "{", "// Initialise:", "$", "data", "=", "[", "]", ";", "// Obtain Dimensions:", "$", "sizes", "=", "$", "this", "->", "dbObject", "(", "'ButtonSize'", ")", ";", "// Iterate Size Viewports:", "foreach", "(", "$", "sizes", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "if", "(", "$", "value", "=", "$", "sizes", "->", "getField", "(", "$", "viewport", ")", ")", "{", "$", "data", "[", "$", "viewport", "]", "[", "'Size'", "]", "=", "$", "value", ";", "$", "data", "[", "$", "viewport", "]", "[", "'Breakpoint'", "]", "=", "$", "sizes", "->", "getBreakpoint", "(", "$", "viewport", ")", ";", "}", "}", "// Obtain Icon Dimensions:", "$", "iconSizes", "=", "$", "this", "->", "dbObject", "(", "'IconSize'", ")", ";", "// Iterate Icon Size Viewports:", "foreach", "(", "$", "iconSizes", "->", "getViewports", "(", ")", "as", "$", "viewport", ")", "{", "if", "(", "$", "value", "=", "$", "iconSizes", "->", "getField", "(", "$", "viewport", ")", ")", "{", "$", "data", "[", "$", "viewport", "]", "[", "'IconSize'", "]", "=", "$", "value", ";", "$", "data", "[", "$", "viewport", "]", "[", "'Breakpoint'", "]", "=", "$", "iconSizes", "->", "getBreakpoint", "(", "$", "viewport", ")", ";", "}", "}", "// Create Items List:", "$", "items", "=", "ArrayList", "::", "create", "(", ")", ";", "// Create Data Items:", "foreach", "(", "$", "data", "as", "$", "item", ")", "{", "$", "items", "->", "push", "(", "ArrayData", "::", "create", "(", "$", "item", ")", ")", ";", "}", "// Answer Items List:", "return", "$", "items", ";", "}" ]
Answers a list of button dimensions for the custom CSS template. @return ArrayList
[ "Answers", "a", "list", "of", "button", "dimensions", "for", "the", "custom", "CSS", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/ScrollToTopButton.php#L302-L351
232,112
cheprasov/php-memcached-lock
src/MemcachedLock/MemcachedLock.php
MemcachedLock.resetLockData
protected function resetLockData() { $this->isAcquired = false; $this->cas = null; $this->lockExpireTimeInMilliseconds = null; }
php
protected function resetLockData() { $this->isAcquired = false; $this->cas = null; $this->lockExpireTimeInMilliseconds = null; }
[ "protected", "function", "resetLockData", "(", ")", "{", "$", "this", "->", "isAcquired", "=", "false", ";", "$", "this", "->", "cas", "=", "null", ";", "$", "this", "->", "lockExpireTimeInMilliseconds", "=", "null", ";", "}" ]
Reset lock data
[ "Reset", "lock", "data" ]
3afd41642ea0e87982bdcc8d56ea1e40f5d4620d
https://github.com/cheprasov/php-memcached-lock/blob/3afd41642ea0e87982bdcc8d56ea1e40f5d4620d/src/MemcachedLock/MemcachedLock.php#L191-L195
232,113
digiaonline/paytrail-php
src/Common/BaseObject.php
BaseObject.configure
public function configure($properties = array()) { foreach ($properties as $name => $value) { if ( ! property_exists($this, $name)) { throw new PropertyDoesNotExist(sprintf('Property "%s" does not exist in %s', $name, get_called_class())); } $this->{$name} = $value; } }
php
public function configure($properties = array()) { foreach ($properties as $name => $value) { if ( ! property_exists($this, $name)) { throw new PropertyDoesNotExist(sprintf('Property "%s" does not exist in %s', $name, get_called_class())); } $this->{$name} = $value; } }
[ "public", "function", "configure", "(", "$", "properties", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "properties", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "name", ")", ")", "{", "throw", "new", "PropertyDoesNotExist", "(", "sprintf", "(", "'Property \"%s\" does not exist in %s'", ",", "$", "name", ",", "get_called_class", "(", ")", ")", ")", ";", "}", "$", "this", "->", "{", "$", "name", "}", "=", "$", "value", ";", "}", "}" ]
Configure the object. @param array $properties List of properties to set. @throws PropertyDoesNotExist
[ "Configure", "the", "object", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Common/BaseObject.php#L69-L78
232,114
mediact/composer-file-installer
src/FileInstaller.php
FileInstaller.install
public function install(IOInterface $io) { foreach ($this->mappingReader as $mapping) { if (file_exists($mapping->getDestination())) { continue; } $this->installFile($mapping); $io->write( sprintf( '<info>Installed:</info> %s', $mapping->getRelativeDestination() ) ); } }
php
public function install(IOInterface $io) { foreach ($this->mappingReader as $mapping) { if (file_exists($mapping->getDestination())) { continue; } $this->installFile($mapping); $io->write( sprintf( '<info>Installed:</info> %s', $mapping->getRelativeDestination() ) ); } }
[ "public", "function", "install", "(", "IOInterface", "$", "io", ")", "{", "foreach", "(", "$", "this", "->", "mappingReader", "as", "$", "mapping", ")", "{", "if", "(", "file_exists", "(", "$", "mapping", "->", "getDestination", "(", ")", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "installFile", "(", "$", "mapping", ")", ";", "$", "io", "->", "write", "(", "sprintf", "(", "'<info>Installed:</info> %s'", ",", "$", "mapping", "->", "getRelativeDestination", "(", ")", ")", ")", ";", "}", "}" ]
Install the deployer files. @param IOInterface $io @return void @SuppressWarnings(PHPMD.ShortVariable)
[ "Install", "the", "deployer", "files", "." ]
bf0b0d2ee004c187cbc2d5bc9ec3a372ef5dac6d
https://github.com/mediact/composer-file-installer/blob/bf0b0d2ee004c187cbc2d5bc9ec3a372ef5dac6d/src/FileInstaller.php#L33-L49
232,115
mediact/composer-file-installer
src/FileInstaller.php
FileInstaller.installFile
public function installFile(FileMappingInterface $mapping) { $inputFile = new SplFileObject($mapping->getSource(), 'r'); $targetFile = new SplFileObject($mapping->getDestination(), 'w+'); foreach ($inputFile as $input) { $targetFile->fwrite($input); } }
php
public function installFile(FileMappingInterface $mapping) { $inputFile = new SplFileObject($mapping->getSource(), 'r'); $targetFile = new SplFileObject($mapping->getDestination(), 'w+'); foreach ($inputFile as $input) { $targetFile->fwrite($input); } }
[ "public", "function", "installFile", "(", "FileMappingInterface", "$", "mapping", ")", "{", "$", "inputFile", "=", "new", "SplFileObject", "(", "$", "mapping", "->", "getSource", "(", ")", ",", "'r'", ")", ";", "$", "targetFile", "=", "new", "SplFileObject", "(", "$", "mapping", "->", "getDestination", "(", ")", ",", "'w+'", ")", ";", "foreach", "(", "$", "inputFile", "as", "$", "input", ")", "{", "$", "targetFile", "->", "fwrite", "(", "$", "input", ")", ";", "}", "}" ]
Install the given file if it does not exist. @param FileMappingInterface $mapping @return void @SuppressWarnings(PHPMD.ShortVariable)
[ "Install", "the", "given", "file", "if", "it", "does", "not", "exist", "." ]
bf0b0d2ee004c187cbc2d5bc9ec3a372ef5dac6d
https://github.com/mediact/composer-file-installer/blob/bf0b0d2ee004c187cbc2d5bc9ec3a372ef5dac6d/src/FileInstaller.php#L60-L68
232,116
praxisnetau/silverware
src/Extensions/Style/PaginationStyle.php
PaginationStyle.getPaginationSizeClass
public function getPaginationSizeClass() { switch ($this->owner->PaginationSize) { case self::SIZE_SMALL: return $this->style('pagination.small'); case self::SIZE_LARGE: return $this->style('pagination.large'); } }
php
public function getPaginationSizeClass() { switch ($this->owner->PaginationSize) { case self::SIZE_SMALL: return $this->style('pagination.small'); case self::SIZE_LARGE: return $this->style('pagination.large'); } }
[ "public", "function", "getPaginationSizeClass", "(", ")", "{", "switch", "(", "$", "this", "->", "owner", "->", "PaginationSize", ")", "{", "case", "self", "::", "SIZE_SMALL", ":", "return", "$", "this", "->", "style", "(", "'pagination.small'", ")", ";", "case", "self", "::", "SIZE_LARGE", ":", "return", "$", "this", "->", "style", "(", "'pagination.large'", ")", ";", "}", "}" ]
Answers the pagination size class of the extended object. @return string
[ "Answers", "the", "pagination", "size", "class", "of", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/PaginationStyle.php#L143-L151
232,117
praxisnetau/silverware
src/Extensions/Style/PaginationStyle.php
PaginationStyle.getPaginationButtonModeClass
public function getPaginationButtonModeClass() { switch ($this->owner->PaginationButtonMode) { case self::BUTTON_MODE_ICON: return 'icon-only'; case self::BUTTON_MODE_TEXT: return 'text-only'; case self::BUTTON_MODE_BOTH: return 'icon-text'; } }
php
public function getPaginationButtonModeClass() { switch ($this->owner->PaginationButtonMode) { case self::BUTTON_MODE_ICON: return 'icon-only'; case self::BUTTON_MODE_TEXT: return 'text-only'; case self::BUTTON_MODE_BOTH: return 'icon-text'; } }
[ "public", "function", "getPaginationButtonModeClass", "(", ")", "{", "switch", "(", "$", "this", "->", "owner", "->", "PaginationButtonMode", ")", "{", "case", "self", "::", "BUTTON_MODE_ICON", ":", "return", "'icon-only'", ";", "case", "self", "::", "BUTTON_MODE_TEXT", ":", "return", "'text-only'", ";", "case", "self", "::", "BUTTON_MODE_BOTH", ":", "return", "'icon-text'", ";", "}", "}" ]
Answers the pagination button mode class of the extended object. @return string
[ "Answers", "the", "pagination", "button", "mode", "class", "of", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/PaginationStyle.php#L158-L168
232,118
praxisnetau/silverware
src/Extensions/Style/PaginationStyle.php
PaginationStyle.getPaginationButtonModeOptions
public function getPaginationButtonModeOptions() { return [ self::BUTTON_MODE_ICON => _t(__CLASS__ . '.ICON', 'Icon Only'), self::BUTTON_MODE_TEXT => _t(__CLASS__ . '.TEXT', 'Text Only'), self::BUTTON_MODE_BOTH => _t(__CLASS__ . '.BOTH', 'Both Icon and Text') ]; }
php
public function getPaginationButtonModeOptions() { return [ self::BUTTON_MODE_ICON => _t(__CLASS__ . '.ICON', 'Icon Only'), self::BUTTON_MODE_TEXT => _t(__CLASS__ . '.TEXT', 'Text Only'), self::BUTTON_MODE_BOTH => _t(__CLASS__ . '.BOTH', 'Both Icon and Text') ]; }
[ "public", "function", "getPaginationButtonModeOptions", "(", ")", "{", "return", "[", "self", "::", "BUTTON_MODE_ICON", "=>", "_t", "(", "__CLASS__", ".", "'.ICON'", ",", "'Icon Only'", ")", ",", "self", "::", "BUTTON_MODE_TEXT", "=>", "_t", "(", "__CLASS__", ".", "'.TEXT'", ",", "'Text Only'", ")", ",", "self", "::", "BUTTON_MODE_BOTH", "=>", "_t", "(", "__CLASS__", ".", "'.BOTH'", ",", "'Both Icon and Text'", ")", "]", ";", "}" ]
Answers an array of options for the pagination button mode field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "pagination", "button", "mode", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/PaginationStyle.php#L188-L195
232,119
praxisnetau/silverware
src/Model/ComponentController.php
ComponentController.getViewer
public function getViewer($action) { // Answer Viewer Object (from parent): if (!$this->isCMSPreview()) { return parent::getViewer($action); } // Load Page Requirements (uses theme): PageController::create(Page::create())->doInit(); // Load Preview Requirements: Requirements::css('silverware/silverware: admin/client/dist/styles/preview.css'); // Answer Viewer Object (for CMS preview): return new SSViewer(sprintf('%s\CMSPreview', Component::class)); }
php
public function getViewer($action) { // Answer Viewer Object (from parent): if (!$this->isCMSPreview()) { return parent::getViewer($action); } // Load Page Requirements (uses theme): PageController::create(Page::create())->doInit(); // Load Preview Requirements: Requirements::css('silverware/silverware: admin/client/dist/styles/preview.css'); // Answer Viewer Object (for CMS preview): return new SSViewer(sprintf('%s\CMSPreview', Component::class)); }
[ "public", "function", "getViewer", "(", "$", "action", ")", "{", "// Answer Viewer Object (from parent):", "if", "(", "!", "$", "this", "->", "isCMSPreview", "(", ")", ")", "{", "return", "parent", "::", "getViewer", "(", "$", "action", ")", ";", "}", "// Load Page Requirements (uses theme):", "PageController", "::", "create", "(", "Page", "::", "create", "(", ")", ")", "->", "doInit", "(", ")", ";", "// Load Preview Requirements:", "Requirements", "::", "css", "(", "'silverware/silverware: admin/client/dist/styles/preview.css'", ")", ";", "// Answer Viewer Object (for CMS preview):", "return", "new", "SSViewer", "(", "sprintf", "(", "'%s\\CMSPreview'", ",", "Component", "::", "class", ")", ")", ";", "}" ]
Answers a viewer object to render the template for the current page. @param string $action @return SSViewer
[ "Answers", "a", "viewer", "object", "to", "render", "the", "template", "for", "the", "current", "page", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/ComponentController.php#L71-L90
232,120
praxisnetau/silverware
src/Lists/ListSourceSlide.php
ListSourceSlide.createSlide
protected function createSlide(ViewableData $item) { // Create Slide Object: $slide = Slide::create([ 'Title' => $item->MetaTitle, 'ImageID' => $item->MetaImageID, 'Caption' => $item->MetaImageCaption, 'ParentID' => $this->ParentID, 'HideImage' => $this->HideImage, 'HideTitle' => $this->HideTitle, 'HideCaption' => $this->HideCaption, 'TitleAfterCaption' => $this->TitleAfterCaption ]); // Define Slide Link: $slide->LinkTo = LinkToExtension::MODE_URL; $slide->LinkURL = $item->MetaAbsoluteLink; $slide->LinkDisabled = $this->LinkDisabled; $slide->OpenLinkInNewTab = $this->OpenLinkInNewTab; // Answer Slide Object: return $slide; }
php
protected function createSlide(ViewableData $item) { // Create Slide Object: $slide = Slide::create([ 'Title' => $item->MetaTitle, 'ImageID' => $item->MetaImageID, 'Caption' => $item->MetaImageCaption, 'ParentID' => $this->ParentID, 'HideImage' => $this->HideImage, 'HideTitle' => $this->HideTitle, 'HideCaption' => $this->HideCaption, 'TitleAfterCaption' => $this->TitleAfterCaption ]); // Define Slide Link: $slide->LinkTo = LinkToExtension::MODE_URL; $slide->LinkURL = $item->MetaAbsoluteLink; $slide->LinkDisabled = $this->LinkDisabled; $slide->OpenLinkInNewTab = $this->OpenLinkInNewTab; // Answer Slide Object: return $slide; }
[ "protected", "function", "createSlide", "(", "ViewableData", "$", "item", ")", "{", "// Create Slide Object:", "$", "slide", "=", "Slide", "::", "create", "(", "[", "'Title'", "=>", "$", "item", "->", "MetaTitle", ",", "'ImageID'", "=>", "$", "item", "->", "MetaImageID", ",", "'Caption'", "=>", "$", "item", "->", "MetaImageCaption", ",", "'ParentID'", "=>", "$", "this", "->", "ParentID", ",", "'HideImage'", "=>", "$", "this", "->", "HideImage", ",", "'HideTitle'", "=>", "$", "this", "->", "HideTitle", ",", "'HideCaption'", "=>", "$", "this", "->", "HideCaption", ",", "'TitleAfterCaption'", "=>", "$", "this", "->", "TitleAfterCaption", "]", ")", ";", "// Define Slide Link:", "$", "slide", "->", "LinkTo", "=", "LinkToExtension", "::", "MODE_URL", ";", "$", "slide", "->", "LinkURL", "=", "$", "item", "->", "MetaAbsoluteLink", ";", "$", "slide", "->", "LinkDisabled", "=", "$", "this", "->", "LinkDisabled", ";", "$", "slide", "->", "OpenLinkInNewTab", "=", "$", "this", "->", "OpenLinkInNewTab", ";", "// Answer Slide Object:", "return", "$", "slide", ";", "}" ]
Creates a slide for the given list item. @param ViewableData $item @return Slide
[ "Creates", "a", "slide", "for", "the", "given", "list", "item", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Lists/ListSourceSlide.php#L161-L186
232,121
terra-ops/terra-cli
src/terra/Command/Status.php
Status.systemStatus
protected function systemStatus(InputInterface $input, OutputInterface $output) { // If no apps, trigger app:Add command. $helper = $this->getHelper('question'); $apps = $this->getApplication()->getTerra()->getConfig()->get('apps'); if (empty($apps)) { $output->writeln('You have no apps!'); $question = new ConfirmationQuestion("Add an App? [y\N] ", false); if ($helper->ask($input, $output, $question)) { // Run environment:add command. $command = $this->getApplication()->find('app:add'); $command->run($input, $output); return; } } // APPS table. $table = $this->getHelper('table'); $table->setHeaders(array( 'APPS', 'Description', 'Repo', 'Environments', )); $rows = array(); $options = array(); foreach ($this->getApplication() ->getTerra() ->getConfig() ->get('apps') as $app) { $options[] = $app['name']; $row = array( $app['name'], $app['description'], $app['repo'], is_array($app['environments']) ? implode(', ', array_keys($app['environments'])) : 'None', ); $rows[] = $row; } $table->setRows($rows); $table->render($output); $helper = $this->getHelper('question'); $question = new Question('App? '); $question->setAutocompleterValues($options); // // // Run app status // $name = $helper->ask($input, $output, $question); // if (empty($name)) { // return; // } // else { // // If an app name was chosen, run appStatus // $formatter = $this->getHelper('formatter'); // $input->setArgument('app_name', $name); // $this->appStatus($input, $output); // // } }
php
protected function systemStatus(InputInterface $input, OutputInterface $output) { // If no apps, trigger app:Add command. $helper = $this->getHelper('question'); $apps = $this->getApplication()->getTerra()->getConfig()->get('apps'); if (empty($apps)) { $output->writeln('You have no apps!'); $question = new ConfirmationQuestion("Add an App? [y\N] ", false); if ($helper->ask($input, $output, $question)) { // Run environment:add command. $command = $this->getApplication()->find('app:add'); $command->run($input, $output); return; } } // APPS table. $table = $this->getHelper('table'); $table->setHeaders(array( 'APPS', 'Description', 'Repo', 'Environments', )); $rows = array(); $options = array(); foreach ($this->getApplication() ->getTerra() ->getConfig() ->get('apps') as $app) { $options[] = $app['name']; $row = array( $app['name'], $app['description'], $app['repo'], is_array($app['environments']) ? implode(', ', array_keys($app['environments'])) : 'None', ); $rows[] = $row; } $table->setRows($rows); $table->render($output); $helper = $this->getHelper('question'); $question = new Question('App? '); $question->setAutocompleterValues($options); // // // Run app status // $name = $helper->ask($input, $output, $question); // if (empty($name)) { // return; // } // else { // // If an app name was chosen, run appStatus // $formatter = $this->getHelper('formatter'); // $input->setArgument('app_name', $name); // $this->appStatus($input, $output); // // } }
[ "protected", "function", "systemStatus", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// If no apps, trigger app:Add command.", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "'question'", ")", ";", "$", "apps", "=", "$", "this", "->", "getApplication", "(", ")", "->", "getTerra", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'apps'", ")", ";", "if", "(", "empty", "(", "$", "apps", ")", ")", "{", "$", "output", "->", "writeln", "(", "'You have no apps!'", ")", ";", "$", "question", "=", "new", "ConfirmationQuestion", "(", "\"Add an App? [y\\N] \"", ",", "false", ")", ";", "if", "(", "$", "helper", "->", "ask", "(", "$", "input", ",", "$", "output", ",", "$", "question", ")", ")", "{", "// Run environment:add command.", "$", "command", "=", "$", "this", "->", "getApplication", "(", ")", "->", "find", "(", "'app:add'", ")", ";", "$", "command", "->", "run", "(", "$", "input", ",", "$", "output", ")", ";", "return", ";", "}", "}", "// APPS table.", "$", "table", "=", "$", "this", "->", "getHelper", "(", "'table'", ")", ";", "$", "table", "->", "setHeaders", "(", "array", "(", "'APPS'", ",", "'Description'", ",", "'Repo'", ",", "'Environments'", ",", ")", ")", ";", "$", "rows", "=", "array", "(", ")", ";", "$", "options", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getApplication", "(", ")", "->", "getTerra", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'apps'", ")", "as", "$", "app", ")", "{", "$", "options", "[", "]", "=", "$", "app", "[", "'name'", "]", ";", "$", "row", "=", "array", "(", "$", "app", "[", "'name'", "]", ",", "$", "app", "[", "'description'", "]", ",", "$", "app", "[", "'repo'", "]", ",", "is_array", "(", "$", "app", "[", "'environments'", "]", ")", "?", "implode", "(", "', '", ",", "array_keys", "(", "$", "app", "[", "'environments'", "]", ")", ")", ":", "'None'", ",", ")", ";", "$", "rows", "[", "]", "=", "$", "row", ";", "}", "$", "table", "->", "setRows", "(", "$", "rows", ")", ";", "$", "table", "->", "render", "(", "$", "output", ")", ";", "$", "helper", "=", "$", "this", "->", "getHelper", "(", "'question'", ")", ";", "$", "question", "=", "new", "Question", "(", "'App? '", ")", ";", "$", "question", "->", "setAutocompleterValues", "(", "$", "options", ")", ";", "//", "// // Run app status", "// $name = $helper->ask($input, $output, $question);", "// if (empty($name)) {", "// return;", "// }", "// else {", "// // If an app name was chosen, run appStatus", "// $formatter = $this->getHelper('formatter');", "// $input->setArgument('app_name', $name);", "// $this->appStatus($input, $output);", "//", "// }", "}" ]
Output the overall system status. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output
[ "Output", "the", "overall", "system", "status", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Status.php#L56-L116
232,122
terra-ops/terra-cli
src/terra/Command/Status.php
Status.appStatus
protected function appStatus(InputInterface $input, OutputInterface $output) { $output->writeln('<info>App:</info> ' . $input->getArgument('app_name')); // If there are no apps, return if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) { $output->writeln('<comment>There are no apps!</comment>'); $output->writeln('Use the command <info>terra app:add</info> to add your first app.'); return; } $app_name = strtr($input->getArgument('app_name'), array( '-' => '_', )); $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name); if (empty($app)) { $output->writeln('<error>No app with that name! </error>'); return 1; } // If no environments: if (count(($app['environments'])) == 0) { $output->writeln('<comment>There are no environments!</comment>'); $output->writeln('Use the command <info>terra environment:add</info> to add your first environment.'); return; } $table = $this->getHelper('table'); $table->setHeaders(array( 'Name', 'Code Path / docroot', 'URLs & Drush Alias', 'Version', )); $rows = array(); foreach ($app['environments'] as $environment) { // @TODO: Detect if URL proxy is online $environment_factory = new EnvironmentFactory($environment, $app); // Build list of domains. $environment['domains'][] = 'http://'. $environment_factory->getHost() . ':' . $environment_factory->getPort(); $environment['domains'][] = 'http://'.$environment_factory->getUrl(); $environment['url'] = implode(PHP_EOL, $environment['domains']); $environment['url'] .= PHP_EOL . $environment_factory->getDrushAlias(); unset($environment['domains']); $rows[] = array( $environment['name'], $environment['path'] . PHP_EOL . $environment['document_root'], $environment['url'], $environment['version'], ); } $table->setRows($rows); $table->render($output); }
php
protected function appStatus(InputInterface $input, OutputInterface $output) { $output->writeln('<info>App:</info> ' . $input->getArgument('app_name')); // If there are no apps, return if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) { $output->writeln('<comment>There are no apps!</comment>'); $output->writeln('Use the command <info>terra app:add</info> to add your first app.'); return; } $app_name = strtr($input->getArgument('app_name'), array( '-' => '_', )); $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name); if (empty($app)) { $output->writeln('<error>No app with that name! </error>'); return 1; } // If no environments: if (count(($app['environments'])) == 0) { $output->writeln('<comment>There are no environments!</comment>'); $output->writeln('Use the command <info>terra environment:add</info> to add your first environment.'); return; } $table = $this->getHelper('table'); $table->setHeaders(array( 'Name', 'Code Path / docroot', 'URLs & Drush Alias', 'Version', )); $rows = array(); foreach ($app['environments'] as $environment) { // @TODO: Detect if URL proxy is online $environment_factory = new EnvironmentFactory($environment, $app); // Build list of domains. $environment['domains'][] = 'http://'. $environment_factory->getHost() . ':' . $environment_factory->getPort(); $environment['domains'][] = 'http://'.$environment_factory->getUrl(); $environment['url'] = implode(PHP_EOL, $environment['domains']); $environment['url'] .= PHP_EOL . $environment_factory->getDrushAlias(); unset($environment['domains']); $rows[] = array( $environment['name'], $environment['path'] . PHP_EOL . $environment['document_root'], $environment['url'], $environment['version'], ); } $table->setRows($rows); $table->render($output); }
[ "protected", "function", "appStatus", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "writeln", "(", "'<info>App:</info> '", ".", "$", "input", "->", "getArgument", "(", "'app_name'", ")", ")", ";", "// If there are no apps, return", "if", "(", "count", "(", "$", "this", "->", "getApplication", "(", ")", "->", "getTerra", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'apps'", ")", ")", "==", "0", ")", "{", "$", "output", "->", "writeln", "(", "'<comment>There are no apps!</comment>'", ")", ";", "$", "output", "->", "writeln", "(", "'Use the command <info>terra app:add</info> to add your first app.'", ")", ";", "return", ";", "}", "$", "app_name", "=", "strtr", "(", "$", "input", "->", "getArgument", "(", "'app_name'", ")", ",", "array", "(", "'-'", "=>", "'_'", ",", ")", ")", ";", "$", "app", "=", "$", "this", "->", "getApplication", "(", ")", "->", "getTerra", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'apps'", ",", "$", "app_name", ")", ";", "if", "(", "empty", "(", "$", "app", ")", ")", "{", "$", "output", "->", "writeln", "(", "'<error>No app with that name! </error>'", ")", ";", "return", "1", ";", "}", "// If no environments:", "if", "(", "count", "(", "(", "$", "app", "[", "'environments'", "]", ")", ")", "==", "0", ")", "{", "$", "output", "->", "writeln", "(", "'<comment>There are no environments!</comment>'", ")", ";", "$", "output", "->", "writeln", "(", "'Use the command <info>terra environment:add</info> to add your first environment.'", ")", ";", "return", ";", "}", "$", "table", "=", "$", "this", "->", "getHelper", "(", "'table'", ")", ";", "$", "table", "->", "setHeaders", "(", "array", "(", "'Name'", ",", "'Code Path / docroot'", ",", "'URLs & Drush Alias'", ",", "'Version'", ",", ")", ")", ";", "$", "rows", "=", "array", "(", ")", ";", "foreach", "(", "$", "app", "[", "'environments'", "]", "as", "$", "environment", ")", "{", "// @TODO: Detect if URL proxy is online", "$", "environment_factory", "=", "new", "EnvironmentFactory", "(", "$", "environment", ",", "$", "app", ")", ";", "// Build list of domains.", "$", "environment", "[", "'domains'", "]", "[", "]", "=", "'http://'", ".", "$", "environment_factory", "->", "getHost", "(", ")", ".", "':'", ".", "$", "environment_factory", "->", "getPort", "(", ")", ";", "$", "environment", "[", "'domains'", "]", "[", "]", "=", "'http://'", ".", "$", "environment_factory", "->", "getUrl", "(", ")", ";", "$", "environment", "[", "'url'", "]", "=", "implode", "(", "PHP_EOL", ",", "$", "environment", "[", "'domains'", "]", ")", ";", "$", "environment", "[", "'url'", "]", ".=", "PHP_EOL", ".", "$", "environment_factory", "->", "getDrushAlias", "(", ")", ";", "unset", "(", "$", "environment", "[", "'domains'", "]", ")", ";", "$", "rows", "[", "]", "=", "array", "(", "$", "environment", "[", "'name'", "]", ",", "$", "environment", "[", "'path'", "]", ".", "PHP_EOL", ".", "$", "environment", "[", "'document_root'", "]", ",", "$", "environment", "[", "'url'", "]", ",", "$", "environment", "[", "'version'", "]", ",", ")", ";", "}", "$", "table", "->", "setRows", "(", "$", "rows", ")", ";", "$", "table", "->", "render", "(", "$", "output", ")", ";", "}" ]
Outputs the status of an app. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @param $app
[ "Outputs", "the", "status", "of", "an", "app", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Status.php#L125-L189
232,123
terra-ops/terra-cli
src/terra/Command/Status.php
Status.environmentStatus
protected function environmentStatus(InputInterface $input, OutputInterface $output) { // If there are no apps, return if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) { $output->writeln('<comment>There are no apps!</comment>'); $output->writeln('Use the command <info>terra app:add</info> to add your first app.'); return; } $app_name = $input->getArgument('app_name'); $environment_name = $input->getArgument('environment_name'); $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name); // If no environments: if (count(($app['environments'])) == 0) { $output->writeln('<comment>There are no environments!</comment>'); $output->writeln('Use the command <info>terra environment:add</info> to add your first environment.'); return; } // If no environment by that name... if (!isset($app['environments'][$environment_name])) { $output->writeln("<error>There is no environment named {$environment_name} in the app {$app_name}</error>"); return; } $environment = $app['environments'][$environment_name]; $environment_factory = new EnvironmentFactory($environment, $app); $environment['scale'] = $environment_factory->getScale(); $environment['url'] = 'http://'. $environment_factory->getHost() . ':' . $environment_factory->getPort(); $environment['url'] .= PHP_EOL.'http://'.$environment_factory->getUrl(); $table = $this->getHelper('table'); $table->setHeaders(array( 'Name', 'Code Path', 'docroot', 'URLs', 'Version', 'Scale', )); $rows = array( $environment ); $table->setRows($rows); $table->render($output); $output->writeln('Docker Compose Path: '.$environment_factory->getDockerComposePath()); }
php
protected function environmentStatus(InputInterface $input, OutputInterface $output) { // If there are no apps, return if (count($this->getApplication()->getTerra()->getConfig()->get('apps')) == 0) { $output->writeln('<comment>There are no apps!</comment>'); $output->writeln('Use the command <info>terra app:add</info> to add your first app.'); return; } $app_name = $input->getArgument('app_name'); $environment_name = $input->getArgument('environment_name'); $app = $this->getApplication()->getTerra()->getConfig()->get('apps', $app_name); // If no environments: if (count(($app['environments'])) == 0) { $output->writeln('<comment>There are no environments!</comment>'); $output->writeln('Use the command <info>terra environment:add</info> to add your first environment.'); return; } // If no environment by that name... if (!isset($app['environments'][$environment_name])) { $output->writeln("<error>There is no environment named {$environment_name} in the app {$app_name}</error>"); return; } $environment = $app['environments'][$environment_name]; $environment_factory = new EnvironmentFactory($environment, $app); $environment['scale'] = $environment_factory->getScale(); $environment['url'] = 'http://'. $environment_factory->getHost() . ':' . $environment_factory->getPort(); $environment['url'] .= PHP_EOL.'http://'.$environment_factory->getUrl(); $table = $this->getHelper('table'); $table->setHeaders(array( 'Name', 'Code Path', 'docroot', 'URLs', 'Version', 'Scale', )); $rows = array( $environment ); $table->setRows($rows); $table->render($output); $output->writeln('Docker Compose Path: '.$environment_factory->getDockerComposePath()); }
[ "protected", "function", "environmentStatus", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// If there are no apps, return", "if", "(", "count", "(", "$", "this", "->", "getApplication", "(", ")", "->", "getTerra", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'apps'", ")", ")", "==", "0", ")", "{", "$", "output", "->", "writeln", "(", "'<comment>There are no apps!</comment>'", ")", ";", "$", "output", "->", "writeln", "(", "'Use the command <info>terra app:add</info> to add your first app.'", ")", ";", "return", ";", "}", "$", "app_name", "=", "$", "input", "->", "getArgument", "(", "'app_name'", ")", ";", "$", "environment_name", "=", "$", "input", "->", "getArgument", "(", "'environment_name'", ")", ";", "$", "app", "=", "$", "this", "->", "getApplication", "(", ")", "->", "getTerra", "(", ")", "->", "getConfig", "(", ")", "->", "get", "(", "'apps'", ",", "$", "app_name", ")", ";", "// If no environments:", "if", "(", "count", "(", "(", "$", "app", "[", "'environments'", "]", ")", ")", "==", "0", ")", "{", "$", "output", "->", "writeln", "(", "'<comment>There are no environments!</comment>'", ")", ";", "$", "output", "->", "writeln", "(", "'Use the command <info>terra environment:add</info> to add your first environment.'", ")", ";", "return", ";", "}", "// If no environment by that name...", "if", "(", "!", "isset", "(", "$", "app", "[", "'environments'", "]", "[", "$", "environment_name", "]", ")", ")", "{", "$", "output", "->", "writeln", "(", "\"<error>There is no environment named {$environment_name} in the app {$app_name}</error>\"", ")", ";", "return", ";", "}", "$", "environment", "=", "$", "app", "[", "'environments'", "]", "[", "$", "environment_name", "]", ";", "$", "environment_factory", "=", "new", "EnvironmentFactory", "(", "$", "environment", ",", "$", "app", ")", ";", "$", "environment", "[", "'scale'", "]", "=", "$", "environment_factory", "->", "getScale", "(", ")", ";", "$", "environment", "[", "'url'", "]", "=", "'http://'", ".", "$", "environment_factory", "->", "getHost", "(", ")", ".", "':'", ".", "$", "environment_factory", "->", "getPort", "(", ")", ";", "$", "environment", "[", "'url'", "]", ".=", "PHP_EOL", ".", "'http://'", ".", "$", "environment_factory", "->", "getUrl", "(", ")", ";", "$", "table", "=", "$", "this", "->", "getHelper", "(", "'table'", ")", ";", "$", "table", "->", "setHeaders", "(", "array", "(", "'Name'", ",", "'Code Path'", ",", "'docroot'", ",", "'URLs'", ",", "'Version'", ",", "'Scale'", ",", ")", ")", ";", "$", "rows", "=", "array", "(", "$", "environment", ")", ";", "$", "table", "->", "setRows", "(", "$", "rows", ")", ";", "$", "table", "->", "render", "(", "$", "output", ")", ";", "$", "output", "->", "writeln", "(", "'Docker Compose Path: '", ".", "$", "environment_factory", "->", "getDockerComposePath", "(", ")", ")", ";", "}" ]
Outputs the status of an environment. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @param $app @param $environment
[ "Outputs", "the", "status", "of", "an", "environment", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Status.php#L200-L255
232,124
praxisnetau/silverware
src/Components/MediaComponent.php
MediaComponent.getMediaClassNames
public function getMediaClassNames() { $classes = [$this->MediaType]; if ($this->MediaType == 'video') { $classes[] = $this->VideoAspect; } if ($this->CaptionShown) { $classes[] = $this->style('figure.image'); } $this->extend('updateMediaClassNames', $classes); return $classes; }
php
public function getMediaClassNames() { $classes = [$this->MediaType]; if ($this->MediaType == 'video') { $classes[] = $this->VideoAspect; } if ($this->CaptionShown) { $classes[] = $this->style('figure.image'); } $this->extend('updateMediaClassNames', $classes); return $classes; }
[ "public", "function", "getMediaClassNames", "(", ")", "{", "$", "classes", "=", "[", "$", "this", "->", "MediaType", "]", ";", "if", "(", "$", "this", "->", "MediaType", "==", "'video'", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "VideoAspect", ";", "}", "if", "(", "$", "this", "->", "CaptionShown", ")", "{", "$", "classes", "[", "]", "=", "$", "this", "->", "style", "(", "'figure.image'", ")", ";", "}", "$", "this", "->", "extend", "(", "'updateMediaClassNames'", ",", "$", "classes", ")", ";", "return", "$", "classes", ";", "}" ]
Answers an array of media class names for the HTML template. @return array
[ "Answers", "an", "array", "of", "media", "class", "names", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/MediaComponent.php#L403-L418
232,125
praxisnetau/silverware
src/Components/MediaComponent.php
MediaComponent.getCaptionHTML
public function getCaptionHTML() { if ($this->CaptionMode == self::CAPTION_TEXT && $this->Caption) { return $this->Caption; } if ($this->CaptionMode == self::CAPTION_DESC && $this->Description) { return sprintf('<p>%s</p>', $this->Description); } }
php
public function getCaptionHTML() { if ($this->CaptionMode == self::CAPTION_TEXT && $this->Caption) { return $this->Caption; } if ($this->CaptionMode == self::CAPTION_DESC && $this->Description) { return sprintf('<p>%s</p>', $this->Description); } }
[ "public", "function", "getCaptionHTML", "(", ")", "{", "if", "(", "$", "this", "->", "CaptionMode", "==", "self", "::", "CAPTION_TEXT", "&&", "$", "this", "->", "Caption", ")", "{", "return", "$", "this", "->", "Caption", ";", "}", "if", "(", "$", "this", "->", "CaptionMode", "==", "self", "::", "CAPTION_DESC", "&&", "$", "this", "->", "Description", ")", "{", "return", "sprintf", "(", "'<p>%s</p>'", ",", "$", "this", "->", "Description", ")", ";", "}", "}" ]
Answers the HTML for the caption. @return string
[ "Answers", "the", "HTML", "for", "the", "caption", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/MediaComponent.php#L507-L516
232,126
praxisnetau/silverware
src/Components/MediaComponent.php
MediaComponent.getImageTitleText
public function getImageTitleText() { switch ($this->ImageTitle) { case self::IMAGE_TITLE_MEDIA: return $this->MediaTitle; case self::IMAGE_TITLE_COMPONENT: return $this->Title; } }
php
public function getImageTitleText() { switch ($this->ImageTitle) { case self::IMAGE_TITLE_MEDIA: return $this->MediaTitle; case self::IMAGE_TITLE_COMPONENT: return $this->Title; } }
[ "public", "function", "getImageTitleText", "(", ")", "{", "switch", "(", "$", "this", "->", "ImageTitle", ")", "{", "case", "self", "::", "IMAGE_TITLE_MEDIA", ":", "return", "$", "this", "->", "MediaTitle", ";", "case", "self", "::", "IMAGE_TITLE_COMPONENT", ":", "return", "$", "this", "->", "Title", ";", "}", "}" ]
Answers the title text for image popups. @return string
[ "Answers", "the", "title", "text", "for", "image", "popups", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/MediaComponent.php#L574-L582
232,127
praxisnetau/silverware
src/Components/MediaComponent.php
MediaComponent.getImageCaptionText
public function getImageCaptionText() { switch ($this->ImageCaption) { case self::IMAGE_CAPTION_MEDIA: return $this->Description; case self::IMAGE_CAPTION_COMPONENT: return $this->dbObject('Caption')->Summary(); } }
php
public function getImageCaptionText() { switch ($this->ImageCaption) { case self::IMAGE_CAPTION_MEDIA: return $this->Description; case self::IMAGE_CAPTION_COMPONENT: return $this->dbObject('Caption')->Summary(); } }
[ "public", "function", "getImageCaptionText", "(", ")", "{", "switch", "(", "$", "this", "->", "ImageCaption", ")", "{", "case", "self", "::", "IMAGE_CAPTION_MEDIA", ":", "return", "$", "this", "->", "Description", ";", "case", "self", "::", "IMAGE_CAPTION_COMPONENT", ":", "return", "$", "this", "->", "dbObject", "(", "'Caption'", ")", "->", "Summary", "(", ")", ";", "}", "}" ]
Answers the caption text for image popups. @return string
[ "Answers", "the", "caption", "text", "for", "image", "popups", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/MediaComponent.php#L589-L597
232,128
praxisnetau/silverware
src/Components/MediaComponent.php
MediaComponent.getEmbed
public function getEmbed() { // Determine Media Type: switch ($this->MediaType) { case 'rich': case 'video': return $this->renderWith(sprintf('%s\Video', self::class)); case 'photo': return $this->renderWith(sprintf('%s\Photo', self::class)); case 'link': return $this->renderWith(sprintf('%s\Link', self::class)); } // Answer Null (invalid media type): return null; }
php
public function getEmbed() { // Determine Media Type: switch ($this->MediaType) { case 'rich': case 'video': return $this->renderWith(sprintf('%s\Video', self::class)); case 'photo': return $this->renderWith(sprintf('%s\Photo', self::class)); case 'link': return $this->renderWith(sprintf('%s\Link', self::class)); } // Answer Null (invalid media type): return null; }
[ "public", "function", "getEmbed", "(", ")", "{", "// Determine Media Type:", "switch", "(", "$", "this", "->", "MediaType", ")", "{", "case", "'rich'", ":", "case", "'video'", ":", "return", "$", "this", "->", "renderWith", "(", "sprintf", "(", "'%s\\Video'", ",", "self", "::", "class", ")", ")", ";", "case", "'photo'", ":", "return", "$", "this", "->", "renderWith", "(", "sprintf", "(", "'%s\\Photo'", ",", "self", "::", "class", ")", ")", ";", "case", "'link'", ":", "return", "$", "this", "->", "renderWith", "(", "sprintf", "(", "'%s\\Link'", ",", "self", "::", "class", ")", ")", ";", "}", "// Answer Null (invalid media type):", "return", "null", ";", "}" ]
Answers the HTML to embed the media within the template. @return string
[ "Answers", "the", "HTML", "to", "embed", "the", "media", "within", "the", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/MediaComponent.php#L614-L635
232,129
praxisnetau/silverware
src/Components/MediaComponent.php
MediaComponent.getImageTitleOptions
public function getImageTitleOptions() { return [ self::IMAGE_TITLE_NONE => _t(__CLASS__ . '.NONE', 'None'), self::IMAGE_TITLE_MEDIA => _t(__CLASS__ . '.MEDIATITLE', 'Media Title'), self::IMAGE_TITLE_COMPONENT => _t(__CLASS__ . '.COMPONENTTITLE', 'Component Title') ]; }
php
public function getImageTitleOptions() { return [ self::IMAGE_TITLE_NONE => _t(__CLASS__ . '.NONE', 'None'), self::IMAGE_TITLE_MEDIA => _t(__CLASS__ . '.MEDIATITLE', 'Media Title'), self::IMAGE_TITLE_COMPONENT => _t(__CLASS__ . '.COMPONENTTITLE', 'Component Title') ]; }
[ "public", "function", "getImageTitleOptions", "(", ")", "{", "return", "[", "self", "::", "IMAGE_TITLE_NONE", "=>", "_t", "(", "__CLASS__", ".", "'.NONE'", ",", "'None'", ")", ",", "self", "::", "IMAGE_TITLE_MEDIA", "=>", "_t", "(", "__CLASS__", ".", "'.MEDIATITLE'", ",", "'Media Title'", ")", ",", "self", "::", "IMAGE_TITLE_COMPONENT", "=>", "_t", "(", "__CLASS__", ".", "'.COMPONENTTITLE'", ",", "'Component Title'", ")", "]", ";", "}" ]
Answers an array of options for the image title field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "image", "title", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/MediaComponent.php#L652-L659
232,130
praxisnetau/silverware
src/Components/MediaComponent.php
MediaComponent.getImageCaptionOptions
public function getImageCaptionOptions() { return [ self::IMAGE_CAPTION_NONE => _t(__CLASS__ . '.NONE', 'None'), self::IMAGE_CAPTION_MEDIA => _t(__CLASS__ . '.MEDIADESCRIPTION', 'Media Description'), self::IMAGE_CAPTION_COMPONENT => _t(__CLASS__ . '.COMPONENTCAPTION', 'Component Caption') ]; }
php
public function getImageCaptionOptions() { return [ self::IMAGE_CAPTION_NONE => _t(__CLASS__ . '.NONE', 'None'), self::IMAGE_CAPTION_MEDIA => _t(__CLASS__ . '.MEDIADESCRIPTION', 'Media Description'), self::IMAGE_CAPTION_COMPONENT => _t(__CLASS__ . '.COMPONENTCAPTION', 'Component Caption') ]; }
[ "public", "function", "getImageCaptionOptions", "(", ")", "{", "return", "[", "self", "::", "IMAGE_CAPTION_NONE", "=>", "_t", "(", "__CLASS__", ".", "'.NONE'", ",", "'None'", ")", ",", "self", "::", "IMAGE_CAPTION_MEDIA", "=>", "_t", "(", "__CLASS__", ".", "'.MEDIADESCRIPTION'", ",", "'Media Description'", ")", ",", "self", "::", "IMAGE_CAPTION_COMPONENT", "=>", "_t", "(", "__CLASS__", ".", "'.COMPONENTCAPTION'", ",", "'Component Caption'", ")", "]", ";", "}" ]
Answers an array of options for the image caption field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "image", "caption", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/MediaComponent.php#L666-L673
232,131
jack-theripper/transcoder
src/Traits/MetadataTrait.php
MetadataTrait.setMetadata
protected function setMetadata($metadata, $value = null) { if ( ! is_array($metadata)) { $metadata = [(string) $metadata => $value]; } $this->metadata = array_filter($metadata, 'is_scalar'); return $this; }
php
protected function setMetadata($metadata, $value = null) { if ( ! is_array($metadata)) { $metadata = [(string) $metadata => $value]; } $this->metadata = array_filter($metadata, 'is_scalar'); return $this; }
[ "protected", "function", "setMetadata", "(", "$", "metadata", ",", "$", "value", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "metadata", ")", ")", "{", "$", "metadata", "=", "[", "(", "string", ")", "$", "metadata", "=>", "$", "value", "]", ";", "}", "$", "this", "->", "metadata", "=", "array_filter", "(", "$", "metadata", ",", "'is_scalar'", ")", ";", "return", "$", "this", ";", "}" ]
Sets the metadata. @param string|array $metadata @param mixed $value @return $this
[ "Sets", "the", "metadata", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Traits/MetadataTrait.php#L101-L111
232,132
z-song/easy-fa
src/FontAwesome.php
FontAwesome.initClasses
protected function initClasses() { $this->addClass('fa', ''); if (is_string($this->icon)) { $this->addClass($this->icon); } }
php
protected function initClasses() { $this->addClass('fa', ''); if (is_string($this->icon)) { $this->addClass($this->icon); } }
[ "protected", "function", "initClasses", "(", ")", "{", "$", "this", "->", "addClass", "(", "'fa'", ",", "''", ")", ";", "if", "(", "is_string", "(", "$", "this", "->", "icon", ")", ")", "{", "$", "this", "->", "addClass", "(", "$", "this", "->", "icon", ")", ";", "}", "}" ]
Initialize classes.
[ "Initialize", "classes", "." ]
6afb2e638033a53020ed69e683d9063cf374287a
https://github.com/z-song/easy-fa/blob/6afb2e638033a53020ed69e683d9063cf374287a/src/FontAwesome.php#L47-L54
232,133
z-song/easy-fa
src/FontAwesome.php
FontAwesome.style
public function style($style) { if (is_string($style)) { $this->attributes['style'] = $style; return $this; } if (is_array($style)) { $html = []; foreach ($style as $name => $value) { $html[] = "$name:$value"; } $this->attributes['style'] = implode(';', $html); } return $this; }
php
public function style($style) { if (is_string($style)) { $this->attributes['style'] = $style; return $this; } if (is_array($style)) { $html = []; foreach ($style as $name => $value) { $html[] = "$name:$value"; } $this->attributes['style'] = implode(';', $html); } return $this; }
[ "public", "function", "style", "(", "$", "style", ")", "{", "if", "(", "is_string", "(", "$", "style", ")", ")", "{", "$", "this", "->", "attributes", "[", "'style'", "]", "=", "$", "style", ";", "return", "$", "this", ";", "}", "if", "(", "is_array", "(", "$", "style", ")", ")", "{", "$", "html", "=", "[", "]", ";", "foreach", "(", "$", "style", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "html", "[", "]", "=", "\"$name:$value\"", ";", "}", "$", "this", "->", "attributes", "[", "'style'", "]", "=", "implode", "(", "';'", ",", "$", "html", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add style to html tag. @param $style @return $this
[ "Add", "style", "to", "html", "tag", "." ]
6afb2e638033a53020ed69e683d9063cf374287a
https://github.com/z-song/easy-fa/blob/6afb2e638033a53020ed69e683d9063cf374287a/src/FontAwesome.php#L264-L284
232,134
z-song/easy-fa
src/FontAwesome.php
FontAwesome.formatAttributes
protected function formatAttributes() { $this->attributes['class'] = implode(' ', $this->classes); $html = ''; foreach ($this->attributes as $name => $value) { $html[] = "$name=\"$value\""; } return implode(' ', $html); }
php
protected function formatAttributes() { $this->attributes['class'] = implode(' ', $this->classes); $html = ''; foreach ($this->attributes as $name => $value) { $html[] = "$name=\"$value\""; } return implode(' ', $html); }
[ "protected", "function", "formatAttributes", "(", ")", "{", "$", "this", "->", "attributes", "[", "'class'", "]", "=", "implode", "(", "' '", ",", "$", "this", "->", "classes", ")", ";", "$", "html", "=", "''", ";", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "html", "[", "]", "=", "\"$name=\\\"$value\\\"\"", ";", "}", "return", "implode", "(", "' '", ",", "$", "html", ")", ";", "}" ]
Format icon classes. @return string
[ "Format", "icon", "classes", "." ]
6afb2e638033a53020ed69e683d9063cf374287a
https://github.com/z-song/easy-fa/blob/6afb2e638033a53020ed69e683d9063cf374287a/src/FontAwesome.php#L291-L302
232,135
axypro/sourcemap
SourceMap.php
SourceMap.save
public function save($filename = null, $jsonFlag = JSON_UNESCAPED_SLASHES) { if ($filename === null) { if ($this->outFileName === null) { throw new OutFileNotSpecified(); } $filename = $this->outFileName; } IO::saveJSON($this->getData(), $filename, $jsonFlag); $this->outFileName = $filename; }
php
public function save($filename = null, $jsonFlag = JSON_UNESCAPED_SLASHES) { if ($filename === null) { if ($this->outFileName === null) { throw new OutFileNotSpecified(); } $filename = $this->outFileName; } IO::saveJSON($this->getData(), $filename, $jsonFlag); $this->outFileName = $filename; }
[ "public", "function", "save", "(", "$", "filename", "=", "null", ",", "$", "jsonFlag", "=", "JSON_UNESCAPED_SLASHES", ")", "{", "if", "(", "$", "filename", "===", "null", ")", "{", "if", "(", "$", "this", "->", "outFileName", "===", "null", ")", "{", "throw", "new", "OutFileNotSpecified", "(", ")", ";", "}", "$", "filename", "=", "$", "this", "->", "outFileName", ";", "}", "IO", "::", "saveJSON", "(", "$", "this", "->", "getData", "(", ")", ",", "$", "filename", ",", "$", "jsonFlag", ")", ";", "$", "this", "->", "outFileName", "=", "$", "filename", ";", "}" ]
Saves the map file @link https://github.com/axypro/sourcemap/blob/master/doc/common.md documentation @param string $filename [optional] the map file name (by default used outFileName) @param int $jsonFlag [optional] @throws \axy\sourcemap\errors\IOError @throws \axy\sourcemap\errors\OutFileNotSpecified
[ "Saves", "the", "map", "file" ]
f5793e5d166bf2a1735e27676007a21c121e20af
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/SourceMap.php#L47-L57
232,136
axypro/sourcemap
SourceMap.php
SourceMap.addPosition
public function addPosition($position) { $position = PosBuilder::build($position); $generated = $position->generated; $source = $position->source; if ($generated->line === null) { throw new IncompleteData('required generated line number'); } if ($generated->column === null) { throw new IncompleteData('required generated column number'); } if ($this->sources->fillSource($source)) { if ($source->line === null) { throw new IncompleteData('required source line number'); } if ($source->column === null) { throw new IncompleteData('required source column number'); } $this->names->fillSource($source); } $this->context->getMappings()->addPosition($position); return $position; }
php
public function addPosition($position) { $position = PosBuilder::build($position); $generated = $position->generated; $source = $position->source; if ($generated->line === null) { throw new IncompleteData('required generated line number'); } if ($generated->column === null) { throw new IncompleteData('required generated column number'); } if ($this->sources->fillSource($source)) { if ($source->line === null) { throw new IncompleteData('required source line number'); } if ($source->column === null) { throw new IncompleteData('required source column number'); } $this->names->fillSource($source); } $this->context->getMappings()->addPosition($position); return $position; }
[ "public", "function", "addPosition", "(", "$", "position", ")", "{", "$", "position", "=", "PosBuilder", "::", "build", "(", "$", "position", ")", ";", "$", "generated", "=", "$", "position", "->", "generated", ";", "$", "source", "=", "$", "position", "->", "source", ";", "if", "(", "$", "generated", "->", "line", "===", "null", ")", "{", "throw", "new", "IncompleteData", "(", "'required generated line number'", ")", ";", "}", "if", "(", "$", "generated", "->", "column", "===", "null", ")", "{", "throw", "new", "IncompleteData", "(", "'required generated column number'", ")", ";", "}", "if", "(", "$", "this", "->", "sources", "->", "fillSource", "(", "$", "source", ")", ")", "{", "if", "(", "$", "source", "->", "line", "===", "null", ")", "{", "throw", "new", "IncompleteData", "(", "'required source line number'", ")", ";", "}", "if", "(", "$", "source", "->", "column", "===", "null", ")", "{", "throw", "new", "IncompleteData", "(", "'required source column number'", ")", ";", "}", "$", "this", "->", "names", "->", "fillSource", "(", "$", "source", ")", ";", "}", "$", "this", "->", "context", "->", "getMappings", "(", ")", "->", "addPosition", "(", "$", "position", ")", ";", "return", "$", "position", ";", "}" ]
Adds a position to the source map @link https://github.com/axypro/sourcemap/blob/master/doc/build.md documentation @param \axy\sourcemap\PosMap|array|object $position @return \axy\sourcemap\PosMap @throws \axy\sourcemap\errors\InvalidIndexed @throws \axy\sourcemap\errors\IncompleteData
[ "Adds", "a", "position", "to", "the", "source", "map" ]
f5793e5d166bf2a1735e27676007a21c121e20af
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/SourceMap.php#L130-L152
232,137
axypro/sourcemap
SourceMap.php
SourceMap.merge
public function merge($map, $file = null) { $map = MapBuilder::build($map); if ($file === null) { $file = $map->file; } $sourceIndex = $this->sources->getIndexByName($file); if ($sourceIndex === null) { return false; } $mSources = []; $oSources = $map->sources->getNames(); if (!empty($oSources)) { foreach ($oSources as $index => $name) { if ($index === 0) { $this->sources->rename($sourceIndex, $name); if ($index !== $sourceIndex) { $mSources[$index] = $sourceIndex; } } else { $nIndex = $this->sources->add($name); if ($nIndex !== $index) { $mSources[$index] = $nIndex; } } } } $mNames = []; foreach ($map->names->getNames() as $index => $name) { $nIndex = $this->names->add($name); if ($nIndex !== $index) { $mNames[$index] = $nIndex; } } $this->context->getMappings()->merge($map->context->getMappings(), $sourceIndex, $mSources, $mNames); return true; }
php
public function merge($map, $file = null) { $map = MapBuilder::build($map); if ($file === null) { $file = $map->file; } $sourceIndex = $this->sources->getIndexByName($file); if ($sourceIndex === null) { return false; } $mSources = []; $oSources = $map->sources->getNames(); if (!empty($oSources)) { foreach ($oSources as $index => $name) { if ($index === 0) { $this->sources->rename($sourceIndex, $name); if ($index !== $sourceIndex) { $mSources[$index] = $sourceIndex; } } else { $nIndex = $this->sources->add($name); if ($nIndex !== $index) { $mSources[$index] = $nIndex; } } } } $mNames = []; foreach ($map->names->getNames() as $index => $name) { $nIndex = $this->names->add($name); if ($nIndex !== $index) { $mNames[$index] = $nIndex; } } $this->context->getMappings()->merge($map->context->getMappings(), $sourceIndex, $mSources, $mNames); return true; }
[ "public", "function", "merge", "(", "$", "map", ",", "$", "file", "=", "null", ")", "{", "$", "map", "=", "MapBuilder", "::", "build", "(", "$", "map", ")", ";", "if", "(", "$", "file", "===", "null", ")", "{", "$", "file", "=", "$", "map", "->", "file", ";", "}", "$", "sourceIndex", "=", "$", "this", "->", "sources", "->", "getIndexByName", "(", "$", "file", ")", ";", "if", "(", "$", "sourceIndex", "===", "null", ")", "{", "return", "false", ";", "}", "$", "mSources", "=", "[", "]", ";", "$", "oSources", "=", "$", "map", "->", "sources", "->", "getNames", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "oSources", ")", ")", "{", "foreach", "(", "$", "oSources", "as", "$", "index", "=>", "$", "name", ")", "{", "if", "(", "$", "index", "===", "0", ")", "{", "$", "this", "->", "sources", "->", "rename", "(", "$", "sourceIndex", ",", "$", "name", ")", ";", "if", "(", "$", "index", "!==", "$", "sourceIndex", ")", "{", "$", "mSources", "[", "$", "index", "]", "=", "$", "sourceIndex", ";", "}", "}", "else", "{", "$", "nIndex", "=", "$", "this", "->", "sources", "->", "add", "(", "$", "name", ")", ";", "if", "(", "$", "nIndex", "!==", "$", "index", ")", "{", "$", "mSources", "[", "$", "index", "]", "=", "$", "nIndex", ";", "}", "}", "}", "}", "$", "mNames", "=", "[", "]", ";", "foreach", "(", "$", "map", "->", "names", "->", "getNames", "(", ")", "as", "$", "index", "=>", "$", "name", ")", "{", "$", "nIndex", "=", "$", "this", "->", "names", "->", "add", "(", "$", "name", ")", ";", "if", "(", "$", "nIndex", "!==", "$", "index", ")", "{", "$", "mNames", "[", "$", "index", "]", "=", "$", "nIndex", ";", "}", "}", "$", "this", "->", "context", "->", "getMappings", "(", ")", "->", "merge", "(", "$", "map", "->", "context", "->", "getMappings", "(", ")", ",", "$", "sourceIndex", ",", "$", "mSources", ",", "$", "mNames", ")", ";", "return", "true", ";", "}" ]
Merges a map to the current map @link https://github.com/axypro/sourcemap/blob/master/doc/merge.md documentation @param \axy\sourcemap\SourceMap|array|string $map the other map (an instance, a data array or a file name) @param string $file [optional] file name in current sources (by default "file" from $map) @return bool @throws \axy\sourcemap\errors\IOError @throws \axy\sourcemap\errors\InvalidFormat @throws \InvalidArgumentException
[ "Merges", "a", "map", "to", "the", "current", "map" ]
f5793e5d166bf2a1735e27676007a21c121e20af
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/SourceMap.php#L242-L278
232,138
axypro/sourcemap
SourceMap.php
SourceMap.optimize
public function optimize() { $changed = false; $stat = $this->context->getMappings()->getStat(); $sources = array_keys(array_diff_key($this->sources->getNames(), $stat['sources'])); $names = array_keys(array_diff_key($this->names->getNames(), $stat['names'])); if (!empty($sources)) { $changed = true; rsort($sources); foreach ($sources as $index) { $this->sources->remove($index); } } if (!empty($names)) { $changed = true; foreach ($names as $index) { $this->names->remove($index); } } return $changed; }
php
public function optimize() { $changed = false; $stat = $this->context->getMappings()->getStat(); $sources = array_keys(array_diff_key($this->sources->getNames(), $stat['sources'])); $names = array_keys(array_diff_key($this->names->getNames(), $stat['names'])); if (!empty($sources)) { $changed = true; rsort($sources); foreach ($sources as $index) { $this->sources->remove($index); } } if (!empty($names)) { $changed = true; foreach ($names as $index) { $this->names->remove($index); } } return $changed; }
[ "public", "function", "optimize", "(", ")", "{", "$", "changed", "=", "false", ";", "$", "stat", "=", "$", "this", "->", "context", "->", "getMappings", "(", ")", "->", "getStat", "(", ")", ";", "$", "sources", "=", "array_keys", "(", "array_diff_key", "(", "$", "this", "->", "sources", "->", "getNames", "(", ")", ",", "$", "stat", "[", "'sources'", "]", ")", ")", ";", "$", "names", "=", "array_keys", "(", "array_diff_key", "(", "$", "this", "->", "names", "->", "getNames", "(", ")", ",", "$", "stat", "[", "'names'", "]", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "sources", ")", ")", "{", "$", "changed", "=", "true", ";", "rsort", "(", "$", "sources", ")", ";", "foreach", "(", "$", "sources", "as", "$", "index", ")", "{", "$", "this", "->", "sources", "->", "remove", "(", "$", "index", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "names", ")", ")", "{", "$", "changed", "=", "true", ";", "foreach", "(", "$", "names", "as", "$", "index", ")", "{", "$", "this", "->", "names", "->", "remove", "(", "$", "index", ")", ";", "}", "}", "return", "$", "changed", ";", "}" ]
Optimizes the data @return bool
[ "Optimizes", "the", "data" ]
f5793e5d166bf2a1735e27676007a21c121e20af
https://github.com/axypro/sourcemap/blob/f5793e5d166bf2a1735e27676007a21c121e20af/SourceMap.php#L285-L305
232,139
Speicher210/Reflection
src/ReflectionConstant.php
ReflectionConstant.export
public static function export($className, $constantName, $return = false) { $export = new self($className, $constantName); $export = (string)$export; if ($return === true) { return $export; } else { echo $export; return null; } }
php
public static function export($className, $constantName, $return = false) { $export = new self($className, $constantName); $export = (string)$export; if ($return === true) { return $export; } else { echo $export; return null; } }
[ "public", "static", "function", "export", "(", "$", "className", ",", "$", "constantName", ",", "$", "return", "=", "false", ")", "{", "$", "export", "=", "new", "self", "(", "$", "className", ",", "$", "constantName", ")", ";", "$", "export", "=", "(", "string", ")", "$", "export", ";", "if", "(", "$", "return", "===", "true", ")", "{", "return", "$", "export", ";", "}", "else", "{", "echo", "$", "export", ";", "return", "null", ";", "}", "}" ]
Export the current constant reflection. @param string $className The class name where the constant is defined. @param string $constantName The name of the constant. @param boolean $return Flag if the export should be returned or not. @return string
[ "Export", "the", "current", "constant", "reflection", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionConstant.php#L85-L96
232,140
Speicher210/Reflection
src/ReflectionConstant.php
ReflectionConstant.getDocComment
public function getDocComment() { $fileName = $this->getDeclaringClass()->getFileName(); if ($fileName === false) { return false; } else { return $this->getDocCommentFromFile($fileName); } }
php
public function getDocComment() { $fileName = $this->getDeclaringClass()->getFileName(); if ($fileName === false) { return false; } else { return $this->getDocCommentFromFile($fileName); } }
[ "public", "function", "getDocComment", "(", ")", "{", "$", "fileName", "=", "$", "this", "->", "getDeclaringClass", "(", ")", "->", "getFileName", "(", ")", ";", "if", "(", "$", "fileName", "===", "false", ")", "{", "return", "false", ";", "}", "else", "{", "return", "$", "this", "->", "getDocCommentFromFile", "(", "$", "fileName", ")", ";", "}", "}" ]
Return the string containing the current constant comment or false if there's no comment. @return string
[ "Return", "the", "string", "containing", "the", "current", "constant", "comment", "or", "false", "if", "there", "s", "no", "comment", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionConstant.php#L113-L121
232,141
Speicher210/Reflection
src/ReflectionConstant.php
ReflectionConstant.getDocCommentFromFile
private function getDocCommentFromFile($fileName) { $lines = file($fileName, FILE_IGNORE_NEW_LINES); $declaringClassStartLine = $this->getDeclaringClass()->getStartLine() - 1; $declaringClassLength = $this->getDeclaringClass()->getEndLine() - $declaringClassStartLine + 1; $currentClassLines = array_slice($lines, $declaringClassStartLine, $declaringClassLength, true); // Need the php open tag to tokenize the class. $tokens = token_get_all("<?php\n" . implode("\n", $currentClassLines)); $return = false; $constDeclarationKey = $this->getCurrentConstantKeyFromClassTokens($tokens); // Now we have the key value of the constant declaration, we have to pick up the comment before the declaration (if it exists). for ($constDeclarationKey--; $constDeclarationKey > 0; $constDeclarationKey--) { if ($tokens[$constDeclarationKey][0] !== T_WHITESPACE && $tokens[$constDeclarationKey][0] !== T_DOC_COMMENT) { break; } elseif ($tokens[$constDeclarationKey][0] === T_DOC_COMMENT) { $return = $tokens[$constDeclarationKey][1]; break; } } return $return; }
php
private function getDocCommentFromFile($fileName) { $lines = file($fileName, FILE_IGNORE_NEW_LINES); $declaringClassStartLine = $this->getDeclaringClass()->getStartLine() - 1; $declaringClassLength = $this->getDeclaringClass()->getEndLine() - $declaringClassStartLine + 1; $currentClassLines = array_slice($lines, $declaringClassStartLine, $declaringClassLength, true); // Need the php open tag to tokenize the class. $tokens = token_get_all("<?php\n" . implode("\n", $currentClassLines)); $return = false; $constDeclarationKey = $this->getCurrentConstantKeyFromClassTokens($tokens); // Now we have the key value of the constant declaration, we have to pick up the comment before the declaration (if it exists). for ($constDeclarationKey--; $constDeclarationKey > 0; $constDeclarationKey--) { if ($tokens[$constDeclarationKey][0] !== T_WHITESPACE && $tokens[$constDeclarationKey][0] !== T_DOC_COMMENT) { break; } elseif ($tokens[$constDeclarationKey][0] === T_DOC_COMMENT) { $return = $tokens[$constDeclarationKey][1]; break; } } return $return; }
[ "private", "function", "getDocCommentFromFile", "(", "$", "fileName", ")", "{", "$", "lines", "=", "file", "(", "$", "fileName", ",", "FILE_IGNORE_NEW_LINES", ")", ";", "$", "declaringClassStartLine", "=", "$", "this", "->", "getDeclaringClass", "(", ")", "->", "getStartLine", "(", ")", "-", "1", ";", "$", "declaringClassLength", "=", "$", "this", "->", "getDeclaringClass", "(", ")", "->", "getEndLine", "(", ")", "-", "$", "declaringClassStartLine", "+", "1", ";", "$", "currentClassLines", "=", "array_slice", "(", "$", "lines", ",", "$", "declaringClassStartLine", ",", "$", "declaringClassLength", ",", "true", ")", ";", "// Need the php open tag to tokenize the class.", "$", "tokens", "=", "token_get_all", "(", "\"<?php\\n\"", ".", "implode", "(", "\"\\n\"", ",", "$", "currentClassLines", ")", ")", ";", "$", "return", "=", "false", ";", "$", "constDeclarationKey", "=", "$", "this", "->", "getCurrentConstantKeyFromClassTokens", "(", "$", "tokens", ")", ";", "// Now we have the key value of the constant declaration, we have to pick up the comment before the declaration (if it exists).", "for", "(", "$", "constDeclarationKey", "--", ";", "$", "constDeclarationKey", ">", "0", ";", "$", "constDeclarationKey", "--", ")", "{", "if", "(", "$", "tokens", "[", "$", "constDeclarationKey", "]", "[", "0", "]", "!==", "T_WHITESPACE", "&&", "$", "tokens", "[", "$", "constDeclarationKey", "]", "[", "0", "]", "!==", "T_DOC_COMMENT", ")", "{", "break", ";", "}", "elseif", "(", "$", "tokens", "[", "$", "constDeclarationKey", "]", "[", "0", "]", "===", "T_DOC_COMMENT", ")", "{", "$", "return", "=", "$", "tokens", "[", "$", "constDeclarationKey", "]", "[", "1", "]", ";", "break", ";", "}", "}", "return", "$", "return", ";", "}" ]
Returns the doc comment from an existing filename or false if empty. @param string $fileName an existing filename @return string
[ "Returns", "the", "doc", "comment", "from", "an", "existing", "filename", "or", "false", "if", "empty", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionConstant.php#L129-L155
232,142
Speicher210/Reflection
src/ReflectionConstant.php
ReflectionConstant.getCurrentConstantKeyFromClassTokens
private function getCurrentConstantKeyFromClassTokens($tokens) { $parsingStateConstDeclarationFound = false; $constDeclarationKey = 0; foreach ($tokens as $key => $token) { if (is_array($token) === true && $token[0] === T_CONST) { $parsingStateConstDeclarationFound = true; $constDeclarationKey = $key; } if ($parsingStateConstDeclarationFound === true && $token[0] === T_STRING) { if ($token[1] === $this->getName()) { break; } else { $parsingStateConstDeclarationFound = false; } } } return $constDeclarationKey; }
php
private function getCurrentConstantKeyFromClassTokens($tokens) { $parsingStateConstDeclarationFound = false; $constDeclarationKey = 0; foreach ($tokens as $key => $token) { if (is_array($token) === true && $token[0] === T_CONST) { $parsingStateConstDeclarationFound = true; $constDeclarationKey = $key; } if ($parsingStateConstDeclarationFound === true && $token[0] === T_STRING) { if ($token[1] === $this->getName()) { break; } else { $parsingStateConstDeclarationFound = false; } } } return $constDeclarationKey; }
[ "private", "function", "getCurrentConstantKeyFromClassTokens", "(", "$", "tokens", ")", "{", "$", "parsingStateConstDeclarationFound", "=", "false", ";", "$", "constDeclarationKey", "=", "0", ";", "foreach", "(", "$", "tokens", "as", "$", "key", "=>", "$", "token", ")", "{", "if", "(", "is_array", "(", "$", "token", ")", "===", "true", "&&", "$", "token", "[", "0", "]", "===", "T_CONST", ")", "{", "$", "parsingStateConstDeclarationFound", "=", "true", ";", "$", "constDeclarationKey", "=", "$", "key", ";", "}", "if", "(", "$", "parsingStateConstDeclarationFound", "===", "true", "&&", "$", "token", "[", "0", "]", "===", "T_STRING", ")", "{", "if", "(", "$", "token", "[", "1", "]", "===", "$", "this", "->", "getName", "(", ")", ")", "{", "break", ";", "}", "else", "{", "$", "parsingStateConstDeclarationFound", "=", "false", ";", "}", "}", "}", "return", "$", "constDeclarationKey", ";", "}" ]
Returns the current constant declaration key in the list of given tokens. Returns 0 if not found. @param array $tokens the array of tokens (see http://www.php.net/manual/en/ref.tokenizer.php) @return int
[ "Returns", "the", "current", "constant", "declaration", "key", "in", "the", "list", "of", "given", "tokens", ".", "Returns", "0", "if", "not", "found", "." ]
3d0f5033077b6a3f47cebbeded6538caeb0a1909
https://github.com/Speicher210/Reflection/blob/3d0f5033077b6a3f47cebbeded6538caeb0a1909/src/ReflectionConstant.php#L163-L184
232,143
youngguns-nl/moneybird_php_api
SimpleXMLElement.php
SimpleXMLElement.addCData
protected function addCData($cdata_text) { $node = dom_import_simplexml($this); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($cdata_text)); }
php
protected function addCData($cdata_text) { $node = dom_import_simplexml($this); $no = $node->ownerDocument; $node->appendChild($no->createCDATASection($cdata_text)); }
[ "protected", "function", "addCData", "(", "$", "cdata_text", ")", "{", "$", "node", "=", "dom_import_simplexml", "(", "$", "this", ")", ";", "$", "no", "=", "$", "node", "->", "ownerDocument", ";", "$", "node", "->", "appendChild", "(", "$", "no", "->", "createCDATASection", "(", "$", "cdata_text", ")", ")", ";", "}" ]
Add CDATA text in a node @param string $cdata_text The CDATA value to add
[ "Add", "CDATA", "text", "in", "a", "node" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/SimpleXMLElement.php#L19-L24
232,144
youngguns-nl/moneybird_php_api
SimpleXMLElement.php
SimpleXMLElement.addChild
public function addChild($key, $value = null, $namespace = null) { return parent::addChild($key, htmlspecialchars($value), $namespace); }
php
public function addChild($key, $value = null, $namespace = null) { return parent::addChild($key, htmlspecialchars($value), $namespace); }
[ "public", "function", "addChild", "(", "$", "key", ",", "$", "value", "=", "null", ",", "$", "namespace", "=", "null", ")", "{", "return", "parent", "::", "addChild", "(", "$", "key", ",", "htmlspecialchars", "(", "$", "value", ")", ",", "$", "namespace", ")", ";", "}" ]
Adds a child element to the XML node @param string $name The name of the child element to add. @param string $value [optional] If specified, the value of the child element. @param string $namespace [optional] If specified, the namespace to which the child element belongs. @return SimpleXMLElement The addChild method returns a SimpleXMLElement object representing the child added to the XML node.
[ "Adds", "a", "child", "element", "to", "the", "XML", "node" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/SimpleXMLElement.php#L44-L47
232,145
youngguns-nl/moneybird_php_api
SimpleXMLElement.php
SimpleXMLElement.appendXML
public function appendXML(SimpleXMLElement $append) { if (strlen(trim((string) $append)) == 0) { $xml = $this->addChild($append->getName()); foreach ($append->children() as $child) { $xml->appendXML($child); } } else { $xml = $this->addChild($append->getName(), (string) $append); } foreach ($append->attributes() as $n => $v) { $xml->addAttribute($n, $v); } }
php
public function appendXML(SimpleXMLElement $append) { if (strlen(trim((string) $append)) == 0) { $xml = $this->addChild($append->getName()); foreach ($append->children() as $child) { $xml->appendXML($child); } } else { $xml = $this->addChild($append->getName(), (string) $append); } foreach ($append->attributes() as $n => $v) { $xml->addAttribute($n, $v); } }
[ "public", "function", "appendXML", "(", "SimpleXMLElement", "$", "append", ")", "{", "if", "(", "strlen", "(", "trim", "(", "(", "string", ")", "$", "append", ")", ")", "==", "0", ")", "{", "$", "xml", "=", "$", "this", "->", "addChild", "(", "$", "append", "->", "getName", "(", ")", ")", ";", "foreach", "(", "$", "append", "->", "children", "(", ")", "as", "$", "child", ")", "{", "$", "xml", "->", "appendXML", "(", "$", "child", ")", ";", "}", "}", "else", "{", "$", "xml", "=", "$", "this", "->", "addChild", "(", "$", "append", "->", "getName", "(", ")", ",", "(", "string", ")", "$", "append", ")", ";", "}", "foreach", "(", "$", "append", "->", "attributes", "(", ")", "as", "$", "n", "=>", "$", "v", ")", "{", "$", "xml", "->", "addAttribute", "(", "$", "n", ",", "$", "v", ")", ";", "}", "}" ]
Add SimpleXMLElement code into a SimpleXMLElement @param SimpleXMLElement $append
[ "Add", "SimpleXMLElement", "code", "into", "a", "SimpleXMLElement" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/SimpleXMLElement.php#L53-L66
232,146
iwyg/jitimage
src/Thapp/JitImage/Driver/ImDriver.php
ImDriver.compile
private function compile() { $commands = array_keys($this->commands); $values = $this->getArrayValues(array_values($this->commands)); $origSource = $this->source; $vs = '%s'; $bin = $this->converter; $type = preg_replace('#^image/#', null, $this->getInfo('type')); $this->tmpFile = $this->getTempFile(); if ($this->isMultipartImage()) { $this->intermediate = $this->getTempFile($type); $this->source = $this->intermediate; } array_unshift($values, sprintf('%s:%s', $type, escapeshellarg($this->source))); array_unshift($values, $bin); array_unshift($commands, $vs); array_unshift($commands, $vs); if ($this->isMultipartImage()) { array_unshift( $values, sprintf( '%s %s:%s -coalesce %s %s', $this->converter, $type, $origSource, $this->intermediate, PHP_EOL ) ); array_unshift($commands, $vs); } array_push($values, sprintf('%s:%s', $this->getOutputType(), $this->tmpFile)); array_push($commands, $vs); $cmd = implode(' ', $commands); $this->source = $origSource; return vsprintf($cmd, $values); }
php
private function compile() { $commands = array_keys($this->commands); $values = $this->getArrayValues(array_values($this->commands)); $origSource = $this->source; $vs = '%s'; $bin = $this->converter; $type = preg_replace('#^image/#', null, $this->getInfo('type')); $this->tmpFile = $this->getTempFile(); if ($this->isMultipartImage()) { $this->intermediate = $this->getTempFile($type); $this->source = $this->intermediate; } array_unshift($values, sprintf('%s:%s', $type, escapeshellarg($this->source))); array_unshift($values, $bin); array_unshift($commands, $vs); array_unshift($commands, $vs); if ($this->isMultipartImage()) { array_unshift( $values, sprintf( '%s %s:%s -coalesce %s %s', $this->converter, $type, $origSource, $this->intermediate, PHP_EOL ) ); array_unshift($commands, $vs); } array_push($values, sprintf('%s:%s', $this->getOutputType(), $this->tmpFile)); array_push($commands, $vs); $cmd = implode(' ', $commands); $this->source = $origSource; return vsprintf($cmd, $values); }
[ "private", "function", "compile", "(", ")", "{", "$", "commands", "=", "array_keys", "(", "$", "this", "->", "commands", ")", ";", "$", "values", "=", "$", "this", "->", "getArrayValues", "(", "array_values", "(", "$", "this", "->", "commands", ")", ")", ";", "$", "origSource", "=", "$", "this", "->", "source", ";", "$", "vs", "=", "'%s'", ";", "$", "bin", "=", "$", "this", "->", "converter", ";", "$", "type", "=", "preg_replace", "(", "'#^image/#'", ",", "null", ",", "$", "this", "->", "getInfo", "(", "'type'", ")", ")", ";", "$", "this", "->", "tmpFile", "=", "$", "this", "->", "getTempFile", "(", ")", ";", "if", "(", "$", "this", "->", "isMultipartImage", "(", ")", ")", "{", "$", "this", "->", "intermediate", "=", "$", "this", "->", "getTempFile", "(", "$", "type", ")", ";", "$", "this", "->", "source", "=", "$", "this", "->", "intermediate", ";", "}", "array_unshift", "(", "$", "values", ",", "sprintf", "(", "'%s:%s'", ",", "$", "type", ",", "escapeshellarg", "(", "$", "this", "->", "source", ")", ")", ")", ";", "array_unshift", "(", "$", "values", ",", "$", "bin", ")", ";", "array_unshift", "(", "$", "commands", ",", "$", "vs", ")", ";", "array_unshift", "(", "$", "commands", ",", "$", "vs", ")", ";", "if", "(", "$", "this", "->", "isMultipartImage", "(", ")", ")", "{", "array_unshift", "(", "$", "values", ",", "sprintf", "(", "'%s %s:%s -coalesce %s %s'", ",", "$", "this", "->", "converter", ",", "$", "type", ",", "$", "origSource", ",", "$", "this", "->", "intermediate", ",", "PHP_EOL", ")", ")", ";", "array_unshift", "(", "$", "commands", ",", "$", "vs", ")", ";", "}", "array_push", "(", "$", "values", ",", "sprintf", "(", "'%s:%s'", ",", "$", "this", "->", "getOutputType", "(", ")", ",", "$", "this", "->", "tmpFile", ")", ")", ";", "array_push", "(", "$", "commands", ",", "$", "vs", ")", ";", "$", "cmd", "=", "implode", "(", "' '", ",", "$", "commands", ")", ";", "$", "this", "->", "source", "=", "$", "origSource", ";", "return", "vsprintf", "(", "$", "cmd", ",", "$", "values", ")", ";", "}" ]
compile the convert command @access protected @return string the compiled command
[ "compile", "the", "convert", "command" ]
25300cc5bb17835634ec60d71f5ac2ba870abbe4
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/Driver/ImDriver.php#L431-L482
232,147
funivan/PhpTokenizer
src/Token.php
Token.remove
public function remove() : self { $this->type = static::INVALID_TYPE; $this->value = static::INVALID_VALUE; $this->line = static::INVALID_LINE; $this->index = static::INVALID_INDEX; return $this; }
php
public function remove() : self { $this->type = static::INVALID_TYPE; $this->value = static::INVALID_VALUE; $this->line = static::INVALID_LINE; $this->index = static::INVALID_INDEX; return $this; }
[ "public", "function", "remove", "(", ")", ":", "self", "{", "$", "this", "->", "type", "=", "static", "::", "INVALID_TYPE", ";", "$", "this", "->", "value", "=", "static", "::", "INVALID_VALUE", ";", "$", "this", "->", "line", "=", "static", "::", "INVALID_LINE", ";", "$", "this", "->", "index", "=", "static", "::", "INVALID_INDEX", ";", "return", "$", "this", ";", "}" ]
Remove all data from token so this token become invalid @return $this
[ "Remove", "all", "data", "from", "token", "so", "this", "token", "become", "invalid" ]
f31ec8f1440708518c2a785b3f129f130621e966
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/Token.php#L198-L204
232,148
funivan/PhpTokenizer
src/Token.php
Token.appendToValue
public function appendToValue($part) : self { if (!is_string($part) and !is_numeric($part)) { throw new InvalidArgumentException('You can append only string to value'); } $this->value .= $part; return $this; }
php
public function appendToValue($part) : self { if (!is_string($part) and !is_numeric($part)) { throw new InvalidArgumentException('You can append only string to value'); } $this->value .= $part; return $this; }
[ "public", "function", "appendToValue", "(", "$", "part", ")", ":", "self", "{", "if", "(", "!", "is_string", "(", "$", "part", ")", "and", "!", "is_numeric", "(", "$", "part", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'You can append only string to value'", ")", ";", "}", "$", "this", "->", "value", ".=", "$", "part", ";", "return", "$", "this", ";", "}" ]
Add part to the end of value @param string $part @return $this @throws Exception
[ "Add", "part", "to", "the", "end", "of", "value" ]
f31ec8f1440708518c2a785b3f129f130621e966
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/Token.php#L214-L223
232,149
funivan/PhpTokenizer
src/Token.php
Token.prependToValue
public function prependToValue($part) : self { if (!is_string($part) and !is_numeric($part)) { throw new InvalidArgumentException('You can prepend only string to value'); } $this->value = $part . $this->value; return $this; }
php
public function prependToValue($part) : self { if (!is_string($part) and !is_numeric($part)) { throw new InvalidArgumentException('You can prepend only string to value'); } $this->value = $part . $this->value; return $this; }
[ "public", "function", "prependToValue", "(", "$", "part", ")", ":", "self", "{", "if", "(", "!", "is_string", "(", "$", "part", ")", "and", "!", "is_numeric", "(", "$", "part", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'You can prepend only string to value'", ")", ";", "}", "$", "this", "->", "value", "=", "$", "part", ".", "$", "this", "->", "value", ";", "return", "$", "this", ";", "}" ]
Add part to the begin of value @param string $part @return $this @throws Exception
[ "Add", "part", "to", "the", "begin", "of", "value" ]
f31ec8f1440708518c2a785b3f129f130621e966
https://github.com/funivan/PhpTokenizer/blob/f31ec8f1440708518c2a785b3f129f130621e966/src/Token.php#L233-L242
232,150
youngguns-nl/moneybird_php_api
JsonMapper.php
JsonMapper.fromJson
public function fromJson(Array $jsonArray) { $classname = $this->jsonKeyToClassname(key($jsonArray)); $jsonArray = current($jsonArray); if (!is_null($classname)) { $return = new $classname(); if ($return instanceof ArrayObject) { foreach ($jsonArray as $child) { $return->append($this->fromJson($child)); } } else { $objectData = array(); foreach ($jsonArray as $key => $child) { $key = $this->keyToProperty($key); if (isset($objectData[$key])) { if (!is_array($objectData[$key])) { $objectData[$key] = array($objectData[$key]); } $objectData[$key][] = $this->fromJson(array($key => $child)); } else { $objectData[$key] = $this->fromJson(array($key => $child)); } } $return = new $classname($objectData); } } else { $return = $jsonArray; } return $return; }
php
public function fromJson(Array $jsonArray) { $classname = $this->jsonKeyToClassname(key($jsonArray)); $jsonArray = current($jsonArray); if (!is_null($classname)) { $return = new $classname(); if ($return instanceof ArrayObject) { foreach ($jsonArray as $child) { $return->append($this->fromJson($child)); } } else { $objectData = array(); foreach ($jsonArray as $key => $child) { $key = $this->keyToProperty($key); if (isset($objectData[$key])) { if (!is_array($objectData[$key])) { $objectData[$key] = array($objectData[$key]); } $objectData[$key][] = $this->fromJson(array($key => $child)); } else { $objectData[$key] = $this->fromJson(array($key => $child)); } } $return = new $classname($objectData); } } else { $return = $jsonArray; } return $return; }
[ "public", "function", "fromJson", "(", "Array", "$", "jsonArray", ")", "{", "$", "classname", "=", "$", "this", "->", "jsonKeyToClassname", "(", "key", "(", "$", "jsonArray", ")", ")", ";", "$", "jsonArray", "=", "current", "(", "$", "jsonArray", ")", ";", "if", "(", "!", "is_null", "(", "$", "classname", ")", ")", "{", "$", "return", "=", "new", "$", "classname", "(", ")", ";", "if", "(", "$", "return", "instanceof", "ArrayObject", ")", "{", "foreach", "(", "$", "jsonArray", "as", "$", "child", ")", "{", "$", "return", "->", "append", "(", "$", "this", "->", "fromJson", "(", "$", "child", ")", ")", ";", "}", "}", "else", "{", "$", "objectData", "=", "array", "(", ")", ";", "foreach", "(", "$", "jsonArray", "as", "$", "key", "=>", "$", "child", ")", "{", "$", "key", "=", "$", "this", "->", "keyToProperty", "(", "$", "key", ")", ";", "if", "(", "isset", "(", "$", "objectData", "[", "$", "key", "]", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "objectData", "[", "$", "key", "]", ")", ")", "{", "$", "objectData", "[", "$", "key", "]", "=", "array", "(", "$", "objectData", "[", "$", "key", "]", ")", ";", "}", "$", "objectData", "[", "$", "key", "]", "[", "]", "=", "$", "this", "->", "fromJson", "(", "array", "(", "$", "key", "=>", "$", "child", ")", ")", ";", "}", "else", "{", "$", "objectData", "[", "$", "key", "]", "=", "$", "this", "->", "fromJson", "(", "array", "(", "$", "key", "=>", "$", "child", ")", ")", ";", "}", "}", "$", "return", "=", "new", "$", "classname", "(", "$", "objectData", ")", ";", "}", "}", "else", "{", "$", "return", "=", "$", "jsonArray", ";", "}", "return", "$", "return", ";", "}" ]
Create object from json @param @access public
[ "Create", "object", "from", "json" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/JsonMapper.php#L129-L159
232,151
youngguns-nl/moneybird_php_api
JsonMapper.php
JsonMapper.jsonKeyToClassname
protected function jsonKeyToClassname($jsonKey) { if (isset($this->objectMapper[$jsonKey])) { return $this->objectMapper[$jsonKey]; } return null; }
php
protected function jsonKeyToClassname($jsonKey) { if (isset($this->objectMapper[$jsonKey])) { return $this->objectMapper[$jsonKey]; } return null; }
[ "protected", "function", "jsonKeyToClassname", "(", "$", "jsonKey", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "objectMapper", "[", "$", "jsonKey", "]", ")", ")", "{", "return", "$", "this", "->", "objectMapper", "[", "$", "jsonKey", "]", ";", "}", "return", "null", ";", "}" ]
Map key to classname @param string $jsonKey @return string @access protected
[ "Map", "key", "to", "classname" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/JsonMapper.php#L167-L173
232,152
youngguns-nl/moneybird_php_api
JsonMapper.php
JsonMapper.mapObjectToElementName
protected function mapObjectToElementName(Mapper_Mapable $subject) { // Pick a default value based on the subject class $name = substr(get_class($subject), strlen(__NAMESPACE__) + 1); // See if the objectMapper array contains the (super)class foreach ($this->objectMapper as $key => $class) { if ($subject instanceof $class) { $name = $key; break; } } // Map the name to a proper key $name = $this->propertyToKey($name); // Get rid of the unnecessary type specs (i.e. invoice_detail => detail) $simplified = array( 'payment', 'history', 'detail', ); foreach ($simplified as $simplify) { $name = preg_replace('/^[a-z\-\/]+[_\/](' . preg_quote($simplify) . ')/', '\\1', $name); } if ($subject instanceof SyncObject) { $name = 'ids'; } $pos = ($subject instanceof SyncArray) ? strpos($name, '_') : strrpos($name, '_'); if ($pos !== false) { $name = substr($name, 0, $pos); } if ($subject instanceof ArrayObject && substr($name, -1) != 's') { $name .= 's'; } // Exceptions $name = str_replace( array( 'historys', 'details', 'incoming-invoice', ), array( 'history', 'details_attributes', 'incoming_invoice', ), $name ); return lcfirst($name); }
php
protected function mapObjectToElementName(Mapper_Mapable $subject) { // Pick a default value based on the subject class $name = substr(get_class($subject), strlen(__NAMESPACE__) + 1); // See if the objectMapper array contains the (super)class foreach ($this->objectMapper as $key => $class) { if ($subject instanceof $class) { $name = $key; break; } } // Map the name to a proper key $name = $this->propertyToKey($name); // Get rid of the unnecessary type specs (i.e. invoice_detail => detail) $simplified = array( 'payment', 'history', 'detail', ); foreach ($simplified as $simplify) { $name = preg_replace('/^[a-z\-\/]+[_\/](' . preg_quote($simplify) . ')/', '\\1', $name); } if ($subject instanceof SyncObject) { $name = 'ids'; } $pos = ($subject instanceof SyncArray) ? strpos($name, '_') : strrpos($name, '_'); if ($pos !== false) { $name = substr($name, 0, $pos); } if ($subject instanceof ArrayObject && substr($name, -1) != 's') { $name .= 's'; } // Exceptions $name = str_replace( array( 'historys', 'details', 'incoming-invoice', ), array( 'history', 'details_attributes', 'incoming_invoice', ), $name ); return lcfirst($name); }
[ "protected", "function", "mapObjectToElementName", "(", "Mapper_Mapable", "$", "subject", ")", "{", "// Pick a default value based on the subject class", "$", "name", "=", "substr", "(", "get_class", "(", "$", "subject", ")", ",", "strlen", "(", "__NAMESPACE__", ")", "+", "1", ")", ";", "// See if the objectMapper array contains the (super)class", "foreach", "(", "$", "this", "->", "objectMapper", "as", "$", "key", "=>", "$", "class", ")", "{", "if", "(", "$", "subject", "instanceof", "$", "class", ")", "{", "$", "name", "=", "$", "key", ";", "break", ";", "}", "}", "// Map the name to a proper key", "$", "name", "=", "$", "this", "->", "propertyToKey", "(", "$", "name", ")", ";", "// Get rid of the unnecessary type specs (i.e. invoice_detail => detail)", "$", "simplified", "=", "array", "(", "'payment'", ",", "'history'", ",", "'detail'", ",", ")", ";", "foreach", "(", "$", "simplified", "as", "$", "simplify", ")", "{", "$", "name", "=", "preg_replace", "(", "'/^[a-z\\-\\/]+[_\\/]('", ".", "preg_quote", "(", "$", "simplify", ")", ".", "')/'", ",", "'\\\\1'", ",", "$", "name", ")", ";", "}", "if", "(", "$", "subject", "instanceof", "SyncObject", ")", "{", "$", "name", "=", "'ids'", ";", "}", "$", "pos", "=", "(", "$", "subject", "instanceof", "SyncArray", ")", "?", "strpos", "(", "$", "name", ",", "'_'", ")", ":", "strrpos", "(", "$", "name", ",", "'_'", ")", ";", "if", "(", "$", "pos", "!==", "false", ")", "{", "$", "name", "=", "substr", "(", "$", "name", ",", "0", ",", "$", "pos", ")", ";", "}", "if", "(", "$", "subject", "instanceof", "ArrayObject", "&&", "substr", "(", "$", "name", ",", "-", "1", ")", "!=", "'s'", ")", "{", "$", "name", ".=", "'s'", ";", "}", "// Exceptions", "$", "name", "=", "str_replace", "(", "array", "(", "'historys'", ",", "'details'", ",", "'incoming-invoice'", ",", ")", ",", "array", "(", "'history'", ",", "'details_attributes'", ",", "'incoming_invoice'", ",", ")", ",", "$", "name", ")", ";", "return", "lcfirst", "(", "$", "name", ")", ";", "}" ]
Maps object to Json element-name @access protected @param Mapper_Mapable $subject Object to map to Json @return string
[ "Maps", "object", "to", "Json", "element", "-", "name" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/JsonMapper.php#L225-L275
232,153
youngguns-nl/moneybird_php_api
JsonMapper.php
JsonMapper.toJson
public function toJson(Mapper_Mapable $subject) { $jsonArrayValue = array(); if ($subject instanceof DeleteBySaving && $subject->isDeleted()) { // $jsonArrayValue->addChild('_destroy', '1'); } foreach ($subject->toArray() as $property => $value) { $key = $this->propertyToXmlkey($property); if (is_null($value)) { $jsonArrayValue[$key] = null; } elseif (is_bool($value)) { $jsonArrayValue[$key] = $value === true ? 'true' : 'false'; } elseif (is_array($value)) { $jsonArrayValue[$key] = $value; } elseif (!is_object($value) && !is_array($value)) { $jsonArrayValue[$key] = $value; } elseif (is_object($value) && $value instanceof Mapper_Mapable) { $jsonArrayValue[$key] = $this->toXml($value); } elseif (is_object($value) && $value instanceof \DateTime) { $jsonArrayValue[$key] = $value->format('c'); } else { throw new Mapper_Exception('Invalid value for key ' . $key); } } $key = $this->mapObjectToElementName($subject); return array($key => $jsonArrayValue); }
php
public function toJson(Mapper_Mapable $subject) { $jsonArrayValue = array(); if ($subject instanceof DeleteBySaving && $subject->isDeleted()) { // $jsonArrayValue->addChild('_destroy', '1'); } foreach ($subject->toArray() as $property => $value) { $key = $this->propertyToXmlkey($property); if (is_null($value)) { $jsonArrayValue[$key] = null; } elseif (is_bool($value)) { $jsonArrayValue[$key] = $value === true ? 'true' : 'false'; } elseif (is_array($value)) { $jsonArrayValue[$key] = $value; } elseif (!is_object($value) && !is_array($value)) { $jsonArrayValue[$key] = $value; } elseif (is_object($value) && $value instanceof Mapper_Mapable) { $jsonArrayValue[$key] = $this->toXml($value); } elseif (is_object($value) && $value instanceof \DateTime) { $jsonArrayValue[$key] = $value->format('c'); } else { throw new Mapper_Exception('Invalid value for key ' . $key); } } $key = $this->mapObjectToElementName($subject); return array($key => $jsonArrayValue); }
[ "public", "function", "toJson", "(", "Mapper_Mapable", "$", "subject", ")", "{", "$", "jsonArrayValue", "=", "array", "(", ")", ";", "if", "(", "$", "subject", "instanceof", "DeleteBySaving", "&&", "$", "subject", "->", "isDeleted", "(", ")", ")", "{", "//\t\t\t$jsonArrayValue->addChild('_destroy', '1');", "}", "foreach", "(", "$", "subject", "->", "toArray", "(", ")", "as", "$", "property", "=>", "$", "value", ")", "{", "$", "key", "=", "$", "this", "->", "propertyToXmlkey", "(", "$", "property", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "jsonArrayValue", "[", "$", "key", "]", "=", "null", ";", "}", "elseif", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "jsonArrayValue", "[", "$", "key", "]", "=", "$", "value", "===", "true", "?", "'true'", ":", "'false'", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "jsonArrayValue", "[", "$", "key", "]", "=", "$", "value", ";", "}", "elseif", "(", "!", "is_object", "(", "$", "value", ")", "&&", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "jsonArrayValue", "[", "$", "key", "]", "=", "$", "value", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", "&&", "$", "value", "instanceof", "Mapper_Mapable", ")", "{", "$", "jsonArrayValue", "[", "$", "key", "]", "=", "$", "this", "->", "toXml", "(", "$", "value", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", "&&", "$", "value", "instanceof", "\\", "DateTime", ")", "{", "$", "jsonArrayValue", "[", "$", "key", "]", "=", "$", "value", "->", "format", "(", "'c'", ")", ";", "}", "else", "{", "throw", "new", "Mapper_Exception", "(", "'Invalid value for key '", ".", "$", "key", ")", ";", "}", "}", "$", "key", "=", "$", "this", "->", "mapObjectToElementName", "(", "$", "subject", ")", ";", "return", "array", "(", "$", "key", "=>", "$", "jsonArrayValue", ")", ";", "}" ]
Convert to Json @access public @param Mapper_Mapable $subject Object to map to Json @return SimpleXMLElement
[ "Convert", "to", "Json" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/JsonMapper.php#L296-L324
232,154
chippyash/Builder-Pattern
src/Chippyash/BuilderPattern/AbstractCollectionBuilder.php
AbstractCollectionBuilder.setCollection
public function setCollection(array $collection) { if (is_array($this->buildItems) && array_key_exists('collection', $this->buildItems) && !empty($this->buildItems['collection'])) { unset($this->collection); } $this->setBuildItems(); foreach ($collection as $builder) { $this->addBuilder($builder); } return $this; }
php
public function setCollection(array $collection) { if (is_array($this->buildItems) && array_key_exists('collection', $this->buildItems) && !empty($this->buildItems['collection'])) { unset($this->collection); } $this->setBuildItems(); foreach ($collection as $builder) { $this->addBuilder($builder); } return $this; }
[ "public", "function", "setCollection", "(", "array", "$", "collection", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "buildItems", ")", "&&", "array_key_exists", "(", "'collection'", ",", "$", "this", "->", "buildItems", ")", "&&", "!", "empty", "(", "$", "this", "->", "buildItems", "[", "'collection'", "]", ")", ")", "{", "unset", "(", "$", "this", "->", "collection", ")", ";", "}", "$", "this", "->", "setBuildItems", "(", ")", ";", "foreach", "(", "$", "collection", "as", "$", "builder", ")", "{", "$", "this", "->", "addBuilder", "(", "$", "builder", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the entire collection @param array $collection Array of BuilderInterface @return \Chippyash\BuilderPattern\DataBuilder\AbstractCollectionBuilder Fluent Interface
[ "Set", "the", "entire", "collection" ]
00be4830438542abe494ac9be0bbd27723a0c984
https://github.com/chippyash/Builder-Pattern/blob/00be4830438542abe494ac9be0bbd27723a0c984/src/Chippyash/BuilderPattern/AbstractCollectionBuilder.php#L72-L85
232,155
jack-theripper/transcoder
src/Stream/StreamTrait.php
StreamTrait.setIndex
public function setIndex($position) { if ( ! is_int($position) || $position < 0) { throw new \InvalidArgumentException('Wrong index value.'); } $this->index = $position; return $this; }
php
public function setIndex($position) { if ( ! is_int($position) || $position < 0) { throw new \InvalidArgumentException('Wrong index value.'); } $this->index = $position; return $this; }
[ "public", "function", "setIndex", "(", "$", "position", ")", "{", "if", "(", "!", "is_int", "(", "$", "position", ")", "||", "$", "position", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Wrong index value.'", ")", ";", "}", "$", "this", "->", "index", "=", "$", "position", ";", "return", "$", "this", ";", "}" ]
Set a new order. @param int $position @return $this @throws \InvalidArgumentException
[ "Set", "a", "new", "order", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/StreamTrait.php#L164-L174
232,156
jack-theripper/transcoder
src/Stream/StreamTrait.php
StreamTrait.save
public function save(FormatInterface $format, $filePath, $overwrite = true) { $media = $this->media->withoutFilters(); $media->addFilter(new SimpleFilter([ 'map' => sprintf('0:%s', $this->getIndex()) ])); return $media->save($format, $filePath, $overwrite); }
php
public function save(FormatInterface $format, $filePath, $overwrite = true) { $media = $this->media->withoutFilters(); $media->addFilter(new SimpleFilter([ 'map' => sprintf('0:%s', $this->getIndex()) ])); return $media->save($format, $filePath, $overwrite); }
[ "public", "function", "save", "(", "FormatInterface", "$", "format", ",", "$", "filePath", ",", "$", "overwrite", "=", "true", ")", "{", "$", "media", "=", "$", "this", "->", "media", "->", "withoutFilters", "(", ")", ";", "$", "media", "->", "addFilter", "(", "new", "SimpleFilter", "(", "[", "'map'", "=>", "sprintf", "(", "'0:%s'", ",", "$", "this", "->", "getIndex", "(", ")", ")", "]", ")", ")", ";", "return", "$", "media", "->", "save", "(", "$", "format", ",", "$", "filePath", ",", "$", "overwrite", ")", ";", "}" ]
Stream save. @param FormatInterface $format @param string $filePath @param bool $overwrite @return \Arhitector\Transcoder\TranscodeInterface @throws \Arhitector\Transcoder\Exception\InvalidFilterException @throws \Symfony\Component\Process\Exception\ProcessFailedException @throws \Arhitector\Transcoder\Exception\TranscoderException @throws \InvalidArgumentException
[ "Stream", "save", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/StreamTrait.php#L230-L238
232,157
jack-theripper/transcoder
src/Stream/StreamTrait.php
StreamTrait.toArray
public function toArray() { $result = []; foreach (get_class_methods($this) as $method) { if (stripos($method, 'get') === 0) { $result[strtolower(substr($method, 3))] = $this->{$method}(); } } return $result; }
php
public function toArray() { $result = []; foreach (get_class_methods($this) as $method) { if (stripos($method, 'get') === 0) { $result[strtolower(substr($method, 3))] = $this->{$method}(); } } return $result; }
[ "public", "function", "toArray", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "get_class_methods", "(", "$", "this", ")", "as", "$", "method", ")", "{", "if", "(", "stripos", "(", "$", "method", ",", "'get'", ")", "===", "0", ")", "{", "$", "result", "[", "strtolower", "(", "substr", "(", "$", "method", ",", "3", ")", ")", "]", "=", "$", "this", "->", "{", "$", "method", "}", "(", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Get array of values. @return array
[ "Get", "array", "of", "values", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/StreamTrait.php#L245-L258
232,158
jack-theripper/transcoder
src/Stream/StreamTrait.php
StreamTrait.setProfile
protected function setProfile($profile) { if ( ! is_string($profile) && $profile !== null) { throw new \InvalidArgumentException('Wrong profile value.'); } $this->profile = $profile; return $this; }
php
protected function setProfile($profile) { if ( ! is_string($profile) && $profile !== null) { throw new \InvalidArgumentException('Wrong profile value.'); } $this->profile = $profile; return $this; }
[ "protected", "function", "setProfile", "(", "$", "profile", ")", "{", "if", "(", "!", "is_string", "(", "$", "profile", ")", "&&", "$", "profile", "!==", "null", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Wrong profile value.'", ")", ";", "}", "$", "this", "->", "profile", "=", "$", "profile", ";", "return", "$", "this", ";", "}" ]
Set profile value. @param string $profile @return $this @throws \InvalidArgumentException
[ "Set", "profile", "value", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/StreamTrait.php#L268-L278
232,159
jack-theripper/transcoder
src/Stream/StreamTrait.php
StreamTrait.setBitrate
protected function setBitrate($bitrate) { if ( ! is_numeric($bitrate) || $bitrate < 0) { throw new \InvalidArgumentException('Wrong bitrate value.'); } $this->bitrate = (int) $bitrate; return $this; }
php
protected function setBitrate($bitrate) { if ( ! is_numeric($bitrate) || $bitrate < 0) { throw new \InvalidArgumentException('Wrong bitrate value.'); } $this->bitrate = (int) $bitrate; return $this; }
[ "protected", "function", "setBitrate", "(", "$", "bitrate", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "bitrate", ")", "||", "$", "bitrate", "<", "0", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Wrong bitrate value.'", ")", ";", "}", "$", "this", "->", "bitrate", "=", "(", "int", ")", "$", "bitrate", ";", "return", "$", "this", ";", "}" ]
Set bit rate value. @param int $bitrate @return $this @throws \InvalidArgumentException
[ "Set", "bit", "rate", "value", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/StreamTrait.php#L288-L298
232,160
jack-theripper/transcoder
src/Stream/StreamTrait.php
StreamTrait.setStartTime
protected function setStartTime($startTime) { if ( ! is_numeric($startTime)) { throw new \InvalidArgumentException('Wrong start time value.'); } $this->startTime = (float) $startTime; return $this; }
php
protected function setStartTime($startTime) { if ( ! is_numeric($startTime)) { throw new \InvalidArgumentException('Wrong start time value.'); } $this->startTime = (float) $startTime; return $this; }
[ "protected", "function", "setStartTime", "(", "$", "startTime", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "startTime", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Wrong start time value.'", ")", ";", "}", "$", "this", "->", "startTime", "=", "(", "float", ")", "$", "startTime", ";", "return", "$", "this", ";", "}" ]
Set start time value. @param float $startTime @return $this @throws \InvalidArgumentException
[ "Set", "start", "time", "value", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Stream/StreamTrait.php#L308-L318
232,161
monarkee/bumble
Traits/BumbleUserTrait.php
BumbleUserTrait.getAvatar
public function getAvatar() { $config = app('config'); return $config->has('bumble.email') ? Gravatar::get($this->attributes[$config->get('bumble.email')]) : $this->attributes['email']; }
php
public function getAvatar() { $config = app('config'); return $config->has('bumble.email') ? Gravatar::get($this->attributes[$config->get('bumble.email')]) : $this->attributes['email']; }
[ "public", "function", "getAvatar", "(", ")", "{", "$", "config", "=", "app", "(", "'config'", ")", ";", "return", "$", "config", "->", "has", "(", "'bumble.email'", ")", "?", "Gravatar", "::", "get", "(", "$", "this", "->", "attributes", "[", "$", "config", "->", "get", "(", "'bumble.email'", ")", "]", ")", ":", "$", "this", "->", "attributes", "[", "'email'", "]", ";", "}" ]
Get the Gravatar URL for a user @return mixed
[ "Get", "the", "Gravatar", "URL", "for", "a", "user" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Traits/BumbleUserTrait.php#L11-L15
232,162
monarkee/bumble
Fields/Field.php
Field.getName
public function getName() { $label = $this->hasOption('title') ? $this->getOption('title') : $this->title; return ucwords(str_replace('_', ' ', $label)); }
php
public function getName() { $label = $this->hasOption('title') ? $this->getOption('title') : $this->title; return ucwords(str_replace('_', ' ', $label)); }
[ "public", "function", "getName", "(", ")", "{", "$", "label", "=", "$", "this", "->", "hasOption", "(", "'title'", ")", "?", "$", "this", "->", "getOption", "(", "'title'", ")", ":", "$", "this", "->", "title", ";", "return", "ucwords", "(", "str_replace", "(", "'_'", ",", "' '", ",", "$", "label", ")", ")", ";", "}" ]
Get the name for this field @return string
[ "Get", "the", "name", "for", "this", "field" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/Field.php#L83-L88
232,163
monarkee/bumble
Fields/Field.php
Field.getFieldHtml
public function getFieldHtml($post, $model, $editing = false) { $data = ['post' => $post, 'model' => $model, 'editing' => $editing, 'field' => $this]; return view($this->getWidgetType(), $data)->render(); }
php
public function getFieldHtml($post, $model, $editing = false) { $data = ['post' => $post, 'model' => $model, 'editing' => $editing, 'field' => $this]; return view($this->getWidgetType(), $data)->render(); }
[ "public", "function", "getFieldHtml", "(", "$", "post", ",", "$", "model", ",", "$", "editing", "=", "false", ")", "{", "$", "data", "=", "[", "'post'", "=>", "$", "post", ",", "'model'", "=>", "$", "model", ",", "'editing'", "=>", "$", "editing", ",", "'field'", "=>", "$", "this", "]", ";", "return", "view", "(", "$", "this", "->", "getWidgetType", "(", ")", ",", "$", "data", ")", "->", "render", "(", ")", ";", "}" ]
Get the fields HTML
[ "Get", "the", "fields", "HTML" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/Field.php#L174-L178
232,164
monarkee/bumble
Fields/Field.php
Field.registerAssets
public function registerAssets() { if ($this->cssAssets) { foreach($this->cssAssets as $asset) { $this->assetLoader->registerCssAsset($asset); } } if ($this->jsAssets) { foreach($this->jsAssets as $asset) { $this->assetLoader->registerJsAsset($asset); } } }
php
public function registerAssets() { if ($this->cssAssets) { foreach($this->cssAssets as $asset) { $this->assetLoader->registerCssAsset($asset); } } if ($this->jsAssets) { foreach($this->jsAssets as $asset) { $this->assetLoader->registerJsAsset($asset); } } }
[ "public", "function", "registerAssets", "(", ")", "{", "if", "(", "$", "this", "->", "cssAssets", ")", "{", "foreach", "(", "$", "this", "->", "cssAssets", "as", "$", "asset", ")", "{", "$", "this", "->", "assetLoader", "->", "registerCssAsset", "(", "$", "asset", ")", ";", "}", "}", "if", "(", "$", "this", "->", "jsAssets", ")", "{", "foreach", "(", "$", "this", "->", "jsAssets", "as", "$", "asset", ")", "{", "$", "this", "->", "assetLoader", "->", "registerJsAsset", "(", "$", "asset", ")", ";", "}", "}", "}" ]
Register the Assets for a given Field
[ "Register", "the", "Assets", "for", "a", "given", "Field" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/Field.php#L183-L200
232,165
monarkee/bumble
Fields/Field.php
Field.getWidgetType
public function getWidgetType() { // 1. Use the fieldtypes property if set // 2. Use the option 'widget' // 3. Use the fieldType getter if ($this->hasOption('widget')) return $this->viewPrefix . '.' . $this->getOption('widget'); if (isset($this->view)) return $this->view; return $this->viewPrefix . '.' . $this->getFieldType(); }
php
public function getWidgetType() { // 1. Use the fieldtypes property if set // 2. Use the option 'widget' // 3. Use the fieldType getter if ($this->hasOption('widget')) return $this->viewPrefix . '.' . $this->getOption('widget'); if (isset($this->view)) return $this->view; return $this->viewPrefix . '.' . $this->getFieldType(); }
[ "public", "function", "getWidgetType", "(", ")", "{", "// 1. Use the fieldtypes property if set", "// 2. Use the option 'widget'", "// 3. Use the fieldType getter", "if", "(", "$", "this", "->", "hasOption", "(", "'widget'", ")", ")", "return", "$", "this", "->", "viewPrefix", ".", "'.'", ".", "$", "this", "->", "getOption", "(", "'widget'", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "view", ")", ")", "return", "$", "this", "->", "view", ";", "return", "$", "this", "->", "viewPrefix", ".", "'.'", ".", "$", "this", "->", "getFieldType", "(", ")", ";", "}" ]
Return the widget type to be used for this field @return string
[ "Return", "the", "widget", "type", "to", "be", "used", "for", "this", "field" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/Field.php#L208-L218
232,166
monarkee/bumble
Fields/Field.php
Field.process
public function process($model, $input) { $column = $this->getColumn(); if(isset($input[$column])) { $model->{$column} = $input[$column]; } return $model; }
php
public function process($model, $input) { $column = $this->getColumn(); if(isset($input[$column])) { $model->{$column} = $input[$column]; } return $model; }
[ "public", "function", "process", "(", "$", "model", ",", "$", "input", ")", "{", "$", "column", "=", "$", "this", "->", "getColumn", "(", ")", ";", "if", "(", "isset", "(", "$", "input", "[", "$", "column", "]", ")", ")", "{", "$", "model", "->", "{", "$", "column", "}", "=", "$", "input", "[", "$", "column", "]", ";", "}", "return", "$", "model", ";", "}" ]
The default process action is to just return the passed model back to the caller @param $model @param $input @return BumbleModel
[ "The", "default", "process", "action", "is", "to", "just", "return", "the", "passed", "model", "back", "to", "the", "caller" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/Field.php#L269-L278
232,167
cawaphp/cawa
src/Http/Cookie.php
Cookie.setExpire
public function setExpire($expire) : self { // convert expiration time to a Unix timestamp if ($expire instanceof \DateTime || $expire instanceof \DateTimeImmutable) { $expire = (int) $expire->format('U'); } elseif (!is_numeric($expire) || !is_int($expire)) { throw new \InvalidArgumentException(sprintf( "The cookie expiration time is not valid with type '%s'", gettype($expire) )); } elseif ($expire > 0) { $expire = time() + $expire; } $this->expire = $expire; return $this; }
php
public function setExpire($expire) : self { // convert expiration time to a Unix timestamp if ($expire instanceof \DateTime || $expire instanceof \DateTimeImmutable) { $expire = (int) $expire->format('U'); } elseif (!is_numeric($expire) || !is_int($expire)) { throw new \InvalidArgumentException(sprintf( "The cookie expiration time is not valid with type '%s'", gettype($expire) )); } elseif ($expire > 0) { $expire = time() + $expire; } $this->expire = $expire; return $this; }
[ "public", "function", "setExpire", "(", "$", "expire", ")", ":", "self", "{", "// convert expiration time to a Unix timestamp", "if", "(", "$", "expire", "instanceof", "\\", "DateTime", "||", "$", "expire", "instanceof", "\\", "DateTimeImmutable", ")", "{", "$", "expire", "=", "(", "int", ")", "$", "expire", "->", "format", "(", "'U'", ")", ";", "}", "elseif", "(", "!", "is_numeric", "(", "$", "expire", ")", "||", "!", "is_int", "(", "$", "expire", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"The cookie expiration time is not valid with type '%s'\"", ",", "gettype", "(", "$", "expire", ")", ")", ")", ";", "}", "elseif", "(", "$", "expire", ">", "0", ")", "{", "$", "expire", "=", "time", "(", ")", "+", "$", "expire", ";", "}", "$", "this", "->", "expire", "=", "$", "expire", ";", "return", "$", "this", ";", "}" ]
Set the time the cookie expires. @param int|\DateTime $expire if int, the ttl of this cookie, 0 if session cookie @throws \InvalidArgumentException @return $this|self
[ "Set", "the", "time", "the", "cookie", "expires", "." ]
bd250532200121e7aa1da44e547c04c4c148fb37
https://github.com/cawaphp/cawa/blob/bd250532200121e7aa1da44e547c04c4c148fb37/src/Http/Cookie.php#L146-L163
232,168
youngguns-nl/moneybird_php_api
Estimate/Service.php
Service.getAll
public function getAll($filter = null, Subject $parent = null) { return $this->connector->getAll(__NAMESPACE__, $filter, $parent); }
php
public function getAll($filter = null, Subject $parent = null) { return $this->connector->getAll(__NAMESPACE__, $filter, $parent); }
[ "public", "function", "getAll", "(", "$", "filter", "=", "null", ",", "Subject", "$", "parent", "=", "null", ")", "{", "return", "$", "this", "->", "connector", "->", "getAll", "(", "__NAMESPACE__", ",", "$", "filter", ",", "$", "parent", ")", ";", "}" ]
Get all estimates @param string|integer $filter Filter name or id (advanced filters) @param Subject $parent @return ArrayObject @throws InvalidFilterException
[ "Get", "all", "estimates" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Estimate/Service.php#L71-L74
232,169
youngguns-nl/moneybird_php_api
Estimate/Service.php
Service.send
public function send(Estimate $estimate, $method = 'email', $email = null, $message = null) { return $this->connector->send($estimate, $this->buildEnvelope($method, $email, $message)); }
php
public function send(Estimate $estimate, $method = 'email', $email = null, $message = null) { return $this->connector->send($estimate, $this->buildEnvelope($method, $email, $message)); }
[ "public", "function", "send", "(", "Estimate", "$", "estimate", ",", "$", "method", "=", "'email'", ",", "$", "email", "=", "null", ",", "$", "message", "=", "null", ")", "{", "return", "$", "this", "->", "connector", "->", "send", "(", "$", "estimate", ",", "$", "this", "->", "buildEnvelope", "(", "$", "method", ",", "$", "email", ",", "$", "message", ")", ")", ";", "}" ]
Send the estimate. Returns the updated estimate @param Estimate $estimate @param string $method Send method (email|hand|post); default: email @param type $email Address to send to; default: contact e-mail @param type $message @return Estimate
[ "Send", "the", "estimate", ".", "Returns", "the", "updated", "estimate" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Estimate/Service.php#L105-L108
232,170
hussainweb/drupal-api-client
src/Entity/Entity.php
Entity.getData
public function getData() { if (!$this->data) { // Convert the appropriate fields to integer. $this->data = (object) $this->rawData; $int_fields = $this->getIntegerFields(); foreach ($int_fields as $field) { $this->data->$field = (int) $this->data->$field; } } return $this->data; }
php
public function getData() { if (!$this->data) { // Convert the appropriate fields to integer. $this->data = (object) $this->rawData; $int_fields = $this->getIntegerFields(); foreach ($int_fields as $field) { $this->data->$field = (int) $this->data->$field; } } return $this->data; }
[ "public", "function", "getData", "(", ")", "{", "if", "(", "!", "$", "this", "->", "data", ")", "{", "// Convert the appropriate fields to integer.", "$", "this", "->", "data", "=", "(", "object", ")", "$", "this", "->", "rawData", ";", "$", "int_fields", "=", "$", "this", "->", "getIntegerFields", "(", ")", ";", "foreach", "(", "$", "int_fields", "as", "$", "field", ")", "{", "$", "this", "->", "data", "->", "$", "field", "=", "(", "int", ")", "$", "this", "->", "data", "->", "$", "field", ";", "}", "}", "return", "$", "this", "->", "data", ";", "}" ]
Get the response entity data. @return mixed
[ "Get", "the", "response", "entity", "data", "." ]
d15de9591a3d5181b4d44c2e50235fb98b3d3448
https://github.com/hussainweb/drupal-api-client/blob/d15de9591a3d5181b4d44c2e50235fb98b3d3448/src/Entity/Entity.php#L40-L52
232,171
iwyg/jitimage
src/Thapp/JitImage/JitImage.php
JitImage.get
public function get() { if ($this->targetSize) { throw new \InvalidArgumentException('can\'t get original iamge if target size is already set'); } $this->mode = 'default'; $this->arguments = []; return $this->process(); }
php
public function get() { if ($this->targetSize) { throw new \InvalidArgumentException('can\'t get original iamge if target size is already set'); } $this->mode = 'default'; $this->arguments = []; return $this->process(); }
[ "public", "function", "get", "(", ")", "{", "if", "(", "$", "this", "->", "targetSize", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'can\\'t get original iamge if target size is already set'", ")", ";", "}", "$", "this", "->", "mode", "=", "'default'", ";", "$", "this", "->", "arguments", "=", "[", "]", ";", "return", "$", "this", "->", "process", "(", ")", ";", "}" ]
get the unprocessed image @access protected @return void
[ "get", "the", "unprocessed", "image" ]
25300cc5bb17835634ec60d71f5ac2ba870abbe4
https://github.com/iwyg/jitimage/blob/25300cc5bb17835634ec60d71f5ac2ba870abbe4/src/Thapp/JitImage/JitImage.php#L238-L247
232,172
youngguns-nl/moneybird_php_api
Envelope/AbstractEnvelope.php
AbstractEnvelope.setSendMethodAttr
protected function setSendMethodAttr($value, $isDirty = true) { if (!in_array($value, array('hand', 'email', 'post'))) { throw new InvalidMethodException('Invalid send method: ' . $value); } $this->sendMethod = $value; $this->setDirtyState($isDirty, 'sendMethod'); }
php
protected function setSendMethodAttr($value, $isDirty = true) { if (!in_array($value, array('hand', 'email', 'post'))) { throw new InvalidMethodException('Invalid send method: ' . $value); } $this->sendMethod = $value; $this->setDirtyState($isDirty, 'sendMethod'); }
[ "protected", "function", "setSendMethodAttr", "(", "$", "value", ",", "$", "isDirty", "=", "true", ")", "{", "if", "(", "!", "in_array", "(", "$", "value", ",", "array", "(", "'hand'", ",", "'email'", ",", "'post'", ")", ")", ")", "{", "throw", "new", "InvalidMethodException", "(", "'Invalid send method: '", ".", "$", "value", ")", ";", "}", "$", "this", "->", "sendMethod", "=", "$", "value", ";", "$", "this", "->", "setDirtyState", "(", "$", "isDirty", ",", "'sendMethod'", ")", ";", "}" ]
Set send method @param string $value @param bool $isDirty new value is dirty, defaults to true @throws InvalidMethodException
[ "Set", "send", "method" ]
bb5035dd60cf087c7a055458d207be418355ab74
https://github.com/youngguns-nl/moneybird_php_api/blob/bb5035dd60cf087c7a055458d207be418355ab74/Envelope/AbstractEnvelope.php#L51-L59
232,173
jr-cologne/db-class
src/DB.php
DB.connect
public function connect(string $dsn, string $username = null, string $password = null, array $options = []) : bool { try { if (empty($options)) { parent::__construct($dsn, $username, $password, $this->default_options); } else { parent::__construct($dsn, $username, $password, $options); } } catch (PDOException $e) { $this->pdo_exception = $e; $this->connected = false; return false; } $this->connected = true; return true; }
php
public function connect(string $dsn, string $username = null, string $password = null, array $options = []) : bool { try { if (empty($options)) { parent::__construct($dsn, $username, $password, $this->default_options); } else { parent::__construct($dsn, $username, $password, $options); } } catch (PDOException $e) { $this->pdo_exception = $e; $this->connected = false; return false; } $this->connected = true; return true; }
[ "public", "function", "connect", "(", "string", "$", "dsn", ",", "string", "$", "username", "=", "null", ",", "string", "$", "password", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", ":", "bool", "{", "try", "{", "if", "(", "empty", "(", "$", "options", ")", ")", "{", "parent", "::", "__construct", "(", "$", "dsn", ",", "$", "username", ",", "$", "password", ",", "$", "this", "->", "default_options", ")", ";", "}", "else", "{", "parent", "::", "__construct", "(", "$", "dsn", ",", "$", "username", ",", "$", "password", ",", "$", "options", ")", ";", "}", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "$", "this", "->", "pdo_exception", "=", "$", "e", ";", "$", "this", "->", "connected", "=", "false", ";", "return", "false", ";", "}", "$", "this", "->", "connected", "=", "true", ";", "return", "true", ";", "}" ]
Creates a connection to a specified database by PDO. @param string $dsn the data source name of the method PDO::__construct() @param string $username = null @param string $password = null @param array $options = [] array of options that should be passed into the method PDO::__construct() @return boolean true on success, false on failure
[ "Creates", "a", "connection", "to", "a", "specified", "database", "by", "PDO", "." ]
6578f51b5fb8ffe96687bcf1b8e490c2c848a396
https://github.com/jr-cologne/db-class/blob/6578f51b5fb8ffe96687bcf1b8e490c2c848a396/src/DB.php#L115-L132
232,174
jr-cologne/db-class
src/DB.php
DB.select
public function select(string $columns, array $where = [], int $fetch_mode = PDO::FETCH_ASSOC) : self { $this->query_builder->resetProperties(); $this->query_builder->setMode('select'); $this->query_builder->setColumns($columns); if (!empty($where)) { $this->query_builder->setWhere($where); $where = $this->formatWhereData($where); } try { $stmt = parent::prepare($this->query_builder->getQuery()); $stmt->execute($where); $this->results = $stmt->fetchAll($fetch_mode); } catch (PDOException $e) { $this->pdo_exception = $e; $this->query_failed = true; } return $this; }
php
public function select(string $columns, array $where = [], int $fetch_mode = PDO::FETCH_ASSOC) : self { $this->query_builder->resetProperties(); $this->query_builder->setMode('select'); $this->query_builder->setColumns($columns); if (!empty($where)) { $this->query_builder->setWhere($where); $where = $this->formatWhereData($where); } try { $stmt = parent::prepare($this->query_builder->getQuery()); $stmt->execute($where); $this->results = $stmt->fetchAll($fetch_mode); } catch (PDOException $e) { $this->pdo_exception = $e; $this->query_failed = true; } return $this; }
[ "public", "function", "select", "(", "string", "$", "columns", ",", "array", "$", "where", "=", "[", "]", ",", "int", "$", "fetch_mode", "=", "PDO", "::", "FETCH_ASSOC", ")", ":", "self", "{", "$", "this", "->", "query_builder", "->", "resetProperties", "(", ")", ";", "$", "this", "->", "query_builder", "->", "setMode", "(", "'select'", ")", ";", "$", "this", "->", "query_builder", "->", "setColumns", "(", "$", "columns", ")", ";", "if", "(", "!", "empty", "(", "$", "where", ")", ")", "{", "$", "this", "->", "query_builder", "->", "setWhere", "(", "$", "where", ")", ";", "$", "where", "=", "$", "this", "->", "formatWhereData", "(", "$", "where", ")", ";", "}", "try", "{", "$", "stmt", "=", "parent", "::", "prepare", "(", "$", "this", "->", "query_builder", "->", "getQuery", "(", ")", ")", ";", "$", "stmt", "->", "execute", "(", "$", "where", ")", ";", "$", "this", "->", "results", "=", "$", "stmt", "->", "fetchAll", "(", "$", "fetch_mode", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "$", "this", "->", "pdo_exception", "=", "$", "e", ";", "$", "this", "->", "query_failed", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Executes a SELECT query and fetches data from a database. @param string $columns @param array $where = [] assoc array with format column => value @param int $fetch_mode = PDO::FETCH_ASSOC the wished pdo fetch mode @return DB
[ "Executes", "a", "SELECT", "query", "and", "fetches", "data", "from", "a", "database", "." ]
6578f51b5fb8ffe96687bcf1b8e490c2c848a396
https://github.com/jr-cologne/db-class/blob/6578f51b5fb8ffe96687bcf1b8e490c2c848a396/src/DB.php#L163-L183
232,175
jr-cologne/db-class
src/DB.php
DB.insert
public function insert(array $data) : bool { $this->query_builder->resetProperties(); $this->query_builder->setMode('insert'); $columns = array_keys($data); $this->query_builder->setColumns($columns); $this->query_builder->setValues($columns); try { $stmt = parent::prepare($this->query_builder->getQuery()); return $stmt->execute($data); } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
php
public function insert(array $data) : bool { $this->query_builder->resetProperties(); $this->query_builder->setMode('insert'); $columns = array_keys($data); $this->query_builder->setColumns($columns); $this->query_builder->setValues($columns); try { $stmt = parent::prepare($this->query_builder->getQuery()); return $stmt->execute($data); } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
[ "public", "function", "insert", "(", "array", "$", "data", ")", ":", "bool", "{", "$", "this", "->", "query_builder", "->", "resetProperties", "(", ")", ";", "$", "this", "->", "query_builder", "->", "setMode", "(", "'insert'", ")", ";", "$", "columns", "=", "array_keys", "(", "$", "data", ")", ";", "$", "this", "->", "query_builder", "->", "setColumns", "(", "$", "columns", ")", ";", "$", "this", "->", "query_builder", "->", "setValues", "(", "$", "columns", ")", ";", "try", "{", "$", "stmt", "=", "parent", "::", "prepare", "(", "$", "this", "->", "query_builder", "->", "getQuery", "(", ")", ")", ";", "return", "$", "stmt", "->", "execute", "(", "$", "data", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "$", "this", "->", "pdo_exception", "=", "$", "e", ";", "return", "false", ";", "}", "}" ]
Inserts data into a database. @param array $data assoc array of data to insert with the format column => value @return boolean true on success, false on failure
[ "Inserts", "data", "into", "a", "database", "." ]
6578f51b5fb8ffe96687bcf1b8e490c2c848a396
https://github.com/jr-cologne/db-class/blob/6578f51b5fb8ffe96687bcf1b8e490c2c848a396/src/DB.php#L236-L254
232,176
jr-cologne/db-class
src/DB.php
DB.multi_insert
public function multi_insert(string $columns, array $data) { $this->query_builder->resetProperties(); $this->query_builder->setMode('insert'); $this->query_builder->setColumns($columns); $this->query_builder->setValues($columns); try { $stmt = parent::prepare($this->query_builder->getQuery()); $successful_executions = 0; foreach ($data as $value) { if ($stmt->execute($value)) { $successful_executions++; } } $data_amount = count($data); if ($data_amount === $successful_executions) { return true; } else if ($successful_executions >= 1) { return 0; } return false; } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
php
public function multi_insert(string $columns, array $data) { $this->query_builder->resetProperties(); $this->query_builder->setMode('insert'); $this->query_builder->setColumns($columns); $this->query_builder->setValues($columns); try { $stmt = parent::prepare($this->query_builder->getQuery()); $successful_executions = 0; foreach ($data as $value) { if ($stmt->execute($value)) { $successful_executions++; } } $data_amount = count($data); if ($data_amount === $successful_executions) { return true; } else if ($successful_executions >= 1) { return 0; } return false; } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
[ "public", "function", "multi_insert", "(", "string", "$", "columns", ",", "array", "$", "data", ")", "{", "$", "this", "->", "query_builder", "->", "resetProperties", "(", ")", ";", "$", "this", "->", "query_builder", "->", "setMode", "(", "'insert'", ")", ";", "$", "this", "->", "query_builder", "->", "setColumns", "(", "$", "columns", ")", ";", "$", "this", "->", "query_builder", "->", "setValues", "(", "$", "columns", ")", ";", "try", "{", "$", "stmt", "=", "parent", "::", "prepare", "(", "$", "this", "->", "query_builder", "->", "getQuery", "(", ")", ")", ";", "$", "successful_executions", "=", "0", ";", "foreach", "(", "$", "data", "as", "$", "value", ")", "{", "if", "(", "$", "stmt", "->", "execute", "(", "$", "value", ")", ")", "{", "$", "successful_executions", "++", ";", "}", "}", "$", "data_amount", "=", "count", "(", "$", "data", ")", ";", "if", "(", "$", "data_amount", "===", "$", "successful_executions", ")", "{", "return", "true", ";", "}", "else", "if", "(", "$", "successful_executions", ">=", "1", ")", "{", "return", "0", ";", "}", "return", "false", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "$", "this", "->", "pdo_exception", "=", "$", "e", ";", "return", "false", ";", "}", "}" ]
Inserts multiple rows of data into a database. @param string $columns @param array $data 2d array with assoc array of data (with the format column => value) for each row @return mixed true on success, 0 if at least one record could be inserted, false on failure
[ "Inserts", "multiple", "rows", "of", "data", "into", "a", "database", "." ]
6578f51b5fb8ffe96687bcf1b8e490c2c848a396
https://github.com/jr-cologne/db-class/blob/6578f51b5fb8ffe96687bcf1b8e490c2c848a396/src/DB.php#L263-L294
232,177
jr-cologne/db-class
src/DB.php
DB.update
public function update(array $data, array $where = []) : bool { $this->query_builder->resetProperties(); $this->query_builder->setMode('update'); $this->query_builder->setData($data); if (!empty($where)) { $this->query_builder->setWhere($where); $where = $this->formatWhereData($where); } try { $stmt = parent::prepare($this->query_builder->getQuery()); return $stmt->execute(array_merge($data, $where)); } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
php
public function update(array $data, array $where = []) : bool { $this->query_builder->resetProperties(); $this->query_builder->setMode('update'); $this->query_builder->setData($data); if (!empty($where)) { $this->query_builder->setWhere($where); $where = $this->formatWhereData($where); } try { $stmt = parent::prepare($this->query_builder->getQuery()); return $stmt->execute(array_merge($data, $where)); } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
[ "public", "function", "update", "(", "array", "$", "data", ",", "array", "$", "where", "=", "[", "]", ")", ":", "bool", "{", "$", "this", "->", "query_builder", "->", "resetProperties", "(", ")", ";", "$", "this", "->", "query_builder", "->", "setMode", "(", "'update'", ")", ";", "$", "this", "->", "query_builder", "->", "setData", "(", "$", "data", ")", ";", "if", "(", "!", "empty", "(", "$", "where", ")", ")", "{", "$", "this", "->", "query_builder", "->", "setWhere", "(", "$", "where", ")", ";", "$", "where", "=", "$", "this", "->", "formatWhereData", "(", "$", "where", ")", ";", "}", "try", "{", "$", "stmt", "=", "parent", "::", "prepare", "(", "$", "this", "->", "query_builder", "->", "getQuery", "(", ")", ")", ";", "return", "$", "stmt", "->", "execute", "(", "array_merge", "(", "$", "data", ",", "$", "where", ")", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "$", "this", "->", "pdo_exception", "=", "$", "e", ";", "return", "false", ";", "}", "}" ]
Updates data of a database. Attention: If you do not provide a where clause, all records of the table will be updated. @param array $data assoc array of new data with the format column => value @param array $where = [] assoc array with format column => value @return boolean true on success, false on failure
[ "Updates", "data", "of", "a", "database", "." ]
6578f51b5fb8ffe96687bcf1b8e490c2c848a396
https://github.com/jr-cologne/db-class/blob/6578f51b5fb8ffe96687bcf1b8e490c2c848a396/src/DB.php#L306-L326
232,178
jr-cologne/db-class
src/DB.php
DB.delete
public function delete(array $where = []) : bool { $this->query_builder->resetProperties(); $this->query_builder->setMode('delete'); if (!empty($where)) { $this->query_builder->setWhere($where); $where = $this->formatWhereData($where); } try { $stmt = parent::prepare($this->query_builder->getQuery()); return $stmt->execute($where); } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
php
public function delete(array $where = []) : bool { $this->query_builder->resetProperties(); $this->query_builder->setMode('delete'); if (!empty($where)) { $this->query_builder->setWhere($where); $where = $this->formatWhereData($where); } try { $stmt = parent::prepare($this->query_builder->getQuery()); return $stmt->execute($where); } catch (PDOException $e) { $this->pdo_exception = $e; return false; } }
[ "public", "function", "delete", "(", "array", "$", "where", "=", "[", "]", ")", ":", "bool", "{", "$", "this", "->", "query_builder", "->", "resetProperties", "(", ")", ";", "$", "this", "->", "query_builder", "->", "setMode", "(", "'delete'", ")", ";", "if", "(", "!", "empty", "(", "$", "where", ")", ")", "{", "$", "this", "->", "query_builder", "->", "setWhere", "(", "$", "where", ")", ";", "$", "where", "=", "$", "this", "->", "formatWhereData", "(", "$", "where", ")", ";", "}", "try", "{", "$", "stmt", "=", "parent", "::", "prepare", "(", "$", "this", "->", "query_builder", "->", "getQuery", "(", ")", ")", ";", "return", "$", "stmt", "->", "execute", "(", "$", "where", ")", ";", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "$", "this", "->", "pdo_exception", "=", "$", "e", ";", "return", "false", ";", "}", "}" ]
Deletes data from a database. Attention: If you do not provide a where clause, all records of the table will be deleted. @param array $where = [] assoc array with the format column => value @return boolean true on success, false on failure
[ "Deletes", "data", "from", "a", "database", "." ]
6578f51b5fb8ffe96687bcf1b8e490c2c848a396
https://github.com/jr-cologne/db-class/blob/6578f51b5fb8ffe96687bcf1b8e490c2c848a396/src/DB.php#L337-L355
232,179
detain/ip-tools
src/Ip.php
Ip.broadcast
public static function broadcast($address, $netmask) { return long2ip(ip2long(self::network($address, $netmask)) | (~(ip2long($netmask)))); }
php
public static function broadcast($address, $netmask) { return long2ip(ip2long(self::network($address, $netmask)) | (~(ip2long($netmask)))); }
[ "public", "static", "function", "broadcast", "(", "$", "address", ",", "$", "netmask", ")", "{", "return", "long2ip", "(", "ip2long", "(", "self", "::", "network", "(", "$", "address", ",", "$", "netmask", ")", ")", "|", "(", "~", "(", "ip2long", "(", "$", "netmask", ")", ")", ")", ")", ";", "}" ]
Gets the broadcast address @param string $address an ip address (ie 192.168.0.100) @param string $netmask the netmask (ie 255.255.255.0) @return string the broadcast address
[ "Gets", "the", "broadcast", "address" ]
a55989053080c31688829e8ec20a137de6350ee9
https://github.com/detain/ip-tools/blob/a55989053080c31688829e8ec20a137de6350ee9/src/Ip.php#L49-L52
232,180
detain/ip-tools
src/Ip.php
Ip.isValid
public static function isValid($ip) { $valid = self::isValidv4($ip); if ($valid) { self::$ip = $ip; self::$isv6 = false; return true; } $valid = self::isValidv6($ip); if ($valid) { self::$ip = $ip; self::$isv6 = true; return true; } return false; }
php
public static function isValid($ip) { $valid = self::isValidv4($ip); if ($valid) { self::$ip = $ip; self::$isv6 = false; return true; } $valid = self::isValidv6($ip); if ($valid) { self::$ip = $ip; self::$isv6 = true; return true; } return false; }
[ "public", "static", "function", "isValid", "(", "$", "ip", ")", "{", "$", "valid", "=", "self", "::", "isValidv4", "(", "$", "ip", ")", ";", "if", "(", "$", "valid", ")", "{", "self", "::", "$", "ip", "=", "$", "ip", ";", "self", "::", "$", "isv6", "=", "false", ";", "return", "true", ";", "}", "$", "valid", "=", "self", "::", "isValidv6", "(", "$", "ip", ")", ";", "if", "(", "$", "valid", ")", "{", "self", "::", "$", "ip", "=", "$", "ip", ";", "self", "::", "$", "isv6", "=", "true", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if an IP is valid. @param string $ip IP @return boolean true if IP is valid, otherwise false.
[ "Checks", "if", "an", "IP", "is", "valid", "." ]
a55989053080c31688829e8ec20a137de6350ee9
https://github.com/detain/ip-tools/blob/a55989053080c31688829e8ec20a137de6350ee9/src/Ip.php#L71-L87
232,181
detain/ip-tools
src/Ip.php
Ip.isLocal
public static function isLocal($ip) { $localIpv4Ranges = array( '10.*.*.*', '127.*.*.*', '192.168.*.*', '169.254.*.*', '172.16.0.0-172.31.255.255', '224.*.*.*', ); $localIpv6Ranges = array( 'fe80::/10', '::1/128', 'fc00::/7' ); if (self::isValidv4($ip)) { return self::match($ip, $localIpv4Ranges); } if (self::isValidv6($ip)) { return self::match($ip, $localIpv6Ranges); } return false; }
php
public static function isLocal($ip) { $localIpv4Ranges = array( '10.*.*.*', '127.*.*.*', '192.168.*.*', '169.254.*.*', '172.16.0.0-172.31.255.255', '224.*.*.*', ); $localIpv6Ranges = array( 'fe80::/10', '::1/128', 'fc00::/7' ); if (self::isValidv4($ip)) { return self::match($ip, $localIpv4Ranges); } if (self::isValidv6($ip)) { return self::match($ip, $localIpv6Ranges); } return false; }
[ "public", "static", "function", "isLocal", "(", "$", "ip", ")", "{", "$", "localIpv4Ranges", "=", "array", "(", "'10.*.*.*'", ",", "'127.*.*.*'", ",", "'192.168.*.*'", ",", "'169.254.*.*'", ",", "'172.16.0.0-172.31.255.255'", ",", "'224.*.*.*'", ",", ")", ";", "$", "localIpv6Ranges", "=", "array", "(", "'fe80::/10'", ",", "'::1/128'", ",", "'fc00::/7'", ")", ";", "if", "(", "self", "::", "isValidv4", "(", "$", "ip", ")", ")", "{", "return", "self", "::", "match", "(", "$", "ip", ",", "$", "localIpv4Ranges", ")", ";", "}", "if", "(", "self", "::", "isValidv6", "(", "$", "ip", ")", ")", "{", "return", "self", "::", "match", "(", "$", "ip", ",", "$", "localIpv6Ranges", ")", ";", "}", "return", "false", ";", "}" ]
Checks if an IP is local @param string $ip IP @return boolean true if the IP is local, otherwise false
[ "Checks", "if", "an", "IP", "is", "local" ]
a55989053080c31688829e8ec20a137de6350ee9
https://github.com/detain/ip-tools/blob/a55989053080c31688829e8ec20a137de6350ee9/src/Ip.php#L118-L144
232,182
detain/ip-tools
src/Ip.php
Ip.ip2long
public static function ip2long($ip) { $long = -1; if (self::isValidv6($ip)) { if (!function_exists('bcadd')) { throw new \RuntimeException('BCMATH extension not installed!'); } $ip_n = inet_pton($ip); $bin = ''; for ($bit = strlen($ip_n) - 1; $bit >= 0; $bit--) { $bin = sprintf('%08b', ord($ip_n[$bit])) . $bin; } $dec = '0'; for ($i = 0; $i < strlen($bin); $i++) { $dec = bcmul($dec, '2', 0); $dec = bcadd($dec, $bin[$i], 0); } $long = $dec; } elseif (self::isValidv4($ip)) { $long = ip2long($ip); } return $long; }
php
public static function ip2long($ip) { $long = -1; if (self::isValidv6($ip)) { if (!function_exists('bcadd')) { throw new \RuntimeException('BCMATH extension not installed!'); } $ip_n = inet_pton($ip); $bin = ''; for ($bit = strlen($ip_n) - 1; $bit >= 0; $bit--) { $bin = sprintf('%08b', ord($ip_n[$bit])) . $bin; } $dec = '0'; for ($i = 0; $i < strlen($bin); $i++) { $dec = bcmul($dec, '2', 0); $dec = bcadd($dec, $bin[$i], 0); } $long = $dec; } elseif (self::isValidv4($ip)) { $long = ip2long($ip); } return $long; }
[ "public", "static", "function", "ip2long", "(", "$", "ip", ")", "{", "$", "long", "=", "-", "1", ";", "if", "(", "self", "::", "isValidv6", "(", "$", "ip", ")", ")", "{", "if", "(", "!", "function_exists", "(", "'bcadd'", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'BCMATH extension not installed!'", ")", ";", "}", "$", "ip_n", "=", "inet_pton", "(", "$", "ip", ")", ";", "$", "bin", "=", "''", ";", "for", "(", "$", "bit", "=", "strlen", "(", "$", "ip_n", ")", "-", "1", ";", "$", "bit", ">=", "0", ";", "$", "bit", "--", ")", "{", "$", "bin", "=", "sprintf", "(", "'%08b'", ",", "ord", "(", "$", "ip_n", "[", "$", "bit", "]", ")", ")", ".", "$", "bin", ";", "}", "$", "dec", "=", "'0'", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "bin", ")", ";", "$", "i", "++", ")", "{", "$", "dec", "=", "bcmul", "(", "$", "dec", ",", "'2'", ",", "0", ")", ";", "$", "dec", "=", "bcadd", "(", "$", "dec", ",", "$", "bin", "[", "$", "i", "]", ",", "0", ")", ";", "}", "$", "long", "=", "$", "dec", ";", "}", "elseif", "(", "self", "::", "isValidv4", "(", "$", "ip", ")", ")", "{", "$", "long", "=", "ip2long", "(", "$", "ip", ")", ";", "}", "return", "$", "long", ";", "}" ]
Gets IP long representation @param string $ip IPv4 or IPv6 @return long If IP is valid returns IP long representation, otherwise -1.
[ "Gets", "IP", "long", "representation" ]
a55989053080c31688829e8ec20a137de6350ee9
https://github.com/detain/ip-tools/blob/a55989053080c31688829e8ec20a137de6350ee9/src/Ip.php#L330-L354
232,183
detain/ip-tools
src/Ip.php
Ip.long2ip
public static function long2ip($dec, $ipv6 = false) { $ipstr = ''; if ($ipv6) { if (!function_exists('bcadd')) { throw new \RuntimeException('BCMATH extension not installed!'); } $bin = ''; do { $bin = bcmod($dec, '2') . $bin; $dec = bcdiv($dec, '2', 0); } while (bccomp($dec, '0')); $bin = str_pad($bin, 128, '0', STR_PAD_LEFT); $ip = array(); for ($bit = 0; $bit <= 7; $bit++) { $bin_part = substr($bin, $bit * 16, 16); $ip[] = dechex(bindec($bin_part)); } $ip = implode(':', $ip); $ipstr = inet_ntop(inet_pton($ip)); } else { $ipstr = long2ip($dec); } return $ipstr; }
php
public static function long2ip($dec, $ipv6 = false) { $ipstr = ''; if ($ipv6) { if (!function_exists('bcadd')) { throw new \RuntimeException('BCMATH extension not installed!'); } $bin = ''; do { $bin = bcmod($dec, '2') . $bin; $dec = bcdiv($dec, '2', 0); } while (bccomp($dec, '0')); $bin = str_pad($bin, 128, '0', STR_PAD_LEFT); $ip = array(); for ($bit = 0; $bit <= 7; $bit++) { $bin_part = substr($bin, $bit * 16, 16); $ip[] = dechex(bindec($bin_part)); } $ip = implode(':', $ip); $ipstr = inet_ntop(inet_pton($ip)); } else { $ipstr = long2ip($dec); } return $ipstr; }
[ "public", "static", "function", "long2ip", "(", "$", "dec", ",", "$", "ipv6", "=", "false", ")", "{", "$", "ipstr", "=", "''", ";", "if", "(", "$", "ipv6", ")", "{", "if", "(", "!", "function_exists", "(", "'bcadd'", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'BCMATH extension not installed!'", ")", ";", "}", "$", "bin", "=", "''", ";", "do", "{", "$", "bin", "=", "bcmod", "(", "$", "dec", ",", "'2'", ")", ".", "$", "bin", ";", "$", "dec", "=", "bcdiv", "(", "$", "dec", ",", "'2'", ",", "0", ")", ";", "}", "while", "(", "bccomp", "(", "$", "dec", ",", "'0'", ")", ")", ";", "$", "bin", "=", "str_pad", "(", "$", "bin", ",", "128", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "$", "ip", "=", "array", "(", ")", ";", "for", "(", "$", "bit", "=", "0", ";", "$", "bit", "<=", "7", ";", "$", "bit", "++", ")", "{", "$", "bin_part", "=", "substr", "(", "$", "bin", ",", "$", "bit", "*", "16", ",", "16", ")", ";", "$", "ip", "[", "]", "=", "dechex", "(", "bindec", "(", "$", "bin_part", ")", ")", ";", "}", "$", "ip", "=", "implode", "(", "':'", ",", "$", "ip", ")", ";", "$", "ipstr", "=", "inet_ntop", "(", "inet_pton", "(", "$", "ip", ")", ")", ";", "}", "else", "{", "$", "ipstr", "=", "long2ip", "(", "$", "dec", ")", ";", "}", "return", "$", "ipstr", ";", "}" ]
Gets IP string representation from IP long @param long $dec IPv4 or IPv6 long @return string If IP is valid returns IP string representation, otherwise ''.
[ "Gets", "IP", "string", "representation", "from", "IP", "long" ]
a55989053080c31688829e8ec20a137de6350ee9
https://github.com/detain/ip-tools/blob/a55989053080c31688829e8ec20a137de6350ee9/src/Ip.php#L363-L389
232,184
jack-theripper/transcoder
src/Filter/Fade.php
Fade.setEffectType
public function setEffectType($effectType) { $available = [self::FADE_IN, self::FADE_OUT]; if ( ! is_scalar($effectType) || ! in_array($effectType, $available, false)) { throw new \InvalidArgumentException(sprintf('Wrong effect type value for %s, available values are %s', (string) $effectType, implode(', ', $available))); } $this->effectType = (string) $effectType; return $this; }
php
public function setEffectType($effectType) { $available = [self::FADE_IN, self::FADE_OUT]; if ( ! is_scalar($effectType) || ! in_array($effectType, $available, false)) { throw new \InvalidArgumentException(sprintf('Wrong effect type value for %s, available values are %s', (string) $effectType, implode(', ', $available))); } $this->effectType = (string) $effectType; return $this; }
[ "public", "function", "setEffectType", "(", "$", "effectType", ")", "{", "$", "available", "=", "[", "self", "::", "FADE_IN", ",", "self", "::", "FADE_OUT", "]", ";", "if", "(", "!", "is_scalar", "(", "$", "effectType", ")", "||", "!", "in_array", "(", "$", "effectType", ",", "$", "available", ",", "false", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Wrong effect type value for %s, available values are %s'", ",", "(", "string", ")", "$", "effectType", ",", "implode", "(", "', '", ",", "$", "available", ")", ")", ")", ";", "}", "$", "this", "->", "effectType", "=", "(", "string", ")", "$", "effectType", ";", "return", "$", "this", ";", "}" ]
Specify the effect type, can be either in for fade-in, or out for a fade-out effect. @param string $effectType @return Fade @throws \InvalidArgumentException
[ "Specify", "the", "effect", "type", "can", "be", "either", "in", "for", "fade", "-", "in", "or", "out", "for", "a", "fade", "-", "out", "effect", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Fade.php#L237-L250
232,185
jack-theripper/transcoder
src/Filter/Fade.php
Fade.setStartSample
public function setStartSample($startSample) { if ( ! is_numeric($startSample)) { throw new \InvalidArgumentException('The start sample value must be a number.'); } $this->startSample = (int) $startSample; return $this; }
php
public function setStartSample($startSample) { if ( ! is_numeric($startSample)) { throw new \InvalidArgumentException('The start sample value must be a number.'); } $this->startSample = (int) $startSample; return $this; }
[ "public", "function", "setStartSample", "(", "$", "startSample", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "startSample", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The start sample value must be a number.'", ")", ";", "}", "$", "this", "->", "startSample", "=", "(", "int", ")", "$", "startSample", ";", "return", "$", "this", ";", "}" ]
Specify the number of the start sample for starting to apply the fade effect. @param int $startSample @return Fade @throws \InvalidArgumentException
[ "Specify", "the", "number", "of", "the", "start", "sample", "for", "starting", "to", "apply", "the", "fade", "effect", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Fade.php#L294-L304
232,186
jack-theripper/transcoder
src/Filter/Fade.php
Fade.setNumberSamples
public function setNumberSamples($numberSamples) { if ( ! is_numeric($numberSamples)) { throw new \InvalidArgumentException('The number of samples value must be a number.'); } $this->numberSamples = (int) $numberSamples; return $this; }
php
public function setNumberSamples($numberSamples) { if ( ! is_numeric($numberSamples)) { throw new \InvalidArgumentException('The number of samples value must be a number.'); } $this->numberSamples = (int) $numberSamples; return $this; }
[ "public", "function", "setNumberSamples", "(", "$", "numberSamples", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "numberSamples", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The number of samples value must be a number.'", ")", ";", "}", "$", "this", "->", "numberSamples", "=", "(", "int", ")", "$", "numberSamples", ";", "return", "$", "this", ";", "}" ]
Specify the number of samples for which the fade effect has to last. At the end of the fade-in effect the output audio will have the same volume as the input audio, at the end of the fade-out transition the output audio will be silence. @param int $numberSamples @return Fade @throws \InvalidArgumentException
[ "Specify", "the", "number", "of", "samples", "for", "which", "the", "fade", "effect", "has", "to", "last", ".", "At", "the", "end", "of", "the", "fade", "-", "in", "effect", "the", "output", "audio", "will", "have", "the", "same", "volume", "as", "the", "input", "audio", "at", "the", "end", "of", "the", "fade", "-", "out", "transition", "the", "output", "audio", "will", "be", "silence", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Fade.php#L352-L362
232,187
jack-theripper/transcoder
src/Filter/Fade.php
Fade.setCurve
public function setCurve($curve) { $available = [ self::CURVE_TRIANGULAR, self::CURVE_QUARTER, self::CURVE_HALF_SIN, self::CURVE_EXP_SIN, self::CURVE_TRIANGULAR, self::CURVE_INV_PAR, self::CURVE_QUADRATE, self::CURVE_CUBE, self::CURVE_SQUARE_ROOT, self::CURVE_CUBIC_ROOT, self::CURVE_PAR, self::CURVE_EXP, self::CURVE_IQSIN, self::CURVE_IHSIN, self::CURVE_DOUBLE_EXP_SE, self::CURVE_DOUBLE_EXP_SI ]; if ( ! is_scalar($curve) || ! in_array($curve, $available, false)) { throw new \InvalidArgumentException(sprintf('Wrong curve value for %s, available values are %s', (string) $curve, implode(', ', $available))); } $this->curve = (string) $curve; return $this; }
php
public function setCurve($curve) { $available = [ self::CURVE_TRIANGULAR, self::CURVE_QUARTER, self::CURVE_HALF_SIN, self::CURVE_EXP_SIN, self::CURVE_TRIANGULAR, self::CURVE_INV_PAR, self::CURVE_QUADRATE, self::CURVE_CUBE, self::CURVE_SQUARE_ROOT, self::CURVE_CUBIC_ROOT, self::CURVE_PAR, self::CURVE_EXP, self::CURVE_IQSIN, self::CURVE_IHSIN, self::CURVE_DOUBLE_EXP_SE, self::CURVE_DOUBLE_EXP_SI ]; if ( ! is_scalar($curve) || ! in_array($curve, $available, false)) { throw new \InvalidArgumentException(sprintf('Wrong curve value for %s, available values are %s', (string) $curve, implode(', ', $available))); } $this->curve = (string) $curve; return $this; }
[ "public", "function", "setCurve", "(", "$", "curve", ")", "{", "$", "available", "=", "[", "self", "::", "CURVE_TRIANGULAR", ",", "self", "::", "CURVE_QUARTER", ",", "self", "::", "CURVE_HALF_SIN", ",", "self", "::", "CURVE_EXP_SIN", ",", "self", "::", "CURVE_TRIANGULAR", ",", "self", "::", "CURVE_INV_PAR", ",", "self", "::", "CURVE_QUADRATE", ",", "self", "::", "CURVE_CUBE", ",", "self", "::", "CURVE_SQUARE_ROOT", ",", "self", "::", "CURVE_CUBIC_ROOT", ",", "self", "::", "CURVE_PAR", ",", "self", "::", "CURVE_EXP", ",", "self", "::", "CURVE_IQSIN", ",", "self", "::", "CURVE_IHSIN", ",", "self", "::", "CURVE_DOUBLE_EXP_SE", ",", "self", "::", "CURVE_DOUBLE_EXP_SI", "]", ";", "if", "(", "!", "is_scalar", "(", "$", "curve", ")", "||", "!", "in_array", "(", "$", "curve", ",", "$", "available", ",", "false", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Wrong curve value for %s, available values are %s'", ",", "(", "string", ")", "$", "curve", ",", "implode", "(", "', '", ",", "$", "available", ")", ")", ")", ";", "}", "$", "this", "->", "curve", "=", "(", "string", ")", "$", "curve", ";", "return", "$", "this", ";", "}" ]
Set curve for fade transition. @param string $curve @return Fade @throws \InvalidArgumentException
[ "Set", "curve", "for", "fade", "transition", "." ]
bd87db4c76ccceafa9fc271b14013ebf12e0b32e
https://github.com/jack-theripper/transcoder/blob/bd87db4c76ccceafa9fc271b14013ebf12e0b32e/src/Filter/Fade.php#L382-L412
232,188
monarkee/bumble
Services/PostService.php
PostService.filterEmptyInput
private function filterEmptyInput($input) { foreach ($input as $key => $value) { if (empty($value)) { unset($input[$key]); } } return $input; }
php
private function filterEmptyInput($input) { foreach ($input as $key => $value) { if (empty($value)) { unset($input[$key]); } } return $input; }
[ "private", "function", "filterEmptyInput", "(", "$", "input", ")", "{", "foreach", "(", "$", "input", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "{", "unset", "(", "$", "input", "[", "$", "key", "]", ")", ";", "}", "}", "return", "$", "input", ";", "}" ]
Loop through the input and remove any key that has an empty value @param $input
[ "Loop", "through", "the", "input", "and", "remove", "any", "key", "that", "has", "an", "empty", "value" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Services/PostService.php#L174-L185
232,189
nineinchnick/yii2-usr
models/BaseUsrForm.php
BaseUsrForm.getBehaviorLabels
public function getBehaviorLabels() { $labels = []; foreach ($this->_behaviors as $name => $foo) { if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) { $labels = array_merge($labels, $behavior->attributeLabels()); } } return $labels; }
php
public function getBehaviorLabels() { $labels = []; foreach ($this->_behaviors as $name => $foo) { if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) { $labels = array_merge($labels, $behavior->attributeLabels()); } } return $labels; }
[ "public", "function", "getBehaviorLabels", "(", ")", "{", "$", "labels", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_behaviors", "as", "$", "name", "=>", "$", "foo", ")", "{", "if", "(", "(", "$", "behavior", "=", "$", "this", "->", "getBehavior", "(", "$", "name", ")", ")", "instanceof", "\\", "nineinchnick", "\\", "usr", "\\", "components", "\\", "FormModelBehavior", ")", "{", "$", "labels", "=", "array_merge", "(", "$", "labels", ",", "$", "behavior", "->", "attributeLabels", "(", ")", ")", ";", "}", "}", "return", "$", "labels", ";", "}" ]
Returns attribute labels defined in attached behaviors that extend FormModelBehavior. @return array attribute labels (name => label) @see Model::attributeLabels()
[ "Returns", "attribute", "labels", "defined", "in", "attached", "behaviors", "that", "extend", "FormModelBehavior", "." ]
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/BaseUsrForm.php#L101-L111
232,190
nineinchnick/yii2-usr
models/BaseUsrForm.php
BaseUsrForm.filterRules
public function filterRules($rules) { foreach ($this->_behaviors as $name => $foo) { if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) { $rules = $behavior->filterRules($rules); } } return $rules; }
php
public function filterRules($rules) { foreach ($this->_behaviors as $name => $foo) { if (($behavior = $this->getBehavior($name)) instanceof \nineinchnick\usr\components\FormModelBehavior) { $rules = $behavior->filterRules($rules); } } return $rules; }
[ "public", "function", "filterRules", "(", "$", "rules", ")", "{", "foreach", "(", "$", "this", "->", "_behaviors", "as", "$", "name", "=>", "$", "foo", ")", "{", "if", "(", "(", "$", "behavior", "=", "$", "this", "->", "getBehavior", "(", "$", "name", ")", ")", "instanceof", "\\", "nineinchnick", "\\", "usr", "\\", "components", "\\", "FormModelBehavior", ")", "{", "$", "rules", "=", "$", "behavior", "->", "filterRules", "(", "$", "rules", ")", ";", "}", "}", "return", "$", "rules", ";", "}" ]
Filters base rules through each attached behavior that extend FormModelBehavior, which may add their own rules or remove existing ones. @param array base form model rules @return array validation rules @see Model::rules()
[ "Filters", "base", "rules", "through", "each", "attached", "behavior", "that", "extend", "FormModelBehavior", "which", "may", "add", "their", "own", "rules", "or", "remove", "existing", "ones", "." ]
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/BaseUsrForm.php#L120-L129
232,191
nineinchnick/yii2-usr
models/BaseUsrForm.php
BaseUsrForm.behaviorValidator
public function behaviorValidator($attribute, $params) { $behavior = $params['behavior']; $validator = $params['validator']; unset($params['behavior']); unset($params['validator']); if (($behavior = $this->getBehavior($behavior)) !== null) { return $behavior->{$validator}($attribute, $params); } return true; }
php
public function behaviorValidator($attribute, $params) { $behavior = $params['behavior']; $validator = $params['validator']; unset($params['behavior']); unset($params['validator']); if (($behavior = $this->getBehavior($behavior)) !== null) { return $behavior->{$validator}($attribute, $params); } return true; }
[ "public", "function", "behaviorValidator", "(", "$", "attribute", ",", "$", "params", ")", "{", "$", "behavior", "=", "$", "params", "[", "'behavior'", "]", ";", "$", "validator", "=", "$", "params", "[", "'validator'", "]", ";", "unset", "(", "$", "params", "[", "'behavior'", "]", ")", ";", "unset", "(", "$", "params", "[", "'validator'", "]", ")", ";", "if", "(", "(", "$", "behavior", "=", "$", "this", "->", "getBehavior", "(", "$", "behavior", ")", ")", "!==", "null", ")", "{", "return", "$", "behavior", "->", "{", "$", "validator", "}", "(", "$", "attribute", ",", "$", "params", ")", ";", "}", "return", "true", ";", "}" ]
A wrapper for inline validators from behaviors extending FormModelBehavior. Set the behavior name in 'behavior' param and validator name in 'validator' param. @todo port @param $attribute string @param $params array
[ "A", "wrapper", "for", "inline", "validators", "from", "behaviors", "extending", "FormModelBehavior", ".", "Set", "the", "behavior", "name", "in", "behavior", "param", "and", "validator", "name", "in", "validator", "param", "." ]
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/models/BaseUsrForm.php#L138-L149
232,192
praxisnetau/silverstripe-moderno-admin
code/extensions/ModernoConfigExtension.php
ModernoConfigExtension.ModernoLogoImageExists
public function ModernoLogoImageExists() { if ($image = $this->owner->ModernoLogoImage()) { return ($image->exists() && file_exists($image->getFullPath())); } return false; }
php
public function ModernoLogoImageExists() { if ($image = $this->owner->ModernoLogoImage()) { return ($image->exists() && file_exists($image->getFullPath())); } return false; }
[ "public", "function", "ModernoLogoImageExists", "(", ")", "{", "if", "(", "$", "image", "=", "$", "this", "->", "owner", "->", "ModernoLogoImage", "(", ")", ")", "{", "return", "(", "$", "image", "->", "exists", "(", ")", "&&", "file_exists", "(", "$", "image", "->", "getFullPath", "(", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
Answers true if a custom logo image exists. @return boolean
[ "Answers", "true", "if", "a", "custom", "logo", "image", "exists", "." ]
8e09b43ca84eea6d3d556fe0f459860c2a397703
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/ModernoConfigExtension.php#L224-L231
232,193
praxisnetau/silverstripe-moderno-admin
code/extensions/ModernoConfigExtension.php
ModernoConfigExtension.ModernoLoadingImageExists
public function ModernoLoadingImageExists() { if ($image = $this->owner->ModernoLoadingImage()) { return ($image->exists() && file_exists($image->getFullPath())); } return false; }
php
public function ModernoLoadingImageExists() { if ($image = $this->owner->ModernoLoadingImage()) { return ($image->exists() && file_exists($image->getFullPath())); } return false; }
[ "public", "function", "ModernoLoadingImageExists", "(", ")", "{", "if", "(", "$", "image", "=", "$", "this", "->", "owner", "->", "ModernoLoadingImage", "(", ")", ")", "{", "return", "(", "$", "image", "->", "exists", "(", ")", "&&", "file_exists", "(", "$", "image", "->", "getFullPath", "(", ")", ")", ")", ";", "}", "return", "false", ";", "}" ]
Answers true if a custom loading image exists. @return boolean
[ "Answers", "true", "if", "a", "custom", "loading", "image", "exists", "." ]
8e09b43ca84eea6d3d556fe0f459860c2a397703
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/ModernoConfigExtension.php#L238-L245
232,194
praxisnetau/silverstripe-moderno-admin
code/extensions/ModernoConfigExtension.php
ModernoConfigExtension.getTargetDimensions
private function getTargetDimensions($image) { // Obtain Source Image: $si = $this->owner->{$image}(); // Obtain Source Image Dimensions: $sw = $si->getWidth(); $sh = $si->getHeight(); // Obtain Target Image Dimensions: $wp = "{$image}Width"; $hp = "{$image}Height"; $tw = $this->owner->$wp; $th = $this->owner->$hp; // Calculate Target Width/Height (if required): if ($tw && !$th && $sw) { $th = round(($tw / $sw) * $sh); } elseif (!$tw && $th && $sh) { $tw = round(($th / $sh) * $sw); } // Answer Dimensions: return array($tw, $th); }
php
private function getTargetDimensions($image) { // Obtain Source Image: $si = $this->owner->{$image}(); // Obtain Source Image Dimensions: $sw = $si->getWidth(); $sh = $si->getHeight(); // Obtain Target Image Dimensions: $wp = "{$image}Width"; $hp = "{$image}Height"; $tw = $this->owner->$wp; $th = $this->owner->$hp; // Calculate Target Width/Height (if required): if ($tw && !$th && $sw) { $th = round(($tw / $sw) * $sh); } elseif (!$tw && $th && $sh) { $tw = round(($th / $sh) * $sw); } // Answer Dimensions: return array($tw, $th); }
[ "private", "function", "getTargetDimensions", "(", "$", "image", ")", "{", "// Obtain Source Image:", "$", "si", "=", "$", "this", "->", "owner", "->", "{", "$", "image", "}", "(", ")", ";", "// Obtain Source Image Dimensions:", "$", "sw", "=", "$", "si", "->", "getWidth", "(", ")", ";", "$", "sh", "=", "$", "si", "->", "getHeight", "(", ")", ";", "// Obtain Target Image Dimensions:", "$", "wp", "=", "\"{$image}Width\"", ";", "$", "hp", "=", "\"{$image}Height\"", ";", "$", "tw", "=", "$", "this", "->", "owner", "->", "$", "wp", ";", "$", "th", "=", "$", "this", "->", "owner", "->", "$", "hp", ";", "// Calculate Target Width/Height (if required):", "if", "(", "$", "tw", "&&", "!", "$", "th", "&&", "$", "sw", ")", "{", "$", "th", "=", "round", "(", "(", "$", "tw", "/", "$", "sw", ")", "*", "$", "sh", ")", ";", "}", "elseif", "(", "!", "$", "tw", "&&", "$", "th", "&&", "$", "sh", ")", "{", "$", "tw", "=", "round", "(", "(", "$", "th", "/", "$", "sh", ")", "*", "$", "sw", ")", ";", "}", "// Answer Dimensions:", "return", "array", "(", "$", "tw", ",", "$", "th", ")", ";", "}" ]
Answers the target dimensions for the specified image. @param string $image @return array
[ "Answers", "the", "target", "dimensions", "for", "the", "specified", "image", "." ]
8e09b43ca84eea6d3d556fe0f459860c2a397703
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/ModernoConfigExtension.php#L309-L339
232,195
praxisnetau/silverstripe-moderno-admin
code/extensions/ModernoConfigExtension.php
ModernoConfigExtension.performImageResize
private function performImageResize($image, $retina = false) { // Obtain Source Image: $si = $this->owner->{$image}(); // Obtain Resize Method: $rp = "{$image}Resize"; $tr = $this->owner->$rp; // Obtain Target Dimensions: list($tw, $th) = $this->getTargetDimensions($image); // Perform Image Resize: if ($tw && $th && $tr) { // Handle Retina Flag: if ($retina) { $tw = ($tw * 2); $th = ($th * 2); } // Build Argument Array: if (strpos($tr, 'Width') !== false) { $args = array($tw); } elseif (strpos($tr, 'Height') !== false) { $args = array($th); } else { $args = array($tw, $th); } // Call Resize Method: if ($si->hasMethod($tr)) { return call_user_func_array(array($si, $tr), $args); } } // Answer Source Image (no resize): return $si; }
php
private function performImageResize($image, $retina = false) { // Obtain Source Image: $si = $this->owner->{$image}(); // Obtain Resize Method: $rp = "{$image}Resize"; $tr = $this->owner->$rp; // Obtain Target Dimensions: list($tw, $th) = $this->getTargetDimensions($image); // Perform Image Resize: if ($tw && $th && $tr) { // Handle Retina Flag: if ($retina) { $tw = ($tw * 2); $th = ($th * 2); } // Build Argument Array: if (strpos($tr, 'Width') !== false) { $args = array($tw); } elseif (strpos($tr, 'Height') !== false) { $args = array($th); } else { $args = array($tw, $th); } // Call Resize Method: if ($si->hasMethod($tr)) { return call_user_func_array(array($si, $tr), $args); } } // Answer Source Image (no resize): return $si; }
[ "private", "function", "performImageResize", "(", "$", "image", ",", "$", "retina", "=", "false", ")", "{", "// Obtain Source Image:", "$", "si", "=", "$", "this", "->", "owner", "->", "{", "$", "image", "}", "(", ")", ";", "// Obtain Resize Method:", "$", "rp", "=", "\"{$image}Resize\"", ";", "$", "tr", "=", "$", "this", "->", "owner", "->", "$", "rp", ";", "// Obtain Target Dimensions:", "list", "(", "$", "tw", ",", "$", "th", ")", "=", "$", "this", "->", "getTargetDimensions", "(", "$", "image", ")", ";", "// Perform Image Resize:", "if", "(", "$", "tw", "&&", "$", "th", "&&", "$", "tr", ")", "{", "// Handle Retina Flag:", "if", "(", "$", "retina", ")", "{", "$", "tw", "=", "(", "$", "tw", "*", "2", ")", ";", "$", "th", "=", "(", "$", "th", "*", "2", ")", ";", "}", "// Build Argument Array:", "if", "(", "strpos", "(", "$", "tr", ",", "'Width'", ")", "!==", "false", ")", "{", "$", "args", "=", "array", "(", "$", "tw", ")", ";", "}", "elseif", "(", "strpos", "(", "$", "tr", ",", "'Height'", ")", "!==", "false", ")", "{", "$", "args", "=", "array", "(", "$", "th", ")", ";", "}", "else", "{", "$", "args", "=", "array", "(", "$", "tw", ",", "$", "th", ")", ";", "}", "// Call Resize Method:", "if", "(", "$", "si", "->", "hasMethod", "(", "$", "tr", ")", ")", "{", "return", "call_user_func_array", "(", "array", "(", "$", "si", ",", "$", "tr", ")", ",", "$", "args", ")", ";", "}", "}", "// Answer Source Image (no resize):", "return", "$", "si", ";", "}" ]
Answers a resized version of the loading image. @param string $image @param boolean $retina @return Image
[ "Answers", "a", "resized", "version", "of", "the", "loading", "image", "." ]
8e09b43ca84eea6d3d556fe0f459860c2a397703
https://github.com/praxisnetau/silverstripe-moderno-admin/blob/8e09b43ca84eea6d3d556fe0f459860c2a397703/code/extensions/ModernoConfigExtension.php#L348-L397
232,196
monarkee/bumble
Fields/FileField.php
FileField.getUploadTo
public function getUploadTo($path = '') { if (isset($this->options['upload_to'])) return $this->options['upload_to']; return public_path($this->addSlashes(self::DEFAULT_UPLOAD_TO)) . $path; }
php
public function getUploadTo($path = '') { if (isset($this->options['upload_to'])) return $this->options['upload_to']; return public_path($this->addSlashes(self::DEFAULT_UPLOAD_TO)) . $path; }
[ "public", "function", "getUploadTo", "(", "$", "path", "=", "''", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "options", "[", "'upload_to'", "]", ")", ")", "return", "$", "this", "->", "options", "[", "'upload_to'", "]", ";", "return", "public_path", "(", "$", "this", "->", "addSlashes", "(", "self", "::", "DEFAULT_UPLOAD_TO", ")", ")", ".", "$", "path", ";", "}" ]
Get where the file is to be uploaded to @return mixed
[ "Get", "where", "the", "file", "is", "to", "be", "uploaded", "to" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/FileField.php#L45-L50
232,197
monarkee/bumble
Fields/FileField.php
FileField.handleFile
public function handleFile($request, $file, $filename) { $filesystem = new FileFieldUploadService([ 'file' => $file, 'filename' => $filename, 'upload_to' => $this->getUploadTo(), ]); // Write the image to the file system and move it in place $filesystem->write(); }
php
public function handleFile($request, $file, $filename) { $filesystem = new FileFieldUploadService([ 'file' => $file, 'filename' => $filename, 'upload_to' => $this->getUploadTo(), ]); // Write the image to the file system and move it in place $filesystem->write(); }
[ "public", "function", "handleFile", "(", "$", "request", ",", "$", "file", ",", "$", "filename", ")", "{", "$", "filesystem", "=", "new", "FileFieldUploadService", "(", "[", "'file'", "=>", "$", "file", ",", "'filename'", "=>", "$", "filename", ",", "'upload_to'", "=>", "$", "this", "->", "getUploadTo", "(", ")", ",", "]", ")", ";", "// Write the image to the file system and move it in place", "$", "filesystem", "->", "write", "(", ")", ";", "}" ]
Upload the file to the server @param $request @param $file @param $filename
[ "Upload", "the", "file", "to", "the", "server" ]
6e140e341980d6f9467418594eed48c3859c00f7
https://github.com/monarkee/bumble/blob/6e140e341980d6f9467418594eed48c3859c00f7/Fields/FileField.php#L79-L89
232,198
thephpleague/omnipay-netbanx
src/Message/AbstractRequest.php
AbstractRequest.translateCardType
protected function translateCardType($brand) { switch ($brand) { case CreditCard::BRAND_VISA: $cardType = 'VI'; break; case CreditCard::BRAND_AMEX: $cardType = 'AM'; break; case CreditCard::BRAND_DISCOVER: $cardType = 'DI'; break; case CreditCard::BRAND_MASTERCARD: $cardType = 'MC'; break; case CreditCard::BRAND_MAESTRO: $cardType = 'MD'; break; case CreditCard::BRAND_LASER: $cardType = 'LA'; break; case CreditCard::BRAND_SOLO: $cardType = 'SO'; break; case CreditCard::BRAND_JCB: $cardType = 'JC'; break; case CreditCard::BRAND_DINERS_CLUB: $cardType = 'DC'; break; default: $cardType = 'VI'; } return $cardType; }
php
protected function translateCardType($brand) { switch ($brand) { case CreditCard::BRAND_VISA: $cardType = 'VI'; break; case CreditCard::BRAND_AMEX: $cardType = 'AM'; break; case CreditCard::BRAND_DISCOVER: $cardType = 'DI'; break; case CreditCard::BRAND_MASTERCARD: $cardType = 'MC'; break; case CreditCard::BRAND_MAESTRO: $cardType = 'MD'; break; case CreditCard::BRAND_LASER: $cardType = 'LA'; break; case CreditCard::BRAND_SOLO: $cardType = 'SO'; break; case CreditCard::BRAND_JCB: $cardType = 'JC'; break; case CreditCard::BRAND_DINERS_CLUB: $cardType = 'DC'; break; default: $cardType = 'VI'; } return $cardType; }
[ "protected", "function", "translateCardType", "(", "$", "brand", ")", "{", "switch", "(", "$", "brand", ")", "{", "case", "CreditCard", "::", "BRAND_VISA", ":", "$", "cardType", "=", "'VI'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_AMEX", ":", "$", "cardType", "=", "'AM'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_DISCOVER", ":", "$", "cardType", "=", "'DI'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_MASTERCARD", ":", "$", "cardType", "=", "'MC'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_MAESTRO", ":", "$", "cardType", "=", "'MD'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_LASER", ":", "$", "cardType", "=", "'LA'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_SOLO", ":", "$", "cardType", "=", "'SO'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_JCB", ":", "$", "cardType", "=", "'JC'", ";", "break", ";", "case", "CreditCard", "::", "BRAND_DINERS_CLUB", ":", "$", "cardType", "=", "'DC'", ";", "break", ";", "default", ":", "$", "cardType", "=", "'VI'", ";", "}", "return", "$", "cardType", ";", "}" ]
Translate card type to internal NetBanx format @param string $brand @return string
[ "Translate", "card", "type", "to", "internal", "NetBanx", "format" ]
3684bbbf0dbdb977c1484d7252d776d81c68c813
https://github.com/thephpleague/omnipay-netbanx/blob/3684bbbf0dbdb977c1484d7252d776d81c68c813/src/Message/AbstractRequest.php#L153-L188
232,199
nineinchnick/yii2-usr
Module.php
Module.createFormModel
public function createFormModel($class, $scenario = null) { $namespacedClass = "\\nineinchnick\\usr\\models\\{$class}"; /** @var Model */ $form = new $namespacedClass(); if ($scenario !== null) { $form->setScenario($scenario); } if ($form instanceof \nineinchnick\usr\models\BaseUsrForm) { $form->webUser = Yii::$app->user; } if ($form instanceof \nineinchnick\usr\models\BasePasswordForm) { $form->passwordStrengthRules = $this->passwordStrengthRules; } switch ($class) { default: break; case 'ProfileForm': $form->pictureUploadRules = $this->pictureUploadRules; if (!empty($this->profileFormBehaviors)) { foreach ($this->profileFormBehaviors as $name => $config) { $form->attachBehavior($name, $config); } } // no break case 'RecoveryForm': if ($this->captcha !== null && \yii\captcha\Captcha::checkRequirements()) { $form->attachBehavior('captcha', [ 'class' => 'nineinchnick\usr\components\CaptchaFormBehavior', 'ruleOptions' => $class == 'ProfileForm' ? ['on' => 'register'] : ['except' => ['reset', 'verify']], ]); } break; case 'LoginForm': if ($this->loginFormBehaviors !== null && is_array($this->loginFormBehaviors)) { foreach ($this->loginFormBehaviors as $name => $config) { $form->attachBehavior($name, $config); } } break; case 'AuthForm': $form->setValidProviders(array_keys(Yii::$app->get('authClientCollection')->clients)); break; } return $form; }
php
public function createFormModel($class, $scenario = null) { $namespacedClass = "\\nineinchnick\\usr\\models\\{$class}"; /** @var Model */ $form = new $namespacedClass(); if ($scenario !== null) { $form->setScenario($scenario); } if ($form instanceof \nineinchnick\usr\models\BaseUsrForm) { $form->webUser = Yii::$app->user; } if ($form instanceof \nineinchnick\usr\models\BasePasswordForm) { $form->passwordStrengthRules = $this->passwordStrengthRules; } switch ($class) { default: break; case 'ProfileForm': $form->pictureUploadRules = $this->pictureUploadRules; if (!empty($this->profileFormBehaviors)) { foreach ($this->profileFormBehaviors as $name => $config) { $form->attachBehavior($name, $config); } } // no break case 'RecoveryForm': if ($this->captcha !== null && \yii\captcha\Captcha::checkRequirements()) { $form->attachBehavior('captcha', [ 'class' => 'nineinchnick\usr\components\CaptchaFormBehavior', 'ruleOptions' => $class == 'ProfileForm' ? ['on' => 'register'] : ['except' => ['reset', 'verify']], ]); } break; case 'LoginForm': if ($this->loginFormBehaviors !== null && is_array($this->loginFormBehaviors)) { foreach ($this->loginFormBehaviors as $name => $config) { $form->attachBehavior($name, $config); } } break; case 'AuthForm': $form->setValidProviders(array_keys(Yii::$app->get('authClientCollection')->clients)); break; } return $form; }
[ "public", "function", "createFormModel", "(", "$", "class", ",", "$", "scenario", "=", "null", ")", "{", "$", "namespacedClass", "=", "\"\\\\nineinchnick\\\\usr\\\\models\\\\{$class}\"", ";", "/** @var Model */", "$", "form", "=", "new", "$", "namespacedClass", "(", ")", ";", "if", "(", "$", "scenario", "!==", "null", ")", "{", "$", "form", "->", "setScenario", "(", "$", "scenario", ")", ";", "}", "if", "(", "$", "form", "instanceof", "\\", "nineinchnick", "\\", "usr", "\\", "models", "\\", "BaseUsrForm", ")", "{", "$", "form", "->", "webUser", "=", "Yii", "::", "$", "app", "->", "user", ";", "}", "if", "(", "$", "form", "instanceof", "\\", "nineinchnick", "\\", "usr", "\\", "models", "\\", "BasePasswordForm", ")", "{", "$", "form", "->", "passwordStrengthRules", "=", "$", "this", "->", "passwordStrengthRules", ";", "}", "switch", "(", "$", "class", ")", "{", "default", ":", "break", ";", "case", "'ProfileForm'", ":", "$", "form", "->", "pictureUploadRules", "=", "$", "this", "->", "pictureUploadRules", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "profileFormBehaviors", ")", ")", "{", "foreach", "(", "$", "this", "->", "profileFormBehaviors", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "form", "->", "attachBehavior", "(", "$", "name", ",", "$", "config", ")", ";", "}", "}", "// no break", "case", "'RecoveryForm'", ":", "if", "(", "$", "this", "->", "captcha", "!==", "null", "&&", "\\", "yii", "\\", "captcha", "\\", "Captcha", "::", "checkRequirements", "(", ")", ")", "{", "$", "form", "->", "attachBehavior", "(", "'captcha'", ",", "[", "'class'", "=>", "'nineinchnick\\usr\\components\\CaptchaFormBehavior'", ",", "'ruleOptions'", "=>", "$", "class", "==", "'ProfileForm'", "?", "[", "'on'", "=>", "'register'", "]", ":", "[", "'except'", "=>", "[", "'reset'", ",", "'verify'", "]", "]", ",", "]", ")", ";", "}", "break", ";", "case", "'LoginForm'", ":", "if", "(", "$", "this", "->", "loginFormBehaviors", "!==", "null", "&&", "is_array", "(", "$", "this", "->", "loginFormBehaviors", ")", ")", "{", "foreach", "(", "$", "this", "->", "loginFormBehaviors", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "form", "->", "attachBehavior", "(", "$", "name", ",", "$", "config", ")", ";", "}", "}", "break", ";", "case", "'AuthForm'", ":", "$", "form", "->", "setValidProviders", "(", "array_keys", "(", "Yii", "::", "$", "app", "->", "get", "(", "'authClientCollection'", ")", "->", "clients", ")", ")", ";", "break", ";", "}", "return", "$", "form", ";", "}" ]
A factory to create pre-configured form models. Only model class names from the nineinchnick\usr\models namespace are allowed. Sets scenario, password strength rules for models extending BasePasswordForm and attaches behaviors. @param string $class without the namespace @param string $scenario @return Model
[ "A", "factory", "to", "create", "pre", "-", "configured", "form", "models", ".", "Only", "model", "class", "names", "from", "the", "nineinchnick", "\\", "usr", "\\", "models", "namespace", "are", "allowed", ".", "Sets", "scenario", "password", "strength", "rules", "for", "models", "extending", "BasePasswordForm", "and", "attaches", "behaviors", "." ]
d51fbe95eeba0068cc4543efa3bca7baa30ed5e6
https://github.com/nineinchnick/yii2-usr/blob/d51fbe95eeba0068cc4543efa3bca7baa30ed5e6/Module.php#L151-L199