repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
PHPPowertools/HTML5
src/PowerTools/HTML5/Elements.php
HTML5_Elements.isA
public static function isA($name, $mask) { if (!static::isElement($name)) { return false; } return (static::element($name) & $mask) == $mask; }
php
public static function isA($name, $mask) { if (!static::isElement($name)) { return false; } return (static::element($name) & $mask) == $mask; }
[ "public", "static", "function", "isA", "(", "$", "name", ",", "$", "mask", ")", "{", "if", "(", "!", "static", "::", "isElement", "(", "$", "name", ")", ")", "{", "return", "false", ";", "}", "return", "(", "static", "::", "element", "(", "$", "n...
Check whether the given element meets the given criterion. Example: Elements::isA('script', Elements::TEXT_RAW); // Returns true. Elements::isA('script', Elements::TEXT_RCDATA); // Returns false. @param string $name The element name. @param int $mask One of the constants on this class. @return boolean true if the e...
[ "Check", "whether", "the", "given", "element", "meets", "the", "given", "criterion", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Elements.php#L560-L566
PHPPowertools/HTML5
src/PowerTools/HTML5/Elements.php
HTML5_Elements.element
public static function element($name) { if (isset(static::$html5[$name])) { return static::$html5[$name]; } if (isset(static::$svg[$name])) { return static::$svg[$name]; } if (isset(static::$mathml[$name])) { return static::$mathml[$name]; ...
php
public static function element($name) { if (isset(static::$html5[$name])) { return static::$html5[$name]; } if (isset(static::$svg[$name])) { return static::$svg[$name]; } if (isset(static::$mathml[$name])) { return static::$mathml[$name]; ...
[ "public", "static", "function", "element", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "html5", "[", "$", "name", "]", ")", ")", "{", "return", "static", "::", "$", "html5", "[", "$", "name", "]", ";", "}", "if", "...
Get the element mask for the given element name. @param string $name The name of the element. @return int The element mask.
[ "Get", "the", "element", "mask", "for", "the", "given", "element", "name", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Elements.php#L631-L643
PHPPowertools/HTML5
src/PowerTools/HTML5/Elements.php
HTML5_Elements.normalizeSvgElement
public static function normalizeSvgElement($name) { $name = strtolower($name); if (isset(static::$svgCaseSensitiveElementMap[$name])) { $name = static::$svgCaseSensitiveElementMap[$name]; } return $name; }
php
public static function normalizeSvgElement($name) { $name = strtolower($name); if (isset(static::$svgCaseSensitiveElementMap[$name])) { $name = static::$svgCaseSensitiveElementMap[$name]; } return $name; }
[ "public", "static", "function", "normalizeSvgElement", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "svgCaseSensitiveElementMap", "[", "$", "name", "]", ")", ")", ...
Normalize a SVG element name to its proper case and form. @param string $name The name of the element. @return string The normalized form of the element name.
[ "Normalize", "a", "SVG", "element", "name", "to", "its", "proper", "case", "and", "form", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Elements.php#L653-L660
PHPPowertools/HTML5
src/PowerTools/HTML5/Elements.php
HTML5_Elements.normalizeSvgAttribute
public static function normalizeSvgAttribute($name) { $name = strtolower($name); if (isset(static::$svgCaseSensitiveAttributeMap[$name])) { $name = static::$svgCaseSensitiveAttributeMap[$name]; } return $name; }
php
public static function normalizeSvgAttribute($name) { $name = strtolower($name); if (isset(static::$svgCaseSensitiveAttributeMap[$name])) { $name = static::$svgCaseSensitiveAttributeMap[$name]; } return $name; }
[ "public", "static", "function", "normalizeSvgAttribute", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "svgCaseSensitiveAttributeMap", "[", "$", "name", "]", ")", ")"...
Normalize a SVG attribute name to its proper case and form. @param string $name The name of the attribute. @return string The normalized form of the attribute name.
[ "Normalize", "a", "SVG", "attribute", "name", "to", "its", "proper", "case", "and", "form", "." ]
train
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Elements.php#L670-L677
spiral-modules/listing
source/Listing/Filters/SearchFilter.php
SearchFilter.whereClause
protected function whereClause($selector) { $whereClause = []; foreach ($this->mapping as $expression => $type) { switch ($type) { case self::LIKE_STRING: $whereClause[] = $this->likeString($expression, $selector); break; ...
php
protected function whereClause($selector) { $whereClause = []; foreach ($this->mapping as $expression => $type) { switch ($type) { case self::LIKE_STRING: $whereClause[] = $this->likeString($expression, $selector); break; ...
[ "protected", "function", "whereClause", "(", "$", "selector", ")", "{", "$", "whereClause", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "mapping", "as", "$", "expression", "=>", "$", "type", ")", "{", "switch", "(", "$", "type", ")", "{", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Filters/SearchFilter.php#L84-L112
spiral-modules/listing
source/Listing/Filters/SearchFilter.php
SearchFilter.summarize
private function summarize(array $whereClause, $selector) { switch (count($whereClause)) { case 1: return $whereClause[0]; default: if ($selector instanceof RecordSelector) { return ['@OR' => $whereClause]; } ...
php
private function summarize(array $whereClause, $selector) { switch (count($whereClause)) { case 1: return $whereClause[0]; default: if ($selector instanceof RecordSelector) { return ['@OR' => $whereClause]; } ...
[ "private", "function", "summarize", "(", "array", "$", "whereClause", ",", "$", "selector", ")", "{", "switch", "(", "count", "(", "$", "whereClause", ")", ")", "{", "case", "1", ":", "return", "$", "whereClause", "[", "0", "]", ";", "default", ":", ...
Summarize expression array. @param array $whereClause @param RecordSelector|DocumentSelector $selector @return array
[ "Summarize", "expression", "array", "." ]
train
https://github.com/spiral-modules/listing/blob/89abe8939ce91cbf61b51b99e93ce1e57c8af83c/source/Listing/Filters/SearchFilter.php#L171-L188
hametuha/wpametu
src/WPametu/UI/Field/Radio.php
Radio.get_option
protected function get_option($key, $label, $counter, $data, array $fields = []){ return sprintf('<label%6$s><input type="radio" name="%1$s" id="%1$s-%2$d" value="%3$s" %4$s /> %5$s </label>', $this->get_name(), $counter, esc_attr($key), checked( (!$data && $key == $this->default) || $ke...
php
protected function get_option($key, $label, $counter, $data, array $fields = []){ return sprintf('<label%6$s><input type="radio" name="%1$s" id="%1$s-%2$d" value="%3$s" %4$s /> %5$s </label>', $this->get_name(), $counter, esc_attr($key), checked( (!$data && $key == $this->default) || $ke...
[ "protected", "function", "get_option", "(", "$", "key", ",", "$", "label", ",", "$", "counter", ",", "$", "data", ",", "array", "$", "fields", "=", "[", "]", ")", "{", "return", "sprintf", "(", "'<label%6$s><input type=\"radio\" name=\"%1$s\" id=\"%1$s-%2$d\" va...
Get fields input @param string $key @param string $label @param int $counter @param string $data @param array $fields @return string
[ "Get", "fields", "input" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/Radio.php#L49-L54
nabab/bbn
src/bbn/x.php
x.log
public static function log($st, $file='misc'){ if ( \defined('BBN_DATA_PATH') ){ if ( !\is_string($file) ){ $file = 'misc'; } $log_file = BBN_DATA_PATH.'logs/'.$file.'.log'; $backtrace = array_filter(debug_backtrace(), function($a){ return $a['function'] === 'log'; }); ...
php
public static function log($st, $file='misc'){ if ( \defined('BBN_DATA_PATH') ){ if ( !\is_string($file) ){ $file = 'misc'; } $log_file = BBN_DATA_PATH.'logs/'.$file.'.log'; $backtrace = array_filter(debug_backtrace(), function($a){ return $a['function'] === 'log'; }); ...
[ "public", "static", "function", "log", "(", "$", "st", ",", "$", "file", "=", "'misc'", ")", "{", "if", "(", "\\", "defined", "(", "'BBN_DATA_PATH'", ")", ")", "{", "if", "(", "!", "\\", "is_string", "(", "$", "file", ")", ")", "{", "$", "file", ...
Saves logs to a file. ```php \bbn\x::log('My text', 'FileName'); ``` @param mixed $st Item to log. @param string $file Filename, default: "misc". @return void
[ "Saves", "logs", "to", "a", "file", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L75-L103
nabab/bbn
src/bbn/x.php
x.log_error
public static function log_error($errno, $errstr, $errfile, $errline){ if ( \defined('BBN_DATA_PATH') ){ if ( is_dir(BBN_DATA_PATH.'logs') ){ $file = BBN_DATA_PATH.'logs/_php_error.json'; $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20); $r = false; if ( is_file($f...
php
public static function log_error($errno, $errstr, $errfile, $errline){ if ( \defined('BBN_DATA_PATH') ){ if ( is_dir(BBN_DATA_PATH.'logs') ){ $file = BBN_DATA_PATH.'logs/_php_error.json'; $backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 20); $r = false; if ( is_file($f...
[ "public", "static", "function", "log_error", "(", "$", "errno", ",", "$", "errstr", ",", "$", "errfile", ",", "$", "errline", ")", "{", "if", "(", "\\", "defined", "(", "'BBN_DATA_PATH'", ")", ")", "{", "if", "(", "is_dir", "(", "BBN_DATA_PATH", ".", ...
Puts the PHP errors into a JSON file. @param string $errno The text to save. @param string $errstr The file's name, default: "misc". @param $errfile @param $errline @return bool
[ "Puts", "the", "PHP", "errors", "into", "a", "JSON", "file", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L114-L164
nabab/bbn
src/bbn/x.php
x.merge_objects
public static function merge_objects($o1, $o2){ $args = \func_get_args(); /* @todo check if it's working with more than 2 object arguments */ if ( \count($args) > 2 ){ for ( $i = \count($args) - 1; $i > 1; $i-- ){ $args[$i-1] = self::merge_arrays($args[$i-1], $args[$i]); } $o2 = $a...
php
public static function merge_objects($o1, $o2){ $args = \func_get_args(); /* @todo check if it's working with more than 2 object arguments */ if ( \count($args) > 2 ){ for ( $i = \count($args) - 1; $i > 1; $i-- ){ $args[$i-1] = self::merge_arrays($args[$i-1], $args[$i]); } $o2 = $a...
[ "public", "static", "function", "merge_objects", "(", "$", "o1", ",", "$", "o2", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "/* @todo check if it's working with more than 2 object arguments */", "if", "(", "\\", "count", "(", "$", "args", ...
Returns to a merged object from two objects. ```php class A { public $a = 10; public $b = 20; }; class B { public $c = 30; public $d = 40; }; $obj1 = new A; $obj2 = new B; \bbn\x::merge_objects($obj1, $obj2); // object {'a': 10, 'b': 20, 'c': 30, 'd': 40} ``` @param object $o1 The first object to merge. @param obj...
[ "Returns", "to", "a", "merged", "object", "from", "two", "objects", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L191-L204
nabab/bbn
src/bbn/x.php
x.merge_arrays
public static function merge_arrays(array $a1, array $a2){ $args = \func_get_args(); if ( \count($args) > 2 ){ for ( $i = \count($args) - 1; $i > 1; $i-- ){ $args[$i-1] = self::merge_arrays($args[$i-1], $args[$i]); } $a2 = $args[1]; } if ( (self::is_assoc($a1) || empty($a1)) &&...
php
public static function merge_arrays(array $a1, array $a2){ $args = \func_get_args(); if ( \count($args) > 2 ){ for ( $i = \count($args) - 1; $i > 1; $i-- ){ $args[$i-1] = self::merge_arrays($args[$i-1], $args[$i]); } $a2 = $args[1]; } if ( (self::is_assoc($a1) || empty($a1)) &&...
[ "public", "static", "function", "merge_arrays", "(", "array", "$", "a1", ",", "array", "$", "a2", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "\\", "count", "(", "$", "args", ")", ">", "2", ")", "{", "for", "(", ...
Returns to a merged array from two or more arrays. ```php \bbn\x::merge_arrays([1, 'Test'], [2, 'Example']); // array [1, 'Test', 2, 'Example'] ``` @param array $a1 The first array to merge. @param array $a2 The second array to merge. @return array The merged array.
[ "Returns", "to", "a", "merged", "array", "from", "two", "or", "more", "arrays", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L217-L247
nabab/bbn
src/bbn/x.php
x.remove_empty
public static function remove_empty($arr, $remove_space = false){ foreach ( $arr as $k => $v ){ if ( \is_object($arr) ){ if ( \is_array($v) || \is_object($v) ){ $arr->$k = self::remove_empty($v); } if ( empty($arr->$k) ){ unset($arr->$k); } } els...
php
public static function remove_empty($arr, $remove_space = false){ foreach ( $arr as $k => $v ){ if ( \is_object($arr) ){ if ( \is_array($v) || \is_object($v) ){ $arr->$k = self::remove_empty($v); } if ( empty($arr->$k) ){ unset($arr->$k); } } els...
[ "public", "static", "function", "remove_empty", "(", "$", "arr", ",", "$", "remove_space", "=", "false", ")", "{", "foreach", "(", "$", "arr", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "\\", "is_object", "(", "$", "arr", ")", ")", "{",...
Returns an object or an array cleaned of all empty values. @todo Add a preserve_keys option? ```php \bbn\x::remove_empty(['Allison', 'Mike', '', 'John', ' ']); // array [0 => 'Allison', 1 => 'Mike', 3 => 'John', 4 => ' '] \bbn\x::remove_empty(['Allison', 'Mike', '', 'John', ' '], 1)); // array [0 => 'Allison', 1 => '...
[ "Returns", "an", "object", "or", "an", "array", "cleaned", "of", "all", "empty", "values", ".", "@todo", "Add", "a", "preserve_keys", "option?" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L416-L439
nabab/bbn
src/bbn/x.php
x.to_groups
public static function to_groups(array $arr, $keyname = 'value', $valname = 'text'){ $r = []; foreach ( $arr as $k => $v ){ $r[] = [$keyname => $k, $valname => $v]; } return $r; }
php
public static function to_groups(array $arr, $keyname = 'value', $valname = 'text'){ $r = []; foreach ( $arr as $k => $v ){ $r[] = [$keyname => $k, $valname => $v]; } return $r; }
[ "public", "static", "function", "to_groups", "(", "array", "$", "arr", ",", "$", "keyname", "=", "'value'", ",", "$", "valname", "=", "'text'", ")", "{", "$", "r", "=", "[", "]", ";", "foreach", "(", "$", "arr", "as", "$", "k", "=>", "$", "v", ...
Converts an indexed array into a numeric array where the original index is a property. @todo the name is not fitted ```php \bbn\x::to_groups([25 => 'Allison', 33 => 'Mike', 19 => 'John']); // array [['value' => 25, 'text' => 'Allison'], ['value' => 33, 'text' => 'Francis'], ['value' => 19, 'text' => 'John']] \bbn\x::...
[ "Converts", "an", "indexed", "array", "into", "a", "numeric", "array", "where", "the", "original", "index", "is", "a", "property", ".", "@todo", "the", "name", "is", "not", "fitted" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L458-L464
nabab/bbn
src/bbn/x.php
x.is_assoc
public static function is_assoc(array $r){ $keys = array_keys($r); $c = \count($keys); for ( $i = 0; $i < $c; $i++ ){ if ( $keys[$i] !== $i ){ return 1; } } return false; }
php
public static function is_assoc(array $r){ $keys = array_keys($r); $c = \count($keys); for ( $i = 0; $i < $c; $i++ ){ if ( $keys[$i] !== $i ){ return 1; } } return false; }
[ "public", "static", "function", "is_assoc", "(", "array", "$", "r", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "r", ")", ";", "$", "c", "=", "\\", "count", "(", "$", "keys", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", ...
Checks if the given array is associative. ```php \bbn\\x::is_assoc(['id' => 0, 'name' => 'Allison']); \bbn\\x::is_assoc(['Allison', 'John', 'Bert']); \bbn\\x::is_assoc([0 => "Allison", 1 => "John", 2 => "Bert"]); \bbn\\x::is_assoc([0 => "Allison", 1 => "John", 3 => "Bert"]); // boolean true // boolean false // boo...
[ "Checks", "if", "the", "given", "array", "is", "associative", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L487-L496
nabab/bbn
src/bbn/x.php
x.get_dump
public static function get_dump(){ $args = \func_get_args(); $st = ''; foreach ( $args as $a ){ $r = $a; if ( \is_null($a) ){ $r = 'null'; } else if ( $a === false ){ $r = 'false'; } else if ( $a === true ){ $r = 'true'; } else if ( $a ...
php
public static function get_dump(){ $args = \func_get_args(); $st = ''; foreach ( $args as $a ){ $r = $a; if ( \is_null($a) ){ $r = 'null'; } else if ( $a === false ){ $r = 'false'; } else if ( $a === true ){ $r = 'true'; } else if ( $a ...
[ "public", "static", "function", "get_dump", "(", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "$", "st", "=", "''", ";", "foreach", "(", "$", "args", "as", "$", "a", ")", "{", "$", "r", "=", "$", "a", ";", "if", "(", "\\"...
Returns a dump of the given variable. @param mixed @return string
[ "Returns", "a", "dump", "of", "the", "given", "variable", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L504-L554
nabab/bbn
src/bbn/x.php
x.build_options
public static function build_options($values, $selected='', $empty_label=false){ if ( \is_array($values) ) { $r = ''; if ( $empty_label !== false ){ $r .= '<option value="">'.$empty_label.'</option>'; } $is_assoc = self::is_assoc($values); foreach ( $values as $k => $v ) ...
php
public static function build_options($values, $selected='', $empty_label=false){ if ( \is_array($values) ) { $r = ''; if ( $empty_label !== false ){ $r .= '<option value="">'.$empty_label.'</option>'; } $is_assoc = self::is_assoc($values); foreach ( $values as $k => $v ) ...
[ "public", "static", "function", "build_options", "(", "$", "values", ",", "$", "selected", "=", "''", ",", "$", "empty_label", "=", "false", ")", "{", "if", "(", "\\", "is_array", "(", "$", "values", ")", ")", "{", "$", "r", "=", "''", ";", "if", ...
Returns the HTML code for creating the &lt;option&gt; tag(s) based on an array. If the array is indexed, the index will be used as value ```php \bbn\x::build_options(['yes', 'no']); // string "<option value="yes">yes</option>;<option value="no">no</option>" \bbn\x::build_options(['yes', 'no'], 'no'); // string "<optio...
[ "Returns", "the", "HTML", "code", "for", "creating", "the", "&lt", ";", "option&gt", ";", "tag", "(", "s", ")", "based", "on", "an", "array", ".", "If", "the", "array", "is", "indexed", "the", "index", "will", "be", "used", "as", "value" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L608-L639
nabab/bbn
src/bbn/x.php
x.to_keypair
public static function to_keypair($arr, $protected = 1){ $num = \count($arr); $res = []; if ( ($num % 2) === 0 ){ $i = 0; while ( isset($arr[$i]) ){ if ( !\is_string($arr[$i]) || ( !$protected && !preg_match('/[0-9A-z\-_]+/8', str::cast($arr[$i])) ) ){ return false; } ...
php
public static function to_keypair($arr, $protected = 1){ $num = \count($arr); $res = []; if ( ($num % 2) === 0 ){ $i = 0; while ( isset($arr[$i]) ){ if ( !\is_string($arr[$i]) || ( !$protected && !preg_match('/[0-9A-z\-_]+/8', str::cast($arr[$i])) ) ){ return false; } ...
[ "public", "static", "function", "to_keypair", "(", "$", "arr", ",", "$", "protected", "=", "1", ")", "{", "$", "num", "=", "\\", "count", "(", "$", "arr", ")", ";", "$", "res", "=", "[", "]", ";", "if", "(", "(", "$", "num", "%", "2", ")", ...
Converts a numeric array into an associative one, alternating key and value. ```php \bbn\x::to_keypair(['Test', 'TestFile', 'Example', 'ExampleFile']); // string ['Test' => 'TestFile', 'Example' => 'ExampleFile'] ``` @param array $arr The array. It must contain an even number of values @param bool $protected If false...
[ "Converts", "a", "numeric", "array", "into", "an", "associative", "one", "alternating", "key", "and", "value", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L653-L667
nabab/bbn
src/bbn/x.php
x.max_with_key
public static function max_with_key($ar, $key){ if (!\is_array($ar) || \count($ar) == 0) return false; $max = current($ar)[$key]; foreach ( $ar as $a ){ if ( is_float($a[$key]) || is_float($max) ){ if ( self::compare_floats($a[$key], $max, '>') ){ $max = $a[$key]; } } ...
php
public static function max_with_key($ar, $key){ if (!\is_array($ar) || \count($ar) == 0) return false; $max = current($ar)[$key]; foreach ( $ar as $a ){ if ( is_float($a[$key]) || is_float($max) ){ if ( self::compare_floats($a[$key], $max, '>') ){ $max = $a[$key]; } } ...
[ "public", "static", "function", "max_with_key", "(", "$", "ar", ",", "$", "key", ")", "{", "if", "(", "!", "\\", "is_array", "(", "$", "ar", ")", "||", "\\", "count", "(", "$", "ar", ")", "==", "0", ")", "return", "false", ";", "$", "max", "=",...
Returns the maximum value of a given property from a 2 dimensions array. @todo Add a custom callable as last parameter ```php \bbn\x::max_with_key([ ['age' => 1, 'name' => 'Michelle'], ['age' => 8, 'name' => 'John'], ['age' => 45, 'name' => 'Sarah'], ['age' => 45, 'name' => 'Camilla'], ['age' => 2, 'name' => 'Allison'...
[ "Returns", "the", "maximum", "value", "of", "a", "given", "property", "from", "a", "2", "dimensions", "array", ".", "@todo", "Add", "a", "custom", "callable", "as", "last", "parameter" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L688-L702
nabab/bbn
src/bbn/x.php
x.min_with_key
public static function min_with_key($array, $key){ if (!\is_array($array) || \count($array) == 0) return false; $min = $array[0][$key]; foreach($array as $a){ if($a[$key] < $min){ $min = $a[$key]; } } return $min; }
php
public static function min_with_key($array, $key){ if (!\is_array($array) || \count($array) == 0) return false; $min = $array[0][$key]; foreach($array as $a){ if($a[$key] < $min){ $min = $a[$key]; } } return $min; }
[ "public", "static", "function", "min_with_key", "(", "$", "array", ",", "$", "key", ")", "{", "if", "(", "!", "\\", "is_array", "(", "$", "array", ")", "||", "\\", "count", "(", "$", "array", ")", "==", "0", ")", "return", "false", ";", "$", "min...
Returns the minimum value of an index from a multidimensional array. ```php \bbn\x::min_with_key([ ['age' => 1, 'name' => 'Michelle'], ['age' => 8, 'name' => 'John'], ['age' => 45, 'name' => 'Sarah'], ['age' => 45, 'name' => 'Camilla'], ['age' => 2, 'name' => 'Allison'] ], 'age'); // int 1 ``` @param array $array A ...
[ "Returns", "the", "minimum", "value", "of", "an", "index", "from", "a", "multidimensional", "array", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L722-L731
nabab/bbn
src/bbn/x.php
x.debug
public static function debug($file=''){ $debug = array_map(function($a){ if ( isset($a['object']) ){ unset($a['object']); } return $a; }, debug_backtrace()); if ( empty($file) ){ self::hdump($debug); } else{ self::log($debug, $file); } }
php
public static function debug($file=''){ $debug = array_map(function($a){ if ( isset($a['object']) ){ unset($a['object']); } return $a; }, debug_backtrace()); if ( empty($file) ){ self::hdump($debug); } else{ self::log($debug, $file); } }
[ "public", "static", "function", "debug", "(", "$", "file", "=", "''", ")", "{", "$", "debug", "=", "array_map", "(", "function", "(", "$", "a", ")", "{", "if", "(", "isset", "(", "$", "a", "[", "'object'", "]", ")", ")", "{", "unset", "(", "$",...
Gets the backtrace and dumps or logs it into a file. ```php \bbn\x::dump(\bbn\x::debug()); ``` @param string $file The file to debug @return void
[ "Gets", "the", "backtrace", "and", "dumps", "or", "logs", "it", "into", "a", "file", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L742-L755
nabab/bbn
src/bbn/x.php
x.map
public static function map(callable $fn, array $ar, string $items = null){ $res = []; foreach ( $ar as $i => $a ){ $is_false = $a === false; $r = $fn($a); if ( $is_false ){ $res[] = $r; } else if ( $r !== false ){ if ( \is_array($r) && $items && isset($r[$items]) &&...
php
public static function map(callable $fn, array $ar, string $items = null){ $res = []; foreach ( $ar as $i => $a ){ $is_false = $a === false; $r = $fn($a); if ( $is_false ){ $res[] = $r; } else if ( $r !== false ){ if ( \is_array($r) && $items && isset($r[$items]) &&...
[ "public", "static", "function", "map", "(", "callable", "$", "fn", ",", "array", "$", "ar", ",", "string", "$", "items", "=", "null", ")", "{", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "ar", "as", "$", "i", "=>", "$", "a", ")", "{...
Applies the given function at all levels of a multidimensional array (if defined param $item). ```php $ar = [ ['age' => 45, 'name' => 'John', 'children' => [ ['age' => 8, 'name' => 'Carol'], ['age' => 24, 'name' => 'Jack'], ] ], ['age' => 44, 'name' => 'Benjamin'], ['age' => 60, 'name' => 'Paul', 'children' => [ ['age...
[ "Applies", "the", "given", "function", "at", "all", "levels", "of", "a", "multidimensional", "array", "(", "if", "defined", "param", "$item", ")", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L829-L845
nabab/bbn
src/bbn/x.php
x.find
public static function find(array $ar, array $where){ //die(var_dump($where)); if ( !empty($where) ){ foreach ( $ar as $i => $v ){ $ok = 1; foreach ( $where as $k => $w ){ if ( !isset($v[$k]) || ($v[$k] !== $w) ){ $ok = false; break; } } ...
php
public static function find(array $ar, array $where){ //die(var_dump($where)); if ( !empty($where) ){ foreach ( $ar as $i => $v ){ $ok = 1; foreach ( $where as $k => $w ){ if ( !isset($v[$k]) || ($v[$k] !== $w) ){ $ok = false; break; } } ...
[ "public", "static", "function", "find", "(", "array", "$", "ar", ",", "array", "$", "where", ")", "{", "//die(var_dump($where));", "if", "(", "!", "empty", "(", "$", "where", ")", ")", "{", "foreach", "(", "$", "ar", "as", "$", "i", "=>", "$", "v",...
Returns the array's first index, which satisfies the 'where' condition. ```php \bbn\x::hdump(\bbn\x::find([[ 'id' => 1, 'name' => 'Andrew', 'fname' => 'Williams' ], [ 'id' => 2, 'name' => 'Albert', 'fname' => 'Taylor' ], [ 'id' => 3, 'name' => 'Mike', 'fname' => 'Smith' ], [ 'id' => 4, 'name' => 'John', 'fname' => 'Wh...
[ "Returns", "the", "array", "s", "first", "index", "which", "satisfies", "the", "where", "condition", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L893-L910
nabab/bbn
src/bbn/x.php
x.get_row
public static function get_row(array $r, array $where){ if ( ($res = self::find($r, $where)) !== false ){ return $r[$res]; } return false; }
php
public static function get_row(array $r, array $where){ if ( ($res = self::find($r, $where)) !== false ){ return $r[$res]; } return false; }
[ "public", "static", "function", "get_row", "(", "array", "$", "r", ",", "array", "$", "where", ")", "{", "if", "(", "(", "$", "res", "=", "self", "::", "find", "(", "$", "r", ",", "$", "where", ")", ")", "!==", "false", ")", "{", "return", "$",...
Returns the first row of an array to satisfy the where parameters ({@link find()). ```php \bbn\x::dump(\bbn\x::get_row([[ 'id' => 1, 'name' => 'Andrew', 'fname' => 'Williams' ], [ 'id' => 2, 'name' => 'Albert', 'fname' => 'Taylor' ], [ 'id' => 3, 'name' => 'Mike', 'fname' => 'Smith' ], [ 'id' => 4, 'name' => 'John', '...
[ "Returns", "the", "first", "row", "of", "an", "array", "to", "satisfy", "the", "where", "parameters", "(", "{", "@link", "find", "()", ")", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L941-L946
nabab/bbn
src/bbn/x.php
x.get_field
public static function get_field(array $r, array $where, string $field){ if ( ($res = self::get_row($r, $where)) && isset($res[$field]) ){ return $res[$field]; } return false; }
php
public static function get_field(array $r, array $where, string $field){ if ( ($res = self::get_row($r, $where)) && isset($res[$field]) ){ return $res[$field]; } return false; }
[ "public", "static", "function", "get_field", "(", "array", "$", "r", ",", "array", "$", "where", ",", "string", "$", "field", ")", "{", "if", "(", "(", "$", "res", "=", "self", "::", "get_row", "(", "$", "r", ",", "$", "where", ")", ")", "&&", ...
Returns the first value of a specific field of an array. ```php \bbn\x::dump(\bbn\x::get_row([[ 'id' => 1, 'name' => 'Andrew', 'fname' => 'Williams' ], [ 'id' => 2, 'name' => 'Albert', 'fname' => 'Taylor' ], [ 'id' => 3, 'name' => 'Mike', 'fname' => 'Smith' ], [ 'id' => 4, 'name' => 'John', 'fname' => 'White' ]], ['na...
[ "Returns", "the", "first", "value", "of", "a", "specific", "field", "of", "an", "array", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L977-L982
nabab/bbn
src/bbn/x.php
x.pick
public static function pick(array $ar, array $keys){ while ( \count($keys) ){ $r = array_shift($keys); if ( isset($ar[$r]) ){ $ar = $ar[$r]; if ( !count($keys) ){ return $ar; } } } }
php
public static function pick(array $ar, array $keys){ while ( \count($keys) ){ $r = array_shift($keys); if ( isset($ar[$r]) ){ $ar = $ar[$r]; if ( !count($keys) ){ return $ar; } } } }
[ "public", "static", "function", "pick", "(", "array", "$", "ar", ",", "array", "$", "keys", ")", "{", "while", "(", "\\", "count", "(", "$", "keys", ")", ")", "{", "$", "r", "=", "array_shift", "(", "$", "keys", ")", ";", "if", "(", "isset", "(...
Returns a reference to a subarray targeted by an array $keys. ```php $ar = [ 'session' => [ 'user' => [ 'profile' => [ 'admin' => [ 'email' => 'test@test.com' ] ] ] ] ]; \bbn\x::hdump(\bbn\x::pick($ar,['session', 'user', 'profile', 'admin', 'email'])); // string test@test.com \bbn\x::hdump(\bbn\x::pick($ar,['session'...
[ "Returns", "a", "reference", "to", "a", "subarray", "targeted", "by", "an", "array", "$keys", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1009-L1019
nabab/bbn
src/bbn/x.php
x.sort
public static function sort(&$ar){ usort($ar, function($a, $b){ if ( !str::is_number($a, $b) ){ $a = str_replace('.', '0', str_replace('_', '1', str::change_case($a, 'lower'))); $b = str_replace('.', '0', str_replace('_', '1', str::change_case($b, 'lower'))); return strcmp($a, $b); ...
php
public static function sort(&$ar){ usort($ar, function($a, $b){ if ( !str::is_number($a, $b) ){ $a = str_replace('.', '0', str_replace('_', '1', str::change_case($a, 'lower'))); $b = str_replace('.', '0', str_replace('_', '1', str::change_case($b, 'lower'))); return strcmp($a, $b); ...
[ "public", "static", "function", "sort", "(", "&", "$", "ar", ")", "{", "usort", "(", "$", "ar", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "!", "str", "::", "is_number", "(", "$", "a", ",", "$", "b", ")", ")", "{", ...
Sorts the items of an array. ```php $var = [3, 2, 5, 6, 1]; \bbn\x::sort($var); \bbn\x::hdump($var); // array [1,2,3,5,6] ``` @param $ar array The reference of the array to sort @return void
[ "Sorts", "the", "items", "of", "an", "array", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1035-L1050
nabab/bbn
src/bbn/x.php
x.sort_by
public static function sort_by(&$ar, $key, $dir = ''){ $args = \func_get_args(); array_shift($args); if ( \is_string($key) ){ $args = [[ 'key' => $key, 'dir' => $dir ]]; } usort($ar, function($a, $b) use($args){ foreach ( $args as $arg ){ $key = $arg['key']...
php
public static function sort_by(&$ar, $key, $dir = ''){ $args = \func_get_args(); array_shift($args); if ( \is_string($key) ){ $args = [[ 'key' => $key, 'dir' => $dir ]]; } usort($ar, function($a, $b) use($args){ foreach ( $args as $arg ){ $key = $arg['key']...
[ "public", "static", "function", "sort_by", "(", "&", "$", "ar", ",", "$", "key", ",", "$", "dir", "=", "''", ")", "{", "$", "args", "=", "\\", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "if", "(", "\\", "is_string"...
Sorts the items of an indexed array based on a given $key. ```php $v = [['age'=>10, 'name'=>'thomas'], ['age'=>22, 'name'=>'John'], ['age'=>37, 'name'=>'Michael']]; \bbn\x::sort_by($v,'name','desc'); \bbn\x::hdump($v); \bbn\x::sort_by($v,'name','asc'); \bbn\x::hdump($v); \bbn\x::sort_by($v,'age','asc'); \bbn\x::hdump(...
[ "Sorts", "the", "items", "of", "an", "indexed", "array", "based", "on", "a", "given", "$key", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1072-L1110
nabab/bbn
src/bbn/x.php
x.curl
public static function curl(string $url, array $param = null, array $options = ['post' => 1]){ $ch = curl_init(); self::$last_curl = $ch; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (\is_object($param) ){ $param = self::to_array($param); } if ( \defined('BBN_IS_SSL') && \defined('BBN_I...
php
public static function curl(string $url, array $param = null, array $options = ['post' => 1]){ $ch = curl_init(); self::$last_curl = $ch; curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); if (\is_object($param) ){ $param = self::to_array($param); } if ( \defined('BBN_IS_SSL') && \defined('BBN_I...
[ "public", "static", "function", "curl", "(", "string", "$", "url", ",", "array", "$", "param", "=", "null", ",", "array", "$", "options", "=", "[", "'post'", "=>", "1", "]", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "self", "::", "$",...
Makes a Curl call towards a URL and returns the result as a string. ```php $url = 'https://www.omdbapi.com/'; $param = ['t'=>'la vita è bella']; \bbn\x::hdump(\bbn\x::curl($url,$param, ['POST' => false])); // object {"Title":"La vita è bella","Year":"1943","Rated":"N/A","Released":"26 May 1943","Runtime":"76 mi...
[ "Makes", "a", "Curl", "call", "towards", "a", "URL", "and", "returns", "the", "result", "as", "a", "string", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1143-L1189
nabab/bbn
src/bbn/x.php
x.get_tree
public static function get_tree($ar){ $res = []; foreach ( $ar as $k => $a ){ $r = ['text' => $k]; if ( \is_object($a) ){ $a = self::to_array($a); } if ( \is_array($a) ){ $r['items'] = self::get_tree($a); } else if ( \is_null($a) ){ $r['text'] .= ': nu...
php
public static function get_tree($ar){ $res = []; foreach ( $ar as $k => $a ){ $r = ['text' => $k]; if ( \is_object($a) ){ $a = self::to_array($a); } if ( \is_array($a) ){ $r['items'] = self::get_tree($a); } else if ( \is_null($a) ){ $r['text'] .= ': nu...
[ "public", "static", "function", "get_tree", "(", "$", "ar", ")", "{", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "ar", "as", "$", "k", "=>", "$", "a", ")", "{", "$", "r", "=", "[", "'text'", "=>", "$", "k", "]", ";", "if", "(", ...
Returns the given array or object as a tree structure ready for a JS tree. ```php \bbn\x::hdump(\bbn\x::get_tree([['id' => 1,'name' => 'Andrew','fname' => 'Williams','children' =>[['name' => 'Emma','age' => 6],['name' => 'Giorgio','age' => 9]]], ['id' => 2,'name' => 'Albert','fname' => 'Taylor','children' =>[['name' =...
[ "Returns", "the", "given", "array", "or", "object", "as", "a", "tree", "structure", "ready", "for", "a", "JS", "tree", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1227-L1252
nabab/bbn
src/bbn/x.php
x.from_csv
public static function from_csv($st, $delimiter = ',', $enclosure = '"', $separator = PHP_EOL){ if ( \is_string($st) ){ $r = []; $lines = explode($separator, $st); foreach ( $lines as $line ){ array_push($r, str_getcsv($line, $delimiter, $enclosure)); } return $r; } ret...
php
public static function from_csv($st, $delimiter = ',', $enclosure = '"', $separator = PHP_EOL){ if ( \is_string($st) ){ $r = []; $lines = explode($separator, $st); foreach ( $lines as $line ){ array_push($r, str_getcsv($line, $delimiter, $enclosure)); } return $r; } ret...
[ "public", "static", "function", "from_csv", "(", "$", "st", ",", "$", "delimiter", "=", "','", ",", "$", "enclosure", "=", "'\"'", ",", "$", "separator", "=", "PHP_EOL", ")", "{", "if", "(", "\\", "is_string", "(", "$", "st", ")", ")", "{", "$", ...
Formats a CSV line(s) and returns it as an array. Adapted from http://us3.php.net/manual/en/function.fputcsv.php#87120 ```php \bbn\x::dump(\bbn\x::from_csv( '"141";"10/11/2002";"350.00";"1311742251" "142";"12/12/2002";"349.00";"1311742258"' )); // [ [ "141", "10/11/2002", "350.00", "1311742251", ], [ "142", "12/12/200...
[ "Formats", "a", "CSV", "line", "(", "s", ")", "and", "returns", "it", "as", "an", "array", ".", "Adapted", "from", "http", ":", "//", "us3", ".", "php", ".", "net", "/", "manual", "/", "en", "/", "function", ".", "fputcsv", ".", "php#87120" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1320-L1330
nabab/bbn
src/bbn/x.php
x.to_csv
public static function to_csv(array $data, $delimiter = ';', $enclosure = '"', $separator = PHP_EOL, $encloseAll = false, $nullToMysqlNull = false ){ $delimiter_esc = preg_quote($delimiter, '/'); $enclosure_esc = preg_quote($enclosure, '/'); $lines = []; foreach ( $data as $d ){ $output = []; ...
php
public static function to_csv(array $data, $delimiter = ';', $enclosure = '"', $separator = PHP_EOL, $encloseAll = false, $nullToMysqlNull = false ){ $delimiter_esc = preg_quote($delimiter, '/'); $enclosure_esc = preg_quote($enclosure, '/'); $lines = []; foreach ( $data as $d ){ $output = []; ...
[ "public", "static", "function", "to_csv", "(", "array", "$", "data", ",", "$", "delimiter", "=", "';'", ",", "$", "enclosure", "=", "'\"'", ",", "$", "separator", "=", "PHP_EOL", ",", "$", "encloseAll", "=", "false", ",", "$", "nullToMysqlNull", "=", "...
Formats an array as a CSV string. Adapted from http://us3.php.net/manual/en/function.fputcsv.php#87120 ```php \bbn\x::dump(\bbn\x::to_csv([["John", "Mike", "David", "Clara"],["White", "Red", "Green", "Blue"]])); /* string John;Mike;David;Clara White;Red;Green;Blue ``` @param array $data The array to format @param st...
[ "Formats", "an", "array", "as", "a", "CSV", "string", ".", "Adapted", "from", "http", ":", "//", "us3", ".", "php", ".", "net", "/", "manual", "/", "en", "/", "function", ".", "fputcsv", ".", "php#87120" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1351-L1375
nabab/bbn
src/bbn/x.php
x.is_same
public static function is_same(string $file1, string $file2, $strict = false){ if ( !is_file($file1) || !is_file($file2) ){ throw Exception("Boo! One of the files given to the x::is_same function doesn't exist"); } else{ $same = filesize($file1) === filesize($file2); if ( !$strict || !$sam...
php
public static function is_same(string $file1, string $file2, $strict = false){ if ( !is_file($file1) || !is_file($file2) ){ throw Exception("Boo! One of the files given to the x::is_same function doesn't exist"); } else{ $same = filesize($file1) === filesize($file2); if ( !$strict || !$sam...
[ "public", "static", "function", "is_same", "(", "string", "$", "file1", ",", "string", "$", "file2", ",", "$", "strict", "=", "false", ")", "{", "if", "(", "!", "is_file", "(", "$", "file1", ")", "||", "!", "is_file", "(", "$", "file2", ")", ")", ...
Checks if two files are the same. @param string $file1 @param string $file2 @param bool $strict @return bool
[ "Checks", "if", "two", "files", "are", "the", "same", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1385-L1396
nabab/bbn
src/bbn/x.php
x.to_excel
public static function to_excel(array $data, string $file, bool $with_titles = true): bool { $checked = false; $todo = []; foreach ( $data as $d ){ if ( !$checked && self::is_assoc($d) ){ if ( $with_titles ){ $line1 = []; $line2 = []; foreach ( $d as $k => $v ){...
php
public static function to_excel(array $data, string $file, bool $with_titles = true): bool { $checked = false; $todo = []; foreach ( $data as $d ){ if ( !$checked && self::is_assoc($d) ){ if ( $with_titles ){ $line1 = []; $line2 = []; foreach ( $d as $k => $v ){...
[ "public", "static", "function", "to_excel", "(", "array", "$", "data", ",", "string", "$", "file", ",", "bool", "$", "with_titles", "=", "true", ")", ":", "bool", "{", "$", "checked", "=", "false", ";", "$", "todo", "=", "[", "]", ";", "foreach", "...
Creates an Excel file from a given array. @param array $array The array to export @param string $file The file path @param bool $with_titles Set it to false if you don't want the columns titles. Default true @return bool
[ "Creates", "an", "Excel", "file", "from", "a", "given", "array", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1462-L1494
nabab/bbn
src/bbn/x.php
x.make_uid
public static function make_uid($binary = false, $hyphens = false){ $tmp = sprintf($hyphens ? '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' : '%04x%04x%04x%04x%04x%04x%04x%04x', // 32 bits for "time_low" mt_rand(0, 0xffff), mt_rand(0, 0xffff), // 16 bits for "time_mid" mt_rand(0, 0xffff), ...
php
public static function make_uid($binary = false, $hyphens = false){ $tmp = sprintf($hyphens ? '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' : '%04x%04x%04x%04x%04x%04x%04x%04x', // 32 bits for "time_low" mt_rand(0, 0xffff), mt_rand(0, 0xffff), // 16 bits for "time_mid" mt_rand(0, 0xffff), ...
[ "public", "static", "function", "make_uid", "(", "$", "binary", "=", "false", ",", "$", "hyphens", "=", "false", ")", "{", "$", "tmp", "=", "sprintf", "(", "$", "hyphens", "?", "'%04x%04x-%04x-%04x-%04x-%04x%04x%04x'", ":", "'%04x%04x%04x%04x%04x%04x%04x%04x'", ...
Makes a UID. @param bool $binary Set it to true if you want a binary UID @param bool $hypens Set it to true if you want hypens to seperate the UID @return string|bynary
[ "Makes", "a", "UID", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1503-L1525
nabab/bbn
src/bbn/x.php
x.convert_uids
public static function convert_uids($st){ if ( \is_array($st) || \is_object($st) ){ foreach ( $st as &$s ){ $s = self::convert_uids($s); } } else if ( \bbn\str::is_uid($st) ){ $st = bin2hex($st); } return $st; }
php
public static function convert_uids($st){ if ( \is_array($st) || \is_object($st) ){ foreach ( $st as &$s ){ $s = self::convert_uids($s); } } else if ( \bbn\str::is_uid($st) ){ $st = bin2hex($st); } return $st; }
[ "public", "static", "function", "convert_uids", "(", "$", "st", ")", "{", "if", "(", "\\", "is_array", "(", "$", "st", ")", "||", "\\", "is_object", "(", "$", "st", ")", ")", "{", "foreach", "(", "$", "st", "as", "&", "$", "s", ")", "{", "$", ...
Converts a hex UID to a binary UID. You can also give an array or an object to convert the array's items or the object's properties. @param string|array|object $st @return string
[ "Converts", "a", "hex", "UID", "to", "a", "binary", "UID", ".", "You", "can", "also", "give", "an", "array", "or", "an", "object", "to", "convert", "the", "array", "s", "items", "or", "the", "object", "s", "properties", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1532-L1542
nabab/bbn
src/bbn/x.php
x.compare_floats
public static function compare_floats($v1, $v2, string $operator = '===', int $precision = 4): bool { $v1 = round((float)$v1 * pow(10, $precision)); $v2 = round((float)$v2 * pow(10, $precision)); switch ($operator ){ case '===': return $v1 === $v2; case '==': return $v1 == $v2;...
php
public static function compare_floats($v1, $v2, string $operator = '===', int $precision = 4): bool { $v1 = round((float)$v1 * pow(10, $precision)); $v2 = round((float)$v2 * pow(10, $precision)); switch ($operator ){ case '===': return $v1 === $v2; case '==': return $v1 == $v2;...
[ "public", "static", "function", "compare_floats", "(", "$", "v1", ",", "$", "v2", ",", "string", "$", "operator", "=", "'==='", ",", "int", "$", "precision", "=", "4", ")", ":", "bool", "{", "$", "v1", "=", "round", "(", "(", "float", ")", "$", "...
Compares two float numbers with the given operator. @param float $v1 @param float $v2 @param string $operator @param int $precision @return boolean
[ "Compares", "two", "float", "numbers", "with", "the", "given", "operator", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1553-L1572
nabab/bbn
src/bbn/x.php
x.json_base64_encode
public static function json_base64_encode(array $arr, $json = true) { $res = []; foreach ( $arr as $i => $a ){ if ( is_array($a) ){ $res[$i] = self::json_base64_encode($a, false); } else if ( is_string($a) ){ $res[$i] = base64_encode($a); } else{ $res[$i] ...
php
public static function json_base64_encode(array $arr, $json = true) { $res = []; foreach ( $arr as $i => $a ){ if ( is_array($a) ){ $res[$i] = self::json_base64_encode($a, false); } else if ( is_string($a) ){ $res[$i] = base64_encode($a); } else{ $res[$i] ...
[ "public", "static", "function", "json_base64_encode", "(", "array", "$", "arr", ",", "$", "json", "=", "true", ")", "{", "$", "res", "=", "[", "]", ";", "foreach", "(", "$", "arr", "as", "$", "i", "=>", "$", "a", ")", "{", "if", "(", "is_array", ...
Encodes an array's values to the base64 encoding scheme. You can also convert the resulting array into a JSON string (default). @param array $arr @param boolean $json @return string|array
[ "Encodes", "an", "array", "s", "values", "to", "the", "base64", "encoding", "scheme", ".", "You", "can", "also", "convert", "the", "resulting", "array", "into", "a", "JSON", "string", "(", "default", ")", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1581-L1596
nabab/bbn
src/bbn/x.php
x.json_base64_decode
public static function json_base64_decode($st): ?array { $res = \is_string($st) ? json_decode($st, true) : $st; if ( \is_array($res) ){ foreach ( $res as $i => $a ){ if ( \is_array($a) ){ $res[$i] = self::json_base64_decode($a); } else if ( \is_string($a) ){ $...
php
public static function json_base64_decode($st): ?array { $res = \is_string($st) ? json_decode($st, true) : $st; if ( \is_array($res) ){ foreach ( $res as $i => $a ){ if ( \is_array($a) ){ $res[$i] = self::json_base64_decode($a); } else if ( \is_string($a) ){ $...
[ "public", "static", "function", "json_base64_decode", "(", "$", "st", ")", ":", "?", "array", "{", "$", "res", "=", "\\", "is_string", "(", "$", "st", ")", "?", "json_decode", "(", "$", "st", ",", "true", ")", ":", "$", "st", ";", "if", "(", "\\"...
Decodes the base64 array's values. You can also give a JSON string of an array. @param string|array $st @result array
[ "Decodes", "the", "base64", "array", "s", "values", ".", "You", "can", "also", "give", "a", "JSON", "string", "of", "an", "array", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1604-L1622
nabab/bbn
src/bbn/x.php
x.index_by_first_val
public static function index_by_first_val(array $ar): array { if ( empty($ar) || !isset($ar[0]) || !\count($ar[0]) ){ return $ar; } $cols = array_keys($ar[0]); $idx = array_shift($cols); $num_cols = \count($cols); $res = []; foreach ( $ar as $d ){ $index = $d[$idx]; unset...
php
public static function index_by_first_val(array $ar): array { if ( empty($ar) || !isset($ar[0]) || !\count($ar[0]) ){ return $ar; } $cols = array_keys($ar[0]); $idx = array_shift($cols); $num_cols = \count($cols); $res = []; foreach ( $ar as $d ){ $index = $d[$idx]; unset...
[ "public", "static", "function", "index_by_first_val", "(", "array", "$", "ar", ")", ":", "array", "{", "if", "(", "empty", "(", "$", "ar", ")", "||", "!", "isset", "(", "$", "ar", "[", "0", "]", ")", "||", "!", "\\", "count", "(", "$", "ar", "[...
Creates an associative array based on the first array's value. @param array $ar @return array
[ "Creates", "an", "associative", "array", "based", "on", "the", "first", "array", "s", "value", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/x.php#L1629-L1644
thienhungho/yii2-product-management
src/modules/ProductManage/controllers/ProductUnitController.php
ProductUnitController.actionView
public function actionView($id) { $model = $this->findModel($id); $providerProductUnitEquivalent = new \yii\data\ArrayDataProvider([ 'allModels' => $model->productUnitEquivalents, ]); return $this->render('view', [ 'model' => $this->findModel($id), ...
php
public function actionView($id) { $model = $this->findModel($id); $providerProductUnitEquivalent = new \yii\data\ArrayDataProvider([ 'allModels' => $model->productUnitEquivalents, ]); return $this->render('view', [ 'model' => $this->findModel($id), ...
[ "public", "function", "actionView", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "providerProductUnitEquivalent", "=", "new", "\\", "yii", "\\", "data", "\\", "ArrayDataProvider", "(", "[", ...
@param $id @return string @throws NotFoundHttpException
[ "@param", "$id" ]
train
https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductUnitController.php#L50-L60
thienhungho/yii2-product-management
src/modules/ProductManage/controllers/ProductUnitController.php
ProductUnitController.actionPdf
public function actionPdf($id) { $model = $this->findModel($id); $providerProductUnitEquivalent = new \yii\data\ArrayDataProvider([ 'allModels' => $model->productUnitEquivalents, ]); $content = $this->renderAjax('_pdf', [ 'model' => $model, 'p...
php
public function actionPdf($id) { $model = $this->findModel($id); $providerProductUnitEquivalent = new \yii\data\ArrayDataProvider([ 'allModels' => $model->productUnitEquivalents, ]); $content = $this->renderAjax('_pdf', [ 'model' => $model, 'p...
[ "public", "function", "actionPdf", "(", "$", "id", ")", "{", "$", "model", "=", "$", "this", "->", "findModel", "(", "$", "id", ")", ";", "$", "providerProductUnitEquivalent", "=", "new", "\\", "yii", "\\", "data", "\\", "ArrayDataProvider", "(", "[", ...
@param $id @return mixed @throws NotFoundHttpException
[ "@param", "$id" ]
train
https://github.com/thienhungho/yii2-product-management/blob/72e1237bba123faf671e44491bd93077b50adde9/src/modules/ProductManage/controllers/ProductUnitController.php#L123-L150
HedronDev/hedron
src/Parser/ComposerJson.php
ComposerJson.parse
public function parse(GitPostReceiveHandler $handler, CommandStackInterface $commandStack) { if (array_search('composer.json', $handler->getIntersectFiles()) !== FALSE) { $environment = $this->getEnvironment(); $clientDir = $this->getClientDirectoryName(); $commandStack->addCommand("cd {$environme...
php
public function parse(GitPostReceiveHandler $handler, CommandStackInterface $commandStack) { if (array_search('composer.json', $handler->getIntersectFiles()) !== FALSE) { $environment = $this->getEnvironment(); $clientDir = $this->getClientDirectoryName(); $commandStack->addCommand("cd {$environme...
[ "public", "function", "parse", "(", "GitPostReceiveHandler", "$", "handler", ",", "CommandStackInterface", "$", "commandStack", ")", "{", "if", "(", "array_search", "(", "'composer.json'", ",", "$", "handler", "->", "getIntersectFiles", "(", ")", ")", "!==", "FA...
{@inheritdoc}
[ "{" ]
train
https://github.com/HedronDev/hedron/blob/3b4adec4912f2d7c0b7e7262dc36515fbc2e8e00/src/Parser/ComposerJson.php#L18-L31
fkooman/php-lib-http
src/fkooman/Http/Url.php
Url.getQueryString
public function getQueryString() { $requestUri = $this->getRequestUri(); if (false !== $qPos = mb_strpos($requestUri, '?')) { // has query string return mb_substr($requestUri, $qPos + 1); } return ''; }
php
public function getQueryString() { $requestUri = $this->getRequestUri(); if (false !== $qPos = mb_strpos($requestUri, '?')) { // has query string return mb_substr($requestUri, $qPos + 1); } return ''; }
[ "public", "function", "getQueryString", "(", ")", "{", "$", "requestUri", "=", "$", "this", "->", "getRequestUri", "(", ")", ";", "if", "(", "false", "!==", "$", "qPos", "=", "mb_strpos", "(", "$", "requestUri", ",", "'?'", ")", ")", "{", "// has query...
The query string. @return string the query string, or empty string if no query string is available
[ "The", "query", "string", "." ]
train
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Url.php#L151-L161
fkooman/php-lib-http
src/fkooman/Http/Url.php
Url.getQueryStringAsArray
public function getQueryStringAsArray() { $queryString = $this->getQueryString(); if ('' === $queryString) { return []; } $queryStringArray = []; parse_str($queryString, $queryStringArray); return $queryStringArray; }
php
public function getQueryStringAsArray() { $queryString = $this->getQueryString(); if ('' === $queryString) { return []; } $queryStringArray = []; parse_str($queryString, $queryStringArray); return $queryStringArray; }
[ "public", "function", "getQueryStringAsArray", "(", ")", "{", "$", "queryString", "=", "$", "this", "->", "getQueryString", "(", ")", ";", "if", "(", "''", "===", "$", "queryString", ")", "{", "return", "[", "]", ";", "}", "$", "queryStringArray", "=", ...
The query string as array. @return array the query string as array. The array will be empty if the query string is empty
[ "The", "query", "string", "as", "array", "." ]
train
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Url.php#L169-L181
fkooman/php-lib-http
src/fkooman/Http/Url.php
Url.getQueryParameter
public function getQueryParameter($key) { $queryStringArray = $this->getQueryStringAsArray(); if (array_key_exists($key, $queryStringArray)) { return $queryStringArray[$key]; } return null; }
php
public function getQueryParameter($key) { $queryStringArray = $this->getQueryStringAsArray(); if (array_key_exists($key, $queryStringArray)) { return $queryStringArray[$key]; } return null; }
[ "public", "function", "getQueryParameter", "(", "$", "key", ")", "{", "$", "queryStringArray", "=", "$", "this", "->", "getQueryStringAsArray", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "queryStringArray", ")", ")", "{", "ret...
Return a specific query string parameter value. @param string $key the query parameter key to get @return mixed the query parameter value if it is set, or null if the parameter is not available
[ "Return", "a", "specific", "query", "string", "parameter", "value", "." ]
train
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Url.php#L191-L200
fkooman/php-lib-http
src/fkooman/Http/Url.php
Url.getRoot
public function getRoot() { $requestUri = $this->getRequestUri(); $pathInfo = $this->getPathInfo(); // remove query string from REQUEST_URI, if set if (false !== $qPos = mb_strpos($requestUri, '?')) { // has query string $requestUri = mb_substr($requestUri, 0...
php
public function getRoot() { $requestUri = $this->getRequestUri(); $pathInfo = $this->getPathInfo(); // remove query string from REQUEST_URI, if set if (false !== $qPos = mb_strpos($requestUri, '?')) { // has query string $requestUri = mb_substr($requestUri, 0...
[ "public", "function", "getRoot", "(", ")", "{", "$", "requestUri", "=", "$", "this", "->", "getRequestUri", "(", ")", ";", "$", "pathInfo", "=", "$", "this", "->", "getPathInfo", "(", ")", ";", "// remove query string from REQUEST_URI, if set", "if", "(", "f...
Get the REQUEST_URI without PATH_INFO and QUERY_STRING, taking server rewriting in consideration. Example (without URL rewriting): https://www.example.org/foo/index.php/bar?a=b will return: '/foo/index.php' Example (with URL rewriting to index.php): https://www.example.org/foo/bar?a=b will return: '/foo' Example (wi...
[ "Get", "the", "REQUEST_URI", "without", "PATH_INFO", "and", "QUERY_STRING", "taking", "server", "rewriting", "in", "consideration", "." ]
train
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Url.php#L218-L236
fkooman/php-lib-http
src/fkooman/Http/Url.php
Url.getAuthority
public function getAuthority() { $scheme = $this->getScheme(); $serverName = $this->getHost(); $serverPort = $this->getPort(); $authority = sprintf('%s://%s', $scheme, $serverName); if (('https' === $scheme && 443 !== $serverPort) || ('http' === $scheme && 80 !== $serverPort...
php
public function getAuthority() { $scheme = $this->getScheme(); $serverName = $this->getHost(); $serverPort = $this->getPort(); $authority = sprintf('%s://%s', $scheme, $serverName); if (('https' === $scheme && 443 !== $serverPort) || ('http' === $scheme && 80 !== $serverPort...
[ "public", "function", "getAuthority", "(", ")", "{", "$", "scheme", "=", "$", "this", "->", "getScheme", "(", ")", ";", "$", "serverName", "=", "$", "this", "->", "getHost", "(", ")", ";", "$", "serverPort", "=", "$", "this", "->", "getPort", "(", ...
Get the authority part of the URL. That is, the scheme, host and optional port if it is not a standard port. @return string the authority part of the URL
[ "Get", "the", "authority", "part", "of", "the", "URL", ".", "That", "is", "the", "scheme", "host", "and", "optional", "port", "if", "it", "is", "not", "a", "standard", "port", "." ]
train
https://github.com/fkooman/php-lib-http/blob/94956a480459b7f6b880d61f21ef03e683deb995/src/fkooman/Http/Url.php#L252-L264
alevilar/ristorantino-vendor
Compras/Model/PedidoEstado.php
PedidoEstado.beforeDelete
public function beforeDelete($cascade = true) { $idInborrables = array( COMPRAS_PEDIDO_ESTADO_PENDIENTE, COMPRAS_PEDIDO_ESTADO_COMPLETADO, COMPRAS_PEDIDO_ESTADO_PEDIDO, ); if ( in_array($this->id, $idInborrables)) { return false; } return true; }
php
public function beforeDelete($cascade = true) { $idInborrables = array( COMPRAS_PEDIDO_ESTADO_PENDIENTE, COMPRAS_PEDIDO_ESTADO_COMPLETADO, COMPRAS_PEDIDO_ESTADO_PEDIDO, ); if ( in_array($this->id, $idInborrables)) { return false; } return true; }
[ "public", "function", "beforeDelete", "(", "$", "cascade", "=", "true", ")", "{", "$", "idInborrables", "=", "array", "(", "COMPRAS_PEDIDO_ESTADO_PENDIENTE", ",", "COMPRAS_PEDIDO_ESTADO_COMPLETADO", ",", "COMPRAS_PEDIDO_ESTADO_PEDIDO", ",", ")", ";", "if", "(", "in_...
Called before every deletion operation. @param bool $cascade If true records that depend on this record will also be deleted @return bool True if the operation should continue, false if it should abort @link http://book.cakephp.org/2.0/en/models/callback-methods.html#beforedelete
[ "Called", "before", "every", "deletion", "operation", "." ]
train
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Compras/Model/PedidoEstado.php#L64-L75
gdbots/iam-php
src/Policy.php
Policy.isGranted
public function isGranted(string $action): bool { if (empty($this->allowed)) { return false; } if (isset($this->denied[$action]) || isset($this->denied[self::WILDCARD])) { return false; } $rules = $this->getRules($action); foreach ($rules as...
php
public function isGranted(string $action): bool { if (empty($this->allowed)) { return false; } if (isset($this->denied[$action]) || isset($this->denied[self::WILDCARD])) { return false; } $rules = $this->getRules($action); foreach ($rules as...
[ "public", "function", "isGranted", "(", "string", "$", "action", ")", ":", "bool", "{", "if", "(", "empty", "(", "$", "this", "->", "allowed", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "denied", "[", ...
Returns true if the policy should allow the action to be carried out. @param string $action @return bool
[ "Returns", "true", "if", "the", "policy", "should", "allow", "the", "action", "to", "be", "carried", "out", "." ]
train
https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/Policy.php#L61-L86
gdbots/iam-php
src/Policy.php
Policy.getRules
private function getRules(string $action): array { $rules = []; $parts = explode(self::DELIMITER, $action); while (array_pop($parts)) { $rules[] = implode(self::DELIMITER, $parts) . self::DELIMITER . self::WILDCARD; } $rules = array_reverse($rules); $rul...
php
private function getRules(string $action): array { $rules = []; $parts = explode(self::DELIMITER, $action); while (array_pop($parts)) { $rules[] = implode(self::DELIMITER, $parts) . self::DELIMITER . self::WILDCARD; } $rules = array_reverse($rules); $rul...
[ "private", "function", "getRules", "(", "string", "$", "action", ")", ":", "array", "{", "$", "rules", "=", "[", "]", ";", "$", "parts", "=", "explode", "(", "self", "::", "DELIMITER", ",", "$", "action", ")", ";", "while", "(", "array_pop", "(", "...
Converts an action with potentially colon delimiters into a set of permissions to check for. @example An action of "acme:blog:command:publish-article" becomes an array of: [ '*', 'acme:*', 'acme:blog:*', 'acme:blog:command:*', 'acme:blog:command:publish-article', ] @param string $action @return string[]
[ "Converts", "an", "action", "with", "potentially", "colon", "delimiters", "into", "a", "set", "of", "permissions", "to", "check", "for", "." ]
train
https://github.com/gdbots/iam-php/blob/3dbfa602de183a7ac5fb5140304e8cf4c4b15ab3/src/Policy.php#L127-L141
rhosocial/yii2-user
models/log/UserLoginTrait.php
UserLoginTrait.getLoginLogs
public function getLoginLogs() { /* @var $this User */ $class = $this->loginLogClass; try { return $class::getLatests($this, Login::GET_ALL_LATESTS); } catch (\Exception $ex) { Yii::error($ex->getMessage(), __METHOD__); return []; } }
php
public function getLoginLogs() { /* @var $this User */ $class = $this->loginLogClass; try { return $class::getLatests($this, Login::GET_ALL_LATESTS); } catch (\Exception $ex) { Yii::error($ex->getMessage(), __METHOD__); return []; } }
[ "public", "function", "getLoginLogs", "(", ")", "{", "/* @var $this User */", "$", "class", "=", "$", "this", "->", "loginLogClass", ";", "try", "{", "return", "$", "class", "::", "getLatests", "(", "$", "this", ",", "Login", "::", "GET_ALL_LATESTS", ")", ...
Get login logs. @return Login[]
[ "Get", "login", "logs", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/log/UserLoginTrait.php#L35-L45
rhosocial/yii2-user
models/log/UserLoginTrait.php
UserLoginTrait.recordLogin
public function recordLogin($config = []) { if (empty($this->loginLogClass)) { return false; } $log = $this->create($this->loginLogClass, $config); try { return $log->save(); } catch (\Exception $ex) { Yii::error($ex->getMessage(), __METHOD...
php
public function recordLogin($config = []) { if (empty($this->loginLogClass)) { return false; } $log = $this->create($this->loginLogClass, $config); try { return $log->save(); } catch (\Exception $ex) { Yii::error($ex->getMessage(), __METHOD...
[ "public", "function", "recordLogin", "(", "$", "config", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "loginLogClass", ")", ")", "{", "return", "false", ";", "}", "$", "log", "=", "$", "this", "->", "create", "(", "$", "th...
Record login. @param array $config @return mixed
[ "Record", "login", "." ]
train
https://github.com/rhosocial/yii2-user/blob/96737a9d8ca7e9c42cd2b7736d6c0a90ede6e5bc/models/log/UserLoginTrait.php#L68-L79
jnaxo/country-codes
src/Store/api/Collection.php
Collection.setData
public function setData($collection, $resource_name = '') { $this->collection = collect(); if (!$this->resource_name) { $this->resource_name = empty($resource_name) ? 'undefined' : $resource_name; } $this->data = []; foreach ($collection as $item) { ...
php
public function setData($collection, $resource_name = '') { $this->collection = collect(); if (!$this->resource_name) { $this->resource_name = empty($resource_name) ? 'undefined' : $resource_name; } $this->data = []; foreach ($collection as $item) { ...
[ "public", "function", "setData", "(", "$", "collection", ",", "$", "resource_name", "=", "''", ")", "{", "$", "this", "->", "collection", "=", "collect", "(", ")", ";", "if", "(", "!", "$", "this", "->", "resource_name", ")", "{", "$", "this", "->", ...
Set collection data @param type $collection @param string $resource_name
[ "Set", "collection", "data" ]
train
https://github.com/jnaxo/country-codes/blob/ab1f24886e1b49eef5fd4b4eb4fb37aa7faeacd9/src/Store/api/Collection.php#L87-L103
sciactive/nymph-server
src/Nymph.php
Nymph.configure
public static function configure($config = []) { $defaults = include dirname(__DIR__).'/conf/defaults.php'; self::$config = array_replace_recursive($defaults, $config); if (isset(self::$driver)) { if (self::$driver->connected) { self::$driver->disconnect(); } self::$driver = null;...
php
public static function configure($config = []) { $defaults = include dirname(__DIR__).'/conf/defaults.php'; self::$config = array_replace_recursive($defaults, $config); if (isset(self::$driver)) { if (self::$driver->connected) { self::$driver->disconnect(); } self::$driver = null;...
[ "public", "static", "function", "configure", "(", "$", "config", "=", "[", "]", ")", "{", "$", "defaults", "=", "include", "dirname", "(", "__DIR__", ")", ".", "'/conf/defaults.php'", ";", "self", "::", "$", "config", "=", "array_replace_recursive", "(", "...
Apply configuration to Nymph. $config should be an associative array of Nymph configuration. Use the following form: [ 'driver' => 'MySQL', 'pubsub' => true, 'MySql' => [ 'host' => '127.0.0.1' ] ] @param array $config An associative array of Nymph's configuration.
[ "Apply", "configuration", "to", "Nymph", "." ]
train
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Nymph.php#L55-L76
sciactive/nymph-server
src/Nymph.php
Nymph.checkData
public static function checkData( &$data, &$sdata, $selectors, $guid = null, $tags = null, $typesAlreadyChecked = [], $dataValsAreadyChecked = [] ) { return self::$driver->checkData( $data, $sdata, $selectors, $guid, $tags, ...
php
public static function checkData( &$data, &$sdata, $selectors, $guid = null, $tags = null, $typesAlreadyChecked = [], $dataValsAreadyChecked = [] ) { return self::$driver->checkData( $data, $sdata, $selectors, $guid, $tags, ...
[ "public", "static", "function", "checkData", "(", "&", "$", "data", ",", "&", "$", "sdata", ",", "$", "selectors", ",", "$", "guid", "=", "null", ",", "$", "tags", "=", "null", ",", "$", "typesAlreadyChecked", "=", "[", "]", ",", "$", "dataValsAready...
Check entity data to see if it matches given selectors. @param array $data An array of unserialized entity data. The data array should contain the cdate and mdate. @param array $sdata An array of serialized entity data. If a value here is checked, it will be unserialized and placed in the $data array. @param array $se...
[ "Check", "entity", "data", "to", "see", "if", "it", "matches", "given", "selectors", "." ]
train
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Nymph.php#L101-L119
sciactive/nymph-server
src/Nymph.php
Nymph.hsort
public static function hsort( &$array, $property = null, $parentProperty = null, $caseSensitive = false, $reverse = false ) { return self::$driver->hsort( $array, $property, $parentProperty, $caseSensitive, $reverse ); }
php
public static function hsort( &$array, $property = null, $parentProperty = null, $caseSensitive = false, $reverse = false ) { return self::$driver->hsort( $array, $property, $parentProperty, $caseSensitive, $reverse ); }
[ "public", "static", "function", "hsort", "(", "&", "$", "array", ",", "$", "property", "=", "null", ",", "$", "parentProperty", "=", "null", ",", "$", "caseSensitive", "=", "false", ",", "$", "reverse", "=", "false", ")", "{", "return", "self", "::", ...
Sort an array of entities hierarchically by a specified property's value. Entities will be placed immediately after their parents. The $parentProperty property must hold either null, or the entity's parent. @param array &$array The array of entities. @param string|null $property The name of the property to sort entit...
[ "Sort", "an", "array", "of", "entities", "hierarchically", "by", "a", "specified", "property", "s", "value", "." ]
train
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Nymph.php#L160-L174
sciactive/nymph-server
src/Nymph.php
Nymph.sort
public static function sort( &$array, $property = null, $caseSensitive = false, $reverse = false ) { return self::$driver->sort( $array, $property, $caseSensitive, $reverse ); }
php
public static function sort( &$array, $property = null, $caseSensitive = false, $reverse = false ) { return self::$driver->sort( $array, $property, $caseSensitive, $reverse ); }
[ "public", "static", "function", "sort", "(", "&", "$", "array", ",", "$", "property", "=", "null", ",", "$", "caseSensitive", "=", "false", ",", "$", "reverse", "=", "false", ")", "{", "return", "self", "::", "$", "driver", "->", "sort", "(", "$", ...
Sort an array of entities by a specified property's value. @param array &$array The array of entities. @param string|null $property The name of the property to sort entities by. @param bool $caseSensitive Sort case sensitively. @param bool $reverse Reverse the sort order.
[ "Sort", "an", "array", "of", "entities", "by", "a", "specified", "property", "s", "value", "." ]
train
https://github.com/sciactive/nymph-server/blob/3c18dbf45c2750d07c798e14534dba87387beeba/src/Nymph.php#L213-L225
ronaldborla/chikka
src/Borla/Chikka/Models/Carrier.php
Carrier.identifyNetwork
static function identifyNetwork($carrierCode) { // Loop through codes foreach (static::codes() as $network=> $codes) { // If found if (in_array($carrierCode, $codes)) { // Return network return $network; } } // Return false return false; }
php
static function identifyNetwork($carrierCode) { // Loop through codes foreach (static::codes() as $network=> $codes) { // If found if (in_array($carrierCode, $codes)) { // Return network return $network; } } // Return false return false; }
[ "static", "function", "identifyNetwork", "(", "$", "carrierCode", ")", "{", "// Loop through codes", "foreach", "(", "static", "::", "codes", "(", ")", "as", "$", "network", "=>", "$", "codes", ")", "{", "// If found", "if", "(", "in_array", "(", "$", "car...
Identify network @param string|int $carrierCode Carrier code parsed by Utilities::parseMobileNumber()
[ "Identify", "network" ]
train
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Carrier.php#L83-L94
infusephp/infuse
src/SymfonyHttpBridge.php
SymfonyHttpBridge.convertSymfonyRequest
public function convertSymfonyRequest(SymfonyRequest $request) { $session = $request->getSession(); if ($session) { $session = $session->all(); } else { $session = []; } // decode request parameters $parameters = $request->request->all(); ...
php
public function convertSymfonyRequest(SymfonyRequest $request) { $session = $request->getSession(); if ($session) { $session = $session->all(); } else { $session = []; } // decode request parameters $parameters = $request->request->all(); ...
[ "public", "function", "convertSymfonyRequest", "(", "SymfonyRequest", "$", "request", ")", "{", "$", "session", "=", "$", "request", "->", "getSession", "(", ")", ";", "if", "(", "$", "session", ")", "{", "$", "session", "=", "$", "session", "->", "all",...
Converts a Symfony request object into an Infuse request object. @param SymfonyRequest $request @return Request
[ "Converts", "a", "Symfony", "request", "object", "into", "an", "Infuse", "request", "object", "." ]
train
https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/SymfonyHttpBridge.php#L22-L44
infusephp/infuse
src/SymfonyHttpBridge.php
SymfonyHttpBridge.convertInfuseResponse
public function convertInfuseResponse(Response $res) { $response = new SymfonyResponse($res->getBody(), $res->getCode(), $res->headers()); // transfer cookies foreach ($res->cookies() as $name => $params) { list($value, $expire, $path, $domain, $secure, $httponly) = $params; ...
php
public function convertInfuseResponse(Response $res) { $response = new SymfonyResponse($res->getBody(), $res->getCode(), $res->headers()); // transfer cookies foreach ($res->cookies() as $name => $params) { list($value, $expire, $path, $domain, $secure, $httponly) = $params; ...
[ "public", "function", "convertInfuseResponse", "(", "Response", "$", "res", ")", "{", "$", "response", "=", "new", "SymfonyResponse", "(", "$", "res", "->", "getBody", "(", ")", ",", "$", "res", "->", "getCode", "(", ")", ",", "$", "res", "->", "header...
Converts an Infuse response object into a Symfony response object. @param Response $res @return SymfonyResponse
[ "Converts", "an", "Infuse", "response", "object", "into", "a", "Symfony", "response", "object", "." ]
train
https://github.com/infusephp/infuse/blob/7520b237c69f3d8a07d95d7481b26027ced2ed83/src/SymfonyHttpBridge.php#L53-L65
ajgarlag/AjglCsv
src/Reader/ReaderFactory.php
ReaderFactory.createReader
public function createReader( $type, $filePath, $delimiter = ReaderInterface::DELIMITER_DEFAULT, $fileCharset = ReaderInterface::CHARSET_DEFAULT, $mode = 'r' ) { switch ($type) { case 'php': return new NativePhpReader($filePath, $delimiter,...
php
public function createReader( $type, $filePath, $delimiter = ReaderInterface::DELIMITER_DEFAULT, $fileCharset = ReaderInterface::CHARSET_DEFAULT, $mode = 'r' ) { switch ($type) { case 'php': return new NativePhpReader($filePath, $delimiter,...
[ "public", "function", "createReader", "(", "$", "type", ",", "$", "filePath", ",", "$", "delimiter", "=", "ReaderInterface", "::", "DELIMITER_DEFAULT", ",", "$", "fileCharset", "=", "ReaderInterface", "::", "CHARSET_DEFAULT", ",", "$", "mode", "=", "'r'", ")",...
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Reader/ReaderFactory.php#L22-L42
hametuha/wpametu
src/WPametu/Utility/Command.php
Command.table
protected static function table($header, $body){ $table = new \cli\Table(); $table->setHeaders( $header ); $table->setRows( $body ); $table->display(); }
php
protected static function table($header, $body){ $table = new \cli\Table(); $table->setHeaders( $header ); $table->setRows( $body ); $table->display(); }
[ "protected", "static", "function", "table", "(", "$", "header", ",", "$", "body", ")", "{", "$", "table", "=", "new", "\\", "cli", "\\", "Table", "(", ")", ";", "$", "table", "->", "setHeaders", "(", "$", "header", ")", ";", "$", "table", "->", "...
Show table @param array $header @param array $body
[ "Show", "table" ]
train
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/Utility/Command.php#L69-L74
nabab/bbn
src/bbn/user/preferences.php
preferences._init_user
private function _init_user(bbn\user $user): preferences { $this->user = $user; $this->id_user = $this->user->get_id(); $this->id_group = $this->user->get_group(); return $this; }
php
private function _init_user(bbn\user $user): preferences { $this->user = $user; $this->id_user = $this->user->get_id(); $this->id_group = $this->user->get_group(); return $this; }
[ "private", "function", "_init_user", "(", "bbn", "\\", "user", "$", "user", ")", ":", "preferences", "{", "$", "this", "->", "user", "=", "$", "user", ";", "$", "this", "->", "id_user", "=", "$", "this", "->", "user", "->", "get_id", "(", ")", ";",...
Sets the user variables using a user object @param bbn\user $user @return preferences
[ "Sets", "the", "user", "variables", "using", "a", "user", "object" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L84-L90
nabab/bbn
src/bbn/user/preferences.php
preferences._get_id_option
private function _get_id_option(string $id_option = null): ?string { if ( !$id_option && !($id_option = $this->get_current()) ){ return null; } if ( $id_option && !bbn\str::is_uid($id_option) ){ $id_option = $this->opt->from_path(...\func_get_args()); } if ( $id_option && bbn\str::is_u...
php
private function _get_id_option(string $id_option = null): ?string { if ( !$id_option && !($id_option = $this->get_current()) ){ return null; } if ( $id_option && !bbn\str::is_uid($id_option) ){ $id_option = $this->opt->from_path(...\func_get_args()); } if ( $id_option && bbn\str::is_u...
[ "private", "function", "_get_id_option", "(", "string", "$", "id_option", "=", "null", ")", ":", "?", "string", "{", "if", "(", "!", "$", "id_option", "&&", "!", "(", "$", "id_option", "=", "$", "this", "->", "get_current", "(", ")", ")", ")", "{", ...
Retrieves or confirm the ID of an option based on the same parameters as options::from_path @param string|null $id_option @return null|string
[ "Retrieves", "or", "confirm", "the", "ID", "of", "an", "option", "based", "on", "the", "same", "parameters", "as", "options", "::", "from_path" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L98-L110
nabab/bbn
src/bbn/user/preferences.php
preferences._insert
private function _insert(string $id_option, array $cfg): int { $json = ($tmp = $this->get_cfg(false, $cfg)) ? json_encode($tmp) : NULL; return $this->db->insert($this->class_cfg['table'], [ $this->fields['id_option'] => $id_option, $this->fields['num'] => $cfg[$this->fields['num']] ?? NULL, ...
php
private function _insert(string $id_option, array $cfg): int { $json = ($tmp = $this->get_cfg(false, $cfg)) ? json_encode($tmp) : NULL; return $this->db->insert($this->class_cfg['table'], [ $this->fields['id_option'] => $id_option, $this->fields['num'] => $cfg[$this->fields['num']] ?? NULL, ...
[ "private", "function", "_insert", "(", "string", "$", "id_option", ",", "array", "$", "cfg", ")", ":", "int", "{", "$", "json", "=", "(", "$", "tmp", "=", "$", "this", "->", "get_cfg", "(", "false", ",", "$", "cfg", ")", ")", "?", "json_encode", ...
Actually inserts a row into the preferences table @param string $id_option @param array $cfg @return int
[ "Actually", "inserts", "a", "row", "into", "the", "preferences", "table" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L119-L131
nabab/bbn
src/bbn/user/preferences.php
preferences._retrieve_ids
private function _retrieve_ids(string $id_option = null, string $id_user = null, string $id_group = null): ?array { if ( ($id_user || $id_group) && ($id_option = $this->_get_id_option($id_option)) ){ $col_id = $this->db->csn($this->fields['id'], true); $table = $this->db->tsn($this->class_cfg['table']...
php
private function _retrieve_ids(string $id_option = null, string $id_user = null, string $id_group = null): ?array { if ( ($id_user || $id_group) && ($id_option = $this->_get_id_option($id_option)) ){ $col_id = $this->db->csn($this->fields['id'], true); $table = $this->db->tsn($this->class_cfg['table']...
[ "private", "function", "_retrieve_ids", "(", "string", "$", "id_option", "=", "null", ",", "string", "$", "id_user", "=", "null", ",", "string", "$", "id_group", "=", "null", ")", ":", "?", "array", "{", "if", "(", "(", "$", "id_user", "||", "$", "id...
Returns preferences' IDs from the option's ID @param null|string $id_option @param null|string $id_user @param null|string $id_group @return array|null
[ "Returns", "preferences", "IDs", "from", "the", "option", "s", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L141-L178
nabab/bbn
src/bbn/user/preferences.php
preferences._get_links
private function _get_links(string $id_link, string $id_user = null, string $id_group = null): ?array { if ( $id_link = $this->_get_id_option($id_link) ){ $where = [ 'logic' => 'AND', 'conditions' => [ [ 'field' => $this->fields['id_link'], 'operator' => '='...
php
private function _get_links(string $id_link, string $id_user = null, string $id_group = null): ?array { if ( $id_link = $this->_get_id_option($id_link) ){ $where = [ 'logic' => 'AND', 'conditions' => [ [ 'field' => $this->fields['id_link'], 'operator' => '='...
[ "private", "function", "_get_links", "(", "string", "$", "id_link", ",", "string", "$", "id_user", "=", "null", ",", "string", "$", "id_group", "=", "null", ")", ":", "?", "array", "{", "if", "(", "$", "id_link", "=", "$", "this", "->", "_get_id_option...
Gets the preferences which have the option's $id as id_link @param string $id_link @return array|null
[ "Gets", "the", "preferences", "which", "have", "the", "option", "s", "$id", "as", "id_link" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L186-L221
nabab/bbn
src/bbn/user/preferences.php
preferences.retrieve_ids
public function retrieve_ids(string $id_option = null): ?array { return $this->_retrieve_ids($id_option, $this->id_user, $this->id_group); }
php
public function retrieve_ids(string $id_option = null): ?array { return $this->_retrieve_ids($id_option, $this->id_user, $this->id_group); }
[ "public", "function", "retrieve_ids", "(", "string", "$", "id_option", "=", "null", ")", ":", "?", "array", "{", "return", "$", "this", "->", "_retrieve_ids", "(", "$", "id_option", ",", "$", "this", "->", "id_user", ",", "$", "this", "->", "id_group", ...
Returns preferences' IDs from the option's ID @param null|string $id_option @return null|array
[ "Returns", "preferences", "IDs", "from", "the", "option", "s", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L262-L265
nabab/bbn
src/bbn/user/preferences.php
preferences.retrieve_user_ids
public function retrieve_user_ids(string $id_option = null, string $id_user): ?array { return $this->_retrieve_ids($id_option, $id_user); }
php
public function retrieve_user_ids(string $id_option = null, string $id_user): ?array { return $this->_retrieve_ids($id_option, $id_user); }
[ "public", "function", "retrieve_user_ids", "(", "string", "$", "id_option", "=", "null", ",", "string", "$", "id_user", ")", ":", "?", "array", "{", "return", "$", "this", "->", "_retrieve_ids", "(", "$", "id_option", ",", "$", "id_user", ")", ";", "}" ]
Returns preferences' IDs from the option's ID and the given user ID @param null|string $id_option @param string $id_user @return array|null
[ "Returns", "preferences", "IDs", "from", "the", "option", "s", "ID", "and", "the", "given", "user", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L274-L277
nabab/bbn
src/bbn/user/preferences.php
preferences.retrieve_group_ids
public function retrieve_group_ids(string $id_option = null, string $id_group): ?array { return $this->_retrieve_ids($id_option, null, $id_group); }
php
public function retrieve_group_ids(string $id_option = null, string $id_group): ?array { return $this->_retrieve_ids($id_option, null, $id_group); }
[ "public", "function", "retrieve_group_ids", "(", "string", "$", "id_option", "=", "null", ",", "string", "$", "id_group", ")", ":", "?", "array", "{", "return", "$", "this", "->", "_retrieve_ids", "(", "$", "id_option", ",", "null", ",", "$", "id_group", ...
Returns preferences' IDs from the option's ID and the given group ID @param null|string $id_option @param string $id_group @return array|null
[ "Returns", "preferences", "IDs", "from", "the", "option", "s", "ID", "and", "the", "given", "group", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L286-L289
nabab/bbn
src/bbn/user/preferences.php
preferences.has
public function has(string $id_option = null, bool $force = false): bool { if ( !$force && $this->user->is_dev() ){ return true; } return (bool)$this->retrieve_ids($id_option); }
php
public function has(string $id_option = null, bool $force = false): bool { if ( !$force && $this->user->is_dev() ){ return true; } return (bool)$this->retrieve_ids($id_option); }
[ "public", "function", "has", "(", "string", "$", "id_option", "=", "null", ",", "bool", "$", "force", "=", "false", ")", ":", "bool", "{", "if", "(", "!", "$", "force", "&&", "$", "this", "->", "user", "->", "is_dev", "(", ")", ")", "{", "return"...
Returns true if the current user can access a preference, false otherwise @param string|null $id_option @param bool $force @return bool
[ "Returns", "true", "if", "the", "current", "user", "can", "access", "a", "preference", "false", "otherwise" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L298-L304
nabab/bbn
src/bbn/user/preferences.php
preferences.user_has
public function user_has(string $id_option, string $id_user): bool { return (bool)$this->_retrieve_ids($id_option, $id_user); }
php
public function user_has(string $id_option, string $id_user): bool { return (bool)$this->_retrieve_ids($id_option, $id_user); }
[ "public", "function", "user_has", "(", "string", "$", "id_option", ",", "string", "$", "id_user", ")", ":", "bool", "{", "return", "(", "bool", ")", "$", "this", "->", "_retrieve_ids", "(", "$", "id_option", ",", "$", "id_user", ")", ";", "}" ]
Checks if a user has the given preference @param string $id_option @param string $id_user @return bool
[ "Checks", "if", "a", "user", "has", "the", "given", "preference" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L313-L316
nabab/bbn
src/bbn/user/preferences.php
preferences.group_has
public function group_has(string $id_option, string $id_group): bool { return (bool)$this->_retrieve_ids($id_option, null, $id_group); }
php
public function group_has(string $id_option, string $id_group): bool { return (bool)$this->_retrieve_ids($id_option, null, $id_group); }
[ "public", "function", "group_has", "(", "string", "$", "id_option", ",", "string", "$", "id_group", ")", ":", "bool", "{", "return", "(", "bool", ")", "$", "this", "->", "_retrieve_ids", "(", "$", "id_option", ",", "null", ",", "$", "id_group", ")", ";...
Checks if a group has the given preference @param string $id_option @param string $id_group @return bool
[ "Checks", "if", "a", "group", "has", "the", "given", "preference" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L325-L328
nabab/bbn
src/bbn/user/preferences.php
preferences.get_cfg
public function get_cfg(string $id = null, array $cfg = null): ?array { if ( (null !== $cfg) || ($cfg = $this->db->select_one( $this->class_cfg['table'], $this->fields['cfg'], [$this->fields['id'] => $id ] )) ){ if ( bbn\str::is_json($cfg) ){ $cfg = json...
php
public function get_cfg(string $id = null, array $cfg = null): ?array { if ( (null !== $cfg) || ($cfg = $this->db->select_one( $this->class_cfg['table'], $this->fields['cfg'], [$this->fields['id'] => $id ] )) ){ if ( bbn\str::is_json($cfg) ){ $cfg = json...
[ "public", "function", "get_cfg", "(", "string", "$", "id", "=", "null", ",", "array", "$", "cfg", "=", "null", ")", ":", "?", "array", "{", "if", "(", "(", "null", "!==", "$", "cfg", ")", "||", "(", "$", "cfg", "=", "$", "this", "->", "db", "...
Gets the cfg array, normalized either from the DB or from the $cfg argument @param string $id @param null|array $cfg @return null|array
[ "Gets", "the", "cfg", "array", "normalized", "either", "from", "the", "DB", "or", "from", "the", "$cfg", "argument" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L363-L387
nabab/bbn
src/bbn/user/preferences.php
preferences.get_cfg_by_option
public function get_cfg_by_option(string $id_option, string $id_user = null): ?array { if ( ($cfg = $this->db->select_one( $this->class_cfg['table'], $this->fields['cfg'], [ $this->fields['id_option'] => $id_option, $this->fields['id_user'] => $id_user ?: $this->i...
php
public function get_cfg_by_option(string $id_option, string $id_user = null): ?array { if ( ($cfg = $this->db->select_one( $this->class_cfg['table'], $this->fields['cfg'], [ $this->fields['id_option'] => $id_option, $this->fields['id_user'] => $id_user ?: $this->i...
[ "public", "function", "get_cfg_by_option", "(", "string", "$", "id_option", ",", "string", "$", "id_user", "=", "null", ")", ":", "?", "array", "{", "if", "(", "(", "$", "cfg", "=", "$", "this", "->", "db", "->", "select_one", "(", "$", "this", "->",...
Gets the cfg array, normalized either from the DB or from the $cfg argument @param string $id @param null|array $cfg @return null|array
[ "Gets", "the", "cfg", "array", "normalized", "either", "from", "the", "DB", "or", "from", "the", "$cfg", "argument" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L396-L414
nabab/bbn
src/bbn/user/preferences.php
preferences.get_links
public function get_links(string $id): ?array { return $this->_get_links($id, $this->id_user, $this->id_group); }
php
public function get_links(string $id): ?array { return $this->_get_links($id, $this->id_user, $this->id_group); }
[ "public", "function", "get_links", "(", "string", "$", "id", ")", ":", "?", "array", "{", "return", "$", "this", "->", "_get_links", "(", "$", "id", ",", "$", "this", "->", "id_user", ",", "$", "this", "->", "id_group", ")", ";", "}" ]
Gets the preferences which have the option's $id as id_link @param string $id @return array|null
[ "Gets", "the", "preferences", "which", "have", "the", "option", "s", "$id", "as", "id_link" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L422-L425
nabab/bbn
src/bbn/user/preferences.php
preferences.get
public function get(string $id, bool $with_config = true): ?array { if ( bbn\str::is_uid($id) ){ $cols = implode(', ', array_map(function($a){ return $a; }, $this->fields)); $table = $this->db->tsn($this->class_cfg['table'], true); $uid = $this->db->csn($this->fields['id'], true); ...
php
public function get(string $id, bool $with_config = true): ?array { if ( bbn\str::is_uid($id) ){ $cols = implode(', ', array_map(function($a){ return $a; }, $this->fields)); $table = $this->db->tsn($this->class_cfg['table'], true); $uid = $this->db->csn($this->fields['id'], true); ...
[ "public", "function", "get", "(", "string", "$", "id", ",", "bool", "$", "with_config", "=", "true", ")", ":", "?", "array", "{", "if", "(", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", ")", "{", "$", "cols", "=", "implode", "(", "'...
Returns the current user's preference based on the given id, his own profile and his group's @param string $id @param bool $with_config @return array|null
[ "Returns", "the", "current", "user", "s", "preference", "based", "on", "the", "given", "id", "his", "own", "profile", "and", "his", "group", "s" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L433-L462
nabab/bbn
src/bbn/user/preferences.php
preferences.get_all
public function get_all(string $id_option = null, bool $with_config = true): ?array { if ( $id_option = $this->_get_id_option($id_option) ){ $fields = $this->fields; if ( !$with_config ){ unset($fields['cfg']); } $table = $this->db->tsn($this->class_table, true); $cols = imp...
php
public function get_all(string $id_option = null, bool $with_config = true): ?array { if ( $id_option = $this->_get_id_option($id_option) ){ $fields = $this->fields; if ( !$with_config ){ unset($fields['cfg']); } $table = $this->db->tsn($this->class_table, true); $cols = imp...
[ "public", "function", "get_all", "(", "string", "$", "id_option", "=", "null", ",", "bool", "$", "with_config", "=", "true", ")", ":", "?", "array", "{", "if", "(", "$", "id_option", "=", "$", "this", "->", "_get_id_option", "(", "$", "id_option", ")",...
Returns an array of the current user's preferences based on the given id_option, his own profile and his group's @param null|string $id_option @param bool $with_config @return array|null
[ "Returns", "an", "array", "of", "the", "current", "user", "s", "preferences", "based", "on", "the", "given", "id_option", "his", "own", "profile", "and", "his", "group", "s" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L470-L513
nabab/bbn
src/bbn/user/preferences.php
preferences.set_by_option
public function set_by_option(string $id_option, array $cfg): int { if ( $id = $this->retrieve_user_ids($id_option, $this->id_user) ){ return $this->set($id[0], $cfg); } return $this->_insert($id_option, $cfg); }
php
public function set_by_option(string $id_option, array $cfg): int { if ( $id = $this->retrieve_user_ids($id_option, $this->id_user) ){ return $this->set($id[0], $cfg); } return $this->_insert($id_option, $cfg); }
[ "public", "function", "set_by_option", "(", "string", "$", "id_option", ",", "array", "$", "cfg", ")", ":", "int", "{", "if", "(", "$", "id", "=", "$", "this", "->", "retrieve_user_ids", "(", "$", "id_option", ",", "$", "this", "->", "id_user", ")", ...
Sets the permission row for the current user by the option's ID @param string $id_option @param array $cfg @return int
[ "Sets", "the", "permission", "row", "for", "the", "current", "user", "by", "the", "option", "s", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L643-L649
nabab/bbn
src/bbn/user/preferences.php
preferences.set
public function set(string $id, array $cfg = null): int { return $this->db->update($this->class_cfg['table'], [ $this->fields['cfg'] => $cfg ? json_encode($this->get_cfg(false, $cfg)) : null ], [ $this->fields['id'] => $id ]); }
php
public function set(string $id, array $cfg = null): int { return $this->db->update($this->class_cfg['table'], [ $this->fields['cfg'] => $cfg ? json_encode($this->get_cfg(false, $cfg)) : null ], [ $this->fields['id'] => $id ]); }
[ "public", "function", "set", "(", "string", "$", "id", ",", "array", "$", "cfg", "=", "null", ")", ":", "int", "{", "return", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'table'", "]", ",", "[", "$", "this"...
Sets the permission config for the current user by the preference's ID @param string $id @param array $cfg @return int
[ "Sets", "the", "permission", "config", "for", "the", "current", "user", "by", "the", "preference", "s", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L658-L665
nabab/bbn
src/bbn/user/preferences.php
preferences.update
public function update(string $id, array $cfg): int { return $this->db->update($this->class_cfg['table'], [ $this->fields['text'] => $cfg[$this->fields['text']] ?? NULL, $this->fields['num'] => $cfg[$this->fields['num']] ?? NULL, $this->fields['id_link'] => $cfg[$this->fields['id_link']] ?? NULL...
php
public function update(string $id, array $cfg): int { return $this->db->update($this->class_cfg['table'], [ $this->fields['text'] => $cfg[$this->fields['text']] ?? NULL, $this->fields['num'] => $cfg[$this->fields['num']] ?? NULL, $this->fields['id_link'] => $cfg[$this->fields['id_link']] ?? NULL...
[ "public", "function", "update", "(", "string", "$", "id", ",", "array", "$", "cfg", ")", ":", "int", "{", "return", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'table'", "]", ",", "[", "$", "this", "->", "f...
Sets the permission row for the current user by the preference's ID @param string $id @param array $cfg @return int
[ "Sets", "the", "permission", "row", "for", "the", "current", "user", "by", "the", "preference", "s", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L674-L686
nabab/bbn
src/bbn/user/preferences.php
preferences.add
public function add(string $id_option = null, array $cfg): ?string { return ( ($id_option = $this->_get_id_option($id_option)) && $this->_insert($id_option, $cfg) ) ? $this->db->last_id() : null; }
php
public function add(string $id_option = null, array $cfg): ?string { return ( ($id_option = $this->_get_id_option($id_option)) && $this->_insert($id_option, $cfg) ) ? $this->db->last_id() : null; }
[ "public", "function", "add", "(", "string", "$", "id_option", "=", "null", ",", "array", "$", "cfg", ")", ":", "?", "string", "{", "return", "(", "(", "$", "id_option", "=", "$", "this", "->", "_get_id_option", "(", "$", "id_option", ")", ")", "&&", ...
Adds a new preference for the given option for the current user. @param null|string $id_option @param array $cfg @return null|string
[ "Adds", "a", "new", "preference", "for", "the", "given", "option", "for", "the", "current", "user", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L703-L709
nabab/bbn
src/bbn/user/preferences.php
preferences.delete
public function delete($id): ?int { return $this->db->delete($this->class_cfg['table'], [$this->fields['id'] => $id]); }
php
public function delete($id): ?int { return $this->db->delete($this->class_cfg['table'], [$this->fields['id'] => $id]); }
[ "public", "function", "delete", "(", "$", "id", ")", ":", "?", "int", "{", "return", "$", "this", "->", "db", "->", "delete", "(", "$", "this", "->", "class_cfg", "[", "'table'", "]", ",", "[", "$", "this", "->", "fields", "[", "'id'", "]", "=>",...
Deletes the given permission @param $id @return int|null
[ "Deletes", "the", "given", "permission" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L717-L720
nabab/bbn
src/bbn/user/preferences.php
preferences.delete_user_option
public function delete_user_option(string $id_option, string $id_user = null): ?int { if ( $id_option = $this->_get_id_option($id_option) ){ return $this->db->delete($this->class_cfg['table'], [ $this->fields['id_option'] => $id_option, $this->fields['id_user'] => $id_user ?: $this->id_user ...
php
public function delete_user_option(string $id_option, string $id_user = null): ?int { if ( $id_option = $this->_get_id_option($id_option) ){ return $this->db->delete($this->class_cfg['table'], [ $this->fields['id_option'] => $id_option, $this->fields['id_user'] => $id_user ?: $this->id_user ...
[ "public", "function", "delete_user_option", "(", "string", "$", "id_option", ",", "string", "$", "id_user", "=", "null", ")", ":", "?", "int", "{", "if", "(", "$", "id_option", "=", "$", "this", "->", "_get_id_option", "(", "$", "id_option", ")", ")", ...
Deletes all the given or current user's permissions for the given option @param null|string $id_option @param null|string $id_user @return null|int
[ "Deletes", "all", "the", "given", "or", "current", "user", "s", "permissions", "for", "the", "given", "option" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L729-L738
nabab/bbn
src/bbn/user/preferences.php
preferences.delete_group_option
public function delete_group_option(string $id_option, string $id_group): ?int { if ( $id_option = $this->_get_id_option($id_option) ){ return $this->db->delete($this->class_cfg['table'], [ $this->fields['id_option'] => $id_option, $this->fields['id_group'] => $id_group ]); } r...
php
public function delete_group_option(string $id_option, string $id_group): ?int { if ( $id_option = $this->_get_id_option($id_option) ){ return $this->db->delete($this->class_cfg['table'], [ $this->fields['id_option'] => $id_option, $this->fields['id_group'] => $id_group ]); } r...
[ "public", "function", "delete_group_option", "(", "string", "$", "id_option", ",", "string", "$", "id_group", ")", ":", "?", "int", "{", "if", "(", "$", "id_option", "=", "$", "this", "->", "_get_id_option", "(", "$", "id_option", ")", ")", "{", "return"...
Deletes all the given group's permissions for the given option @param null|string $id_option @param string $id_group @return int|null
[ "Deletes", "all", "the", "given", "group", "s", "permissions", "for", "the", "given", "option" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L747-L756
nabab/bbn
src/bbn/user/preferences.php
preferences.set_cfg
public function set_cfg(string $id = null, array $cfg = null): int { if ( null !== $cfg ){ $cfg = $this->get_cfg(null, $cfg); $config = json_encode($cfg); } else{ $config = null; } return $this->db->update($this->class_cfg['table'], [ $this->fields['cfg'] => $config ], ...
php
public function set_cfg(string $id = null, array $cfg = null): int { if ( null !== $cfg ){ $cfg = $this->get_cfg(null, $cfg); $config = json_encode($cfg); } else{ $config = null; } return $this->db->update($this->class_cfg['table'], [ $this->fields['cfg'] => $config ], ...
[ "public", "function", "set_cfg", "(", "string", "$", "id", "=", "null", ",", "array", "$", "cfg", "=", "null", ")", ":", "int", "{", "if", "(", "null", "!==", "$", "cfg", ")", "{", "$", "cfg", "=", "$", "this", "->", "get_cfg", "(", "null", ","...
Sets (or unsets) the cfg field of a given preference based on its ID @param string $id @param null|array $cfg @return int
[ "Sets", "(", "or", "unsets", ")", "the", "cfg", "field", "of", "a", "given", "preference", "based", "on", "its", "ID" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L765-L779
nabab/bbn
src/bbn/user/preferences.php
preferences.set_text
public function set_text(string $id, string $text = null): ?int { return $this->db->update($this->class_cfg['table'], [ $this->fields['text'] => $text ], [ $this->fields['id'] => $id ]); }
php
public function set_text(string $id, string $text = null): ?int { return $this->db->update($this->class_cfg['table'], [ $this->fields['text'] => $text ], [ $this->fields['id'] => $id ]); }
[ "public", "function", "set_text", "(", "string", "$", "id", ",", "string", "$", "text", "=", "null", ")", ":", "?", "int", "{", "return", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'table'", "]", ",", "[", ...
Sets (or unsets) the text field of the given preference and returns the result of the executed query @param string $id @param null|string $text @return null|int
[ "Sets", "(", "or", "unsets", ")", "the", "text", "field", "of", "the", "given", "preference", "and", "returns", "the", "result", "of", "the", "executed", "query" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L788-L795
nabab/bbn
src/bbn/user/preferences.php
preferences.set_link
public function set_link(string $id, string $id_link = null): ?int { return $this->db->update($this->class_cfg['table'], [ $this->fields['id_link'] => $id_link ], [ $this->fields['id'] => $id ]); }
php
public function set_link(string $id, string $id_link = null): ?int { return $this->db->update($this->class_cfg['table'], [ $this->fields['id_link'] => $id_link ], [ $this->fields['id'] => $id ]); }
[ "public", "function", "set_link", "(", "string", "$", "id", ",", "string", "$", "id_link", "=", "null", ")", ":", "?", "int", "{", "return", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "class_cfg", "[", "'table'", "]", ",", "["...
Sets (or unsets) the id_link field of the given preference and returns the result of the executed query @param string $id @param string $id_link @return null|int
[ "Sets", "(", "or", "unsets", ")", "the", "id_link", "field", "of", "the", "given", "preference", "and", "returns", "the", "result", "of", "the", "executed", "query" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L804-L811
nabab/bbn
src/bbn/user/preferences.php
preferences.add_link
public function add_link(string $id_option, string $id_link): ?string { $id = $this->db->select_one($this->class_cfg['table'], $this->fields['id'], [ $this->fields['id_user'] => $this->id_user, $this->fields['id_option'] => $id_option ]); if ( $id ){ if ( $this->db->update($this->class_c...
php
public function add_link(string $id_option, string $id_link): ?string { $id = $this->db->select_one($this->class_cfg['table'], $this->fields['id'], [ $this->fields['id_user'] => $this->id_user, $this->fields['id_option'] => $id_option ]); if ( $id ){ if ( $this->db->update($this->class_c...
[ "public", "function", "add_link", "(", "string", "$", "id_option", ",", "string", "$", "id_link", ")", ":", "?", "string", "{", "$", "id", "=", "$", "this", "->", "db", "->", "select_one", "(", "$", "this", "->", "class_cfg", "[", "'table'", "]", ","...
Sets (or unsets) the id_link field of the given preference and returns the result of the executed query @param string $id_option @param string $id_link @return null|string The inserted or updated preference's ID
[ "Sets", "(", "or", "unsets", ")", "the", "id_link", "field", "of", "the", "given", "preference", "and", "returns", "the", "result", "of", "the", "executed", "query" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L820-L841
nabab/bbn
src/bbn/user/preferences.php
preferences.get_shared
public function get_shared(string $id): ?array { if ( bbn\str::is_uid($id) ){ return $this->db->rselect_all($this->class_table, [ $this->fields['id'], $this->fields['id_user'], $this->fields['id_group'] ], [ $this->fields['id_alias'] => $id ]); } return nu...
php
public function get_shared(string $id): ?array { if ( bbn\str::is_uid($id) ){ return $this->db->rselect_all($this->class_table, [ $this->fields['id'], $this->fields['id_user'], $this->fields['id_group'] ], [ $this->fields['id_alias'] => $id ]); } return nu...
[ "public", "function", "get_shared", "(", "string", "$", "id", ")", ":", "?", "array", "{", "if", "(", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "db", "->", "rselect_all", "(", "$", "this", "->...
Returns an array @param string $id @return array|null
[ "Returns", "an", "array" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L849-L861
nabab/bbn
src/bbn/user/preferences.php
preferences.make_public
public function make_public(string $id, bool $cancel = false): ?int { if ( $cfg = $this->get($id) ){ return $this->db->update($this->class_table, ['public' => $cancel ? 0 : 1], [ $this->fields['id'] => $id ]); } return null; }
php
public function make_public(string $id, bool $cancel = false): ?int { if ( $cfg = $this->get($id) ){ return $this->db->update($this->class_table, ['public' => $cancel ? 0 : 1], [ $this->fields['id'] => $id ]); } return null; }
[ "public", "function", "make_public", "(", "string", "$", "id", ",", "bool", "$", "cancel", "=", "false", ")", ":", "?", "int", "{", "if", "(", "$", "cfg", "=", "$", "this", "->", "get", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->"...
Makes (or unmakes) the given preference public. @param string $id @param bool $cancel @return int|null
[ "Makes", "(", "or", "unmakes", ")", "the", "given", "preference", "public", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L870-L878
nabab/bbn
src/bbn/user/preferences.php
preferences.share_with_group
public function share_with_group(string $id, string $id_group, bool $cancel = false): ?int { if ( $cfg = $this->get($id) ){ $id_share = $this->db->select_one($this->class_table, $this->fields['id'], [ 'id_alias' => $id, 'id_group' => $id_group ]); if ( $cancel && $id_share ){ ...
php
public function share_with_group(string $id, string $id_group, bool $cancel = false): ?int { if ( $cfg = $this->get($id) ){ $id_share = $this->db->select_one($this->class_table, $this->fields['id'], [ 'id_alias' => $id, 'id_group' => $id_group ]); if ( $cancel && $id_share ){ ...
[ "public", "function", "share_with_group", "(", "string", "$", "id", ",", "string", "$", "id_group", ",", "bool", "$", "cancel", "=", "false", ")", ":", "?", "int", "{", "if", "(", "$", "cfg", "=", "$", "this", "->", "get", "(", "$", "id", ")", ")...
Shares (or unshares) the given preference to the given group. @param string $id @param string $id_group @param bool $cancel @return int|null
[ "Shares", "(", "or", "unshares", ")", "the", "given", "preference", "to", "the", "given", "group", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L888-L909
nabab/bbn
src/bbn/user/preferences.php
preferences.add_bit
public function add_bit(string $id_usr_opt, array $cfg): ?string { if ( ($id_usr_opt = $this->_get_id_option($id_usr_opt)) && ($c = $this->class_cfg['arch']['user_options_bits']) ){ $to_cfg = $this->get_bit_cfg(null, $cfg); if ( isset($to_cfg['items']) ){ unset($to_cfg['items']...
php
public function add_bit(string $id_usr_opt, array $cfg): ?string { if ( ($id_usr_opt = $this->_get_id_option($id_usr_opt)) && ($c = $this->class_cfg['arch']['user_options_bits']) ){ $to_cfg = $this->get_bit_cfg(null, $cfg); if ( isset($to_cfg['items']) ){ unset($to_cfg['items']...
[ "public", "function", "add_bit", "(", "string", "$", "id_usr_opt", ",", "array", "$", "cfg", ")", ":", "?", "string", "{", "if", "(", "(", "$", "id_usr_opt", "=", "$", "this", "->", "_get_id_option", "(", "$", "id_usr_opt", ")", ")", "&&", "(", "$", ...
Adds a bit to a preference @param string $id_usr_opt The preference's ID @param array $cfg The bit's values @return string|null
[ "Adds", "a", "bit", "to", "a", "preference" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L948-L987
nabab/bbn
src/bbn/user/preferences.php
preferences.delete_bit
public function delete_bit(string $id): ?int { if ( \bbn\str::is_uid($id) ){ return $this->db->delete($this->class_cfg['tables']['user_options_bits'], [ $this->class_cfg['arch']['user_options_bits']['id'] => $id ]); } return null; }
php
public function delete_bit(string $id): ?int { if ( \bbn\str::is_uid($id) ){ return $this->db->delete($this->class_cfg['tables']['user_options_bits'], [ $this->class_cfg['arch']['user_options_bits']['id'] => $id ]); } return null; }
[ "public", "function", "delete_bit", "(", "string", "$", "id", ")", ":", "?", "int", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", ")", "{", "return", "$", "this", "->", "db", "->", "delete", "(", "$", "this", "-...
Deletes a preference's bit @param string The bit's ID @return int|null
[ "Deletes", "a", "preference", "s", "bit" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L996-L1004
nabab/bbn
src/bbn/user/preferences.php
preferences.update_bit
public function update_bit(string $id, array $cfg, $merge_config = false): ?int { if ( \bbn\str::is_uid($id) ){ $c = $this->class_cfg['arch']['user_options_bits']; $fields = array_values($c); if ( \array_key_exists($c['id'], $cfg) ){ unset($cfg[$c['id']]); } $to_cfg = $this->...
php
public function update_bit(string $id, array $cfg, $merge_config = false): ?int { if ( \bbn\str::is_uid($id) ){ $c = $this->class_cfg['arch']['user_options_bits']; $fields = array_values($c); if ( \array_key_exists($c['id'], $cfg) ){ unset($cfg[$c['id']]); } $to_cfg = $this->...
[ "public", "function", "update_bit", "(", "string", "$", "id", ",", "array", "$", "cfg", ",", "$", "merge_config", "=", "false", ")", ":", "?", "int", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", ")", "{", "$", ...
Updates a preference's bit @param string $id The bit's ID @param array The bit's values @return int|null
[ "Updates", "a", "preference", "s", "bit" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1013-L1053
nabab/bbn
src/bbn/user/preferences.php
preferences.get_bit
public function get_bit(string $id, bool $with_config = true): array { if ( \bbn\str::is_uid($id) && ($bit = $this->db->rselect($this->class_cfg['tables']['user_options_bits'], [], [ $this->class_cfg['arch']['user_options_bits']['id'] => $id ])) ){ if ( !empty($with_config) ){ ...
php
public function get_bit(string $id, bool $with_config = true): array { if ( \bbn\str::is_uid($id) && ($bit = $this->db->rselect($this->class_cfg['tables']['user_options_bits'], [], [ $this->class_cfg['arch']['user_options_bits']['id'] => $id ])) ){ if ( !empty($with_config) ){ ...
[ "public", "function", "get_bit", "(", "string", "$", "id", ",", "bool", "$", "with_config", "=", "true", ")", ":", "array", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", "&&", "(", "$", "bit", "=", "$", "this", ...
Returns a single preference's bit @param string $id The bit's ID @return array
[ "Returns", "a", "single", "preference", "s", "bit" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1061-L1075
nabab/bbn
src/bbn/user/preferences.php
preferences.get_bits
public function get_bits(string $id_usr_opt, $id_parent = false, bool $with_config = true): array { $c = $this->class_cfg['arch']['user_options_bits']; $t = $this; $where = [ $c['id_user_option'] => $id_usr_opt ]; if ( is_null($id_parent) || \bbn\str::is_uid($id_parent) ){ $where[$c['i...
php
public function get_bits(string $id_usr_opt, $id_parent = false, bool $with_config = true): array { $c = $this->class_cfg['arch']['user_options_bits']; $t = $this; $where = [ $c['id_user_option'] => $id_usr_opt ]; if ( is_null($id_parent) || \bbn\str::is_uid($id_parent) ){ $where[$c['i...
[ "public", "function", "get_bits", "(", "string", "$", "id_usr_opt", ",", "$", "id_parent", "=", "false", ",", "bool", "$", "with_config", "=", "true", ")", ":", "array", "{", "$", "c", "=", "$", "this", "->", "class_cfg", "[", "'arch'", "]", "[", "'u...
Returns the bits list of a preference @param string $id The preference's ID @param null|string $id_parent The bits'parent ID @return array
[ "Returns", "the", "bits", "list", "of", "a", "preference" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1084-L1106
nabab/bbn
src/bbn/user/preferences.php
preferences.get_full_bits
public function get_full_bits(string $id_usr_opt, string $id_parent = null, bool $with_config = true): array { if ( \bbn\str::is_uid($id_usr_opt) ){ $c = $this->class_cfg['arch']['user_options_bits']; $t = $this; return array_map(function($b) use($t, $c, $id_usr_opt, $with_config){ if ( ...
php
public function get_full_bits(string $id_usr_opt, string $id_parent = null, bool $with_config = true): array { if ( \bbn\str::is_uid($id_usr_opt) ){ $c = $this->class_cfg['arch']['user_options_bits']; $t = $this; return array_map(function($b) use($t, $c, $id_usr_opt, $with_config){ if ( ...
[ "public", "function", "get_full_bits", "(", "string", "$", "id_usr_opt", ",", "string", "$", "id_parent", "=", "null", ",", "bool", "$", "with_config", "=", "true", ")", ":", "array", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", ...
Returns the hierarchical bits list of a preference @param string $id_usr_opt The preference's ID @param string $id_parent The parent's ID of a bit. Default: null @param bool $with_config Set it to false if you don't want the preference's cfg field values on the results. @return array
[ "Returns", "the", "hierarchical", "bits", "list", "of", "a", "preference" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1116-L1143
nabab/bbn
src/bbn/user/preferences.php
preferences.get_tree
public function get_tree(string $id, bool $with_config = true): array { if ( \bbn\str::is_uid($id) && ($p = $this->get($id, $with_config)) ){ $p['items'] = $this->get_full_bits($id, null, $with_config); return $p; } return []; }
php
public function get_tree(string $id, bool $with_config = true): array { if ( \bbn\str::is_uid($id) && ($p = $this->get($id, $with_config)) ){ $p['items'] = $this->get_full_bits($id, null, $with_config); return $p; } return []; }
[ "public", "function", "get_tree", "(", "string", "$", "id", ",", "bool", "$", "with_config", "=", "true", ")", ":", "array", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", "&&", "(", "$", "p", "=", "$", "this", "...
Returns a preference and its hierarchical bits list @param string $id The preference's ID @param bool $with_config Set it to false if you don't want the preference's cfg field values on the results.
[ "Returns", "a", "preference", "and", "its", "hierarchical", "bits", "list" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1151-L1161
nabab/bbn
src/bbn/user/preferences.php
preferences.order_bit
public function order_bit(string $id, int $pos): ?bool { if ( \bbn\str::is_uid($id) && ($cf = $this->get_class_cfg()) && ($cfg = $cf['arch']['user_options_bits']) && ($bit = $this->get_bit($id)) && ($old = (int)$bit[$cfg['num']]) && !empty($pos) && ($old !== $pos) && ...
php
public function order_bit(string $id, int $pos): ?bool { if ( \bbn\str::is_uid($id) && ($cf = $this->get_class_cfg()) && ($cfg = $cf['arch']['user_options_bits']) && ($bit = $this->get_bit($id)) && ($old = (int)$bit[$cfg['num']]) && !empty($pos) && ($old !== $pos) && ...
[ "public", "function", "order_bit", "(", "string", "$", "id", ",", "int", "$", "pos", ")", ":", "?", "bool", "{", "if", "(", "\\", "bbn", "\\", "str", "::", "is_uid", "(", "$", "id", ")", "&&", "(", "$", "cf", "=", "$", "this", "->", "get_class_...
Orders a bit. @param string $id The bit's ID @param int $pos The new position @return bool|null
[ "Orders", "a", "bit", "." ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/user/preferences.php#L1237-L1280