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
225,200
n2n/n2n-log4php
src/app/n2n/log4php/Logger.php
Logger.getHierarchy
public static function getHierarchy() { if(!isset(self::$hierarchy)) { self::$hierarchy = new \n2n\log4php\LoggerHierarchy(new LoggerRoot()); } return self::$hierarchy; }
php
public static function getHierarchy() { if(!isset(self::$hierarchy)) { self::$hierarchy = new \n2n\log4php\LoggerHierarchy(new LoggerRoot()); } return self::$hierarchy; }
[ "public", "static", "function", "getHierarchy", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "hierarchy", ")", ")", "{", "self", "::", "$", "hierarchy", "=", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerHierarchy", "(", "new", "LoggerRoot", "(", ")", ")", ";", "}", "return", "self", "::", "$", "hierarchy", ";", "}" ]
Returns the hierarchy used by this Logger. Caution: do not use this hierarchy unless you have called initialize(). To get Loggers, use the Logger::getLogger and Logger::getRootLogger methods instead of operating on on the hierarchy directly. @return \n2n\log4php\LoggerHierarchy
[ "Returns", "the", "hierarchy", "used", "by", "this", "Logger", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L450-L455
225,201
n2n/n2n-log4php
src/app/n2n/log4php/Logger.php
Logger.getConfigurator
private static function getConfigurator($configurator = null) { if ($configurator === null) { return new \n2n\log4php\configurator\ConfiguratorDefault(); } if (is_object($configurator)) { if ($configurator instanceof \n2n\log4php\LoggerConfigurator) { return $configurator; } else { throw new \n2n\log4php\LoggerException("log4php: Given configurator object [$configurator] does not implement the \n2n\log4php\LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); } } if (is_string($configurator)) { if (!class_exists($configurator)) { throw new \n2n\log4php\LoggerException("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); } $instance = new $configurator(); if (!($instance instanceof \n2n\log4php\LoggerConfigurator)) { throw new \n2n\log4php\LoggerException("log4php: Specified configurator class [$configurator] does not implement the \n2n\log4php\LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); } return $instance; } throw new \n2n\log4php\LoggerException("log4php: Invalid configurator specified. Expected either a string or a \\n2n\\log4php\\LoggerConfigurator instance. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); }
php
private static function getConfigurator($configurator = null) { if ($configurator === null) { return new \n2n\log4php\configurator\ConfiguratorDefault(); } if (is_object($configurator)) { if ($configurator instanceof \n2n\log4php\LoggerConfigurator) { return $configurator; } else { throw new \n2n\log4php\LoggerException("log4php: Given configurator object [$configurator] does not implement the \n2n\log4php\LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); } } if (is_string($configurator)) { if (!class_exists($configurator)) { throw new \n2n\log4php\LoggerException("log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); } $instance = new $configurator(); if (!($instance instanceof \n2n\log4php\LoggerConfigurator)) { throw new \n2n\log4php\LoggerException("log4php: Specified configurator class [$configurator] does not implement the \n2n\log4php\LoggerConfigurator interface. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); } return $instance; } throw new \n2n\log4php\LoggerException("log4php: Invalid configurator specified. Expected either a string or a \\n2n\\log4php\\LoggerConfigurator instance. Reverting to default configurator.", E_USER_WARNING); return new \n2n\log4php\configurator\ConfiguratorDefault(); }
[ "private", "static", "function", "getConfigurator", "(", "$", "configurator", "=", "null", ")", "{", "if", "(", "$", "configurator", "===", "null", ")", "{", "return", "new", "\\", "n2n", "\\", "log4php", "\\", "configurator", "\\", "ConfiguratorDefault", "(", ")", ";", "}", "if", "(", "is_object", "(", "$", "configurator", ")", ")", "{", "if", "(", "$", "configurator", "instanceof", "\\", "n2n", "\\", "log4php", "\\", "LoggerConfigurator", ")", "{", "return", "$", "configurator", ";", "}", "else", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Given configurator object [$configurator] does not implement the \\n2n\\log4php\\LoggerConfigurator interface. Reverting to default configurator.\"", ",", "E_USER_WARNING", ")", ";", "return", "new", "\\", "n2n", "\\", "log4php", "\\", "configurator", "\\", "ConfiguratorDefault", "(", ")", ";", "}", "}", "if", "(", "is_string", "(", "$", "configurator", ")", ")", "{", "if", "(", "!", "class_exists", "(", "$", "configurator", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Specified configurator class [$configurator] does not exist. Reverting to default configurator.\"", ",", "E_USER_WARNING", ")", ";", "return", "new", "\\", "n2n", "\\", "log4php", "\\", "configurator", "\\", "ConfiguratorDefault", "(", ")", ";", "}", "$", "instance", "=", "new", "$", "configurator", "(", ")", ";", "if", "(", "!", "(", "$", "instance", "instanceof", "\\", "n2n", "\\", "log4php", "\\", "LoggerConfigurator", ")", ")", "{", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Specified configurator class [$configurator] does not implement the \\n2n\\log4php\\LoggerConfigurator interface. Reverting to default configurator.\"", ",", "E_USER_WARNING", ")", ";", "return", "new", "\\", "n2n", "\\", "log4php", "\\", "configurator", "\\", "ConfiguratorDefault", "(", ")", ";", "}", "return", "$", "instance", ";", "}", "throw", "new", "\\", "n2n", "\\", "log4php", "\\", "LoggerException", "(", "\"log4php: Invalid configurator specified. Expected either a string or a \\\\n2n\\\\log4php\\\\LoggerConfigurator instance. Reverting to default configurator.\"", ",", "E_USER_WARNING", ")", ";", "return", "new", "\\", "n2n", "\\", "log4php", "\\", "configurator", "\\", "ConfiguratorDefault", "(", ")", ";", "}" ]
Creates a logger configurator instance based on the provided configurator class. If no class is given, returns an instance of the default configurator. @param string|\n2n\log4php\LoggerConfigurator $configurator The configurator class or \n2n\log4php\LoggerConfigurator instance.
[ "Creates", "a", "logger", "configurator", "instance", "based", "on", "the", "provided", "configurator", "class", ".", "If", "no", "class", "is", "given", "returns", "an", "instance", "of", "the", "default", "configurator", "." ]
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/Logger.php#L556-L588
225,202
froq/froq-database
src/model/Oppa.php
Oppa.initQueryBuilder
public final function initQueryBuilder(string $stack = null, bool $isSub = false): QueryBuilder { $stack = $stack ?? $this->getStack(); // use self stack if $stack is null if ($stack == null) { throw new DatabaseException(sprintf("Null \$stack, set it in '%s' class", static::class)); } return new QueryBuilder($this->vendor->getDatabase()->getLink(), $stack, $isSub); }
php
public final function initQueryBuilder(string $stack = null, bool $isSub = false): QueryBuilder { $stack = $stack ?? $this->getStack(); // use self stack if $stack is null if ($stack == null) { throw new DatabaseException(sprintf("Null \$stack, set it in '%s' class", static::class)); } return new QueryBuilder($this->vendor->getDatabase()->getLink(), $stack, $isSub); }
[ "public", "final", "function", "initQueryBuilder", "(", "string", "$", "stack", "=", "null", ",", "bool", "$", "isSub", "=", "false", ")", ":", "QueryBuilder", "{", "$", "stack", "=", "$", "stack", "??", "$", "this", "->", "getStack", "(", ")", ";", "// use self stack if $stack is null", "if", "(", "$", "stack", "==", "null", ")", "{", "throw", "new", "DatabaseException", "(", "sprintf", "(", "\"Null \\$stack, set it in '%s' class\"", ",", "static", "::", "class", ")", ")", ";", "}", "return", "new", "QueryBuilder", "(", "$", "this", "->", "vendor", "->", "getDatabase", "(", ")", "->", "getLink", "(", ")", ",", "$", "stack", ",", "$", "isSub", ")", ";", "}" ]
Init query builder. @param string|null $stack @param bool $isSub @return Oppa\Query\Builder @throws froq\database\DatabaseException
[ "Init", "query", "builder", "." ]
829732986f9f9db4ef83ce87f0461f190947c958
https://github.com/froq/froq-database/blob/829732986f9f9db4ef83ce87f0461f190947c958/src/model/Oppa.php#L308-L317
225,203
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.getValue
public function getValue(array $array, string $path) { // If the $path value is empty, return the entire array graph if ($this->isRoot($path)) { return $array; } // If $path doesn't exist returns null. It is not possible to distinghuish between a path that exists and has a // null value and a path that doesn't exist at all. return $this->pa->getValue($array, $path); }
php
public function getValue(array $array, string $path) { // If the $path value is empty, return the entire array graph if ($this->isRoot($path)) { return $array; } // If $path doesn't exist returns null. It is not possible to distinghuish between a path that exists and has a // null value and a path that doesn't exist at all. return $this->pa->getValue($array, $path); }
[ "public", "function", "getValue", "(", "array", "$", "array", ",", "string", "$", "path", ")", "{", "// If the $path value is empty, return the entire array graph", "if", "(", "$", "this", "->", "isRoot", "(", "$", "path", ")", ")", "{", "return", "$", "array", ";", "}", "// If $path doesn't exist returns null. It is not possible to distinghuish between a path that exists and has a", "// null value and a path that doesn't exist at all.", "return", "$", "this", "->", "pa", "->", "getValue", "(", "$", "array", ",", "$", "path", ")", ";", "}" ]
Get the value of the given path from the array graph. @param array $array @param string $path @return array|string
[ "Get", "the", "value", "of", "the", "given", "path", "from", "the", "array", "graph", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L56-L66
225,204
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.getValueByPartialKey
public function getValueByPartialKey(array $array, string $searchingKey): ?string { foreach ($array as $key => $value) { if (false !== stripos($key, $searchingKey)) { return $value; } } return null; }
php
public function getValueByPartialKey(array $array, string $searchingKey): ?string { foreach ($array as $key => $value) { if (false !== stripos($key, $searchingKey)) { return $value; } } return null; }
[ "public", "function", "getValueByPartialKey", "(", "array", "$", "array", ",", "string", "$", "searchingKey", ")", ":", "?", "string", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "false", "!==", "stripos", "(", "$", "key", ",", "$", "searchingKey", ")", ")", "{", "return", "$", "value", ";", "}", "}", "return", "null", ";", "}" ]
This just searches in the first level, not in deeper ones. @param array $array @param string $searchingKey @return string|null
[ "This", "just", "searches", "in", "the", "first", "level", "not", "in", "deeper", "ones", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L76-L85
225,205
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.isReadable
public function isReadable(array $array, string $path): bool { try { return $this->pa->isReadable($array, $path); } catch (\Exception $e) { return false; } }
php
public function isReadable(array $array, string $path): bool { try { return $this->pa->isReadable($array, $path); } catch (\Exception $e) { return false; } }
[ "public", "function", "isReadable", "(", "array", "$", "array", ",", "string", "$", "path", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "pa", "->", "isReadable", "(", "$", "array", ",", "$", "path", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Checks if a path exists in the given array. @param array $array @param string $path @return bool
[ "Checks", "if", "a", "path", "exists", "in", "the", "given", "array", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L108-L115
225,206
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.add
public function add(array &$array, string $toPath, $value, string $propertyForNewValue = '', string $propertyForOldValue = ''): void { // Get the value at destination path (to preserve it if isn't an array) $currentValue = $this->getValue($array, $toPath); // If the current value isn't yet an array... if (false === is_array($currentValue)) { // ... Transform the current value into an array $currentValue = '' === $propertyForOldValue // Use the autogenerated keys ? [$currentValue] // Use the passed key name : [$propertyForOldValue => $currentValue]; } // Add the new value to the array if ('' === $propertyForNewValue) { // If no property name is set for the new value, simply add it $currentValue[] = $value; } else { // Remove "[" and "]" $propertyForNewValue = rtrim(ltrim($propertyForNewValue, '['), ']'); // ! ! ! THIS MAY OVERWRITE A YET EXISTENT VALUE ! ! ! $currentValue[$propertyForNewValue] = $value; } $this->edit($array, $toPath, $currentValue); }
php
public function add(array &$array, string $toPath, $value, string $propertyForNewValue = '', string $propertyForOldValue = ''): void { // Get the value at destination path (to preserve it if isn't an array) $currentValue = $this->getValue($array, $toPath); // If the current value isn't yet an array... if (false === is_array($currentValue)) { // ... Transform the current value into an array $currentValue = '' === $propertyForOldValue // Use the autogenerated keys ? [$currentValue] // Use the passed key name : [$propertyForOldValue => $currentValue]; } // Add the new value to the array if ('' === $propertyForNewValue) { // If no property name is set for the new value, simply add it $currentValue[] = $value; } else { // Remove "[" and "]" $propertyForNewValue = rtrim(ltrim($propertyForNewValue, '['), ']'); // ! ! ! THIS MAY OVERWRITE A YET EXISTENT VALUE ! ! ! $currentValue[$propertyForNewValue] = $value; } $this->edit($array, $toPath, $currentValue); }
[ "public", "function", "add", "(", "array", "&", "$", "array", ",", "string", "$", "toPath", ",", "$", "value", ",", "string", "$", "propertyForNewValue", "=", "''", ",", "string", "$", "propertyForOldValue", "=", "''", ")", ":", "void", "{", "// Get the value at destination path (to preserve it if isn't an array)", "$", "currentValue", "=", "$", "this", "->", "getValue", "(", "$", "array", ",", "$", "toPath", ")", ";", "// If the current value isn't yet an array...", "if", "(", "false", "===", "is_array", "(", "$", "currentValue", ")", ")", "{", "// ... Transform the current value into an array", "$", "currentValue", "=", "''", "===", "$", "propertyForOldValue", "// Use the autogenerated keys", "?", "[", "$", "currentValue", "]", "// Use the passed key name", ":", "[", "$", "propertyForOldValue", "=>", "$", "currentValue", "]", ";", "}", "// Add the new value to the array", "if", "(", "''", "===", "$", "propertyForNewValue", ")", "{", "// If no property name is set for the new value, simply add it", "$", "currentValue", "[", "]", "=", "$", "value", ";", "}", "else", "{", "// Remove \"[\" and \"]\"", "$", "propertyForNewValue", "=", "rtrim", "(", "ltrim", "(", "$", "propertyForNewValue", ",", "'['", ")", ",", "']'", ")", ";", "// ! ! ! THIS MAY OVERWRITE A YET EXISTENT VALUE ! ! !", "$", "currentValue", "[", "$", "propertyForNewValue", "]", "=", "$", "value", ";", "}", "$", "this", "->", "edit", "(", "$", "array", ",", "$", "toPath", ",", "$", "currentValue", ")", ";", "}" ]
Adds a value to a node. The method can recognize if the current value at $toPath is a string: if it is, the method first transforms the current value into an array and then adds the new value to this new array, so preserving the already present value. Passing $propertyForNewValue and $propertyForOldValue it is possible to set the property names of the already present value and of the newly created value. If the key doesn't exist, the method simply adds it. @param array $array Passed by reference @param string $toPath The location where to add the value taken $fromPath @param mixed $value The value to add @param string $propertyForNewValue The name to give to the new property @param string $propertyForOldValue The old value is now assigned to a property: this is its property name
[ "Adds", "a", "value", "to", "a", "node", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L202-L230
225,207
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.edit
public function edit(array &$array, string $path, $value): void { // If $path is not writable if (false === $this->isRoot($path) && false === $this->pa->isReadable($array, $path)) { throw new AccessException(sprintf('The path "%s" you are trying to edit isn\'t readable and so cannot be edited.', $path)); } if ($this->isRoot($path)) { $array = $value; } else { $this->pa->setValue($array, $path, $value); } }
php
public function edit(array &$array, string $path, $value): void { // If $path is not writable if (false === $this->isRoot($path) && false === $this->pa->isReadable($array, $path)) { throw new AccessException(sprintf('The path "%s" you are trying to edit isn\'t readable and so cannot be edited.', $path)); } if ($this->isRoot($path)) { $array = $value; } else { $this->pa->setValue($array, $path, $value); } }
[ "public", "function", "edit", "(", "array", "&", "$", "array", ",", "string", "$", "path", ",", "$", "value", ")", ":", "void", "{", "// If $path is not writable", "if", "(", "false", "===", "$", "this", "->", "isRoot", "(", "$", "path", ")", "&&", "false", "===", "$", "this", "->", "pa", "->", "isReadable", "(", "$", "array", ",", "$", "path", ")", ")", "{", "throw", "new", "AccessException", "(", "sprintf", "(", "'The path \"%s\" you are trying to edit isn\\'t readable and so cannot be edited.'", ",", "$", "path", ")", ")", ";", "}", "if", "(", "$", "this", "->", "isRoot", "(", "$", "path", ")", ")", "{", "$", "array", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "pa", "->", "setValue", "(", "$", "array", ",", "$", "path", ",", "$", "value", ")", ";", "}", "}" ]
Edits the value at the given path. @param array $array @param string $path @param $value @throws AccessException If the path to edit is not readable
[ "Edits", "the", "value", "at", "the", "given", "path", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L295-L307
225,208
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.mvUp
public function mvUp(array &$array, string $path): void { // Build the path object $pathObject = new PropertyPath($path); // get the values to move one level up $values = $this->pa->getValue($array, $path); // Remove the key to move one level up $this->rm($array, $path); $parentPath = null === $pathObject->getParent() ? '[]' : $pathObject->getParent(); // Get the values of the up level $parentValues = $this->getValue($array, $parentPath); $mergedArray = array_merge($this->forceArray($parentValues), $this->forceArray($values)); $this->edit($array, $parentPath, $mergedArray); }
php
public function mvUp(array &$array, string $path): void { // Build the path object $pathObject = new PropertyPath($path); // get the values to move one level up $values = $this->pa->getValue($array, $path); // Remove the key to move one level up $this->rm($array, $path); $parentPath = null === $pathObject->getParent() ? '[]' : $pathObject->getParent(); // Get the values of the up level $parentValues = $this->getValue($array, $parentPath); $mergedArray = array_merge($this->forceArray($parentValues), $this->forceArray($values)); $this->edit($array, $parentPath, $mergedArray); }
[ "public", "function", "mvUp", "(", "array", "&", "$", "array", ",", "string", "$", "path", ")", ":", "void", "{", "// Build the path object", "$", "pathObject", "=", "new", "PropertyPath", "(", "$", "path", ")", ";", "// get the values to move one level up", "$", "values", "=", "$", "this", "->", "pa", "->", "getValue", "(", "$", "array", ",", "$", "path", ")", ";", "// Remove the key to move one level up", "$", "this", "->", "rm", "(", "$", "array", ",", "$", "path", ")", ";", "$", "parentPath", "=", "null", "===", "$", "pathObject", "->", "getParent", "(", ")", "?", "'[]'", ":", "$", "pathObject", "->", "getParent", "(", ")", ";", "// Get the values of the up level", "$", "parentValues", "=", "$", "this", "->", "getValue", "(", "$", "array", ",", "$", "parentPath", ")", ";", "$", "mergedArray", "=", "array_merge", "(", "$", "this", "->", "forceArray", "(", "$", "parentValues", ")", ",", "$", "this", "->", "forceArray", "(", "$", "values", ")", ")", ";", "$", "this", "->", "edit", "(", "$", "array", ",", "$", "parentPath", ",", "$", "mergedArray", ")", ";", "}" ]
Moves a value one level up in the array. Example: $array = [ 'level1' => ['value 1.1', 'value 1.2', 'value 1.3'], 'level2' => ['key1' => 'value 2.1', 'value 2.2', 'value 2.3'] ]; is transformed into the array: $array = [ 'level1' => ['value 1.1', 'value 1.2', 'value 1.3'], 'key' => 'value 2.1', 1 => 'value 2.2', 2 => 'value 2.3' ]; @param array $array @param string $path
[ "Moves", "a", "value", "one", "level", "up", "in", "the", "array", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L390-L409
225,209
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.rm
public function rm(array &$array, string $path): void { // This way it will trigger an error if the calculated value is not correct $node = null; $path = new PropertyPathBuilder($path); $nodes = $path->getPropertyPath()->getElements(); $parentLevel = null; $currentLevel = &$array; foreach ($nodes as &$node) { $parentLevel = &$currentLevel; $currentLevel = &$currentLevel[$node]; } if (null !== $parentLevel) { unset($parentLevel[$node]); } }
php
public function rm(array &$array, string $path): void { // This way it will trigger an error if the calculated value is not correct $node = null; $path = new PropertyPathBuilder($path); $nodes = $path->getPropertyPath()->getElements(); $parentLevel = null; $currentLevel = &$array; foreach ($nodes as &$node) { $parentLevel = &$currentLevel; $currentLevel = &$currentLevel[$node]; } if (null !== $parentLevel) { unset($parentLevel[$node]); } }
[ "public", "function", "rm", "(", "array", "&", "$", "array", ",", "string", "$", "path", ")", ":", "void", "{", "// This way it will trigger an error if the calculated value is not correct", "$", "node", "=", "null", ";", "$", "path", "=", "new", "PropertyPathBuilder", "(", "$", "path", ")", ";", "$", "nodes", "=", "$", "path", "->", "getPropertyPath", "(", ")", "->", "getElements", "(", ")", ";", "$", "parentLevel", "=", "null", ";", "$", "currentLevel", "=", "&", "$", "array", ";", "foreach", "(", "$", "nodes", "as", "&", "$", "node", ")", "{", "$", "parentLevel", "=", "&", "$", "currentLevel", ";", "$", "currentLevel", "=", "&", "$", "currentLevel", "[", "$", "node", "]", ";", "}", "if", "(", "null", "!==", "$", "parentLevel", ")", "{", "unset", "(", "$", "parentLevel", "[", "$", "node", "]", ")", ";", "}", "}" ]
Removes an element from the array. @see http://stackoverflow.com/a/16698855/1399706 @param array $array @param string $path
[ "Removes", "an", "element", "from", "the", "array", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L419-L436
225,210
Aerendir/PHPArrayWriter
src/ArrayWriter.php
ArrayWriter.wrap
public function wrap(array &$array, string $path, string $wrapperName): void { // Get the value to move: if path is empty, get the full array graph $value = (empty($path) || '[]' === $path) ? $array : $this->pa->getValue($array, $path); // Remove eventual [ or ] from the $wrapperName $wrapperName = $this->unpathize($wrapperName); $value = [$wrapperName => $value]; // Set the new value: if path is empty, edit the full Array Graph, edit only the given path instead if (empty($path)) { $array = $value; } else { $this->edit($array, $path, $value); } }
php
public function wrap(array &$array, string $path, string $wrapperName): void { // Get the value to move: if path is empty, get the full array graph $value = (empty($path) || '[]' === $path) ? $array : $this->pa->getValue($array, $path); // Remove eventual [ or ] from the $wrapperName $wrapperName = $this->unpathize($wrapperName); $value = [$wrapperName => $value]; // Set the new value: if path is empty, edit the full Array Graph, edit only the given path instead if (empty($path)) { $array = $value; } else { $this->edit($array, $path, $value); } }
[ "public", "function", "wrap", "(", "array", "&", "$", "array", ",", "string", "$", "path", ",", "string", "$", "wrapperName", ")", ":", "void", "{", "// Get the value to move: if path is empty, get the full array graph", "$", "value", "=", "(", "empty", "(", "$", "path", ")", "||", "'[]'", "===", "$", "path", ")", "?", "$", "array", ":", "$", "this", "->", "pa", "->", "getValue", "(", "$", "array", ",", "$", "path", ")", ";", "// Remove eventual [ or ] from the $wrapperName", "$", "wrapperName", "=", "$", "this", "->", "unpathize", "(", "$", "wrapperName", ")", ";", "$", "value", "=", "[", "$", "wrapperName", "=>", "$", "value", "]", ";", "// Set the new value: if path is empty, edit the full Array Graph, edit only the given path instead", "if", "(", "empty", "(", "$", "path", ")", ")", "{", "$", "array", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "edit", "(", "$", "array", ",", "$", "path", ",", "$", "value", ")", ";", "}", "}" ]
Adds a parent key to the current array. For example, given this array: $array = [ 0 => 'element 0', 1 => 'element 1', 2 => 'element 2', ... ]; calling ArrayWriter('', 'root') will rearrange the array in this way: $array = [ 'root' => [ 0 => 'element 0', 1 => 'element 1', 2 => 'element 2', ... ] ]; @param array $array @param string $path @param string $wrapperName
[ "Adds", "a", "parent", "key", "to", "the", "current", "array", "." ]
de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf
https://github.com/Aerendir/PHPArrayWriter/blob/de3015f8cefe9ceaf4fc704e8cbf5153dc613ebf/src/ArrayWriter.php#L459-L475
225,211
egulias/ListenersDebug
Listener/ListenerFetcher.php
ListenerFetcher.getEventSubscriberInformation
public function getEventSubscriberInformation($class) { $events = array(); $reflectionClass = new \ReflectionClass($class); $interfaces = $reflectionClass->getInterfaceNames(); foreach ($interfaces as $interface) { if ($interface == 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface') { return $class::getSubscribedEvents(); } } return $events; }
php
public function getEventSubscriberInformation($class) { $events = array(); $reflectionClass = new \ReflectionClass($class); $interfaces = $reflectionClass->getInterfaceNames(); foreach ($interfaces as $interface) { if ($interface == 'Symfony\\Component\\EventDispatcher\\EventSubscriberInterface') { return $class::getSubscribedEvents(); } } return $events; }
[ "public", "function", "getEventSubscriberInformation", "(", "$", "class", ")", "{", "$", "events", "=", "array", "(", ")", ";", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "class", ")", ";", "$", "interfaces", "=", "$", "reflectionClass", "->", "getInterfaceNames", "(", ")", ";", "foreach", "(", "$", "interfaces", "as", "$", "interface", ")", "{", "if", "(", "$", "interface", "==", "'Symfony\\\\Component\\\\EventDispatcher\\\\EventSubscriberInterface'", ")", "{", "return", "$", "class", "::", "getSubscribedEvents", "(", ")", ";", "}", "}", "return", "$", "events", ";", "}" ]
Obtains the information available from class if it is defined as an EventSubscriber @param string $class Fully qualified class name @return array array('event.name' => array(array('method','priority')))
[ "Obtains", "the", "information", "available", "from", "class", "if", "it", "is", "defined", "as", "an", "EventSubscriber" ]
7f9d5aaed942be69e058dc7b99d4e802304482c0
https://github.com/egulias/ListenersDebug/blob/7f9d5aaed942be69e058dc7b99d4e802304482c0/Listener/ListenerFetcher.php#L131-L143
225,212
bytic/Common
src/Controllers/Traits/Models/HasModelManagerTrait.php
HasModelManagerTrait.initModelManager
protected function initModelManager() { $managerClass = $this->getModel(); $modelManager = $this->newModelManagerInstance($this->getModel()); if ($modelManager instanceof RecordManager) { $this->modelManager = $this->newModelManagerInstance($this->getModel()); } else { throw new Exception( "invalid ModelManager name [$managerClass] for controller [" . $this->getClassName() . "]" ); } }
php
protected function initModelManager() { $managerClass = $this->getModel(); $modelManager = $this->newModelManagerInstance($this->getModel()); if ($modelManager instanceof RecordManager) { $this->modelManager = $this->newModelManagerInstance($this->getModel()); } else { throw new Exception( "invalid ModelManager name [$managerClass] for controller [" . $this->getClassName() . "]" ); } }
[ "protected", "function", "initModelManager", "(", ")", "{", "$", "managerClass", "=", "$", "this", "->", "getModel", "(", ")", ";", "$", "modelManager", "=", "$", "this", "->", "newModelManagerInstance", "(", "$", "this", "->", "getModel", "(", ")", ")", ";", "if", "(", "$", "modelManager", "instanceof", "RecordManager", ")", "{", "$", "this", "->", "modelManager", "=", "$", "this", "->", "newModelManagerInstance", "(", "$", "this", "->", "getModel", "(", ")", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "\"invalid ModelManager name [$managerClass] \n for controller [\"", ".", "$", "this", "->", "getClassName", "(", ")", ".", "\"]\"", ")", ";", "}", "}" ]
Init the Model Manager @throws Exception @return void
[ "Init", "the", "Model", "Manager" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/Models/HasModelManagerTrait.php#L53-L65
225,213
bytic/Common
src/Controllers/Traits/Models/HasModelManagerTrait.php
HasModelManagerTrait.generateModelName
protected function generateModelName() { $name = str_replace(["async-", "modal-"], '', $this->getName()); $manager = ModelLocator::get($name); return get_class($manager); }
php
protected function generateModelName() { $name = str_replace(["async-", "modal-"], '', $this->getName()); $manager = ModelLocator::get($name); return get_class($manager); }
[ "protected", "function", "generateModelName", "(", ")", "{", "$", "name", "=", "str_replace", "(", "[", "\"async-\"", ",", "\"modal-\"", "]", ",", "''", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "$", "manager", "=", "ModelLocator", "::", "get", "(", "$", "name", ")", ";", "return", "get_class", "(", "$", "manager", ")", ";", "}" ]
Generate the model name from controller name @return string
[ "Generate", "the", "model", "name", "from", "controller", "name" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Controllers/Traits/Models/HasModelManagerTrait.php#L108-L113
225,214
stubbles/stubbles-input
src/main/php/errors/ParamError.php
ParamError.fromData
public static function fromData($error, array $details = []): self { if ($error instanceof self) { return $error; } if (!is_string($error)) { throw new \InvalidArgumentException('Given error must either be an error id or an instance of ' . __CLASS__); } return new self($error, $details); }
php
public static function fromData($error, array $details = []): self { if ($error instanceof self) { return $error; } if (!is_string($error)) { throw new \InvalidArgumentException('Given error must either be an error id or an instance of ' . __CLASS__); } return new self($error, $details); }
[ "public", "static", "function", "fromData", "(", "$", "error", ",", "array", "$", "details", "=", "[", "]", ")", ":", "self", "{", "if", "(", "$", "error", "instanceof", "self", ")", "{", "return", "$", "error", ";", "}", "if", "(", "!", "is_string", "(", "$", "error", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Given error must either be an error id or an instance of '", ".", "__CLASS__", ")", ";", "}", "return", "new", "self", "(", "$", "error", ",", "$", "details", ")", ";", "}" ]
creates an instance from given error id and details In case given error is already an instance of ParamError it is simply returned. @param \stubbles\input\errors\ParamError|string $error id of error or an instance of ParamError @param array $details details of what caused the error @return \stubbles\input\errors\ParamError @throws \InvalidArgumentException
[ "creates", "an", "instance", "from", "given", "error", "id", "and", "details" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamError.php#L56-L67
225,215
stubbles/stubbles-input
src/main/php/errors/ParamError.php
ParamError.fillMessages
public function fillMessages(array $templates): array { $messages = []; foreach ($templates as $locale => $message) { $messages[] = $this->fillMessage($message, $locale); } return $messages; }
php
public function fillMessages(array $templates): array { $messages = []; foreach ($templates as $locale => $message) { $messages[] = $this->fillMessage($message, $locale); } return $messages; }
[ "public", "function", "fillMessages", "(", "array", "$", "templates", ")", ":", "array", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "$", "templates", "as", "$", "locale", "=>", "$", "message", ")", "{", "$", "messages", "[", "]", "=", "$", "this", "->", "fillMessage", "(", "$", "message", ",", "$", "locale", ")", ";", "}", "return", "$", "messages", ";", "}" ]
fills given list of messages with details @param array $templates map of locales and message templates @return \stubbles\input\errors\messages\LocalizedMessage[]
[ "fills", "given", "list", "of", "messages", "with", "details" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamError.php#L98-L106
225,216
stubbles/stubbles-input
src/main/php/errors/ParamError.php
ParamError.fillMessage
public function fillMessage(string $message, string $locale): LocalizedMessage { foreach ($this->details as $key => $detail) { $message = str_replace('{' . $key . '}', $this->flattenDetail($detail), $message); } return new LocalizedMessage($locale, $message); }
php
public function fillMessage(string $message, string $locale): LocalizedMessage { foreach ($this->details as $key => $detail) { $message = str_replace('{' . $key . '}', $this->flattenDetail($detail), $message); } return new LocalizedMessage($locale, $message); }
[ "public", "function", "fillMessage", "(", "string", "$", "message", ",", "string", "$", "locale", ")", ":", "LocalizedMessage", "{", "foreach", "(", "$", "this", "->", "details", "as", "$", "key", "=>", "$", "detail", ")", "{", "$", "message", "=", "str_replace", "(", "'{'", ".", "$", "key", ".", "'}'", ",", "$", "this", "->", "flattenDetail", "(", "$", "detail", ")", ",", "$", "message", ")", ";", "}", "return", "new", "LocalizedMessage", "(", "$", "locale", ",", "$", "message", ")", ";", "}" ]
fills given message with details @param string $message message template to fill up @param string $locale locale of the message @return \stubbles\input\errors\messages\LocalizedMessage
[ "fills", "given", "message", "with", "details" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamError.php#L115-L122
225,217
stubbles/stubbles-input
src/main/php/errors/ParamError.php
ParamError.flattenDetail
private function flattenDetail($detail): string { if (is_array($detail)) { return join(', ', $detail); } elseif (is_object($detail) && !method_exists($detail, '__toString')) { return get_class($detail); } return (string) $detail; }
php
private function flattenDetail($detail): string { if (is_array($detail)) { return join(', ', $detail); } elseif (is_object($detail) && !method_exists($detail, '__toString')) { return get_class($detail); } return (string) $detail; }
[ "private", "function", "flattenDetail", "(", "$", "detail", ")", ":", "string", "{", "if", "(", "is_array", "(", "$", "detail", ")", ")", "{", "return", "join", "(", "', '", ",", "$", "detail", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "detail", ")", "&&", "!", "method_exists", "(", "$", "detail", ",", "'__toString'", ")", ")", "{", "return", "get_class", "(", "$", "detail", ")", ";", "}", "return", "(", "string", ")", "$", "detail", ";", "}" ]
flattens the given detail to be used within a message @param mixed $detail @return string
[ "flattens", "the", "given", "detail", "to", "be", "used", "within", "a", "message" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/errors/ParamError.php#L130-L139
225,218
froq/froq-database
src/model/Model.php
Model.setStackPrimaryValue
public final function setStackPrimaryValue($value): void { if ($this->stackPrimary != null) { $this->set($this->stackPrimary, $value); } }
php
public final function setStackPrimaryValue($value): void { if ($this->stackPrimary != null) { $this->set($this->stackPrimary, $value); } }
[ "public", "final", "function", "setStackPrimaryValue", "(", "$", "value", ")", ":", "void", "{", "if", "(", "$", "this", "->", "stackPrimary", "!=", "null", ")", "{", "$", "this", "->", "set", "(", "$", "this", "->", "stackPrimary", ",", "$", "value", ")", ";", "}", "}" ]
Set stack primary value. @param any $value @return void
[ "Set", "stack", "primary", "value", "." ]
829732986f9f9db4ef83ce87f0461f190947c958
https://github.com/froq/froq-database/blob/829732986f9f9db4ef83ce87f0461f190947c958/src/model/Model.php#L216-L221
225,219
froq/froq-database
src/model/Model.php
Model.getPager
public final function getPager(int $totalRecords = null, string $startKey = null, string $stopKey = null): Pager { if ($totalRecords !== null) { $this->pager->run($totalRecords, $startKey, $stopKey); } return $this->pager; }
php
public final function getPager(int $totalRecords = null, string $startKey = null, string $stopKey = null): Pager { if ($totalRecords !== null) { $this->pager->run($totalRecords, $startKey, $stopKey); } return $this->pager; }
[ "public", "final", "function", "getPager", "(", "int", "$", "totalRecords", "=", "null", ",", "string", "$", "startKey", "=", "null", ",", "string", "$", "stopKey", "=", "null", ")", ":", "Pager", "{", "if", "(", "$", "totalRecords", "!==", "null", ")", "{", "$", "this", "->", "pager", "->", "run", "(", "$", "totalRecords", ",", "$", "startKey", ",", "$", "stopKey", ")", ";", "}", "return", "$", "this", "->", "pager", ";", "}" ]
Get pager. @param int|null $totalRecords @param string|null $startKey @param string|null $stopKey @return froq\pager\Pager
[ "Get", "pager", "." ]
829732986f9f9db4ef83ce87f0461f190947c958
https://github.com/froq/froq-database/blob/829732986f9f9db4ef83ce87f0461f190947c958/src/model/Model.php#L241-L249
225,220
froq/froq-database
src/model/Model.php
Model.getPagerResults
public final function getPagerResults(int $totalRecords, string $startKey = null, string $stopKey = null): array { return $this->pager->run($totalRecords, $startKey, $stopKey); }
php
public final function getPagerResults(int $totalRecords, string $startKey = null, string $stopKey = null): array { return $this->pager->run($totalRecords, $startKey, $stopKey); }
[ "public", "final", "function", "getPagerResults", "(", "int", "$", "totalRecords", ",", "string", "$", "startKey", "=", "null", ",", "string", "$", "stopKey", "=", "null", ")", ":", "array", "{", "return", "$", "this", "->", "pager", "->", "run", "(", "$", "totalRecords", ",", "$", "startKey", ",", "$", "stopKey", ")", ";", "}" ]
Get pager results. @param int $totalRecords @param string|null $startKey @param string|null $stopKey @return array
[ "Get", "pager", "results", "." ]
829732986f9f9db4ef83ce87f0461f190947c958
https://github.com/froq/froq-database/blob/829732986f9f9db4ef83ce87f0461f190947c958/src/model/Model.php#L258-L262
225,221
froq/froq-database
src/model/Model.php
Model.setFail
public final function setFail(\Throwable $fail): void { if ($this->failOption) { if ($this->failOption == 'log') { $logger = clone $this->service->getApp()->getLogger(); $logger->setDirectory($this->failLogDirectory); $logger->logFail($fail); } elseif ($this->failOption == 'throw') { throw $fail; } } $this->fail = $fail; }
php
public final function setFail(\Throwable $fail): void { if ($this->failOption) { if ($this->failOption == 'log') { $logger = clone $this->service->getApp()->getLogger(); $logger->setDirectory($this->failLogDirectory); $logger->logFail($fail); } elseif ($this->failOption == 'throw') { throw $fail; } } $this->fail = $fail; }
[ "public", "final", "function", "setFail", "(", "\\", "Throwable", "$", "fail", ")", ":", "void", "{", "if", "(", "$", "this", "->", "failOption", ")", "{", "if", "(", "$", "this", "->", "failOption", "==", "'log'", ")", "{", "$", "logger", "=", "clone", "$", "this", "->", "service", "->", "getApp", "(", ")", "->", "getLogger", "(", ")", ";", "$", "logger", "->", "setDirectory", "(", "$", "this", "->", "failLogDirectory", ")", ";", "$", "logger", "->", "logFail", "(", "$", "fail", ")", ";", "}", "elseif", "(", "$", "this", "->", "failOption", "==", "'throw'", ")", "{", "throw", "$", "fail", ";", "}", "}", "$", "this", "->", "fail", "=", "$", "fail", ";", "}" ]
Set fail. @param \Throwable $fail @return void @throws \Throwable
[ "Set", "fail", "." ]
829732986f9f9db4ef83ce87f0461f190947c958
https://github.com/froq/froq-database/blob/829732986f9f9db4ef83ce87f0461f190947c958/src/model/Model.php#L288-L300
225,222
nails/driver-cdn-local
src/Local.php
Local.urlServe
public function urlServe($sObject, $sBucket, $bForceDownload = false) { $sUrl = $this->urlServeScheme($bForceDownload); $sFilename = strtolower(substr($sObject, 0, strrpos($sObject, '.'))); $sExtension = strtolower(substr($sObject, strrpos($sObject, '.'))); // Sub in the values $sUrl = str_replace('{{bucket}}', $sBucket, $sUrl); $sUrl = str_replace('{{filename}}', $sFilename, $sUrl); $sUrl = str_replace('{{extension}}', $sExtension, $sUrl); return $sUrl; }
php
public function urlServe($sObject, $sBucket, $bForceDownload = false) { $sUrl = $this->urlServeScheme($bForceDownload); $sFilename = strtolower(substr($sObject, 0, strrpos($sObject, '.'))); $sExtension = strtolower(substr($sObject, strrpos($sObject, '.'))); // Sub in the values $sUrl = str_replace('{{bucket}}', $sBucket, $sUrl); $sUrl = str_replace('{{filename}}', $sFilename, $sUrl); $sUrl = str_replace('{{extension}}', $sExtension, $sUrl); return $sUrl; }
[ "public", "function", "urlServe", "(", "$", "sObject", ",", "$", "sBucket", ",", "$", "bForceDownload", "=", "false", ")", "{", "$", "sUrl", "=", "$", "this", "->", "urlServeScheme", "(", "$", "bForceDownload", ")", ";", "$", "sFilename", "=", "strtolower", "(", "substr", "(", "$", "sObject", ",", "0", ",", "strrpos", "(", "$", "sObject", ",", "'.'", ")", ")", ")", ";", "$", "sExtension", "=", "strtolower", "(", "substr", "(", "$", "sObject", ",", "strrpos", "(", "$", "sObject", ",", "'.'", ")", ")", ")", ";", "// Sub in the values", "$", "sUrl", "=", "str_replace", "(", "'{{bucket}}'", ",", "$", "sBucket", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{filename}}'", ",", "$", "sFilename", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{extension}}'", ",", "$", "sExtension", ",", "$", "sUrl", ")", ";", "return", "$", "sUrl", ";", "}" ]
Generates the correct URL for serving a file @param string $sObject The object to serve @param string $sBucket The bucket to serve from @param boolean $bForceDownload Whether to force a download @return string
[ "Generates", "the", "correct", "URL", "for", "serving", "a", "file" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L257-L269
225,223
nails/driver-cdn-local
src/Local.php
Local.urlServeRaw
public function urlServeRaw($sObject, $sBucket) { $sUrl = 'assets/uploads/' . $sBucket . '/' . $sObject; return $this->urlMakeSecure($sUrl, false); }
php
public function urlServeRaw($sObject, $sBucket) { $sUrl = 'assets/uploads/' . $sBucket . '/' . $sObject; return $this->urlMakeSecure($sUrl, false); }
[ "public", "function", "urlServeRaw", "(", "$", "sObject", ",", "$", "sBucket", ")", "{", "$", "sUrl", "=", "'assets/uploads/'", ".", "$", "sBucket", ".", "'/'", ".", "$", "sObject", ";", "return", "$", "this", "->", "urlMakeSecure", "(", "$", "sUrl", ",", "false", ")", ";", "}" ]
Generate the correct URL for serving a file direct from the file system @param $sObject @param $sBucket @return string
[ "Generate", "the", "correct", "URL", "for", "serving", "a", "file", "direct", "from", "the", "file", "system" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L281-L285
225,224
nails/driver-cdn-local
src/Local.php
Local.urlServeScheme
public function urlServeScheme($bForceDownload = false) { $sUrl = $this->getUri('serve') . '/serve/{{bucket}}/{{filename}}{{extension}}'; if ($bForceDownload) { $sUrl .= '?dl=1'; } return $this->urlMakeSecure($sUrl, false); }
php
public function urlServeScheme($bForceDownload = false) { $sUrl = $this->getUri('serve') . '/serve/{{bucket}}/{{filename}}{{extension}}'; if ($bForceDownload) { $sUrl .= '?dl=1'; } return $this->urlMakeSecure($sUrl, false); }
[ "public", "function", "urlServeScheme", "(", "$", "bForceDownload", "=", "false", ")", "{", "$", "sUrl", "=", "$", "this", "->", "getUri", "(", "'serve'", ")", ".", "'/serve/{{bucket}}/{{filename}}{{extension}}'", ";", "if", "(", "$", "bForceDownload", ")", "{", "$", "sUrl", ".=", "'?dl=1'", ";", "}", "return", "$", "this", "->", "urlMakeSecure", "(", "$", "sUrl", ",", "false", ")", ";", "}" ]
Returns the scheme of 'serve' URLs @param boolean $bForceDownload Whether or not to force download @return string
[ "Returns", "the", "scheme", "of", "serve", "URLs" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L296-L305
225,225
nails/driver-cdn-local
src/Local.php
Local.urlServeZipped
public function urlServeZipped($sObjectIds, $sHash, $sFilename) { $sUrl = $this->urlServeZippedScheme(); // Sub in the values $sUrl = str_replace('{{ids}}', $sObjectIds, $sUrl); $sUrl = str_replace('{{hash}}', $sHash, $sUrl); $sUrl = str_replace('{{filename}}', urlencode($sFilename), $sUrl); return $sUrl; }
php
public function urlServeZipped($sObjectIds, $sHash, $sFilename) { $sUrl = $this->urlServeZippedScheme(); // Sub in the values $sUrl = str_replace('{{ids}}', $sObjectIds, $sUrl); $sUrl = str_replace('{{hash}}', $sHash, $sUrl); $sUrl = str_replace('{{filename}}', urlencode($sFilename), $sUrl); return $sUrl; }
[ "public", "function", "urlServeZipped", "(", "$", "sObjectIds", ",", "$", "sHash", ",", "$", "sFilename", ")", "{", "$", "sUrl", "=", "$", "this", "->", "urlServeZippedScheme", "(", ")", ";", "// Sub in the values", "$", "sUrl", "=", "str_replace", "(", "'{{ids}}'", ",", "$", "sObjectIds", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{hash}}'", ",", "$", "sHash", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{filename}}'", ",", "urlencode", "(", "$", "sFilename", ")", ",", "$", "sUrl", ")", ";", "return", "$", "sUrl", ";", "}" ]
Generates a URL for serving zipped objects @param string $sObjectIds A comma separated list of object IDs @param string $sHash The security hash @param string $sFilename The filename to give the zip file @return string
[ "Generates", "a", "URL", "for", "serving", "zipped", "objects" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L318-L328
225,226
nails/driver-cdn-local
src/Local.php
Local.urlCrop
public function urlCrop($sObject, $sBucket, $iWidth, $iHeight) { $sUrl = $this->urlCropScheme(); $sFilename = strtolower(substr($sObject, 0, strrpos($sObject, '.'))); $sExtension = strtolower(substr($sObject, strrpos($sObject, '.'))); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{bucket}}', $sBucket, $sUrl); $sUrl = str_replace('{{filename}}', $sFilename, $sUrl); $sUrl = str_replace('{{extension}}', $sExtension, $sUrl); return $sUrl; }
php
public function urlCrop($sObject, $sBucket, $iWidth, $iHeight) { $sUrl = $this->urlCropScheme(); $sFilename = strtolower(substr($sObject, 0, strrpos($sObject, '.'))); $sExtension = strtolower(substr($sObject, strrpos($sObject, '.'))); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{bucket}}', $sBucket, $sUrl); $sUrl = str_replace('{{filename}}', $sFilename, $sUrl); $sUrl = str_replace('{{extension}}', $sExtension, $sUrl); return $sUrl; }
[ "public", "function", "urlCrop", "(", "$", "sObject", ",", "$", "sBucket", ",", "$", "iWidth", ",", "$", "iHeight", ")", "{", "$", "sUrl", "=", "$", "this", "->", "urlCropScheme", "(", ")", ";", "$", "sFilename", "=", "strtolower", "(", "substr", "(", "$", "sObject", ",", "0", ",", "strrpos", "(", "$", "sObject", ",", "'.'", ")", ")", ")", ";", "$", "sExtension", "=", "strtolower", "(", "substr", "(", "$", "sObject", ",", "strrpos", "(", "$", "sObject", ",", "'.'", ")", ")", ")", ";", "// Sub in the values", "$", "sUrl", "=", "str_replace", "(", "'{{width}}'", ",", "$", "iWidth", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{height}}'", ",", "$", "iHeight", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{bucket}}'", ",", "$", "sBucket", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{filename}}'", ",", "$", "sFilename", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{extension}}'", ",", "$", "sExtension", ",", "$", "sUrl", ")", ";", "return", "$", "sUrl", ";", "}" ]
Generates the correct URL for using the crop utility @param string $sBucket The bucket which the image resides in @param string $sObject The filename of the image we're cropping @param integer $iWidth The width of the cropped image @param integer $iHeight The height of the cropped image @return string
[ "Generates", "the", "correct", "URL", "for", "using", "the", "crop", "utility" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L355-L369
225,227
nails/driver-cdn-local
src/Local.php
Local.urlScale
public function urlScale($sObject, $sBucket, $iWidth, $iHeight) { $sUrl = $this->urlScaleScheme(); $sFilename = strtolower(substr($sObject, 0, strrpos($sObject, '.'))); $sExtension = strtolower(substr($sObject, strrpos($sObject, '.'))); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{bucket}}', $sBucket, $sUrl); $sUrl = str_replace('{{filename}}', $sFilename, $sUrl); $sUrl = str_replace('{{extension}}', $sExtension, $sUrl); return $sUrl; }
php
public function urlScale($sObject, $sBucket, $iWidth, $iHeight) { $sUrl = $this->urlScaleScheme(); $sFilename = strtolower(substr($sObject, 0, strrpos($sObject, '.'))); $sExtension = strtolower(substr($sObject, strrpos($sObject, '.'))); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{bucket}}', $sBucket, $sUrl); $sUrl = str_replace('{{filename}}', $sFilename, $sUrl); $sUrl = str_replace('{{extension}}', $sExtension, $sUrl); return $sUrl; }
[ "public", "function", "urlScale", "(", "$", "sObject", ",", "$", "sBucket", ",", "$", "iWidth", ",", "$", "iHeight", ")", "{", "$", "sUrl", "=", "$", "this", "->", "urlScaleScheme", "(", ")", ";", "$", "sFilename", "=", "strtolower", "(", "substr", "(", "$", "sObject", ",", "0", ",", "strrpos", "(", "$", "sObject", ",", "'.'", ")", ")", ")", ";", "$", "sExtension", "=", "strtolower", "(", "substr", "(", "$", "sObject", ",", "strrpos", "(", "$", "sObject", ",", "'.'", ")", ")", ")", ";", "// Sub in the values", "$", "sUrl", "=", "str_replace", "(", "'{{width}}'", ",", "$", "iWidth", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{height}}'", ",", "$", "iHeight", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{bucket}}'", ",", "$", "sBucket", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{filename}}'", ",", "$", "sFilename", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{extension}}'", ",", "$", "sExtension", ",", "$", "sUrl", ")", ";", "return", "$", "sUrl", ";", "}" ]
Generates the correct URL for using the scale utility @param string $sBucket The bucket which the image resides in @param string $sObject The filename of the image we're 'scaling' @param integer $iWidth The width of the scaled image @param integer $iHeight The height of the scaled image @return string
[ "Generates", "the", "correct", "URL", "for", "using", "the", "scale", "utility" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L396-L410
225,228
nails/driver-cdn-local
src/Local.php
Local.urlPlaceholder
public function urlPlaceholder($iWidth, $iHeight, $iBorder = 0) { $sUrl = $this->urlPlaceholderScheme(); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{border}}', $iBorder, $sUrl); return $sUrl; }
php
public function urlPlaceholder($iWidth, $iHeight, $iBorder = 0) { $sUrl = $this->urlPlaceholderScheme(); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{border}}', $iBorder, $sUrl); return $sUrl; }
[ "public", "function", "urlPlaceholder", "(", "$", "iWidth", ",", "$", "iHeight", ",", "$", "iBorder", "=", "0", ")", "{", "$", "sUrl", "=", "$", "this", "->", "urlPlaceholderScheme", "(", ")", ";", "// Sub in the values", "$", "sUrl", "=", "str_replace", "(", "'{{width}}'", ",", "$", "iWidth", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{height}}'", ",", "$", "iHeight", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{border}}'", ",", "$", "iBorder", ",", "$", "sUrl", ")", ";", "return", "$", "sUrl", ";", "}" ]
Generates the correct URL for using the placeholder utility @param integer $iWidth The width of the placeholder @param integer $iHeight The height of the placeholder @param integer $iBorder The width of the border round the placeholder @return string
[ "Generates", "the", "correct", "URL", "for", "using", "the", "placeholder", "utility" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L436-L446
225,229
nails/driver-cdn-local
src/Local.php
Local.urlBlankAvatar
public function urlBlankAvatar($iWidth, $iHeight, $mSex = '') { $sUrl = $this->urlBlankAvatarScheme(); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{sex}}', $mSex, $sUrl); return $sUrl; }
php
public function urlBlankAvatar($iWidth, $iHeight, $mSex = '') { $sUrl = $this->urlBlankAvatarScheme(); // Sub in the values $sUrl = str_replace('{{width}}', $iWidth, $sUrl); $sUrl = str_replace('{{height}}', $iHeight, $sUrl); $sUrl = str_replace('{{sex}}', $mSex, $sUrl); return $sUrl; }
[ "public", "function", "urlBlankAvatar", "(", "$", "iWidth", ",", "$", "iHeight", ",", "$", "mSex", "=", "''", ")", "{", "$", "sUrl", "=", "$", "this", "->", "urlBlankAvatarScheme", "(", ")", ";", "// Sub in the values", "$", "sUrl", "=", "str_replace", "(", "'{{width}}'", ",", "$", "iWidth", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{height}}'", ",", "$", "iHeight", ",", "$", "sUrl", ")", ";", "$", "sUrl", "=", "str_replace", "(", "'{{sex}}'", ",", "$", "mSex", ",", "$", "sUrl", ")", ";", "return", "$", "sUrl", ";", "}" ]
Generates the correct URL for a blank avatar @param integer $iWidth The width fo the avatar @param integer $iHeight The height of the avatar§ @param string|integer $mSex What gender the avatar should represent @return string
[ "Generates", "the", "correct", "URL", "for", "a", "blank", "avatar" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L472-L482
225,230
nails/driver-cdn-local
src/Local.php
Local.urlMakeSecure
protected function urlMakeSecure($sUrl, $bIsProcessing = true) { if (Functions::isPageSecure()) { if ($bIsProcessing) { $sSearch = $this->getUri('process'); $sReplace = $this->getUri('process_secure'); } else { $sSearch = $this->getUri('serve'); $sReplace = $this->getUri('serve_secure'); } $sUrl = str_replace($sSearch, $sReplace, $sUrl); } return preg_match('#^https?://#', $sUrl) ? $sUrl : site_url($sUrl); }
php
protected function urlMakeSecure($sUrl, $bIsProcessing = true) { if (Functions::isPageSecure()) { if ($bIsProcessing) { $sSearch = $this->getUri('process'); $sReplace = $this->getUri('process_secure'); } else { $sSearch = $this->getUri('serve'); $sReplace = $this->getUri('serve_secure'); } $sUrl = str_replace($sSearch, $sReplace, $sUrl); } return preg_match('#^https?://#', $sUrl) ? $sUrl : site_url($sUrl); }
[ "protected", "function", "urlMakeSecure", "(", "$", "sUrl", ",", "$", "bIsProcessing", "=", "true", ")", "{", "if", "(", "Functions", "::", "isPageSecure", "(", ")", ")", "{", "if", "(", "$", "bIsProcessing", ")", "{", "$", "sSearch", "=", "$", "this", "->", "getUri", "(", "'process'", ")", ";", "$", "sReplace", "=", "$", "this", "->", "getUri", "(", "'process_secure'", ")", ";", "}", "else", "{", "$", "sSearch", "=", "$", "this", "->", "getUri", "(", "'serve'", ")", ";", "$", "sReplace", "=", "$", "this", "->", "getUri", "(", "'serve_secure'", ")", ";", "}", "$", "sUrl", "=", "str_replace", "(", "$", "sSearch", ",", "$", "sReplace", ",", "$", "sUrl", ")", ";", "}", "return", "preg_match", "(", "'#^https?://#'", ",", "$", "sUrl", ")", "?", "$", "sUrl", ":", "site_url", "(", "$", "sUrl", ")", ";", "}" ]
Formats a URL and makes it secure if needed @param string $sUrl The URL to secure @param boolean $bIsProcessing Whether it's a processing type URL @return string
[ "Formats", "a", "URL", "and", "makes", "it", "secure", "if", "needed" ]
60f6cd80a331734a853b2e1e4721641494c0ce6e
https://github.com/nails/driver-cdn-local/blob/60f6cd80a331734a853b2e1e4721641494c0ce6e/src/Local.php#L550-L564
225,231
SetBased/php-abc-table-detail
src/TableRow/HtmlTableRow.php
HtmlTableRow.addRow
public static function addRow(DetailTable $table, $header, ?string $htmlSnippet): void { if ($htmlSnippet!==null && $htmlSnippet!=='') { $table->addRow($header, ['class' => 'html'], $htmlSnippet, true); } else { $table->addRow($header); } }
php
public static function addRow(DetailTable $table, $header, ?string $htmlSnippet): void { if ($htmlSnippet!==null && $htmlSnippet!=='') { $table->addRow($header, ['class' => 'html'], $htmlSnippet, true); } else { $table->addRow($header); } }
[ "public", "static", "function", "addRow", "(", "DetailTable", "$", "table", ",", "$", "header", ",", "?", "string", "$", "htmlSnippet", ")", ":", "void", "{", "if", "(", "$", "htmlSnippet", "!==", "null", "&&", "$", "htmlSnippet", "!==", "''", ")", "{", "$", "table", "->", "addRow", "(", "$", "header", ",", "[", "'class'", "=>", "'html'", "]", ",", "$", "htmlSnippet", ",", "true", ")", ";", "}", "else", "{", "$", "table", "->", "addRow", "(", "$", "header", ")", ";", "}", "}" ]
Adds a row with a HTML snippet to a detail table. @param DetailTable $table The detail table. @param string|int|null $header The header text of this table row. @param string|null $htmlSnippet The HTML snippet.
[ "Adds", "a", "row", "with", "a", "HTML", "snippet", "to", "a", "detail", "table", "." ]
1f786174ccb10800f9c07bfd497b0ab35940a8ea
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/TableRow/HtmlTableRow.php#L20-L30
225,232
SetBased/php-abc-form
src/Control/Control.php
Control.setSubmitName
protected function setSubmitName(string $parentSubmitName): void { $submitKey = $this->submitKey(); if ($parentSubmitName!=='') { if ($submitKey!=='') $this->submitName = $parentSubmitName.'['.$submitKey.']'; else $this->submitName = $parentSubmitName; } else { $this->submitName = $submitKey; } }
php
protected function setSubmitName(string $parentSubmitName): void { $submitKey = $this->submitKey(); if ($parentSubmitName!=='') { if ($submitKey!=='') $this->submitName = $parentSubmitName.'['.$submitKey.']'; else $this->submitName = $parentSubmitName; } else { $this->submitName = $submitKey; } }
[ "protected", "function", "setSubmitName", "(", "string", "$", "parentSubmitName", ")", ":", "void", "{", "$", "submitKey", "=", "$", "this", "->", "submitKey", "(", ")", ";", "if", "(", "$", "parentSubmitName", "!==", "''", ")", "{", "if", "(", "$", "submitKey", "!==", "''", ")", "$", "this", "->", "submitName", "=", "$", "parentSubmitName", ".", "'['", ".", "$", "submitKey", ".", "']'", ";", "else", "$", "this", "->", "submitName", "=", "$", "parentSubmitName", ";", "}", "else", "{", "$", "this", "->", "submitName", "=", "$", "submitKey", ";", "}", "}" ]
Sets the name this will be used for this form control when the form is submitted. @param string $parentSubmitName The submit name of the parent form control of this form control.
[ "Sets", "the", "name", "this", "will", "be", "used", "for", "this", "form", "control", "when", "the", "form", "is", "submitted", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/Control.php#L360-L373
225,233
SetBased/php-abc-form
src/Control/Control.php
Control.submitKey
protected function submitKey(): string { return ($this->obfuscator) ? $this->obfuscator->encode(Cast::toOptInt($this->name)) : $this->name; }
php
protected function submitKey(): string { return ($this->obfuscator) ? $this->obfuscator->encode(Cast::toOptInt($this->name)) : $this->name; }
[ "protected", "function", "submitKey", "(", ")", ":", "string", "{", "return", "(", "$", "this", "->", "obfuscator", ")", "?", "$", "this", "->", "obfuscator", "->", "encode", "(", "Cast", "::", "toOptInt", "(", "$", "this", "->", "name", ")", ")", ":", "$", "this", "->", "name", ";", "}" ]
Returns the key under which the control is submitted in the submitted values. @return string @since 1.0.0 @api
[ "Returns", "the", "key", "under", "which", "the", "control", "is", "submitted", "in", "the", "submitted", "values", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/Control.php#L384-L387
225,234
stubbles/stubbles-input
src/main/php/filter/SimplePasswordChecker.php
SimplePasswordChecker.check
public function check(Secret $proposedPassword): array { $errors = []; if ($proposedPassword->length() < $this->minLength) { $errors['PASSWORD_TOO_SHORT'] = ['minLength' => $this->minLength]; } if (in_array($proposedPassword->unveil(), $this->disallowedValues)) { $errors['PASSWORD_DISALLOWED'] = []; } if (null !== $this->minDiffChars && count(count_chars($proposedPassword->unveil(), 1)) < $this->minDiffChars) { $errors['PASSWORD_TOO_LESS_DIFF_CHARS'] = ['minDiff' => $this->minDiffChars]; } return $errors; }
php
public function check(Secret $proposedPassword): array { $errors = []; if ($proposedPassword->length() < $this->minLength) { $errors['PASSWORD_TOO_SHORT'] = ['minLength' => $this->minLength]; } if (in_array($proposedPassword->unveil(), $this->disallowedValues)) { $errors['PASSWORD_DISALLOWED'] = []; } if (null !== $this->minDiffChars && count(count_chars($proposedPassword->unveil(), 1)) < $this->minDiffChars) { $errors['PASSWORD_TOO_LESS_DIFF_CHARS'] = ['minDiff' => $this->minDiffChars]; } return $errors; }
[ "public", "function", "check", "(", "Secret", "$", "proposedPassword", ")", ":", "array", "{", "$", "errors", "=", "[", "]", ";", "if", "(", "$", "proposedPassword", "->", "length", "(", ")", "<", "$", "this", "->", "minLength", ")", "{", "$", "errors", "[", "'PASSWORD_TOO_SHORT'", "]", "=", "[", "'minLength'", "=>", "$", "this", "->", "minLength", "]", ";", "}", "if", "(", "in_array", "(", "$", "proposedPassword", "->", "unveil", "(", ")", ",", "$", "this", "->", "disallowedValues", ")", ")", "{", "$", "errors", "[", "'PASSWORD_DISALLOWED'", "]", "=", "[", "]", ";", "}", "if", "(", "null", "!==", "$", "this", "->", "minDiffChars", "&&", "count", "(", "count_chars", "(", "$", "proposedPassword", "->", "unveil", "(", ")", ",", "1", ")", ")", "<", "$", "this", "->", "minDiffChars", ")", "{", "$", "errors", "[", "'PASSWORD_TOO_LESS_DIFF_CHARS'", "]", "=", "[", "'minDiff'", "=>", "$", "this", "->", "minDiffChars", "]", ";", "}", "return", "$", "errors", ";", "}" ]
checks given password In case the password does not satisfy the return value is a list of error ids. @param \stubbles\values\Secret $proposedPassword @return array
[ "checks", "given", "password" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/SimplePasswordChecker.php#L109-L125
225,235
Eve-PHP/Framework
src/Cli/Install.php
Install.run
public function run($args) { $this->setup($args); Index::info('Downloading files..'); $this('curl') ->setUrl('https://github.com/Eve-PHP/Shade/archive/master.zip') ->setFile($this->file) ->setFollowLocation(true) ->setSslVerifyPeer(false) ->send(); fclose($this->file); Index::info('Extracting files..'); try { $zip = new \ZipArchive(); $resource = $zip->open($this->cwd . '/tmp/framework.zip'); if(!$resource) { throw new \Exception('Cannot extract data. Aborting.'); } $zip->extractTo($this->cwd.'/tmp'); $zip->close(); Index::info('Copying files..'); $root = $this->cwd.'/tmp/Shade-master'; $files = $this('folder', $root)->getFiles(null, true); foreach($files as $file) { $destination = str_replace('/tmp/Shade-master', '', $file->get()); $folder = $this('file', $destination)->getFolder(); if(!is_dir($folder)) { mkdir($folder, 0777, true); } copy($file->get(), $destination); } } catch(\Exception $e) { Index::error($e->getMessage(), false); } Index::info('Cleaning up ..'); $tmp = $this('folder', $this->cwd . '/tmp'); $files = $tmp->getFiles(null, true); $folders = $tmp->getFolders(null, true); $folders = array_reverse($folders); foreach($files as $file) { $file->remove(); } foreach($folders as $folder) { $folder->remove(); } $tmp->remove(); Index::info('Copying settings..'); $this('file', $this->cwd.'/settings/databases.php')->setData($this->databases); copy($this->cwd.'/settings/sample.config.php', $this->cwd.'/settings/config.php'); copy($this->cwd.'/settings/sample.test.php', $this->cwd.'/settings/test.php'); Index::info('Creating database..'); $this->install(); Index::success('Database created.'); Index::warning('Please set the configs in the settings folder'); Index::system('Control Login is: admin@openovate.com / admin'); Index::success('Framework installation complete!'); die(0); }
php
public function run($args) { $this->setup($args); Index::info('Downloading files..'); $this('curl') ->setUrl('https://github.com/Eve-PHP/Shade/archive/master.zip') ->setFile($this->file) ->setFollowLocation(true) ->setSslVerifyPeer(false) ->send(); fclose($this->file); Index::info('Extracting files..'); try { $zip = new \ZipArchive(); $resource = $zip->open($this->cwd . '/tmp/framework.zip'); if(!$resource) { throw new \Exception('Cannot extract data. Aborting.'); } $zip->extractTo($this->cwd.'/tmp'); $zip->close(); Index::info('Copying files..'); $root = $this->cwd.'/tmp/Shade-master'; $files = $this('folder', $root)->getFiles(null, true); foreach($files as $file) { $destination = str_replace('/tmp/Shade-master', '', $file->get()); $folder = $this('file', $destination)->getFolder(); if(!is_dir($folder)) { mkdir($folder, 0777, true); } copy($file->get(), $destination); } } catch(\Exception $e) { Index::error($e->getMessage(), false); } Index::info('Cleaning up ..'); $tmp = $this('folder', $this->cwd . '/tmp'); $files = $tmp->getFiles(null, true); $folders = $tmp->getFolders(null, true); $folders = array_reverse($folders); foreach($files as $file) { $file->remove(); } foreach($folders as $folder) { $folder->remove(); } $tmp->remove(); Index::info('Copying settings..'); $this('file', $this->cwd.'/settings/databases.php')->setData($this->databases); copy($this->cwd.'/settings/sample.config.php', $this->cwd.'/settings/config.php'); copy($this->cwd.'/settings/sample.test.php', $this->cwd.'/settings/test.php'); Index::info('Creating database..'); $this->install(); Index::success('Database created.'); Index::warning('Please set the configs in the settings folder'); Index::system('Control Login is: admin@openovate.com / admin'); Index::success('Framework installation complete!'); die(0); }
[ "public", "function", "run", "(", "$", "args", ")", "{", "$", "this", "->", "setup", "(", "$", "args", ")", ";", "Index", "::", "info", "(", "'Downloading files..'", ")", ";", "$", "this", "(", "'curl'", ")", "->", "setUrl", "(", "'https://github.com/Eve-PHP/Shade/archive/master.zip'", ")", "->", "setFile", "(", "$", "this", "->", "file", ")", "->", "setFollowLocation", "(", "true", ")", "->", "setSslVerifyPeer", "(", "false", ")", "->", "send", "(", ")", ";", "fclose", "(", "$", "this", "->", "file", ")", ";", "Index", "::", "info", "(", "'Extracting files..'", ")", ";", "try", "{", "$", "zip", "=", "new", "\\", "ZipArchive", "(", ")", ";", "$", "resource", "=", "$", "zip", "->", "open", "(", "$", "this", "->", "cwd", ".", "'/tmp/framework.zip'", ")", ";", "if", "(", "!", "$", "resource", ")", "{", "throw", "new", "\\", "Exception", "(", "'Cannot extract data. Aborting.'", ")", ";", "}", "$", "zip", "->", "extractTo", "(", "$", "this", "->", "cwd", ".", "'/tmp'", ")", ";", "$", "zip", "->", "close", "(", ")", ";", "Index", "::", "info", "(", "'Copying files..'", ")", ";", "$", "root", "=", "$", "this", "->", "cwd", ".", "'/tmp/Shade-master'", ";", "$", "files", "=", "$", "this", "(", "'folder'", ",", "$", "root", ")", "->", "getFiles", "(", "null", ",", "true", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "destination", "=", "str_replace", "(", "'/tmp/Shade-master'", ",", "''", ",", "$", "file", "->", "get", "(", ")", ")", ";", "$", "folder", "=", "$", "this", "(", "'file'", ",", "$", "destination", ")", "->", "getFolder", "(", ")", ";", "if", "(", "!", "is_dir", "(", "$", "folder", ")", ")", "{", "mkdir", "(", "$", "folder", ",", "0777", ",", "true", ")", ";", "}", "copy", "(", "$", "file", "->", "get", "(", ")", ",", "$", "destination", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "Index", "::", "error", "(", "$", "e", "->", "getMessage", "(", ")", ",", "false", ")", ";", "}", "Index", "::", "info", "(", "'Cleaning up ..'", ")", ";", "$", "tmp", "=", "$", "this", "(", "'folder'", ",", "$", "this", "->", "cwd", ".", "'/tmp'", ")", ";", "$", "files", "=", "$", "tmp", "->", "getFiles", "(", "null", ",", "true", ")", ";", "$", "folders", "=", "$", "tmp", "->", "getFolders", "(", "null", ",", "true", ")", ";", "$", "folders", "=", "array_reverse", "(", "$", "folders", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "file", "->", "remove", "(", ")", ";", "}", "foreach", "(", "$", "folders", "as", "$", "folder", ")", "{", "$", "folder", "->", "remove", "(", ")", ";", "}", "$", "tmp", "->", "remove", "(", ")", ";", "Index", "::", "info", "(", "'Copying settings..'", ")", ";", "$", "this", "(", "'file'", ",", "$", "this", "->", "cwd", ".", "'/settings/databases.php'", ")", "->", "setData", "(", "$", "this", "->", "databases", ")", ";", "copy", "(", "$", "this", "->", "cwd", ".", "'/settings/sample.config.php'", ",", "$", "this", "->", "cwd", ".", "'/settings/config.php'", ")", ";", "copy", "(", "$", "this", "->", "cwd", ".", "'/settings/sample.test.php'", ",", "$", "this", "->", "cwd", ".", "'/settings/test.php'", ")", ";", "Index", "::", "info", "(", "'Creating database..'", ")", ";", "$", "this", "->", "install", "(", ")", ";", "Index", "::", "success", "(", "'Database created.'", ")", ";", "Index", "::", "warning", "(", "'Please set the configs in the settings folder'", ")", ";", "Index", "::", "system", "(", "'Control Login is: admin@openovate.com / admin'", ")", ";", "Index", "::", "success", "(", "'Framework installation complete!'", ")", ";", "die", "(", "0", ")", ";", "}" ]
Runs the CLI Install process @param array $args CLI arguments @return void
[ "Runs", "the", "CLI", "Install", "process" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Cli/Install.php#L93-L174
225,236
Eve-PHP/Framework
src/Cli/Install.php
Install.install
public function install() { $build = $this('mysql', $this->databases['default']['host'], '', $this->databases['default']['user'], $this->databases['default']['pass']); $main = $this('mysql', $this->databases['default']['host'], $this->databases['default']['name'], $this->databases['default']['user'], $this->databases['default']['pass']); $build->query('DROP DATABASE IF EXISTS `'.$this->databases['default']['name'].'`'); $build->query('CREATE DATABASE `'.$this->databases['default']['name'].'`'); //get schema $schema = $this('file', $this->cwd.'/schema.sql')->getContent(); //add queries $queries = explode(';', $schema); $queries[] = "INSERT INTO `app` ( `app_id`, `app_name`, `app_domain`, `app_token`, `app_secret`, `app_permissions`, `app_website`, `app_active`, `app_type`, `app_flag`, `app_created`, `app_updated` ) VALUES ( 1, 'Main Application', '*.openovate.com', '986e7ce6bec660838491c1cd0a1f4ef6', 'ba0d2fc7aab09dfa3463943c0aaa8551', '".implode(',', array( 'public_profile', 'public_sso', 'personal_profile', 'user_profile' ))."', 'http://openovate.com/', 1, NULL, 0, '2015-08-21 00:00:00', '2015-08-21 00:00:00' )"; $queries[] = "INSERT INTO `auth` ( `auth_id`, `auth_slug`, `auth_password`, `auth_token`, `auth_secret`, `auth_permissions`, `auth_facebook_token`, `auth_facebook_secret`, `auth_linkedin_token`, `auth_linkedin_secret`, `auth_twitter_token`, `auth_twitter_secret`, `auth_google_token`, `auth_google_secret`, `auth_active`, `auth_type`, `auth_flag`, `auth_created`, `auth_updated` ) VALUES ( 1, 'admin@openovate.com', MD5('admin'), '986e7ce6bec660838491c1cd0a1f4ef6', 'ba0d2fc7aab09dfa3463943c0aaa8551', '".implode(',', array( 'public_profile', 'public_sso', 'personal_profile', 'user_profile' ))."', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 0, '2015-09-11 23:05:17', '2015-09-11 23:05:17' )"; $queries[] = "INSERT INTO `profile` ( `profile_id`, `profile_name`, `profile_email`, `profile_phone`, `profile_detail`, `profile_company`, `profile_job`, `profile_gender`, `profile_birth`, `profile_website`, `profile_facebook`, `profile_linkedin`, `profile_twitter`, `profile_google`, `profile_active`, `profile_type`, `profile_flag`, `profile_created`, `profile_updated` ) VALUES ( 1, 'Admin', 'admin@openovate.com', '+63 (2) 654-5110', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 0, '2015-09-11 23:05:16', '2015-09-11 23:05:16')"; $queries[] = "INSERT INTO `app_profile` (`app_profile_app`, `app_profile_profile`) VALUES (1, 1)"; $queries[] = "INSERT INTO `auth_profile` (`auth_profile_auth`, `auth_profile_profile`) VALUES (1, 1)"; //now call the queries foreach($queries as $query) { $lines = explode("\n", $query); foreach($lines as $i => $line) { if(strpos($line, '--') === 0 || !trim($line)) { unset($lines[$i]); continue; } } $query = trim(implode("\n", $lines)); if(!$query) { continue; } $main->query($query); } }
php
public function install() { $build = $this('mysql', $this->databases['default']['host'], '', $this->databases['default']['user'], $this->databases['default']['pass']); $main = $this('mysql', $this->databases['default']['host'], $this->databases['default']['name'], $this->databases['default']['user'], $this->databases['default']['pass']); $build->query('DROP DATABASE IF EXISTS `'.$this->databases['default']['name'].'`'); $build->query('CREATE DATABASE `'.$this->databases['default']['name'].'`'); //get schema $schema = $this('file', $this->cwd.'/schema.sql')->getContent(); //add queries $queries = explode(';', $schema); $queries[] = "INSERT INTO `app` ( `app_id`, `app_name`, `app_domain`, `app_token`, `app_secret`, `app_permissions`, `app_website`, `app_active`, `app_type`, `app_flag`, `app_created`, `app_updated` ) VALUES ( 1, 'Main Application', '*.openovate.com', '986e7ce6bec660838491c1cd0a1f4ef6', 'ba0d2fc7aab09dfa3463943c0aaa8551', '".implode(',', array( 'public_profile', 'public_sso', 'personal_profile', 'user_profile' ))."', 'http://openovate.com/', 1, NULL, 0, '2015-08-21 00:00:00', '2015-08-21 00:00:00' )"; $queries[] = "INSERT INTO `auth` ( `auth_id`, `auth_slug`, `auth_password`, `auth_token`, `auth_secret`, `auth_permissions`, `auth_facebook_token`, `auth_facebook_secret`, `auth_linkedin_token`, `auth_linkedin_secret`, `auth_twitter_token`, `auth_twitter_secret`, `auth_google_token`, `auth_google_secret`, `auth_active`, `auth_type`, `auth_flag`, `auth_created`, `auth_updated` ) VALUES ( 1, 'admin@openovate.com', MD5('admin'), '986e7ce6bec660838491c1cd0a1f4ef6', 'ba0d2fc7aab09dfa3463943c0aaa8551', '".implode(',', array( 'public_profile', 'public_sso', 'personal_profile', 'user_profile' ))."', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 0, '2015-09-11 23:05:17', '2015-09-11 23:05:17' )"; $queries[] = "INSERT INTO `profile` ( `profile_id`, `profile_name`, `profile_email`, `profile_phone`, `profile_detail`, `profile_company`, `profile_job`, `profile_gender`, `profile_birth`, `profile_website`, `profile_facebook`, `profile_linkedin`, `profile_twitter`, `profile_google`, `profile_active`, `profile_type`, `profile_flag`, `profile_created`, `profile_updated` ) VALUES ( 1, 'Admin', 'admin@openovate.com', '+63 (2) 654-5110', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 0, '2015-09-11 23:05:16', '2015-09-11 23:05:16')"; $queries[] = "INSERT INTO `app_profile` (`app_profile_app`, `app_profile_profile`) VALUES (1, 1)"; $queries[] = "INSERT INTO `auth_profile` (`auth_profile_auth`, `auth_profile_profile`) VALUES (1, 1)"; //now call the queries foreach($queries as $query) { $lines = explode("\n", $query); foreach($lines as $i => $line) { if(strpos($line, '--') === 0 || !trim($line)) { unset($lines[$i]); continue; } } $query = trim(implode("\n", $lines)); if(!$query) { continue; } $main->query($query); } }
[ "public", "function", "install", "(", ")", "{", "$", "build", "=", "$", "this", "(", "'mysql'", ",", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'host'", "]", ",", "''", ",", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'user'", "]", ",", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'pass'", "]", ")", ";", "$", "main", "=", "$", "this", "(", "'mysql'", ",", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'host'", "]", ",", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'name'", "]", ",", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'user'", "]", ",", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'pass'", "]", ")", ";", "$", "build", "->", "query", "(", "'DROP DATABASE IF EXISTS `'", ".", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'name'", "]", ".", "'`'", ")", ";", "$", "build", "->", "query", "(", "'CREATE DATABASE `'", ".", "$", "this", "->", "databases", "[", "'default'", "]", "[", "'name'", "]", ".", "'`'", ")", ";", "//get schema", "$", "schema", "=", "$", "this", "(", "'file'", ",", "$", "this", "->", "cwd", ".", "'/schema.sql'", ")", "->", "getContent", "(", ")", ";", "//add queries", "$", "queries", "=", "explode", "(", "';'", ",", "$", "schema", ")", ";", "$", "queries", "[", "]", "=", "\"INSERT INTO `app` (\n `app_id`,\n `app_name`,\n `app_domain`,\n `app_token`,\n `app_secret`,\n `app_permissions`,\n `app_website`,\n `app_active`,\n `app_type`,\n `app_flag`,\n `app_created`,\n `app_updated`\n ) VALUES (\n 1,\n 'Main Application',\n '*.openovate.com',\n '986e7ce6bec660838491c1cd0a1f4ef6',\n 'ba0d2fc7aab09dfa3463943c0aaa8551',\n '\"", ".", "implode", "(", "','", ",", "array", "(", "'public_profile'", ",", "'public_sso'", ",", "'personal_profile'", ",", "'user_profile'", ")", ")", ".", "\"',\n 'http://openovate.com/',\n 1, NULL, 0, '2015-08-21 00:00:00', '2015-08-21 00:00:00'\n )\"", ";", "$", "queries", "[", "]", "=", "\"INSERT INTO `auth` (\n `auth_id`,\n `auth_slug`,\n `auth_password`,\n `auth_token`,\n `auth_secret`,\n `auth_permissions`,\n `auth_facebook_token`,\n `auth_facebook_secret`,\n `auth_linkedin_token`,\n `auth_linkedin_secret`,\n `auth_twitter_token`,\n `auth_twitter_secret`,\n `auth_google_token`,\n `auth_google_secret`,\n `auth_active`,\n `auth_type`,\n `auth_flag`,\n `auth_created`,\n `auth_updated`\n ) VALUES (\n 1,\n 'admin@openovate.com',\n MD5('admin'),\n '986e7ce6bec660838491c1cd0a1f4ef6',\n 'ba0d2fc7aab09dfa3463943c0aaa8551',\n '\"", ".", "implode", "(", "','", ",", "array", "(", "'public_profile'", ",", "'public_sso'", ",", "'personal_profile'", ",", "'user_profile'", ")", ")", ".", "\"',\n NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 1, NULL, 0,\n '2015-09-11 23:05:17', '2015-09-11 23:05:17'\n )\"", ";", "$", "queries", "[", "]", "=", "\"INSERT INTO `profile` (\n `profile_id`,\n `profile_name`,\n `profile_email`,\n `profile_phone`,\n `profile_detail`,\n `profile_company`,\n `profile_job`,\n `profile_gender`,\n `profile_birth`,\n `profile_website`,\n `profile_facebook`,\n `profile_linkedin`,\n `profile_twitter`,\n `profile_google`,\n `profile_active`,\n `profile_type`,\n `profile_flag`,\n `profile_created`,\n `profile_updated`\n ) VALUES (\n 1,\n 'Admin',\n 'admin@openovate.com',\n '+63 (2) 654-5110',\n NULL, NULL, NULL, NULL, NULL,\n NULL, NULL, NULL, NULL, NULL, 1, NULL,\n 0, '2015-09-11 23:05:16', '2015-09-11 23:05:16')\"", ";", "$", "queries", "[", "]", "=", "\"INSERT INTO `app_profile` (`app_profile_app`, `app_profile_profile`) VALUES (1, 1)\"", ";", "$", "queries", "[", "]", "=", "\"INSERT INTO `auth_profile` (`auth_profile_auth`, `auth_profile_profile`) VALUES (1, 1)\"", ";", "//now call the queries", "foreach", "(", "$", "queries", "as", "$", "query", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "query", ")", ";", "foreach", "(", "$", "lines", "as", "$", "i", "=>", "$", "line", ")", "{", "if", "(", "strpos", "(", "$", "line", ",", "'--'", ")", "===", "0", "||", "!", "trim", "(", "$", "line", ")", ")", "{", "unset", "(", "$", "lines", "[", "$", "i", "]", ")", ";", "continue", ";", "}", "}", "$", "query", "=", "trim", "(", "implode", "(", "\"\\n\"", ",", "$", "lines", ")", ")", ";", "if", "(", "!", "$", "query", ")", "{", "continue", ";", "}", "$", "main", "->", "query", "(", "$", "query", ")", ";", "}", "}" ]
Installs the database @return Eve\Framework\Cli\Install
[ "Installs", "the", "database" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Cli/Install.php#L181-L320
225,237
RevisionTen/cqrs
Services/SnapshotStore.php
SnapshotStore.find
public function find($uuid, $max_version = null): ?Snapshot { $criteria = new Criteria(); $criteria->where(Criteria::expr()->eq('uuid', $uuid)); if (null !== $max_version) { $criteria->andWhere(Criteria::expr()->lte('version', $max_version)); } $criteria->orderBy(['version' => Criteria::DESC]); $snapshot = $this->em->getRepository(Snapshot::class)->matching($criteria)->first(); return $snapshot instanceof Snapshot ? $snapshot : null; }
php
public function find($uuid, $max_version = null): ?Snapshot { $criteria = new Criteria(); $criteria->where(Criteria::expr()->eq('uuid', $uuid)); if (null !== $max_version) { $criteria->andWhere(Criteria::expr()->lte('version', $max_version)); } $criteria->orderBy(['version' => Criteria::DESC]); $snapshot = $this->em->getRepository(Snapshot::class)->matching($criteria)->first(); return $snapshot instanceof Snapshot ? $snapshot : null; }
[ "public", "function", "find", "(", "$", "uuid", ",", "$", "max_version", "=", "null", ")", ":", "?", "Snapshot", "{", "$", "criteria", "=", "new", "Criteria", "(", ")", ";", "$", "criteria", "->", "where", "(", "Criteria", "::", "expr", "(", ")", "->", "eq", "(", "'uuid'", ",", "$", "uuid", ")", ")", ";", "if", "(", "null", "!==", "$", "max_version", ")", "{", "$", "criteria", "->", "andWhere", "(", "Criteria", "::", "expr", "(", ")", "->", "lte", "(", "'version'", ",", "$", "max_version", ")", ")", ";", "}", "$", "criteria", "->", "orderBy", "(", "[", "'version'", "=>", "Criteria", "::", "DESC", "]", ")", ";", "$", "snapshot", "=", "$", "this", "->", "em", "->", "getRepository", "(", "Snapshot", "::", "class", ")", "->", "matching", "(", "$", "criteria", ")", "->", "first", "(", ")", ";", "return", "$", "snapshot", "instanceof", "Snapshot", "?", "$", "snapshot", ":", "null", ";", "}" ]
Finds the latest Snapshot of an Aggregate. @param $uuid @param null $max_version the maximum version for the provided uuid @return Snapshot|null
[ "Finds", "the", "latest", "Snapshot", "of", "an", "Aggregate", "." ]
d94fdd86855a994c4662e24a6c3c08ef586e64f9
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/SnapshotStore.php#L47-L60
225,238
RevisionTen/cqrs
Services/SnapshotStore.php
SnapshotStore.save
public function save(AggregateInterface $aggregate): void { $snapshot = new Snapshot(); $snapshot->setUuid($aggregate->getUuid()); $snapshot->setVersion($aggregate->getVersion()); $snapshot->setAggregateCreated($aggregate->getCreated()); $snapshot->setAggregateModified($aggregate->getModified()); $snapshot->setAggregateClass(\get_class($aggregate)); $snapshot->setHistory($aggregate->getHistory()); $aggregateData = json_decode(json_encode($aggregate), true); $snapshot->setPayload($aggregateData); try { $this->em->persist($snapshot); $this->em->flush(); } catch (OptimisticLockException $e) { $this->messageBus->dispatch(new Message( $e->getMessage(), $e->getCode(), null, $aggregate->getUuid(), $e )); } catch (UniqueConstraintViolationException $e) { $this->messageBus->dispatch(new Message( $e->getMessage(), $e->getCode(), null, $aggregate->getUuid(), $e )); } }
php
public function save(AggregateInterface $aggregate): void { $snapshot = new Snapshot(); $snapshot->setUuid($aggregate->getUuid()); $snapshot->setVersion($aggregate->getVersion()); $snapshot->setAggregateCreated($aggregate->getCreated()); $snapshot->setAggregateModified($aggregate->getModified()); $snapshot->setAggregateClass(\get_class($aggregate)); $snapshot->setHistory($aggregate->getHistory()); $aggregateData = json_decode(json_encode($aggregate), true); $snapshot->setPayload($aggregateData); try { $this->em->persist($snapshot); $this->em->flush(); } catch (OptimisticLockException $e) { $this->messageBus->dispatch(new Message( $e->getMessage(), $e->getCode(), null, $aggregate->getUuid(), $e )); } catch (UniqueConstraintViolationException $e) { $this->messageBus->dispatch(new Message( $e->getMessage(), $e->getCode(), null, $aggregate->getUuid(), $e )); } }
[ "public", "function", "save", "(", "AggregateInterface", "$", "aggregate", ")", ":", "void", "{", "$", "snapshot", "=", "new", "Snapshot", "(", ")", ";", "$", "snapshot", "->", "setUuid", "(", "$", "aggregate", "->", "getUuid", "(", ")", ")", ";", "$", "snapshot", "->", "setVersion", "(", "$", "aggregate", "->", "getVersion", "(", ")", ")", ";", "$", "snapshot", "->", "setAggregateCreated", "(", "$", "aggregate", "->", "getCreated", "(", ")", ")", ";", "$", "snapshot", "->", "setAggregateModified", "(", "$", "aggregate", "->", "getModified", "(", ")", ")", ";", "$", "snapshot", "->", "setAggregateClass", "(", "\\", "get_class", "(", "$", "aggregate", ")", ")", ";", "$", "snapshot", "->", "setHistory", "(", "$", "aggregate", "->", "getHistory", "(", ")", ")", ";", "$", "aggregateData", "=", "json_decode", "(", "json_encode", "(", "$", "aggregate", ")", ",", "true", ")", ";", "$", "snapshot", "->", "setPayload", "(", "$", "aggregateData", ")", ";", "try", "{", "$", "this", "->", "em", "->", "persist", "(", "$", "snapshot", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}", "catch", "(", "OptimisticLockException", "$", "e", ")", "{", "$", "this", "->", "messageBus", "->", "dispatch", "(", "new", "Message", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "null", ",", "$", "aggregate", "->", "getUuid", "(", ")", ",", "$", "e", ")", ")", ";", "}", "catch", "(", "UniqueConstraintViolationException", "$", "e", ")", "{", "$", "this", "->", "messageBus", "->", "dispatch", "(", "new", "Message", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "e", "->", "getCode", "(", ")", ",", "null", ",", "$", "aggregate", "->", "getUuid", "(", ")", ",", "$", "e", ")", ")", ";", "}", "}" ]
Saves a Snapshot. @param AggregateInterface $aggregate
[ "Saves", "a", "Snapshot", "." ]
d94fdd86855a994c4662e24a6c3c08ef586e64f9
https://github.com/RevisionTen/cqrs/blob/d94fdd86855a994c4662e24a6c3c08ef586e64f9/Services/SnapshotStore.php#L67-L99
225,239
czogori/Dami
src/Dami/Migration/FileNameBuilder.php
FileNameBuilder.build
public function build($timestamp = null) { if (null === $timestamp) { $timestamp = new \DateTime(); $timestamp = $timestamp->format('YmdHis'); } $fileName = sprintf('%s_%s.php', $timestamp, S::underscored($this->migrationName)); return $fileName; }
php
public function build($timestamp = null) { if (null === $timestamp) { $timestamp = new \DateTime(); $timestamp = $timestamp->format('YmdHis'); } $fileName = sprintf('%s_%s.php', $timestamp, S::underscored($this->migrationName)); return $fileName; }
[ "public", "function", "build", "(", "$", "timestamp", "=", "null", ")", "{", "if", "(", "null", "===", "$", "timestamp", ")", "{", "$", "timestamp", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "timestamp", "=", "$", "timestamp", "->", "format", "(", "'YmdHis'", ")", ";", "}", "$", "fileName", "=", "sprintf", "(", "'%s_%s.php'", ",", "$", "timestamp", ",", "S", "::", "underscored", "(", "$", "this", "->", "migrationName", ")", ")", ";", "return", "$", "fileName", ";", "}" ]
Build migration file name. @param datatype $timestamp Timestamp of migration. @return string
[ "Build", "migration", "file", "name", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/FileNameBuilder.php#L33-L42
225,240
charlesportwoodii/rpq-client
src/Queue/Stats.php
Stats.get
public function get(string $date = null) : array { if ($date === null) { $date = \date('Y-m-d'); } return [ 'queued' => $this->queue->count(), 'pass' => $this->queue->getStatsByType($date, 'pass'), 'fail' => $this->queue->getStatsByType($date, 'fail'), 'retry' => $this->queue->getStatsByType($date, 'retry'), 'cancel' => $this->queue->getStatsByType($date, 'cancel') ]; }
php
public function get(string $date = null) : array { if ($date === null) { $date = \date('Y-m-d'); } return [ 'queued' => $this->queue->count(), 'pass' => $this->queue->getStatsByType($date, 'pass'), 'fail' => $this->queue->getStatsByType($date, 'fail'), 'retry' => $this->queue->getStatsByType($date, 'retry'), 'cancel' => $this->queue->getStatsByType($date, 'cancel') ]; }
[ "public", "function", "get", "(", "string", "$", "date", "=", "null", ")", ":", "array", "{", "if", "(", "$", "date", "===", "null", ")", "{", "$", "date", "=", "\\", "date", "(", "'Y-m-d'", ")", ";", "}", "return", "[", "'queued'", "=>", "$", "this", "->", "queue", "->", "count", "(", ")", ",", "'pass'", "=>", "$", "this", "->", "queue", "->", "getStatsByType", "(", "$", "date", ",", "'pass'", ")", ",", "'fail'", "=>", "$", "this", "->", "queue", "->", "getStatsByType", "(", "$", "date", ",", "'fail'", ")", ",", "'retry'", "=>", "$", "this", "->", "queue", "->", "getStatsByType", "(", "$", "date", ",", "'retry'", ")", ",", "'cancel'", "=>", "$", "this", "->", "queue", "->", "getStatsByType", "(", "$", "date", ",", "'cancel'", ")", "]", ";", "}" ]
Retrieves stats for a given date @param string $date @return void
[ "Retrieves", "stats", "for", "a", "given", "date" ]
9419cfe5c30d35ea54ce8faba7545daea2312e0f
https://github.com/charlesportwoodii/rpq-client/blob/9419cfe5c30d35ea54ce8faba7545daea2312e0f/src/Queue/Stats.php#L32-L45
225,241
edineibauer/entity
public/src/Entity/Dicionario.php
Dicionario.getDataOnlyEntity
private function getDataOnlyEntity(): array { $data = []; foreach ($this->dicionario as $meta) { if (!in_array($meta->getFormat(), ["extend_mult", "list_mult", "selecao_mult", "information", "checkbox_mult"]) && ($meta->getFormat() !== "password" || strlen($meta->getValue()) > 3)) $data[$meta->getColumn()] = $meta->getValue(); } return $data; }
php
private function getDataOnlyEntity(): array { $data = []; foreach ($this->dicionario as $meta) { if (!in_array($meta->getFormat(), ["extend_mult", "list_mult", "selecao_mult", "information", "checkbox_mult"]) && ($meta->getFormat() !== "password" || strlen($meta->getValue()) > 3)) $data[$meta->getColumn()] = $meta->getValue(); } return $data; }
[ "private", "function", "getDataOnlyEntity", "(", ")", ":", "array", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "dicionario", "as", "$", "meta", ")", "{", "if", "(", "!", "in_array", "(", "$", "meta", "->", "getFormat", "(", ")", ",", "[", "\"extend_mult\"", ",", "\"list_mult\"", ",", "\"selecao_mult\"", ",", "\"information\"", ",", "\"checkbox_mult\"", "]", ")", "&&", "(", "$", "meta", "->", "getFormat", "(", ")", "!==", "\"password\"", "||", "strlen", "(", "$", "meta", "->", "getValue", "(", ")", ")", ">", "3", ")", ")", "$", "data", "[", "$", "meta", "->", "getColumn", "(", ")", "]", "=", "$", "meta", "->", "getValue", "(", ")", ";", "}", "return", "$", "data", ";", "}" ]
Retorna valores de uma entidade correspondente ao seu armazenamento em sql na sua tabela @return array
[ "Retorna", "valores", "de", "uma", "entidade", "correspondente", "ao", "seu", "armazenamento", "em", "sql", "na", "sua", "tabela" ]
8437f5531ed9cd5f75c4c69c7db27b31e31e02c2
https://github.com/edineibauer/entity/blob/8437f5531ed9cd5f75c4c69c7db27b31e31e02c2/public/src/Entity/Dicionario.php#L158-L166
225,242
czogori/Dami
src/Dami/Migration/Api/TableApi.php
TableApi.dropColumn
public function dropColumn($name) { $column = new TextColumn($name); $column->setTable($this); $this->actions[] = function () use ($column) { return $this->manipulation->drop($column); }; return $this; }
php
public function dropColumn($name) { $column = new TextColumn($name); $column->setTable($this); $this->actions[] = function () use ($column) { return $this->manipulation->drop($column); }; return $this; }
[ "public", "function", "dropColumn", "(", "$", "name", ")", "{", "$", "column", "=", "new", "TextColumn", "(", "$", "name", ")", ";", "$", "column", "->", "setTable", "(", "$", "this", ")", ";", "$", "this", "->", "actions", "[", "]", "=", "function", "(", ")", "use", "(", "$", "column", ")", "{", "return", "$", "this", "->", "manipulation", "->", "drop", "(", "$", "column", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Drop a column. @param string $name Column name. @return TableApi Self.
[ "Drop", "a", "column", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/TableApi.php#L79-L89
225,243
czogori/Dami
src/Dami/Migration/Api/TableApi.php
TableApi.addForeignKey
public function addForeignKey($referenceTable, $referenceColumns, array $options = []) { $schema = isset($options['schema']) ? new Schema($options['schema']) : null; $foreignKey = new ForeignKey($this, new Table($referenceTable, $schema)); $foreignKey->setReferencedColumns($referenceColumns); if (isset($options['column'])) { $foreignKey->setColumns($options['column']); } else { $foreignKey->setColumns($referenceColumns); } if (isset($options['update'])) { $foreignKey->setUpdateAction($options['update']); } if (isset($options['delete'])) { $foreignKey->setDeleteAction($options['delete']); } $this->actions[] = function () use ($foreignKey) { return $this->manipulation->create($foreignKey); }; return $this; }
php
public function addForeignKey($referenceTable, $referenceColumns, array $options = []) { $schema = isset($options['schema']) ? new Schema($options['schema']) : null; $foreignKey = new ForeignKey($this, new Table($referenceTable, $schema)); $foreignKey->setReferencedColumns($referenceColumns); if (isset($options['column'])) { $foreignKey->setColumns($options['column']); } else { $foreignKey->setColumns($referenceColumns); } if (isset($options['update'])) { $foreignKey->setUpdateAction($options['update']); } if (isset($options['delete'])) { $foreignKey->setDeleteAction($options['delete']); } $this->actions[] = function () use ($foreignKey) { return $this->manipulation->create($foreignKey); }; return $this; }
[ "public", "function", "addForeignKey", "(", "$", "referenceTable", ",", "$", "referenceColumns", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "schema", "=", "isset", "(", "$", "options", "[", "'schema'", "]", ")", "?", "new", "Schema", "(", "$", "options", "[", "'schema'", "]", ")", ":", "null", ";", "$", "foreignKey", "=", "new", "ForeignKey", "(", "$", "this", ",", "new", "Table", "(", "$", "referenceTable", ",", "$", "schema", ")", ")", ";", "$", "foreignKey", "->", "setReferencedColumns", "(", "$", "referenceColumns", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'column'", "]", ")", ")", "{", "$", "foreignKey", "->", "setColumns", "(", "$", "options", "[", "'column'", "]", ")", ";", "}", "else", "{", "$", "foreignKey", "->", "setColumns", "(", "$", "referenceColumns", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'update'", "]", ")", ")", "{", "$", "foreignKey", "->", "setUpdateAction", "(", "$", "options", "[", "'update'", "]", ")", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'delete'", "]", ")", ")", "{", "$", "foreignKey", "->", "setDeleteAction", "(", "$", "options", "[", "'delete'", "]", ")", ";", "}", "$", "this", "->", "actions", "[", "]", "=", "function", "(", ")", "use", "(", "$", "foreignKey", ")", "{", "return", "$", "this", "->", "manipulation", "->", "create", "(", "$", "foreignKey", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Add a foreign key. @param string $referenceTable Referenced table name. @param string $referenceColumns Columns of referenced table. @param array $options Optional options. @return TableApi Self.
[ "Add", "a", "foreign", "key", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/TableApi.php#L100-L123
225,244
czogori/Dami
src/Dami/Migration/Api/TableApi.php
TableApi.dropForeignKey
public function dropForeignKey($referenceTable, $referenceColumns, array $options = []) { $schema = isset($options['schema']) ? new Schema($options['schema']) : null; $foreignKey = new ForeignKey($this, new Table($referenceTable, $schema)); $foreignKey->setColumns($referenceColumns); $foreignKey->setReferencedColumns($referenceColumns); $this->actions[] = function () use ($foreignKey) { return $this->manipulation->drop($foreignKey); }; return $this; }
php
public function dropForeignKey($referenceTable, $referenceColumns, array $options = []) { $schema = isset($options['schema']) ? new Schema($options['schema']) : null; $foreignKey = new ForeignKey($this, new Table($referenceTable, $schema)); $foreignKey->setColumns($referenceColumns); $foreignKey->setReferencedColumns($referenceColumns); $this->actions[] = function () use ($foreignKey) { return $this->manipulation->drop($foreignKey); }; return $this; }
[ "public", "function", "dropForeignKey", "(", "$", "referenceTable", ",", "$", "referenceColumns", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "schema", "=", "isset", "(", "$", "options", "[", "'schema'", "]", ")", "?", "new", "Schema", "(", "$", "options", "[", "'schema'", "]", ")", ":", "null", ";", "$", "foreignKey", "=", "new", "ForeignKey", "(", "$", "this", ",", "new", "Table", "(", "$", "referenceTable", ",", "$", "schema", ")", ")", ";", "$", "foreignKey", "->", "setColumns", "(", "$", "referenceColumns", ")", ";", "$", "foreignKey", "->", "setReferencedColumns", "(", "$", "referenceColumns", ")", ";", "$", "this", "->", "actions", "[", "]", "=", "function", "(", ")", "use", "(", "$", "foreignKey", ")", "{", "return", "$", "this", "->", "manipulation", "->", "drop", "(", "$", "foreignKey", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Drop a foreign key. @param string $referenceTable Referenced table name. @param string $referenceColumns Columns of referenced table. @param array $options Optional options. @return TableApi Self.
[ "Drop", "a", "foreign", "key", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/TableApi.php#L134-L147
225,245
czogori/Dami
src/Dami/Migration/Api/TableApi.php
TableApi.addUnique
public function addUnique($columns) { $unique = new Unique($columns, $this); $this->actions[] = function () use ($unique) { return $this->manipulation->create($unique); }; return $this; }
php
public function addUnique($columns) { $unique = new Unique($columns, $this); $this->actions[] = function () use ($unique) { return $this->manipulation->create($unique); }; return $this; }
[ "public", "function", "addUnique", "(", "$", "columns", ")", "{", "$", "unique", "=", "new", "Unique", "(", "$", "columns", ",", "$", "this", ")", ";", "$", "this", "->", "actions", "[", "]", "=", "function", "(", ")", "use", "(", "$", "unique", ")", "{", "return", "$", "this", "->", "manipulation", "->", "create", "(", "$", "unique", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Add a unique constraint. @param array $columns Unique columns. @return TableApi Self.
[ "Add", "a", "unique", "constraint", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/TableApi.php#L156-L165
225,246
czogori/Dami
src/Dami/Migration/Api/TableApi.php
TableApi.dropUnique
public function dropUnique($columns) { $unique = new Unique($columns, $this); $this->actions[] = function () use ($unique) { return $this->manipulation->drop($unique); }; return $this; }
php
public function dropUnique($columns) { $unique = new Unique($columns, $this); $this->actions[] = function () use ($unique) { return $this->manipulation->drop($unique); }; return $this; }
[ "public", "function", "dropUnique", "(", "$", "columns", ")", "{", "$", "unique", "=", "new", "Unique", "(", "$", "columns", ",", "$", "this", ")", ";", "$", "this", "->", "actions", "[", "]", "=", "function", "(", ")", "use", "(", "$", "unique", ")", "{", "return", "$", "this", "->", "manipulation", "->", "drop", "(", "$", "unique", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Drop a unique constraint. @param array $columns Unique columns. @return TableApi Self.
[ "Drop", "a", "unique", "constraint", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/TableApi.php#L174-L183
225,247
czogori/Dami
src/Dami/Migration/Api/TableApi.php
TableApi.addIndex
public function addIndex($columns) { $index = new Index($columns, $this); $this->actions[] = function () use ($index) { return $this->manipulation->create($index); }; return $this; }
php
public function addIndex($columns) { $index = new Index($columns, $this); $this->actions[] = function () use ($index) { return $this->manipulation->create($index); }; return $this; }
[ "public", "function", "addIndex", "(", "$", "columns", ")", "{", "$", "index", "=", "new", "Index", "(", "$", "columns", ",", "$", "this", ")", ";", "$", "this", "->", "actions", "[", "]", "=", "function", "(", ")", "use", "(", "$", "index", ")", "{", "return", "$", "this", "->", "manipulation", "->", "create", "(", "$", "index", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Add a index on columns. @param array $columns Index columns. @return TableApi Self.
[ "Add", "a", "index", "on", "columns", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/TableApi.php#L192-L201
225,248
czogori/Dami
src/Dami/Migration/Api/TableApi.php
TableApi.dropIndex
public function dropIndex($columns) { $index = new Index($columns, $this); $this->actions[] = function () use ($index) { return $this->manipulation->drop($index); }; return $this; }
php
public function dropIndex($columns) { $index = new Index($columns, $this); $this->actions[] = function () use ($index) { return $this->manipulation->drop($index); }; return $this; }
[ "public", "function", "dropIndex", "(", "$", "columns", ")", "{", "$", "index", "=", "new", "Index", "(", "$", "columns", ",", "$", "this", ")", ";", "$", "this", "->", "actions", "[", "]", "=", "function", "(", ")", "use", "(", "$", "index", ")", "{", "return", "$", "this", "->", "manipulation", "->", "drop", "(", "$", "index", ")", ";", "}", ";", "return", "$", "this", ";", "}" ]
Drop a index on columns. @param array $columns Index columns. @return TableApi Self.
[ "Drop", "a", "index", "on", "columns", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/Migration/Api/TableApi.php#L210-L219
225,249
SetBased/php-abc-html
src/Helper/Html.php
Html.generateAttribute
public static function generateAttribute(string $name, $value): string { $html = ''; switch ($name) { // Boolean attributes. case 'autofocus': case 'checked': case 'disabled': case 'hidden': case 'ismap': case 'multiple': case 'novalidate': case 'readonly': case 'required': case 'selected': case 'spellcheck': if (!empty($value)) { $html = ' '; $html .= $name; $html .= '="'; $html .= $name; $html .= '"'; } break; // Annoying boolean attribute exceptions. case 'draggable': case 'contenteditable': if ($value!==null) { $html = ' '; $html .= $name; $html .= (!empty($value)) ? '="true"' : '="false"'; } break; case 'autocomplete': if ($value!==null) { $html = ' '; $html .= $name; $html .= (!empty($value)) ? '="on"' : '="off"'; } break; case 'translate': if ($value!==null) { $html = ' '; $html .= $name; $html .= (!empty($value)) ? '="yes"' : '="no"'; } break; case 'class' and is_array($value): $classes = implode(' ', self::cleanClasses($value)); if ($classes!=='') { $html = ' class="'; $html .= htmlspecialchars($classes, ENT_QUOTES, self::$encoding); $html .= '"'; } break; default: if ($value!==null && $value!=='') { $html = ' '; $html .= htmlspecialchars($name, ENT_QUOTES, self::$encoding); $html .= '="'; $html .= htmlspecialchars(Cast::toManString($value), ENT_QUOTES, self::$encoding); $html .= '"'; } break; } return $html; }
php
public static function generateAttribute(string $name, $value): string { $html = ''; switch ($name) { // Boolean attributes. case 'autofocus': case 'checked': case 'disabled': case 'hidden': case 'ismap': case 'multiple': case 'novalidate': case 'readonly': case 'required': case 'selected': case 'spellcheck': if (!empty($value)) { $html = ' '; $html .= $name; $html .= '="'; $html .= $name; $html .= '"'; } break; // Annoying boolean attribute exceptions. case 'draggable': case 'contenteditable': if ($value!==null) { $html = ' '; $html .= $name; $html .= (!empty($value)) ? '="true"' : '="false"'; } break; case 'autocomplete': if ($value!==null) { $html = ' '; $html .= $name; $html .= (!empty($value)) ? '="on"' : '="off"'; } break; case 'translate': if ($value!==null) { $html = ' '; $html .= $name; $html .= (!empty($value)) ? '="yes"' : '="no"'; } break; case 'class' and is_array($value): $classes = implode(' ', self::cleanClasses($value)); if ($classes!=='') { $html = ' class="'; $html .= htmlspecialchars($classes, ENT_QUOTES, self::$encoding); $html .= '"'; } break; default: if ($value!==null && $value!=='') { $html = ' '; $html .= htmlspecialchars($name, ENT_QUOTES, self::$encoding); $html .= '="'; $html .= htmlspecialchars(Cast::toManString($value), ENT_QUOTES, self::$encoding); $html .= '"'; } break; } return $html; }
[ "public", "static", "function", "generateAttribute", "(", "string", "$", "name", ",", "$", "value", ")", ":", "string", "{", "$", "html", "=", "''", ";", "switch", "(", "$", "name", ")", "{", "// Boolean attributes.", "case", "'autofocus'", ":", "case", "'checked'", ":", "case", "'disabled'", ":", "case", "'hidden'", ":", "case", "'ismap'", ":", "case", "'multiple'", ":", "case", "'novalidate'", ":", "case", "'readonly'", ":", "case", "'required'", ":", "case", "'selected'", ":", "case", "'spellcheck'", ":", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "html", "=", "' '", ";", "$", "html", ".=", "$", "name", ";", "$", "html", ".=", "'=\"'", ";", "$", "html", ".=", "$", "name", ";", "$", "html", ".=", "'\"'", ";", "}", "break", ";", "// Annoying boolean attribute exceptions.", "case", "'draggable'", ":", "case", "'contenteditable'", ":", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "html", "=", "' '", ";", "$", "html", ".=", "$", "name", ";", "$", "html", ".=", "(", "!", "empty", "(", "$", "value", ")", ")", "?", "'=\"true\"'", ":", "'=\"false\"'", ";", "}", "break", ";", "case", "'autocomplete'", ":", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "html", "=", "' '", ";", "$", "html", ".=", "$", "name", ";", "$", "html", ".=", "(", "!", "empty", "(", "$", "value", ")", ")", "?", "'=\"on\"'", ":", "'=\"off\"'", ";", "}", "break", ";", "case", "'translate'", ":", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "html", "=", "' '", ";", "$", "html", ".=", "$", "name", ";", "$", "html", ".=", "(", "!", "empty", "(", "$", "value", ")", ")", "?", "'=\"yes\"'", ":", "'=\"no\"'", ";", "}", "break", ";", "case", "'class'", "and", "is_array", "(", "$", "value", ")", ":", "$", "classes", "=", "implode", "(", "' '", ",", "self", "::", "cleanClasses", "(", "$", "value", ")", ")", ";", "if", "(", "$", "classes", "!==", "''", ")", "{", "$", "html", "=", "' class=\"'", ";", "$", "html", ".=", "htmlspecialchars", "(", "$", "classes", ",", "ENT_QUOTES", ",", "self", "::", "$", "encoding", ")", ";", "$", "html", ".=", "'\"'", ";", "}", "break", ";", "default", ":", "if", "(", "$", "value", "!==", "null", "&&", "$", "value", "!==", "''", ")", "{", "$", "html", "=", "' '", ";", "$", "html", ".=", "htmlspecialchars", "(", "$", "name", ",", "ENT_QUOTES", ",", "self", "::", "$", "encoding", ")", ";", "$", "html", ".=", "'=\"'", ";", "$", "html", ".=", "htmlspecialchars", "(", "Cast", "::", "toManString", "(", "$", "value", ")", ",", "ENT_QUOTES", ",", "self", "::", "$", "encoding", ")", ";", "$", "html", ".=", "'\"'", ";", "}", "break", ";", "}", "return", "$", "html", ";", "}" ]
Returns a string with proper conversion of special characters to HTML entities of an attribute of a HTML tag. Boolean attributes (e.g. checked, disabled and draggable, autocomplete also) are set when the value is none empty. @param string $name The name of the attribute. @param mixed $value The value of the attribute. @return string @since 1.0.0 @api
[ "Returns", "a", "string", "with", "proper", "conversion", "of", "special", "characters", "to", "HTML", "entities", "of", "an", "attribute", "of", "a", "HTML", "tag", "." ]
4e123c3b477bcd76ed82239711653b85ad5f4b26
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/Helper/Html.php#L120-L200
225,250
SetBased/php-abc-html
src/Helper/Html.php
Html.generateElement
public static function generateElement(string $tagName, array $attributes = [], ?string $innerText = '', bool $isHtml = false): string { $html = self::generateTag($tagName, $attributes); $html .= ($isHtml) ? $innerText : self::txt2Html($innerText); $html .= '</'; $html .= $tagName; $html .= '>'; return $html; }
php
public static function generateElement(string $tagName, array $attributes = [], ?string $innerText = '', bool $isHtml = false): string { $html = self::generateTag($tagName, $attributes); $html .= ($isHtml) ? $innerText : self::txt2Html($innerText); $html .= '</'; $html .= $tagName; $html .= '>'; return $html; }
[ "public", "static", "function", "generateElement", "(", "string", "$", "tagName", ",", "array", "$", "attributes", "=", "[", "]", ",", "?", "string", "$", "innerText", "=", "''", ",", "bool", "$", "isHtml", "=", "false", ")", ":", "string", "{", "$", "html", "=", "self", "::", "generateTag", "(", "$", "tagName", ",", "$", "attributes", ")", ";", "$", "html", ".=", "(", "$", "isHtml", ")", "?", "$", "innerText", ":", "self", "::", "txt2Html", "(", "$", "innerText", ")", ";", "$", "html", ".=", "'</'", ";", "$", "html", ".=", "$", "tagName", ";", "$", "html", ".=", "'>'", ";", "return", "$", "html", ";", "}" ]
Generates HTML code for an element. Note: tags for void elements such as '<br/>' are not supported. @param string $tagName The name of the tag, e.g. a, form. @param array $attributes The attributes of the tag. Special characters in the attributes will be replaced with HTML entities. @param string|null $innerText The inner text of the tag. @param bool $isHtml If set the inner text is a HTML snippet, otherwise special characters in the inner text will be replaced with HTML entities. @return string @since 1.0.0 @api
[ "Generates", "HTML", "code", "for", "an", "element", "." ]
4e123c3b477bcd76ed82239711653b85ad5f4b26
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/Helper/Html.php#L220-L232
225,251
SetBased/php-abc-html
src/Helper/Html.php
Html.generateTag
public static function generateTag(string $tagName, array $attributes = []): string { $html = '<'; $html .= $tagName; foreach ($attributes as $name => $value) { // Ignore attributes with leading underscore. if (strpos($name, '_')!==0) $html .= self::generateAttribute($name, $value); } $html .= '>'; return $html; }
php
public static function generateTag(string $tagName, array $attributes = []): string { $html = '<'; $html .= $tagName; foreach ($attributes as $name => $value) { // Ignore attributes with leading underscore. if (strpos($name, '_')!==0) $html .= self::generateAttribute($name, $value); } $html .= '>'; return $html; }
[ "public", "static", "function", "generateTag", "(", "string", "$", "tagName", ",", "array", "$", "attributes", "=", "[", "]", ")", ":", "string", "{", "$", "html", "=", "'<'", ";", "$", "html", ".=", "$", "tagName", ";", "foreach", "(", "$", "attributes", "as", "$", "name", "=>", "$", "value", ")", "{", "// Ignore attributes with leading underscore.", "if", "(", "strpos", "(", "$", "name", ",", "'_'", ")", "!==", "0", ")", "$", "html", ".=", "self", "::", "generateAttribute", "(", "$", "name", ",", "$", "value", ")", ";", "}", "$", "html", ".=", "'>'", ";", "return", "$", "html", ";", "}" ]
Generates HTML code for a start tag of an element. @param string $tagName The name of the tag, e.g. a, form. @param array $attributes The attributes of the tag. Special characters in the attributes will be replaced with HTML entities. @return string @since 1.0.0 @api
[ "Generates", "HTML", "code", "for", "a", "start", "tag", "of", "an", "element", "." ]
4e123c3b477bcd76ed82239711653b85ad5f4b26
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/Helper/Html.php#L247-L259
225,252
SetBased/php-abc-html
src/Helper/Html.php
Html.txt2Slug
public static function txt2Slug(?string $string): string { if ($string===null) return ''; return trim(preg_replace('/[^0-9a-z]+/', '-', strtr(mb_strtolower($string), self::$trans)), '-'); }
php
public static function txt2Slug(?string $string): string { if ($string===null) return ''; return trim(preg_replace('/[^0-9a-z]+/', '-', strtr(mb_strtolower($string), self::$trans)), '-'); }
[ "public", "static", "function", "txt2Slug", "(", "?", "string", "$", "string", ")", ":", "string", "{", "if", "(", "$", "string", "===", "null", ")", "return", "''", ";", "return", "trim", "(", "preg_replace", "(", "'/[^0-9a-z]+/'", ",", "'-'", ",", "strtr", "(", "mb_strtolower", "(", "$", "string", ")", ",", "self", "::", "$", "trans", ")", ")", ",", "'-'", ")", ";", "}" ]
Returns the slug of a string that can be safely used in an URL. @param string|null $string The string. @return string @since 1.1.0 @api
[ "Returns", "the", "slug", "of", "a", "string", "that", "can", "be", "safely", "used", "in", "an", "URL", "." ]
4e123c3b477bcd76ed82239711653b85ad5f4b26
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/Helper/Html.php#L338-L343
225,253
SetBased/php-abc-html
src/Helper/Html.php
Html.cleanClasses
private static function cleanClasses(array $classes): array { $ret = []; foreach ($classes as $class) { $tmp = Cast::toManString($class, ''); if ($tmp!=='') $ret[] = $tmp; } return array_unique($ret); }
php
private static function cleanClasses(array $classes): array { $ret = []; foreach ($classes as $class) { $tmp = Cast::toManString($class, ''); if ($tmp!=='') $ret[] = $tmp; } return array_unique($ret); }
[ "private", "static", "function", "cleanClasses", "(", "array", "$", "classes", ")", ":", "array", "{", "$", "ret", "=", "[", "]", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "tmp", "=", "Cast", "::", "toManString", "(", "$", "class", ",", "''", ")", ";", "if", "(", "$", "tmp", "!==", "''", ")", "$", "ret", "[", "]", "=", "$", "tmp", ";", "}", "return", "array_unique", "(", "$", "ret", ")", ";", "}" ]
Removes empty and duplicate classes from an array with classes. @param array $classes The classes. @return array
[ "Removes", "empty", "and", "duplicate", "classes", "from", "an", "array", "with", "classes", "." ]
4e123c3b477bcd76ed82239711653b85ad5f4b26
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/Helper/Html.php#L353-L364
225,254
GFG/dto-context
src/DTOContext/DataWrapper/Base.php
Base.toArray
public function toArray() { $ref = new \ReflectionObject($this); $export = array(); foreach ($ref->getProperties() as $property) { $property->setAccessible(true); $name = strtolower( preg_replace('@([A-Z])@', '_\1', $property->getName()) ); $export[$name] = $property->getValue($this); if ($export[$name] instanceof DataWrapperInterface) { $export[$name] = $export[$name]->toArray(); } elseif ($export[$name] instanceof \DateTime) { $export[$name] = $export[$name]->format('Y-m-d'); } } return $export; }
php
public function toArray() { $ref = new \ReflectionObject($this); $export = array(); foreach ($ref->getProperties() as $property) { $property->setAccessible(true); $name = strtolower( preg_replace('@([A-Z])@', '_\1', $property->getName()) ); $export[$name] = $property->getValue($this); if ($export[$name] instanceof DataWrapperInterface) { $export[$name] = $export[$name]->toArray(); } elseif ($export[$name] instanceof \DateTime) { $export[$name] = $export[$name]->format('Y-m-d'); } } return $export; }
[ "public", "function", "toArray", "(", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionObject", "(", "$", "this", ")", ";", "$", "export", "=", "array", "(", ")", ";", "foreach", "(", "$", "ref", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "name", "=", "strtolower", "(", "preg_replace", "(", "'@([A-Z])@'", ",", "'_\\1'", ",", "$", "property", "->", "getName", "(", ")", ")", ")", ";", "$", "export", "[", "$", "name", "]", "=", "$", "property", "->", "getValue", "(", "$", "this", ")", ";", "if", "(", "$", "export", "[", "$", "name", "]", "instanceof", "DataWrapperInterface", ")", "{", "$", "export", "[", "$", "name", "]", "=", "$", "export", "[", "$", "name", "]", "->", "toArray", "(", ")", ";", "}", "elseif", "(", "$", "export", "[", "$", "name", "]", "instanceof", "\\", "DateTime", ")", "{", "$", "export", "[", "$", "name", "]", "=", "$", "export", "[", "$", "name", "]", "->", "format", "(", "'Y-m-d'", ")", ";", "}", "}", "return", "$", "export", ";", "}" ]
Export dataWrapper values as an array @return array
[ "Export", "dataWrapper", "values", "as", "an", "array" ]
c1a47273d3dc2704bfd3f90c2560726688d54558
https://github.com/GFG/dto-context/blob/c1a47273d3dc2704bfd3f90c2560726688d54558/src/DTOContext/DataWrapper/Base.php#L79-L99
225,255
GFG/dto-context
src/DTOContext/DataWrapper/Base.php
Base.toCleanArray
public function toCleanArray() { $export = $this->toArray(); $cleanExport = array(); foreach ($export as $key => $value) { if ($value) { $cleanExport[$key] = $value; } } return $cleanExport; }
php
public function toCleanArray() { $export = $this->toArray(); $cleanExport = array(); foreach ($export as $key => $value) { if ($value) { $cleanExport[$key] = $value; } } return $cleanExport; }
[ "public", "function", "toCleanArray", "(", ")", "{", "$", "export", "=", "$", "this", "->", "toArray", "(", ")", ";", "$", "cleanExport", "=", "array", "(", ")", ";", "foreach", "(", "$", "export", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", ")", "{", "$", "cleanExport", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "return", "$", "cleanExport", ";", "}" ]
ToArray with unset null fields @return array
[ "ToArray", "with", "unset", "null", "fields" ]
c1a47273d3dc2704bfd3f90c2560726688d54558
https://github.com/GFG/dto-context/blob/c1a47273d3dc2704bfd3f90c2560726688d54558/src/DTOContext/DataWrapper/Base.php#L106-L118
225,256
Eve-PHP/Framework
src/Action/Html.php
Html.getEngine
public function getEngine() { if($this->engine) { return $this->engine; } //get the template path $path = eve()->path('template'); //create engine $this->engine = eve('handlebars'); //add helpers $helpers = include(__DIR__.'/helpers.php'); foreach($helpers as $name => $callback) { $this->engine->registerHelper($name, $callback); } return $this->engine; }
php
public function getEngine() { if($this->engine) { return $this->engine; } //get the template path $path = eve()->path('template'); //create engine $this->engine = eve('handlebars'); //add helpers $helpers = include(__DIR__.'/helpers.php'); foreach($helpers as $name => $callback) { $this->engine->registerHelper($name, $callback); } return $this->engine; }
[ "public", "function", "getEngine", "(", ")", "{", "if", "(", "$", "this", "->", "engine", ")", "{", "return", "$", "this", "->", "engine", ";", "}", "//get the template path", "$", "path", "=", "eve", "(", ")", "->", "path", "(", "'template'", ")", ";", "//create engine", "$", "this", "->", "engine", "=", "eve", "(", "'handlebars'", ")", ";", "//add helpers", "$", "helpers", "=", "include", "(", "__DIR__", ".", "'/helpers.php'", ")", ";", "foreach", "(", "$", "helpers", "as", "$", "name", "=>", "$", "callback", ")", "{", "$", "this", "->", "engine", "->", "registerHelper", "(", "$", "name", ",", "$", "callback", ")", ";", "}", "return", "$", "this", "->", "engine", ";", "}" ]
Returns the default template engine @return Eden\Handlebars\Index
[ "Returns", "the", "default", "template", "engine" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Action/Html.php#L177-L197
225,257
Eve-PHP/Framework
src/Action/Html.php
Html.getTemplate
protected function getTemplate() { //if no template if(!$this->template) { //Action folder and template folder //are in the same directoryby default // Sample\Namespace\Action\Can\Be\Anywhere $index = 'Action\\'; $root = strpos(get_class($this), $index); $root += strlen($index); $this->template = eve('string') // \Can\Be\Anywhere ->set('\\'.substr(get_class($this), $root)) // /Can/Be/Anywhere ->str_replace('\\', DIRECTORY_SEPARATOR) // /can/be/anywhere ->strtolower() // jic ->str_replace('//', '/') //done ->get(); } return $this->template; }
php
protected function getTemplate() { //if no template if(!$this->template) { //Action folder and template folder //are in the same directoryby default // Sample\Namespace\Action\Can\Be\Anywhere $index = 'Action\\'; $root = strpos(get_class($this), $index); $root += strlen($index); $this->template = eve('string') // \Can\Be\Anywhere ->set('\\'.substr(get_class($this), $root)) // /Can/Be/Anywhere ->str_replace('\\', DIRECTORY_SEPARATOR) // /can/be/anywhere ->strtolower() // jic ->str_replace('//', '/') //done ->get(); } return $this->template; }
[ "protected", "function", "getTemplate", "(", ")", "{", "//if no template", "if", "(", "!", "$", "this", "->", "template", ")", "{", "//Action folder and template folder", "//are in the same directoryby default", "// Sample\\Namespace\\Action\\Can\\Be\\Anywhere", "$", "index", "=", "'Action\\\\'", ";", "$", "root", "=", "strpos", "(", "get_class", "(", "$", "this", ")", ",", "$", "index", ")", ";", "$", "root", "+=", "strlen", "(", "$", "index", ")", ";", "$", "this", "->", "template", "=", "eve", "(", "'string'", ")", "// \\Can\\Be\\Anywhere", "->", "set", "(", "'\\\\'", ".", "substr", "(", "get_class", "(", "$", "this", ")", ",", "$", "root", ")", ")", "// /Can/Be/Anywhere", "->", "str_replace", "(", "'\\\\'", ",", "DIRECTORY_SEPARATOR", ")", "// /can/be/anywhere", "->", "strtolower", "(", ")", "// jic", "->", "str_replace", "(", "'//'", ",", "'/'", ")", "//done", "->", "get", "(", ")", ";", "}", "return", "$", "this", "->", "template", ";", "}" ]
Returns file path used for templating @return array
[ "Returns", "file", "path", "used", "for", "templating" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Action/Html.php#L204-L230
225,258
Eve-PHP/Framework
src/Action/Html.php
Html.parse
private function parse($file, $data = array(), $trigger = null) { if(is_null($data)) { $data = array(); } else if(is_string($data)) { $trigger = $data; $data = array(); } if($trigger) { eve()->trigger('template-'.$trigger, $file, $data); } $path = eve()->path('template'); if(file_exists($path.'/'.$file.'.php') && static::TEMPLATE_EXTENSION !== 'php' ) { return eve('template')->set($data)->parsePHP($path.'/'.$file.'.php'); } else if(file_exists($path.$file.'.phtml') && static::TEMPLATE_EXTENSION !== 'phtml' ) { return eve('template')->set($data)->parsePHP($path.'/'.$file.'.phtml'); } $contents = file_get_contents($path . '/'. $file . '.' . static::TEMPLATE_EXTENSION); $template = $this->getEngine()->compile($contents); return $template($data); }
php
private function parse($file, $data = array(), $trigger = null) { if(is_null($data)) { $data = array(); } else if(is_string($data)) { $trigger = $data; $data = array(); } if($trigger) { eve()->trigger('template-'.$trigger, $file, $data); } $path = eve()->path('template'); if(file_exists($path.'/'.$file.'.php') && static::TEMPLATE_EXTENSION !== 'php' ) { return eve('template')->set($data)->parsePHP($path.'/'.$file.'.php'); } else if(file_exists($path.$file.'.phtml') && static::TEMPLATE_EXTENSION !== 'phtml' ) { return eve('template')->set($data)->parsePHP($path.'/'.$file.'.phtml'); } $contents = file_get_contents($path . '/'. $file . '.' . static::TEMPLATE_EXTENSION); $template = $this->getEngine()->compile($contents); return $template($data); }
[ "private", "function", "parse", "(", "$", "file", ",", "$", "data", "=", "array", "(", ")", ",", "$", "trigger", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "$", "data", "=", "array", "(", ")", ";", "}", "else", "if", "(", "is_string", "(", "$", "data", ")", ")", "{", "$", "trigger", "=", "$", "data", ";", "$", "data", "=", "array", "(", ")", ";", "}", "if", "(", "$", "trigger", ")", "{", "eve", "(", ")", "->", "trigger", "(", "'template-'", ".", "$", "trigger", ",", "$", "file", ",", "$", "data", ")", ";", "}", "$", "path", "=", "eve", "(", ")", "->", "path", "(", "'template'", ")", ";", "if", "(", "file_exists", "(", "$", "path", ".", "'/'", ".", "$", "file", ".", "'.php'", ")", "&&", "static", "::", "TEMPLATE_EXTENSION", "!==", "'php'", ")", "{", "return", "eve", "(", "'template'", ")", "->", "set", "(", "$", "data", ")", "->", "parsePHP", "(", "$", "path", ".", "'/'", ".", "$", "file", ".", "'.php'", ")", ";", "}", "else", "if", "(", "file_exists", "(", "$", "path", ".", "$", "file", ".", "'.phtml'", ")", "&&", "static", "::", "TEMPLATE_EXTENSION", "!==", "'phtml'", ")", "{", "return", "eve", "(", "'template'", ")", "->", "set", "(", "$", "data", ")", "->", "parsePHP", "(", "$", "path", ".", "'/'", ".", "$", "file", ".", "'.phtml'", ")", ";", "}", "$", "contents", "=", "file_get_contents", "(", "$", "path", ".", "'/'", ".", "$", "file", ".", "'.'", ".", "static", "::", "TEMPLATE_EXTENSION", ")", ";", "$", "template", "=", "$", "this", "->", "getEngine", "(", ")", "->", "compile", "(", "$", "contents", ")", ";", "return", "$", "template", "(", "$", "data", ")", ";", "}" ]
Returns the template loaded with specified data @param string $file The relative template file @param array $data Data to bind to the template @param string|null $trigger Event trigger to fire @return string
[ "Returns", "the", "template", "loaded", "with", "specified", "data" ]
cd4ca9472c6c46034bde402bf20bf2f86657c608
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Action/Html.php#L241-L270
225,259
froq/froq-session
src/Session.php
Session.isValidId
public function isValidId(?string $id): bool { if ($id == '') { return false; } if ($this->saveHandler != null && method_exists($this->saveHandler, 'isValidId')) { return $this->saveHandler->isValidId($id); } static $idPattern; if ($idPattern == null) { if ($this->options['hash']) { $idPattern = '~^[A-F0-9]{'. $this->options['hashLength'] .'}$~'; } else { // @see http://php.net/manual/en/session.configuration.php#ini.session.sid-length // @see http://php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character // @see https://github.com/php/php-src/blob/PHP-7.1/UPGRADING#L114 $idLength = ini_get('session.sid_length') ?: self::SID_LENGTH; $idBitsPerCharacter = ini_get('session.sid_bits_per_character'); if ($idBitsPerCharacter == '') { // never happens, but obsession.. ini_set('session.sid_length', (string) self::SID_LENGTH); ini_set('session.sid_bits_per_character', (string) ($idBitsPerCharacter = self::SID_BITSPERCHARACTER)); } $idCharacters = ''; switch ((int) $idBitsPerCharacter) { case 4: $idCharacters = '0-9a-f'; break; case 5: $idCharacters = '0-9a-v'; break; case 6: $idCharacters = '0-9a-zA-Z-,'; break; } $idPattern = '~^['. $idCharacters .']{'. $idLength .'}$~'; } } return (bool) preg_match($idPattern, $id); }
php
public function isValidId(?string $id): bool { if ($id == '') { return false; } if ($this->saveHandler != null && method_exists($this->saveHandler, 'isValidId')) { return $this->saveHandler->isValidId($id); } static $idPattern; if ($idPattern == null) { if ($this->options['hash']) { $idPattern = '~^[A-F0-9]{'. $this->options['hashLength'] .'}$~'; } else { // @see http://php.net/manual/en/session.configuration.php#ini.session.sid-length // @see http://php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character // @see https://github.com/php/php-src/blob/PHP-7.1/UPGRADING#L114 $idLength = ini_get('session.sid_length') ?: self::SID_LENGTH; $idBitsPerCharacter = ini_get('session.sid_bits_per_character'); if ($idBitsPerCharacter == '') { // never happens, but obsession.. ini_set('session.sid_length', (string) self::SID_LENGTH); ini_set('session.sid_bits_per_character', (string) ($idBitsPerCharacter = self::SID_BITSPERCHARACTER)); } $idCharacters = ''; switch ((int) $idBitsPerCharacter) { case 4: $idCharacters = '0-9a-f'; break; case 5: $idCharacters = '0-9a-v'; break; case 6: $idCharacters = '0-9a-zA-Z-,'; break; } $idPattern = '~^['. $idCharacters .']{'. $idLength .'}$~'; } } return (bool) preg_match($idPattern, $id); }
[ "public", "function", "isValidId", "(", "?", "string", "$", "id", ")", ":", "bool", "{", "if", "(", "$", "id", "==", "''", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "saveHandler", "!=", "null", "&&", "method_exists", "(", "$", "this", "->", "saveHandler", ",", "'isValidId'", ")", ")", "{", "return", "$", "this", "->", "saveHandler", "->", "isValidId", "(", "$", "id", ")", ";", "}", "static", "$", "idPattern", ";", "if", "(", "$", "idPattern", "==", "null", ")", "{", "if", "(", "$", "this", "->", "options", "[", "'hash'", "]", ")", "{", "$", "idPattern", "=", "'~^[A-F0-9]{'", ".", "$", "this", "->", "options", "[", "'hashLength'", "]", ".", "'}$~'", ";", "}", "else", "{", "// @see http://php.net/manual/en/session.configuration.php#ini.session.sid-length", "// @see http://php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character", "// @see https://github.com/php/php-src/blob/PHP-7.1/UPGRADING#L114", "$", "idLength", "=", "ini_get", "(", "'session.sid_length'", ")", "?", ":", "self", "::", "SID_LENGTH", ";", "$", "idBitsPerCharacter", "=", "ini_get", "(", "'session.sid_bits_per_character'", ")", ";", "if", "(", "$", "idBitsPerCharacter", "==", "''", ")", "{", "// never happens, but obsession..", "ini_set", "(", "'session.sid_length'", ",", "(", "string", ")", "self", "::", "SID_LENGTH", ")", ";", "ini_set", "(", "'session.sid_bits_per_character'", ",", "(", "string", ")", "(", "$", "idBitsPerCharacter", "=", "self", "::", "SID_BITSPERCHARACTER", ")", ")", ";", "}", "$", "idCharacters", "=", "''", ";", "switch", "(", "(", "int", ")", "$", "idBitsPerCharacter", ")", "{", "case", "4", ":", "$", "idCharacters", "=", "'0-9a-f'", ";", "break", ";", "case", "5", ":", "$", "idCharacters", "=", "'0-9a-v'", ";", "break", ";", "case", "6", ":", "$", "idCharacters", "=", "'0-9a-zA-Z-,'", ";", "break", ";", "}", "$", "idPattern", "=", "'~^['", ".", "$", "idCharacters", ".", "']{'", ".", "$", "idLength", ".", "'}$~'", ";", "}", "}", "return", "(", "bool", ")", "preg_match", "(", "$", "idPattern", ",", "$", "id", ")", ";", "}" ]
Is valid id. @param ?string $id @return bool
[ "Is", "valid", "id", "." ]
16b1ac72fa784aa0f5b7ee25f2b3d2bfb3193494
https://github.com/froq/froq-session/blob/16b1ac72fa784aa0f5b7ee25f2b3d2bfb3193494/src/Session.php#L387-L424
225,260
froq/froq-session
src/Session.php
Session.isValidSource
public function isValidSource(?string $id): bool { if ($id == '') { return false; } if ($this->saveHandler != null && method_exists($this->saveHandler, 'isValidSource')) { return $this->saveHandler->isValidSource($id); } // for 'sess_' @see https://github.com/php/php-src/blob/master/ext/session/mod_files.c#L85 return file_exists($this->savePath .'/sess_'. $id); }
php
public function isValidSource(?string $id): bool { if ($id == '') { return false; } if ($this->saveHandler != null && method_exists($this->saveHandler, 'isValidSource')) { return $this->saveHandler->isValidSource($id); } // for 'sess_' @see https://github.com/php/php-src/blob/master/ext/session/mod_files.c#L85 return file_exists($this->savePath .'/sess_'. $id); }
[ "public", "function", "isValidSource", "(", "?", "string", "$", "id", ")", ":", "bool", "{", "if", "(", "$", "id", "==", "''", ")", "{", "return", "false", ";", "}", "if", "(", "$", "this", "->", "saveHandler", "!=", "null", "&&", "method_exists", "(", "$", "this", "->", "saveHandler", ",", "'isValidSource'", ")", ")", "{", "return", "$", "this", "->", "saveHandler", "->", "isValidSource", "(", "$", "id", ")", ";", "}", "// for 'sess_' @see https://github.com/php/php-src/blob/master/ext/session/mod_files.c#L85", "return", "file_exists", "(", "$", "this", "->", "savePath", ".", "'/sess_'", ".", "$", "id", ")", ";", "}" ]
Is valid source. @param ?string $id @return bool
[ "Is", "valid", "source", "." ]
16b1ac72fa784aa0f5b7ee25f2b3d2bfb3193494
https://github.com/froq/froq-session/blob/16b1ac72fa784aa0f5b7ee25f2b3d2bfb3193494/src/Session.php#L431-L443
225,261
froq/froq-session
src/Session.php
Session.generateId
public function generateId(): string { if ($this->saveHandler != null && method_exists($this->saveHandler, 'generateId')) { return $this->saveHandler->generateId($id); } $id = session_create_id(); // hash by length if ($this->options['hash']) { switch ($this->options['hashLength']) { case 32: $id = hash('md5', $id); break; case 40: $id = hash('sha1', $id); break; case 64: $id = hash('sha256', $id); break; case 128: $id = hash('sha512', $id); break; default: throw new SessionException("No valid 'hashLength' option given, only ". "'32,40,64,128' are accepted"); } $id = strtoupper($id); } return $id; }
php
public function generateId(): string { if ($this->saveHandler != null && method_exists($this->saveHandler, 'generateId')) { return $this->saveHandler->generateId($id); } $id = session_create_id(); // hash by length if ($this->options['hash']) { switch ($this->options['hashLength']) { case 32: $id = hash('md5', $id); break; case 40: $id = hash('sha1', $id); break; case 64: $id = hash('sha256', $id); break; case 128: $id = hash('sha512', $id); break; default: throw new SessionException("No valid 'hashLength' option given, only ". "'32,40,64,128' are accepted"); } $id = strtoupper($id); } return $id; }
[ "public", "function", "generateId", "(", ")", ":", "string", "{", "if", "(", "$", "this", "->", "saveHandler", "!=", "null", "&&", "method_exists", "(", "$", "this", "->", "saveHandler", ",", "'generateId'", ")", ")", "{", "return", "$", "this", "->", "saveHandler", "->", "generateId", "(", "$", "id", ")", ";", "}", "$", "id", "=", "session_create_id", "(", ")", ";", "// hash by length", "if", "(", "$", "this", "->", "options", "[", "'hash'", "]", ")", "{", "switch", "(", "$", "this", "->", "options", "[", "'hashLength'", "]", ")", "{", "case", "32", ":", "$", "id", "=", "hash", "(", "'md5'", ",", "$", "id", ")", ";", "break", ";", "case", "40", ":", "$", "id", "=", "hash", "(", "'sha1'", ",", "$", "id", ")", ";", "break", ";", "case", "64", ":", "$", "id", "=", "hash", "(", "'sha256'", ",", "$", "id", ")", ";", "break", ";", "case", "128", ":", "$", "id", "=", "hash", "(", "'sha512'", ",", "$", "id", ")", ";", "break", ";", "default", ":", "throw", "new", "SessionException", "(", "\"No valid 'hashLength' option given, only \"", ".", "\"'32,40,64,128' are accepted\"", ")", ";", "}", "$", "id", "=", "strtoupper", "(", "$", "id", ")", ";", "}", "return", "$", "id", ";", "}" ]
Generate id. @return string @throws froq\session\SessionException
[ "Generate", "id", "." ]
16b1ac72fa784aa0f5b7ee25f2b3d2bfb3193494
https://github.com/froq/froq-session/blob/16b1ac72fa784aa0f5b7ee25f2b3d2bfb3193494/src/Session.php#L450-L473
225,262
bytic/Common
src/Records/Traits/Media/Logos/RecordTrait.php
RecordTrait.initLogoTypes
public function initLogoTypes() { if (isset($this->logoTypes)) { $this->_logoTypes = $this->logoTypes; } else { $this->_logoTypes = []; } }
php
public function initLogoTypes() { if (isset($this->logoTypes)) { $this->_logoTypes = $this->logoTypes; } else { $this->_logoTypes = []; } }
[ "public", "function", "initLogoTypes", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "logoTypes", ")", ")", "{", "$", "this", "->", "_logoTypes", "=", "$", "this", "->", "logoTypes", ";", "}", "else", "{", "$", "this", "->", "_logoTypes", "=", "[", "]", ";", "}", "}" ]
Init Logo Types
[ "Init", "Logo", "Types" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/Media/Logos/RecordTrait.php#L94-L101
225,263
spiral/translator
src/Translator.php
Translator.get
protected function get(string &$locale, string $domain, string $string): string { if ($this->catalogueManager->get($locale)->has($domain, $string)) { return $this->catalogueManager->get($locale)->get($domain, $string); } $locale = $this->config->getFallbackLocale(); if ($this->catalogueManager->get($locale)->has($domain, $string)) { return $this->catalogueManager->get($locale)->get($domain, $string); } // we can automatically register message if ($this->config->isAutoRegisterMessages()) { $this->catalogueManager->get($locale)->set($domain, $string, $string); $this->catalogueManager->save($locale); } //Unable to find translation return $string; }
php
protected function get(string &$locale, string $domain, string $string): string { if ($this->catalogueManager->get($locale)->has($domain, $string)) { return $this->catalogueManager->get($locale)->get($domain, $string); } $locale = $this->config->getFallbackLocale(); if ($this->catalogueManager->get($locale)->has($domain, $string)) { return $this->catalogueManager->get($locale)->get($domain, $string); } // we can automatically register message if ($this->config->isAutoRegisterMessages()) { $this->catalogueManager->get($locale)->set($domain, $string, $string); $this->catalogueManager->save($locale); } //Unable to find translation return $string; }
[ "protected", "function", "get", "(", "string", "&", "$", "locale", ",", "string", "$", "domain", ",", "string", "$", "string", ")", ":", "string", "{", "if", "(", "$", "this", "->", "catalogueManager", "->", "get", "(", "$", "locale", ")", "->", "has", "(", "$", "domain", ",", "$", "string", ")", ")", "{", "return", "$", "this", "->", "catalogueManager", "->", "get", "(", "$", "locale", ")", "->", "get", "(", "$", "domain", ",", "$", "string", ")", ";", "}", "$", "locale", "=", "$", "this", "->", "config", "->", "getFallbackLocale", "(", ")", ";", "if", "(", "$", "this", "->", "catalogueManager", "->", "get", "(", "$", "locale", ")", "->", "has", "(", "$", "domain", ",", "$", "string", ")", ")", "{", "return", "$", "this", "->", "catalogueManager", "->", "get", "(", "$", "locale", ")", "->", "get", "(", "$", "domain", ",", "$", "string", ")", ";", "}", "// we can automatically register message", "if", "(", "$", "this", "->", "config", "->", "isAutoRegisterMessages", "(", ")", ")", "{", "$", "this", "->", "catalogueManager", "->", "get", "(", "$", "locale", ")", "->", "set", "(", "$", "domain", ",", "$", "string", ",", "$", "string", ")", ";", "$", "this", "->", "catalogueManager", "->", "save", "(", "$", "locale", ")", ";", "}", "//Unable to find translation", "return", "$", "string", ";", "}" ]
Get translation message from the locale bundle or fallback to default locale. @param string $locale @param string $domain @param string $string @return string
[ "Get", "translation", "message", "from", "the", "locale", "bundle", "or", "fallback", "to", "default", "locale", "." ]
dde0f3d3db7960c22a36b9e781fe30ab51656424
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Translator.php#L163-L183
225,264
spiral/translator
src/Translator.php
Translator.interpolate
public static function interpolate( string $string, array $values, string $prefix = '{', string $postfix = '}' ): string { $replaces = []; foreach ($values as $key => $value) { $value = (is_array($value) || $value instanceof \Closure) ? '' : $value; try { //Object as string $value = is_object($value) ? (string)$value : $value; } catch (\Exception $e) { $value = ''; } $replaces[$prefix . $key . $postfix] = $value; } return strtr($string, $replaces); }
php
public static function interpolate( string $string, array $values, string $prefix = '{', string $postfix = '}' ): string { $replaces = []; foreach ($values as $key => $value) { $value = (is_array($value) || $value instanceof \Closure) ? '' : $value; try { //Object as string $value = is_object($value) ? (string)$value : $value; } catch (\Exception $e) { $value = ''; } $replaces[$prefix . $key . $postfix] = $value; } return strtr($string, $replaces); }
[ "public", "static", "function", "interpolate", "(", "string", "$", "string", ",", "array", "$", "values", ",", "string", "$", "prefix", "=", "'{'", ",", "string", "$", "postfix", "=", "'}'", ")", ":", "string", "{", "$", "replaces", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "value", "=", "(", "is_array", "(", "$", "value", ")", "||", "$", "value", "instanceof", "\\", "Closure", ")", "?", "''", ":", "$", "value", ";", "try", "{", "//Object as string", "$", "value", "=", "is_object", "(", "$", "value", ")", "?", "(", "string", ")", "$", "value", ":", "$", "value", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "value", "=", "''", ";", "}", "$", "replaces", "[", "$", "prefix", ".", "$", "key", ".", "$", "postfix", "]", "=", "$", "value", ";", "}", "return", "strtr", "(", "$", "string", ",", "$", "replaces", ")", ";", "}" ]
Interpolate string with given parameters, used by many spiral components. Input: Hello {name}! Good {time}! + ['name' => 'Member', 'time' => 'day'] Output: Hello Member! Good Day! @param string $string @param array $values Arguments (key => value). Will skip unknown names. @param string $prefix Placeholder prefix, "{" by default. @param string $postfix Placeholder postfix, "}" by default. @return string
[ "Interpolate", "string", "with", "given", "parameters", "used", "by", "many", "spiral", "components", "." ]
dde0f3d3db7960c22a36b9e781fe30ab51656424
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Translator.php#L197-L216
225,265
kapitchi/KapitchiContact
src/KapitchiContact/Service/Storage/StorageTypeListener.php
StorageTypeListener.attachShared
public function attachShared(SharedEventManagerInterface $sharedEm) { $this->listeners[] = $sharedEm->attach($this->entityFormClass, 'init', array($this, 'onEntityFormInit')); $this->listeners[] = $sharedEm->attach($this->entityFormClass, 'setData', array($this, 'onEntityFormSetData')); $this->listeners[] = $sharedEm->attach($this->entityInputFilterClass, 'init', array($this, 'onEntityInputFilterInit')); $this->listeners[] = $sharedEm->attach($this->entityServiceClass, 'persist', array($this, 'onEntityServicePersist')); }
php
public function attachShared(SharedEventManagerInterface $sharedEm) { $this->listeners[] = $sharedEm->attach($this->entityFormClass, 'init', array($this, 'onEntityFormInit')); $this->listeners[] = $sharedEm->attach($this->entityFormClass, 'setData', array($this, 'onEntityFormSetData')); $this->listeners[] = $sharedEm->attach($this->entityInputFilterClass, 'init', array($this, 'onEntityInputFilterInit')); $this->listeners[] = $sharedEm->attach($this->entityServiceClass, 'persist', array($this, 'onEntityServicePersist')); }
[ "public", "function", "attachShared", "(", "SharedEventManagerInterface", "$", "sharedEm", ")", "{", "$", "this", "->", "listeners", "[", "]", "=", "$", "sharedEm", "->", "attach", "(", "$", "this", "->", "entityFormClass", ",", "'init'", ",", "array", "(", "$", "this", ",", "'onEntityFormInit'", ")", ")", ";", "$", "this", "->", "listeners", "[", "]", "=", "$", "sharedEm", "->", "attach", "(", "$", "this", "->", "entityFormClass", ",", "'setData'", ",", "array", "(", "$", "this", ",", "'onEntityFormSetData'", ")", ")", ";", "$", "this", "->", "listeners", "[", "]", "=", "$", "sharedEm", "->", "attach", "(", "$", "this", "->", "entityInputFilterClass", ",", "'init'", ",", "array", "(", "$", "this", ",", "'onEntityInputFilterInit'", ")", ")", ";", "$", "this", "->", "listeners", "[", "]", "=", "$", "sharedEm", "->", "attach", "(", "$", "this", "->", "entityServiceClass", ",", "'persist'", ",", "array", "(", "$", "this", ",", "'onEntityServicePersist'", ")", ")", ";", "}" ]
Attach listeners to an event manager @param EventManagerInterface $events @return void
[ "Attach", "listeners", "to", "an", "event", "manager" ]
318fe7fb62151736dc83b8a96267a1a308e9fd57
https://github.com/kapitchi/KapitchiContact/blob/318fe7fb62151736dc83b8a96267a1a308e9fd57/src/KapitchiContact/Service/Storage/StorageTypeListener.php#L62-L68
225,266
kapitchi/KapitchiContact
src/KapitchiContact/Service/Storage/StorageTypeListener.php
StorageTypeListener.detachShared
public function detachShared(SharedEventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($listener)) { unset($this->listeners[$index]); } } }
php
public function detachShared(SharedEventManagerInterface $events) { foreach ($this->listeners as $index => $listener) { if ($events->detach($listener)) { unset($this->listeners[$index]); } } }
[ "public", "function", "detachShared", "(", "SharedEventManagerInterface", "$", "events", ")", "{", "foreach", "(", "$", "this", "->", "listeners", "as", "$", "index", "=>", "$", "listener", ")", "{", "if", "(", "$", "events", "->", "detach", "(", "$", "listener", ")", ")", "{", "unset", "(", "$", "this", "->", "listeners", "[", "$", "index", "]", ")", ";", "}", "}", "}" ]
Detach listeners from an event manager @param EventManagerInterface $events @return void
[ "Detach", "listeners", "from", "an", "event", "manager" ]
318fe7fb62151736dc83b8a96267a1a308e9fd57
https://github.com/kapitchi/KapitchiContact/blob/318fe7fb62151736dc83b8a96267a1a308e9fd57/src/KapitchiContact/Service/Storage/StorageTypeListener.php#L76-L83
225,267
stubbles/stubbles-input
src/main/php/broker/param/MultipleSourceParamBroker.php
MultipleSourceParamBroker.procure
public function procure(Request $request, Annotation $annotation) { $read = $this->readSourceMethod($request, $annotation); $valueReader = $request->$read($annotation->getParamName()); /* @var $valueReader \stubbles\input\ValueReader */ if ($annotation->isRequired()) { return $this->filter( $valueReader->required($annotation->getRequiredErrorId('FIELD_EMPTY')), $annotation ); } if ($this->supportsDefault() && $annotation->hasValueByName('default')) { return $this->filter( $valueReader->defaultingTo($this->parseDefault($annotation->getDefault())), $annotation ); } return $this->filter($valueReader, $annotation); }
php
public function procure(Request $request, Annotation $annotation) { $read = $this->readSourceMethod($request, $annotation); $valueReader = $request->$read($annotation->getParamName()); /* @var $valueReader \stubbles\input\ValueReader */ if ($annotation->isRequired()) { return $this->filter( $valueReader->required($annotation->getRequiredErrorId('FIELD_EMPTY')), $annotation ); } if ($this->supportsDefault() && $annotation->hasValueByName('default')) { return $this->filter( $valueReader->defaultingTo($this->parseDefault($annotation->getDefault())), $annotation ); } return $this->filter($valueReader, $annotation); }
[ "public", "function", "procure", "(", "Request", "$", "request", ",", "Annotation", "$", "annotation", ")", "{", "$", "read", "=", "$", "this", "->", "readSourceMethod", "(", "$", "request", ",", "$", "annotation", ")", ";", "$", "valueReader", "=", "$", "request", "->", "$", "read", "(", "$", "annotation", "->", "getParamName", "(", ")", ")", ";", "/* @var $valueReader \\stubbles\\input\\ValueReader */", "if", "(", "$", "annotation", "->", "isRequired", "(", ")", ")", "{", "return", "$", "this", "->", "filter", "(", "$", "valueReader", "->", "required", "(", "$", "annotation", "->", "getRequiredErrorId", "(", "'FIELD_EMPTY'", ")", ")", ",", "$", "annotation", ")", ";", "}", "if", "(", "$", "this", "->", "supportsDefault", "(", ")", "&&", "$", "annotation", "->", "hasValueByName", "(", "'default'", ")", ")", "{", "return", "$", "this", "->", "filter", "(", "$", "valueReader", "->", "defaultingTo", "(", "$", "this", "->", "parseDefault", "(", "$", "annotation", "->", "getDefault", "(", ")", ")", ")", ",", "$", "annotation", ")", ";", "}", "return", "$", "this", "->", "filter", "(", "$", "valueReader", ",", "$", "annotation", ")", ";", "}" ]
extracts parameter from request and handles it @param \stubbles\input\Request $request instance to handle value with @param \stubbles\reflect\annotation\Annotation $annotation annotation which contains request param metadata @return mixed
[ "extracts", "parameter", "from", "request", "and", "handles", "it" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/param/MultipleSourceParamBroker.php#L30-L50
225,268
stubbles/stubbles-input
src/main/php/broker/param/MultipleSourceParamBroker.php
MultipleSourceParamBroker.procureParam
public function procureParam(Param $param, Annotation $annotation) { return $this->filter(ValueReader::forValue($param->value()), $annotation); }
php
public function procureParam(Param $param, Annotation $annotation) { return $this->filter(ValueReader::forValue($param->value()), $annotation); }
[ "public", "function", "procureParam", "(", "Param", "$", "param", ",", "Annotation", "$", "annotation", ")", "{", "return", "$", "this", "->", "filter", "(", "ValueReader", "::", "forValue", "(", "$", "param", "->", "value", "(", ")", ")", ",", "$", "annotation", ")", ";", "}" ]
handles a single param @param \stubbles\values\Value $param @param \stubbles\reflect\annotation\Annotation $annotation @return mixed
[ "handles", "a", "single", "param" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/param/MultipleSourceParamBroker.php#L80-L83
225,269
stubbles/stubbles-input
src/main/php/broker/param/MultipleSourceParamBroker.php
MultipleSourceParamBroker.readSourceMethod
private function readSourceMethod(Request $request, Annotation $annotation): string { $method = 'read' . $this->source($annotation); if (!method_exists($request, $method)) { throw new \RuntimeException( 'Unknown source ' . $annotation->getSource() . ' for ' . $annotation . ' on ' . get_class($request) ); } return $method; }
php
private function readSourceMethod(Request $request, Annotation $annotation): string { $method = 'read' . $this->source($annotation); if (!method_exists($request, $method)) { throw new \RuntimeException( 'Unknown source ' . $annotation->getSource() . ' for ' . $annotation . ' on ' . get_class($request) ); } return $method; }
[ "private", "function", "readSourceMethod", "(", "Request", "$", "request", ",", "Annotation", "$", "annotation", ")", ":", "string", "{", "$", "method", "=", "'read'", ".", "$", "this", "->", "source", "(", "$", "annotation", ")", ";", "if", "(", "!", "method_exists", "(", "$", "request", ",", "$", "method", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Unknown source '", ".", "$", "annotation", "->", "getSource", "(", ")", ".", "' for '", ".", "$", "annotation", ".", "' on '", ".", "get_class", "(", "$", "request", ")", ")", ";", "}", "return", "$", "method", ";", "}" ]
retrieves method to call on request instance @param \stubbles\input\Request $request @param \stubbles\reflect\annotation\Annotation $annotation @return string @throws \RuntimeException
[ "retrieves", "method", "to", "call", "on", "request", "instance" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/param/MultipleSourceParamBroker.php#L93-L104
225,270
stubbles/stubbles-input
src/main/php/broker/param/MultipleSourceParamBroker.php
MultipleSourceParamBroker.source
private function source(Annotation $annotation): string { if ($annotation->hasValueByName('source')) { return ucfirst(strtolower($annotation->getSource())); } return 'Param'; }
php
private function source(Annotation $annotation): string { if ($annotation->hasValueByName('source')) { return ucfirst(strtolower($annotation->getSource())); } return 'Param'; }
[ "private", "function", "source", "(", "Annotation", "$", "annotation", ")", ":", "string", "{", "if", "(", "$", "annotation", "->", "hasValueByName", "(", "'source'", ")", ")", "{", "return", "ucfirst", "(", "strtolower", "(", "$", "annotation", "->", "getSource", "(", ")", ")", ")", ";", "}", "return", "'Param'", ";", "}" ]
returns source from where to read value @param \stubbles\reflect\annotation\Annotation $annotation @return string
[ "returns", "source", "from", "where", "to", "read", "value" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/broker/param/MultipleSourceParamBroker.php#L112-L119
225,271
DrNixx/yii2-onix
src/collections/Iterator.php
Iterator.key
public function key() { if ($this->type == self::PAIRS) { return $this->current->key; } else { return $this->index; } }
php
public function key() { if ($this->type == self::PAIRS) { return $this->current->key; } else { return $this->index; } }
[ "public", "function", "key", "(", ")", "{", "if", "(", "$", "this", "->", "type", "==", "self", "::", "PAIRS", ")", "{", "return", "$", "this", "->", "current", "->", "key", ";", "}", "else", "{", "return", "$", "this", "->", "index", ";", "}", "}" ]
Return the current key @return mixed The current key
[ "Return", "the", "current", "key" ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/Iterator.php#L103-L110
225,272
DrNixx/yii2-onix
src/collections/Iterator.php
Iterator.current
public function current() { if ($this->type == self::KEYS) { return $this->current->key; } else { return $this->current->value; } }
php
public function current() { if ($this->type == self::KEYS) { return $this->current->key; } else { return $this->current->value; } }
[ "public", "function", "current", "(", ")", "{", "if", "(", "$", "this", "->", "type", "==", "self", "::", "KEYS", ")", "{", "return", "$", "this", "->", "current", "->", "key", ";", "}", "else", "{", "return", "$", "this", "->", "current", "->", "value", ";", "}", "}" ]
Return the current value @return mixed The current value
[ "Return", "the", "current", "value" ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/Iterator.php#L116-L123
225,273
DrNixx/yii2-onix
src/collections/Iterator.php
Iterator.next
public function next() { try { $this->current = $this->map->successor($this->current); } catch (\OutOfBoundsException $e) { $this->current = null; } $this->index++; }
php
public function next() { try { $this->current = $this->map->successor($this->current); } catch (\OutOfBoundsException $e) { $this->current = null; } $this->index++; }
[ "public", "function", "next", "(", ")", "{", "try", "{", "$", "this", "->", "current", "=", "$", "this", "->", "map", "->", "successor", "(", "$", "this", "->", "current", ")", ";", "}", "catch", "(", "\\", "OutOfBoundsException", "$", "e", ")", "{", "$", "this", "->", "current", "=", "null", ";", "}", "$", "this", "->", "index", "++", ";", "}" ]
Move forward to the next element @return void
[ "Move", "forward", "to", "the", "next", "element" ]
0a621ed301dc94971ff71af062b24d6bc0858dd7
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/Iterator.php#L129-L138
225,274
bytic/form
src/Traits/HasDisplayGroupsTrait.php
HasDisplayGroupsTrait.addDisplayGroup
public function addDisplayGroup(array $elements, $name) { $group = $this->newDisplayGroup(); foreach ($elements as $element) { if (isset($this->_elements[$element])) { $add = $this->getElement($element); if (null !== $add) { $group->addElement($add); } } } if (empty($group)) { trigger_error('No valid elements specified for display group'); } $name = (string)$name; $group->setLegend($name); $this->_displayGroups[$name] = $group; return $this; }
php
public function addDisplayGroup(array $elements, $name) { $group = $this->newDisplayGroup(); foreach ($elements as $element) { if (isset($this->_elements[$element])) { $add = $this->getElement($element); if (null !== $add) { $group->addElement($add); } } } if (empty($group)) { trigger_error('No valid elements specified for display group'); } $name = (string)$name; $group->setLegend($name); $this->_displayGroups[$name] = $group; return $this; }
[ "public", "function", "addDisplayGroup", "(", "array", "$", "elements", ",", "$", "name", ")", "{", "$", "group", "=", "$", "this", "->", "newDisplayGroup", "(", ")", ";", "foreach", "(", "$", "elements", "as", "$", "element", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_elements", "[", "$", "element", "]", ")", ")", "{", "$", "add", "=", "$", "this", "->", "getElement", "(", "$", "element", ")", ";", "if", "(", "null", "!==", "$", "add", ")", "{", "$", "group", "->", "addElement", "(", "$", "add", ")", ";", "}", "}", "}", "if", "(", "empty", "(", "$", "group", ")", ")", "{", "trigger_error", "(", "'No valid elements specified for display group'", ")", ";", "}", "$", "name", "=", "(", "string", ")", "$", "name", ";", "$", "group", "->", "setLegend", "(", "$", "name", ")", ";", "$", "this", "->", "_displayGroups", "[", "$", "name", "]", "=", "$", "group", ";", "return", "$", "this", ";", "}" ]
Add a display group Groups named elements for display purposes. @param array $elements @param $name @return $this
[ "Add", "a", "display", "group", "Groups", "named", "elements", "for", "display", "purposes", "." ]
eb0fcb950b912c15f6fde6974e75d61eaaa06248
https://github.com/bytic/form/blob/eb0fcb950b912c15f6fde6974e75d61eaaa06248/src/Traits/HasDisplayGroupsTrait.php#L22-L43
225,275
railken/amethyst-consume-rule
src/ConsumeRules/FrequencyConsumeRule.php
FrequencyConsumeRule.getDateIntervalPropertyByUnit
public function getDateIntervalPropertyByUnit(DateInterval $diff, $unit) { if ($unit === 'seconds') { return $diff->s + $diff->i * 60 + $diff->h * 60 * 60 + $diff->days * 60 * 60 * 24; } if ($unit === 'minutes') { return $diff->i + $diff->h * 60 + $diff->days * 60 * 24; } if ($unit === 'hours') { return $diff->h + $diff->days * 24; } if ($unit === 'days') { return $diff->days; } if ($unit === 'months') { return $diff->m + $diff->y * 12; } if ($unit === 'years') { return $diff->y; } }
php
public function getDateIntervalPropertyByUnit(DateInterval $diff, $unit) { if ($unit === 'seconds') { return $diff->s + $diff->i * 60 + $diff->h * 60 * 60 + $diff->days * 60 * 60 * 24; } if ($unit === 'minutes') { return $diff->i + $diff->h * 60 + $diff->days * 60 * 24; } if ($unit === 'hours') { return $diff->h + $diff->days * 24; } if ($unit === 'days') { return $diff->days; } if ($unit === 'months') { return $diff->m + $diff->y * 12; } if ($unit === 'years') { return $diff->y; } }
[ "public", "function", "getDateIntervalPropertyByUnit", "(", "DateInterval", "$", "diff", ",", "$", "unit", ")", "{", "if", "(", "$", "unit", "===", "'seconds'", ")", "{", "return", "$", "diff", "->", "s", "+", "$", "diff", "->", "i", "*", "60", "+", "$", "diff", "->", "h", "*", "60", "*", "60", "+", "$", "diff", "->", "days", "*", "60", "*", "60", "*", "24", ";", "}", "if", "(", "$", "unit", "===", "'minutes'", ")", "{", "return", "$", "diff", "->", "i", "+", "$", "diff", "->", "h", "*", "60", "+", "$", "diff", "->", "days", "*", "60", "*", "24", ";", "}", "if", "(", "$", "unit", "===", "'hours'", ")", "{", "return", "$", "diff", "->", "h", "+", "$", "diff", "->", "days", "*", "24", ";", "}", "if", "(", "$", "unit", "===", "'days'", ")", "{", "return", "$", "diff", "->", "days", ";", "}", "if", "(", "$", "unit", "===", "'months'", ")", "{", "return", "$", "diff", "->", "m", "+", "$", "diff", "->", "y", "*", "12", ";", "}", "if", "(", "$", "unit", "===", "'years'", ")", "{", "return", "$", "diff", "->", "y", ";", "}", "}" ]
Retrieve date interval property by unit. @param DateInterval $diff @param string $unit @return float|int
[ "Retrieve", "date", "interval", "property", "by", "unit", "." ]
c07ca1ec37ab9266c1782a1068739f225ebbd397
https://github.com/railken/amethyst-consume-rule/blob/c07ca1ec37ab9266c1782a1068739f225ebbd397/src/ConsumeRules/FrequencyConsumeRule.php#L66-L91
225,276
railken/amethyst-consume-rule
src/ConsumeRules/FrequencyConsumeRule.php
FrequencyConsumeRule.convertTime
public function convertTime(string $unit, float $value) { if ($unit === 'seconds') { return $value; } if ($unit === 'minutes') { return $value * (60); } if ($unit === 'hours') { return $value * (3600); } if ($unit === 'days') { return $value * (86400); } if ($unit === 'weeks') { return $value * (7 * 86400); } if ($unit === 'months') { return $value * (30 * 86400); } if ($unit === 'years') { return $value * (365 * 86400); } throw new \Exception('Wrong frequencies'); }
php
public function convertTime(string $unit, float $value) { if ($unit === 'seconds') { return $value; } if ($unit === 'minutes') { return $value * (60); } if ($unit === 'hours') { return $value * (3600); } if ($unit === 'days') { return $value * (86400); } if ($unit === 'weeks') { return $value * (7 * 86400); } if ($unit === 'months') { return $value * (30 * 86400); } if ($unit === 'years') { return $value * (365 * 86400); } throw new \Exception('Wrong frequencies'); }
[ "public", "function", "convertTime", "(", "string", "$", "unit", ",", "float", "$", "value", ")", "{", "if", "(", "$", "unit", "===", "'seconds'", ")", "{", "return", "$", "value", ";", "}", "if", "(", "$", "unit", "===", "'minutes'", ")", "{", "return", "$", "value", "*", "(", "60", ")", ";", "}", "if", "(", "$", "unit", "===", "'hours'", ")", "{", "return", "$", "value", "*", "(", "3600", ")", ";", "}", "if", "(", "$", "unit", "===", "'days'", ")", "{", "return", "$", "value", "*", "(", "86400", ")", ";", "}", "if", "(", "$", "unit", "===", "'weeks'", ")", "{", "return", "$", "value", "*", "(", "7", "*", "86400", ")", ";", "}", "if", "(", "$", "unit", "===", "'months'", ")", "{", "return", "$", "value", "*", "(", "30", "*", "86400", ")", ";", "}", "if", "(", "$", "unit", "===", "'years'", ")", "{", "return", "$", "value", "*", "(", "365", "*", "86400", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "'Wrong frequencies'", ")", ";", "}" ]
Converts to seconds. @param string $unit @param float $value @return float
[ "Converts", "to", "seconds", "." ]
c07ca1ec37ab9266c1782a1068739f225ebbd397
https://github.com/railken/amethyst-consume-rule/blob/c07ca1ec37ab9266c1782a1068739f225ebbd397/src/ConsumeRules/FrequencyConsumeRule.php#L101-L132
225,277
bytic/Common
src/Records/Traits/Media/Covers/RecordTrait.php
RecordTrait.cropCovers
public function cropCovers($request) { $path = $request['path']; $coords = $this->getCropCoordinates($request); $covers = $this->getNewCovers(); $full = reset($this->_coverTypes); $cropperCover = $this->getTempCover(); $cropperCover->setResourceFromFile(UPLOADS_PATH . 'tmp/' . $path); $originalCover = $this->getTempCover(); $originalCover->setResourceFromFile(UPLOADS_PATH . 'tmp/' . str_replace('crop-', '', $path)); $covers[$full]->setResourceFromFile($originalCover->getFile()); $covers[$full]->save(); $crop = next($this->_coverTypes); $workingCover = $covers[$crop]; $workingCover->copyResource($covers[$full]); $ratio = $covers[$full]->getWidth() / $cropperCover->getWidth(); $adjustX = round($coords['x'] * $ratio); $adjustY = round($coords['y'] * $ratio); $adjustWidth = round($coords['width'] * $ratio); $adjustHeight = round($coords['height'] * $ratio); $workingCover->crop( $adjustX, $adjustY, $workingCover->cropWidth, $workingCover->cropHeight, $adjustWidth, $adjustHeight); while ($size = next($this->_coverTypes)) { $covers[$size]->copyResource($covers[$crop])->resize()->unsharpMask()->save(); } $covers[$crop]->unsharpMask()->save(); Nip_File_System::instance()->deleteFile($cropperCover->getFile()); Nip_File_System::instance()->deleteFile($originalCover->getFile()); return $covers['default']; }
php
public function cropCovers($request) { $path = $request['path']; $coords = $this->getCropCoordinates($request); $covers = $this->getNewCovers(); $full = reset($this->_coverTypes); $cropperCover = $this->getTempCover(); $cropperCover->setResourceFromFile(UPLOADS_PATH . 'tmp/' . $path); $originalCover = $this->getTempCover(); $originalCover->setResourceFromFile(UPLOADS_PATH . 'tmp/' . str_replace('crop-', '', $path)); $covers[$full]->setResourceFromFile($originalCover->getFile()); $covers[$full]->save(); $crop = next($this->_coverTypes); $workingCover = $covers[$crop]; $workingCover->copyResource($covers[$full]); $ratio = $covers[$full]->getWidth() / $cropperCover->getWidth(); $adjustX = round($coords['x'] * $ratio); $adjustY = round($coords['y'] * $ratio); $adjustWidth = round($coords['width'] * $ratio); $adjustHeight = round($coords['height'] * $ratio); $workingCover->crop( $adjustX, $adjustY, $workingCover->cropWidth, $workingCover->cropHeight, $adjustWidth, $adjustHeight); while ($size = next($this->_coverTypes)) { $covers[$size]->copyResource($covers[$crop])->resize()->unsharpMask()->save(); } $covers[$crop]->unsharpMask()->save(); Nip_File_System::instance()->deleteFile($cropperCover->getFile()); Nip_File_System::instance()->deleteFile($originalCover->getFile()); return $covers['default']; }
[ "public", "function", "cropCovers", "(", "$", "request", ")", "{", "$", "path", "=", "$", "request", "[", "'path'", "]", ";", "$", "coords", "=", "$", "this", "->", "getCropCoordinates", "(", "$", "request", ")", ";", "$", "covers", "=", "$", "this", "->", "getNewCovers", "(", ")", ";", "$", "full", "=", "reset", "(", "$", "this", "->", "_coverTypes", ")", ";", "$", "cropperCover", "=", "$", "this", "->", "getTempCover", "(", ")", ";", "$", "cropperCover", "->", "setResourceFromFile", "(", "UPLOADS_PATH", ".", "'tmp/'", ".", "$", "path", ")", ";", "$", "originalCover", "=", "$", "this", "->", "getTempCover", "(", ")", ";", "$", "originalCover", "->", "setResourceFromFile", "(", "UPLOADS_PATH", ".", "'tmp/'", ".", "str_replace", "(", "'crop-'", ",", "''", ",", "$", "path", ")", ")", ";", "$", "covers", "[", "$", "full", "]", "->", "setResourceFromFile", "(", "$", "originalCover", "->", "getFile", "(", ")", ")", ";", "$", "covers", "[", "$", "full", "]", "->", "save", "(", ")", ";", "$", "crop", "=", "next", "(", "$", "this", "->", "_coverTypes", ")", ";", "$", "workingCover", "=", "$", "covers", "[", "$", "crop", "]", ";", "$", "workingCover", "->", "copyResource", "(", "$", "covers", "[", "$", "full", "]", ")", ";", "$", "ratio", "=", "$", "covers", "[", "$", "full", "]", "->", "getWidth", "(", ")", "/", "$", "cropperCover", "->", "getWidth", "(", ")", ";", "$", "adjustX", "=", "round", "(", "$", "coords", "[", "'x'", "]", "*", "$", "ratio", ")", ";", "$", "adjustY", "=", "round", "(", "$", "coords", "[", "'y'", "]", "*", "$", "ratio", ")", ";", "$", "adjustWidth", "=", "round", "(", "$", "coords", "[", "'width'", "]", "*", "$", "ratio", ")", ";", "$", "adjustHeight", "=", "round", "(", "$", "coords", "[", "'height'", "]", "*", "$", "ratio", ")", ";", "$", "workingCover", "->", "crop", "(", "$", "adjustX", ",", "$", "adjustY", ",", "$", "workingCover", "->", "cropWidth", ",", "$", "workingCover", "->", "cropHeight", ",", "$", "adjustWidth", ",", "$", "adjustHeight", ")", ";", "while", "(", "$", "size", "=", "next", "(", "$", "this", "->", "_coverTypes", ")", ")", "{", "$", "covers", "[", "$", "size", "]", "->", "copyResource", "(", "$", "covers", "[", "$", "crop", "]", ")", "->", "resize", "(", ")", "->", "unsharpMask", "(", ")", "->", "save", "(", ")", ";", "}", "$", "covers", "[", "$", "crop", "]", "->", "unsharpMask", "(", ")", "->", "save", "(", ")", ";", "Nip_File_System", "::", "instance", "(", ")", "->", "deleteFile", "(", "$", "cropperCover", "->", "getFile", "(", ")", ")", ";", "Nip_File_System", "::", "instance", "(", ")", "->", "deleteFile", "(", "$", "originalCover", "->", "getFile", "(", ")", ")", ";", "return", "$", "covers", "[", "'default'", "]", ";", "}" ]
Saves cropped covers @param array $request
[ "Saves", "cropped", "covers" ]
5d17043e03a2274a758fba1f6dedb7d85195bcfb
https://github.com/bytic/Common/blob/5d17043e03a2274a758fba1f6dedb7d85195bcfb/src/Records/Traits/Media/Covers/RecordTrait.php#L246-L288
225,278
mvccore/ext-debug-tracy-session
src/MvcCore/Ext/Debugs/Tracys/SessionPanel.php
SessionPanel.prepareSessionData
protected function prepareSessionData () { if ($_SESSION === NULL) return; // read `\MvcCore\Session` storage $sessionClass = \MvcCore\Application::GetInstance()->GetSessionClass(); $sessionRawMetaStore = $sessionClass::GetSessionMetadata(); $sessionMetaStore = $sessionRawMetaStore instanceof \stdClass ? $sessionRawMetaStore : (object) ['names' => []]; $maxLifeTimes = (object) [ 'hoops' => 0, 'seconds' => 0, ]; $standardRecords = []; $namespaceRecords = []; // look for each record in `$_SESSION` // if data are defined as session namespace // record in `\MvcCore\Session` meta store: foreach ($_SESSION as $sessionKey => $sessionData) { if ($sessionKey === self::$MetaStoreKey) continue; $item = new \stdClass; $item->key = $sessionKey; $item->value = \Tracy\Dumper::toHtml($sessionData); if (isset($sessionMetaStore->names[$sessionKey])) { if (count((array) $_SESSION[$sessionKey]) === 0) // this will be destroyed automatically by // \MvcCore\Session::Close();` before `session_write_close()`. continue; $item->type = self::_TYPE_NAMESPACE; $item->expirations = []; if (isset($sessionMetaStore->hoops[$sessionKey])) { $value = $sessionMetaStore->hoops[$sessionKey]; $item->expirations[] = (object) [ 'type' => self::_EXPIRATION_HOOPS, 'value' => $value, 'text' => $value . ' hoops', ]; if ($value > $maxLifeTimes->hoops) $maxLifeTimes->hoops = $value; } if (isset($sessionMetaStore->expirations[$sessionKey])) { $value = $sessionMetaStore->expirations[$sessionKey] - $this->now; $item->expirations[] = (object) [ 'type' => self::_EXPIRATION_TIME, 'value' => $value, 'text' => $this->_formateMaxLifeTimestamp($value), ]; if ($value > $maxLifeTimes->seconds) $maxLifeTimes->seconds = $value; } $namespaceRecords[$sessionKey] = $item; } else { $item->type = self::_TYPE_PHP; $standardRecords[$sessionKey] = $item; } } ksort($standardRecords); ksort($namespaceRecords); $this->session = array_merge($namespaceRecords, $standardRecords); $maxLifeTimesItems = []; if ($maxLifeTimes->seconds > 0) $maxLifeTimesItems[] = $this->_formateMaxLifeTimestamp($maxLifeTimes->seconds); if ($maxLifeTimes->hoops > 0) $maxLifeTimesItems[] = $maxLifeTimes->hoops . ' hoops'; $this->sessionMaxLifeTime = implode(', ', $maxLifeTimesItems); }
php
protected function prepareSessionData () { if ($_SESSION === NULL) return; // read `\MvcCore\Session` storage $sessionClass = \MvcCore\Application::GetInstance()->GetSessionClass(); $sessionRawMetaStore = $sessionClass::GetSessionMetadata(); $sessionMetaStore = $sessionRawMetaStore instanceof \stdClass ? $sessionRawMetaStore : (object) ['names' => []]; $maxLifeTimes = (object) [ 'hoops' => 0, 'seconds' => 0, ]; $standardRecords = []; $namespaceRecords = []; // look for each record in `$_SESSION` // if data are defined as session namespace // record in `\MvcCore\Session` meta store: foreach ($_SESSION as $sessionKey => $sessionData) { if ($sessionKey === self::$MetaStoreKey) continue; $item = new \stdClass; $item->key = $sessionKey; $item->value = \Tracy\Dumper::toHtml($sessionData); if (isset($sessionMetaStore->names[$sessionKey])) { if (count((array) $_SESSION[$sessionKey]) === 0) // this will be destroyed automatically by // \MvcCore\Session::Close();` before `session_write_close()`. continue; $item->type = self::_TYPE_NAMESPACE; $item->expirations = []; if (isset($sessionMetaStore->hoops[$sessionKey])) { $value = $sessionMetaStore->hoops[$sessionKey]; $item->expirations[] = (object) [ 'type' => self::_EXPIRATION_HOOPS, 'value' => $value, 'text' => $value . ' hoops', ]; if ($value > $maxLifeTimes->hoops) $maxLifeTimes->hoops = $value; } if (isset($sessionMetaStore->expirations[$sessionKey])) { $value = $sessionMetaStore->expirations[$sessionKey] - $this->now; $item->expirations[] = (object) [ 'type' => self::_EXPIRATION_TIME, 'value' => $value, 'text' => $this->_formateMaxLifeTimestamp($value), ]; if ($value > $maxLifeTimes->seconds) $maxLifeTimes->seconds = $value; } $namespaceRecords[$sessionKey] = $item; } else { $item->type = self::_TYPE_PHP; $standardRecords[$sessionKey] = $item; } } ksort($standardRecords); ksort($namespaceRecords); $this->session = array_merge($namespaceRecords, $standardRecords); $maxLifeTimesItems = []; if ($maxLifeTimes->seconds > 0) $maxLifeTimesItems[] = $this->_formateMaxLifeTimestamp($maxLifeTimes->seconds); if ($maxLifeTimes->hoops > 0) $maxLifeTimesItems[] = $maxLifeTimes->hoops . ' hoops'; $this->sessionMaxLifeTime = implode(', ', $maxLifeTimesItems); }
[ "protected", "function", "prepareSessionData", "(", ")", "{", "if", "(", "$", "_SESSION", "===", "NULL", ")", "return", ";", "// read `\\MvcCore\\Session` storage", "$", "sessionClass", "=", "\\", "MvcCore", "\\", "Application", "::", "GetInstance", "(", ")", "->", "GetSessionClass", "(", ")", ";", "$", "sessionRawMetaStore", "=", "$", "sessionClass", "::", "GetSessionMetadata", "(", ")", ";", "$", "sessionMetaStore", "=", "$", "sessionRawMetaStore", "instanceof", "\\", "stdClass", "?", "$", "sessionRawMetaStore", ":", "(", "object", ")", "[", "'names'", "=>", "[", "]", "]", ";", "$", "maxLifeTimes", "=", "(", "object", ")", "[", "'hoops'", "=>", "0", ",", "'seconds'", "=>", "0", ",", "]", ";", "$", "standardRecords", "=", "[", "]", ";", "$", "namespaceRecords", "=", "[", "]", ";", "// look for each record in `$_SESSION`", "// if data are defined as session namespace", "// record in `\\MvcCore\\Session` meta store:", "foreach", "(", "$", "_SESSION", "as", "$", "sessionKey", "=>", "$", "sessionData", ")", "{", "if", "(", "$", "sessionKey", "===", "self", "::", "$", "MetaStoreKey", ")", "continue", ";", "$", "item", "=", "new", "\\", "stdClass", ";", "$", "item", "->", "key", "=", "$", "sessionKey", ";", "$", "item", "->", "value", "=", "\\", "Tracy", "\\", "Dumper", "::", "toHtml", "(", "$", "sessionData", ")", ";", "if", "(", "isset", "(", "$", "sessionMetaStore", "->", "names", "[", "$", "sessionKey", "]", ")", ")", "{", "if", "(", "count", "(", "(", "array", ")", "$", "_SESSION", "[", "$", "sessionKey", "]", ")", "===", "0", ")", "// this will be destroyed automatically by", "// \\MvcCore\\Session::Close();` before `session_write_close()`.", "continue", ";", "$", "item", "->", "type", "=", "self", "::", "_TYPE_NAMESPACE", ";", "$", "item", "->", "expirations", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "sessionMetaStore", "->", "hoops", "[", "$", "sessionKey", "]", ")", ")", "{", "$", "value", "=", "$", "sessionMetaStore", "->", "hoops", "[", "$", "sessionKey", "]", ";", "$", "item", "->", "expirations", "[", "]", "=", "(", "object", ")", "[", "'type'", "=>", "self", "::", "_EXPIRATION_HOOPS", ",", "'value'", "=>", "$", "value", ",", "'text'", "=>", "$", "value", ".", "' hoops'", ",", "]", ";", "if", "(", "$", "value", ">", "$", "maxLifeTimes", "->", "hoops", ")", "$", "maxLifeTimes", "->", "hoops", "=", "$", "value", ";", "}", "if", "(", "isset", "(", "$", "sessionMetaStore", "->", "expirations", "[", "$", "sessionKey", "]", ")", ")", "{", "$", "value", "=", "$", "sessionMetaStore", "->", "expirations", "[", "$", "sessionKey", "]", "-", "$", "this", "->", "now", ";", "$", "item", "->", "expirations", "[", "]", "=", "(", "object", ")", "[", "'type'", "=>", "self", "::", "_EXPIRATION_TIME", ",", "'value'", "=>", "$", "value", ",", "'text'", "=>", "$", "this", "->", "_formateMaxLifeTimestamp", "(", "$", "value", ")", ",", "]", ";", "if", "(", "$", "value", ">", "$", "maxLifeTimes", "->", "seconds", ")", "$", "maxLifeTimes", "->", "seconds", "=", "$", "value", ";", "}", "$", "namespaceRecords", "[", "$", "sessionKey", "]", "=", "$", "item", ";", "}", "else", "{", "$", "item", "->", "type", "=", "self", "::", "_TYPE_PHP", ";", "$", "standardRecords", "[", "$", "sessionKey", "]", "=", "$", "item", ";", "}", "}", "ksort", "(", "$", "standardRecords", ")", ";", "ksort", "(", "$", "namespaceRecords", ")", ";", "$", "this", "->", "session", "=", "array_merge", "(", "$", "namespaceRecords", ",", "$", "standardRecords", ")", ";", "$", "maxLifeTimesItems", "=", "[", "]", ";", "if", "(", "$", "maxLifeTimes", "->", "seconds", ">", "0", ")", "$", "maxLifeTimesItems", "[", "]", "=", "$", "this", "->", "_formateMaxLifeTimestamp", "(", "$", "maxLifeTimes", "->", "seconds", ")", ";", "if", "(", "$", "maxLifeTimes", "->", "hoops", ">", "0", ")", "$", "maxLifeTimesItems", "[", "]", "=", "$", "maxLifeTimes", "->", "hoops", ".", "' hoops'", ";", "$", "this", "->", "sessionMaxLifeTime", "=", "implode", "(", "', '", ",", "$", "maxLifeTimesItems", ")", ";", "}" ]
Read and parse session data except MvcCore metadata session record. @return void
[ "Read", "and", "parse", "session", "data", "except", "MvcCore", "metadata", "session", "record", "." ]
fddbf5bec01d5f0e31f14e94beac7f5480e8630f
https://github.com/mvccore/ext-debug-tracy-session/blob/fddbf5bec01d5f0e31f14e94beac7f5480e8630f/src/MvcCore/Ext/Debugs/Tracys/SessionPanel.php#L103-L172
225,279
mvccore/ext-debug-tracy-session
src/MvcCore/Ext/Debugs/Tracys/SessionPanel.php
SessionPanel._formateMaxLifeTimestamp
private function _formateMaxLifeTimestamp ($timestamp = 0) { $result = []; if ($timestamp >= 31557600) { $localVal = floor($timestamp / 31557600); $result[] = $localVal . ' year' . (($localVal > 1) ? 's' : ''); if ($localVal > 1) return 'more than ' . $result[0]; $timestamp = $timestamp - (floor($timestamp / 31557600) * 31557600); } if ($timestamp >= 2592000) { $localVal = floor($timestamp / 2592000); $result[] = $localVal . ' month' . (($localVal > 1) ? 's' : ''); if (count($result) == 1 && $localVal > 1) return 'more than ' . $result[0]; $timestamp = $timestamp - (floor($timestamp / 2592000) * 2592000); } if ($timestamp >= 86400) { $localVal = floor($timestamp / 86400); $result[] = $localVal . ' day' . (($localVal > 1) ? 's' : ''); if (count($result) == 1 && $localVal > 1) return 'more than ' . $result[0]; $timestamp = $timestamp - (floor($timestamp / 86400) * 86400); } if ($timestamp >= 3600) { $localVal = floor($timestamp / 3600); $result[] = $localVal . ' hour' . (($localVal > 1) ? 's' : ''); $timestamp = $timestamp - (floor($timestamp / 3600) * 3600); } if ($timestamp >= 60) { $localVal = floor($timestamp / 60); $result[] = $localVal . ' minute' . (($localVal > 1) ? 's' : ''); $timestamp = $timestamp - (floor($timestamp / 60) * 60); } if ($timestamp > 0) { $localVal = floor($timestamp); if ($localVal > 1) $result[] = $localVal . ' seconds'; } return implode(', ', $result); }
php
private function _formateMaxLifeTimestamp ($timestamp = 0) { $result = []; if ($timestamp >= 31557600) { $localVal = floor($timestamp / 31557600); $result[] = $localVal . ' year' . (($localVal > 1) ? 's' : ''); if ($localVal > 1) return 'more than ' . $result[0]; $timestamp = $timestamp - (floor($timestamp / 31557600) * 31557600); } if ($timestamp >= 2592000) { $localVal = floor($timestamp / 2592000); $result[] = $localVal . ' month' . (($localVal > 1) ? 's' : ''); if (count($result) == 1 && $localVal > 1) return 'more than ' . $result[0]; $timestamp = $timestamp - (floor($timestamp / 2592000) * 2592000); } if ($timestamp >= 86400) { $localVal = floor($timestamp / 86400); $result[] = $localVal . ' day' . (($localVal > 1) ? 's' : ''); if (count($result) == 1 && $localVal > 1) return 'more than ' . $result[0]; $timestamp = $timestamp - (floor($timestamp / 86400) * 86400); } if ($timestamp >= 3600) { $localVal = floor($timestamp / 3600); $result[] = $localVal . ' hour' . (($localVal > 1) ? 's' : ''); $timestamp = $timestamp - (floor($timestamp / 3600) * 3600); } if ($timestamp >= 60) { $localVal = floor($timestamp / 60); $result[] = $localVal . ' minute' . (($localVal > 1) ? 's' : ''); $timestamp = $timestamp - (floor($timestamp / 60) * 60); } if ($timestamp > 0) { $localVal = floor($timestamp); if ($localVal > 1) $result[] = $localVal . ' seconds'; } return implode(', ', $result); }
[ "private", "function", "_formateMaxLifeTimestamp", "(", "$", "timestamp", "=", "0", ")", "{", "$", "result", "=", "[", "]", ";", "if", "(", "$", "timestamp", ">=", "31557600", ")", "{", "$", "localVal", "=", "floor", "(", "$", "timestamp", "/", "31557600", ")", ";", "$", "result", "[", "]", "=", "$", "localVal", ".", "' year'", ".", "(", "(", "$", "localVal", ">", "1", ")", "?", "'s'", ":", "''", ")", ";", "if", "(", "$", "localVal", ">", "1", ")", "return", "'more than '", ".", "$", "result", "[", "0", "]", ";", "$", "timestamp", "=", "$", "timestamp", "-", "(", "floor", "(", "$", "timestamp", "/", "31557600", ")", "*", "31557600", ")", ";", "}", "if", "(", "$", "timestamp", ">=", "2592000", ")", "{", "$", "localVal", "=", "floor", "(", "$", "timestamp", "/", "2592000", ")", ";", "$", "result", "[", "]", "=", "$", "localVal", ".", "' month'", ".", "(", "(", "$", "localVal", ">", "1", ")", "?", "'s'", ":", "''", ")", ";", "if", "(", "count", "(", "$", "result", ")", "==", "1", "&&", "$", "localVal", ">", "1", ")", "return", "'more than '", ".", "$", "result", "[", "0", "]", ";", "$", "timestamp", "=", "$", "timestamp", "-", "(", "floor", "(", "$", "timestamp", "/", "2592000", ")", "*", "2592000", ")", ";", "}", "if", "(", "$", "timestamp", ">=", "86400", ")", "{", "$", "localVal", "=", "floor", "(", "$", "timestamp", "/", "86400", ")", ";", "$", "result", "[", "]", "=", "$", "localVal", ".", "' day'", ".", "(", "(", "$", "localVal", ">", "1", ")", "?", "'s'", ":", "''", ")", ";", "if", "(", "count", "(", "$", "result", ")", "==", "1", "&&", "$", "localVal", ">", "1", ")", "return", "'more than '", ".", "$", "result", "[", "0", "]", ";", "$", "timestamp", "=", "$", "timestamp", "-", "(", "floor", "(", "$", "timestamp", "/", "86400", ")", "*", "86400", ")", ";", "}", "if", "(", "$", "timestamp", ">=", "3600", ")", "{", "$", "localVal", "=", "floor", "(", "$", "timestamp", "/", "3600", ")", ";", "$", "result", "[", "]", "=", "$", "localVal", ".", "' hour'", ".", "(", "(", "$", "localVal", ">", "1", ")", "?", "'s'", ":", "''", ")", ";", "$", "timestamp", "=", "$", "timestamp", "-", "(", "floor", "(", "$", "timestamp", "/", "3600", ")", "*", "3600", ")", ";", "}", "if", "(", "$", "timestamp", ">=", "60", ")", "{", "$", "localVal", "=", "floor", "(", "$", "timestamp", "/", "60", ")", ";", "$", "result", "[", "]", "=", "$", "localVal", ".", "' minute'", ".", "(", "(", "$", "localVal", ">", "1", ")", "?", "'s'", ":", "''", ")", ";", "$", "timestamp", "=", "$", "timestamp", "-", "(", "floor", "(", "$", "timestamp", "/", "60", ")", "*", "60", ")", ";", "}", "if", "(", "$", "timestamp", ">", "0", ")", "{", "$", "localVal", "=", "floor", "(", "$", "timestamp", ")", ";", "if", "(", "$", "localVal", ">", "1", ")", "$", "result", "[", "]", "=", "$", "localVal", ".", "' seconds'", ";", "}", "return", "implode", "(", "', '", ",", "$", "result", ")", ";", "}" ]
Return expiration time in human readable format from seconds count. @param int $timestamp @return string
[ "Return", "expiration", "time", "in", "human", "readable", "format", "from", "seconds", "count", "." ]
fddbf5bec01d5f0e31f14e94beac7f5480e8630f
https://github.com/mvccore/ext-debug-tracy-session/blob/fddbf5bec01d5f0e31f14e94beac7f5480e8630f/src/MvcCore/Ext/Debugs/Tracys/SessionPanel.php#L179-L214
225,280
sopinetchat/SopinetChatBundle
Service/FileHelper.php
FileHelper.uploadFileByFile
public function uploadFileByFile(UploadedFile $file_request, $fieldName, $classFileString) { $file_content = file_get_contents($file_request->getPathname()); $file_extension = $file_request->getClientOriginalExtension(); $file_app_object = $this->writeFileBytes($file_content, $file_extension, $fieldName, $classFileString); $this->em->persist($file_app_object); $this->em->flush(); return $file_app_object; }
php
public function uploadFileByFile(UploadedFile $file_request, $fieldName, $classFileString) { $file_content = file_get_contents($file_request->getPathname()); $file_extension = $file_request->getClientOriginalExtension(); $file_app_object = $this->writeFileBytes($file_content, $file_extension, $fieldName, $classFileString); $this->em->persist($file_app_object); $this->em->flush(); return $file_app_object; }
[ "public", "function", "uploadFileByFile", "(", "UploadedFile", "$", "file_request", ",", "$", "fieldName", ",", "$", "classFileString", ")", "{", "$", "file_content", "=", "file_get_contents", "(", "$", "file_request", "->", "getPathname", "(", ")", ")", ";", "$", "file_extension", "=", "$", "file_request", "->", "getClientOriginalExtension", "(", ")", ";", "$", "file_app_object", "=", "$", "this", "->", "writeFileBytes", "(", "$", "file_content", ",", "$", "file_extension", ",", "$", "fieldName", ",", "$", "classFileString", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "file_app_object", ")", ";", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "return", "$", "file_app_object", ";", "}" ]
Guarda un fichero y devuelve su objeto File @param UploadedFile $file_request @param String $fieldName / Nombre del campo para el fichero en base de datos @return File
[ "Guarda", "un", "fichero", "y", "devuelve", "su", "objeto", "File" ]
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/FileHelper.php#L32-L41
225,281
sopinetchat/SopinetChatBundle
Service/FileHelper.php
FileHelper.createDir
private function createDir($path) { $dir = $path; if (!is_dir($dir)) { $old = umask(0); mkdir($dir,0777,true); umask($old); chmod($dir, 0777); } return $dir; }
php
private function createDir($path) { $dir = $path; if (!is_dir($dir)) { $old = umask(0); mkdir($dir,0777,true); umask($old); chmod($dir, 0777); } return $dir; }
[ "private", "function", "createDir", "(", "$", "path", ")", "{", "$", "dir", "=", "$", "path", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "old", "=", "umask", "(", "0", ")", ";", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ";", "umask", "(", "$", "old", ")", ";", "chmod", "(", "$", "dir", ",", "0777", ")", ";", "}", "return", "$", "dir", ";", "}" ]
Funcion para crear un directorio @param unknown $path - Directorio a crear @return unknown
[ "Funcion", "para", "crear", "un", "directorio" ]
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/FileHelper.php#L48-L57
225,282
sopinetchat/SopinetChatBundle
Service/FileHelper.php
FileHelper.bytes_to_file
private function bytes_to_file($bytes, $output_file) { $ifp = fopen($output_file, "wb"); fwrite($ifp, $bytes); fclose($ifp); }
php
private function bytes_to_file($bytes, $output_file) { $ifp = fopen($output_file, "wb"); fwrite($ifp, $bytes); fclose($ifp); }
[ "private", "function", "bytes_to_file", "(", "$", "bytes", ",", "$", "output_file", ")", "{", "$", "ifp", "=", "fopen", "(", "$", "output_file", ",", "\"wb\"", ")", ";", "fwrite", "(", "$", "ifp", ",", "$", "bytes", ")", ";", "fclose", "(", "$", "ifp", ")", ";", "}" ]
Pasa bytes a Fichero @param $bytes @param $output_file
[ "Pasa", "bytes", "a", "Fichero" ]
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/FileHelper.php#L65-L69
225,283
sopinetchat/SopinetChatBundle
Service/FileHelper.php
FileHelper.writeFileBytes
private function writeFileBytes($data_bytes, $extension, $field, $classFileString) { $dir_rel = "uploads" . DIRECTORY_SEPARATOR . "gallery" . DIRECTORY_SEPARATOR; $dir = $this->createDir($this->getRoot(). DIRECTORY_SEPARATOR ."web" . DIRECTORY_SEPARATOR . $dir_rel); $file = new $classFileString; // Obtenemos un nombre único $name=uniqid("AppFileUniqSystem", true); $name = $field . "_" . md5($name) .'.' . $extension; // Calculamos el nombre de la ruta completo y relativo, metemos los bytes $file_abs_name = $dir . $name; $file_rel_name = $dir_rel. $name; $this->bytes_to_file($data_bytes, $file_abs_name); // Guardamos los datos en File $file->setPath($file_rel_name); // Devolvemos el File return $file; }
php
private function writeFileBytes($data_bytes, $extension, $field, $classFileString) { $dir_rel = "uploads" . DIRECTORY_SEPARATOR . "gallery" . DIRECTORY_SEPARATOR; $dir = $this->createDir($this->getRoot(). DIRECTORY_SEPARATOR ."web" . DIRECTORY_SEPARATOR . $dir_rel); $file = new $classFileString; // Obtenemos un nombre único $name=uniqid("AppFileUniqSystem", true); $name = $field . "_" . md5($name) .'.' . $extension; // Calculamos el nombre de la ruta completo y relativo, metemos los bytes $file_abs_name = $dir . $name; $file_rel_name = $dir_rel. $name; $this->bytes_to_file($data_bytes, $file_abs_name); // Guardamos los datos en File $file->setPath($file_rel_name); // Devolvemos el File return $file; }
[ "private", "function", "writeFileBytes", "(", "$", "data_bytes", ",", "$", "extension", ",", "$", "field", ",", "$", "classFileString", ")", "{", "$", "dir_rel", "=", "\"uploads\"", ".", "DIRECTORY_SEPARATOR", ".", "\"gallery\"", ".", "DIRECTORY_SEPARATOR", ";", "$", "dir", "=", "$", "this", "->", "createDir", "(", "$", "this", "->", "getRoot", "(", ")", ".", "DIRECTORY_SEPARATOR", ".", "\"web\"", ".", "DIRECTORY_SEPARATOR", ".", "$", "dir_rel", ")", ";", "$", "file", "=", "new", "$", "classFileString", ";", "// Obtenemos un nombre único", "$", "name", "=", "uniqid", "(", "\"AppFileUniqSystem\"", ",", "true", ")", ";", "$", "name", "=", "$", "field", ".", "\"_\"", ".", "md5", "(", "$", "name", ")", ".", "'.'", ".", "$", "extension", ";", "// Calculamos el nombre de la ruta completo y relativo, metemos los bytes", "$", "file_abs_name", "=", "$", "dir", ".", "$", "name", ";", "$", "file_rel_name", "=", "$", "dir_rel", ".", "$", "name", ";", "$", "this", "->", "bytes_to_file", "(", "$", "data_bytes", ",", "$", "file_abs_name", ")", ";", "// Guardamos los datos en File", "$", "file", "->", "setPath", "(", "$", "file_rel_name", ")", ";", "// Devolvemos el File", "return", "$", "file", ";", "}" ]
Escribe en un fichero sus Bytes, crea el objeto File @param $data_bytes @param $extension @return File
[ "Escribe", "en", "un", "fichero", "sus", "Bytes", "crea", "el", "objeto", "File" ]
92c306963d8e9c74ecaa06422cea65bcf1bb3ba2
https://github.com/sopinetchat/SopinetChatBundle/blob/92c306963d8e9c74ecaa06422cea65bcf1bb3ba2/Service/FileHelper.php#L78-L97
225,284
czogori/Dami
src/Dami/DependencyInjection/DamiExtension.php
DamiExtension.defineParameters
private function defineParameters(ContainerBuilder $container) { $container->setParameter('dami.api.class', 'Dami\Migration\Api\ApiMigration'); $container->setParameter('dami.template_renderer.class', 'Dami\Migration\TemplateRenderer'); $container->setParameter('dami.template_initialization.class', 'Dami\Migration\TemplateInitialization'); $container->setParameter('dami.migration_name_parser.class', 'Dami\Migration\MigrationNameParser'); }
php
private function defineParameters(ContainerBuilder $container) { $container->setParameter('dami.api.class', 'Dami\Migration\Api\ApiMigration'); $container->setParameter('dami.template_renderer.class', 'Dami\Migration\TemplateRenderer'); $container->setParameter('dami.template_initialization.class', 'Dami\Migration\TemplateInitialization'); $container->setParameter('dami.migration_name_parser.class', 'Dami\Migration\MigrationNameParser'); }
[ "private", "function", "defineParameters", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "container", "->", "setParameter", "(", "'dami.api.class'", ",", "'Dami\\Migration\\Api\\ApiMigration'", ")", ";", "$", "container", "->", "setParameter", "(", "'dami.template_renderer.class'", ",", "'Dami\\Migration\\TemplateRenderer'", ")", ";", "$", "container", "->", "setParameter", "(", "'dami.template_initialization.class'", ",", "'Dami\\Migration\\TemplateInitialization'", ")", ";", "$", "container", "->", "setParameter", "(", "'dami.migration_name_parser.class'", ",", "'Dami\\Migration\\MigrationNameParser'", ")", ";", "}" ]
Define parameters. @param ContainerBuilder $container @return void
[ "Define", "parameters", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/DependencyInjection/DamiExtension.php#L102-L108
225,285
czogori/Dami
src/Dami/DependencyInjection/DamiExtension.php
DamiExtension.defineConnectionConfigParameter
private function defineConnectionConfigParameter(ContainerBuilder $container, $config) { $definition = new Definition('Rentgen\Database\Connection\ConnectionConfig'); $definition->setArguments(array($config['environments'])); $container->setDefinition('connection_config', $definition); }
php
private function defineConnectionConfigParameter(ContainerBuilder $container, $config) { $definition = new Definition('Rentgen\Database\Connection\ConnectionConfig'); $definition->setArguments(array($config['environments'])); $container->setDefinition('connection_config', $definition); }
[ "private", "function", "defineConnectionConfigParameter", "(", "ContainerBuilder", "$", "container", ",", "$", "config", ")", "{", "$", "definition", "=", "new", "Definition", "(", "'Rentgen\\Database\\Connection\\ConnectionConfig'", ")", ";", "$", "definition", "->", "setArguments", "(", "array", "(", "$", "config", "[", "'environments'", "]", ")", ")", ";", "$", "container", "->", "setDefinition", "(", "'connection_config'", ",", "$", "definition", ")", ";", "}" ]
Define connection config parameters. @param ContainerBuilder $container @param array $config @return void
[ "Define", "connection", "config", "parameters", "." ]
19612e643f8bea76706cc667c3f2c12a42d4cd19
https://github.com/czogori/Dami/blob/19612e643f8bea76706cc667c3f2c12a42d4cd19/src/Dami/DependencyInjection/DamiExtension.php#L118-L123
225,286
SetBased/php-abc-form
src/Control/ComplexControl.php
ComplexControl.getErrorMessages
public function getErrorMessages($recursive = false): ?array { $ret = []; if ($recursive) { foreach ($this->controls as $control) { $tmp = $control->getErrorMessages(true); if (is_array($tmp)) { $ret = array_merge($ret, $tmp); } } } if (isset($this->errorMessages)) { $ret = array_merge($ret, $this->errorMessages); } if (empty($ret)) $ret = null; return $ret; }
php
public function getErrorMessages($recursive = false): ?array { $ret = []; if ($recursive) { foreach ($this->controls as $control) { $tmp = $control->getErrorMessages(true); if (is_array($tmp)) { $ret = array_merge($ret, $tmp); } } } if (isset($this->errorMessages)) { $ret = array_merge($ret, $this->errorMessages); } if (empty($ret)) $ret = null; return $ret; }
[ "public", "function", "getErrorMessages", "(", "$", "recursive", "=", "false", ")", ":", "?", "array", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "$", "recursive", ")", "{", "foreach", "(", "$", "this", "->", "controls", "as", "$", "control", ")", "{", "$", "tmp", "=", "$", "control", "->", "getErrorMessages", "(", "true", ")", ";", "if", "(", "is_array", "(", "$", "tmp", ")", ")", "{", "$", "ret", "=", "array_merge", "(", "$", "ret", ",", "$", "tmp", ")", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "errorMessages", ")", ")", "{", "$", "ret", "=", "array_merge", "(", "$", "ret", ",", "$", "this", "->", "errorMessages", ")", ";", "}", "if", "(", "empty", "(", "$", "ret", ")", ")", "$", "ret", "=", "null", ";", "return", "$", "ret", ";", "}" ]
Returns an array of all error messages of the child form controls of this complex form controls. @param bool $recursive If set error messages of complex child controls of this complex form controls are fetched also. @return array|null @since 1.0.0 @api
[ "Returns", "an", "array", "of", "all", "error", "messages", "of", "the", "child", "form", "controls", "of", "this", "complex", "form", "controls", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/ComplexControl.php#L159-L182
225,287
SetBased/php-abc-form
src/Control/ComplexControl.php
ComplexControl.prepare
public function prepare(string $parentSubmitName): void { parent::prepare($parentSubmitName); foreach ($this->controls as $control) { $control->prepare($this->submitName); } }
php
public function prepare(string $parentSubmitName): void { parent::prepare($parentSubmitName); foreach ($this->controls as $control) { $control->prepare($this->submitName); } }
[ "public", "function", "prepare", "(", "string", "$", "parentSubmitName", ")", ":", "void", "{", "parent", "::", "prepare", "(", "$", "parentSubmitName", ")", ";", "foreach", "(", "$", "this", "->", "controls", "as", "$", "control", ")", "{", "$", "control", "->", "prepare", "(", "$", "this", "->", "submitName", ")", ";", "}", "}" ]
Prepares this form complex control for HTML code generation or loading submitted values. @param string $parentSubmitName The submit name of the parent control. @since 1.0.0 @api
[ "Prepares", "this", "form", "complex", "control", "for", "HTML", "code", "generation", "or", "loading", "submitted", "values", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/ComplexControl.php#L362-L370
225,288
SetBased/php-abc-form
src/Control/ComplexControl.php
ComplexControl.setValue
public function setValue($values): void { foreach ($this->controls as $control) { $control->setValuesBase($values); } }
php
public function setValue($values): void { foreach ($this->controls as $control) { $control->setValuesBase($values); } }
[ "public", "function", "setValue", "(", "$", "values", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "controls", "as", "$", "control", ")", "{", "$", "control", "->", "setValuesBase", "(", "$", "values", ")", ";", "}", "}" ]
Sets the values of the form controls of this complex control. The values of form controls for which no explicit value is set are set to null. @param mixed $values The values as a nested array. @since 1.0.0 @api
[ "Sets", "the", "values", "of", "the", "form", "controls", "of", "this", "complex", "control", ".", "The", "values", "of", "form", "controls", "for", "which", "no", "explicit", "value", "is", "set", "are", "set", "to", "null", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/ComplexControl.php#L425-L431
225,289
SetBased/php-abc-form
src/Control/ComplexControl.php
ComplexControl.validateBase
public function validateBase(array &$invalidFormControls): bool { $valid = true; // First, validate all child form controls. foreach ($this->controls as $control) { if (!$control->validateBase($invalidFormControls)) { $this->invalidControls[] = $control; $valid = false; } } if ($valid) { // All the child form controls are valid. Validate this complex form control. foreach ($this->validators as $validator) { $valid = $validator->validate($this); if ($valid!==true) { $invalidFormControls[] = $this; break; } } } return $valid; }
php
public function validateBase(array &$invalidFormControls): bool { $valid = true; // First, validate all child form controls. foreach ($this->controls as $control) { if (!$control->validateBase($invalidFormControls)) { $this->invalidControls[] = $control; $valid = false; } } if ($valid) { // All the child form controls are valid. Validate this complex form control. foreach ($this->validators as $validator) { $valid = $validator->validate($this); if ($valid!==true) { $invalidFormControls[] = $this; break; } } } return $valid; }
[ "public", "function", "validateBase", "(", "array", "&", "$", "invalidFormControls", ")", ":", "bool", "{", "$", "valid", "=", "true", ";", "// First, validate all child form controls.", "foreach", "(", "$", "this", "->", "controls", "as", "$", "control", ")", "{", "if", "(", "!", "$", "control", "->", "validateBase", "(", "$", "invalidFormControls", ")", ")", "{", "$", "this", "->", "invalidControls", "[", "]", "=", "$", "control", ";", "$", "valid", "=", "false", ";", "}", "}", "if", "(", "$", "valid", ")", "{", "// All the child form controls are valid. Validate this complex form control.", "foreach", "(", "$", "this", "->", "validators", "as", "$", "validator", ")", "{", "$", "valid", "=", "$", "validator", "->", "validate", "(", "$", "this", ")", ";", "if", "(", "$", "valid", "!==", "true", ")", "{", "$", "invalidFormControls", "[", "]", "=", "$", "this", ";", "break", ";", "}", "}", "}", "return", "$", "valid", ";", "}" ]
Executes a validators on the child form controls of this form complex control. If and only if all child form controls are valid the validators of this complex control are executed. @param array $invalidFormControls A nested array of invalid form controls. @return bool True if and only if all form controls are valid.
[ "Executes", "a", "validators", "on", "the", "child", "form", "controls", "of", "this", "form", "complex", "control", ".", "If", "and", "only", "if", "all", "child", "form", "controls", "are", "valid", "the", "validators", "of", "this", "complex", "control", "are", "executed", "." ]
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/ComplexControl.php#L459-L488
225,290
railken/amethyst-api
src/Api/Transformers/BaseTransformer.php
BaseTransformer.resolveInclude
public function resolveInclude(string $relationName, array $args) { $entity = $args[0]; $relation = $entity->{$relationName}; if (!$relation) { return null; } if ($relation instanceof Collection) { if ($relation->count() === 0) { return null; } $classRelation = get_class($relation[0]); $method = 'collection'; } else { $classRelation = get_class($relation); $method = 'item'; } $manager = Helper::newManagerByModel($classRelation, $this->manager->getAgent()); if (!$manager) { return null; } return $this->$method( $relation, new BaseTransformer($manager, $this->request), str_replace('_', '-', $this->inflector->tableize($manager->getName())) ); }
php
public function resolveInclude(string $relationName, array $args) { $entity = $args[0]; $relation = $entity->{$relationName}; if (!$relation) { return null; } if ($relation instanceof Collection) { if ($relation->count() === 0) { return null; } $classRelation = get_class($relation[0]); $method = 'collection'; } else { $classRelation = get_class($relation); $method = 'item'; } $manager = Helper::newManagerByModel($classRelation, $this->manager->getAgent()); if (!$manager) { return null; } return $this->$method( $relation, new BaseTransformer($manager, $this->request), str_replace('_', '-', $this->inflector->tableize($manager->getName())) ); }
[ "public", "function", "resolveInclude", "(", "string", "$", "relationName", ",", "array", "$", "args", ")", "{", "$", "entity", "=", "$", "args", "[", "0", "]", ";", "$", "relation", "=", "$", "entity", "->", "{", "$", "relationName", "}", ";", "if", "(", "!", "$", "relation", ")", "{", "return", "null", ";", "}", "if", "(", "$", "relation", "instanceof", "Collection", ")", "{", "if", "(", "$", "relation", "->", "count", "(", ")", "===", "0", ")", "{", "return", "null", ";", "}", "$", "classRelation", "=", "get_class", "(", "$", "relation", "[", "0", "]", ")", ";", "$", "method", "=", "'collection'", ";", "}", "else", "{", "$", "classRelation", "=", "get_class", "(", "$", "relation", ")", ";", "$", "method", "=", "'item'", ";", "}", "$", "manager", "=", "Helper", "::", "newManagerByModel", "(", "$", "classRelation", ",", "$", "this", "->", "manager", "->", "getAgent", "(", ")", ")", ";", "if", "(", "!", "$", "manager", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "$", "method", "(", "$", "relation", ",", "new", "BaseTransformer", "(", "$", "manager", ",", "$", "this", "->", "request", ")", ",", "str_replace", "(", "'_'", ",", "'-'", ",", "$", "this", "->", "inflector", "->", "tableize", "(", "$", "manager", "->", "getName", "(", ")", ")", ")", ")", ";", "}" ]
Resolve an include using the manager. @param string $relationName @param array $args @return \League\Fractal\Resource\Item
[ "Resolve", "an", "include", "using", "the", "manager", "." ]
00b78540b05dac59e6ef9367f1c37623a5754b89
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Transformers/BaseTransformer.php#L111-L144
225,291
railken/amethyst-api
src/Api/Support/Sorter.php
Sorter.add
public function add($name, $direction) { if (!in_array($name, $this->keys, true)) { throw new Exceptions\InvalidSorterFieldException($name); } if (!in_array($direction, ['asc', 'desc'], true)) { throw new Exceptions\InvalidSorterDirectionException($direction); } $field = new SorterField(); $field->setName($name); $field->setDirection($direction); $this->values[] = $field; }
php
public function add($name, $direction) { if (!in_array($name, $this->keys, true)) { throw new Exceptions\InvalidSorterFieldException($name); } if (!in_array($direction, ['asc', 'desc'], true)) { throw new Exceptions\InvalidSorterDirectionException($direction); } $field = new SorterField(); $field->setName($name); $field->setDirection($direction); $this->values[] = $field; }
[ "public", "function", "add", "(", "$", "name", ",", "$", "direction", ")", "{", "if", "(", "!", "in_array", "(", "$", "name", ",", "$", "this", "->", "keys", ",", "true", ")", ")", "{", "throw", "new", "Exceptions", "\\", "InvalidSorterFieldException", "(", "$", "name", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "direction", ",", "[", "'asc'", ",", "'desc'", "]", ",", "true", ")", ")", "{", "throw", "new", "Exceptions", "\\", "InvalidSorterDirectionException", "(", "$", "direction", ")", ";", "}", "$", "field", "=", "new", "SorterField", "(", ")", ";", "$", "field", "->", "setName", "(", "$", "name", ")", ";", "$", "field", "->", "setDirection", "(", "$", "direction", ")", ";", "$", "this", "->", "values", "[", "]", "=", "$", "field", ";", "}" ]
Perform the query and retrieve the information about pagination. @param string $name @param string $direction @return $this
[ "Perform", "the", "query", "and", "retrieve", "the", "information", "about", "pagination", "." ]
00b78540b05dac59e6ef9367f1c37623a5754b89
https://github.com/railken/amethyst-api/blob/00b78540b05dac59e6ef9367f1c37623a5754b89/src/Api/Support/Sorter.php#L43-L56
225,292
stubbles/stubbles-input
src/main/php/filter/JsonFilter.php
JsonFilter.isValidJsonStructure
private function isValidJsonStructure(string $json): bool { if ('{' === $json[0] && $json[strlen($json) - 1] !== '}') { return false; } elseif ('[' === $json[0] && $json[strlen($json) - 1] !== ']') { return false; } elseif ('{' !== $json[0] && '[' !== $json[0]) { return false; } return true; }
php
private function isValidJsonStructure(string $json): bool { if ('{' === $json[0] && $json[strlen($json) - 1] !== '}') { return false; } elseif ('[' === $json[0] && $json[strlen($json) - 1] !== ']') { return false; } elseif ('{' !== $json[0] && '[' !== $json[0]) { return false; } return true; }
[ "private", "function", "isValidJsonStructure", "(", "string", "$", "json", ")", ":", "bool", "{", "if", "(", "'{'", "===", "$", "json", "[", "0", "]", "&&", "$", "json", "[", "strlen", "(", "$", "json", ")", "-", "1", "]", "!==", "'}'", ")", "{", "return", "false", ";", "}", "elseif", "(", "'['", "===", "$", "json", "[", "0", "]", "&&", "$", "json", "[", "strlen", "(", "$", "json", ")", "-", "1", "]", "!==", "']'", ")", "{", "return", "false", ";", "}", "elseif", "(", "'{'", "!==", "$", "json", "[", "0", "]", "&&", "'['", "!==", "$", "json", "[", "0", "]", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
checks if given json is valid a valid structure JSON can only be an object or an array structure (see JSON spec & RFC), but json_decode() lacks this restriction. @param string $json @return bool
[ "checks", "if", "given", "json", "is", "valid", "a", "valid", "structure" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/JsonFilter.php#L85-L96
225,293
DemonTPx/util-bundle
src/Controller/BaseController.php
BaseController.addReferrerToForm
public function addReferrerToForm(FormInterface $form): void { $request = $this->get('request_stack')->getCurrentRequest(); $form->add('http-referrer', HiddenType::class, [ 'mapped' => false, 'data' => $request->headers->get('referer'), ]); }
php
public function addReferrerToForm(FormInterface $form): void { $request = $this->get('request_stack')->getCurrentRequest(); $form->add('http-referrer', HiddenType::class, [ 'mapped' => false, 'data' => $request->headers->get('referer'), ]); }
[ "public", "function", "addReferrerToForm", "(", "FormInterface", "$", "form", ")", ":", "void", "{", "$", "request", "=", "$", "this", "->", "get", "(", "'request_stack'", ")", "->", "getCurrentRequest", "(", ")", ";", "$", "form", "->", "add", "(", "'http-referrer'", ",", "HiddenType", "::", "class", ",", "[", "'mapped'", "=>", "false", ",", "'data'", "=>", "$", "request", "->", "headers", "->", "get", "(", "'referer'", ")", ",", "]", ")", ";", "}" ]
Add the current HTTP referrer header to the form @see redirectToFormReferrer
[ "Add", "the", "current", "HTTP", "referrer", "header", "to", "the", "form" ]
5f58a0e4a383549e996a00d1d63fcb7a337ffaba
https://github.com/DemonTPx/util-bundle/blob/5f58a0e4a383549e996a00d1d63fcb7a337ffaba/src/Controller/BaseController.php#L20-L27
225,294
DemonTPx/util-bundle
src/Controller/BaseController.php
BaseController.redirectToReferrer
public function redirectToReferrer(string $defaultRoute = null): RedirectResponse { $request = $this->get('request_stack')->getCurrentRequest(); return $this->redirectToFirstValidRoute([ $request->headers->get('referer'), $defaultRoute, ]); }
php
public function redirectToReferrer(string $defaultRoute = null): RedirectResponse { $request = $this->get('request_stack')->getCurrentRequest(); return $this->redirectToFirstValidRoute([ $request->headers->get('referer'), $defaultRoute, ]); }
[ "public", "function", "redirectToReferrer", "(", "string", "$", "defaultRoute", "=", "null", ")", ":", "RedirectResponse", "{", "$", "request", "=", "$", "this", "->", "get", "(", "'request_stack'", ")", "->", "getCurrentRequest", "(", ")", ";", "return", "$", "this", "->", "redirectToFirstValidRoute", "(", "[", "$", "request", "->", "headers", "->", "get", "(", "'referer'", ")", ",", "$", "defaultRoute", ",", "]", ")", ";", "}" ]
Redirect to the referrer Falls back to the default route when no referrer is defined
[ "Redirect", "to", "the", "referrer", "Falls", "back", "to", "the", "default", "route", "when", "no", "referrer", "is", "defined" ]
5f58a0e4a383549e996a00d1d63fcb7a337ffaba
https://github.com/DemonTPx/util-bundle/blob/5f58a0e4a383549e996a00d1d63fcb7a337ffaba/src/Controller/BaseController.php#L46-L54
225,295
DemonTPx/util-bundle
src/Controller/BaseController.php
BaseController.redirectToFirstValidRoute
public function redirectToFirstValidRoute(array $routeList): RedirectResponse { foreach ($routeList as $route) { if ($route) { return $this->redirect($route); } } throw new \InvalidArgumentException('No valid route given'); }
php
public function redirectToFirstValidRoute(array $routeList): RedirectResponse { foreach ($routeList as $route) { if ($route) { return $this->redirect($route); } } throw new \InvalidArgumentException('No valid route given'); }
[ "public", "function", "redirectToFirstValidRoute", "(", "array", "$", "routeList", ")", ":", "RedirectResponse", "{", "foreach", "(", "$", "routeList", "as", "$", "route", ")", "{", "if", "(", "$", "route", ")", "{", "return", "$", "this", "->", "redirect", "(", "$", "route", ")", ";", "}", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'No valid route given'", ")", ";", "}" ]
Redirect to the first valid route in the given list @param string[] $routeList
[ "Redirect", "to", "the", "first", "valid", "route", "in", "the", "given", "list" ]
5f58a0e4a383549e996a00d1d63fcb7a337ffaba
https://github.com/DemonTPx/util-bundle/blob/5f58a0e4a383549e996a00d1d63fcb7a337ffaba/src/Controller/BaseController.php#L61-L70
225,296
stubbles/stubbles-input
src/main/php/ValueReader.php
ValueReader.required
public function required(string $errorId = 'FIELD_EMPTY'): valuereader\CommonValueReader { if ($this->value->isNull()) { return new valuereader\MissingValueReader( function($actualErrorId) { $this->paramErrors->append($this->paramName, $actualErrorId); }, $errorId ); } return $this; }
php
public function required(string $errorId = 'FIELD_EMPTY'): valuereader\CommonValueReader { if ($this->value->isNull()) { return new valuereader\MissingValueReader( function($actualErrorId) { $this->paramErrors->append($this->paramName, $actualErrorId); }, $errorId ); } return $this; }
[ "public", "function", "required", "(", "string", "$", "errorId", "=", "'FIELD_EMPTY'", ")", ":", "valuereader", "\\", "CommonValueReader", "{", "if", "(", "$", "this", "->", "value", "->", "isNull", "(", ")", ")", "{", "return", "new", "valuereader", "\\", "MissingValueReader", "(", "function", "(", "$", "actualErrorId", ")", "{", "$", "this", "->", "paramErrors", "->", "append", "(", "$", "this", "->", "paramName", ",", "$", "actualErrorId", ")", ";", "}", ",", "$", "errorId", ")", ";", "}", "return", "$", "this", ";", "}" ]
enforce the value to be required @api @param string $errorId optional error id to use when value not set @return \stubbles\input\valuereader\CommonValueReader
[ "enforce", "the", "value", "to", "be", "required" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L97-L110
225,297
stubbles/stubbles-input
src/main/php/ValueReader.php
ValueReader.asBool
public function asBool() { if ($this->value->isNull()) { return null; } return $this->value->isOneOf([1, '1', 'true', true, 'yes'], true); }
php
public function asBool() { if ($this->value->isNull()) { return null; } return $this->value->isOneOf([1, '1', 'true', true, 'yes'], true); }
[ "public", "function", "asBool", "(", ")", "{", "if", "(", "$", "this", "->", "value", "->", "isNull", "(", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "value", "->", "isOneOf", "(", "[", "1", ",", "'1'", ",", "'true'", ",", "true", ",", "'yes'", "]", ",", "true", ")", ";", "}" ]
read as boolean value @api @return bool @since 1.7.0
[ "read", "as", "boolean", "value" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L164-L171
225,298
stubbles/stubbles-input
src/main/php/ValueReader.php
ValueReader.asInt
public function asInt(NumberRange $range = null) { return $this->handleFilter( function() use($range) { return filter\RangeFilter::wrap( filter\IntegerFilter::instance(), $range ); } ); }
php
public function asInt(NumberRange $range = null) { return $this->handleFilter( function() use($range) { return filter\RangeFilter::wrap( filter\IntegerFilter::instance(), $range ); } ); }
[ "public", "function", "asInt", "(", "NumberRange", "$", "range", "=", "null", ")", "{", "return", "$", "this", "->", "handleFilter", "(", "function", "(", ")", "use", "(", "$", "range", ")", "{", "return", "filter", "\\", "RangeFilter", "::", "wrap", "(", "filter", "\\", "IntegerFilter", "::", "instance", "(", ")", ",", "$", "range", ")", ";", "}", ")", ";", "}" ]
read as integer value @api @param \stubbles\input\filter\range\NumberRange $range optional range of allowed values @return int
[ "read", "as", "integer", "value" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L180-L191
225,299
stubbles/stubbles-input
src/main/php/ValueReader.php
ValueReader.asSecret
public function asSecret(StringLength $length = null) { return $this->handleFilter( function() use($length) { return filter\RangeFilter::wrap( filter\SecretFilter::instance(), $length ); } ); }
php
public function asSecret(StringLength $length = null) { return $this->handleFilter( function() use($length) { return filter\RangeFilter::wrap( filter\SecretFilter::instance(), $length ); } ); }
[ "public", "function", "asSecret", "(", "StringLength", "$", "length", "=", "null", ")", "{", "return", "$", "this", "->", "handleFilter", "(", "function", "(", ")", "use", "(", "$", "length", ")", "{", "return", "filter", "\\", "RangeFilter", "::", "wrap", "(", "filter", "\\", "SecretFilter", "::", "instance", "(", ")", ",", "$", "length", ")", ";", "}", ")", ";", "}" ]
read as secret @api @param \stubbles\input\filter\range\StringLength $length optional allowed length of string @return \stubbles\values\Secret @since 6.0.0
[ "read", "as", "secret" ]
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L243-L254