repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
wb-crowdfusion/crowdfusion
system/core/classes/libraries/validation/Errors.php
Errors.hasFieldError
public function hasFieldError($field) { foreach ((array)$this->errors as $err) { if ($err instanceof FieldValidationError) { $tfield = $err->getFieldResolved(); if($tfield == $field) return true; } } return false; }
php
public function hasFieldError($field) { foreach ((array)$this->errors as $err) { if ($err instanceof FieldValidationError) { $tfield = $err->getFieldResolved(); if($tfield == $field) return true; } } return false; }
[ "public", "function", "hasFieldError", "(", "$", "field", ")", "{", "foreach", "(", "(", "array", ")", "$", "this", "->", "errors", "as", "$", "err", ")", "{", "if", "(", "$", "err", "instanceof", "FieldValidationError", ")", "{", "$", "tfield", "=", "$", "err", "->", "getFieldResolved", "(", ")", ";", "if", "(", "$", "tfield", "==", "$", "field", ")", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Determines if an error has occurred for the supplied field already @param $field Field name @return boolean
[ "Determines", "if", "an", "error", "has", "occurred", "for", "the", "supplied", "field", "already" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/validation/Errors.php#L147-L159
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/validation/Errors.php
Errors.getErrorsAsArray
public function getErrorsAsArray() { $errors = array(); $errors['HasErrors'] = $this->hasErrors(); $errors['ErrorCount'] = $this->getErrorCount(); $errors['Errors'] = (array)$this->errors; /* $errors['ErrorString'] = ''; $errors['FieldErrorString'] = ''; $errors['GlobalErrorString'] = ''; $errors['ErrorStringHTML'] = ''; $errors['FieldErrorStringHTML'] = ''; $errors['GlobalErrorStringHTML'] = ''; */ foreach ((array)$this->errors as $err) { if ($err instanceof FieldValidationError) { $field = $err->getFieldResolved(); $errors['Has'.$field.'Error'] = true; // $errors[$field.'ErrorMessage'] = $err->getDefaultErrorMessage(); // $errors[$field.'ErrorCode'] = $err->getErrorCode(); $errors['ErrorFields'][] = $field; $errors['ErrorValues'][] = $err->getValue(); // $errors['FieldErrorString'] .= $err->getDefaultErrorMessage()."\n"; // $errors['FieldErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>'; } else { // $errors['GlobalErrorString'] .= $err->getDefaultErrorMessage()."\n"; // $errors['GlobalErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>'; } $errors['ErrorCodes'][] = $err->getErrorCode(); // $errors['ErrorMessages'][] = $err->getDefaultErrorMessage(); // $errors['ErrorString'] .= $err->getDefaultErrorMessage()."\n"; // $errors['ErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>'; } return $errors; }
php
public function getErrorsAsArray() { $errors = array(); $errors['HasErrors'] = $this->hasErrors(); $errors['ErrorCount'] = $this->getErrorCount(); $errors['Errors'] = (array)$this->errors; /* $errors['ErrorString'] = ''; $errors['FieldErrorString'] = ''; $errors['GlobalErrorString'] = ''; $errors['ErrorStringHTML'] = ''; $errors['FieldErrorStringHTML'] = ''; $errors['GlobalErrorStringHTML'] = ''; */ foreach ((array)$this->errors as $err) { if ($err instanceof FieldValidationError) { $field = $err->getFieldResolved(); $errors['Has'.$field.'Error'] = true; // $errors[$field.'ErrorMessage'] = $err->getDefaultErrorMessage(); // $errors[$field.'ErrorCode'] = $err->getErrorCode(); $errors['ErrorFields'][] = $field; $errors['ErrorValues'][] = $err->getValue(); // $errors['FieldErrorString'] .= $err->getDefaultErrorMessage()."\n"; // $errors['FieldErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>'; } else { // $errors['GlobalErrorString'] .= $err->getDefaultErrorMessage()."\n"; // $errors['GlobalErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>'; } $errors['ErrorCodes'][] = $err->getErrorCode(); // $errors['ErrorMessages'][] = $err->getDefaultErrorMessage(); // $errors['ErrorString'] .= $err->getDefaultErrorMessage()."\n"; // $errors['ErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>'; } return $errors; }
[ "public", "function", "getErrorsAsArray", "(", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "$", "errors", "[", "'HasErrors'", "]", "=", "$", "this", "->", "hasErrors", "(", ")", ";", "$", "errors", "[", "'ErrorCount'", "]", "=", "$", "this", "->", "getErrorCount", "(", ")", ";", "$", "errors", "[", "'Errors'", "]", "=", "(", "array", ")", "$", "this", "->", "errors", ";", "/*\n $errors['ErrorString'] = '';\n $errors['FieldErrorString'] = '';\n $errors['GlobalErrorString'] = '';\n $errors['ErrorStringHTML'] = '';\n $errors['FieldErrorStringHTML'] = '';\n $errors['GlobalErrorStringHTML'] = '';\n\n */", "foreach", "(", "(", "array", ")", "$", "this", "->", "errors", "as", "$", "err", ")", "{", "if", "(", "$", "err", "instanceof", "FieldValidationError", ")", "{", "$", "field", "=", "$", "err", "->", "getFieldResolved", "(", ")", ";", "$", "errors", "[", "'Has'", ".", "$", "field", ".", "'Error'", "]", "=", "true", ";", "// $errors[$field.'ErrorMessage'] = $err->getDefaultErrorMessage();", "// $errors[$field.'ErrorCode'] = $err->getErrorCode();", "$", "errors", "[", "'ErrorFields'", "]", "[", "]", "=", "$", "field", ";", "$", "errors", "[", "'ErrorValues'", "]", "[", "]", "=", "$", "err", "->", "getValue", "(", ")", ";", "// $errors['FieldErrorString'] .= $err->getDefaultErrorMessage().\"\\n\";", "// $errors['FieldErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>';", "}", "else", "{", "// $errors['GlobalErrorString'] .= $err->getDefaultErrorMessage().\"\\n\";", "// $errors['GlobalErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>';", "}", "$", "errors", "[", "'ErrorCodes'", "]", "[", "]", "=", "$", "err", "->", "getErrorCode", "(", ")", ";", "// $errors['ErrorMessages'][] = $err->getDefaultErrorMessage();", "// $errors['ErrorString'] .= $err->getDefaultErrorMessage().\"\\n\";", "// $errors['ErrorStringHTML'] .= $err->getDefaultErrorMessage().'<br/>';", "}", "return", "$", "errors", ";", "}" ]
Extracts the errors from the collection as ValidationErrors into simple arrays @return array
[ "Extracts", "the", "errors", "from", "the", "collection", "as", "ValidationErrors", "into", "simple", "arrays" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/validation/Errors.php#L178-L220
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/validation/Errors.php
Errors.toString
public function toString() { $errorString = ''; foreach ((array)$this->errors as $err) { $errorString .= $err->getDefaultErrorMessage().", "; } return substr($errorString, 0, -2); }
php
public function toString() { $errorString = ''; foreach ((array)$this->errors as $err) { $errorString .= $err->getDefaultErrorMessage().", "; } return substr($errorString, 0, -2); }
[ "public", "function", "toString", "(", ")", "{", "$", "errorString", "=", "''", ";", "foreach", "(", "(", "array", ")", "$", "this", "->", "errors", "as", "$", "err", ")", "{", "$", "errorString", ".=", "$", "err", "->", "getDefaultErrorMessage", "(", ")", ".", "\", \"", ";", "}", "return", "substr", "(", "$", "errorString", ",", "0", ",", "-", "2", ")", ";", "}" ]
Returns a string that's a combination of all errors @return string
[ "Returns", "a", "string", "that", "s", "a", "combination", "of", "all", "errors" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/validation/Errors.php#L227-L234
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/validation/Errors.php
Errors.rejectField
public function rejectField($errorCode, $fieldResolved, $fieldTitle, $value, $message = '') { $this->addFieldError($errorCode, $fieldResolved, 'field', $fieldTitle, $value, $message==''?"$fieldTitle is required.":$message); return $this; }
php
public function rejectField($errorCode, $fieldResolved, $fieldTitle, $value, $message = '') { $this->addFieldError($errorCode, $fieldResolved, 'field', $fieldTitle, $value, $message==''?"$fieldTitle is required.":$message); return $this; }
[ "public", "function", "rejectField", "(", "$", "errorCode", ",", "$", "fieldResolved", ",", "$", "fieldTitle", ",", "$", "value", ",", "$", "message", "=", "''", ")", "{", "$", "this", "->", "addFieldError", "(", "$", "errorCode", ",", "$", "fieldResolved", ",", "'field'", ",", "$", "fieldTitle", ",", "$", "value", ",", "$", "message", "==", "''", "?", "\"$fieldTitle is required.\"", ":", "$", "message", ")", ";", "return", "$", "this", ";", "}" ]
Adds a field error to the specified field @param string $errorCode The error code to use @param string $fieldResolved The machine readable field identifier @param string $fieldTitle The human readable field name @param string $value The value to check @param string $message (optional) A default error message to display if one cannot be located. @return this
[ "Adds", "a", "field", "error", "to", "the", "specified", "field" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/validation/Errors.php#L315-L319
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/validation/Errors.php
Errors.validateModelObject
public function validateModelObject(ModelObject $model) { $fields = $model->getPersistentFields(); foreach ( $fields as $fieldName ) { $value = $model->$fieldName; $fieldResolved = get_class($model).'.'.$fieldName; $this->rejectIfInvalid($fieldResolved, 'field', $model->getFieldTitle($fieldName), $value, new ValidationExpression($model->getValidation($fieldName))); } }
php
public function validateModelObject(ModelObject $model) { $fields = $model->getPersistentFields(); foreach ( $fields as $fieldName ) { $value = $model->$fieldName; $fieldResolved = get_class($model).'.'.$fieldName; $this->rejectIfInvalid($fieldResolved, 'field', $model->getFieldTitle($fieldName), $value, new ValidationExpression($model->getValidation($fieldName))); } }
[ "public", "function", "validateModelObject", "(", "ModelObject", "$", "model", ")", "{", "$", "fields", "=", "$", "model", "->", "getPersistentFields", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", ")", "{", "$", "value", "=", "$", "model", "->", "$", "fieldName", ";", "$", "fieldResolved", "=", "get_class", "(", "$", "model", ")", ".", "'.'", ".", "$", "fieldName", ";", "$", "this", "->", "rejectIfInvalid", "(", "$", "fieldResolved", ",", "'field'", ",", "$", "model", "->", "getFieldTitle", "(", "$", "fieldName", ")", ",", "$", "value", ",", "new", "ValidationExpression", "(", "$", "model", "->", "getValidation", "(", "$", "fieldName", ")", ")", ")", ";", "}", "}" ]
Validates the model object, rejecting the fields that fail validation @param ModelObject $model The object to validate @return void
[ "Validates", "the", "model", "object", "rejecting", "the", "fields", "that", "fail", "validation" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/validation/Errors.php#L366-L381
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.wordsTokenized
public static function wordsTokenized($string) { for ($tokens = array(), $nextToken = strtok($string, ' '); $nextToken !== false; $nextToken = strtok(' ')) { if ($nextToken{0} == '"') $nextToken = $nextToken{strlen($nextToken)-1} == '"' ? '"' . substr($nextToken, 1, -1) . '"' : '"' . substr($nextToken, 1) . ' ' . strtok('"') . '"'; $tokens[] = $nextToken; } return $tokens; }
php
public static function wordsTokenized($string) { for ($tokens = array(), $nextToken = strtok($string, ' '); $nextToken !== false; $nextToken = strtok(' ')) { if ($nextToken{0} == '"') $nextToken = $nextToken{strlen($nextToken)-1} == '"' ? '"' . substr($nextToken, 1, -1) . '"' : '"' . substr($nextToken, 1) . ' ' . strtok('"') . '"'; $tokens[] = $nextToken; } return $tokens; }
[ "public", "static", "function", "wordsTokenized", "(", "$", "string", ")", "{", "for", "(", "$", "tokens", "=", "array", "(", ")", ",", "$", "nextToken", "=", "strtok", "(", "$", "string", ",", "' '", ")", ";", "$", "nextToken", "!==", "false", ";", "$", "nextToken", "=", "strtok", "(", "' '", ")", ")", "{", "if", "(", "$", "nextToken", "{", "0", "}", "==", "'\"'", ")", "$", "nextToken", "=", "$", "nextToken", "{", "strlen", "(", "$", "nextToken", ")", "-", "1", "}", "==", "'\"'", "?", "'\"'", ".", "substr", "(", "$", "nextToken", ",", "1", ",", "-", "1", ")", ".", "'\"'", ":", "'\"'", ".", "substr", "(", "$", "nextToken", ",", "1", ")", ".", "' '", ".", "strtok", "(", "'\"'", ")", ".", "'\"'", ";", "$", "tokens", "[", "]", "=", "$", "nextToken", ";", "}", "return", "$", "tokens", ";", "}" ]
Splits a string into an array, exploded by spaces. However, it takes "quoted strings" into account, will count them as a single item. @param string $string String to split @see http://us2.php.net/manual/en/function.strtok.php#53244 @author brian dot cairns dot remove dot this at commerx dot com @return array An array containing the split words
[ "Splits", "a", "string", "into", "an", "array", "exploded", "by", "spaces", ".", "However", "it", "takes", "quoted", "strings", "into", "account", "will", "count", "them", "as", "a", "single", "item", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L106-L117
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.smartSplit
public static function smartSplit($data, $delimiter = ';', $quote = "'", $escape = "\\'", $limit = null) { $results = array (); // Split like normal to start. $lines = explode($delimiter, $data); if (empty ($lines)) return array (); $broke = false; for ($i = 0; $i < count($lines); $i++) { $line = $lines[$i]; // Now, add each fully quoted line if (!self::lineIsOpenQuoted($line, $quote, $escape)) $results[] = $line; else { // Otherwise, add each new line until we find the first closed line do { $line .= $delimiter . $lines[++ $i]; } while (($i +1) < count($lines) && self::lineIsOpenQuoted($line, $quote, $escape)); $results[] = $line; } } if (!is_null($limit) && count($results) > $limit) { $newresults = array(); for ($i = 0; $i < ($limit-1); $i++) { $newresults[] = array_shift($results); } $newresults[] = implode($delimiter, $results); return $newresults; } return $results; }
php
public static function smartSplit($data, $delimiter = ';', $quote = "'", $escape = "\\'", $limit = null) { $results = array (); // Split like normal to start. $lines = explode($delimiter, $data); if (empty ($lines)) return array (); $broke = false; for ($i = 0; $i < count($lines); $i++) { $line = $lines[$i]; // Now, add each fully quoted line if (!self::lineIsOpenQuoted($line, $quote, $escape)) $results[] = $line; else { // Otherwise, add each new line until we find the first closed line do { $line .= $delimiter . $lines[++ $i]; } while (($i +1) < count($lines) && self::lineIsOpenQuoted($line, $quote, $escape)); $results[] = $line; } } if (!is_null($limit) && count($results) > $limit) { $newresults = array(); for ($i = 0; $i < ($limit-1); $i++) { $newresults[] = array_shift($results); } $newresults[] = implode($delimiter, $results); return $newresults; } return $results; }
[ "public", "static", "function", "smartSplit", "(", "$", "data", ",", "$", "delimiter", "=", "';'", ",", "$", "quote", "=", "\"'\"", ",", "$", "escape", "=", "\"\\\\'\"", ",", "$", "limit", "=", "null", ")", "{", "$", "results", "=", "array", "(", ")", ";", "// Split like normal to start.", "$", "lines", "=", "explode", "(", "$", "delimiter", ",", "$", "data", ")", ";", "if", "(", "empty", "(", "$", "lines", ")", ")", "return", "array", "(", ")", ";", "$", "broke", "=", "false", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "lines", ")", ";", "$", "i", "++", ")", "{", "$", "line", "=", "$", "lines", "[", "$", "i", "]", ";", "// Now, add each fully quoted line", "if", "(", "!", "self", "::", "lineIsOpenQuoted", "(", "$", "line", ",", "$", "quote", ",", "$", "escape", ")", ")", "$", "results", "[", "]", "=", "$", "line", ";", "else", "{", "// Otherwise, add each new line until we find the first closed line", "do", "{", "$", "line", ".=", "$", "delimiter", ".", "$", "lines", "[", "++", "$", "i", "]", ";", "}", "while", "(", "(", "$", "i", "+", "1", ")", "<", "count", "(", "$", "lines", ")", "&&", "self", "::", "lineIsOpenQuoted", "(", "$", "line", ",", "$", "quote", ",", "$", "escape", ")", ")", ";", "$", "results", "[", "]", "=", "$", "line", ";", "}", "}", "if", "(", "!", "is_null", "(", "$", "limit", ")", "&&", "count", "(", "$", "results", ")", ">", "$", "limit", ")", "{", "$", "newresults", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "(", "$", "limit", "-", "1", ")", ";", "$", "i", "++", ")", "{", "$", "newresults", "[", "]", "=", "array_shift", "(", "$", "results", ")", ";", "}", "$", "newresults", "[", "]", "=", "implode", "(", "$", "delimiter", ",", "$", "results", ")", ";", "return", "$", "newresults", ";", "}", "return", "$", "results", ";", "}" ]
Split a string around a delimiter, taking into account quoted substrings @param string $data big string with data @param string $delimiter Field delimiter @param string $quote quote field character @param string $escape escaped quote character @param int $limit Return at most this many parts @return array of all splitted lines
[ "Split", "a", "string", "around", "a", "delimiter", "taking", "into", "account", "quoted", "substrings" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L131-L169
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.lineIsOpenQuoted
public static function lineIsOpenQuoted($line, $quote, $escape) { // Returns TRUE if line is valid $pos = 0; $quote_open = false; $esc_len = strlen($escape); for (; $pos < strlen($line); ++ $pos) { $char = $line[$pos]; // If the character is part of an escape squence, advance the string. if (substr($line, $pos, $esc_len) == $escape) { $pos += $esc_len - 1; // Subtract one because we advance on loop start. continue; } // Otherwise, toggle the quote flag if this is a quote character if ($char == $quote) $quote_open = !$quote_open; // Continue if the character is anything else. } if ($quote_open) return true; else return false; }
php
public static function lineIsOpenQuoted($line, $quote, $escape) { // Returns TRUE if line is valid $pos = 0; $quote_open = false; $esc_len = strlen($escape); for (; $pos < strlen($line); ++ $pos) { $char = $line[$pos]; // If the character is part of an escape squence, advance the string. if (substr($line, $pos, $esc_len) == $escape) { $pos += $esc_len - 1; // Subtract one because we advance on loop start. continue; } // Otherwise, toggle the quote flag if this is a quote character if ($char == $quote) $quote_open = !$quote_open; // Continue if the character is anything else. } if ($quote_open) return true; else return false; }
[ "public", "static", "function", "lineIsOpenQuoted", "(", "$", "line", ",", "$", "quote", ",", "$", "escape", ")", "{", "// Returns TRUE if line is valid", "$", "pos", "=", "0", ";", "$", "quote_open", "=", "false", ";", "$", "esc_len", "=", "strlen", "(", "$", "escape", ")", ";", "for", "(", ";", "$", "pos", "<", "strlen", "(", "$", "line", ")", ";", "++", "$", "pos", ")", "{", "$", "char", "=", "$", "line", "[", "$", "pos", "]", ";", "// If the character is part of an escape squence, advance the string.", "if", "(", "substr", "(", "$", "line", ",", "$", "pos", ",", "$", "esc_len", ")", "==", "$", "escape", ")", "{", "$", "pos", "+=", "$", "esc_len", "-", "1", ";", "// Subtract one because we advance on loop start.", "continue", ";", "}", "// Otherwise, toggle the quote flag if this is a quote character", "if", "(", "$", "char", "==", "$", "quote", ")", "$", "quote_open", "=", "!", "$", "quote_open", ";", "// Continue if the character is anything else.", "}", "if", "(", "$", "quote_open", ")", "return", "true", ";", "else", "return", "false", ";", "}" ]
Determines if a line is "open-quoted" and continues to the next line. Most useful for parsing CSV files. @param string $line The line to examine @param string $quote The quote character (must be one character) @param string $escape The escape character or character set @return void
[ "Determines", "if", "a", "line", "is", "open", "-", "quoted", "and", "continues", "to", "the", "next", "line", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L182-L209
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.smartExplode
public static function smartExplode($string) { if (empty($string)) return array(); if (is_array($string)) return $string; if (!is_array($string)) { if (strpos($string, ';') !== false) return explode(';', trim($string, ';')); if (strpos($string, ',') !== false) return explode(',', trim($string, ',')); } return (array)$string; }
php
public static function smartExplode($string) { if (empty($string)) return array(); if (is_array($string)) return $string; if (!is_array($string)) { if (strpos($string, ';') !== false) return explode(';', trim($string, ';')); if (strpos($string, ',') !== false) return explode(',', trim($string, ',')); } return (array)$string; }
[ "public", "static", "function", "smartExplode", "(", "$", "string", ")", "{", "if", "(", "empty", "(", "$", "string", ")", ")", "return", "array", "(", ")", ";", "if", "(", "is_array", "(", "$", "string", ")", ")", "return", "$", "string", ";", "if", "(", "!", "is_array", "(", "$", "string", ")", ")", "{", "if", "(", "strpos", "(", "$", "string", ",", "';'", ")", "!==", "false", ")", "return", "explode", "(", "';'", ",", "trim", "(", "$", "string", ",", "';'", ")", ")", ";", "if", "(", "strpos", "(", "$", "string", ",", "','", ")", "!==", "false", ")", "return", "explode", "(", "','", ",", "trim", "(", "$", "string", ",", "','", ")", ")", ";", "}", "return", "(", "array", ")", "$", "string", ";", "}" ]
Explodes a string into an array split upon ';' or ',' characters @param string $string The string to *EXPLODE* @return array
[ "Explodes", "a", "string", "into", "an", "array", "split", "upon", ";", "or", "characters" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L366-L383
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.pluralize
public static function pluralize($word) { $plural = array( '/(quiz)$/i' => '\1zes', '/^(ox)$/i' => '\1en', '/([m|l])ouse$/i' => '\1ice', '/(matr|vert|ind)ix|ex$/i' => '\1ices', '/(x|ch|ss|sh)$/i' => '\1es', '/([^aeiouy]|qu)ies$/i' => '\1y', '/([^aeiouy]|qu)y$/i' => '\1ies', '/(hive)$/i' => '\1s', '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', '/sis$/i' => 'ses', '/([ti])um$/i' => '\1a', '/(buffal|tomat)o$/i' => '\1oes', '/(bu)s$/i' => '\1ses', '/(alias|status)/i'=> '\1es', '/(octop|vir)us$/i'=> '\1i', '/(ax|test)is$/i'=> '\1es', '/s$/i'=> 's', '/$/'=> 's'); $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); $irregular = array( 'person' => 'people', 'man' => 'men', 'child' => 'children', 'sex' => 'sexes', 'move' => 'moves'); $lowercased_word = strtolower($word); foreach ($uncountable as $_uncountable) { if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) return $word; } foreach ($irregular as $_plural=> $_singular) { if (preg_match('/('.$_plural.')$/i', $word, $arr)) { return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); } } foreach ($plural as $rule => $replacement) { if (preg_match($rule, $word)) { return preg_replace($rule, $replacement, $word); } } return false; }
php
public static function pluralize($word) { $plural = array( '/(quiz)$/i' => '\1zes', '/^(ox)$/i' => '\1en', '/([m|l])ouse$/i' => '\1ice', '/(matr|vert|ind)ix|ex$/i' => '\1ices', '/(x|ch|ss|sh)$/i' => '\1es', '/([^aeiouy]|qu)ies$/i' => '\1y', '/([^aeiouy]|qu)y$/i' => '\1ies', '/(hive)$/i' => '\1s', '/(?:([^f])fe|([lr])f)$/i' => '\1\2ves', '/sis$/i' => 'ses', '/([ti])um$/i' => '\1a', '/(buffal|tomat)o$/i' => '\1oes', '/(bu)s$/i' => '\1ses', '/(alias|status)/i'=> '\1es', '/(octop|vir)us$/i'=> '\1i', '/(ax|test)is$/i'=> '\1es', '/s$/i'=> 's', '/$/'=> 's'); $uncountable = array('equipment', 'information', 'rice', 'money', 'species', 'series', 'fish', 'sheep'); $irregular = array( 'person' => 'people', 'man' => 'men', 'child' => 'children', 'sex' => 'sexes', 'move' => 'moves'); $lowercased_word = strtolower($word); foreach ($uncountable as $_uncountable) { if (substr($lowercased_word, (-1 * strlen($_uncountable))) == $_uncountable) return $word; } foreach ($irregular as $_plural=> $_singular) { if (preg_match('/('.$_plural.')$/i', $word, $arr)) { return preg_replace('/('.$_plural.')$/i', substr($arr[0], 0, 1) . substr($_singular, 1), $word); } } foreach ($plural as $rule => $replacement) { if (preg_match($rule, $word)) { return preg_replace($rule, $replacement, $word); } } return false; }
[ "public", "static", "function", "pluralize", "(", "$", "word", ")", "{", "$", "plural", "=", "array", "(", "'/(quiz)$/i'", "=>", "'\\1zes'", ",", "'/^(ox)$/i'", "=>", "'\\1en'", ",", "'/([m|l])ouse$/i'", "=>", "'\\1ice'", ",", "'/(matr|vert|ind)ix|ex$/i'", "=>", "'\\1ices'", ",", "'/(x|ch|ss|sh)$/i'", "=>", "'\\1es'", ",", "'/([^aeiouy]|qu)ies$/i'", "=>", "'\\1y'", ",", "'/([^aeiouy]|qu)y$/i'", "=>", "'\\1ies'", ",", "'/(hive)$/i'", "=>", "'\\1s'", ",", "'/(?:([^f])fe|([lr])f)$/i'", "=>", "'\\1\\2ves'", ",", "'/sis$/i'", "=>", "'ses'", ",", "'/([ti])um$/i'", "=>", "'\\1a'", ",", "'/(buffal|tomat)o$/i'", "=>", "'\\1oes'", ",", "'/(bu)s$/i'", "=>", "'\\1ses'", ",", "'/(alias|status)/i'", "=>", "'\\1es'", ",", "'/(octop|vir)us$/i'", "=>", "'\\1i'", ",", "'/(ax|test)is$/i'", "=>", "'\\1es'", ",", "'/s$/i'", "=>", "'s'", ",", "'/$/'", "=>", "'s'", ")", ";", "$", "uncountable", "=", "array", "(", "'equipment'", ",", "'information'", ",", "'rice'", ",", "'money'", ",", "'species'", ",", "'series'", ",", "'fish'", ",", "'sheep'", ")", ";", "$", "irregular", "=", "array", "(", "'person'", "=>", "'people'", ",", "'man'", "=>", "'men'", ",", "'child'", "=>", "'children'", ",", "'sex'", "=>", "'sexes'", ",", "'move'", "=>", "'moves'", ")", ";", "$", "lowercased_word", "=", "strtolower", "(", "$", "word", ")", ";", "foreach", "(", "$", "uncountable", "as", "$", "_uncountable", ")", "{", "if", "(", "substr", "(", "$", "lowercased_word", ",", "(", "-", "1", "*", "strlen", "(", "$", "_uncountable", ")", ")", ")", "==", "$", "_uncountable", ")", "return", "$", "word", ";", "}", "foreach", "(", "$", "irregular", "as", "$", "_plural", "=>", "$", "_singular", ")", "{", "if", "(", "preg_match", "(", "'/('", ".", "$", "_plural", ".", "')$/i'", ",", "$", "word", ",", "$", "arr", ")", ")", "{", "return", "preg_replace", "(", "'/('", ".", "$", "_plural", ".", "')$/i'", ",", "substr", "(", "$", "arr", "[", "0", "]", ",", "0", ",", "1", ")", ".", "substr", "(", "$", "_singular", ",", "1", ")", ",", "$", "word", ")", ";", "}", "}", "foreach", "(", "$", "plural", "as", "$", "rule", "=>", "$", "replacement", ")", "{", "if", "(", "preg_match", "(", "$", "rule", ",", "$", "word", ")", ")", "{", "return", "preg_replace", "(", "$", "rule", ",", "$", "replacement", ",", "$", "word", ")", ";", "}", "}", "return", "false", ";", "}" ]
Takes a word, and makes it plural. @param string $word The word to pluralize @return string
[ "Takes", "a", "word", "and", "makes", "it", "plural", "." ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L533-L584
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.strToBool
public static function strToBool($string) { if(is_bool($string)) return $string; if (in_array(strtolower((string)$string), array('1', 'true', 'on', '+', 'yes', 'y'))) return true; elseif (in_array(strtolower((string)$string), array('', '0','false', 'off', '-', 'no', 'n'))) return false; return false; }
php
public static function strToBool($string) { if(is_bool($string)) return $string; if (in_array(strtolower((string)$string), array('1', 'true', 'on', '+', 'yes', 'y'))) return true; elseif (in_array(strtolower((string)$string), array('', '0','false', 'off', '-', 'no', 'n'))) return false; return false; }
[ "public", "static", "function", "strToBool", "(", "$", "string", ")", "{", "if", "(", "is_bool", "(", "$", "string", ")", ")", "return", "$", "string", ";", "if", "(", "in_array", "(", "strtolower", "(", "(", "string", ")", "$", "string", ")", ",", "array", "(", "'1'", ",", "'true'", ",", "'on'", ",", "'+'", ",", "'yes'", ",", "'y'", ")", ")", ")", "return", "true", ";", "elseif", "(", "in_array", "(", "strtolower", "(", "(", "string", ")", "$", "string", ")", ",", "array", "(", "''", ",", "'0'", ",", "'false'", ",", "'off'", ",", "'-'", ",", "'no'", ",", "'n'", ")", ")", ")", "return", "false", ";", "return", "false", ";", "}" ]
Translates the given string into a boolean value if it's in the proper format @param string $string The string to convert @return boolean true or false, translated @throws Exception if string cannot be converted
[ "Translates", "the", "given", "string", "into", "a", "boolean", "value", "if", "it", "s", "in", "the", "proper", "format" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L594-L605
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.stripslashesDeep
public static function stripslashesDeep($value) { $value = is_array($value) ? array_map(array('StringUtils', 'stripslashesDeep'), $value) : stripslashes($value); return $value; }
php
public static function stripslashesDeep($value) { $value = is_array($value) ? array_map(array('StringUtils', 'stripslashesDeep'), $value) : stripslashes($value); return $value; }
[ "public", "static", "function", "stripslashesDeep", "(", "$", "value", ")", "{", "$", "value", "=", "is_array", "(", "$", "value", ")", "?", "array_map", "(", "array", "(", "'StringUtils'", ",", "'stripslashesDeep'", ")", ",", "$", "value", ")", ":", "stripslashes", "(", "$", "value", ")", ";", "return", "$", "value", ";", "}" ]
Recursively strips slashes from all values in the array @param mixed $value If an array, all values will be stripslashed() If a string, then it will be stripslashed() @return array The stripped array
[ "Recursively", "strips", "slashes", "from", "all", "values", "in", "the", "array" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L615-L622
train
wb-crowdfusion/crowdfusion
system/core/classes/libraries/utils/StringUtils.php
StringUtils.stripHtml
public static function stripHtml($value, $tags = null, $keepContent = false) { $content = ''; if(!is_array($tags)) { $tags = (strpos($value, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags)); if(end($tags) == '') array_pop($tags); } foreach($tags as $tag) { if (!$keepContent) $content = '(.+</'.$tag.'[^>]*>|)'; $value = preg_replace('#</?'.$tag.'[^>]*>'.$content.'#is', '', $value); } return $value; }
php
public static function stripHtml($value, $tags = null, $keepContent = false) { $content = ''; if(!is_array($tags)) { $tags = (strpos($value, '>') !== false ? explode('>', str_replace('<', '', $tags)) : array($tags)); if(end($tags) == '') array_pop($tags); } foreach($tags as $tag) { if (!$keepContent) $content = '(.+</'.$tag.'[^>]*>|)'; $value = preg_replace('#</?'.$tag.'[^>]*>'.$content.'#is', '', $value); } return $value; }
[ "public", "static", "function", "stripHtml", "(", "$", "value", ",", "$", "tags", "=", "null", ",", "$", "keepContent", "=", "false", ")", "{", "$", "content", "=", "''", ";", "if", "(", "!", "is_array", "(", "$", "tags", ")", ")", "{", "$", "tags", "=", "(", "strpos", "(", "$", "value", ",", "'>'", ")", "!==", "false", "?", "explode", "(", "'>'", ",", "str_replace", "(", "'<'", ",", "''", ",", "$", "tags", ")", ")", ":", "array", "(", "$", "tags", ")", ")", ";", "if", "(", "end", "(", "$", "tags", ")", "==", "''", ")", "array_pop", "(", "$", "tags", ")", ";", "}", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "if", "(", "!", "$", "keepContent", ")", "$", "content", "=", "'(.+</'", ".", "$", "tag", ".", "'[^>]*>|)'", ";", "$", "value", "=", "preg_replace", "(", "'#</?'", ".", "$", "tag", ".", "'[^>]*>'", ".", "$", "content", ".", "'#is'", ",", "''", ",", "$", "value", ")", ";", "}", "return", "$", "value", ";", "}" ]
Strips a string of HTML tags specified, can strip content or just remove tags @param string $value Html/text to strip html from @param string $tags Comma separated list of tags to strip (ie "<object>,<script>") @param bool $keepContent Keep content within html tags (defaults to false) @return string @static @see http://us.php.net/manual/en/function.strip-tags.php#96483
[ "Strips", "a", "string", "of", "HTML", "tags", "specified", "can", "strip", "content", "or", "just", "remove", "tags" ]
8cad7988f046a6fefbed07d026cb4ae6706c1217
https://github.com/wb-crowdfusion/crowdfusion/blob/8cad7988f046a6fefbed07d026cb4ae6706c1217/system/core/classes/libraries/utils/StringUtils.php#L737-L750
train
netbull/CoreBundle
Utils/PDFUtils.php
PDFUtils.convertMetric
public static function convertMetric( $value, $from, $to, $precision = null ) { switch ($from . $to) { case 'incm': $value *= 2.54; break; case 'inmm': $value *= 25.4; break; case 'inpt': $value *= 72; break; case 'cmin': $value /= 2.54; break; case 'cmmm': $value *= 10; break; case 'cmpt': $value *= 72 / 2.54; break; case 'mmin': $value /= 25.4; break; case 'mmcm': $value /= 10; break; case 'mmpt': $value *= 72 / 25.4; break; case 'ptin': $value /= 72; break; case 'ptcm': $value *= 2.54 / 72; break; case 'ptmm': $value *= 25.4 / 72; break; } if ( !is_null($precision) ) { $value = round($value, $precision); } return $value; }
php
public static function convertMetric( $value, $from, $to, $precision = null ) { switch ($from . $to) { case 'incm': $value *= 2.54; break; case 'inmm': $value *= 25.4; break; case 'inpt': $value *= 72; break; case 'cmin': $value /= 2.54; break; case 'cmmm': $value *= 10; break; case 'cmpt': $value *= 72 / 2.54; break; case 'mmin': $value /= 25.4; break; case 'mmcm': $value /= 10; break; case 'mmpt': $value *= 72 / 25.4; break; case 'ptin': $value /= 72; break; case 'ptcm': $value *= 2.54 / 72; break; case 'ptmm': $value *= 25.4 / 72; break; } if ( !is_null($precision) ) { $value = round($value, $precision); } return $value; }
[ "public", "static", "function", "convertMetric", "(", "$", "value", ",", "$", "from", ",", "$", "to", ",", "$", "precision", "=", "null", ")", "{", "switch", "(", "$", "from", ".", "$", "to", ")", "{", "case", "'incm'", ":", "$", "value", "*=", "2.54", ";", "break", ";", "case", "'inmm'", ":", "$", "value", "*=", "25.4", ";", "break", ";", "case", "'inpt'", ":", "$", "value", "*=", "72", ";", "break", ";", "case", "'cmin'", ":", "$", "value", "/=", "2.54", ";", "break", ";", "case", "'cmmm'", ":", "$", "value", "*=", "10", ";", "break", ";", "case", "'cmpt'", ":", "$", "value", "*=", "72", "/", "2.54", ";", "break", ";", "case", "'mmin'", ":", "$", "value", "/=", "25.4", ";", "break", ";", "case", "'mmcm'", ":", "$", "value", "/=", "10", ";", "break", ";", "case", "'mmpt'", ":", "$", "value", "*=", "72", "/", "25.4", ";", "break", ";", "case", "'ptin'", ":", "$", "value", "/=", "72", ";", "break", ";", "case", "'ptcm'", ":", "$", "value", "*=", "2.54", "/", "72", ";", "break", ";", "case", "'ptmm'", ":", "$", "value", "*=", "25.4", "/", "72", ";", "break", ";", "}", "if", "(", "!", "is_null", "(", "$", "precision", ")", ")", "{", "$", "value", "=", "round", "(", "$", "value", ",", "$", "precision", ")", ";", "}", "return", "$", "value", ";", "}" ]
convert value from one metric to another. @param $value @param $from @param $to @param null $precision @return float|int
[ "convert", "value", "from", "one", "metric", "to", "another", "." ]
0bacc1d9e4733b6da613027400c48421e5a14645
https://github.com/netbull/CoreBundle/blob/0bacc1d9e4733b6da613027400c48421e5a14645/Utils/PDFUtils.php#L21-L66
train
Kris-Kuiper/sFire-Framework
src/Validator/Form/Combine.php
Combine.setValues
public function setValues($values) { if(false === is_array($values)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($values)), E_USER_ERROR); } $this -> values = $values; return $this; }
php
public function setValues($values) { if(false === is_array($values)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($values)), E_USER_ERROR); } $this -> values = $values; return $this; }
[ "public", "function", "setValues", "(", "$", "values", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "values", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type array, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "values", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "values", "=", "$", "values", ";", "return", "$", "this", ";", "}" ]
Add one or multiple fields to combine them as one @param string|array $fieldnames @return sFire\Validator\Combine
[ "Add", "one", "or", "multiple", "fields", "to", "combine", "them", "as", "one" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Combine.php#L51-L60
train
Kris-Kuiper/sFire-Framework
src/Validator/Form/Combine.php
Combine.setFieldnames
public function setFieldnames($fieldnames) { if(false === is_array($fieldnames)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($fieldnames)), E_USER_ERROR); } $this -> fieldnames = $fieldnames; }
php
public function setFieldnames($fieldnames) { if(false === is_array($fieldnames)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type array, "%s" given', __METHOD__, gettype($fieldnames)), E_USER_ERROR); } $this -> fieldnames = $fieldnames; }
[ "public", "function", "setFieldnames", "(", "$", "fieldnames", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "fieldnames", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type array, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "fieldnames", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "fieldnames", "=", "$", "fieldnames", ";", "}" ]
Sets the fieldnames @param array $fieldnames @return sFire\Validator\Combine
[ "Sets", "the", "fieldnames" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Combine.php#L67-L74
train
Kris-Kuiper/sFire-Framework
src/Validator/Form/Combine.php
Combine.glue
public function glue($glue) { if(false === is_string($glue)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($glue)), E_USER_ERROR); } $this -> glue = $glue; return $this; }
php
public function glue($glue) { if(false === is_string($glue)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($glue)), E_USER_ERROR); } $this -> glue = $glue; return $this; }
[ "public", "function", "glue", "(", "$", "glue", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "glue", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "glue", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "glue", "=", "$", "glue", ";", "return", "$", "this", ";", "}" ]
Joins the fieldnames with the glue string between each fieldname @param string $glue @return sFire\Validator\Combine
[ "Joins", "the", "fieldnames", "with", "the", "glue", "string", "between", "each", "fieldname" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Combine.php#L82-L91
train
Kris-Kuiper/sFire-Framework
src/Validator/Form/Combine.php
Combine.format
public function format($format) { if(false === is_string($format)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($format)), E_USER_ERROR); } $this -> format = $format; return $this; }
php
public function format($format) { if(false === is_string($format)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($format)), E_USER_ERROR); } $this -> format = $format; return $this; }
[ "public", "function", "format", "(", "$", "format", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "format", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "format", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "format", "=", "$", "format", ";", "return", "$", "this", ";", "}" ]
Converts the fieldname values to the specific given format @param string $format @return sFire\Validator\Combine
[ "Converts", "the", "fieldname", "values", "to", "the", "specific", "given", "format" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Combine.php#L99-L108
train
Kris-Kuiper/sFire-Framework
src/Validator/Form/Combine.php
Combine.name
public function name($name) { if(false === is_string($name)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR); } $this -> name = $name; return $this; }
php
public function name($name) { if(false === is_string($name)) { return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($name)), E_USER_ERROR); } $this -> name = $name; return $this; }
[ "public", "function", "name", "(", "$", "name", ")", "{", "if", "(", "false", "===", "is_string", "(", "$", "name", ")", ")", "{", "return", "trigger_error", "(", "sprintf", "(", "'Argument 1 passed to %s() must be of the type string, \"%s\" given'", ",", "__METHOD__", ",", "gettype", "(", "$", "name", ")", ")", ",", "E_USER_ERROR", ")", ";", "}", "$", "this", "->", "name", "=", "$", "name", ";", "return", "$", "this", ";", "}" ]
Gives the combined fieldnames a new single name @param string $name @return sFire\Validator\Combine
[ "Gives", "the", "combined", "fieldnames", "a", "new", "single", "name" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Combine.php#L116-L125
train
Kris-Kuiper/sFire-Framework
src/Validator/Form/Combine.php
Combine.combine
public function combine() { if(count($this -> values) > 0) { if(null !== $this -> glue) { return implode($this -> glue, $this -> values); } return vsprintf($this -> format, $this -> values); } }
php
public function combine() { if(count($this -> values) > 0) { if(null !== $this -> glue) { return implode($this -> glue, $this -> values); } return vsprintf($this -> format, $this -> values); } }
[ "public", "function", "combine", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "values", ")", ">", "0", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "glue", ")", "{", "return", "implode", "(", "$", "this", "->", "glue", ",", "$", "this", "->", "values", ")", ";", "}", "return", "vsprintf", "(", "$", "this", "->", "format", ",", "$", "this", "->", "values", ")", ";", "}", "}" ]
Combine the values with the glue or format @return string
[ "Combine", "the", "values", "with", "the", "glue", "or", "format" ]
deefe1d9d2b40e7326381e8dcd4f01f9aa61885c
https://github.com/Kris-Kuiper/sFire-Framework/blob/deefe1d9d2b40e7326381e8dcd4f01f9aa61885c/src/Validator/Form/Combine.php#L168-L178
train
RocketPropelledTortoise/Core
src/Taxonomy/Utils/RecursiveQuery.php
RecursiveQuery.getRecursiveAncestry
protected function getRecursiveAncestry(Collection $all_results, $ids) { $all_results->merge($results = DB::table($this->hierarchyTable)->whereIn('term_id', $ids)->get()); if (count($results)) { $this->getRecursiveAncestry($all_results, Arr::pluck($results, 'parent_id')); } }
php
protected function getRecursiveAncestry(Collection $all_results, $ids) { $all_results->merge($results = DB::table($this->hierarchyTable)->whereIn('term_id', $ids)->get()); if (count($results)) { $this->getRecursiveAncestry($all_results, Arr::pluck($results, 'parent_id')); } }
[ "protected", "function", "getRecursiveAncestry", "(", "Collection", "$", "all_results", ",", "$", "ids", ")", "{", "$", "all_results", "->", "merge", "(", "$", "results", "=", "DB", "::", "table", "(", "$", "this", "->", "hierarchyTable", ")", "->", "whereIn", "(", "'term_id'", ",", "$", "ids", ")", "->", "get", "(", ")", ")", ";", "if", "(", "count", "(", "$", "results", ")", ")", "{", "$", "this", "->", "getRecursiveAncestry", "(", "$", "all_results", ",", "Arr", "::", "pluck", "(", "$", "results", ",", "'parent_id'", ")", ")", ";", "}", "}" ]
Get the ancestry recursively @param Collection $all_results @param int[] $ids
[ "Get", "the", "ancestry", "recursively" ]
78b65663fc463e21e494257140ddbed0a9ccb3c3
https://github.com/RocketPropelledTortoise/Core/blob/78b65663fc463e21e494257140ddbed0a9ccb3c3/src/Taxonomy/Utils/RecursiveQuery.php#L66-L73
train
pluf/tenant
src/Tenant/Views/Ticket.php
Tenant_Views_Ticket.createManyToOne
public function createManyToOne($request, $match) { $parent = Pluf_Shortcuts_GetObjectOr404('Tenant_Ticket', $match['parentId']); $object = new Tenant_Comment(); $form = Pluf_Shortcuts_GetFormForModel($object, $request->REQUEST); $object = $form->save(false); $object->ticket_id = $parent; $object->author_id = $request->user; $object->create(); return $object; }
php
public function createManyToOne($request, $match) { $parent = Pluf_Shortcuts_GetObjectOr404('Tenant_Ticket', $match['parentId']); $object = new Tenant_Comment(); $form = Pluf_Shortcuts_GetFormForModel($object, $request->REQUEST); $object = $form->save(false); $object->ticket_id = $parent; $object->author_id = $request->user; $object->create(); return $object; }
[ "public", "function", "createManyToOne", "(", "$", "request", ",", "$", "match", ")", "{", "$", "parent", "=", "Pluf_Shortcuts_GetObjectOr404", "(", "'Tenant_Ticket'", ",", "$", "match", "[", "'parentId'", "]", ")", ";", "$", "object", "=", "new", "Tenant_Comment", "(", ")", ";", "$", "form", "=", "Pluf_Shortcuts_GetFormForModel", "(", "$", "object", ",", "$", "request", "->", "REQUEST", ")", ";", "$", "object", "=", "$", "form", "->", "save", "(", "false", ")", ";", "$", "object", "->", "ticket_id", "=", "$", "parent", ";", "$", "object", "->", "author_id", "=", "$", "request", "->", "user", ";", "$", "object", "->", "create", "(", ")", ";", "return", "$", "object", ";", "}" ]
Create new comment @param Pluf_HTTP_Request $request @param array $match @param array $p
[ "Create", "new", "comment" ]
a06359c52b9a257b5a0a186264e8770acfc54b73
https://github.com/pluf/tenant/blob/a06359c52b9a257b5a0a186264e8770acfc54b73/src/Tenant/Views/Ticket.php#L37-L47
train
mwyatt/core
src/Url.php
Url.generateVersioned
public function generateVersioned($pathBase, $pathAppend) { $pathAbsolute = $pathBase . $pathAppend; if (!file_exists($pathAbsolute)) { throw new \Exception("cannot get cache busting path for file '$pathAbsolute'"); } // get mod time $timeModified = filemtime($pathAbsolute); // return url to asset with modified time as query var return $this->generate() . $pathAppend . '?' . $timeModified; }
php
public function generateVersioned($pathBase, $pathAppend) { $pathAbsolute = $pathBase . $pathAppend; if (!file_exists($pathAbsolute)) { throw new \Exception("cannot get cache busting path for file '$pathAbsolute'"); } // get mod time $timeModified = filemtime($pathAbsolute); // return url to asset with modified time as query var return $this->generate() . $pathAppend . '?' . $timeModified; }
[ "public", "function", "generateVersioned", "(", "$", "pathBase", ",", "$", "pathAppend", ")", "{", "$", "pathAbsolute", "=", "$", "pathBase", ".", "$", "pathAppend", ";", "if", "(", "!", "file_exists", "(", "$", "pathAbsolute", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"cannot get cache busting path for file '$pathAbsolute'\"", ")", ";", "}", "// get mod time", "$", "timeModified", "=", "filemtime", "(", "$", "pathAbsolute", ")", ";", "// return url to asset with modified time as query var", "return", "$", "this", "->", "generate", "(", ")", ".", "$", "pathAppend", ".", "'?'", ".", "$", "timeModified", ";", "}" ]
gets absolute path of a single file with cache busting powers! @param string $path @return string
[ "gets", "absolute", "path", "of", "a", "single", "file", "with", "cache", "busting", "powers!" ]
8ea9d67cc84fe6aff17a469c703d5492dbcd93ed
https://github.com/mwyatt/core/blob/8ea9d67cc84fe6aff17a469c703d5492dbcd93ed/src/Url.php#L101-L113
train
ciims/ciims-modules-install
controllers/DefaultController.php
DefaultController.actionError
public function actionError() { $error = array(); if (!empty(Yii::app()->errorHandler->error)) $error=Yii::app()->errorHandler->error; $this->render('error', array('error' => $error)); }
php
public function actionError() { $error = array(); if (!empty(Yii::app()->errorHandler->error)) $error=Yii::app()->errorHandler->error; $this->render('error', array('error' => $error)); }
[ "public", "function", "actionError", "(", ")", "{", "$", "error", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "Yii", "::", "app", "(", ")", "->", "errorHandler", "->", "error", ")", ")", "$", "error", "=", "Yii", "::", "app", "(", ")", "->", "errorHandler", "->", "error", ";", "$", "this", "->", "render", "(", "'error'", ",", "array", "(", "'error'", "=>", "$", "error", ")", ")", ";", "}" ]
Error Action The installer shouldn't error, if this happens, flat out die and blame the developer
[ "Error", "Action", "The", "installer", "shouldn", "t", "error", "if", "this", "happens", "flat", "out", "die", "and", "blame", "the", "developer" ]
54d6a93e5c42c2d98e19de38a90e27f77358e88b
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/controllers/DefaultController.php#L23-L30
train
ciims/ciims-modules-install
controllers/DefaultController.php
DefaultController.actionIndex
public function actionIndex() { $model = new DatabaseForm; // Assign previously set credentials if (Cii::get(Yii::app()->session['dsn']) != "") $model->attributes = Yii::app()->session['dsn']; // If a post request was sent if (Cii::get($_POST, 'DatabaseForm')) { $model->attributes = $_POST['DatabaseForm']; if ($model->validateConnection()) { Yii::app()->session['dsn'] = $model->attributes; $this->redirect($this->createUrl('/migrate')); } else { Yii::app()->user->setFlash('error', Yii::t('Install.main', '{{warning}} {{error}}', array( '{{warning}}' => CHtml::tag('strong', array(), Yii::t('Install.main', 'Warning!')), '{{error}}' => $model->getError('dsn') ))); } } $this->render('index', array('model'=>$model)); }
php
public function actionIndex() { $model = new DatabaseForm; // Assign previously set credentials if (Cii::get(Yii::app()->session['dsn']) != "") $model->attributes = Yii::app()->session['dsn']; // If a post request was sent if (Cii::get($_POST, 'DatabaseForm')) { $model->attributes = $_POST['DatabaseForm']; if ($model->validateConnection()) { Yii::app()->session['dsn'] = $model->attributes; $this->redirect($this->createUrl('/migrate')); } else { Yii::app()->user->setFlash('error', Yii::t('Install.main', '{{warning}} {{error}}', array( '{{warning}}' => CHtml::tag('strong', array(), Yii::t('Install.main', 'Warning!')), '{{error}}' => $model->getError('dsn') ))); } } $this->render('index', array('model'=>$model)); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "model", "=", "new", "DatabaseForm", ";", "// Assign previously set credentials", "if", "(", "Cii", "::", "get", "(", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", ")", "!=", "\"\"", ")", "$", "model", "->", "attributes", "=", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", ";", "// If a post request was sent", "if", "(", "Cii", "::", "get", "(", "$", "_POST", ",", "'DatabaseForm'", ")", ")", "{", "$", "model", "->", "attributes", "=", "$", "_POST", "[", "'DatabaseForm'", "]", ";", "if", "(", "$", "model", "->", "validateConnection", "(", ")", ")", "{", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", "=", "$", "model", "->", "attributes", ";", "$", "this", "->", "redirect", "(", "$", "this", "->", "createUrl", "(", "'/migrate'", ")", ")", ";", "}", "else", "{", "Yii", "::", "app", "(", ")", "->", "user", "->", "setFlash", "(", "'error'", ",", "Yii", "::", "t", "(", "'Install.main'", ",", "'{{warning}} {{error}}'", ",", "array", "(", "'{{warning}}'", "=>", "CHtml", "::", "tag", "(", "'strong'", ",", "array", "(", ")", ",", "Yii", "::", "t", "(", "'Install.main'", ",", "'Warning!'", ")", ")", ",", "'{{error}}'", "=>", "$", "model", "->", "getError", "(", "'dsn'", ")", ")", ")", ")", ";", "}", "}", "$", "this", "->", "render", "(", "'index'", ",", "array", "(", "'model'", "=>", "$", "model", ")", ")", ";", "}" ]
Initial action the user arrives to. Handles setting up the database connection
[ "Initial", "action", "the", "user", "arrives", "to", ".", "Handles", "setting", "up", "the", "database", "connection" ]
54d6a93e5c42c2d98e19de38a90e27f77358e88b
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/controllers/DefaultController.php#L36-L64
train
ciims/ciims-modules-install
controllers/DefaultController.php
DefaultController.actionCreateAdmin
public function actionCreateAdmin() { $model = new UserForm; if (Cii::get($_POST, 'UserForm') != NULL) { $model->attributes = Cii::get($_POST, 'UserForm', array()); if ($model->validate()) { $response = $this->runInstaller($model); if (file_exists(Yii::getPathOfAlias('application.config').DS.'/main.php')) { $this->render('admin'); Yii::app()->end(); } else Yii::app()->user->setFlash('error', $response); } $errors = $model->getErrors(); $firstError = array_values($errors); Yii::app()->user->setFlash('error', Yii::t('Install.main', '{{warning}} {{error}}', array( '{{warning}}' => CHtml::tag('strong', array(), Yii::t('Install.main', 'Warning!')), '{{error}}' => $firstError[0][0] ))); } $this->render('createadmin', array('model' => $model)); }
php
public function actionCreateAdmin() { $model = new UserForm; if (Cii::get($_POST, 'UserForm') != NULL) { $model->attributes = Cii::get($_POST, 'UserForm', array()); if ($model->validate()) { $response = $this->runInstaller($model); if (file_exists(Yii::getPathOfAlias('application.config').DS.'/main.php')) { $this->render('admin'); Yii::app()->end(); } else Yii::app()->user->setFlash('error', $response); } $errors = $model->getErrors(); $firstError = array_values($errors); Yii::app()->user->setFlash('error', Yii::t('Install.main', '{{warning}} {{error}}', array( '{{warning}}' => CHtml::tag('strong', array(), Yii::t('Install.main', 'Warning!')), '{{error}}' => $firstError[0][0] ))); } $this->render('createadmin', array('model' => $model)); }
[ "public", "function", "actionCreateAdmin", "(", ")", "{", "$", "model", "=", "new", "UserForm", ";", "if", "(", "Cii", "::", "get", "(", "$", "_POST", ",", "'UserForm'", ")", "!=", "NULL", ")", "{", "$", "model", "->", "attributes", "=", "Cii", "::", "get", "(", "$", "_POST", ",", "'UserForm'", ",", "array", "(", ")", ")", ";", "if", "(", "$", "model", "->", "validate", "(", ")", ")", "{", "$", "response", "=", "$", "this", "->", "runInstaller", "(", "$", "model", ")", ";", "if", "(", "file_exists", "(", "Yii", "::", "getPathOfAlias", "(", "'application.config'", ")", ".", "DS", ".", "'/main.php'", ")", ")", "{", "$", "this", "->", "render", "(", "'admin'", ")", ";", "Yii", "::", "app", "(", ")", "->", "end", "(", ")", ";", "}", "else", "Yii", "::", "app", "(", ")", "->", "user", "->", "setFlash", "(", "'error'", ",", "$", "response", ")", ";", "}", "$", "errors", "=", "$", "model", "->", "getErrors", "(", ")", ";", "$", "firstError", "=", "array_values", "(", "$", "errors", ")", ";", "Yii", "::", "app", "(", ")", "->", "user", "->", "setFlash", "(", "'error'", ",", "Yii", "::", "t", "(", "'Install.main'", ",", "'{{warning}} {{error}}'", ",", "array", "(", "'{{warning}}'", "=>", "CHtml", "::", "tag", "(", "'strong'", ",", "array", "(", ")", ",", "Yii", "::", "t", "(", "'Install.main'", ",", "'Warning!'", ")", ")", ",", "'{{error}}'", "=>", "$", "firstError", "[", "0", "]", "[", "0", "]", ")", ")", ")", ";", "}", "$", "this", "->", "render", "(", "'createadmin'", ",", "array", "(", "'model'", "=>", "$", "model", ")", ")", ";", "}" ]
This action enables us to create an admin user for CiiMS
[ "This", "action", "enables", "us", "to", "create", "an", "admin", "user", "for", "CiiMS" ]
54d6a93e5c42c2d98e19de38a90e27f77358e88b
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/controllers/DefaultController.php#L86-L114
train
ciims/ciims-modules-install
controllers/DefaultController.php
DefaultController.actionRunMigrations
public function actionRunMigrations() { header('Content-Type: application/json'); $response = $this->runMigrationTool(); $data = array('migrated' => false, 'details' => $response); if (strpos($response, 'Migrated up successfully.') || strpos($response, 'Your system is up-to-date.')) $data = array('migrated' => true, 'details' => $response); echo CJavaScript::jsonEncode($data); Yii::app()->end(); }
php
public function actionRunMigrations() { header('Content-Type: application/json'); $response = $this->runMigrationTool(); $data = array('migrated' => false, 'details' => $response); if (strpos($response, 'Migrated up successfully.') || strpos($response, 'Your system is up-to-date.')) $data = array('migrated' => true, 'details' => $response); echo CJavaScript::jsonEncode($data); Yii::app()->end(); }
[ "public", "function", "actionRunMigrations", "(", ")", "{", "header", "(", "'Content-Type: application/json'", ")", ";", "$", "response", "=", "$", "this", "->", "runMigrationTool", "(", ")", ";", "$", "data", "=", "array", "(", "'migrated'", "=>", "false", ",", "'details'", "=>", "$", "response", ")", ";", "if", "(", "strpos", "(", "$", "response", ",", "'Migrated up successfully.'", ")", "||", "strpos", "(", "$", "response", ",", "'Your system is up-to-date.'", ")", ")", "$", "data", "=", "array", "(", "'migrated'", "=>", "true", ",", "'details'", "=>", "$", "response", ")", ";", "echo", "CJavaScript", "::", "jsonEncode", "(", "$", "data", ")", ";", "Yii", "::", "app", "(", ")", "->", "end", "(", ")", ";", "}" ]
Ajax comment to run CDbMigrations
[ "Ajax", "comment", "to", "run", "CDbMigrations" ]
54d6a93e5c42c2d98e19de38a90e27f77358e88b
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/controllers/DefaultController.php#L119-L132
train
ciims/ciims-modules-install
controllers/DefaultController.php
DefaultController.runInstaller
private function runInstaller($userModel) { return $this->runCommand(Yii::app()->session['dsn'], 'application.modules.install.InstallerCommand', array( 'yiic', 'installer', 'index', '--dbHost='.Yii::app()->session['dsn']['host'], '--dbName='.Yii::app()->session['dsn']['dbname'], '--dbUsername='.Yii::app()->session['dsn']['username'], '--dbPassword='.Yii::app()->session['dsn']['password'], '--adminEmail='.$userModel->email, '--adminPassword='.$userModel->password, '--adminUsername='.$userModel->username, '--siteName='.$userModel->siteName, '--force=true' )); }
php
private function runInstaller($userModel) { return $this->runCommand(Yii::app()->session['dsn'], 'application.modules.install.InstallerCommand', array( 'yiic', 'installer', 'index', '--dbHost='.Yii::app()->session['dsn']['host'], '--dbName='.Yii::app()->session['dsn']['dbname'], '--dbUsername='.Yii::app()->session['dsn']['username'], '--dbPassword='.Yii::app()->session['dsn']['password'], '--adminEmail='.$userModel->email, '--adminPassword='.$userModel->password, '--adminUsername='.$userModel->username, '--siteName='.$userModel->siteName, '--force=true' )); }
[ "private", "function", "runInstaller", "(", "$", "userModel", ")", "{", "return", "$", "this", "->", "runCommand", "(", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", ",", "'application.modules.install.InstallerCommand'", ",", "array", "(", "'yiic'", ",", "'installer'", ",", "'index'", ",", "'--dbHost='", ".", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", "[", "'host'", "]", ",", "'--dbName='", ".", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", "[", "'dbname'", "]", ",", "'--dbUsername='", ".", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", "[", "'username'", "]", ",", "'--dbPassword='", ".", "Yii", "::", "app", "(", ")", "->", "session", "[", "'dsn'", "]", "[", "'password'", "]", ",", "'--adminEmail='", ".", "$", "userModel", "->", "email", ",", "'--adminPassword='", ".", "$", "userModel", "->", "password", ",", "'--adminUsername='", ".", "$", "userModel", "->", "username", ",", "'--siteName='", ".", "$", "userModel", "->", "siteName", ",", "'--force=true'", ")", ")", ";", "}" ]
Runs the CLI installer which writes the config files and create the initial admin user @param $userModel UserForm @return string
[ "Runs", "the", "CLI", "installer", "which", "writes", "the", "config", "files", "and", "create", "the", "initial", "admin", "user" ]
54d6a93e5c42c2d98e19de38a90e27f77358e88b
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/controllers/DefaultController.php#L153-L169
train
ciims/ciims-modules-install
controllers/DefaultController.php
DefaultController.runCommand
private function runCommand($dsn, $command, $data) { $runner=new CConsoleCommandRunner(); $runner->commands=array( 'migrate' => array( 'class' => $command, 'dsn' => $dsn, 'interactive' => 0, ), 'db'=>array( 'class'=>'CDbConnection', 'connectionString' => "mysql:host={$dsn['host']};dbname={$dsn['dbname']}", 'emulatePrepare' => true, 'username' => $dsn['username'], 'password' => $dsn['password'], 'charset' => 'utf8', ), ); ob_start(); $modules = array_filter(glob(Yii::app()->getBasePath().'/modules/*', GLOB_ONLYDIR)); foreach ($modules as $module) { if (file_exists($module.'/commands')) $runner->addCommands($module.'/commands'); } $runner->run($data); return htmlentities(ob_get_clean(), null, Yii::app()->charset); }
php
private function runCommand($dsn, $command, $data) { $runner=new CConsoleCommandRunner(); $runner->commands=array( 'migrate' => array( 'class' => $command, 'dsn' => $dsn, 'interactive' => 0, ), 'db'=>array( 'class'=>'CDbConnection', 'connectionString' => "mysql:host={$dsn['host']};dbname={$dsn['dbname']}", 'emulatePrepare' => true, 'username' => $dsn['username'], 'password' => $dsn['password'], 'charset' => 'utf8', ), ); ob_start(); $modules = array_filter(glob(Yii::app()->getBasePath().'/modules/*', GLOB_ONLYDIR)); foreach ($modules as $module) { if (file_exists($module.'/commands')) $runner->addCommands($module.'/commands'); } $runner->run($data); return htmlentities(ob_get_clean(), null, Yii::app()->charset); }
[ "private", "function", "runCommand", "(", "$", "dsn", ",", "$", "command", ",", "$", "data", ")", "{", "$", "runner", "=", "new", "CConsoleCommandRunner", "(", ")", ";", "$", "runner", "->", "commands", "=", "array", "(", "'migrate'", "=>", "array", "(", "'class'", "=>", "$", "command", ",", "'dsn'", "=>", "$", "dsn", ",", "'interactive'", "=>", "0", ",", ")", ",", "'db'", "=>", "array", "(", "'class'", "=>", "'CDbConnection'", ",", "'connectionString'", "=>", "\"mysql:host={$dsn['host']};dbname={$dsn['dbname']}\"", ",", "'emulatePrepare'", "=>", "true", ",", "'username'", "=>", "$", "dsn", "[", "'username'", "]", ",", "'password'", "=>", "$", "dsn", "[", "'password'", "]", ",", "'charset'", "=>", "'utf8'", ",", ")", ",", ")", ";", "ob_start", "(", ")", ";", "$", "modules", "=", "array_filter", "(", "glob", "(", "Yii", "::", "app", "(", ")", "->", "getBasePath", "(", ")", ".", "'/modules/*'", ",", "GLOB_ONLYDIR", ")", ")", ";", "foreach", "(", "$", "modules", "as", "$", "module", ")", "{", "if", "(", "file_exists", "(", "$", "module", ".", "'/commands'", ")", ")", "$", "runner", "->", "addCommands", "(", "$", "module", ".", "'/commands'", ")", ";", "}", "$", "runner", "->", "run", "(", "$", "data", ")", ";", "return", "htmlentities", "(", "ob_get_clean", "(", ")", ",", "null", ",", "Yii", "::", "app", "(", ")", "->", "charset", ")", ";", "}" ]
Runs a given command @param array $dsn The DSN @param string $command The CLI command to run @param array $data The runner data to use @return string
[ "Runs", "a", "given", "command" ]
54d6a93e5c42c2d98e19de38a90e27f77358e88b
https://github.com/ciims/ciims-modules-install/blob/54d6a93e5c42c2d98e19de38a90e27f77358e88b/controllers/DefaultController.php#L178-L209
train
linpax/microphp-framework
src/db/drivers/Connection.php
Connection.setDriver
public function setDriver($dsn, array $config = [], array $options = []) { $class = '\Micro\Db\Drivers\\'.ucfirst(substr($dsn, 0, strpos($dsn, ':'))).'Driver'; if (!class_exists($class)) { throw new Exception('DB driver `'.$class.'` not supported'); } unset($this->driver); $this->driver = new $class($dsn, $config, $options); }
php
public function setDriver($dsn, array $config = [], array $options = []) { $class = '\Micro\Db\Drivers\\'.ucfirst(substr($dsn, 0, strpos($dsn, ':'))).'Driver'; if (!class_exists($class)) { throw new Exception('DB driver `'.$class.'` not supported'); } unset($this->driver); $this->driver = new $class($dsn, $config, $options); }
[ "public", "function", "setDriver", "(", "$", "dsn", ",", "array", "$", "config", "=", "[", "]", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "class", "=", "'\\Micro\\Db\\Drivers\\\\'", ".", "ucfirst", "(", "substr", "(", "$", "dsn", ",", "0", ",", "strpos", "(", "$", "dsn", ",", "':'", ")", ")", ")", ".", "'Driver'", ";", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "Exception", "(", "'DB driver `'", ".", "$", "class", ".", "'` not supported'", ")", ";", "}", "unset", "(", "$", "this", "->", "driver", ")", ";", "$", "this", "->", "driver", "=", "new", "$", "class", "(", "$", "dsn", ",", "$", "config", ",", "$", "options", ")", ";", "}" ]
Set active connection driver @access public @param string $dsn DSN connection string @param array $config Configuration of connection @param array $options Other options @return void @throws Exception
[ "Set", "active", "connection", "driver" ]
11f3370f3f64c516cce9b84ecd8276c6e9ae8df9
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/db/drivers/Connection.php#L66-L77
train
siriusSupreme/sirius-redis
src/Connections/PhpRedisConnection.php
PhpRedisConnection.hmget
public function hmget($key, ...$dictionary) { if (count($dictionary) == 1) { $dictionary = $dictionary[0]; } return array_values($this->command('hmget', [$key, $dictionary])); }
php
public function hmget($key, ...$dictionary) { if (count($dictionary) == 1) { $dictionary = $dictionary[0]; } return array_values($this->command('hmget', [$key, $dictionary])); }
[ "public", "function", "hmget", "(", "$", "key", ",", "...", "$", "dictionary", ")", "{", "if", "(", "count", "(", "$", "dictionary", ")", "==", "1", ")", "{", "$", "dictionary", "=", "$", "dictionary", "[", "0", "]", ";", "}", "return", "array_values", "(", "$", "this", "->", "command", "(", "'hmget'", ",", "[", "$", "key", ",", "$", "dictionary", "]", ")", ")", ";", "}" ]
Get the value of the given hash fields. @param string $key @param dynamic $dictionary @return int
[ "Get", "the", "value", "of", "the", "given", "hash", "fields", "." ]
30abe086fdc44ba424d1554e16db586fa95b27a1
https://github.com/siriusSupreme/sirius-redis/blob/30abe086fdc44ba424d1554e16db586fa95b27a1/src/Connections/PhpRedisConnection.php#L104-L111
train
siriusSupreme/sirius-redis
src/Connections/PhpRedisConnection.php
PhpRedisConnection.eval
public function eval($script, $numberOfKeys, ...$arguments) { return $this->client->eval($script, $arguments, $numberOfKeys); }
php
public function eval($script, $numberOfKeys, ...$arguments) { return $this->client->eval($script, $arguments, $numberOfKeys); }
[ "public", "function", "eval", "(", "$", "script", ",", "$", "numberOfKeys", ",", "...", "$", "arguments", ")", "{", "return", "$", "this", "->", "client", "->", "eval", "(", "$", "script", ",", "$", "arguments", ",", "$", "numberOfKeys", ")", ";", "}" ]
Evaluate a script and retunr its result. @param string $script @param int $numberOfKeys @param dynamic $arguments @return mixed
[ "Evaluate", "a", "script", "and", "retunr", "its", "result", "." ]
30abe086fdc44ba424d1554e16db586fa95b27a1
https://github.com/siriusSupreme/sirius-redis/blob/30abe086fdc44ba424d1554e16db586fa95b27a1/src/Connections/PhpRedisConnection.php#L319-L322
train
mossphp/moss-storage
Moss/Storage/Query/Storage.php
Storage.read
public function read($entityName) { return new ReadQuery( $this->connection, $this->models->get($entityName), $this->factory, $this->accessor, $this->dispatcher ); }
php
public function read($entityName) { return new ReadQuery( $this->connection, $this->models->get($entityName), $this->factory, $this->accessor, $this->dispatcher ); }
[ "public", "function", "read", "(", "$", "entityName", ")", "{", "return", "new", "ReadQuery", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "models", "->", "get", "(", "$", "entityName", ")", ",", "$", "this", "->", "factory", ",", "$", "this", "->", "accessor", ",", "$", "this", "->", "dispatcher", ")", ";", "}" ]
Sets read operation @param string $entityName @return ReadQueryInterface
[ "Sets", "read", "operation" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Storage.php#L107-L116
train
mossphp/moss-storage
Moss/Storage/Query/Storage.php
Storage.readOne
public function readOne($entityName) { return new ReadOneQuery( $this->connection, $this->models->get($entityName), $this->factory, $this->accessor, $this->dispatcher ); }
php
public function readOne($entityName) { return new ReadOneQuery( $this->connection, $this->models->get($entityName), $this->factory, $this->accessor, $this->dispatcher ); }
[ "public", "function", "readOne", "(", "$", "entityName", ")", "{", "return", "new", "ReadOneQuery", "(", "$", "this", "->", "connection", ",", "$", "this", "->", "models", "->", "get", "(", "$", "entityName", ")", ",", "$", "this", "->", "factory", ",", "$", "this", "->", "accessor", ",", "$", "this", "->", "dispatcher", ")", ";", "}" ]
Sets read one operation @param string $entityName @return ReadQueryInterface
[ "Sets", "read", "one", "operation" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Storage.php#L125-L134
train
mossphp/moss-storage
Moss/Storage/Query/Storage.php
Storage.write
public function write($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new WriteQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
php
public function write($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new WriteQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
[ "public", "function", "write", "(", "$", "instance", ",", "$", "entity", "=", "null", ")", "{", "list", "(", "$", "instance", ",", "$", "entity", ")", "=", "$", "this", "->", "reassignEntity", "(", "$", "instance", ",", "$", "entity", ")", ";", "return", "new", "WriteQuery", "(", "$", "this", "->", "connection", ",", "$", "instance", ",", "$", "this", "->", "models", "->", "get", "(", "$", "entity", ")", ",", "$", "this", "->", "factory", ",", "$", "this", "->", "accessor", ",", "$", "this", "->", "dispatcher", ")", ";", "}" ]
Sets write operation @param array|object $instance @param null|string|object $entity @return WriteQueryInterface
[ "Sets", "write", "operation" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Storage.php#L144-L156
train
mossphp/moss-storage
Moss/Storage/Query/Storage.php
Storage.update
public function update($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new UpdateQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
php
public function update($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new UpdateQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
[ "public", "function", "update", "(", "$", "instance", ",", "$", "entity", "=", "null", ")", "{", "list", "(", "$", "instance", ",", "$", "entity", ")", "=", "$", "this", "->", "reassignEntity", "(", "$", "instance", ",", "$", "entity", ")", ";", "return", "new", "UpdateQuery", "(", "$", "this", "->", "connection", ",", "$", "instance", ",", "$", "this", "->", "models", "->", "get", "(", "$", "entity", ")", ",", "$", "this", "->", "factory", ",", "$", "this", "->", "accessor", ",", "$", "this", "->", "dispatcher", ")", ";", "}" ]
Sets update operation @param array|object $instance @param null|string|object $entity @return UpdateQueryInterface
[ "Sets", "update", "operation" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Storage.php#L166-L178
train
mossphp/moss-storage
Moss/Storage/Query/Storage.php
Storage.insert
public function insert($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new InsertQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
php
public function insert($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new InsertQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
[ "public", "function", "insert", "(", "$", "instance", ",", "$", "entity", "=", "null", ")", "{", "list", "(", "$", "instance", ",", "$", "entity", ")", "=", "$", "this", "->", "reassignEntity", "(", "$", "instance", ",", "$", "entity", ")", ";", "return", "new", "InsertQuery", "(", "$", "this", "->", "connection", ",", "$", "instance", ",", "$", "this", "->", "models", "->", "get", "(", "$", "entity", ")", ",", "$", "this", "->", "factory", ",", "$", "this", "->", "accessor", ",", "$", "this", "->", "dispatcher", ")", ";", "}" ]
Sets insert operation @param array|object $instance @param null|string|object $entity @return InsertQueryInterface
[ "Sets", "insert", "operation" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Storage.php#L188-L200
train
mossphp/moss-storage
Moss/Storage/Query/Storage.php
Storage.delete
public function delete($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new DeleteQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
php
public function delete($instance, $entity = null) { list($instance, $entity) = $this->reassignEntity($instance, $entity); return new DeleteQuery( $this->connection, $instance, $this->models->get($entity), $this->factory, $this->accessor, $this->dispatcher ); }
[ "public", "function", "delete", "(", "$", "instance", ",", "$", "entity", "=", "null", ")", "{", "list", "(", "$", "instance", ",", "$", "entity", ")", "=", "$", "this", "->", "reassignEntity", "(", "$", "instance", ",", "$", "entity", ")", ";", "return", "new", "DeleteQuery", "(", "$", "this", "->", "connection", ",", "$", "instance", ",", "$", "this", "->", "models", "->", "get", "(", "$", "entity", ")", ",", "$", "this", "->", "factory", ",", "$", "this", "->", "accessor", ",", "$", "this", "->", "dispatcher", ")", ";", "}" ]
Sets delete operation @param array|object $instance @param null|string|object $entity @return DeleteQueryInterface
[ "Sets", "delete", "operation" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Query/Storage.php#L210-L222
train
Dhii/exception
src/InitBaseExceptionCapableTrait.php
InitBaseExceptionCapableTrait._initBaseException
public function _initBaseException($message = null, $code = null, RootException $previous = null) { $message = is_null($message) ? '' : $this->_normalizeString($message); $code = is_null($code) ? 0 : $this->_normalizeInt($code); $this->_initParent($message, $code, $previous); }
php
public function _initBaseException($message = null, $code = null, RootException $previous = null) { $message = is_null($message) ? '' : $this->_normalizeString($message); $code = is_null($code) ? 0 : $this->_normalizeInt($code); $this->_initParent($message, $code, $previous); }
[ "public", "function", "_initBaseException", "(", "$", "message", "=", "null", ",", "$", "code", "=", "null", ",", "RootException", "$", "previous", "=", "null", ")", "{", "$", "message", "=", "is_null", "(", "$", "message", ")", "?", "''", ":", "$", "this", "->", "_normalizeString", "(", "$", "message", ")", ";", "$", "code", "=", "is_null", "(", "$", "code", ")", "?", "0", ":", "$", "this", "->", "_normalizeInt", "(", "$", "code", ")", ";", "$", "this", "->", "_initParent", "(", "$", "message", ",", "$", "code", ",", "$", "previous", ")", ";", "}" ]
Initializes the base exception. @since [*next-version*] @param string|Stringable|int|float|bool|null $message The message, if any. @param int|float|string|Stringable|null $code The numeric error code, if any. @param RootException|null $previous The inner exception, if any. @throws BaseInvalidArgumentException If the message or the code is invalid.
[ "Initializes", "the", "base", "exception", "." ]
d42828984c85a509af3f7fde709561a1e520b9e4
https://github.com/Dhii/exception/blob/d42828984c85a509af3f7fde709561a1e520b9e4/src/InitBaseExceptionCapableTrait.php#L27-L37
train
ricardopedias/old-extended
src/Accessor.php
Accessor.dateTransform
public function dateTransform($date_value, $format_origin = 'd/m/Y H:i:s', $format_destiny = 'Y-m-d H:i:s') { $date = \DateTime::createFromFormat($format_origin, $date_value); return $date !== false ? $date->format($format_destiny) : ''; }
php
public function dateTransform($date_value, $format_origin = 'd/m/Y H:i:s', $format_destiny = 'Y-m-d H:i:s') { $date = \DateTime::createFromFormat($format_origin, $date_value); return $date !== false ? $date->format($format_destiny) : ''; }
[ "public", "function", "dateTransform", "(", "$", "date_value", ",", "$", "format_origin", "=", "'d/m/Y H:i:s'", ",", "$", "format_destiny", "=", "'Y-m-d H:i:s'", ")", "{", "$", "date", "=", "\\", "DateTime", "::", "createFromFormat", "(", "$", "format_origin", ",", "$", "date_value", ")", ";", "return", "$", "date", "!==", "false", "?", "$", "date", "->", "format", "(", "$", "format_destiny", ")", ":", "''", ";", "}" ]
Transforma uma data de um formato para outro @param string $date_value O valor da data @param string $format_origin O formato original do valor Ex: d/m/Y @param string $format_destiny O formato transformado Ex: Y-m-d
[ "Transforma", "uma", "data", "de", "um", "formato", "para", "outro" ]
381a1cfc6aa4915e701ad252a7c78733e8484f26
https://github.com/ricardopedias/old-extended/blob/381a1cfc6aa4915e701ad252a7c78733e8484f26/src/Accessor.php#L165-L169
train
blueblazeassociates/geocode-postalcodes
src/php/Utils.php
Utils.validate_distance
public static function validate_distance( $distance ) { $valid = filter_var( $distance, FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'max_range' => PHP_INT_MAX )) ); return false !== $valid ? true : false; }
php
public static function validate_distance( $distance ) { $valid = filter_var( $distance, FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'max_range' => PHP_INT_MAX )) ); return false !== $valid ? true : false; }
[ "public", "static", "function", "validate_distance", "(", "$", "distance", ")", "{", "$", "valid", "=", "filter_var", "(", "$", "distance", ",", "FILTER_VALIDATE_INT", ",", "array", "(", "'options'", "=>", "array", "(", "'min_range'", "=>", "1", ",", "'max_range'", "=>", "PHP_INT_MAX", ")", ")", ")", ";", "return", "false", "!==", "$", "valid", "?", "true", ":", "false", ";", "}" ]
Validate distance. Distance must be a positive integer. @param string|integer $distance @return boolean
[ "Validate", "distance", "." ]
3a9b6c68327b13f5dc15015e78223dd215e8d4ea
https://github.com/blueblazeassociates/geocode-postalcodes/blob/3a9b6c68327b13f5dc15015e78223dd215e8d4ea/src/php/Utils.php#L18-L27
train
dms-org/common.structure
src/DateTime/DateTimeBase.php
DateTimeBase.diff
public function diff(DateTimeBase $other, bool $absolute = false) { return $this->dateTime->diff($other->dateTime, $absolute); }
php
public function diff(DateTimeBase $other, bool $absolute = false) { return $this->dateTime->diff($other->dateTime, $absolute); }
[ "public", "function", "diff", "(", "DateTimeBase", "$", "other", ",", "bool", "$", "absolute", "=", "false", ")", "{", "return", "$", "this", "->", "dateTime", "->", "diff", "(", "$", "other", "->", "dateTime", ",", "$", "absolute", ")", ";", "}" ]
Returns a diff of the supplied date time. @param DateTimeBase $other @param bool $absolute @return \DateInterval
[ "Returns", "a", "diff", "of", "the", "supplied", "date", "time", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/DateTimeBase.php#L31-L34
train
dms-org/common.structure
src/DateTime/DateTimeBase.php
DateTimeBase.equals
public function equals(DateTimeBase $other) : bool { $dateTime = $this->dateTime; $otherDateTime = $other->dateTime; return $dateTime == $otherDateTime && $dateTime->getTimezone()->getName() === $otherDateTime->getTimezone()->getName(); }
php
public function equals(DateTimeBase $other) : bool { $dateTime = $this->dateTime; $otherDateTime = $other->dateTime; return $dateTime == $otherDateTime && $dateTime->getTimezone()->getName() === $otherDateTime->getTimezone()->getName(); }
[ "public", "function", "equals", "(", "DateTimeBase", "$", "other", ")", ":", "bool", "{", "$", "dateTime", "=", "$", "this", "->", "dateTime", ";", "$", "otherDateTime", "=", "$", "other", "->", "dateTime", ";", "return", "$", "dateTime", "==", "$", "otherDateTime", "&&", "$", "dateTime", "->", "getTimezone", "(", ")", "->", "getName", "(", ")", "===", "$", "otherDateTime", "->", "getTimezone", "(", ")", "->", "getName", "(", ")", ";", "}" ]
Returns whether the DateTimeBase is equal to the supplied date. @param DateTimeBase $other @return bool
[ "Returns", "whether", "the", "DateTimeBase", "is", "equal", "to", "the", "supplied", "date", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/DateTimeBase.php#L43-L50
train
johnkrovitch/SamBundle
src/Command/AbstractCommand.php
AbstractCommand.buildTasks
protected function buildTasks(array $configuration) { $this->io->text('- Building tasks...'); $builder = new TaskBuilder($this->debug); $tasks = $builder->build($configuration); $this->io->text('- Tasks build !'); $this->io->newLine(); return $tasks; }
php
protected function buildTasks(array $configuration) { $this->io->text('- Building tasks...'); $builder = new TaskBuilder($this->debug); $tasks = $builder->build($configuration); $this->io->text('- Tasks build !'); $this->io->newLine(); return $tasks; }
[ "protected", "function", "buildTasks", "(", "array", "$", "configuration", ")", "{", "$", "this", "->", "io", "->", "text", "(", "'- Building tasks...'", ")", ";", "$", "builder", "=", "new", "TaskBuilder", "(", "$", "this", "->", "debug", ")", ";", "$", "tasks", "=", "$", "builder", "->", "build", "(", "$", "configuration", ")", ";", "$", "this", "->", "io", "->", "text", "(", "'- Tasks build !'", ")", ";", "$", "this", "->", "io", "->", "newLine", "(", ")", ";", "return", "$", "tasks", ";", "}" ]
Build tasks from the configuration array. @param array $configuration @return Task[]
[ "Build", "tasks", "from", "the", "configuration", "array", "." ]
6cc08ef2dd8f7cd5c33ee27818edd4697afa435e
https://github.com/johnkrovitch/SamBundle/blob/6cc08ef2dd8f7cd5c33ee27818edd4697afa435e/src/Command/AbstractCommand.php#L48-L59
train
johnkrovitch/SamBundle
src/Command/AbstractCommand.php
AbstractCommand.buildFilters
protected function buildFilters(array $configuration) { $this->io->text('- Building filters...'); $builder = new FilterBuilder($this->eventDispatcher); $filters = $builder->build($configuration); $this->io->text('- Filters build !'); $this->io->newLine(); return $filters; }
php
protected function buildFilters(array $configuration) { $this->io->text('- Building filters...'); $builder = new FilterBuilder($this->eventDispatcher); $filters = $builder->build($configuration); $this->io->text('- Filters build !'); $this->io->newLine(); return $filters; }
[ "protected", "function", "buildFilters", "(", "array", "$", "configuration", ")", "{", "$", "this", "->", "io", "->", "text", "(", "'- Building filters...'", ")", ";", "$", "builder", "=", "new", "FilterBuilder", "(", "$", "this", "->", "eventDispatcher", ")", ";", "$", "filters", "=", "$", "builder", "->", "build", "(", "$", "configuration", ")", ";", "$", "this", "->", "io", "->", "text", "(", "'- Filters build !'", ")", ";", "$", "this", "->", "io", "->", "newLine", "(", ")", ";", "return", "$", "filters", ";", "}" ]
Build the filter according to the configuration array. @param array $configuration @return FilterInterface[]
[ "Build", "the", "filter", "according", "to", "the", "configuration", "array", "." ]
6cc08ef2dd8f7cd5c33ee27818edd4697afa435e
https://github.com/johnkrovitch/SamBundle/blob/6cc08ef2dd8f7cd5c33ee27818edd4697afa435e/src/Command/AbstractCommand.php#L68-L79
train
johnkrovitch/SamBundle
src/Command/AbstractCommand.php
AbstractCommand.loadConfigurationFile
protected function loadConfigurationFile($configurationFile) { if (!file_exists($configurationFile)) { throw new Exception('The configuration yml file '.$configurationFile.' was not found'); } $configuration = Yaml::parse(file_get_contents($configurationFile)); if (empty($configuration['jk_assets']['tasks'])) { throw new Exception('Tasks not found in configuration file '.$configurationFile); } return $configuration['jk_assets']['tasks']; }
php
protected function loadConfigurationFile($configurationFile) { if (!file_exists($configurationFile)) { throw new Exception('The configuration yml file '.$configurationFile.' was not found'); } $configuration = Yaml::parse(file_get_contents($configurationFile)); if (empty($configuration['jk_assets']['tasks'])) { throw new Exception('Tasks not found in configuration file '.$configurationFile); } return $configuration['jk_assets']['tasks']; }
[ "protected", "function", "loadConfigurationFile", "(", "$", "configurationFile", ")", "{", "if", "(", "!", "file_exists", "(", "$", "configurationFile", ")", ")", "{", "throw", "new", "Exception", "(", "'The configuration yml file '", ".", "$", "configurationFile", ".", "' was not found'", ")", ";", "}", "$", "configuration", "=", "Yaml", "::", "parse", "(", "file_get_contents", "(", "$", "configurationFile", ")", ")", ";", "if", "(", "empty", "(", "$", "configuration", "[", "'jk_assets'", "]", "[", "'tasks'", "]", ")", ")", "{", "throw", "new", "Exception", "(", "'Tasks not found in configuration file '", ".", "$", "configurationFile", ")", ";", "}", "return", "$", "configuration", "[", "'jk_assets'", "]", "[", "'tasks'", "]", ";", "}" ]
Load the configuration from a yml file. @param $configurationFile @return string[] @throws Exception
[ "Load", "the", "configuration", "from", "a", "yml", "file", "." ]
6cc08ef2dd8f7cd5c33ee27818edd4697afa435e
https://github.com/johnkrovitch/SamBundle/blob/6cc08ef2dd8f7cd5c33ee27818edd4697afa435e/src/Command/AbstractCommand.php#L90-L102
train
johnkrovitch/SamBundle
src/Command/AbstractCommand.php
AbstractCommand.loadConfiguration
protected function loadConfiguration(InputInterface $input) { $loader = new ConfigurationLoader(); if ($input->hasOption('config') && $file = $input->getOption('config')) { $configuration = $loader->loadFromFile($file); } else { if (null === $this->container) { throw new Exception('Unable to find the assets configuration from the container'); } $configuration = $loader->loadFromContainer($this->container); } return $configuration; }
php
protected function loadConfiguration(InputInterface $input) { $loader = new ConfigurationLoader(); if ($input->hasOption('config') && $file = $input->getOption('config')) { $configuration = $loader->loadFromFile($file); } else { if (null === $this->container) { throw new Exception('Unable to find the assets configuration from the container'); } $configuration = $loader->loadFromContainer($this->container); } return $configuration; }
[ "protected", "function", "loadConfiguration", "(", "InputInterface", "$", "input", ")", "{", "$", "loader", "=", "new", "ConfigurationLoader", "(", ")", ";", "if", "(", "$", "input", "->", "hasOption", "(", "'config'", ")", "&&", "$", "file", "=", "$", "input", "->", "getOption", "(", "'config'", ")", ")", "{", "$", "configuration", "=", "$", "loader", "->", "loadFromFile", "(", "$", "file", ")", ";", "}", "else", "{", "if", "(", "null", "===", "$", "this", "->", "container", ")", "{", "throw", "new", "Exception", "(", "'Unable to find the assets configuration from the container'", ")", ";", "}", "$", "configuration", "=", "$", "loader", "->", "loadFromContainer", "(", "$", "this", "->", "container", ")", ";", "}", "return", "$", "configuration", ";", "}" ]
Load the configuration from a yml file or the container, according to the given option. @param InputInterface $input @return array @throws Exception
[ "Load", "the", "configuration", "from", "a", "yml", "file", "or", "the", "container", "according", "to", "the", "given", "option", "." ]
6cc08ef2dd8f7cd5c33ee27818edd4697afa435e
https://github.com/johnkrovitch/SamBundle/blob/6cc08ef2dd8f7cd5c33ee27818edd4697afa435e/src/Command/AbstractCommand.php#L113-L128
train
johnkrovitch/SamBundle
src/Command/AbstractCommand.php
AbstractCommand.setContainer
public function setContainer(ContainerInterface $container = null) { $this->container = $container; $this->eventDispatcher = $this->container->get('event_dispatcher'); }
php
public function setContainer(ContainerInterface $container = null) { $this->container = $container; $this->eventDispatcher = $this->container->get('event_dispatcher'); }
[ "public", "function", "setContainer", "(", "ContainerInterface", "$", "container", "=", "null", ")", "{", "$", "this", "->", "container", "=", "$", "container", ";", "$", "this", "->", "eventDispatcher", "=", "$", "this", "->", "container", "->", "get", "(", "'event_dispatcher'", ")", ";", "}" ]
Sets the container. @param ContainerInterface|null $container A ContainerInterface instance or null
[ "Sets", "the", "container", "." ]
6cc08ef2dd8f7cd5c33ee27818edd4697afa435e
https://github.com/johnkrovitch/SamBundle/blob/6cc08ef2dd8f7cd5c33ee27818edd4697afa435e/src/Command/AbstractCommand.php#L135-L139
train
spoom-php/core
src/extension/Event/Emitter.php
Emitter.sort
protected function sort() { if( !empty( $this->_callback_list ) ) { // sort by the priorities, but keep the original indexes (we need it for the repopulation) $priority_list = $this->_priority_list; asort( $priority_list ); // repopulate the callbacks based on the new priority "map" $tmp = $this->_callback_list; $this->_callback_list = []; foreach( $priority_list as $index => $_ ) { $this->_callback_list[] = $tmp[ $index ]; } // reset priority indexes (to match the repopulated array) $this->_priority_list = array_values( $priority_list ); } }
php
protected function sort() { if( !empty( $this->_callback_list ) ) { // sort by the priorities, but keep the original indexes (we need it for the repopulation) $priority_list = $this->_priority_list; asort( $priority_list ); // repopulate the callbacks based on the new priority "map" $tmp = $this->_callback_list; $this->_callback_list = []; foreach( $priority_list as $index => $_ ) { $this->_callback_list[] = $tmp[ $index ]; } // reset priority indexes (to match the repopulated array) $this->_priority_list = array_values( $priority_list ); } }
[ "protected", "function", "sort", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "_callback_list", ")", ")", "{", "// sort by the priorities, but keep the original indexes (we need it for the repopulation)", "$", "priority_list", "=", "$", "this", "->", "_priority_list", ";", "asort", "(", "$", "priority_list", ")", ";", "// repopulate the callbacks based on the new priority \"map\"", "$", "tmp", "=", "$", "this", "->", "_callback_list", ";", "$", "this", "->", "_callback_list", "=", "[", "]", ";", "foreach", "(", "$", "priority_list", "as", "$", "index", "=>", "$", "_", ")", "{", "$", "this", "->", "_callback_list", "[", "]", "=", "$", "tmp", "[", "$", "index", "]", ";", "}", "// reset priority indexes (to match the repopulated array)", "$", "this", "->", "_priority_list", "=", "array_values", "(", "$", "priority_list", ")", ";", "}", "}" ]
Sort callbacks based on their priority
[ "Sort", "callbacks", "based", "on", "their", "priority" ]
ea7184213352fa2fad7636927a019e5798734e04
https://github.com/spoom-php/core/blob/ea7184213352fa2fad7636927a019e5798734e04/src/extension/Event/Emitter.php#L149-L166
train
lasallecms/lasallecms-l5-tokenbasedlogin-pkg
src/Repositories/UserTokenbasedloginRepository.php
UserTokenbasedloginRepository.createLoginToken
public function createLoginToken($userID) { $user = $this->getFind($userID); $user->login_token = hash_hmac('sha256', Str::random(40), 'secret'); $user->login_token_created_at = Carbon::now(); return $user->save(); }
php
public function createLoginToken($userID) { $user = $this->getFind($userID); $user->login_token = hash_hmac('sha256', Str::random(40), 'secret'); $user->login_token_created_at = Carbon::now(); return $user->save(); }
[ "public", "function", "createLoginToken", "(", "$", "userID", ")", "{", "$", "user", "=", "$", "this", "->", "getFind", "(", "$", "userID", ")", ";", "$", "user", "->", "login_token", "=", "hash_hmac", "(", "'sha256'", ",", "Str", "::", "random", "(", "40", ")", ",", "'secret'", ")", ";", "$", "user", "->", "login_token_created_at", "=", "Carbon", "::", "now", "(", ")", ";", "return", "$", "user", "->", "save", "(", ")", ";", "}" ]
UPDATE the "users" table with a login token @param int $userID User's ID
[ "UPDATE", "the", "users", "table", "with", "a", "login", "token" ]
8b7bc14b959626c3b02111415dd5f0a9b96b11ac
https://github.com/lasallecms/lasallecms-l5-tokenbasedlogin-pkg/blob/8b7bc14b959626c3b02111415dd5f0a9b96b11ac/src/Repositories/UserTokenbasedloginRepository.php#L84-L91
train
lasallecms/lasallecms-l5-tokenbasedlogin-pkg
src/Repositories/UserTokenbasedloginRepository.php
UserTokenbasedloginRepository.isLoginTokenExpired
public function isLoginTokenExpired($user) { $startTime = strtotime($user->login_token_created_at); $now = strtotime(Carbon::now()); // The time difference is in seconds, we want in minutes $timeDiff = ($now - $startTime)/60; $minutes2faFormIsLive = config('lasallecmstokenbasedlogin.token_login_minutes_token_is_live'); if ($timeDiff > $minutes2faFormIsLive) { // Login token has expired return true; } return false; }
php
public function isLoginTokenExpired($user) { $startTime = strtotime($user->login_token_created_at); $now = strtotime(Carbon::now()); // The time difference is in seconds, we want in minutes $timeDiff = ($now - $startTime)/60; $minutes2faFormIsLive = config('lasallecmstokenbasedlogin.token_login_minutes_token_is_live'); if ($timeDiff > $minutes2faFormIsLive) { // Login token has expired return true; } return false; }
[ "public", "function", "isLoginTokenExpired", "(", "$", "user", ")", "{", "$", "startTime", "=", "strtotime", "(", "$", "user", "->", "login_token_created_at", ")", ";", "$", "now", "=", "strtotime", "(", "Carbon", "::", "now", "(", ")", ")", ";", "// The time difference is in seconds, we want in minutes", "$", "timeDiff", "=", "(", "$", "now", "-", "$", "startTime", ")", "/", "60", ";", "$", "minutes2faFormIsLive", "=", "config", "(", "'lasallecmstokenbasedlogin.token_login_minutes_token_is_live'", ")", ";", "if", "(", "$", "timeDiff", ">", "$", "minutes2faFormIsLive", ")", "{", "// Login token has expired", "return", "true", ";", "}", "return", "false", ";", "}" ]
Has a login token expired? @param object $user User object @return bool
[ "Has", "a", "login", "token", "expired?" ]
8b7bc14b959626c3b02111415dd5f0a9b96b11ac
https://github.com/lasallecms/lasallecms-l5-tokenbasedlogin-pkg/blob/8b7bc14b959626c3b02111415dd5f0a9b96b11ac/src/Repositories/UserTokenbasedloginRepository.php#L109-L120
train
lasallecms/lasallecms-l5-tokenbasedlogin-pkg
src/Repositories/UserTokenbasedloginRepository.php
UserTokenbasedloginRepository.deleteUserLoginTokenFields
public function deleteUserLoginTokenFields($userID) { $user = $this->getFind($userID); $user->login_token = ''; $user->login_token_created_at = ''; return $user->save(); }
php
public function deleteUserLoginTokenFields($userID) { $user = $this->getFind($userID); $user->login_token = ''; $user->login_token_created_at = ''; return $user->save(); }
[ "public", "function", "deleteUserLoginTokenFields", "(", "$", "userID", ")", "{", "$", "user", "=", "$", "this", "->", "getFind", "(", "$", "userID", ")", ";", "$", "user", "->", "login_token", "=", "''", ";", "$", "user", "->", "login_token_created_at", "=", "''", ";", "return", "$", "user", "->", "save", "(", ")", ";", "}" ]
Remove the 'login_token' and 'login_token_created_at' fields. @param int $userID The user's ID @return mixed
[ "Remove", "the", "login_token", "and", "login_token_created_at", "fields", "." ]
8b7bc14b959626c3b02111415dd5f0a9b96b11ac
https://github.com/lasallecms/lasallecms-l5-tokenbasedlogin-pkg/blob/8b7bc14b959626c3b02111415dd5f0a9b96b11ac/src/Repositories/UserTokenbasedloginRepository.php#L128-L135
train
nails/module-blog
blog/controllers/Blog.php
NAILS_Blog.index
public function index() { // Meta & Breadcrumbs $this->data['page']->title = APP_NAME . ' Blog'; $this->data['page']->seo->description = ''; $this->data['page']->seo->keywords = ''; // -------------------------------------------------------------------------- // Handle pagination $page = $this->uri->rsegment(3); $perPage = appSetting('home_per_page', 'blog-' . $this->oBlog->id); $perPage = $perPage ? $perPage : 10; $this->data['pagination'] = new stdClass(); $this->data['pagination']->page = $page; $this->data['pagination']->per_page = $perPage; // -------------------------------------------------------------------------- // Send any additional data $data = array(); $data['include_body'] = !appSetting('use_excerpts', 'blog-' . $this->oBlog->id); $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id); $data['sort'] = array('bp.published', 'desc'); // Only published items which are not schduled for the future $data['where'] = array(); $data['where'][] = array('column' => 'blog_id', 'value' => $this->oBlog->id); $data['where'][] = array('column' => 'is_published', 'value' => true); $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false); // -------------------------------------------------------------------------- // Load posts and count $this->data['posts'] = $this->blog_post_model->getAll($page, $perPage, $data); $this->data['pagination']->total = $this->blog_post_model->countAll($data); // -------------------------------------------------------------------------- // Widgets $this->fetchSidebarWidgets(); // -------------------------------------------------------------------------- $this->data['isIndex'] = true; // -------------------------------------------------------------------------- // Load views $oView = Factory::service('View'); $oView->load('structure/header', $this->data); $this->loadView('browse', $this->data); $oView->load('structure/footer', $this->data); }
php
public function index() { // Meta & Breadcrumbs $this->data['page']->title = APP_NAME . ' Blog'; $this->data['page']->seo->description = ''; $this->data['page']->seo->keywords = ''; // -------------------------------------------------------------------------- // Handle pagination $page = $this->uri->rsegment(3); $perPage = appSetting('home_per_page', 'blog-' . $this->oBlog->id); $perPage = $perPage ? $perPage : 10; $this->data['pagination'] = new stdClass(); $this->data['pagination']->page = $page; $this->data['pagination']->per_page = $perPage; // -------------------------------------------------------------------------- // Send any additional data $data = array(); $data['include_body'] = !appSetting('use_excerpts', 'blog-' . $this->oBlog->id); $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id); $data['sort'] = array('bp.published', 'desc'); // Only published items which are not schduled for the future $data['where'] = array(); $data['where'][] = array('column' => 'blog_id', 'value' => $this->oBlog->id); $data['where'][] = array('column' => 'is_published', 'value' => true); $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false); // -------------------------------------------------------------------------- // Load posts and count $this->data['posts'] = $this->blog_post_model->getAll($page, $perPage, $data); $this->data['pagination']->total = $this->blog_post_model->countAll($data); // -------------------------------------------------------------------------- // Widgets $this->fetchSidebarWidgets(); // -------------------------------------------------------------------------- $this->data['isIndex'] = true; // -------------------------------------------------------------------------- // Load views $oView = Factory::service('View'); $oView->load('structure/header', $this->data); $this->loadView('browse', $this->data); $oView->load('structure/footer', $this->data); }
[ "public", "function", "index", "(", ")", "{", "// Meta & Breadcrumbs", "$", "this", "->", "data", "[", "'page'", "]", "->", "title", "=", "APP_NAME", ".", "' Blog'", ";", "$", "this", "->", "data", "[", "'page'", "]", "->", "seo", "->", "description", "=", "''", ";", "$", "this", "->", "data", "[", "'page'", "]", "->", "seo", "->", "keywords", "=", "''", ";", "// --------------------------------------------------------------------------", "// Handle pagination", "$", "page", "=", "$", "this", "->", "uri", "->", "rsegment", "(", "3", ")", ";", "$", "perPage", "=", "appSetting", "(", "'home_per_page'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ";", "$", "perPage", "=", "$", "perPage", "?", "$", "perPage", ":", "10", ";", "$", "this", "->", "data", "[", "'pagination'", "]", "=", "new", "stdClass", "(", ")", ";", "$", "this", "->", "data", "[", "'pagination'", "]", "->", "page", "=", "$", "page", ";", "$", "this", "->", "data", "[", "'pagination'", "]", "->", "per_page", "=", "$", "perPage", ";", "// --------------------------------------------------------------------------", "// Send any additional data", "$", "data", "=", "array", "(", ")", ";", "$", "data", "[", "'include_body'", "]", "=", "!", "appSetting", "(", "'use_excerpts'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ";", "$", "data", "[", "'include_gallery'", "]", "=", "appSetting", "(", "'home_show_gallery'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ";", "$", "data", "[", "'sort'", "]", "=", "array", "(", "'bp.published'", ",", "'desc'", ")", ";", "// Only published items which are not schduled for the future", "$", "data", "[", "'where'", "]", "=", "array", "(", ")", ";", "$", "data", "[", "'where'", "]", "[", "]", "=", "array", "(", "'column'", "=>", "'blog_id'", ",", "'value'", "=>", "$", "this", "->", "oBlog", "->", "id", ")", ";", "$", "data", "[", "'where'", "]", "[", "]", "=", "array", "(", "'column'", "=>", "'is_published'", ",", "'value'", "=>", "true", ")", ";", "$", "data", "[", "'where'", "]", "[", "]", "=", "array", "(", "'column'", "=>", "'published <='", ",", "'value'", "=>", "'NOW()'", ",", "'escape'", "=>", "false", ")", ";", "// --------------------------------------------------------------------------", "// Load posts and count", "$", "this", "->", "data", "[", "'posts'", "]", "=", "$", "this", "->", "blog_post_model", "->", "getAll", "(", "$", "page", ",", "$", "perPage", ",", "$", "data", ")", ";", "$", "this", "->", "data", "[", "'pagination'", "]", "->", "total", "=", "$", "this", "->", "blog_post_model", "->", "countAll", "(", "$", "data", ")", ";", "// --------------------------------------------------------------------------", "// Widgets", "$", "this", "->", "fetchSidebarWidgets", "(", ")", ";", "// --------------------------------------------------------------------------", "$", "this", "->", "data", "[", "'isIndex'", "]", "=", "true", ";", "// --------------------------------------------------------------------------", "// Load views", "$", "oView", "=", "Factory", "::", "service", "(", "'View'", ")", ";", "$", "oView", "->", "load", "(", "'structure/header'", ",", "$", "this", "->", "data", ")", ";", "$", "this", "->", "loadView", "(", "'browse'", ",", "$", "this", "->", "data", ")", ";", "$", "oView", "->", "load", "(", "'structure/footer'", ",", "$", "this", "->", "data", ")", ";", "}" ]
Browse all posts @return void
[ "Browse", "all", "posts" ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/controllers/Blog.php#L45-L99
train
nails/module-blog
blog/controllers/Blog.php
NAILS_Blog.rss
public function rss() { if (!appSetting('rss_enabled', 'blog-' . $this->oBlog->id)) { show404(); } // -------------------------------------------------------------------------- // Get posts $data = array(); $data['include_body'] = true; $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id); $data['sort'] = array('bp.published', 'desc'); // Only published items which are not schduled for the future $data['where'] = array(); $data['where'][] = array('column' => 'blog_id', 'value' => $this->oBlog->id); $data['where'][] = array('column' => 'is_published', 'value' => true); $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false); $this->data['posts'] = $this->blog_post_model->getAll(null, null, $data); $this->data['isRss'] = true; // Set Output $oOutput = Factory::service('Output'); $oOutput->set_content_type('text/xml; charset=UTF-8'); $this->loadView('rss', $this->data); }
php
public function rss() { if (!appSetting('rss_enabled', 'blog-' . $this->oBlog->id)) { show404(); } // -------------------------------------------------------------------------- // Get posts $data = array(); $data['include_body'] = true; $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id); $data['sort'] = array('bp.published', 'desc'); // Only published items which are not schduled for the future $data['where'] = array(); $data['where'][] = array('column' => 'blog_id', 'value' => $this->oBlog->id); $data['where'][] = array('column' => 'is_published', 'value' => true); $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false); $this->data['posts'] = $this->blog_post_model->getAll(null, null, $data); $this->data['isRss'] = true; // Set Output $oOutput = Factory::service('Output'); $oOutput->set_content_type('text/xml; charset=UTF-8'); $this->loadView('rss', $this->data); }
[ "public", "function", "rss", "(", ")", "{", "if", "(", "!", "appSetting", "(", "'rss_enabled'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ")", "{", "show404", "(", ")", ";", "}", "// --------------------------------------------------------------------------", "// Get posts", "$", "data", "=", "array", "(", ")", ";", "$", "data", "[", "'include_body'", "]", "=", "true", ";", "$", "data", "[", "'include_gallery'", "]", "=", "appSetting", "(", "'home_show_gallery'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ";", "$", "data", "[", "'sort'", "]", "=", "array", "(", "'bp.published'", ",", "'desc'", ")", ";", "// Only published items which are not schduled for the future", "$", "data", "[", "'where'", "]", "=", "array", "(", ")", ";", "$", "data", "[", "'where'", "]", "[", "]", "=", "array", "(", "'column'", "=>", "'blog_id'", ",", "'value'", "=>", "$", "this", "->", "oBlog", "->", "id", ")", ";", "$", "data", "[", "'where'", "]", "[", "]", "=", "array", "(", "'column'", "=>", "'is_published'", ",", "'value'", "=>", "true", ")", ";", "$", "data", "[", "'where'", "]", "[", "]", "=", "array", "(", "'column'", "=>", "'published <='", ",", "'value'", "=>", "'NOW()'", ",", "'escape'", "=>", "false", ")", ";", "$", "this", "->", "data", "[", "'posts'", "]", "=", "$", "this", "->", "blog_post_model", "->", "getAll", "(", "null", ",", "null", ",", "$", "data", ")", ";", "$", "this", "->", "data", "[", "'isRss'", "]", "=", "true", ";", "// Set Output", "$", "oOutput", "=", "Factory", "::", "service", "(", "'Output'", ")", ";", "$", "oOutput", "->", "set_content_type", "(", "'text/xml; charset=UTF-8'", ")", ";", "$", "this", "->", "loadView", "(", "'rss'", ",", "$", "this", "->", "data", ")", ";", "}" ]
RSS Feed for the blog @return void
[ "RSS", "Feed", "for", "the", "blog" ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/controllers/Blog.php#L438-L467
train
nails/module-blog
blog/controllers/Blog.php
NAILS_Blog.fetchSidebarWidgets
protected function fetchSidebarWidgets() { $this->data['widget'] = new stdClass(); if (appSetting('sidebar_latest_posts', 'blog-' . $this->oBlog->id)) { $this->data['widget']->latest_posts = $this->blog_widget_model->latestPosts($this->oBlog->id); } if (appSetting('sidebar_categories', 'blog-' . $this->oBlog->id)) { $this->data['widget']->categories = $this->blog_widget_model->categories($this->oBlog->id); } if (appSetting('sidebar_tags', 'blog-' . $this->oBlog->id)) { $this->data['widget']->tags = $this->blog_widget_model->tags($this->oBlog->id); } if (appSetting('sidebar_popular_posts', 'blog-' . $this->oBlog->id)) { $this->data['widget']->popular_posts = $this->blog_widget_model->popularPosts($this->oBlog->id); } }
php
protected function fetchSidebarWidgets() { $this->data['widget'] = new stdClass(); if (appSetting('sidebar_latest_posts', 'blog-' . $this->oBlog->id)) { $this->data['widget']->latest_posts = $this->blog_widget_model->latestPosts($this->oBlog->id); } if (appSetting('sidebar_categories', 'blog-' . $this->oBlog->id)) { $this->data['widget']->categories = $this->blog_widget_model->categories($this->oBlog->id); } if (appSetting('sidebar_tags', 'blog-' . $this->oBlog->id)) { $this->data['widget']->tags = $this->blog_widget_model->tags($this->oBlog->id); } if (appSetting('sidebar_popular_posts', 'blog-' . $this->oBlog->id)) { $this->data['widget']->popular_posts = $this->blog_widget_model->popularPosts($this->oBlog->id); } }
[ "protected", "function", "fetchSidebarWidgets", "(", ")", "{", "$", "this", "->", "data", "[", "'widget'", "]", "=", "new", "stdClass", "(", ")", ";", "if", "(", "appSetting", "(", "'sidebar_latest_posts'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ")", "{", "$", "this", "->", "data", "[", "'widget'", "]", "->", "latest_posts", "=", "$", "this", "->", "blog_widget_model", "->", "latestPosts", "(", "$", "this", "->", "oBlog", "->", "id", ")", ";", "}", "if", "(", "appSetting", "(", "'sidebar_categories'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ")", "{", "$", "this", "->", "data", "[", "'widget'", "]", "->", "categories", "=", "$", "this", "->", "blog_widget_model", "->", "categories", "(", "$", "this", "->", "oBlog", "->", "id", ")", ";", "}", "if", "(", "appSetting", "(", "'sidebar_tags'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ")", "{", "$", "this", "->", "data", "[", "'widget'", "]", "->", "tags", "=", "$", "this", "->", "blog_widget_model", "->", "tags", "(", "$", "this", "->", "oBlog", "->", "id", ")", ";", "}", "if", "(", "appSetting", "(", "'sidebar_popular_posts'", ",", "'blog-'", ".", "$", "this", "->", "oBlog", "->", "id", ")", ")", "{", "$", "this", "->", "data", "[", "'widget'", "]", "->", "popular_posts", "=", "$", "this", "->", "blog_widget_model", "->", "popularPosts", "(", "$", "this", "->", "oBlog", "->", "id", ")", ";", "}", "}" ]
Loads all the enabled sidebar widgets @return void
[ "Loads", "all", "the", "enabled", "sidebar", "widgets" ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/controllers/Blog.php#L498-L521
train
nails/module-blog
blog/controllers/Blog.php
NAILS_Blog.loadView
private function loadView($sView, $aData = array()) { $oView = Factory::service('View'); $sFile = $this->oSkin->path . 'views/' . $sView; if (is_file($sFile . '.php')) { $oView->load($sFile, $aData); } elseif (!empty($this->oSkinParent)) { $sFile = $this->oSkinParent->path . 'views/' . $sView; if (is_file($sFile . '.php')) { $oView->load($sFile, $aData); } else { throw new NailsException('Failed to load blog view "' . $sView . '"'); } } else { throw new NailsException('Failed to load blog view "' . $sView . '"'); } }
php
private function loadView($sView, $aData = array()) { $oView = Factory::service('View'); $sFile = $this->oSkin->path . 'views/' . $sView; if (is_file($sFile . '.php')) { $oView->load($sFile, $aData); } elseif (!empty($this->oSkinParent)) { $sFile = $this->oSkinParent->path . 'views/' . $sView; if (is_file($sFile . '.php')) { $oView->load($sFile, $aData); } else { throw new NailsException('Failed to load blog view "' . $sView . '"'); } } else { throw new NailsException('Failed to load blog view "' . $sView . '"'); } }
[ "private", "function", "loadView", "(", "$", "sView", ",", "$", "aData", "=", "array", "(", ")", ")", "{", "$", "oView", "=", "Factory", "::", "service", "(", "'View'", ")", ";", "$", "sFile", "=", "$", "this", "->", "oSkin", "->", "path", ".", "'views/'", ".", "$", "sView", ";", "if", "(", "is_file", "(", "$", "sFile", ".", "'.php'", ")", ")", "{", "$", "oView", "->", "load", "(", "$", "sFile", ",", "$", "aData", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "this", "->", "oSkinParent", ")", ")", "{", "$", "sFile", "=", "$", "this", "->", "oSkinParent", "->", "path", ".", "'views/'", ".", "$", "sView", ";", "if", "(", "is_file", "(", "$", "sFile", ".", "'.php'", ")", ")", "{", "$", "oView", "->", "load", "(", "$", "sFile", ",", "$", "aData", ")", ";", "}", "else", "{", "throw", "new", "NailsException", "(", "'Failed to load blog view \"'", ".", "$", "sView", ".", "'\"'", ")", ";", "}", "}", "else", "{", "throw", "new", "NailsException", "(", "'Failed to load blog view \"'", ".", "$", "sView", ".", "'\"'", ")", ";", "}", "}" ]
Loads a view from the skin, falls back tot he parent view if there is one. @param string $sView The view to load @return void
[ "Loads", "a", "view", "from", "the", "skin", "falls", "back", "tot", "he", "parent", "view", "if", "there", "is", "one", "." ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/controllers/Blog.php#L530-L552
train
nails/module-blog
blog/controllers/Blog.php
NAILS_Blog._remap
public function _remap() { $method = $this->uri->rsegment(3) ? $this->uri->rsegment(3) : 'index'; if (method_exists($this, $method) && substr($method, 0, 1) != '_' && $this->input->get('id')) { // Permalink $this->single($this->input->get('id')); } elseif (method_exists($this, $method) && substr($method, 0, 1) != '_') { // Method exists, execute it $this->{$method}(); } elseif (is_numeric($method)) { // Paginating the main blog page $this->index(); } else { // Doesn't exist, consider rsegment(3) a slug $this->single(); } }
php
public function _remap() { $method = $this->uri->rsegment(3) ? $this->uri->rsegment(3) : 'index'; if (method_exists($this, $method) && substr($method, 0, 1) != '_' && $this->input->get('id')) { // Permalink $this->single($this->input->get('id')); } elseif (method_exists($this, $method) && substr($method, 0, 1) != '_') { // Method exists, execute it $this->{$method}(); } elseif (is_numeric($method)) { // Paginating the main blog page $this->index(); } else { // Doesn't exist, consider rsegment(3) a slug $this->single(); } }
[ "public", "function", "_remap", "(", ")", "{", "$", "method", "=", "$", "this", "->", "uri", "->", "rsegment", "(", "3", ")", "?", "$", "this", "->", "uri", "->", "rsegment", "(", "3", ")", ":", "'index'", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", "&&", "substr", "(", "$", "method", ",", "0", ",", "1", ")", "!=", "'_'", "&&", "$", "this", "->", "input", "->", "get", "(", "'id'", ")", ")", "{", "// Permalink", "$", "this", "->", "single", "(", "$", "this", "->", "input", "->", "get", "(", "'id'", ")", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", "&&", "substr", "(", "$", "method", ",", "0", ",", "1", ")", "!=", "'_'", ")", "{", "// Method exists, execute it", "$", "this", "->", "{", "$", "method", "}", "(", ")", ";", "}", "elseif", "(", "is_numeric", "(", "$", "method", ")", ")", "{", "// Paginating the main blog page", "$", "this", "->", "index", "(", ")", ";", "}", "else", "{", "// Doesn't exist, consider rsegment(3) a slug", "$", "this", "->", "single", "(", ")", ";", "}", "}" ]
Routes the URL @return void
[ "Routes", "the", "URL" ]
7b369c5209f4343fff7c7e2a22c237d5a95c8c24
https://github.com/nails/module-blog/blob/7b369c5209f4343fff7c7e2a22c237d5a95c8c24/blog/controllers/Blog.php#L560-L584
train
gplcart/cli
controllers/commands/Review.php
Review.cmdGetReview
public function cmdGetReview() { $result = $this->getListReview(); $this->outputFormat($result); $this->outputFormatTableReview($result); $this->output(); }
php
public function cmdGetReview() { $result = $this->getListReview(); $this->outputFormat($result); $this->outputFormatTableReview($result); $this->output(); }
[ "public", "function", "cmdGetReview", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getListReview", "(", ")", ";", "$", "this", "->", "outputFormat", "(", "$", "result", ")", ";", "$", "this", "->", "outputFormatTableReview", "(", "$", "result", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "review-get" command
[ "Callback", "for", "review", "-", "get", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Review.php#L40-L46
train
gplcart/cli
controllers/commands/Review.php
Review.setStatusReview
protected function setStatusReview($status) { $id = $this->getParam(0); $all = $this->getParam('all'); if (!isset($id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } if (isset($id) && (empty($id) || !is_numeric($id))) { $this->errorAndExit($this->text('Invalid argument')); } $options = null; if (isset($id)) { if ($this->getParam('user')) { $options = array('user_id' => $id); } else if ($this->getParam('product')) { $options = array('product_id' => $id); } } else if (!empty($all)) { $options = array(); } if (isset($options)) { $deleted = $count = 0; foreach ($this->review->getList($options) as $item) { $count++; $deleted += (int) $this->review->update($item['review_id'], array('status' => $status)); } $result = $count && $count == $deleted; } else if (!empty($id)) { $result = $this->review->update($id, array('status' => $status)); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } }
php
protected function setStatusReview($status) { $id = $this->getParam(0); $all = $this->getParam('all'); if (!isset($id) && empty($all)) { $this->errorAndExit($this->text('Invalid command')); } if (isset($id) && (empty($id) || !is_numeric($id))) { $this->errorAndExit($this->text('Invalid argument')); } $options = null; if (isset($id)) { if ($this->getParam('user')) { $options = array('user_id' => $id); } else if ($this->getParam('product')) { $options = array('product_id' => $id); } } else if (!empty($all)) { $options = array(); } if (isset($options)) { $deleted = $count = 0; foreach ($this->review->getList($options) as $item) { $count++; $deleted += (int) $this->review->update($item['review_id'], array('status' => $status)); } $result = $count && $count == $deleted; } else if (!empty($id)) { $result = $this->review->update($id, array('status' => $status)); } if (empty($result)) { $this->errorAndExit($this->text('Unexpected result')); } }
[ "protected", "function", "setStatusReview", "(", "$", "status", ")", "{", "$", "id", "=", "$", "this", "->", "getParam", "(", "0", ")", ";", "$", "all", "=", "$", "this", "->", "getParam", "(", "'all'", ")", ";", "if", "(", "!", "isset", "(", "$", "id", ")", "&&", "empty", "(", "$", "all", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "id", ")", "&&", "(", "empty", "(", "$", "id", ")", "||", "!", "is_numeric", "(", "$", "id", ")", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "options", "=", "null", ";", "if", "(", "isset", "(", "$", "id", ")", ")", "{", "if", "(", "$", "this", "->", "getParam", "(", "'user'", ")", ")", "{", "$", "options", "=", "array", "(", "'user_id'", "=>", "$", "id", ")", ";", "}", "else", "if", "(", "$", "this", "->", "getParam", "(", "'product'", ")", ")", "{", "$", "options", "=", "array", "(", "'product_id'", "=>", "$", "id", ")", ";", "}", "}", "else", "if", "(", "!", "empty", "(", "$", "all", ")", ")", "{", "$", "options", "=", "array", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "options", ")", ")", "{", "$", "deleted", "=", "$", "count", "=", "0", ";", "foreach", "(", "$", "this", "->", "review", "->", "getList", "(", "$", "options", ")", "as", "$", "item", ")", "{", "$", "count", "++", ";", "$", "deleted", "+=", "(", "int", ")", "$", "this", "->", "review", "->", "update", "(", "$", "item", "[", "'review_id'", "]", ",", "array", "(", "'status'", "=>", "$", "status", ")", ")", ";", "}", "$", "result", "=", "$", "count", "&&", "$", "count", "==", "$", "deleted", ";", "}", "else", "if", "(", "!", "empty", "(", "$", "id", ")", ")", "{", "$", "result", "=", "$", "this", "->", "review", "->", "update", "(", "$", "id", ",", "array", "(", "'status'", "=>", "$", "status", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "result", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "}" ]
Sets status for one or several reviews @param bool $status
[ "Sets", "status", "for", "one", "or", "several", "reviews" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Review.php#L121-L165
train
gplcart/cli
controllers/commands/Review.php
Review.cmdUpdateReview
public function cmdUpdateReview() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmitted('update', $params[0]); $this->validateComponent('review'); $this->updateReview($params[0]); $this->output(); }
php
public function cmdUpdateReview() { $params = $this->getParam(); if (empty($params[0]) || count($params) < 2) { $this->errorAndExit($this->text('Invalid command')); } if (!is_numeric($params[0])) { $this->errorAndExit($this->text('Invalid argument')); } $this->setSubmitted(null, $params); $this->setSubmitted('update', $params[0]); $this->validateComponent('review'); $this->updateReview($params[0]); $this->output(); }
[ "public", "function", "cmdUpdateReview", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getParam", "(", ")", ";", "if", "(", "empty", "(", "$", "params", "[", "0", "]", ")", "||", "count", "(", "$", "params", ")", "<", "2", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid command'", ")", ")", ";", "}", "if", "(", "!", "is_numeric", "(", "$", "params", "[", "0", "]", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Invalid argument'", ")", ")", ";", "}", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "params", ")", ";", "$", "this", "->", "setSubmitted", "(", "'update'", ",", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "validateComponent", "(", "'review'", ")", ";", "$", "this", "->", "updateReview", "(", "$", "params", "[", "0", "]", ")", ";", "$", "this", "->", "output", "(", ")", ";", "}" ]
Callback for "review-update" command
[ "Callback", "for", "review", "-", "update", "command" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Review.php#L184-L202
train
gplcart/cli
controllers/commands/Review.php
Review.addReview
protected function addReview() { if (!$this->isError()) { $id = $this->review->add($this->getSubmitted()); if (empty($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($id); } }
php
protected function addReview() { if (!$this->isError()) { $id = $this->review->add($this->getSubmitted()); if (empty($id)) { $this->errorAndExit($this->text('Unexpected result')); } $this->line($id); } }
[ "protected", "function", "addReview", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isError", "(", ")", ")", "{", "$", "id", "=", "$", "this", "->", "review", "->", "add", "(", "$", "this", "->", "getSubmitted", "(", ")", ")", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "$", "this", "->", "errorAndExit", "(", "$", "this", "->", "text", "(", "'Unexpected result'", ")", ")", ";", "}", "$", "this", "->", "line", "(", "$", "id", ")", ";", "}", "}" ]
Add a new review
[ "Add", "a", "new", "review" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Review.php#L271-L280
train
gplcart/cli
controllers/commands/Review.php
Review.submitAddReview
protected function submitAddReview() { $this->setSubmitted(null, $this->getParam()); $this->validateComponent('review'); $this->addReview(); }
php
protected function submitAddReview() { $this->setSubmitted(null, $this->getParam()); $this->validateComponent('review'); $this->addReview(); }
[ "protected", "function", "submitAddReview", "(", ")", "{", "$", "this", "->", "setSubmitted", "(", "null", ",", "$", "this", "->", "getParam", "(", ")", ")", ";", "$", "this", "->", "validateComponent", "(", "'review'", ")", ";", "$", "this", "->", "addReview", "(", ")", ";", "}" ]
Add a new review at once
[ "Add", "a", "new", "review", "at", "once" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Review.php#L296-L301
train
gplcart/cli
controllers/commands/Review.php
Review.wizardAddReview
protected function wizardAddReview() { $this->validatePrompt('user_id', $this->text('User'), 'review'); $this->validatePrompt('product_id', $this->text('Product'), 'review'); $this->validatePrompt('text', $this->text('Text'), 'review'); $this->validatePrompt('status', $this->text('Status'), 'review', 0); $this->validateComponent('review'); $this->addReview(); }
php
protected function wizardAddReview() { $this->validatePrompt('user_id', $this->text('User'), 'review'); $this->validatePrompt('product_id', $this->text('Product'), 'review'); $this->validatePrompt('text', $this->text('Text'), 'review'); $this->validatePrompt('status', $this->text('Status'), 'review', 0); $this->validateComponent('review'); $this->addReview(); }
[ "protected", "function", "wizardAddReview", "(", ")", "{", "$", "this", "->", "validatePrompt", "(", "'user_id'", ",", "$", "this", "->", "text", "(", "'User'", ")", ",", "'review'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'product_id'", ",", "$", "this", "->", "text", "(", "'Product'", ")", ",", "'review'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'text'", ",", "$", "this", "->", "text", "(", "'Text'", ")", ",", "'review'", ")", ";", "$", "this", "->", "validatePrompt", "(", "'status'", ",", "$", "this", "->", "text", "(", "'Status'", ")", ",", "'review'", ",", "0", ")", ";", "$", "this", "->", "validateComponent", "(", "'review'", ")", ";", "$", "this", "->", "addReview", "(", ")", ";", "}" ]
Add a new review step by step
[ "Add", "a", "new", "review", "step", "by", "step" ]
e57dba53e291a225b4bff0c0d9b23d685dd1c125
https://github.com/gplcart/cli/blob/e57dba53e291a225b4bff0c0d9b23d685dd1c125/controllers/commands/Review.php#L306-L315
train
Vectrex/vxPHP
src/File/MimeTypeGetter.php
MimeTypeGetter.getTypeFinfoExt
protected static function getTypeFinfoExt($file) { $type = (new \finfo(FILEINFO_MIME_TYPE))->file($file); if($type) { return $type; } else { return self::getTypeFileExtList($file); } }
php
protected static function getTypeFinfoExt($file) { $type = (new \finfo(FILEINFO_MIME_TYPE))->file($file); if($type) { return $type; } else { return self::getTypeFileExtList($file); } }
[ "protected", "static", "function", "getTypeFinfoExt", "(", "$", "file", ")", "{", "$", "type", "=", "(", "new", "\\", "finfo", "(", "FILEINFO_MIME_TYPE", ")", ")", "->", "file", "(", "$", "file", ")", ";", "if", "(", "$", "type", ")", "{", "return", "$", "type", ";", "}", "else", "{", "return", "self", "::", "getTypeFileExtList", "(", "$", "file", ")", ";", "}", "}" ]
Gets the Mime Type using the Fileinfo Extension. If the Extension returns nothing the extension list is used. @param string $file the path to the File @return string the Mime Type
[ "Gets", "the", "Mime", "Type", "using", "the", "Fileinfo", "Extension", ".", "If", "the", "Extension", "returns", "nothing", "the", "extension", "list", "is", "used", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/MimeTypeGetter.php#L1042-L1054
train
Vectrex/vxPHP
src/File/MimeTypeGetter.php
MimeTypeGetter.getTypeFileExtList
protected static function getTypeFileExtList($file) { $info = pathinfo(strtolower($file)); if(isset(self::$extensionToMime[$info['extension']])) { return self::$extensionToMime[$info['extension']]; } else { return self::DEFAULT_MIME_TYPE; } }
php
protected static function getTypeFileExtList($file) { $info = pathinfo(strtolower($file)); if(isset(self::$extensionToMime[$info['extension']])) { return self::$extensionToMime[$info['extension']]; } else { return self::DEFAULT_MIME_TYPE; } }
[ "protected", "static", "function", "getTypeFileExtList", "(", "$", "file", ")", "{", "$", "info", "=", "pathinfo", "(", "strtolower", "(", "$", "file", ")", ")", ";", "if", "(", "isset", "(", "self", "::", "$", "extensionToMime", "[", "$", "info", "[", "'extension'", "]", "]", ")", ")", "{", "return", "self", "::", "$", "extensionToMime", "[", "$", "info", "[", "'extension'", "]", "]", ";", "}", "else", "{", "return", "self", "::", "DEFAULT_MIME_TYPE", ";", "}", "}" ]
extracts the file extension and checks the extension array for the extension. If it is found it returns the MIME type. If not it returns the the default MIME type. @param string $file the path to the file @return string
[ "extracts", "the", "file", "extension", "and", "checks", "the", "extension", "array", "for", "the", "extension", ".", "If", "it", "is", "found", "it", "returns", "the", "MIME", "type", ".", "If", "not", "it", "returns", "the", "the", "default", "MIME", "type", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/MimeTypeGetter.php#L1064-L1075
train
Vectrex/vxPHP
src/File/MimeTypeGetter.php
MimeTypeGetter.getDefaultFileExtension
public static function getDefaultFileExtension($mime) { if(empty(self::$mimeToExtension)) { self::$mimeToExtension = array_flip(self::$extensionToMime); } return isset(self::$mimeToExtension[$mime]) ? self::$mimeToExtension[$mime] : ''; }
php
public static function getDefaultFileExtension($mime) { if(empty(self::$mimeToExtension)) { self::$mimeToExtension = array_flip(self::$extensionToMime); } return isset(self::$mimeToExtension[$mime]) ? self::$mimeToExtension[$mime] : ''; }
[ "public", "static", "function", "getDefaultFileExtension", "(", "$", "mime", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "mimeToExtension", ")", ")", "{", "self", "::", "$", "mimeToExtension", "=", "array_flip", "(", "self", "::", "$", "extensionToMime", ")", ";", "}", "return", "isset", "(", "self", "::", "$", "mimeToExtension", "[", "$", "mime", "]", ")", "?", "self", "::", "$", "mimeToExtension", "[", "$", "mime", "]", ":", "''", ";", "}" ]
returns a default extension by a given MIME type since a single MIME type can be assigned to more than one extension the one determined by the array structure is returned returns an empty string if no match for the MIME type was found @param string @return string
[ "returns", "a", "default", "extension", "by", "a", "given", "MIME", "type" ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/File/MimeTypeGetter.php#L1131-L1139
train
vaccuum/container
source/Traits/TContainerConfiguration.php
TContainerConfiguration.configure
protected function configure(IConfig $config) { $configuration = $config->get('container'); foreach ($configuration as $name => $group) { switch ($name) { case 'parameters': $this->configureParameters($group); break; case 'shared': $this->configureShared($group); break; case 'definitions': $this->configureDefinitions($group); break; case 'aliases': $this->configureAliases($group); break; case 'factories': $this->configureFactories($group); break; } } }
php
protected function configure(IConfig $config) { $configuration = $config->get('container'); foreach ($configuration as $name => $group) { switch ($name) { case 'parameters': $this->configureParameters($group); break; case 'shared': $this->configureShared($group); break; case 'definitions': $this->configureDefinitions($group); break; case 'aliases': $this->configureAliases($group); break; case 'factories': $this->configureFactories($group); break; } } }
[ "protected", "function", "configure", "(", "IConfig", "$", "config", ")", "{", "$", "configuration", "=", "$", "config", "->", "get", "(", "'container'", ")", ";", "foreach", "(", "$", "configuration", "as", "$", "name", "=>", "$", "group", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "'parameters'", ":", "$", "this", "->", "configureParameters", "(", "$", "group", ")", ";", "break", ";", "case", "'shared'", ":", "$", "this", "->", "configureShared", "(", "$", "group", ")", ";", "break", ";", "case", "'definitions'", ":", "$", "this", "->", "configureDefinitions", "(", "$", "group", ")", ";", "break", ";", "case", "'aliases'", ":", "$", "this", "->", "configureAliases", "(", "$", "group", ")", ";", "break", ";", "case", "'factories'", ":", "$", "this", "->", "configureFactories", "(", "$", "group", ")", ";", "break", ";", "}", "}", "}" ]
Configure container. @param IConfig $config @return void
[ "Configure", "container", "." ]
7d474cf42656585a0f66b4cc6f697f1c3185c980
https://github.com/vaccuum/container/blob/7d474cf42656585a0f66b4cc6f697f1c3185c980/source/Traits/TContainerConfiguration.php#L14-L43
train
craig-mcmahon/google-helper
src/GoogleHelper/GoogleHelper.php
GoogleHelper.cmdLineAuth
public function cmdLineAuth() { $authUrl = $this->client->createAuthUrl(); //Request authorization print "Please visit:\n$authUrl\n\n"; print "Please enter the auth code:\n"; $authCode = trim(fgets(STDIN)); // Exchange authorization code for access token $accessToken = $this->client->authenticate($authCode); $this->client->setAccessToken($accessToken); $this->accessToken = $accessToken; $this->refreshToken = $this->client->getRefreshToken(); }
php
public function cmdLineAuth() { $authUrl = $this->client->createAuthUrl(); //Request authorization print "Please visit:\n$authUrl\n\n"; print "Please enter the auth code:\n"; $authCode = trim(fgets(STDIN)); // Exchange authorization code for access token $accessToken = $this->client->authenticate($authCode); $this->client->setAccessToken($accessToken); $this->accessToken = $accessToken; $this->refreshToken = $this->client->getRefreshToken(); }
[ "public", "function", "cmdLineAuth", "(", ")", "{", "$", "authUrl", "=", "$", "this", "->", "client", "->", "createAuthUrl", "(", ")", ";", "//Request authorization", "print", "\"Please visit:\\n$authUrl\\n\\n\"", ";", "print", "\"Please enter the auth code:\\n\"", ";", "$", "authCode", "=", "trim", "(", "fgets", "(", "STDIN", ")", ")", ";", "// Exchange authorization code for access token", "$", "accessToken", "=", "$", "this", "->", "client", "->", "authenticate", "(", "$", "authCode", ")", ";", "$", "this", "->", "client", "->", "setAccessToken", "(", "$", "accessToken", ")", ";", "$", "this", "->", "accessToken", "=", "$", "accessToken", ";", "$", "this", "->", "refreshToken", "=", "$", "this", "->", "client", "->", "getRefreshToken", "(", ")", ";", "}" ]
Auth over command line
[ "Auth", "over", "command", "line" ]
6b877efd7c9827555ecac65ee01e337849db6611
https://github.com/craig-mcmahon/google-helper/blob/6b877efd7c9827555ecac65ee01e337849db6611/src/GoogleHelper/GoogleHelper.php#L79-L93
train
ivopetkov/notifications-bearframework-addon
classes/Notifications.php
Notifications.make
public function make(string $title = null, string $text = null): Notification { if (self::$newNotificationCache === null) { self::$newNotificationCache = new Notification(); } $notification = clone(self::$newNotificationCache); if ($title !== null) { $notification->title = $title; } if ($text !== null) { $notification->text = $text; } return $notification; }
php
public function make(string $title = null, string $text = null): Notification { if (self::$newNotificationCache === null) { self::$newNotificationCache = new Notification(); } $notification = clone(self::$newNotificationCache); if ($title !== null) { $notification->title = $title; } if ($text !== null) { $notification->text = $text; } return $notification; }
[ "public", "function", "make", "(", "string", "$", "title", "=", "null", ",", "string", "$", "text", "=", "null", ")", ":", "Notification", "{", "if", "(", "self", "::", "$", "newNotificationCache", "===", "null", ")", "{", "self", "::", "$", "newNotificationCache", "=", "new", "Notification", "(", ")", ";", "}", "$", "notification", "=", "clone", "(", "self", "::", "$", "newNotificationCache", ")", ";", "if", "(", "$", "title", "!==", "null", ")", "{", "$", "notification", "->", "title", "=", "$", "title", ";", "}", "if", "(", "$", "text", "!==", "null", ")", "{", "$", "notification", "->", "text", "=", "$", "text", ";", "}", "return", "$", "notification", ";", "}" ]
Constructs a new notification and returns it. @param ?string $title The notification title. @param ?string $text The notification text. @return \BearFramework\Notifications\Notification
[ "Constructs", "a", "new", "notification", "and", "returns", "it", "." ]
78a3b5995fcceee98a462e333bd3b4dd4fa155af
https://github.com/ivopetkov/notifications-bearframework-addon/blob/78a3b5995fcceee98a462e333bd3b4dd4fa155af/classes/Notifications.php#L35-L48
train
ivopetkov/notifications-bearframework-addon
classes/Notifications.php
Notifications.send
public function send(string $recipientID, Notification $notification): void { $app = App::get(); if ($notification->id === null) { $notification->id = 'n' . uniqid() . 'x' . base_convert(rand(0, 999999999), 10, 16); } if ($notification->dateCreated === null) { $notification->dateCreated = time(); } if ($this->hasEventListeners('beforeSendNotification')) { $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\BeforeSendNotificationEventDetails($recipientID, $notification); $this->dispatchEvent('beforeSendNotification', $eventDetails); if ($eventDetails->preventDefault) { return; } } if (strlen($notification->type) > 0) { $otherNotifications = $this->getList($recipientID); foreach ($otherNotifications as $otherNotification) { if ((string) $notification->type === (string) $otherNotification->type) { $this->delete($recipientID, $otherNotification->id); } } } $this->set($recipientID, $notification); if ($this->hasEventListeners('sendNotification')) { $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\SendNotificationEventDetails($recipientID, $notification); $this->dispatchEvent('sendNotification', $eventDetails); } }
php
public function send(string $recipientID, Notification $notification): void { $app = App::get(); if ($notification->id === null) { $notification->id = 'n' . uniqid() . 'x' . base_convert(rand(0, 999999999), 10, 16); } if ($notification->dateCreated === null) { $notification->dateCreated = time(); } if ($this->hasEventListeners('beforeSendNotification')) { $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\BeforeSendNotificationEventDetails($recipientID, $notification); $this->dispatchEvent('beforeSendNotification', $eventDetails); if ($eventDetails->preventDefault) { return; } } if (strlen($notification->type) > 0) { $otherNotifications = $this->getList($recipientID); foreach ($otherNotifications as $otherNotification) { if ((string) $notification->type === (string) $otherNotification->type) { $this->delete($recipientID, $otherNotification->id); } } } $this->set($recipientID, $notification); if ($this->hasEventListeners('sendNotification')) { $eventDetails = new \IvoPetkov\BearFrameworkAddons\Notifications\SendNotificationEventDetails($recipientID, $notification); $this->dispatchEvent('sendNotification', $eventDetails); } }
[ "public", "function", "send", "(", "string", "$", "recipientID", ",", "Notification", "$", "notification", ")", ":", "void", "{", "$", "app", "=", "App", "::", "get", "(", ")", ";", "if", "(", "$", "notification", "->", "id", "===", "null", ")", "{", "$", "notification", "->", "id", "=", "'n'", ".", "uniqid", "(", ")", ".", "'x'", ".", "base_convert", "(", "rand", "(", "0", ",", "999999999", ")", ",", "10", ",", "16", ")", ";", "}", "if", "(", "$", "notification", "->", "dateCreated", "===", "null", ")", "{", "$", "notification", "->", "dateCreated", "=", "time", "(", ")", ";", "}", "if", "(", "$", "this", "->", "hasEventListeners", "(", "'beforeSendNotification'", ")", ")", "{", "$", "eventDetails", "=", "new", "\\", "IvoPetkov", "\\", "BearFrameworkAddons", "\\", "Notifications", "\\", "BeforeSendNotificationEventDetails", "(", "$", "recipientID", ",", "$", "notification", ")", ";", "$", "this", "->", "dispatchEvent", "(", "'beforeSendNotification'", ",", "$", "eventDetails", ")", ";", "if", "(", "$", "eventDetails", "->", "preventDefault", ")", "{", "return", ";", "}", "}", "if", "(", "strlen", "(", "$", "notification", "->", "type", ")", ">", "0", ")", "{", "$", "otherNotifications", "=", "$", "this", "->", "getList", "(", "$", "recipientID", ")", ";", "foreach", "(", "$", "otherNotifications", "as", "$", "otherNotification", ")", "{", "if", "(", "(", "string", ")", "$", "notification", "->", "type", "===", "(", "string", ")", "$", "otherNotification", "->", "type", ")", "{", "$", "this", "->", "delete", "(", "$", "recipientID", ",", "$", "otherNotification", "->", "id", ")", ";", "}", "}", "}", "$", "this", "->", "set", "(", "$", "recipientID", ",", "$", "notification", ")", ";", "if", "(", "$", "this", "->", "hasEventListeners", "(", "'sendNotification'", ")", ")", "{", "$", "eventDetails", "=", "new", "\\", "IvoPetkov", "\\", "BearFrameworkAddons", "\\", "Notifications", "\\", "SendNotificationEventDetails", "(", "$", "recipientID", ",", "$", "notification", ")", ";", "$", "this", "->", "dispatchEvent", "(", "'sendNotification'", ",", "$", "eventDetails", ")", ";", "}", "}" ]
Sends a notification. @param string $recipientID The recipient ID. @param \BearFramework\Notifications\Notification $notification The notification to send. @return void No value is returned. @throws \Exception
[ "Sends", "a", "notification", "." ]
78a3b5995fcceee98a462e333bd3b4dd4fa155af
https://github.com/ivopetkov/notifications-bearframework-addon/blob/78a3b5995fcceee98a462e333bd3b4dd4fa155af/classes/Notifications.php#L58-L92
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG.setOptsByArray
public function setOptsByArray($options) { foreach (self::$_setableOptions as $optionKey) { if (isset($options[$optionKey])) { $this->$optionKey = $options[$optionKey]; } } return $this; }
php
public function setOptsByArray($options) { foreach (self::$_setableOptions as $optionKey) { if (isset($options[$optionKey])) { $this->$optionKey = $options[$optionKey]; } } return $this; }
[ "public", "function", "setOptsByArray", "(", "$", "options", ")", "{", "foreach", "(", "self", "::", "$", "_setableOptions", "as", "$", "optionKey", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "$", "optionKey", "]", ")", ")", "{", "$", "this", "->", "$", "optionKey", "=", "$", "options", "[", "$", "optionKey", "]", ";", "}", "}", "return", "$", "this", ";", "}" ]
Retrieve an option array and set valid keys as instance variables. @param array $options
[ "Retrieve", "an", "option", "array", "and", "set", "valid", "keys", "as", "instance", "variables", "." ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L96-L105
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG.getScope
public function getScope() { $calledHere = $this->backTrace[$this->backTraceOffset+1]; if (isset($calledHere['class'])) { return (object) array( 'type' => 'Method', 'name' => $calledHere['class'].$calledHere['type'].$calledHere['function'] ); } elseif(isset($calledHere['function'])) { return (object) array( 'type' => 'Function', 'name' => $calledHere['function'] ); } else { return (object) array( 'type' => 'global' ); } }
php
public function getScope() { $calledHere = $this->backTrace[$this->backTraceOffset+1]; if (isset($calledHere['class'])) { return (object) array( 'type' => 'Method', 'name' => $calledHere['class'].$calledHere['type'].$calledHere['function'] ); } elseif(isset($calledHere['function'])) { return (object) array( 'type' => 'Function', 'name' => $calledHere['function'] ); } else { return (object) array( 'type' => 'global' ); } }
[ "public", "function", "getScope", "(", ")", "{", "$", "calledHere", "=", "$", "this", "->", "backTrace", "[", "$", "this", "->", "backTraceOffset", "+", "1", "]", ";", "if", "(", "isset", "(", "$", "calledHere", "[", "'class'", "]", ")", ")", "{", "return", "(", "object", ")", "array", "(", "'type'", "=>", "'Method'", ",", "'name'", "=>", "$", "calledHere", "[", "'class'", "]", ".", "$", "calledHere", "[", "'type'", "]", ".", "$", "calledHere", "[", "'function'", "]", ")", ";", "}", "elseif", "(", "isset", "(", "$", "calledHere", "[", "'function'", "]", ")", ")", "{", "return", "(", "object", ")", "array", "(", "'type'", "=>", "'Function'", ",", "'name'", "=>", "$", "calledHere", "[", "'function'", "]", ")", ";", "}", "else", "{", "return", "(", "object", ")", "array", "(", "'type'", "=>", "'global'", ")", ";", "}", "}" ]
Get the current function or method scope according to the backtraceOffset @return object
[ "Get", "the", "current", "function", "or", "method", "scope", "according", "to", "the", "backtraceOffset" ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L112-L130
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG.getID
public function getID() { if (!isset($this->ID)) { $this->ID = md5($this->file.$this->line); } return $this->ID; }
php
public function getID() { if (!isset($this->ID)) { $this->ID = md5($this->file.$this->line); } return $this->ID; }
[ "public", "function", "getID", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "ID", ")", ")", "{", "$", "this", "->", "ID", "=", "md5", "(", "$", "this", "->", "file", ".", "$", "this", "->", "line", ")", ";", "}", "return", "$", "this", "->", "ID", ";", "}" ]
Generate a hash from the file and line @return string the id
[ "Generate", "a", "hash", "from", "the", "file", "and", "line" ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L137-L143
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG.setLineAndFile
public function setLineAndFile() { if (isset($this->backTrace[$this->backTraceOffset])) { /* Reset the ID because its based on the current line and file */ $this->ID = null; $calledHere = $this->backTrace[$this->backTraceOffset]; if (isset($calledHere['line'])) { $this->line = $calledHere['line']; } if (isset($calledHere['file'])) { $this->file = $calledHere['file']; } } return $this; }
php
public function setLineAndFile() { if (isset($this->backTrace[$this->backTraceOffset])) { /* Reset the ID because its based on the current line and file */ $this->ID = null; $calledHere = $this->backTrace[$this->backTraceOffset]; if (isset($calledHere['line'])) { $this->line = $calledHere['line']; } if (isset($calledHere['file'])) { $this->file = $calledHere['file']; } } return $this; }
[ "public", "function", "setLineAndFile", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "backTrace", "[", "$", "this", "->", "backTraceOffset", "]", ")", ")", "{", "/* Reset the ID because its based on the current line and file */", "$", "this", "->", "ID", "=", "null", ";", "$", "calledHere", "=", "$", "this", "->", "backTrace", "[", "$", "this", "->", "backTraceOffset", "]", ";", "if", "(", "isset", "(", "$", "calledHere", "[", "'line'", "]", ")", ")", "{", "$", "this", "->", "line", "=", "$", "calledHere", "[", "'line'", "]", ";", "}", "if", "(", "isset", "(", "$", "calledHere", "[", "'file'", "]", ")", ")", "{", "$", "this", "->", "file", "=", "$", "calledHere", "[", "'file'", "]", ";", "}", "}", "return", "$", "this", ";", "}" ]
Use the backTraceOffset and find the file and line in which the debug was called @return void
[ "Use", "the", "backTraceOffset", "and", "find", "the", "file", "and", "line", "in", "which", "the", "debug", "was", "called" ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L150-L166
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG.put
public function put() { X\THEDEBUG::i()->doCallback('beforePut', array(&$this)); $this->doCallback('beforePut', array(&$this)); switch (strtolower($this->modus)) { case 'firephp': $this->putFirePHP(); break; case 'chromephp': $this->putChromePHP(); break; default: $this->putInline(); break; } }
php
public function put() { X\THEDEBUG::i()->doCallback('beforePut', array(&$this)); $this->doCallback('beforePut', array(&$this)); switch (strtolower($this->modus)) { case 'firephp': $this->putFirePHP(); break; case 'chromephp': $this->putChromePHP(); break; default: $this->putInline(); break; } }
[ "public", "function", "put", "(", ")", "{", "X", "\\", "THEDEBUG", "::", "i", "(", ")", "->", "doCallback", "(", "'beforePut'", ",", "array", "(", "&", "$", "this", ")", ")", ";", "$", "this", "->", "doCallback", "(", "'beforePut'", ",", "array", "(", "&", "$", "this", ")", ")", ";", "switch", "(", "strtolower", "(", "$", "this", "->", "modus", ")", ")", "{", "case", "'firephp'", ":", "$", "this", "->", "putFirePHP", "(", ")", ";", "break", ";", "case", "'chromephp'", ":", "$", "this", "->", "putChromePHP", "(", ")", ";", "break", ";", "default", ":", "$", "this", "->", "putInline", "(", ")", ";", "break", ";", "}", "}" ]
fire the appropriate output method for the current modus @return void
[ "fire", "the", "appropriate", "output", "method", "for", "the", "current", "modus" ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L173-L188
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG.putChromePHP
public function putChromePHP() { $ChromePHP = X\THEDEBUG::getChromePHP(); $ChromePHP->backtrace = $this->file.': '.$this->line; $this->_improveVar(); $args = array(); if (!empty($this->name)) { $args[] = $this->name.':'; } $args[] = $this->variable; call_user_func_array( array( $ChromePHP, $this->_getMethod() ), $args ); }
php
public function putChromePHP() { $ChromePHP = X\THEDEBUG::getChromePHP(); $ChromePHP->backtrace = $this->file.': '.$this->line; $this->_improveVar(); $args = array(); if (!empty($this->name)) { $args[] = $this->name.':'; } $args[] = $this->variable; call_user_func_array( array( $ChromePHP, $this->_getMethod() ), $args ); }
[ "public", "function", "putChromePHP", "(", ")", "{", "$", "ChromePHP", "=", "X", "\\", "THEDEBUG", "::", "getChromePHP", "(", ")", ";", "$", "ChromePHP", "->", "backtrace", "=", "$", "this", "->", "file", ".", "': '", ".", "$", "this", "->", "line", ";", "$", "this", "->", "_improveVar", "(", ")", ";", "$", "args", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "name", ")", ")", "{", "$", "args", "[", "]", "=", "$", "this", "->", "name", ".", "':'", ";", "}", "$", "args", "[", "]", "=", "$", "this", "->", "variable", ";", "call_user_func_array", "(", "array", "(", "$", "ChromePHP", ",", "$", "this", "->", "_getMethod", "(", ")", ")", ",", "$", "args", ")", ";", "}" ]
Pass the debug to ChromePHP @return void
[ "Pass", "the", "debug", "to", "ChromePHP" ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L195-L213
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG.putFirePHP
public function putFirePHP() { $FirePHP = X\THEDEBUG::getFirePHP(); $this->_improveVar(); call_user_func_array( array($FirePHP, $this->_getMethod()), array( $this->variable, $this->name, array( 'File' => $this->file, 'Line' => $this->line ) ) ); }
php
public function putFirePHP() { $FirePHP = X\THEDEBUG::getFirePHP(); $this->_improveVar(); call_user_func_array( array($FirePHP, $this->_getMethod()), array( $this->variable, $this->name, array( 'File' => $this->file, 'Line' => $this->line ) ) ); }
[ "public", "function", "putFirePHP", "(", ")", "{", "$", "FirePHP", "=", "X", "\\", "THEDEBUG", "::", "getFirePHP", "(", ")", ";", "$", "this", "->", "_improveVar", "(", ")", ";", "call_user_func_array", "(", "array", "(", "$", "FirePHP", ",", "$", "this", "->", "_getMethod", "(", ")", ")", ",", "array", "(", "$", "this", "->", "variable", ",", "$", "this", "->", "name", ",", "array", "(", "'File'", "=>", "$", "this", "->", "file", ",", "'Line'", "=>", "$", "this", "->", "line", ")", ")", ")", ";", "}" ]
Pass the debug to firePHP @return void
[ "Pass", "the", "debug", "to", "firePHP" ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L220-L236
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG._improveVar
private function _improveVar() { switch ($this->variableType) { case 'boolean': $this->variable = '(boolean) '.($this->variable ? 'true' : 'false'); break; case 'NULL': $this->variable = '(null) NULL'; break; case 'string': $this->variable = '"'.$this->variable.'"'; default: break; } }
php
private function _improveVar() { switch ($this->variableType) { case 'boolean': $this->variable = '(boolean) '.($this->variable ? 'true' : 'false'); break; case 'NULL': $this->variable = '(null) NULL'; break; case 'string': $this->variable = '"'.$this->variable.'"'; default: break; } }
[ "private", "function", "_improveVar", "(", ")", "{", "switch", "(", "$", "this", "->", "variableType", ")", "{", "case", "'boolean'", ":", "$", "this", "->", "variable", "=", "'(boolean) '", ".", "(", "$", "this", "->", "variable", "?", "'true'", ":", "'false'", ")", ";", "break", ";", "case", "'NULL'", ":", "$", "this", "->", "variable", "=", "'(null) NULL'", ";", "break", ";", "case", "'string'", ":", "$", "this", "->", "variable", "=", "'\"'", ".", "$", "this", "->", "variable", ".", "'\"'", ";", "default", ":", "break", ";", "}", "}" ]
Make our variable more understandable. @return null
[ "Make", "our", "variable", "more", "understandable", "." ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L290-L304
train
Xiphe/THEDEBUG
src/Xiphe/THEDEBUG/ADEBUG.php
ADEBUG._allocateArgs
private function _allocateArgs($arguments) { if (empty($arguments)) { return; } /* First argument is the variable to be debugged */ $this->variable = $arguments[0]; $this->variableType = gettype($this->variable); /* * The second and third argument can be either an integer representing * the type, a string used as a message or an array containing multiple options */ for ($i=1; $i < 3; $i++) { if (!isset($arguments[$i])) { return; } if (is_string($arguments[$i])) { $this->name = $arguments[$i]; } elseif(is_int($arguments[$i])) { $this->type = X\THEDEBUG::$debugTypeMap[$arguments[$i]]; } elseif(is_array($arguments[$i]) || is_object($arguments[$i])) { $this->setOptsByArray((array) $arguments[$i]); } } /* The fourth argument can be the back-trace offset */ if (isset($arguments[3])) { if (is_int($arguments[3])) { $this->backTraceOffset = $arguments[3]; } } }
php
private function _allocateArgs($arguments) { if (empty($arguments)) { return; } /* First argument is the variable to be debugged */ $this->variable = $arguments[0]; $this->variableType = gettype($this->variable); /* * The second and third argument can be either an integer representing * the type, a string used as a message or an array containing multiple options */ for ($i=1; $i < 3; $i++) { if (!isset($arguments[$i])) { return; } if (is_string($arguments[$i])) { $this->name = $arguments[$i]; } elseif(is_int($arguments[$i])) { $this->type = X\THEDEBUG::$debugTypeMap[$arguments[$i]]; } elseif(is_array($arguments[$i]) || is_object($arguments[$i])) { $this->setOptsByArray((array) $arguments[$i]); } } /* The fourth argument can be the back-trace offset */ if (isset($arguments[3])) { if (is_int($arguments[3])) { $this->backTraceOffset = $arguments[3]; } } }
[ "private", "function", "_allocateArgs", "(", "$", "arguments", ")", "{", "if", "(", "empty", "(", "$", "arguments", ")", ")", "{", "return", ";", "}", "/* First argument is the variable to be debugged */", "$", "this", "->", "variable", "=", "$", "arguments", "[", "0", "]", ";", "$", "this", "->", "variableType", "=", "gettype", "(", "$", "this", "->", "variable", ")", ";", "/* \r\n\t\t * The second and third argument can be either an integer representing\r\n\t\t * the type, a string used as a message or an array containing multiple options\r\n\t\t */", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "3", ";", "$", "i", "++", ")", "{", "if", "(", "!", "isset", "(", "$", "arguments", "[", "$", "i", "]", ")", ")", "{", "return", ";", "}", "if", "(", "is_string", "(", "$", "arguments", "[", "$", "i", "]", ")", ")", "{", "$", "this", "->", "name", "=", "$", "arguments", "[", "$", "i", "]", ";", "}", "elseif", "(", "is_int", "(", "$", "arguments", "[", "$", "i", "]", ")", ")", "{", "$", "this", "->", "type", "=", "X", "\\", "THEDEBUG", "::", "$", "debugTypeMap", "[", "$", "arguments", "[", "$", "i", "]", "]", ";", "}", "elseif", "(", "is_array", "(", "$", "arguments", "[", "$", "i", "]", ")", "||", "is_object", "(", "$", "arguments", "[", "$", "i", "]", ")", ")", "{", "$", "this", "->", "setOptsByArray", "(", "(", "array", ")", "$", "arguments", "[", "$", "i", "]", ")", ";", "}", "}", "/* The fourth argument can be the back-trace offset */", "if", "(", "isset", "(", "$", "arguments", "[", "3", "]", ")", ")", "{", "if", "(", "is_int", "(", "$", "arguments", "[", "3", "]", ")", ")", "{", "$", "this", "->", "backTraceOffset", "=", "$", "arguments", "[", "3", "]", ";", "}", "}", "}" ]
Check which arguments were passed and name them. @param array $arguments @return void
[ "Check", "which", "arguments", "were", "passed", "and", "name", "them", "." ]
76983738a781cc495241672d57e7650aee57a2db
https://github.com/Xiphe/THEDEBUG/blob/76983738a781cc495241672d57e7650aee57a2db/src/Xiphe/THEDEBUG/ADEBUG.php#L312-L346
train
Dhii/config
src/DereferenceTokensCapableTrait.php
DereferenceTokensCapableTrait._dereferenceTokens
protected function _dereferenceTokens($value) { if (is_scalar($value) && !is_string($value)) { return $value; } try { $value = $this->_normalizeString($value); } catch (InvalidArgumentException $e) { return $value; } $container = $this->_getContainer(); $tokenStart = $this->_getTokenStart(); $tokenEnd = $this->_getTokenEnd(); try { $value = $this->_replaceReferences($value, $container, null, $tokenStart, $tokenEnd); } catch (ContainerExceptionInterface $e) { throw $this->_createRuntimeException($this->__('Could not de-reference tokens'), null, $e); } return $value; }
php
protected function _dereferenceTokens($value) { if (is_scalar($value) && !is_string($value)) { return $value; } try { $value = $this->_normalizeString($value); } catch (InvalidArgumentException $e) { return $value; } $container = $this->_getContainer(); $tokenStart = $this->_getTokenStart(); $tokenEnd = $this->_getTokenEnd(); try { $value = $this->_replaceReferences($value, $container, null, $tokenStart, $tokenEnd); } catch (ContainerExceptionInterface $e) { throw $this->_createRuntimeException($this->__('Could not de-reference tokens'), null, $e); } return $value; }
[ "protected", "function", "_dereferenceTokens", "(", "$", "value", ")", "{", "if", "(", "is_scalar", "(", "$", "value", ")", "&&", "!", "is_string", "(", "$", "value", ")", ")", "{", "return", "$", "value", ";", "}", "try", "{", "$", "value", "=", "$", "this", "->", "_normalizeString", "(", "$", "value", ")", ";", "}", "catch", "(", "InvalidArgumentException", "$", "e", ")", "{", "return", "$", "value", ";", "}", "$", "container", "=", "$", "this", "->", "_getContainer", "(", ")", ";", "$", "tokenStart", "=", "$", "this", "->", "_getTokenStart", "(", ")", ";", "$", "tokenEnd", "=", "$", "this", "->", "_getTokenEnd", "(", ")", ";", "try", "{", "$", "value", "=", "$", "this", "->", "_replaceReferences", "(", "$", "value", ",", "$", "container", ",", "null", ",", "$", "tokenStart", ",", "$", "tokenEnd", ")", ";", "}", "catch", "(", "ContainerExceptionInterface", "$", "e", ")", "{", "throw", "$", "this", "->", "_createRuntimeException", "(", "$", "this", "->", "__", "(", "'Could not de-reference tokens'", ")", ",", "null", ",", "$", "e", ")", ";", "}", "return", "$", "value", ";", "}" ]
Replaces tokens with their values. @since [*next-version*] @param string|Stringable|mixed $value The value, in which tokens may be found. If value is not stringable, will return it as is. @throws RuntimeException If tokens could not be replaced. @return string|Stringable The value with tokens replaced.
[ "Replaces", "tokens", "with", "their", "values", "." ]
1ab9a7ccf9c0ebd7c6fcbce600b4c00b52b2fdcf
https://github.com/Dhii/config/blob/1ab9a7ccf9c0ebd7c6fcbce600b4c00b52b2fdcf/src/DereferenceTokensCapableTrait.php#L31-L54
train
libreworks/caridea-dao
src/Exception/Translator/Doctrine.php
Doctrine.translate
public static function translate(\Exception $e): \Exception { if ($e instanceof \Doctrine\DBAL\Exception\ConnectionException) { return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e); } elseif ($e instanceof \Doctrine\ORM\EntityNotFoundException || $e instanceof \Doctrine\ORM\UnexpectedResultException || $e instanceof \Doctrine\ODM\MongoDB\DocumentNotFoundException || $e instanceof \Doctrine\ODM\CouchDB\DocumentNotFoundException) { return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", 404, $e); } elseif ($e instanceof \Doctrine\ORM\PessimisticLockException || $e instanceof \Doctrine\ORM\OptimisticLockException || $e instanceof \Doctrine\ODM\CouchDB\OptimisticLockException) { return new \Caridea\Dao\Exception\Conflicting("Optimistic or pessimistic concurrency failure", 409, $e); } elseif ($e instanceof \Doctrine\DBAL\Exception\UniqueConstraintViolationException) { return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e); } elseif ($e instanceof \Doctrine\DBAL\Exception\ConstraintViolationException) { return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e); } elseif ($e instanceof \Doctrine\ORM\Query\QueryException || $e instanceof \Doctrine\ORM\Mapping\MappingException || $e instanceof \Doctrine\DBAL\Exception\SyntaxErrorException || $e instanceof \Doctrine\Common\Persistence\Mapping\MappingException) { return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", 0, $e); } return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e); }
php
public static function translate(\Exception $e): \Exception { if ($e instanceof \Doctrine\DBAL\Exception\ConnectionException) { return new \Caridea\Dao\Exception\Unreachable("System unreachable or connection timed out", $e->getCode(), $e); } elseif ($e instanceof \Doctrine\ORM\EntityNotFoundException || $e instanceof \Doctrine\ORM\UnexpectedResultException || $e instanceof \Doctrine\ODM\MongoDB\DocumentNotFoundException || $e instanceof \Doctrine\ODM\CouchDB\DocumentNotFoundException) { return new \Caridea\Dao\Exception\Unretrievable("Data could not be retrieved", 404, $e); } elseif ($e instanceof \Doctrine\ORM\PessimisticLockException || $e instanceof \Doctrine\ORM\OptimisticLockException || $e instanceof \Doctrine\ODM\CouchDB\OptimisticLockException) { return new \Caridea\Dao\Exception\Conflicting("Optimistic or pessimistic concurrency failure", 409, $e); } elseif ($e instanceof \Doctrine\DBAL\Exception\UniqueConstraintViolationException) { return new \Caridea\Dao\Exception\Duplicative("Unique constraint violation", 409, $e); } elseif ($e instanceof \Doctrine\DBAL\Exception\ConstraintViolationException) { return new \Caridea\Dao\Exception\Violating("Constraint violation", 422, $e); } elseif ($e instanceof \Doctrine\ORM\Query\QueryException || $e instanceof \Doctrine\ORM\Mapping\MappingException || $e instanceof \Doctrine\DBAL\Exception\SyntaxErrorException || $e instanceof \Doctrine\Common\Persistence\Mapping\MappingException) { return new \Caridea\Dao\Exception\Inoperable("Invalid API usage", 0, $e); } return new \Caridea\Dao\Exception\Generic("Uncategorized database error", 0, $e); }
[ "public", "static", "function", "translate", "(", "\\", "Exception", "$", "e", ")", ":", "\\", "Exception", "{", "if", "(", "$", "e", "instanceof", "\\", "Doctrine", "\\", "DBAL", "\\", "Exception", "\\", "ConnectionException", ")", "{", "return", "new", "\\", "Caridea", "\\", "Dao", "\\", "Exception", "\\", "Unreachable", "(", "\"System unreachable or connection timed out\"", ",", "$", "e", "->", "getCode", "(", ")", ",", "$", "e", ")", ";", "}", "elseif", "(", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ORM", "\\", "EntityNotFoundException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ORM", "\\", "UnexpectedResultException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ODM", "\\", "MongoDB", "\\", "DocumentNotFoundException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ODM", "\\", "CouchDB", "\\", "DocumentNotFoundException", ")", "{", "return", "new", "\\", "Caridea", "\\", "Dao", "\\", "Exception", "\\", "Unretrievable", "(", "\"Data could not be retrieved\"", ",", "404", ",", "$", "e", ")", ";", "}", "elseif", "(", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ORM", "\\", "PessimisticLockException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ORM", "\\", "OptimisticLockException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ODM", "\\", "CouchDB", "\\", "OptimisticLockException", ")", "{", "return", "new", "\\", "Caridea", "\\", "Dao", "\\", "Exception", "\\", "Conflicting", "(", "\"Optimistic or pessimistic concurrency failure\"", ",", "409", ",", "$", "e", ")", ";", "}", "elseif", "(", "$", "e", "instanceof", "\\", "Doctrine", "\\", "DBAL", "\\", "Exception", "\\", "UniqueConstraintViolationException", ")", "{", "return", "new", "\\", "Caridea", "\\", "Dao", "\\", "Exception", "\\", "Duplicative", "(", "\"Unique constraint violation\"", ",", "409", ",", "$", "e", ")", ";", "}", "elseif", "(", "$", "e", "instanceof", "\\", "Doctrine", "\\", "DBAL", "\\", "Exception", "\\", "ConstraintViolationException", ")", "{", "return", "new", "\\", "Caridea", "\\", "Dao", "\\", "Exception", "\\", "Violating", "(", "\"Constraint violation\"", ",", "422", ",", "$", "e", ")", ";", "}", "elseif", "(", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ORM", "\\", "Query", "\\", "QueryException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "ORM", "\\", "Mapping", "\\", "MappingException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "DBAL", "\\", "Exception", "\\", "SyntaxErrorException", "||", "$", "e", "instanceof", "\\", "Doctrine", "\\", "Common", "\\", "Persistence", "\\", "Mapping", "\\", "MappingException", ")", "{", "return", "new", "\\", "Caridea", "\\", "Dao", "\\", "Exception", "\\", "Inoperable", "(", "\"Invalid API usage\"", ",", "0", ",", "$", "e", ")", ";", "}", "return", "new", "\\", "Caridea", "\\", "Dao", "\\", "Exception", "\\", "Generic", "(", "\"Uncategorized database error\"", ",", "0", ",", "$", "e", ")", ";", "}" ]
Translates a Doctrine exception. @param \Exception $e The exception to translate @return \Exception The exception to use
[ "Translates", "a", "Doctrine", "exception", "." ]
22c2fc81f63050ad23f7b0c40e430ff026e1e767
https://github.com/libreworks/caridea-dao/blob/22c2fc81f63050ad23f7b0c40e430ff026e1e767/src/Exception/Translator/Doctrine.php#L37-L61
train
Wedeto/DB
src/Query/OrderClause.php
OrderClause.toSQL
public function toSQL(Parameters $params, bool $inner_clause) { $drv = $params->getDriver(); $clauses = $this->getClauses(); $strs = array(); foreach ($clauses as $clause) $strs[] = $drv->toSQL($params, $clause); if (count($strs) === 0) return; return "ORDER BY " . implode(", ", $strs); }
php
public function toSQL(Parameters $params, bool $inner_clause) { $drv = $params->getDriver(); $clauses = $this->getClauses(); $strs = array(); foreach ($clauses as $clause) $strs[] = $drv->toSQL($params, $clause); if (count($strs) === 0) return; return "ORDER BY " . implode(", ", $strs); }
[ "public", "function", "toSQL", "(", "Parameters", "$", "params", ",", "bool", "$", "inner_clause", ")", "{", "$", "drv", "=", "$", "params", "->", "getDriver", "(", ")", ";", "$", "clauses", "=", "$", "this", "->", "getClauses", "(", ")", ";", "$", "strs", "=", "array", "(", ")", ";", "foreach", "(", "$", "clauses", "as", "$", "clause", ")", "$", "strs", "[", "]", "=", "$", "drv", "->", "toSQL", "(", "$", "params", ",", "$", "clause", ")", ";", "if", "(", "count", "(", "$", "strs", ")", "===", "0", ")", "return", ";", "return", "\"ORDER BY \"", ".", "implode", "(", "\", \"", ",", "$", "strs", ")", ";", "}" ]
Write a order clause as SQL query syntax @param Parameters $params The query parameters: tables and placeholder values @param bool $inner_clause Unused @return string The generated SQL
[ "Write", "a", "order", "clause", "as", "SQL", "query", "syntax" ]
715f8f2e3ae6b53c511c40b620921cb9c87e6f62
https://github.com/Wedeto/DB/blob/715f8f2e3ae6b53c511c40b620921cb9c87e6f62/src/Query/OrderClause.php#L84-L97
train
Linkvalue-Interne/MajoraGeneratorBundle
src/Majora/Bundle/GeneratorBundle/Generator/ContentModifier/AbstractPhpClassContentModifier.php
AbstractPhpClassContentModifier.retrieveBundleInfoFromGeneratedFile
protected function retrieveBundleInfoFromGeneratedFile(SplFileInfo $generatedFile, Inflector $inflector) { if($generatedFile->getExtension() !== 'php'){ throw new UnsupportedFileForContentModifierException(sprintf( 'This content modifier requires to be used on a PHP file, "%s" is not a PHP file.', $generatedFile->getFilename() )); } $fileContent = $generatedFile->getContents(); $bundleInfo = new BundleInfo(); switch(true) { // Handle PHP files in bundles within their own namespace case preg_match( sprintf( '/namespace (.*%s.*Bundle)/', $inflector->translate('MajoraNamespace') ), $fileContent, $matches ) > 0: $bundleInfo->setNamespace($matches[1]); $bundleInfo->setClassName( stripslashes( str_replace( sprintf('%s\Bundle', $inflector->translate('MajoraNamespace')), $inflector->translate('MajoraNamespace'), $matches[1] ) ) ); break; // Handle PHP files in bundles at the root of the "src" directory case preg_match( '/namespace (.*Bundle)/', $fileContent, $matches ) > 0: $bundleInfo->setNamespace($matches[1]); $bundleInfo->setClassName($matches[1]); break; // Could not retrieve bundle info from file default: throw new \UnexpectedValueException(sprintf( 'Could not retrieve bundle information from "%s" file.', $generatedFile->getFilename() )); } return $bundleInfo; }
php
protected function retrieveBundleInfoFromGeneratedFile(SplFileInfo $generatedFile, Inflector $inflector) { if($generatedFile->getExtension() !== 'php'){ throw new UnsupportedFileForContentModifierException(sprintf( 'This content modifier requires to be used on a PHP file, "%s" is not a PHP file.', $generatedFile->getFilename() )); } $fileContent = $generatedFile->getContents(); $bundleInfo = new BundleInfo(); switch(true) { // Handle PHP files in bundles within their own namespace case preg_match( sprintf( '/namespace (.*%s.*Bundle)/', $inflector->translate('MajoraNamespace') ), $fileContent, $matches ) > 0: $bundleInfo->setNamespace($matches[1]); $bundleInfo->setClassName( stripslashes( str_replace( sprintf('%s\Bundle', $inflector->translate('MajoraNamespace')), $inflector->translate('MajoraNamespace'), $matches[1] ) ) ); break; // Handle PHP files in bundles at the root of the "src" directory case preg_match( '/namespace (.*Bundle)/', $fileContent, $matches ) > 0: $bundleInfo->setNamespace($matches[1]); $bundleInfo->setClassName($matches[1]); break; // Could not retrieve bundle info from file default: throw new \UnexpectedValueException(sprintf( 'Could not retrieve bundle information from "%s" file.', $generatedFile->getFilename() )); } return $bundleInfo; }
[ "protected", "function", "retrieveBundleInfoFromGeneratedFile", "(", "SplFileInfo", "$", "generatedFile", ",", "Inflector", "$", "inflector", ")", "{", "if", "(", "$", "generatedFile", "->", "getExtension", "(", ")", "!==", "'php'", ")", "{", "throw", "new", "UnsupportedFileForContentModifierException", "(", "sprintf", "(", "'This content modifier requires to be used on a PHP file, \"%s\" is not a PHP file.'", ",", "$", "generatedFile", "->", "getFilename", "(", ")", ")", ")", ";", "}", "$", "fileContent", "=", "$", "generatedFile", "->", "getContents", "(", ")", ";", "$", "bundleInfo", "=", "new", "BundleInfo", "(", ")", ";", "switch", "(", "true", ")", "{", "// Handle PHP files in bundles within their own namespace", "case", "preg_match", "(", "sprintf", "(", "'/namespace (.*%s.*Bundle)/'", ",", "$", "inflector", "->", "translate", "(", "'MajoraNamespace'", ")", ")", ",", "$", "fileContent", ",", "$", "matches", ")", ">", "0", ":", "$", "bundleInfo", "->", "setNamespace", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "bundleInfo", "->", "setClassName", "(", "stripslashes", "(", "str_replace", "(", "sprintf", "(", "'%s\\Bundle'", ",", "$", "inflector", "->", "translate", "(", "'MajoraNamespace'", ")", ")", ",", "$", "inflector", "->", "translate", "(", "'MajoraNamespace'", ")", ",", "$", "matches", "[", "1", "]", ")", ")", ")", ";", "break", ";", "// Handle PHP files in bundles at the root of the \"src\" directory", "case", "preg_match", "(", "'/namespace (.*Bundle)/'", ",", "$", "fileContent", ",", "$", "matches", ")", ">", "0", ":", "$", "bundleInfo", "->", "setNamespace", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "bundleInfo", "->", "setClassName", "(", "$", "matches", "[", "1", "]", ")", ";", "break", ";", "// Could not retrieve bundle info from file", "default", ":", "throw", "new", "\\", "UnexpectedValueException", "(", "sprintf", "(", "'Could not retrieve bundle information from \"%s\" file.'", ",", "$", "generatedFile", "->", "getFilename", "(", ")", ")", ")", ";", "}", "return", "$", "bundleInfo", ";", "}" ]
Retrieve information of the Bundle which contains the given file. @param SplFileInfo $generatedFile @param Inflector $inflector @return BundleInfo @throws UnsupportedFileForContentModifierException when file is not a PHP file @throws \UnexpectedValueException when we could not retrieve bundle info from file
[ "Retrieve", "information", "of", "the", "Bundle", "which", "contains", "the", "given", "file", "." ]
9f745c1f64e913df90d86b4fd0770121c563552d
https://github.com/Linkvalue-Interne/MajoraGeneratorBundle/blob/9f745c1f64e913df90d86b4fd0770121c563552d/src/Majora/Bundle/GeneratorBundle/Generator/ContentModifier/AbstractPhpClassContentModifier.php#L26-L81
train
bkstg/schedule-bundle
Timeline/EventSubscriber/EventTimelineSubscriber.php
EventTimelineSubscriber.createInvitationTimelineEntries
public function createInvitationTimelineEntries(EntityPublishedEvent $published_event): void { // Only act on event objects. $event = $published_event->getObject(); if (!$event instanceof Event) { return; } // Get the author for the event. $author = $this->user_provider->loadUserByUsername($event->getAuthor()); // Create components for this action. $event_component = $this->action_manager->findOrCreateComponent($event); $author_component = $this->action_manager->findOrCreateComponent($author); // Add timeline entries for each group. foreach ($event->getGroups() as $group) { foreach ($event->getInvitations() as $invitation) { $invitee = $this->user_provider->loadUserByUsername($invitation->getInvitee()); $invitee_component = $this->action_manager->findOrCreateComponent($invitee); // Create the action and link it. $action = $this->action_manager->create($author_component, 'invited', [ 'directComplement' => $invitee_component, 'indirectComplement' => $event_component, ]); // Update the action. $this->action_manager->updateAction($action); } } }
php
public function createInvitationTimelineEntries(EntityPublishedEvent $published_event): void { // Only act on event objects. $event = $published_event->getObject(); if (!$event instanceof Event) { return; } // Get the author for the event. $author = $this->user_provider->loadUserByUsername($event->getAuthor()); // Create components for this action. $event_component = $this->action_manager->findOrCreateComponent($event); $author_component = $this->action_manager->findOrCreateComponent($author); // Add timeline entries for each group. foreach ($event->getGroups() as $group) { foreach ($event->getInvitations() as $invitation) { $invitee = $this->user_provider->loadUserByUsername($invitation->getInvitee()); $invitee_component = $this->action_manager->findOrCreateComponent($invitee); // Create the action and link it. $action = $this->action_manager->create($author_component, 'invited', [ 'directComplement' => $invitee_component, 'indirectComplement' => $event_component, ]); // Update the action. $this->action_manager->updateAction($action); } } }
[ "public", "function", "createInvitationTimelineEntries", "(", "EntityPublishedEvent", "$", "published_event", ")", ":", "void", "{", "// Only act on event objects.", "$", "event", "=", "$", "published_event", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "event", "instanceof", "Event", ")", "{", "return", ";", "}", "// Get the author for the event.", "$", "author", "=", "$", "this", "->", "user_provider", "->", "loadUserByUsername", "(", "$", "event", "->", "getAuthor", "(", ")", ")", ";", "// Create components for this action.", "$", "event_component", "=", "$", "this", "->", "action_manager", "->", "findOrCreateComponent", "(", "$", "event", ")", ";", "$", "author_component", "=", "$", "this", "->", "action_manager", "->", "findOrCreateComponent", "(", "$", "author", ")", ";", "// Add timeline entries for each group.", "foreach", "(", "$", "event", "->", "getGroups", "(", ")", "as", "$", "group", ")", "{", "foreach", "(", "$", "event", "->", "getInvitations", "(", ")", "as", "$", "invitation", ")", "{", "$", "invitee", "=", "$", "this", "->", "user_provider", "->", "loadUserByUsername", "(", "$", "invitation", "->", "getInvitee", "(", ")", ")", ";", "$", "invitee_component", "=", "$", "this", "->", "action_manager", "->", "findOrCreateComponent", "(", "$", "invitee", ")", ";", "// Create the action and link it.", "$", "action", "=", "$", "this", "->", "action_manager", "->", "create", "(", "$", "author_component", ",", "'invited'", ",", "[", "'directComplement'", "=>", "$", "invitee_component", ",", "'indirectComplement'", "=>", "$", "event_component", ",", "]", ")", ";", "// Update the action.", "$", "this", "->", "action_manager", "->", "updateAction", "(", "$", "action", ")", ";", "}", "}", "}" ]
Create invited timeline events. @param EntityPublishedEvent $published_event The published event. @return void
[ "Create", "invited", "timeline", "events", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Timeline/EventSubscriber/EventTimelineSubscriber.php#L62-L93
train
bkstg/schedule-bundle
Timeline/EventSubscriber/EventTimelineSubscriber.php
EventTimelineSubscriber.createScheduleTimelineEntry
public function createScheduleTimelineEntry(EntityPublishedEvent $event): void { // Only act on schedule objects. $schedule = $event->getObject(); if (!$schedule instanceof Schedule) { return; } // Get the author for the schedule. $author = $this->user_provider->loadUserByUsername($schedule->getAuthor()); // Create components for this action. $schedule_component = $this->action_manager->findOrCreateComponent($schedule); $author_component = $this->action_manager->findOrCreateComponent($author); // Add timeline entries for each group. foreach ($schedule->getGroups() as $group) { // Create the group component. $group_component = $this->action_manager->findOrCreateComponent($group); // Create the action and link it. $action = $this->action_manager->create($author_component, 'scheduled', [ 'directComplement' => $schedule_component, 'indirectComplement' => $group_component, ]); // Update the action. $this->action_manager->updateAction($action); } }
php
public function createScheduleTimelineEntry(EntityPublishedEvent $event): void { // Only act on schedule objects. $schedule = $event->getObject(); if (!$schedule instanceof Schedule) { return; } // Get the author for the schedule. $author = $this->user_provider->loadUserByUsername($schedule->getAuthor()); // Create components for this action. $schedule_component = $this->action_manager->findOrCreateComponent($schedule); $author_component = $this->action_manager->findOrCreateComponent($author); // Add timeline entries for each group. foreach ($schedule->getGroups() as $group) { // Create the group component. $group_component = $this->action_manager->findOrCreateComponent($group); // Create the action and link it. $action = $this->action_manager->create($author_component, 'scheduled', [ 'directComplement' => $schedule_component, 'indirectComplement' => $group_component, ]); // Update the action. $this->action_manager->updateAction($action); } }
[ "public", "function", "createScheduleTimelineEntry", "(", "EntityPublishedEvent", "$", "event", ")", ":", "void", "{", "// Only act on schedule objects.", "$", "schedule", "=", "$", "event", "->", "getObject", "(", ")", ";", "if", "(", "!", "$", "schedule", "instanceof", "Schedule", ")", "{", "return", ";", "}", "// Get the author for the schedule.", "$", "author", "=", "$", "this", "->", "user_provider", "->", "loadUserByUsername", "(", "$", "schedule", "->", "getAuthor", "(", ")", ")", ";", "// Create components for this action.", "$", "schedule_component", "=", "$", "this", "->", "action_manager", "->", "findOrCreateComponent", "(", "$", "schedule", ")", ";", "$", "author_component", "=", "$", "this", "->", "action_manager", "->", "findOrCreateComponent", "(", "$", "author", ")", ";", "// Add timeline entries for each group.", "foreach", "(", "$", "schedule", "->", "getGroups", "(", ")", "as", "$", "group", ")", "{", "// Create the group component.", "$", "group_component", "=", "$", "this", "->", "action_manager", "->", "findOrCreateComponent", "(", "$", "group", ")", ";", "// Create the action and link it.", "$", "action", "=", "$", "this", "->", "action_manager", "->", "create", "(", "$", "author_component", ",", "'scheduled'", ",", "[", "'directComplement'", "=>", "$", "schedule_component", ",", "'indirectComplement'", "=>", "$", "group_component", ",", "]", ")", ";", "// Update the action.", "$", "this", "->", "action_manager", "->", "updateAction", "(", "$", "action", ")", ";", "}", "}" ]
Create the schedule timeline entry. @param EntityPublishedEvent $event The published event. @return void
[ "Create", "the", "schedule", "timeline", "entry", "." ]
e64ac897aa7b28bc48319470d65de13cd4788afe
https://github.com/bkstg/schedule-bundle/blob/e64ac897aa7b28bc48319470d65de13cd4788afe/Timeline/EventSubscriber/EventTimelineSubscriber.php#L102-L131
train
OxfordInfoLabs/kinikit-core
src/Util/CodeUtils.php
CodeUtils.normalisePropertyName
public function normalisePropertyName($propertyName) { if ((strlen ( $propertyName ) > 1) && ((ord ( $propertyName [1] ) >= ord ( "a" )) || is_numeric ( $propertyName [1] ))) { $propertyName = strtolower ( $propertyName [0] ) . substr ( $propertyName, 1 ); } return $propertyName; }
php
public function normalisePropertyName($propertyName) { if ((strlen ( $propertyName ) > 1) && ((ord ( $propertyName [1] ) >= ord ( "a" )) || is_numeric ( $propertyName [1] ))) { $propertyName = strtolower ( $propertyName [0] ) . substr ( $propertyName, 1 ); } return $propertyName; }
[ "public", "function", "normalisePropertyName", "(", "$", "propertyName", ")", "{", "if", "(", "(", "strlen", "(", "$", "propertyName", ")", ">", "1", ")", "&&", "(", "(", "ord", "(", "$", "propertyName", "[", "1", "]", ")", ">=", "ord", "(", "\"a\"", ")", ")", "||", "is_numeric", "(", "$", "propertyName", "[", "1", "]", ")", ")", ")", "{", "$", "propertyName", "=", "strtolower", "(", "$", "propertyName", "[", "0", "]", ")", ".", "substr", "(", "$", "propertyName", ",", "1", ")", ";", "}", "return", "$", "propertyName", ";", "}" ]
Normalise the property name using the standard rules we might expect. @param string $propertyName
[ "Normalise", "the", "property", "name", "using", "the", "standard", "rules", "we", "might", "expect", "." ]
edc1b2e6ffabd595c4c7d322279b3dd1e59ef359
https://github.com/OxfordInfoLabs/kinikit-core/blob/edc1b2e6ffabd595c4c7d322279b3dd1e59ef359/src/Util/CodeUtils.php#L40-L47
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.select
public function select($columns = "*") : QueryBuilder { $this->_query[] = "SELECT"; //Parse column(s) if(is_array($columns)) { $select_columns = ""; $size = sizeof($columns); for($i = 0; $i < $size; $i++) { if($i > 0) { $select_columns .= ', '; } $select_columns .= '`'. $this->sanitize((string)$columns[$i]) .'`'; } $this->_query[] = $select_columns; return $this; } $select_columns = "*"; if( !empty($columns) && $columns !== "*" ) { $select_columns = '`'. $this->sanitize((string)$columns) .'`'; } $this->_query[] = $select_columns; return $this; }
php
public function select($columns = "*") : QueryBuilder { $this->_query[] = "SELECT"; //Parse column(s) if(is_array($columns)) { $select_columns = ""; $size = sizeof($columns); for($i = 0; $i < $size; $i++) { if($i > 0) { $select_columns .= ', '; } $select_columns .= '`'. $this->sanitize((string)$columns[$i]) .'`'; } $this->_query[] = $select_columns; return $this; } $select_columns = "*"; if( !empty($columns) && $columns !== "*" ) { $select_columns = '`'. $this->sanitize((string)$columns) .'`'; } $this->_query[] = $select_columns; return $this; }
[ "public", "function", "select", "(", "$", "columns", "=", "\"*\"", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"SELECT\"", ";", "//Parse column(s)", "if", "(", "is_array", "(", "$", "columns", ")", ")", "{", "$", "select_columns", "=", "\"\"", ";", "$", "size", "=", "sizeof", "(", "$", "columns", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "size", ";", "$", "i", "++", ")", "{", "if", "(", "$", "i", ">", "0", ")", "{", "$", "select_columns", ".=", "', '", ";", "}", "$", "select_columns", ".=", "'`'", ".", "$", "this", "->", "sanitize", "(", "(", "string", ")", "$", "columns", "[", "$", "i", "]", ")", ".", "'`'", ";", "}", "$", "this", "->", "_query", "[", "]", "=", "$", "select_columns", ";", "return", "$", "this", ";", "}", "$", "select_columns", "=", "\"*\"", ";", "if", "(", "!", "empty", "(", "$", "columns", ")", "&&", "$", "columns", "!==", "\"*\"", ")", "{", "$", "select_columns", "=", "'`'", ".", "$", "this", "->", "sanitize", "(", "(", "string", ")", "$", "columns", ")", ".", "'`'", ";", "}", "$", "this", "->", "_query", "[", "]", "=", "$", "select_columns", ";", "return", "$", "this", ";", "}" ]
Begins the select query. @param string|array $columns Column(s) to select, if empty has same effect as "*". @return QueryBuilder Chainability object.
[ "Begins", "the", "select", "query", "." ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L63-L96
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.insert
public function insert(string $table) : QueryBuilder { $this->_query[] = "INSERT INTO"; $this->_query[] = "`". $this->sanitize($table) ."`"; return $this; }
php
public function insert(string $table) : QueryBuilder { $this->_query[] = "INSERT INTO"; $this->_query[] = "`". $this->sanitize($table) ."`"; return $this; }
[ "public", "function", "insert", "(", "string", "$", "table", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"INSERT INTO\"", ";", "$", "this", "->", "_query", "[", "]", "=", "\"`\"", ".", "$", "this", "->", "sanitize", "(", "$", "table", ")", ".", "\"`\"", ";", "return", "$", "this", ";", "}" ]
Begins the insert query @param string $table Table name @return QueryBuilder Chainability object
[ "Begins", "the", "insert", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L105-L111
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.update
public function update(string $table) : QueryBuilder { $this->_query[] = "UPDATE"; $this->_query[] = "`". $this->sanitize($table) ."`"; return $this; }
php
public function update(string $table) : QueryBuilder { $this->_query[] = "UPDATE"; $this->_query[] = "`". $this->sanitize($table) ."`"; return $this; }
[ "public", "function", "update", "(", "string", "$", "table", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"UPDATE\"", ";", "$", "this", "->", "_query", "[", "]", "=", "\"`\"", ".", "$", "this", "->", "sanitize", "(", "$", "table", ")", ".", "\"`\"", ";", "return", "$", "this", ";", "}" ]
Begins the update query @param string $table Table name @return QueryBuilder Chainability object
[ "Begins", "the", "update", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L120-L126
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.delete
public function delete(string $table) : QueryBuilder { $this->_query[] = "DELETE FROM"; $this->_query[] = "`". $this->sanitize($table) ."`"; return $this; }
php
public function delete(string $table) : QueryBuilder { $this->_query[] = "DELETE FROM"; $this->_query[] = "`". $this->sanitize($table) ."`"; return $this; }
[ "public", "function", "delete", "(", "string", "$", "table", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"DELETE FROM\"", ";", "$", "this", "->", "_query", "[", "]", "=", "\"`\"", ".", "$", "this", "->", "sanitize", "(", "$", "table", ")", ".", "\"`\"", ";", "return", "$", "this", ";", "}" ]
Begins the delete query @param string $table Table name @return QueryBuilder Chainability object
[ "Begins", "the", "delete", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L135-L141
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.from
public function from(string $tables) : QueryBuilder { $this->_query[] = "FROM"; $this->_query[] = '`'. $this->sanitize($tables) .'`'; return $this; }
php
public function from(string $tables) : QueryBuilder { $this->_query[] = "FROM"; $this->_query[] = '`'. $this->sanitize($tables) .'`'; return $this; }
[ "public", "function", "from", "(", "string", "$", "tables", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"FROM\"", ";", "$", "this", "->", "_query", "[", "]", "=", "'`'", ".", "$", "this", "->", "sanitize", "(", "$", "tables", ")", ".", "'`'", ";", "return", "$", "this", ";", "}" ]
Begins the FORM part of the query @param string $tables Table name @return QueryBuilder Chainability object
[ "Begins", "the", "FORM", "part", "of", "the", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L150-L156
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.where
public function where(array $condition) : QueryBuilder { $this->_query[] = "WHERE"; foreach($condition as $key => $value) { $this->_query[] = $this->parseTags([$key, $value]); } return $this; }
php
public function where(array $condition) : QueryBuilder { $this->_query[] = "WHERE"; foreach($condition as $key => $value) { $this->_query[] = $this->parseTags([$key, $value]); } return $this; }
[ "public", "function", "where", "(", "array", "$", "condition", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"WHERE\"", ";", "foreach", "(", "$", "condition", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "_query", "[", "]", "=", "$", "this", "->", "parseTags", "(", "[", "$", "key", ",", "$", "value", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Begins the WHERE statement of the query Example: ```php $query->where([ "username" => "test" ]); $query->where( "AND" => [ ["username" => "test"], ["password" => "test"] ] ); ``` @param array $condition Where condition @return QueryBuilder Chainability object
[ "Begins", "the", "WHERE", "statement", "of", "the", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L179-L188
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.order
public function order(string $column, string $method = "DESC") : QueryBuilder { $this->_query[] = "ORDER BY"; $this->_query[] = "`". $this->sanitize($column) ."`"; $this->_query[] = (strtoupper($method) === "DESC") ? "DESC" : "ASC"; return $this; }
php
public function order(string $column, string $method = "DESC") : QueryBuilder { $this->_query[] = "ORDER BY"; $this->_query[] = "`". $this->sanitize($column) ."`"; $this->_query[] = (strtoupper($method) === "DESC") ? "DESC" : "ASC"; return $this; }
[ "public", "function", "order", "(", "string", "$", "column", ",", "string", "$", "method", "=", "\"DESC\"", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"ORDER BY\"", ";", "$", "this", "->", "_query", "[", "]", "=", "\"`\"", ".", "$", "this", "->", "sanitize", "(", "$", "column", ")", ".", "\"`\"", ";", "$", "this", "->", "_query", "[", "]", "=", "(", "strtoupper", "(", "$", "method", ")", "===", "\"DESC\"", ")", "?", "\"DESC\"", ":", "\"ASC\"", ";", "return", "$", "this", ";", "}" ]
Begins the ORDER BY part of the query @param string $column Column name @param string $method Order method @return QueryBuilder Chainability object
[ "Begins", "the", "ORDER", "BY", "part", "of", "the", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L198-L205
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.limit
public function limit($limit) : QueryBuilder { $this->_query[] = "LIMIT"; if(is_array($limit)) { $this->_query[] = $this->getQuoted($limit[0]).","; $this->_query[] = $this->getQuoted($limit[1]); return $this; } $this->_query[] = $this->getQuoted($limit); return $this; }
php
public function limit($limit) : QueryBuilder { $this->_query[] = "LIMIT"; if(is_array($limit)) { $this->_query[] = $this->getQuoted($limit[0]).","; $this->_query[] = $this->getQuoted($limit[1]); return $this; } $this->_query[] = $this->getQuoted($limit); return $this; }
[ "public", "function", "limit", "(", "$", "limit", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"LIMIT\"", ";", "if", "(", "is_array", "(", "$", "limit", ")", ")", "{", "$", "this", "->", "_query", "[", "]", "=", "$", "this", "->", "getQuoted", "(", "$", "limit", "[", "0", "]", ")", ".", "\",\"", ";", "$", "this", "->", "_query", "[", "]", "=", "$", "this", "->", "getQuoted", "(", "$", "limit", "[", "1", "]", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "_query", "[", "]", "=", "$", "this", "->", "getQuoted", "(", "$", "limit", ")", ";", "return", "$", "this", ";", "}" ]
Begins the LIMIT part of the query @param int|array $limit Limit value @return QueryBuilder Chainability object
[ "Begins", "the", "LIMIT", "part", "of", "the", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L214-L228
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.offset
public function offset(int $offset) : QueryBuilder { $this->_query[] = "OFFSET"; $this->_query[] = $offset; return $this; }
php
public function offset(int $offset) : QueryBuilder { $this->_query[] = "OFFSET"; $this->_query[] = $offset; return $this; }
[ "public", "function", "offset", "(", "int", "$", "offset", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"OFFSET\"", ";", "$", "this", "->", "_query", "[", "]", "=", "$", "offset", ";", "return", "$", "this", ";", "}" ]
Begins the OFFSET part of the query @param int $offset Offset value @return QueryBuilder Chainability object
[ "Begins", "the", "OFFSET", "part", "of", "the", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L237-L243
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.set
public function set(array $values) : QueryBuilder { $this->_query[] = "SET"; $set = []; foreach($values as $key => $val) { $set[] = $this->parseTags([$key, $val]); } $this->_query[] = implode(", ", $set); return $this; }
php
public function set(array $values) : QueryBuilder { $this->_query[] = "SET"; $set = []; foreach($values as $key => $val) { $set[] = $this->parseTags([$key, $val]); } $this->_query[] = implode(", ", $set); return $this; }
[ "public", "function", "set", "(", "array", "$", "values", ")", ":", "QueryBuilder", "{", "$", "this", "->", "_query", "[", "]", "=", "\"SET\"", ";", "$", "set", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "set", "[", "]", "=", "$", "this", "->", "parseTags", "(", "[", "$", "key", ",", "$", "val", "]", ")", ";", "}", "$", "this", "->", "_query", "[", "]", "=", "implode", "(", "\", \"", ",", "$", "set", ")", ";", "return", "$", "this", ";", "}" ]
Begins the SET part of the query @param array $values Values to set @return QueryBuilder Chainability object
[ "Begins", "the", "SET", "part", "of", "the", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L252-L264
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.values
public function values(array $values) : QueryBuilder { $args = func_get_args(); $columns = []; $_values = []; foreach($values as $key => $value) { preg_match("/\(JSON\)\s*([\w]+)/i", $key, $jsonTag); if( is_array($value) || is_object($value) ) { if(isset($jsonTag[0])) { $key = preg_replace('/\(JSON\)\s*([\w]+)/i', '$1', $key); $_values[] = $this->getQuoted(json_encode($value)); } else { $_values[] = $this->getQuoted(serialize($value)); } } else if(is_bool($value)) { $_values[] = ($value ? 1 : 0); } else if(is_null($value)) { $_values[] = "NULL"; } else { $_values[] = $this->getQuoted($value); } $columns[] = "`". $this->sanitize($key) ."`"; } $this->_query[] = "(". implode(", ", $columns) .")"; $this->_query[] = "VALUES"; $this->_query[] = "(". implode(", ", $_values) .")"; return $this; }
php
public function values(array $values) : QueryBuilder { $args = func_get_args(); $columns = []; $_values = []; foreach($values as $key => $value) { preg_match("/\(JSON\)\s*([\w]+)/i", $key, $jsonTag); if( is_array($value) || is_object($value) ) { if(isset($jsonTag[0])) { $key = preg_replace('/\(JSON\)\s*([\w]+)/i', '$1', $key); $_values[] = $this->getQuoted(json_encode($value)); } else { $_values[] = $this->getQuoted(serialize($value)); } } else if(is_bool($value)) { $_values[] = ($value ? 1 : 0); } else if(is_null($value)) { $_values[] = "NULL"; } else { $_values[] = $this->getQuoted($value); } $columns[] = "`". $this->sanitize($key) ."`"; } $this->_query[] = "(". implode(", ", $columns) .")"; $this->_query[] = "VALUES"; $this->_query[] = "(". implode(", ", $_values) .")"; return $this; }
[ "public", "function", "values", "(", "array", "$", "values", ")", ":", "QueryBuilder", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "columns", "=", "[", "]", ";", "$", "_values", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "preg_match", "(", "\"/\\(JSON\\)\\s*([\\w]+)/i\"", ",", "$", "key", ",", "$", "jsonTag", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", "||", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "isset", "(", "$", "jsonTag", "[", "0", "]", ")", ")", "{", "$", "key", "=", "preg_replace", "(", "'/\\(JSON\\)\\s*([\\w]+)/i'", ",", "'$1'", ",", "$", "key", ")", ";", "$", "_values", "[", "]", "=", "$", "this", "->", "getQuoted", "(", "json_encode", "(", "$", "value", ")", ")", ";", "}", "else", "{", "$", "_values", "[", "]", "=", "$", "this", "->", "getQuoted", "(", "serialize", "(", "$", "value", ")", ")", ";", "}", "}", "else", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "$", "_values", "[", "]", "=", "(", "$", "value", "?", "1", ":", "0", ")", ";", "}", "else", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "_values", "[", "]", "=", "\"NULL\"", ";", "}", "else", "{", "$", "_values", "[", "]", "=", "$", "this", "->", "getQuoted", "(", "$", "value", ")", ";", "}", "$", "columns", "[", "]", "=", "\"`\"", ".", "$", "this", "->", "sanitize", "(", "$", "key", ")", ".", "\"`\"", ";", "}", "$", "this", "->", "_query", "[", "]", "=", "\"(\"", ".", "implode", "(", "\", \"", ",", "$", "columns", ")", ".", "\")\"", ";", "$", "this", "->", "_query", "[", "]", "=", "\"VALUES\"", ";", "$", "this", "->", "_query", "[", "]", "=", "\"(\"", ".", "implode", "(", "\", \"", ",", "$", "_values", ")", ".", "\")\"", ";", "return", "$", "this", ";", "}" ]
Begins the VALUES part of the query @param array $values Values to insert @return QueryBuilder Chainability object
[ "Begins", "the", "VALUES", "part", "of", "the", "query" ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L273-L308
train
AlexyaFramework/Database
Alexya/Database/QueryBuilder.php
QueryBuilder.sanitize
public function sanitize(string $input) : string { $input = $this->_connection->getConnection()->quote($input); return substr($input, 1, -1); }
php
public function sanitize(string $input) : string { $input = $this->_connection->getConnection()->quote($input); return substr($input, 1, -1); }
[ "public", "function", "sanitize", "(", "string", "$", "input", ")", ":", "string", "{", "$", "input", "=", "$", "this", "->", "_connection", "->", "getConnection", "(", ")", "->", "quote", "(", "$", "input", ")", ";", "return", "substr", "(", "$", "input", ",", "1", ",", "-", "1", ")", ";", "}" ]
Sanitizes the input. @param string $input Input to sanitize. @return string SQL injection free `$input`.
[ "Sanitizes", "the", "input", "." ]
5eb12dc183700ed2357495f4d2c2863ca033eb5a
https://github.com/AlexyaFramework/Database/blob/5eb12dc183700ed2357495f4d2c2863ca033eb5a/Alexya/Database/QueryBuilder.php#L511-L516
train
rawphp/RawConsole
src/RawPHP/RawConsole/Writer/StandardHelpWriter.php
StandardHelpWriter.write
public function write( Command $command, Option $option = NULL ) { $output = PHP_EOL; $output .= '-----------------------------------------------------' . PHP_EOL; $output .= $command->name . ' ' . $command->version . PHP_EOL; $output .= '-----------------------------------------------------' . PHP_EOL; $output .= $command->copyright . PHP_EOL; $output .= $command->description . PHP_EOL; $output .= 'Support: ' . $command->supportSite . PHP_EOL; $output .= 'Source: ' . $command->supportSource . PHP_EOL; $output .= '-----------------------------------------------------' . PHP_EOL . PHP_EOL; $output .= 'Usage: ' . $this->_getUsageExample( $command ); if ( NULL !== $option && !empty( $option->longDescription ) ) // detailed help for single option { $output .= $option->longDescription . PHP_EOL; } else // short overview of each option { $str = ''; foreach ( $command->options as $option ) { $str .= sprintf( " --%-8s (-%s) %-6s%s", $option->longCode, $option->shortCode, $option->shortDescription, PHP_EOL ); } $output .= $str; } echo $output; }
php
public function write( Command $command, Option $option = NULL ) { $output = PHP_EOL; $output .= '-----------------------------------------------------' . PHP_EOL; $output .= $command->name . ' ' . $command->version . PHP_EOL; $output .= '-----------------------------------------------------' . PHP_EOL; $output .= $command->copyright . PHP_EOL; $output .= $command->description . PHP_EOL; $output .= 'Support: ' . $command->supportSite . PHP_EOL; $output .= 'Source: ' . $command->supportSource . PHP_EOL; $output .= '-----------------------------------------------------' . PHP_EOL . PHP_EOL; $output .= 'Usage: ' . $this->_getUsageExample( $command ); if ( NULL !== $option && !empty( $option->longDescription ) ) // detailed help for single option { $output .= $option->longDescription . PHP_EOL; } else // short overview of each option { $str = ''; foreach ( $command->options as $option ) { $str .= sprintf( " --%-8s (-%s) %-6s%s", $option->longCode, $option->shortCode, $option->shortDescription, PHP_EOL ); } $output .= $str; } echo $output; }
[ "public", "function", "write", "(", "Command", "$", "command", ",", "Option", "$", "option", "=", "NULL", ")", "{", "$", "output", "=", "PHP_EOL", ";", "$", "output", ".=", "'-----------------------------------------------------'", ".", "PHP_EOL", ";", "$", "output", ".=", "$", "command", "->", "name", ".", "' '", ".", "$", "command", "->", "version", ".", "PHP_EOL", ";", "$", "output", ".=", "'-----------------------------------------------------'", ".", "PHP_EOL", ";", "$", "output", ".=", "$", "command", "->", "copyright", ".", "PHP_EOL", ";", "$", "output", ".=", "$", "command", "->", "description", ".", "PHP_EOL", ";", "$", "output", ".=", "'Support: '", ".", "$", "command", "->", "supportSite", ".", "PHP_EOL", ";", "$", "output", ".=", "'Source: '", ".", "$", "command", "->", "supportSource", ".", "PHP_EOL", ";", "$", "output", ".=", "'-----------------------------------------------------'", ".", "PHP_EOL", ".", "PHP_EOL", ";", "$", "output", ".=", "'Usage: '", ".", "$", "this", "->", "_getUsageExample", "(", "$", "command", ")", ";", "if", "(", "NULL", "!==", "$", "option", "&&", "!", "empty", "(", "$", "option", "->", "longDescription", ")", ")", "// detailed help for single option", "{", "$", "output", ".=", "$", "option", "->", "longDescription", ".", "PHP_EOL", ";", "}", "else", "// short overview of each option", "{", "$", "str", "=", "''", ";", "foreach", "(", "$", "command", "->", "options", "as", "$", "option", ")", "{", "$", "str", ".=", "sprintf", "(", "\" --%-8s (-%s) %-6s%s\"", ",", "$", "option", "->", "longCode", ",", "$", "option", "->", "shortCode", ",", "$", "option", "->", "shortDescription", ",", "PHP_EOL", ")", ";", "}", "$", "output", ".=", "$", "str", ";", "}", "echo", "$", "output", ";", "}" ]
This method writes the help to the console. @param Command $command the command instance @param Option $option optional option
[ "This", "method", "writes", "the", "help", "to", "the", "console", "." ]
602bedd10f24962305a7ac1979ed326852f4224a
https://github.com/rawphp/RawConsole/blob/602bedd10f24962305a7ac1979ed326852f4224a/src/RawPHP/RawConsole/Writer/StandardHelpWriter.php#L60-L93
train
rawphp/RawConsole
src/RawPHP/RawConsole/Writer/StandardHelpWriter.php
StandardHelpWriter._getUsageExample
private function _getUsageExample( Command $command ) { $name = strtolower( str_replace( 'Command', '', get_class( $command ) ) ); if ( FALSE !== strstr( $name, "\\" ) ) { $pts = explode( "\\", $name ); $name = $pts[ count( $pts ) - 1 ]; } $usage = './' . $name . ' --' . $command->options[ 0 ]->longCode; return $usage . PHP_EOL . PHP_EOL; }
php
private function _getUsageExample( Command $command ) { $name = strtolower( str_replace( 'Command', '', get_class( $command ) ) ); if ( FALSE !== strstr( $name, "\\" ) ) { $pts = explode( "\\", $name ); $name = $pts[ count( $pts ) - 1 ]; } $usage = './' . $name . ' --' . $command->options[ 0 ]->longCode; return $usage . PHP_EOL . PHP_EOL; }
[ "private", "function", "_getUsageExample", "(", "Command", "$", "command", ")", "{", "$", "name", "=", "strtolower", "(", "str_replace", "(", "'Command'", ",", "''", ",", "get_class", "(", "$", "command", ")", ")", ")", ";", "if", "(", "FALSE", "!==", "strstr", "(", "$", "name", ",", "\"\\\\\"", ")", ")", "{", "$", "pts", "=", "explode", "(", "\"\\\\\"", ",", "$", "name", ")", ";", "$", "name", "=", "$", "pts", "[", "count", "(", "$", "pts", ")", "-", "1", "]", ";", "}", "$", "usage", "=", "'./'", ".", "$", "name", ".", "' --'", ".", "$", "command", "->", "options", "[", "0", "]", "->", "longCode", ";", "return", "$", "usage", ".", "PHP_EOL", ".", "PHP_EOL", ";", "}" ]
Prepares the command usage example. @param Command $command the command @return string the command usage example string
[ "Prepares", "the", "command", "usage", "example", "." ]
602bedd10f24962305a7ac1979ed326852f4224a
https://github.com/rawphp/RawConsole/blob/602bedd10f24962305a7ac1979ed326852f4224a/src/RawPHP/RawConsole/Writer/StandardHelpWriter.php#L102-L116
train