repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
Nicklas766/Comment
src/Comment/Modules/Question.php
Question.getPopularTags
public function getPopularTags() { $question = $this->findAll(); $tagsMultiArray = array_map(function ($question) { return explode(',', $question->tags); }, $question); // Merge multi array, count values, sort high to low $tagArr = array_count_values(call_user_func_array("array_merge", $tagsMultiArray)); arsort($tagArr); return $tagArr; }
php
public function getPopularTags() { $question = $this->findAll(); $tagsMultiArray = array_map(function ($question) { return explode(',', $question->tags); }, $question); // Merge multi array, count values, sort high to low $tagArr = array_count_values(call_user_func_array("array_merge", $tagsMultiArray)); arsort($tagArr); return $tagArr; }
[ "public", "function", "getPopularTags", "(", ")", "{", "$", "question", "=", "$", "this", "->", "findAll", "(", ")", ";", "$", "tagsMultiArray", "=", "array_map", "(", "function", "(", "$", "question", ")", "{", "return", "explode", "(", "','", ",", "$", "question", "->", "tags", ")", ";", "}", ",", "$", "question", ")", ";", "// Merge multi array, count values, sort high to low", "$", "tagArr", "=", "array_count_values", "(", "call_user_func_array", "(", "\"array_merge\"", ",", "$", "tagsMultiArray", ")", ")", ";", "arsort", "(", "$", "tagArr", ")", ";", "return", "$", "tagArr", ";", "}" ]
Returns array of tags, keys are name, value is the integer of how many. @return array
[ "Returns", "array", "of", "tags", "keys", "are", "name", "value", "is", "the", "integer", "of", "how", "many", "." ]
1483eaf1ebb120b8bd6c2a1552c084b3a288ff25
https://github.com/Nicklas766/Comment/blob/1483eaf1ebb120b8bd6c2a1552c084b3a288ff25/src/Comment/Modules/Question.php#L90-L102
train
swaros/golib
src/Types/PropsFactory.php
PropsFactory.getKey
private function getKey ( $key = NULL ) { if ($key === NULL) { $key = $this->__keyName; return $this->getClassKey() . '_' . $this->$key; } return $this->getClassKey() . '_' . $key; }
php
private function getKey ( $key = NULL ) { if ($key === NULL) { $key = $this->__keyName; return $this->getClassKey() . '_' . $this->$key; } return $this->getClassKey() . '_' . $key; }
[ "private", "function", "getKey", "(", "$", "key", "=", "NULL", ")", "{", "if", "(", "$", "key", "===", "NULL", ")", "{", "$", "key", "=", "$", "this", "->", "__keyName", ";", "return", "$", "this", "->", "getClassKey", "(", ")", ".", "'_'", ".", "$", "this", "->", "$", "key", ";", "}", "return", "$", "this", "->", "getClassKey", "(", ")", ".", "'_'", ".", "$", "key", ";", "}" ]
returns the key for scope cache @param string $key @return string
[ "returns", "the", "key", "for", "scope", "cache" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Types/PropsFactory.php#L43-L49
train
swaros/golib
src/Types/PropsFactory.php
PropsFactory.applyData
public function applyData ( $data = NULL ) { parent::applyData( $data ); if ($data != null) { self::$propData[$this->getKey()] = $this; self::$keyCache[$this->getClassKey()] = $this->__keyName; $key = $this->__keyName; self::$__ids[$this->getClassKey()][$this->$key] = true; } }
php
public function applyData ( $data = NULL ) { parent::applyData( $data ); if ($data != null) { self::$propData[$this->getKey()] = $this; self::$keyCache[$this->getClassKey()] = $this->__keyName; $key = $this->__keyName; self::$__ids[$this->getClassKey()][$this->$key] = true; } }
[ "public", "function", "applyData", "(", "$", "data", "=", "NULL", ")", "{", "parent", "::", "applyData", "(", "$", "data", ")", ";", "if", "(", "$", "data", "!=", "null", ")", "{", "self", "::", "$", "propData", "[", "$", "this", "->", "getKey", "(", ")", "]", "=", "$", "this", ";", "self", "::", "$", "keyCache", "[", "$", "this", "->", "getClassKey", "(", ")", "]", "=", "$", "this", "->", "__keyName", ";", "$", "key", "=", "$", "this", "->", "__keyName", ";", "self", "::", "$", "__ids", "[", "$", "this", "->", "getClassKey", "(", ")", "]", "[", "$", "this", "->", "$", "key", "]", "=", "true", ";", "}", "}" ]
ovewrite parent becasue of catching all props @param array $data
[ "ovewrite", "parent", "becasue", "of", "catching", "all", "props" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Types/PropsFactory.php#L64-L72
train
swaros/golib
src/Types/PropsFactory.php
PropsFactory.getProps
public function getProps ( $id ) { if (isset( self::$propData[$this->getKey( $id )] )) { return self::$propData[$this->getKey( $id )]; } return NULL; }
php
public function getProps ( $id ) { if (isset( self::$propData[$this->getKey( $id )] )) { return self::$propData[$this->getKey( $id )]; } return NULL; }
[ "public", "function", "getProps", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "propData", "[", "$", "this", "->", "getKey", "(", "$", "id", ")", "]", ")", ")", "{", "return", "self", "::", "$", "propData", "[", "$", "this", "->", "getKey", "(", "$", "id", ")", "]", ";", "}", "return", "NULL", ";", "}" ]
returns the content by the id if these already builded. if not is returns NULL @param mixed $id @return self
[ "returns", "the", "content", "by", "the", "id", "if", "these", "already", "builded", ".", "if", "not", "is", "returns", "NULL" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Types/PropsFactory.php#L103-L108
train
swaros/golib
src/Types/PropsFactory.php
PropsFactory.fetch
public function fetch ( $id ) { if (isset( self::$propData[$this->getKey( $id )] )) { return self::$propData[$this->getKey( $id )]; } return false; }
php
public function fetch ( $id ) { if (isset( self::$propData[$this->getKey( $id )] )) { return self::$propData[$this->getKey( $id )]; } return false; }
[ "public", "function", "fetch", "(", "$", "id", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "propData", "[", "$", "this", "->", "getKey", "(", "$", "id", ")", "]", ")", ")", "{", "return", "self", "::", "$", "propData", "[", "$", "this", "->", "getKey", "(", "$", "id", ")", "]", ";", "}", "return", "false", ";", "}" ]
fetch data if exists so the current object is exchanges @param mixed $id @return self
[ "fetch", "data", "if", "exists", "so", "the", "current", "object", "is", "exchanges" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Types/PropsFactory.php#L117-L122
train
swaros/golib
src/Types/PropsFactory.php
PropsFactory.copyProps
private function copyProps ( self $source ) { foreach ($source as $keyName => $data) { if (substr( $keyName, 0, 2 ) !== '__') { $this->$keyName = $data; } } }
php
private function copyProps ( self $source ) { foreach ($source as $keyName => $data) { if (substr( $keyName, 0, 2 ) !== '__') { $this->$keyName = $data; } } }
[ "private", "function", "copyProps", "(", "self", "$", "source", ")", "{", "foreach", "(", "$", "source", "as", "$", "keyName", "=>", "$", "data", ")", "{", "if", "(", "substr", "(", "$", "keyName", ",", "0", ",", "2", ")", "!==", "'__'", ")", "{", "$", "this", "->", "$", "keyName", "=", "$", "data", ";", "}", "}", "}" ]
copy propertie to self @param self $source
[ "copy", "propertie", "to", "self" ]
9e75c8fb36de7c09b01a6c1c0d27c45f02fed567
https://github.com/swaros/golib/blob/9e75c8fb36de7c09b01a6c1c0d27c45f02fed567/src/Types/PropsFactory.php#L128-L134
train
rmatil/SAX
lib/Sax/Sax.php
Sax.preprocess
public function preprocess( $pSaxReferenceString, array $pSaxAnalysisStrings) { $this->referenceSuffixTree = new SuffixTree( $pSaxReferenceString ); foreach ( $pSaxAnalysisStrings as $anaString ) { $anaTree = new SuffixTree($anaString); $this->annotateSurpriseValues( $this->referenceSuffixTree, $anaTree ); $this->analysisSuffixTree[] = $anaTree; } return $this->analysisSuffixTree; }
php
public function preprocess( $pSaxReferenceString, array $pSaxAnalysisStrings) { $this->referenceSuffixTree = new SuffixTree( $pSaxReferenceString ); foreach ( $pSaxAnalysisStrings as $anaString ) { $anaTree = new SuffixTree($anaString); $this->annotateSurpriseValues( $this->referenceSuffixTree, $anaTree ); $this->analysisSuffixTree[] = $anaTree; } return $this->analysisSuffixTree; }
[ "public", "function", "preprocess", "(", "$", "pSaxReferenceString", ",", "array", "$", "pSaxAnalysisStrings", ")", "{", "$", "this", "->", "referenceSuffixTree", "=", "new", "SuffixTree", "(", "$", "pSaxReferenceString", ")", ";", "foreach", "(", "$", "pSaxAnalysisStrings", "as", "$", "anaString", ")", "{", "$", "anaTree", "=", "new", "SuffixTree", "(", "$", "anaString", ")", ";", "$", "this", "->", "annotateSurpriseValues", "(", "$", "this", "->", "referenceSuffixTree", ",", "$", "anaTree", ")", ";", "$", "this", "->", "analysisSuffixTree", "[", "]", "=", "$", "anaTree", ";", "}", "return", "$", "this", "->", "analysisSuffixTree", ";", "}" ]
Creates the suffix trees for the given reference string and the strings under analysis. Annotates the occurences of each substring in the corresponding node of the tree. @param string $pSaxReferenceString Discretized reference string (i.e. sax word) @param array $pSaxAnalysisStrings Array of discretized string representing the time series under analysis @return array Returns an array containing the analysis trees annotated with their surprise values
[ "Creates", "the", "suffix", "trees", "for", "the", "given", "reference", "string", "and", "the", "strings", "under", "analysis", ".", "Annotates", "the", "occurences", "of", "each", "substring", "in", "the", "corresponding", "node", "of", "the", "tree", "." ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/Sax.php#L157-L167
train
rmatil/SAX
lib/Sax/Sax.php
Sax.computeStatistics
public function computeStatistics( array $pTimeSeries ) { $statistics = array('min' => 0, 'max' => 0, 'stdDev' => 0, 'mean' => 0, 'sum' => 0, 'size' => count( $pTimeSeries ) ); foreach ( $pTimeSeries as $entry ) { if ( $entry['count'] < $statistics['min'] ) { $statistics['min'] = $entry['count']; } if ( $entry['count'] > $statistics['max'] ) { $statistics['max'] = $entry['count']; } $statistics['sum'] += $entry['count']; } $statistics['mean'] = $statistics['sum'] / $statistics['size']; // standard deviation foreach ($pTimeSeries as $entry) { $statistics['stdDev'] += pow( $entry['count'] - $statistics['mean'], 2 ); } if ( $statistics['size'] > 1 ) { $statistics['stdDev'] = sqrt( $statistics['stdDev'] / ( $statistics['size'] - 1 ) ); } else { // standard deviation of a single element is 0 $statistics['stdDev'] = 0; } return $statistics; }
php
public function computeStatistics( array $pTimeSeries ) { $statistics = array('min' => 0, 'max' => 0, 'stdDev' => 0, 'mean' => 0, 'sum' => 0, 'size' => count( $pTimeSeries ) ); foreach ( $pTimeSeries as $entry ) { if ( $entry['count'] < $statistics['min'] ) { $statistics['min'] = $entry['count']; } if ( $entry['count'] > $statistics['max'] ) { $statistics['max'] = $entry['count']; } $statistics['sum'] += $entry['count']; } $statistics['mean'] = $statistics['sum'] / $statistics['size']; // standard deviation foreach ($pTimeSeries as $entry) { $statistics['stdDev'] += pow( $entry['count'] - $statistics['mean'], 2 ); } if ( $statistics['size'] > 1 ) { $statistics['stdDev'] = sqrt( $statistics['stdDev'] / ( $statistics['size'] - 1 ) ); } else { // standard deviation of a single element is 0 $statistics['stdDev'] = 0; } return $statistics; }
[ "public", "function", "computeStatistics", "(", "array", "$", "pTimeSeries", ")", "{", "$", "statistics", "=", "array", "(", "'min'", "=>", "0", ",", "'max'", "=>", "0", ",", "'stdDev'", "=>", "0", ",", "'mean'", "=>", "0", ",", "'sum'", "=>", "0", ",", "'size'", "=>", "count", "(", "$", "pTimeSeries", ")", ")", ";", "foreach", "(", "$", "pTimeSeries", "as", "$", "entry", ")", "{", "if", "(", "$", "entry", "[", "'count'", "]", "<", "$", "statistics", "[", "'min'", "]", ")", "{", "$", "statistics", "[", "'min'", "]", "=", "$", "entry", "[", "'count'", "]", ";", "}", "if", "(", "$", "entry", "[", "'count'", "]", ">", "$", "statistics", "[", "'max'", "]", ")", "{", "$", "statistics", "[", "'max'", "]", "=", "$", "entry", "[", "'count'", "]", ";", "}", "$", "statistics", "[", "'sum'", "]", "+=", "$", "entry", "[", "'count'", "]", ";", "}", "$", "statistics", "[", "'mean'", "]", "=", "$", "statistics", "[", "'sum'", "]", "/", "$", "statistics", "[", "'size'", "]", ";", "// standard deviation", "foreach", "(", "$", "pTimeSeries", "as", "$", "entry", ")", "{", "$", "statistics", "[", "'stdDev'", "]", "+=", "pow", "(", "$", "entry", "[", "'count'", "]", "-", "$", "statistics", "[", "'mean'", "]", ",", "2", ")", ";", "}", "if", "(", "$", "statistics", "[", "'size'", "]", ">", "1", ")", "{", "$", "statistics", "[", "'stdDev'", "]", "=", "sqrt", "(", "$", "statistics", "[", "'stdDev'", "]", "/", "(", "$", "statistics", "[", "'size'", "]", "-", "1", ")", ")", ";", "}", "else", "{", "// standard deviation of a single element is 0", "$", "statistics", "[", "'stdDev'", "]", "=", "0", ";", "}", "return", "$", "statistics", ";", "}" ]
Calculates the minimum, maximum, standard deviation, mean, sum and the size of the given time series. It must contain the key 'count' for each entry. @param array $pTimeSeries Time series to calculate the described attributes @return array An array containing the attributes described above
[ "Calculates", "the", "minimum", "maximum", "standard", "deviation", "mean", "sum", "and", "the", "size", "of", "the", "given", "time", "series", ".", "It", "must", "contain", "the", "key", "count", "for", "each", "entry", "." ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/Sax.php#L253-L286
train
rmatil/SAX
lib/Sax/Sax.php
Sax.discretizeTimeSeries
public function discretizeTimeSeries( array $pTimeSeries, $pFeatureWindowLength = 1 ) { $nrOfBreakpoints = $this->alphabetSize - 1; $breakpoints = $this->breakpoints[$nrOfBreakpoints]; $saxWord = ""; // discretize reference time series for ( $i=0; $i < count( $pTimeSeries ); $i+=$pFeatureWindowLength ) { $datapoint = $pTimeSeries[$i]['count']; // dimensionality reduction using mean for ( $j=$i+1; $j < $pFeatureWindowLength; $j++ ) { $datapoint += $pTimeSeries[$j]['count']; } $datapoint /= $pFeatureWindowLength; // discretize to sax word using breakpoints for ( $z=0; $z < $nrOfBreakpoints + 1; $z++ ) { if ( isset( $breakpoints[$z] ) && $datapoint < $breakpoints[$z] ) { // found first matching interval $saxWord .= $this->alphabet[$z]; break; } elseif ( $z === $nrOfBreakpoints ) { // last datapoint, is greater than the last breakpoint $saxWord .= $this->alphabet[$z]; } } } return $saxWord; }
php
public function discretizeTimeSeries( array $pTimeSeries, $pFeatureWindowLength = 1 ) { $nrOfBreakpoints = $this->alphabetSize - 1; $breakpoints = $this->breakpoints[$nrOfBreakpoints]; $saxWord = ""; // discretize reference time series for ( $i=0; $i < count( $pTimeSeries ); $i+=$pFeatureWindowLength ) { $datapoint = $pTimeSeries[$i]['count']; // dimensionality reduction using mean for ( $j=$i+1; $j < $pFeatureWindowLength; $j++ ) { $datapoint += $pTimeSeries[$j]['count']; } $datapoint /= $pFeatureWindowLength; // discretize to sax word using breakpoints for ( $z=0; $z < $nrOfBreakpoints + 1; $z++ ) { if ( isset( $breakpoints[$z] ) && $datapoint < $breakpoints[$z] ) { // found first matching interval $saxWord .= $this->alphabet[$z]; break; } elseif ( $z === $nrOfBreakpoints ) { // last datapoint, is greater than the last breakpoint $saxWord .= $this->alphabet[$z]; } } } return $saxWord; }
[ "public", "function", "discretizeTimeSeries", "(", "array", "$", "pTimeSeries", ",", "$", "pFeatureWindowLength", "=", "1", ")", "{", "$", "nrOfBreakpoints", "=", "$", "this", "->", "alphabetSize", "-", "1", ";", "$", "breakpoints", "=", "$", "this", "->", "breakpoints", "[", "$", "nrOfBreakpoints", "]", ";", "$", "saxWord", "=", "\"\"", ";", "// discretize reference time series", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "pTimeSeries", ")", ";", "$", "i", "+=", "$", "pFeatureWindowLength", ")", "{", "$", "datapoint", "=", "$", "pTimeSeries", "[", "$", "i", "]", "[", "'count'", "]", ";", "// dimensionality reduction using mean", "for", "(", "$", "j", "=", "$", "i", "+", "1", ";", "$", "j", "<", "$", "pFeatureWindowLength", ";", "$", "j", "++", ")", "{", "$", "datapoint", "+=", "$", "pTimeSeries", "[", "$", "j", "]", "[", "'count'", "]", ";", "}", "$", "datapoint", "/=", "$", "pFeatureWindowLength", ";", "// discretize to sax word using breakpoints ", "for", "(", "$", "z", "=", "0", ";", "$", "z", "<", "$", "nrOfBreakpoints", "+", "1", ";", "$", "z", "++", ")", "{", "if", "(", "isset", "(", "$", "breakpoints", "[", "$", "z", "]", ")", "&&", "$", "datapoint", "<", "$", "breakpoints", "[", "$", "z", "]", ")", "{", "// found first matching interval ", "$", "saxWord", ".=", "$", "this", "->", "alphabet", "[", "$", "z", "]", ";", "break", ";", "}", "elseif", "(", "$", "z", "===", "$", "nrOfBreakpoints", ")", "{", "// last datapoint, is greater than the last breakpoint", "$", "saxWord", ".=", "$", "this", "->", "alphabet", "[", "$", "z", "]", ";", "}", "}", "}", "return", "$", "saxWord", ";", "}" ]
Discretizes a given time series to a "sax word", i.e. a sequence of characters indicating the amplitude of the time series. @param array $pTimeSeries Time series to discretize @param integer $pFeatureWindowLength Amount of datapoints which will used as a single datapoint (by computing the mean), default is one @return string The sax word
[ "Discretizes", "a", "given", "time", "series", "to", "a", "sax", "word", "i", ".", "e", ".", "a", "sequence", "of", "characters", "indicating", "the", "amplitude", "of", "the", "time", "series", "." ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/Sax.php#L340-L370
train
rmatil/SAX
lib/Sax/Sax.php
Sax.annotateSurpriseValues
public function annotateSurpriseValues( &$pReferenceTree , &$pAnalysisTree) { $this->annotateNode( $pReferenceTree, $pAnalysisTree, $pAnalysisTree->nodes[$pAnalysisTree->root], "" ); }
php
public function annotateSurpriseValues( &$pReferenceTree , &$pAnalysisTree) { $this->annotateNode( $pReferenceTree, $pAnalysisTree, $pAnalysisTree->nodes[$pAnalysisTree->root], "" ); }
[ "public", "function", "annotateSurpriseValues", "(", "&", "$", "pReferenceTree", ",", "&", "$", "pAnalysisTree", ")", "{", "$", "this", "->", "annotateNode", "(", "$", "pReferenceTree", ",", "$", "pAnalysisTree", ",", "$", "pAnalysisTree", "->", "nodes", "[", "$", "pAnalysisTree", "->", "root", "]", ",", "\"\"", ")", ";", "}" ]
Annotates surprise values at each node of the analysis tree in context of the reference tree @param SuffixTree $pReferenceTree Suffix tree of the reference time series @param SuffixTree $pAnalysisTree Suffix tree of the time series under analysis
[ "Annotates", "surprise", "values", "at", "each", "node", "of", "the", "analysis", "tree", "in", "context", "of", "the", "reference", "tree" ]
f42cb97300c9f8e87c66644ccc236309db2396e2
https://github.com/rmatil/SAX/blob/f42cb97300c9f8e87c66644ccc236309db2396e2/lib/Sax/Sax.php#L379-L381
train
bartonlp/site-class
includes/database-engines/ErrorClass.class.php
ErrorClass.init
public static function init($args=null) { if(is_null(self::$instance)) { self::$instance = new ErrorClass($args); } return self::$instance; }
php
public static function init($args=null) { if(is_null(self::$instance)) { self::$instance = new ErrorClass($args); } return self::$instance; }
[ "public", "static", "function", "init", "(", "$", "args", "=", "null", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "instance", ")", ")", "{", "self", "::", "$", "instance", "=", "new", "ErrorClass", "(", "$", "args", ")", ";", "}", "return", "self", "::", "$", "instance", ";", "}" ]
args can be array|object. noEmailErrs, development, noHtml, noOutput, errType
[ "args", "can", "be", "array|object", ".", "noEmailErrs", "development", "noHtml", "noOutput", "errType" ]
9095b101701ef0ae12ea9a2b4587a18072d04438
https://github.com/bartonlp/site-class/blob/9095b101701ef0ae12ea9a2b4587a18072d04438/includes/database-engines/ErrorClass.class.php#L239-L244
train
taktwerk/tw-yii2-rest
CreateQueryHelper.php
CreateQueryHelper.createQuery
public static function createQuery($modelClass, $ignore=[]) { $model = $modelClass::find(); $wheres = ['and']; $filter_fields = self::getQueryParams($ignore); $condition_transform_functions = self::conditionTransformFunctions(); foreach($filter_fields as $key => $value){ if($value == '' || in_array($key,self::$exclude_field)) continue; $field_key = $key; if(!strpos($key,'.')){ $field_key = $modelClass::tableName().'.'.$key ; }else{ $relation_model = substr($field_key,0,strrpos($key,'.')); $model->joinWith($relation_model); if(strpos($relation_model,'.')){ $temp = substr($field_key,strrpos($field_key,'.')); $field_key = substr($relation_model,strrpos($relation_model,'.')+1).$temp; $field_key = str_replace($relation_model, $relation_model::tableName(), $field_key); } else { // Build the relation's tale name $baseModel = new $modelClass; $relationModel = $baseModel->getRelation($relation_model); $relationModel = new $relationModel->modelClass; $field_key = str_replace($relation_model . '.', $relationModel->tableName() . '.', $field_key); } } $type = 'EQUAL'; if(preg_match("/^[A-Z]+_/",$value, $matches) && array_key_exists(trim($matches[0],'_'),$condition_transform_functions)){ $type = trim($matches[0],'_'); $value = str_replace($matches[0],'',$value); } $wheres = ArrayHelper::merge($wheres, [$condition_transform_functions[$type]($field_key,$value)]); } if(count($wheres) > 1) { $model->andWhere($wheres); } return $model; }
php
public static function createQuery($modelClass, $ignore=[]) { $model = $modelClass::find(); $wheres = ['and']; $filter_fields = self::getQueryParams($ignore); $condition_transform_functions = self::conditionTransformFunctions(); foreach($filter_fields as $key => $value){ if($value == '' || in_array($key,self::$exclude_field)) continue; $field_key = $key; if(!strpos($key,'.')){ $field_key = $modelClass::tableName().'.'.$key ; }else{ $relation_model = substr($field_key,0,strrpos($key,'.')); $model->joinWith($relation_model); if(strpos($relation_model,'.')){ $temp = substr($field_key,strrpos($field_key,'.')); $field_key = substr($relation_model,strrpos($relation_model,'.')+1).$temp; $field_key = str_replace($relation_model, $relation_model::tableName(), $field_key); } else { // Build the relation's tale name $baseModel = new $modelClass; $relationModel = $baseModel->getRelation($relation_model); $relationModel = new $relationModel->modelClass; $field_key = str_replace($relation_model . '.', $relationModel->tableName() . '.', $field_key); } } $type = 'EQUAL'; if(preg_match("/^[A-Z]+_/",$value, $matches) && array_key_exists(trim($matches[0],'_'),$condition_transform_functions)){ $type = trim($matches[0],'_'); $value = str_replace($matches[0],'',$value); } $wheres = ArrayHelper::merge($wheres, [$condition_transform_functions[$type]($field_key,$value)]); } if(count($wheres) > 1) { $model->andWhere($wheres); } return $model; }
[ "public", "static", "function", "createQuery", "(", "$", "modelClass", ",", "$", "ignore", "=", "[", "]", ")", "{", "$", "model", "=", "$", "modelClass", "::", "find", "(", ")", ";", "$", "wheres", "=", "[", "'and'", "]", ";", "$", "filter_fields", "=", "self", "::", "getQueryParams", "(", "$", "ignore", ")", ";", "$", "condition_transform_functions", "=", "self", "::", "conditionTransformFunctions", "(", ")", ";", "foreach", "(", "$", "filter_fields", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "value", "==", "''", "||", "in_array", "(", "$", "key", ",", "self", "::", "$", "exclude_field", ")", ")", "continue", ";", "$", "field_key", "=", "$", "key", ";", "if", "(", "!", "strpos", "(", "$", "key", ",", "'.'", ")", ")", "{", "$", "field_key", "=", "$", "modelClass", "::", "tableName", "(", ")", ".", "'.'", ".", "$", "key", ";", "}", "else", "{", "$", "relation_model", "=", "substr", "(", "$", "field_key", ",", "0", ",", "strrpos", "(", "$", "key", ",", "'.'", ")", ")", ";", "$", "model", "->", "joinWith", "(", "$", "relation_model", ")", ";", "if", "(", "strpos", "(", "$", "relation_model", ",", "'.'", ")", ")", "{", "$", "temp", "=", "substr", "(", "$", "field_key", ",", "strrpos", "(", "$", "field_key", ",", "'.'", ")", ")", ";", "$", "field_key", "=", "substr", "(", "$", "relation_model", ",", "strrpos", "(", "$", "relation_model", ",", "'.'", ")", "+", "1", ")", ".", "$", "temp", ";", "$", "field_key", "=", "str_replace", "(", "$", "relation_model", ",", "$", "relation_model", "::", "tableName", "(", ")", ",", "$", "field_key", ")", ";", "}", "else", "{", "// Build the relation's tale name", "$", "baseModel", "=", "new", "$", "modelClass", ";", "$", "relationModel", "=", "$", "baseModel", "->", "getRelation", "(", "$", "relation_model", ")", ";", "$", "relationModel", "=", "new", "$", "relationModel", "->", "modelClass", ";", "$", "field_key", "=", "str_replace", "(", "$", "relation_model", ".", "'.'", ",", "$", "relationModel", "->", "tableName", "(", ")", ".", "'.'", ",", "$", "field_key", ")", ";", "}", "}", "$", "type", "=", "'EQUAL'", ";", "if", "(", "preg_match", "(", "\"/^[A-Z]+_/\"", ",", "$", "value", ",", "$", "matches", ")", "&&", "array_key_exists", "(", "trim", "(", "$", "matches", "[", "0", "]", ",", "'_'", ")", ",", "$", "condition_transform_functions", ")", ")", "{", "$", "type", "=", "trim", "(", "$", "matches", "[", "0", "]", ",", "'_'", ")", ";", "$", "value", "=", "str_replace", "(", "$", "matches", "[", "0", "]", ",", "''", ",", "$", "value", ")", ";", "}", "$", "wheres", "=", "ArrayHelper", "::", "merge", "(", "$", "wheres", ",", "[", "$", "condition_transform_functions", "[", "$", "type", "]", "(", "$", "field_key", ",", "$", "value", ")", "]", ")", ";", "}", "if", "(", "count", "(", "$", "wheres", ")", ">", "1", ")", "{", "$", "model", "->", "andWhere", "(", "$", "wheres", ")", ";", "}", "return", "$", "model", ";", "}" ]
Create the query to check for relations and filtering @param $modelClass @param array $ignore @return mixed
[ "Create", "the", "query", "to", "check", "for", "relations", "and", "filtering" ]
dd2102f134c3f4851c464473b95d430f310a895b
https://github.com/taktwerk/tw-yii2-rest/blob/dd2102f134c3f4851c464473b95d430f310a895b/CreateQueryHelper.php#L31-L74
train
taktwerk/tw-yii2-rest
CreateQueryHelper.php
CreateQueryHelper.addOrderSort
public static function addOrderSort($sort, $table, &$query) { if (!empty($sort)) { $sorts = explode(',', $sort); foreach ($sorts as $sort) { if (!strpos($sort, '.')) { preg_match('/\w+\s+(DESC|ASC)/', $sort, $sort_field); $type = !empty($sort_field) ? trim($sort_field[1]) : 'DESC'; $field = !empty($sort_field) ? trim(substr($sort, 0, -strlen($type))) : trim($sort); $order[$table . '.' . $field] = $type == 'DESC' ? SORT_DESC : SORT_ASC; } else { $sort_table = trim(substr($sort, 0, strrpos($sort, '.'))); preg_match('/\w+\.\w+\s+(DESC|ASC)/', $sort, $sort_field); $type = trim($sort_field[1]); $field = trim(substr(substr($sort, strrpos($sort, '.') + 1), 0, -strlen($type))); $order[trim($sort_table) . '.' . $field] = $type == 'DESC' ? SORT_DESC : SORT_ASC;; $query->select[] = explode(' ', $sort_field[0])[0]; $query->joinWith($sort_table); } } $query->select[] = $table . ".*"; } $query->orderBy($order); }
php
public static function addOrderSort($sort, $table, &$query) { if (!empty($sort)) { $sorts = explode(',', $sort); foreach ($sorts as $sort) { if (!strpos($sort, '.')) { preg_match('/\w+\s+(DESC|ASC)/', $sort, $sort_field); $type = !empty($sort_field) ? trim($sort_field[1]) : 'DESC'; $field = !empty($sort_field) ? trim(substr($sort, 0, -strlen($type))) : trim($sort); $order[$table . '.' . $field] = $type == 'DESC' ? SORT_DESC : SORT_ASC; } else { $sort_table = trim(substr($sort, 0, strrpos($sort, '.'))); preg_match('/\w+\.\w+\s+(DESC|ASC)/', $sort, $sort_field); $type = trim($sort_field[1]); $field = trim(substr(substr($sort, strrpos($sort, '.') + 1), 0, -strlen($type))); $order[trim($sort_table) . '.' . $field] = $type == 'DESC' ? SORT_DESC : SORT_ASC;; $query->select[] = explode(' ', $sort_field[0])[0]; $query->joinWith($sort_table); } } $query->select[] = $table . ".*"; } $query->orderBy($order); }
[ "public", "static", "function", "addOrderSort", "(", "$", "sort", ",", "$", "table", ",", "&", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "sort", ")", ")", "{", "$", "sorts", "=", "explode", "(", "','", ",", "$", "sort", ")", ";", "foreach", "(", "$", "sorts", "as", "$", "sort", ")", "{", "if", "(", "!", "strpos", "(", "$", "sort", ",", "'.'", ")", ")", "{", "preg_match", "(", "'/\\w+\\s+(DESC|ASC)/'", ",", "$", "sort", ",", "$", "sort_field", ")", ";", "$", "type", "=", "!", "empty", "(", "$", "sort_field", ")", "?", "trim", "(", "$", "sort_field", "[", "1", "]", ")", ":", "'DESC'", ";", "$", "field", "=", "!", "empty", "(", "$", "sort_field", ")", "?", "trim", "(", "substr", "(", "$", "sort", ",", "0", ",", "-", "strlen", "(", "$", "type", ")", ")", ")", ":", "trim", "(", "$", "sort", ")", ";", "$", "order", "[", "$", "table", ".", "'.'", ".", "$", "field", "]", "=", "$", "type", "==", "'DESC'", "?", "SORT_DESC", ":", "SORT_ASC", ";", "}", "else", "{", "$", "sort_table", "=", "trim", "(", "substr", "(", "$", "sort", ",", "0", ",", "strrpos", "(", "$", "sort", ",", "'.'", ")", ")", ")", ";", "preg_match", "(", "'/\\w+\\.\\w+\\s+(DESC|ASC)/'", ",", "$", "sort", ",", "$", "sort_field", ")", ";", "$", "type", "=", "trim", "(", "$", "sort_field", "[", "1", "]", ")", ";", "$", "field", "=", "trim", "(", "substr", "(", "substr", "(", "$", "sort", ",", "strrpos", "(", "$", "sort", ",", "'.'", ")", "+", "1", ")", ",", "0", ",", "-", "strlen", "(", "$", "type", ")", ")", ")", ";", "$", "order", "[", "trim", "(", "$", "sort_table", ")", ".", "'.'", ".", "$", "field", "]", "=", "$", "type", "==", "'DESC'", "?", "SORT_DESC", ":", "SORT_ASC", ";", ";", "$", "query", "->", "select", "[", "]", "=", "explode", "(", "' '", ",", "$", "sort_field", "[", "0", "]", ")", "[", "0", "]", ";", "$", "query", "->", "joinWith", "(", "$", "sort_table", ")", ";", "}", "}", "$", "query", "->", "select", "[", "]", "=", "$", "table", ".", "\".*\"", ";", "}", "$", "query", "->", "orderBy", "(", "$", "order", ")", ";", "}" ]
Add a sort if there is a sort oder requested. @param $sort @param $table @param $query
[ "Add", "a", "sort", "if", "there", "is", "a", "sort", "oder", "requested", "." ]
dd2102f134c3f4851c464473b95d430f310a895b
https://github.com/taktwerk/tw-yii2-rest/blob/dd2102f134c3f4851c464473b95d430f310a895b/CreateQueryHelper.php#L83-L106
train
taktwerk/tw-yii2-rest
CreateQueryHelper.php
CreateQueryHelper.addGroup
public static function addGroup($group, $table, &$query) { if(!empty($group)) { $groups = explode(',', $group); foreach($groups as $group) { if (!strpos($group, '.')) { $query->groupBy($table . '.' . $group); } else { $query->groupBy($group); } } } }
php
public static function addGroup($group, $table, &$query) { if(!empty($group)) { $groups = explode(',', $group); foreach($groups as $group) { if (!strpos($group, '.')) { $query->groupBy($table . '.' . $group); } else { $query->groupBy($group); } } } }
[ "public", "static", "function", "addGroup", "(", "$", "group", ",", "$", "table", ",", "&", "$", "query", ")", "{", "if", "(", "!", "empty", "(", "$", "group", ")", ")", "{", "$", "groups", "=", "explode", "(", "','", ",", "$", "group", ")", ";", "foreach", "(", "$", "groups", "as", "$", "group", ")", "{", "if", "(", "!", "strpos", "(", "$", "group", ",", "'.'", ")", ")", "{", "$", "query", "->", "groupBy", "(", "$", "table", ".", "'.'", ".", "$", "group", ")", ";", "}", "else", "{", "$", "query", "->", "groupBy", "(", "$", "group", ")", ";", "}", "}", "}", "}" ]
Add a group by functionality to the query builder
[ "Add", "a", "group", "by", "functionality", "to", "the", "query", "builder" ]
dd2102f134c3f4851c464473b95d430f310a895b
https://github.com/taktwerk/tw-yii2-rest/blob/dd2102f134c3f4851c464473b95d430f310a895b/CreateQueryHelper.php#L208-L220
train
kambalabs/KmbPmProxy
src/KmbPmProxy/Service/Environment.php
Environment.save
public function save(Model\EnvironmentInterface $environment, Model\EnvironmentInterface $cloneFrom = null) { $content = $this->getEnvironmentHydrator()->extract($environment); if ($cloneFrom != null) { $content['cloneFrom'] = strval($cloneFrom->getNormalizedName()); } $this->pmProxyClient->put('/environments/' . $environment->getNormalizedName(), $content); if ($environment->hasChildren()) { foreach ($environment->getChildren() as $child) { /** @var Model\EnvironmentInterface $child */ if ($cloneFrom) { $this->save($child, $cloneFrom->getChildByName($child->getName())); } else { $this->save($child); } } } return $this; }
php
public function save(Model\EnvironmentInterface $environment, Model\EnvironmentInterface $cloneFrom = null) { $content = $this->getEnvironmentHydrator()->extract($environment); if ($cloneFrom != null) { $content['cloneFrom'] = strval($cloneFrom->getNormalizedName()); } $this->pmProxyClient->put('/environments/' . $environment->getNormalizedName(), $content); if ($environment->hasChildren()) { foreach ($environment->getChildren() as $child) { /** @var Model\EnvironmentInterface $child */ if ($cloneFrom) { $this->save($child, $cloneFrom->getChildByName($child->getName())); } else { $this->save($child); } } } return $this; }
[ "public", "function", "save", "(", "Model", "\\", "EnvironmentInterface", "$", "environment", ",", "Model", "\\", "EnvironmentInterface", "$", "cloneFrom", "=", "null", ")", "{", "$", "content", "=", "$", "this", "->", "getEnvironmentHydrator", "(", ")", "->", "extract", "(", "$", "environment", ")", ";", "if", "(", "$", "cloneFrom", "!=", "null", ")", "{", "$", "content", "[", "'cloneFrom'", "]", "=", "strval", "(", "$", "cloneFrom", "->", "getNormalizedName", "(", ")", ")", ";", "}", "$", "this", "->", "pmProxyClient", "->", "put", "(", "'/environments/'", ".", "$", "environment", "->", "getNormalizedName", "(", ")", ",", "$", "content", ")", ";", "if", "(", "$", "environment", "->", "hasChildren", "(", ")", ")", "{", "foreach", "(", "$", "environment", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "/** @var Model\\EnvironmentInterface $child */", "if", "(", "$", "cloneFrom", ")", "{", "$", "this", "->", "save", "(", "$", "child", ",", "$", "cloneFrom", "->", "getChildByName", "(", "$", "child", "->", "getName", "(", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "save", "(", "$", "child", ")", ";", "}", "}", "}", "return", "$", "this", ";", "}" ]
Create or update an environment on the Puppet Master @param Model\EnvironmentInterface $environment @param Model\EnvironmentInterface $cloneFrom @return Environment @throws RuntimeException
[ "Create", "or", "update", "an", "environment", "on", "the", "Puppet", "Master" ]
b4c664ae8b6f29e4e8768461ed99e1b0b80bde18
https://github.com/kambalabs/KmbPmProxy/blob/b4c664ae8b6f29e4e8768461ed99e1b0b80bde18/src/KmbPmProxy/Service/Environment.php#L44-L62
train
kambalabs/KmbPmProxy
src/KmbPmProxy/Service/Environment.php
Environment.remove
public function remove(Model\EnvironmentInterface $environment) { $this->pmProxyClient->delete('/environments/' . $environment->getNormalizedName()); if ($environment->hasChildren()) { foreach ($environment->getChildren() as $child) { /** @var Model\EnvironmentInterface $child */ $this->remove($child); } } return $this; }
php
public function remove(Model\EnvironmentInterface $environment) { $this->pmProxyClient->delete('/environments/' . $environment->getNormalizedName()); if ($environment->hasChildren()) { foreach ($environment->getChildren() as $child) { /** @var Model\EnvironmentInterface $child */ $this->remove($child); } } return $this; }
[ "public", "function", "remove", "(", "Model", "\\", "EnvironmentInterface", "$", "environment", ")", "{", "$", "this", "->", "pmProxyClient", "->", "delete", "(", "'/environments/'", ".", "$", "environment", "->", "getNormalizedName", "(", ")", ")", ";", "if", "(", "$", "environment", "->", "hasChildren", "(", ")", ")", "{", "foreach", "(", "$", "environment", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "/** @var Model\\EnvironmentInterface $child */", "$", "this", "->", "remove", "(", "$", "child", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Remove an environment on the Puppet Master @param Model\EnvironmentInterface $environment @return Environment
[ "Remove", "an", "environment", "on", "the", "Puppet", "Master" ]
b4c664ae8b6f29e4e8768461ed99e1b0b80bde18
https://github.com/kambalabs/KmbPmProxy/blob/b4c664ae8b6f29e4e8768461ed99e1b0b80bde18/src/KmbPmProxy/Service/Environment.php#L70-L80
train
SysControllers/Admin
src/app/Repositories/Admin/BaseRepo.php
BaseRepo.findIdUrl
public function findIdUrl($id, $url) { return $this->getModel()->where('id', $id)->where('slug_url', $url)->first(); }
php
public function findIdUrl($id, $url) { return $this->getModel()->where('id', $id)->where('slug_url', $url)->first(); }
[ "public", "function", "findIdUrl", "(", "$", "id", ",", "$", "url", ")", "{", "return", "$", "this", "->", "getModel", "(", ")", "->", "where", "(", "'id'", ",", "$", "id", ")", "->", "where", "(", "'slug_url'", ",", "$", "url", ")", "->", "first", "(", ")", ";", "}" ]
BUSCAR POR ID Y URL
[ "BUSCAR", "POR", "ID", "Y", "URL" ]
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/src/app/Repositories/Admin/BaseRepo.php#L10-L13
train
SysControllers/Admin
src/app/Repositories/Admin/BaseRepo.php
BaseRepo.orderByPagination
public function orderByPagination($field, $order, $value) { return $this->getModel()->orderBy($field, $order)->paginate($value); }
php
public function orderByPagination($field, $order, $value) { return $this->getModel()->orderBy($field, $order)->paginate($value); }
[ "public", "function", "orderByPagination", "(", "$", "field", ",", "$", "order", ",", "$", "value", ")", "{", "return", "$", "this", "->", "getModel", "(", ")", "->", "orderBy", "(", "$", "field", ",", "$", "order", ")", "->", "paginate", "(", "$", "value", ")", ";", "}" ]
ORDERNAR Y PAGINAR
[ "ORDERNAR", "Y", "PAGINAR" ]
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/src/app/Repositories/Admin/BaseRepo.php#L51-L54
train
SysControllers/Admin
src/app/Repositories/Admin/BaseRepo.php
BaseRepo.findAndPaginateDeletes
public function findAndPaginateDeletes(Request $request) { return $this->getModel() ->onlyTrashed() ->titulo($request->get('titulo')) ->orderBy('deleted_at', 'desc') ->paginate(); }
php
public function findAndPaginateDeletes(Request $request) { return $this->getModel() ->onlyTrashed() ->titulo($request->get('titulo')) ->orderBy('deleted_at', 'desc') ->paginate(); }
[ "public", "function", "findAndPaginateDeletes", "(", "Request", "$", "request", ")", "{", "return", "$", "this", "->", "getModel", "(", ")", "->", "onlyTrashed", "(", ")", "->", "titulo", "(", "$", "request", "->", "get", "(", "'titulo'", ")", ")", "->", "orderBy", "(", "'deleted_at'", ",", "'desc'", ")", "->", "paginate", "(", ")", ";", "}" ]
BUSQUEDAS DE REGISTROS ELIMINADOS
[ "BUSQUEDAS", "DE", "REGISTROS", "ELIMINADOS" ]
8f1df46aca422b87f2f522fbba610dcfa0c5f7f3
https://github.com/SysControllers/Admin/blob/8f1df46aca422b87f2f522fbba610dcfa0c5f7f3/src/app/Repositories/Admin/BaseRepo.php#L96-L103
train
the-eater/odango.php
src/AniDbTitles.php
AniDbTitles.construct
static function construct() { $aniDbTitles = new AniDbTitles(); $aniDbTitles->db = Registry::getDatabase(); $aniDbTitles->model = $aniDbTitles->db->factory('@' . $aniDbTitles->table); return $aniDbTitles; }
php
static function construct() { $aniDbTitles = new AniDbTitles(); $aniDbTitles->db = Registry::getDatabase(); $aniDbTitles->model = $aniDbTitles->db->factory('@' . $aniDbTitles->table); return $aniDbTitles; }
[ "static", "function", "construct", "(", ")", "{", "$", "aniDbTitles", "=", "new", "AniDbTitles", "(", ")", ";", "$", "aniDbTitles", "->", "db", "=", "Registry", "::", "getDatabase", "(", ")", ";", "$", "aniDbTitles", "->", "model", "=", "$", "aniDbTitles", "->", "db", "->", "factory", "(", "'@'", ".", "$", "aniDbTitles", "->", "table", ")", ";", "return", "$", "aniDbTitles", ";", "}" ]
Creates a new AniDbTitles instance @param array $dbInfo Array consisting of dsn, username and password, used to connect to the database where the anidbtitles are stored @param string $table The table to store and access the cached anidb titles @return AniDbTitles The created AniDbTitles instance
[ "Creates", "a", "new", "AniDbTitles", "instance" ]
6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/AniDbTitles.php#L23-L31
train
the-eater/odango.php
src/AniDbTitles.php
AniDbTitles.syncDatabase
public function syncDatabase() { $tmpname = '/tmp/odango.php.cache'; if (!file_exists($tmpname)) { $curl = new Curl(); $curl->setOpt(CURLOPT_ENCODING, "gzip"); $curl->download($this->titleDumpUrl, $tmpname); $curl->close(); } $this->db->exec('START TRANSACTION'); $this->db->exec('DELETE FROM ' . $this->table); $xml = simplexml_load_file($tmpname); foreach ($xml as $child) { $aid = (int)$child['aid']; $added = []; foreach($child->title as $title) { $type = (string)$title['type']; $lang = (string)$title->attributes('xml', true)['lang']; if ($lang == 'x-jat' || $lang == 'en') { if (!in_array((string)$title, $added)) { $added[] = (string)$title; $this->model->insert([ 'aniDbId' => $aid, 'title' => (string)$title, 'isDefault' => $type == 'main' ? 1 :0 ]); } else if ( $type == 'main' ) { $this->model->update(['isDefault' => 1], 'AniDbId = '.$aid.' AND title = '.$this->db->quote((string)$title)); } } } } $this->db->exec('COMMIT'); }
php
public function syncDatabase() { $tmpname = '/tmp/odango.php.cache'; if (!file_exists($tmpname)) { $curl = new Curl(); $curl->setOpt(CURLOPT_ENCODING, "gzip"); $curl->download($this->titleDumpUrl, $tmpname); $curl->close(); } $this->db->exec('START TRANSACTION'); $this->db->exec('DELETE FROM ' . $this->table); $xml = simplexml_load_file($tmpname); foreach ($xml as $child) { $aid = (int)$child['aid']; $added = []; foreach($child->title as $title) { $type = (string)$title['type']; $lang = (string)$title->attributes('xml', true)['lang']; if ($lang == 'x-jat' || $lang == 'en') { if (!in_array((string)$title, $added)) { $added[] = (string)$title; $this->model->insert([ 'aniDbId' => $aid, 'title' => (string)$title, 'isDefault' => $type == 'main' ? 1 :0 ]); } else if ( $type == 'main' ) { $this->model->update(['isDefault' => 1], 'AniDbId = '.$aid.' AND title = '.$this->db->quote((string)$title)); } } } } $this->db->exec('COMMIT'); }
[ "public", "function", "syncDatabase", "(", ")", "{", "$", "tmpname", "=", "'/tmp/odango.php.cache'", ";", "if", "(", "!", "file_exists", "(", "$", "tmpname", ")", ")", "{", "$", "curl", "=", "new", "Curl", "(", ")", ";", "$", "curl", "->", "setOpt", "(", "CURLOPT_ENCODING", ",", "\"gzip\"", ")", ";", "$", "curl", "->", "download", "(", "$", "this", "->", "titleDumpUrl", ",", "$", "tmpname", ")", ";", "$", "curl", "->", "close", "(", ")", ";", "}", "$", "this", "->", "db", "->", "exec", "(", "'START TRANSACTION'", ")", ";", "$", "this", "->", "db", "->", "exec", "(", "'DELETE FROM '", ".", "$", "this", "->", "table", ")", ";", "$", "xml", "=", "simplexml_load_file", "(", "$", "tmpname", ")", ";", "foreach", "(", "$", "xml", "as", "$", "child", ")", "{", "$", "aid", "=", "(", "int", ")", "$", "child", "[", "'aid'", "]", ";", "$", "added", "=", "[", "]", ";", "foreach", "(", "$", "child", "->", "title", "as", "$", "title", ")", "{", "$", "type", "=", "(", "string", ")", "$", "title", "[", "'type'", "]", ";", "$", "lang", "=", "(", "string", ")", "$", "title", "->", "attributes", "(", "'xml'", ",", "true", ")", "[", "'lang'", "]", ";", "if", "(", "$", "lang", "==", "'x-jat'", "||", "$", "lang", "==", "'en'", ")", "{", "if", "(", "!", "in_array", "(", "(", "string", ")", "$", "title", ",", "$", "added", ")", ")", "{", "$", "added", "[", "]", "=", "(", "string", ")", "$", "title", ";", "$", "this", "->", "model", "->", "insert", "(", "[", "'aniDbId'", "=>", "$", "aid", ",", "'title'", "=>", "(", "string", ")", "$", "title", ",", "'isDefault'", "=>", "$", "type", "==", "'main'", "?", "1", ":", "0", "]", ")", ";", "}", "else", "if", "(", "$", "type", "==", "'main'", ")", "{", "$", "this", "->", "model", "->", "update", "(", "[", "'isDefault'", "=>", "1", "]", ",", "'AniDbId = '", ".", "$", "aid", ".", "' AND title = '", ".", "$", "this", "->", "db", "->", "quote", "(", "(", "string", ")", "$", "title", ")", ")", ";", "}", "}", "}", "}", "$", "this", "->", "db", "->", "exec", "(", "'COMMIT'", ")", ";", "}" ]
Syncs the database with the up-to-date anidb title dump
[ "Syncs", "the", "database", "with", "the", "up", "-", "to", "-", "date", "anidb", "title", "dump" ]
6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/AniDbTitles.php#L36-L76
train
the-eater/odango.php
src/AniDbTitles.php
AniDbTitles.getAlternativeTitles
public function getAlternativeTitles($title) { $builder = $this->db->builder(); return $builder ->select('search.title') ->from([$this->table . ' as main']) ->join($this->table . ' as search', 'main."aniDbId" = search."aniDbId"') ->where('main.title = :title') ->queryColumn([ 'title' => $title ]); }
php
public function getAlternativeTitles($title) { $builder = $this->db->builder(); return $builder ->select('search.title') ->from([$this->table . ' as main']) ->join($this->table . ' as search', 'main."aniDbId" = search."aniDbId"') ->where('main.title = :title') ->queryColumn([ 'title' => $title ]); }
[ "public", "function", "getAlternativeTitles", "(", "$", "title", ")", "{", "$", "builder", "=", "$", "this", "->", "db", "->", "builder", "(", ")", ";", "return", "$", "builder", "->", "select", "(", "'search.title'", ")", "->", "from", "(", "[", "$", "this", "->", "table", ".", "' as main'", "]", ")", "->", "join", "(", "$", "this", "->", "table", ".", "' as search'", ",", "'main.\"aniDbId\" = search.\"aniDbId\"'", ")", "->", "where", "(", "'main.title = :title'", ")", "->", "queryColumn", "(", "[", "'title'", "=>", "$", "title", "]", ")", ";", "}" ]
Gets all alternative titles for the title given @param string $title The title to get alternative titles for @return array Array consisting of alternative titles for given title
[ "Gets", "all", "alternative", "titles", "for", "the", "title", "given" ]
6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f
https://github.com/the-eater/odango.php/blob/6c78f983e7b3c49ff2f8a10ce7299747d3c82e3f/src/AniDbTitles.php#L83-L94
train
eureka-framework/component-http
src/Http/Http.php
Http.add
public function add($name, $value = null) { if (empty($name)) { return $this; } $params = (!is_array($name) ? array($name => $value) : $name); $query = $this->query(true); foreach ($params as $key => $val) { if (empty($val)) { unset($query[$key]); } elseif (!empty($val)) { $query[$key] = $val; } } $query = http_build_query($query); $this->url['query'] = $query; return $this; }
php
public function add($name, $value = null) { if (empty($name)) { return $this; } $params = (!is_array($name) ? array($name => $value) : $name); $query = $this->query(true); foreach ($params as $key => $val) { if (empty($val)) { unset($query[$key]); } elseif (!empty($val)) { $query[$key] = $val; } } $query = http_build_query($query); $this->url['query'] = $query; return $this; }
[ "public", "function", "add", "(", "$", "name", ",", "$", "value", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "params", "=", "(", "!", "is_array", "(", "$", "name", ")", "?", "array", "(", "$", "name", "=>", "$", "value", ")", ":", "$", "name", ")", ";", "$", "query", "=", "$", "this", "->", "query", "(", "true", ")", ";", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "empty", "(", "$", "val", ")", ")", "{", "unset", "(", "$", "query", "[", "$", "key", "]", ")", ";", "}", "elseif", "(", "!", "empty", "(", "$", "val", ")", ")", "{", "$", "query", "[", "$", "key", "]", "=", "$", "val", ";", "}", "}", "$", "query", "=", "http_build_query", "(", "$", "query", ")", ";", "$", "this", "->", "url", "[", "'query'", "]", "=", "$", "query", ";", "return", "$", "this", ";", "}" ]
Add, replace or remove parameters from query url. @param mixed $name Array of parameter, or parameter name. @param mixed $value Null if first parameter is array, else parameter value. @return self
[ "Add", "replace", "or", "remove", "parameters", "from", "query", "url", "." ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Http.php#L41-L63
train
eureka-framework/component-http
src/Http/Http.php
Http.init
public function init($url = null) { $url = (empty($url) ? Server::getInstance()->getCurrentUri() : $url); $this->url = parse_url($url); return $this; }
php
public function init($url = null) { $url = (empty($url) ? Server::getInstance()->getCurrentUri() : $url); $this->url = parse_url($url); return $this; }
[ "public", "function", "init", "(", "$", "url", "=", "null", ")", "{", "$", "url", "=", "(", "empty", "(", "$", "url", ")", "?", "Server", "::", "getInstance", "(", ")", "->", "getCurrentUri", "(", ")", ":", "$", "url", ")", ";", "$", "this", "->", "url", "=", "parse_url", "(", "$", "url", ")", ";", "return", "$", "this", ";", "}" ]
Initialize object properties. @param string $url Url to parse. If null, get current url. @return self
[ "Initialize", "object", "properties", "." ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Http.php#L71-L77
train
eureka-framework/component-http
src/Http/Http.php
Http.query
public function query($array = false) { $query = (!empty($this->url['query']) ? $this->url['query'] : ''); if ($array) { parse_str($query, $query); return $query; } else { return $query; } }
php
public function query($array = false) { $query = (!empty($this->url['query']) ? $this->url['query'] : ''); if ($array) { parse_str($query, $query); return $query; } else { return $query; } }
[ "public", "function", "query", "(", "$", "array", "=", "false", ")", "{", "$", "query", "=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'query'", "]", ")", "?", "$", "this", "->", "url", "[", "'query'", "]", ":", "''", ")", ";", "if", "(", "$", "array", ")", "{", "parse_str", "(", "$", "query", ",", "$", "query", ")", ";", "return", "$", "query", ";", "}", "else", "{", "return", "$", "query", ";", "}", "}" ]
Return query url. @param bool $array If return array or string @return mixed Query Url
[ "Return", "query", "url", "." ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Http.php#L85-L96
train
eureka-framework/component-http
src/Http/Http.php
Http.setPath
public function setPath($path, $type = 'replace', $replace = '') { $oldPath = (!empty($this->url['path']) ? $this->url['path'] : ''); switch ($type) { case 'add': $path = $oldPath . $path; break; case 'remove': $path = str_replace($path, '', $oldPath); break; case 'replace': default: $path = str_replace($replace, $path, $oldPath); break; } $this->url['path'] = $path; return $this; }
php
public function setPath($path, $type = 'replace', $replace = '') { $oldPath = (!empty($this->url['path']) ? $this->url['path'] : ''); switch ($type) { case 'add': $path = $oldPath . $path; break; case 'remove': $path = str_replace($path, '', $oldPath); break; case 'replace': default: $path = str_replace($replace, $path, $oldPath); break; } $this->url['path'] = $path; return $this; }
[ "public", "function", "setPath", "(", "$", "path", ",", "$", "type", "=", "'replace'", ",", "$", "replace", "=", "''", ")", "{", "$", "oldPath", "=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'path'", "]", ")", "?", "$", "this", "->", "url", "[", "'path'", "]", ":", "''", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'add'", ":", "$", "path", "=", "$", "oldPath", ".", "$", "path", ";", "break", ";", "case", "'remove'", ":", "$", "path", "=", "str_replace", "(", "$", "path", ",", "''", ",", "$", "oldPath", ")", ";", "break", ";", "case", "'replace'", ":", "default", ":", "$", "path", "=", "str_replace", "(", "$", "replace", ",", "$", "path", ",", "$", "oldPath", ")", ";", "break", ";", "}", "$", "this", "->", "url", "[", "'path'", "]", "=", "$", "path", ";", "return", "$", "this", ";", "}" ]
Add or replace path @param string $path @param string $type @param string $replace @return self
[ "Add", "or", "replace", "path" ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Http.php#L106-L126
train
eureka-framework/component-http
src/Http/Http.php
Http.uri
public function uri() { $uri = (!empty($this->url['scheme']) ? $this->url['scheme'] . '://' : Server::getInstance()->get('scheme', '')); $uri .= (!empty($this->url['user']) ? $this->url['user'] . ':' . $this->url['pass'] . '@' : ''); $uri .= (!empty($this->url['host']) ? $this->url['host'] : Server::getInstance()->get('host', '')); $uri .= (!empty($this->url['port']) ? ':' . $this->url['port'] : ''); $uri .= (!empty($this->url['path']) ? $this->url['path'] : ''); $uri .= (!empty($this->url['query']) ? '?' . $this->url['query'] : ''); $uri .= (!empty($this->url['fragment']) ? '#' . $this->url['fragment'] : ''); return $uri; }
php
public function uri() { $uri = (!empty($this->url['scheme']) ? $this->url['scheme'] . '://' : Server::getInstance()->get('scheme', '')); $uri .= (!empty($this->url['user']) ? $this->url['user'] . ':' . $this->url['pass'] . '@' : ''); $uri .= (!empty($this->url['host']) ? $this->url['host'] : Server::getInstance()->get('host', '')); $uri .= (!empty($this->url['port']) ? ':' . $this->url['port'] : ''); $uri .= (!empty($this->url['path']) ? $this->url['path'] : ''); $uri .= (!empty($this->url['query']) ? '?' . $this->url['query'] : ''); $uri .= (!empty($this->url['fragment']) ? '#' . $this->url['fragment'] : ''); return $uri; }
[ "public", "function", "uri", "(", ")", "{", "$", "uri", "=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'scheme'", "]", ")", "?", "$", "this", "->", "url", "[", "'scheme'", "]", ".", "'://'", ":", "Server", "::", "getInstance", "(", ")", "->", "get", "(", "'scheme'", ",", "''", ")", ")", ";", "$", "uri", ".=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'user'", "]", ")", "?", "$", "this", "->", "url", "[", "'user'", "]", ".", "':'", ".", "$", "this", "->", "url", "[", "'pass'", "]", ".", "'@'", ":", "''", ")", ";", "$", "uri", ".=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'host'", "]", ")", "?", "$", "this", "->", "url", "[", "'host'", "]", ":", "Server", "::", "getInstance", "(", ")", "->", "get", "(", "'host'", ",", "''", ")", ")", ";", "$", "uri", ".=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'port'", "]", ")", "?", "':'", ".", "$", "this", "->", "url", "[", "'port'", "]", ":", "''", ")", ";", "$", "uri", ".=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'path'", "]", ")", "?", "$", "this", "->", "url", "[", "'path'", "]", ":", "''", ")", ";", "$", "uri", ".=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'query'", "]", ")", "?", "'?'", ".", "$", "this", "->", "url", "[", "'query'", "]", ":", "''", ")", ";", "$", "uri", ".=", "(", "!", "empty", "(", "$", "this", "->", "url", "[", "'fragment'", "]", ")", "?", "'#'", ".", "$", "this", "->", "url", "[", "'fragment'", "]", ":", "''", ")", ";", "return", "$", "uri", ";", "}" ]
Get formatted uri. @return string Current uri.
[ "Get", "formatted", "uri", "." ]
698c3b73581a9703a9c932890c57e50f8774607a
https://github.com/eureka-framework/component-http/blob/698c3b73581a9703a9c932890c57e50f8774607a/src/Http/Http.php#L133-L144
train
bytic/orm
src/AbstractModels/RecordManager.php
RecordManager.getUrlPK
public function getUrlPK() { if ($this->urlPK == null) { $this->urlPK = $this->getPrimaryKey(); } return $this->urlPK; }
php
public function getUrlPK() { if ($this->urlPK == null) { $this->urlPK = $this->getPrimaryKey(); } return $this->urlPK; }
[ "public", "function", "getUrlPK", "(", ")", "{", "if", "(", "$", "this", "->", "urlPK", "==", "null", ")", "{", "$", "this", "->", "urlPK", "=", "$", "this", "->", "getPrimaryKey", "(", ")", ";", "}", "return", "$", "this", "->", "urlPK", ";", "}" ]
The name of the field used as a foreign key in other tables @return string
[ "The", "name", "of", "the", "field", "used", "as", "a", "foreign", "key", "in", "other", "tables" ]
8d9a79b47761af0bfd9b8d1d28c83221dcac0de0
https://github.com/bytic/orm/blob/8d9a79b47761af0bfd9b8d1d28c83221dcac0de0/src/AbstractModels/RecordManager.php#L413-L420
train
LpFactory/NestedSetRoutingBundle
DependencyInjection/LpFactoryNestedSetRoutingExtension.php
LpFactoryNestedSetRoutingExtension.loadConfiguration
protected function loadConfiguration(array $config, ContainerBuilder $container) { // Load page nested routes $routeConfigurationChain = $container->findDefinition('lp_factory.route_configuration.chain'); foreach ($config['routes'] as $alias => $routeConfiguration) { $routeConfigurationChain->addMethodCall('add', array($alias, $routeConfiguration)); } $routeFactoryId = $config['service_ids']['factory']; $treeStrategyId = $config['service_ids']['strategy']; // Inject service route factory $routeProvider = $container->findDefinition('lp_factory.route_provider'); $routeProvider->replaceArgument(0, new Reference($routeFactoryId)); $routeProvider->replaceArgument(3, new Reference($treeStrategyId)); // Add repository and strategy arguments $routeFactory = $container->findDefinition($routeFactoryId); $routeFactory->replaceArgument(0, new Reference($config['repository'])); $routeFactory->replaceArgument(1, new Reference($treeStrategyId)); $abstractStrategy = $container->findDefinition('lp_factory.route_strategy.abstract'); $abstractStrategy->replaceArgument(0, new Reference($config['repository'])); }
php
protected function loadConfiguration(array $config, ContainerBuilder $container) { // Load page nested routes $routeConfigurationChain = $container->findDefinition('lp_factory.route_configuration.chain'); foreach ($config['routes'] as $alias => $routeConfiguration) { $routeConfigurationChain->addMethodCall('add', array($alias, $routeConfiguration)); } $routeFactoryId = $config['service_ids']['factory']; $treeStrategyId = $config['service_ids']['strategy']; // Inject service route factory $routeProvider = $container->findDefinition('lp_factory.route_provider'); $routeProvider->replaceArgument(0, new Reference($routeFactoryId)); $routeProvider->replaceArgument(3, new Reference($treeStrategyId)); // Add repository and strategy arguments $routeFactory = $container->findDefinition($routeFactoryId); $routeFactory->replaceArgument(0, new Reference($config['repository'])); $routeFactory->replaceArgument(1, new Reference($treeStrategyId)); $abstractStrategy = $container->findDefinition('lp_factory.route_strategy.abstract'); $abstractStrategy->replaceArgument(0, new Reference($config['repository'])); }
[ "protected", "function", "loadConfiguration", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "// Load page nested routes", "$", "routeConfigurationChain", "=", "$", "container", "->", "findDefinition", "(", "'lp_factory.route_configuration.chain'", ")", ";", "foreach", "(", "$", "config", "[", "'routes'", "]", "as", "$", "alias", "=>", "$", "routeConfiguration", ")", "{", "$", "routeConfigurationChain", "->", "addMethodCall", "(", "'add'", ",", "array", "(", "$", "alias", ",", "$", "routeConfiguration", ")", ")", ";", "}", "$", "routeFactoryId", "=", "$", "config", "[", "'service_ids'", "]", "[", "'factory'", "]", ";", "$", "treeStrategyId", "=", "$", "config", "[", "'service_ids'", "]", "[", "'strategy'", "]", ";", "// Inject service route factory", "$", "routeProvider", "=", "$", "container", "->", "findDefinition", "(", "'lp_factory.route_provider'", ")", ";", "$", "routeProvider", "->", "replaceArgument", "(", "0", ",", "new", "Reference", "(", "$", "routeFactoryId", ")", ")", ";", "$", "routeProvider", "->", "replaceArgument", "(", "3", ",", "new", "Reference", "(", "$", "treeStrategyId", ")", ")", ";", "// Add repository and strategy arguments", "$", "routeFactory", "=", "$", "container", "->", "findDefinition", "(", "$", "routeFactoryId", ")", ";", "$", "routeFactory", "->", "replaceArgument", "(", "0", ",", "new", "Reference", "(", "$", "config", "[", "'repository'", "]", ")", ")", ";", "$", "routeFactory", "->", "replaceArgument", "(", "1", ",", "new", "Reference", "(", "$", "treeStrategyId", ")", ")", ";", "$", "abstractStrategy", "=", "$", "container", "->", "findDefinition", "(", "'lp_factory.route_strategy.abstract'", ")", ";", "$", "abstractStrategy", "->", "replaceArgument", "(", "0", ",", "new", "Reference", "(", "$", "config", "[", "'repository'", "]", ")", ")", ";", "}" ]
Load configuration in container @param array $config @param ContainerBuilder $container
[ "Load", "configuration", "in", "container" ]
dc07227a6764e657b7b321827a18127ec18ba214
https://github.com/LpFactory/NestedSetRoutingBundle/blob/dc07227a6764e657b7b321827a18127ec18ba214/DependencyInjection/LpFactoryNestedSetRoutingExtension.php#L49-L71
train
t3v/t3v_core
Classes/Service/QueryResultService.php
QueryResultService.filterByLanguagePresets
public function filterByLanguagePresets($queryResult, array $presets) { $result = $queryResult; if (!empty($presets)) { $sysLanguageUid = $this->languageService->getSysLanguageUid(); $preset = intval($presets[$sysLanguageUid]); if (isset($preset)) { $result = []; foreach ($queryResult as $object) { $uid = $object->getSysLanguageUid(); if (isset($uid) && $uid == $preset) { $result[] = $object; } } } } return $result; }
php
public function filterByLanguagePresets($queryResult, array $presets) { $result = $queryResult; if (!empty($presets)) { $sysLanguageUid = $this->languageService->getSysLanguageUid(); $preset = intval($presets[$sysLanguageUid]); if (isset($preset)) { $result = []; foreach ($queryResult as $object) { $uid = $object->getSysLanguageUid(); if (isset($uid) && $uid == $preset) { $result[] = $object; } } } } return $result; }
[ "public", "function", "filterByLanguagePresets", "(", "$", "queryResult", ",", "array", "$", "presets", ")", "{", "$", "result", "=", "$", "queryResult", ";", "if", "(", "!", "empty", "(", "$", "presets", ")", ")", "{", "$", "sysLanguageUid", "=", "$", "this", "->", "languageService", "->", "getSysLanguageUid", "(", ")", ";", "$", "preset", "=", "intval", "(", "$", "presets", "[", "$", "sysLanguageUid", "]", ")", ";", "if", "(", "isset", "(", "$", "preset", ")", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "queryResult", "as", "$", "object", ")", "{", "$", "uid", "=", "$", "object", "->", "getSysLanguageUid", "(", ")", ";", "if", "(", "isset", "(", "$", "uid", ")", "&&", "$", "uid", "==", "$", "preset", ")", "{", "$", "result", "[", "]", "=", "$", "object", ";", "}", "}", "}", "}", "return", "$", "result", ";", "}" ]
Filters a query result by language presets. @param object $queryResult The query result @param array $presets The language presets @return object The filtered query result
[ "Filters", "a", "query", "result", "by", "language", "presets", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Service/QueryResultService.php#L38-L59
train
t3v/t3v_core
Classes/Service/QueryResultService.php
QueryResultService.filterBySysLanguage
public function filterBySysLanguage($queryResult, $exceptions = []) { $result = $queryResult; if (is_string($exceptions)) { $exceptions = GeneralUtility::intExplode(',', $exceptions, true); } $sysLanguageUid = $this->languageService->getSysLanguageUid(); if (!in_array($sysLanguageUid, $exceptions, true)) { $result = []; foreach ($queryResult as $object) { $uid = $object->getSysLanguageUid(); if (isset($uid) && $uid == $sysLanguageUid) { $result[] = $object; } } } return $result; }
php
public function filterBySysLanguage($queryResult, $exceptions = []) { $result = $queryResult; if (is_string($exceptions)) { $exceptions = GeneralUtility::intExplode(',', $exceptions, true); } $sysLanguageUid = $this->languageService->getSysLanguageUid(); if (!in_array($sysLanguageUid, $exceptions, true)) { $result = []; foreach ($queryResult as $object) { $uid = $object->getSysLanguageUid(); if (isset($uid) && $uid == $sysLanguageUid) { $result[] = $object; } } } return $result; }
[ "public", "function", "filterBySysLanguage", "(", "$", "queryResult", ",", "$", "exceptions", "=", "[", "]", ")", "{", "$", "result", "=", "$", "queryResult", ";", "if", "(", "is_string", "(", "$", "exceptions", ")", ")", "{", "$", "exceptions", "=", "GeneralUtility", "::", "intExplode", "(", "','", ",", "$", "exceptions", ",", "true", ")", ";", "}", "$", "sysLanguageUid", "=", "$", "this", "->", "languageService", "->", "getSysLanguageUid", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "sysLanguageUid", ",", "$", "exceptions", ",", "true", ")", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "queryResult", "as", "$", "object", ")", "{", "$", "uid", "=", "$", "object", "->", "getSysLanguageUid", "(", ")", ";", "if", "(", "isset", "(", "$", "uid", ")", "&&", "$", "uid", "==", "$", "sysLanguageUid", ")", "{", "$", "result", "[", "]", "=", "$", "object", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Filters a query result by system language. @param object $queryResult The query result @param array|string $exceptions The optional UIDs which are ignored as array or as string, seperated by `,` @return object The filtered query result
[ "Filters", "a", "query", "result", "by", "system", "language", "." ]
8c04b7688cc2773f11fcc87fda3f7cd53d80a980
https://github.com/t3v/t3v_core/blob/8c04b7688cc2773f11fcc87fda3f7cd53d80a980/Classes/Service/QueryResultService.php#L68-L90
train
AlexyaFramework/Tools
Alexya/Tools/Session/Session.php
Session.deleteByKey
public function deleteByKey($name) : void { if(!$this->keyExists($name)) { return; } parent::deleteByKey($name); unset($_SESSION[$name]); }
php
public function deleteByKey($name) : void { if(!$this->keyExists($name)) { return; } parent::deleteByKey($name); unset($_SESSION[$name]); }
[ "public", "function", "deleteByKey", "(", "$", "name", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "keyExists", "(", "$", "name", ")", ")", "{", "return", ";", "}", "parent", "::", "deleteByKey", "(", "$", "name", ")", ";", "unset", "(", "$", "_SESSION", "[", "$", "name", "]", ")", ";", "}" ]
Removes a variable from the session. @param mixed $name Variable name.
[ "Removes", "a", "variable", "from", "the", "session", "." ]
2ae7c91cde0517579b926dd872eaf7ea324fd1e4
https://github.com/AlexyaFramework/Tools/blob/2ae7c91cde0517579b926dd872eaf7ea324fd1e4/Alexya/Tools/Session/Session.php#L67-L75
train
AlexyaFramework/Tools
Alexya/Tools/Session/Session.php
Session.set
public function set($name, $value) : void { $_SESSION[$name] = $value; parent::set($name, $value); }
php
public function set($name, $value) : void { $_SESSION[$name] = $value; parent::set($name, $value); }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", ")", ":", "void", "{", "$", "_SESSION", "[", "$", "name", "]", "=", "$", "value", ";", "parent", "::", "set", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Sets a variable. @param mixed $name Variable name. @param mixed $value Variable value.
[ "Sets", "a", "variable", "." ]
2ae7c91cde0517579b926dd872eaf7ea324fd1e4
https://github.com/AlexyaFramework/Tools/blob/2ae7c91cde0517579b926dd872eaf7ea324fd1e4/Alexya/Tools/Session/Session.php#L83-L88
train
koolkode/context
src/AbstractContainer.php
AbstractContainer.initialize
public function initialize($object) { if($object instanceof ScopedProxyInterface) { return $object; } if($object instanceof ContainerAwareInterface) { $object->setContainer($this); } foreach($this->initializers as $initializer) { $object = $initializer->initializeObject($object, $this) ?: $object; } return $object; }
php
public function initialize($object) { if($object instanceof ScopedProxyInterface) { return $object; } if($object instanceof ContainerAwareInterface) { $object->setContainer($this); } foreach($this->initializers as $initializer) { $object = $initializer->initializeObject($object, $this) ?: $object; } return $object; }
[ "public", "function", "initialize", "(", "$", "object", ")", "{", "if", "(", "$", "object", "instanceof", "ScopedProxyInterface", ")", "{", "return", "$", "object", ";", "}", "if", "(", "$", "object", "instanceof", "ContainerAwareInterface", ")", "{", "$", "object", "->", "setContainer", "(", "$", "this", ")", ";", "}", "foreach", "(", "$", "this", "->", "initializers", "as", "$", "initializer", ")", "{", "$", "object", "=", "$", "initializer", "->", "initializeObject", "(", "$", "object", ",", "$", "this", ")", "?", ":", "$", "object", ";", "}", "return", "$", "object", ";", "}" ]
Initialize the object by injection the DI container into aware objects and invoking all container initializers passing the target object. @param object $object The object to be initialized. @return object The object instance that has been passed into the initializer.
[ "Initialize", "the", "object", "by", "injection", "the", "DI", "container", "into", "aware", "objects", "and", "invoking", "all", "container", "initializers", "passing", "the", "target", "object", "." ]
f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36
https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/AbstractContainer.php#L178-L196
train
koolkode/context
src/AbstractContainer.php
AbstractContainer.registerScope
public function registerScope(ScopeManagerInterface $scope) { if(isset($this->scopes[$scope->getScope()])) { throw new DuplicateScopeException(sprintf('Scope "%s" is already registered', $scope->getScope())); } $this->scopes[$scope->getScope()] = $scope; $scope->correlate($this); return $scope; }
php
public function registerScope(ScopeManagerInterface $scope) { if(isset($this->scopes[$scope->getScope()])) { throw new DuplicateScopeException(sprintf('Scope "%s" is already registered', $scope->getScope())); } $this->scopes[$scope->getScope()] = $scope; $scope->correlate($this); return $scope; }
[ "public", "function", "registerScope", "(", "ScopeManagerInterface", "$", "scope", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "scopes", "[", "$", "scope", "->", "getScope", "(", ")", "]", ")", ")", "{", "throw", "new", "DuplicateScopeException", "(", "sprintf", "(", "'Scope \"%s\" is already registered'", ",", "$", "scope", "->", "getScope", "(", ")", ")", ")", ";", "}", "$", "this", "->", "scopes", "[", "$", "scope", "->", "getScope", "(", ")", "]", "=", "$", "scope", ";", "$", "scope", "->", "correlate", "(", "$", "this", ")", ";", "return", "$", "scope", ";", "}" ]
Register and correalate a scope with this DI container instance. @param ScopeManagerInterface $scope The scope to be registered. @return ScopeManagerInterface The registered scope. @throws DuplicateScopeException When the scope is already registered with the container.
[ "Register", "and", "correalate", "a", "scope", "with", "this", "DI", "container", "instance", "." ]
f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36
https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/AbstractContainer.php#L281-L293
train
koolkode/context
src/AbstractContainer.php
AbstractContainer.invokeBindingInitializers
protected function invokeBindingInitializers($typeName, $object, $initializers = NULL) { foreach((array)$initializers as $initializer) { if(is_array($initializer)) { $ref = new \ReflectionMethod(is_object($initializer[0]) ? get_class($initializer[0]) : $initializer[0], $initializer[1]); } else { $ref = new \ReflectionFunction($initializer); } $args = $this->populateArguments($ref, 1, [], new InjectionPoint($typeName, $ref->name)); switch(count($args)) { case 0: $object = $initializer($object) ?: $object; break; case 1: $object = $initializer($object, $args[0]) ?: $object; break; case 2: $object = $initializer($object, $args[0], $args[1]) ?: $object; break; case 3: $object = $initializer($object, $args[0], $args[1], $args[2]) ?: $object; break; case 4: $object = $initializer($object, $args[0], $args[1], $args[2], $args[3]) ?: $object; break; default: $object = call_user_func_array($initializer, array_merge([$object], $args)) ?: $object; } } return $object; }
php
protected function invokeBindingInitializers($typeName, $object, $initializers = NULL) { foreach((array)$initializers as $initializer) { if(is_array($initializer)) { $ref = new \ReflectionMethod(is_object($initializer[0]) ? get_class($initializer[0]) : $initializer[0], $initializer[1]); } else { $ref = new \ReflectionFunction($initializer); } $args = $this->populateArguments($ref, 1, [], new InjectionPoint($typeName, $ref->name)); switch(count($args)) { case 0: $object = $initializer($object) ?: $object; break; case 1: $object = $initializer($object, $args[0]) ?: $object; break; case 2: $object = $initializer($object, $args[0], $args[1]) ?: $object; break; case 3: $object = $initializer($object, $args[0], $args[1], $args[2]) ?: $object; break; case 4: $object = $initializer($object, $args[0], $args[1], $args[2], $args[3]) ?: $object; break; default: $object = call_user_func_array($initializer, array_merge([$object], $args)) ?: $object; } } return $object; }
[ "protected", "function", "invokeBindingInitializers", "(", "$", "typeName", ",", "$", "object", ",", "$", "initializers", "=", "NULL", ")", "{", "foreach", "(", "(", "array", ")", "$", "initializers", "as", "$", "initializer", ")", "{", "if", "(", "is_array", "(", "$", "initializer", ")", ")", "{", "$", "ref", "=", "new", "\\", "ReflectionMethod", "(", "is_object", "(", "$", "initializer", "[", "0", "]", ")", "?", "get_class", "(", "$", "initializer", "[", "0", "]", ")", ":", "$", "initializer", "[", "0", "]", ",", "$", "initializer", "[", "1", "]", ")", ";", "}", "else", "{", "$", "ref", "=", "new", "\\", "ReflectionFunction", "(", "$", "initializer", ")", ";", "}", "$", "args", "=", "$", "this", "->", "populateArguments", "(", "$", "ref", ",", "1", ",", "[", "]", ",", "new", "InjectionPoint", "(", "$", "typeName", ",", "$", "ref", "->", "name", ")", ")", ";", "switch", "(", "count", "(", "$", "args", ")", ")", "{", "case", "0", ":", "$", "object", "=", "$", "initializer", "(", "$", "object", ")", "?", ":", "$", "object", ";", "break", ";", "case", "1", ":", "$", "object", "=", "$", "initializer", "(", "$", "object", ",", "$", "args", "[", "0", "]", ")", "?", ":", "$", "object", ";", "break", ";", "case", "2", ":", "$", "object", "=", "$", "initializer", "(", "$", "object", ",", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ")", "?", ":", "$", "object", ";", "break", ";", "case", "3", ":", "$", "object", "=", "$", "initializer", "(", "$", "object", ",", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ",", "$", "args", "[", "2", "]", ")", "?", ":", "$", "object", ";", "break", ";", "case", "4", ":", "$", "object", "=", "$", "initializer", "(", "$", "object", ",", "$", "args", "[", "0", "]", ",", "$", "args", "[", "1", "]", ",", "$", "args", "[", "2", "]", ",", "$", "args", "[", "3", "]", ")", "?", ":", "$", "object", ";", "break", ";", "default", ":", "$", "object", "=", "call_user_func_array", "(", "$", "initializer", ",", "array_merge", "(", "[", "$", "object", "]", ",", "$", "args", ")", ")", "?", ":", "$", "object", ";", "}", "}", "return", "$", "object", ";", "}" ]
Invoke all passed initializers for the given object. @param object $object The object to be initialized. @param string $initializers Initializers to be called. @return object Returns the passed object instance.
[ "Invoke", "all", "passed", "initializers", "for", "the", "given", "object", "." ]
f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36
https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/AbstractContainer.php#L722-L760
train
koolkode/context
src/AbstractContainer.php
AbstractContainer.getCallableName
protected function getCallableName(\ReflectionFunctionAbstract $ref) { if($ref instanceof \ReflectionMethod) { return $ref->getDeclaringClass()->name . '->' . $ref->name . '()'; } if($ref->isClosure()) { return '*closure*'; } return $ref->getName() . '()'; }
php
protected function getCallableName(\ReflectionFunctionAbstract $ref) { if($ref instanceof \ReflectionMethod) { return $ref->getDeclaringClass()->name . '->' . $ref->name . '()'; } if($ref->isClosure()) { return '*closure*'; } return $ref->getName() . '()'; }
[ "protected", "function", "getCallableName", "(", "\\", "ReflectionFunctionAbstract", "$", "ref", ")", "{", "if", "(", "$", "ref", "instanceof", "\\", "ReflectionMethod", ")", "{", "return", "$", "ref", "->", "getDeclaringClass", "(", ")", "->", "name", ".", "'->'", ".", "$", "ref", "->", "name", ".", "'()'", ";", "}", "if", "(", "$", "ref", "->", "isClosure", "(", ")", ")", "{", "return", "'*closure*'", ";", "}", "return", "$", "ref", "->", "getName", "(", ")", ".", "'()'", ";", "}" ]
Get a human-readable name from a reflected callable. @param \ReflectionFunctionAbstract $ref @return string
[ "Get", "a", "human", "-", "readable", "name", "from", "a", "reflected", "callable", "." ]
f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36
https://github.com/koolkode/context/blob/f4aa614eb4ca1080bd89c7a2a54c9467c5b17a36/src/AbstractContainer.php#L768-L781
train
gplcart/authorize
Main.php
Main.getGateway
protected function getGateway() { /* @var $module \gplcart\modules\omnipay_library\Main */ $module = $this->module->getInstance('omnipay_library'); /** @var \Omnipay\AuthorizeNet\SIMGateway $gateway */ $gateway = $module->getGatewayInstance('AuthorizeNet_SIM'); if (!$gateway instanceof SIMGateway) { throw new UnexpectedValueException('Gateway must be instance of Omnipay\AuthorizeNet\SIMGateway'); } return $gateway; }
php
protected function getGateway() { /* @var $module \gplcart\modules\omnipay_library\Main */ $module = $this->module->getInstance('omnipay_library'); /** @var \Omnipay\AuthorizeNet\SIMGateway $gateway */ $gateway = $module->getGatewayInstance('AuthorizeNet_SIM'); if (!$gateway instanceof SIMGateway) { throw new UnexpectedValueException('Gateway must be instance of Omnipay\AuthorizeNet\SIMGateway'); } return $gateway; }
[ "protected", "function", "getGateway", "(", ")", "{", "/* @var $module \\gplcart\\modules\\omnipay_library\\Main */", "$", "module", "=", "$", "this", "->", "module", "->", "getInstance", "(", "'omnipay_library'", ")", ";", "/** @var \\Omnipay\\AuthorizeNet\\SIMGateway $gateway */", "$", "gateway", "=", "$", "module", "->", "getGatewayInstance", "(", "'AuthorizeNet_SIM'", ")", ";", "if", "(", "!", "$", "gateway", "instanceof", "SIMGateway", ")", "{", "throw", "new", "UnexpectedValueException", "(", "'Gateway must be instance of Omnipay\\AuthorizeNet\\SIMGateway'", ")", ";", "}", "return", "$", "gateway", ";", "}" ]
Get gateway instance @return \Omnipay\AuthorizeNet\SIMGateway @throws UnexpectedValueException
[ "Get", "gateway", "instance" ]
9118d4626c19f73408b80cfe57c7a686936c9d7a
https://github.com/gplcart/authorize/blob/9118d4626c19f73408b80cfe57c7a686936c9d7a/Main.php#L165-L178
train
gplcart/authorize
Main.php
Main.cancelPurchase
protected function cancelPurchase() { $this->controller->setMessage($this->controller->text('Payment has been canceled'), 'warning'); $gateway_message = $this->response->getMessage(); if (!empty($gateway_message)) { $this->controller->setMessage($gateway_message, 'warning'); } }
php
protected function cancelPurchase() { $this->controller->setMessage($this->controller->text('Payment has been canceled'), 'warning'); $gateway_message = $this->response->getMessage(); if (!empty($gateway_message)) { $this->controller->setMessage($gateway_message, 'warning'); } }
[ "protected", "function", "cancelPurchase", "(", ")", "{", "$", "this", "->", "controller", "->", "setMessage", "(", "$", "this", "->", "controller", "->", "text", "(", "'Payment has been canceled'", ")", ",", "'warning'", ")", ";", "$", "gateway_message", "=", "$", "this", "->", "response", "->", "getMessage", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "gateway_message", ")", ")", "{", "$", "this", "->", "controller", "->", "setMessage", "(", "$", "gateway_message", ",", "'warning'", ")", ";", "}", "}" ]
Performs actions when a payment is canceled
[ "Performs", "actions", "when", "a", "payment", "is", "canceled" ]
9118d4626c19f73408b80cfe57c7a686936c9d7a
https://github.com/gplcart/authorize/blob/9118d4626c19f73408b80cfe57c7a686936c9d7a/Main.php#L200-L207
train
gplcart/authorize
Main.php
Main.getPurchaseParams
protected function getPurchaseParams() { $url = "checkout/complete/{$this->data_order['order_id']}"; return array( 'currency' => $this->data_order['currency'], 'amount' => $this->data_order['total_formatted_number'], 'returnUrl' => $this->controller->url($url, array('authorize_return' => true), true), 'cancelUrl' => $this->controller->url($url, array('authorize_return' => true, 'cancel' => true), true) ); }
php
protected function getPurchaseParams() { $url = "checkout/complete/{$this->data_order['order_id']}"; return array( 'currency' => $this->data_order['currency'], 'amount' => $this->data_order['total_formatted_number'], 'returnUrl' => $this->controller->url($url, array('authorize_return' => true), true), 'cancelUrl' => $this->controller->url($url, array('authorize_return' => true, 'cancel' => true), true) ); }
[ "protected", "function", "getPurchaseParams", "(", ")", "{", "$", "url", "=", "\"checkout/complete/{$this->data_order['order_id']}\"", ";", "return", "array", "(", "'currency'", "=>", "$", "this", "->", "data_order", "[", "'currency'", "]", ",", "'amount'", "=>", "$", "this", "->", "data_order", "[", "'total_formatted_number'", "]", ",", "'returnUrl'", "=>", "$", "this", "->", "controller", "->", "url", "(", "$", "url", ",", "array", "(", "'authorize_return'", "=>", "true", ")", ",", "true", ")", ",", "'cancelUrl'", "=>", "$", "this", "->", "controller", "->", "url", "(", "$", "url", ",", "array", "(", "'authorize_return'", "=>", "true", ",", "'cancel'", "=>", "true", ")", ",", "true", ")", ")", ";", "}" ]
Returns an array of purchase parameters @return array
[ "Returns", "an", "array", "of", "purchase", "parameters" ]
9118d4626c19f73408b80cfe57c7a686936c9d7a
https://github.com/gplcart/authorize/blob/9118d4626c19f73408b80cfe57c7a686936c9d7a/Main.php#L234-L244
train
gplcart/authorize
Main.php
Main.finishPurchase
protected function finishPurchase() { if ($this->response->isSuccessful()) { $this->updateOrderStatus(); $this->addTransaction(); $this->redirectSuccess(); } else if ($this->response->isRedirect()) { $this->response->redirect(); } else { $this->redirectError(); } }
php
protected function finishPurchase() { if ($this->response->isSuccessful()) { $this->updateOrderStatus(); $this->addTransaction(); $this->redirectSuccess(); } else if ($this->response->isRedirect()) { $this->response->redirect(); } else { $this->redirectError(); } }
[ "protected", "function", "finishPurchase", "(", ")", "{", "if", "(", "$", "this", "->", "response", "->", "isSuccessful", "(", ")", ")", "{", "$", "this", "->", "updateOrderStatus", "(", ")", ";", "$", "this", "->", "addTransaction", "(", ")", ";", "$", "this", "->", "redirectSuccess", "(", ")", ";", "}", "else", "if", "(", "$", "this", "->", "response", "->", "isRedirect", "(", ")", ")", "{", "$", "this", "->", "response", "->", "redirect", "(", ")", ";", "}", "else", "{", "$", "this", "->", "redirectError", "(", ")", ";", "}", "}" ]
Performs final actions on success payment
[ "Performs", "final", "actions", "on", "success", "payment" ]
9118d4626c19f73408b80cfe57c7a686936c9d7a
https://github.com/gplcart/authorize/blob/9118d4626c19f73408b80cfe57c7a686936c9d7a/Main.php#L249-L260
train
geoffadams/bedrest-core
library/BedRest/Content/Negotiation/MediaTypeList.php
MediaTypeList.getBestMatch
public function getBestMatch(array $formats) { foreach ($this->items as $item) { if (in_array($item['media_range'], $formats)) { return $item['media_range']; } } return false; }
php
public function getBestMatch(array $formats) { foreach ($this->items as $item) { if (in_array($item['media_range'], $formats)) { return $item['media_range']; } } return false; }
[ "public", "function", "getBestMatch", "(", "array", "$", "formats", ")", "{", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "if", "(", "in_array", "(", "$", "item", "[", "'media_range'", "]", ",", "$", "formats", ")", ")", "{", "return", "$", "item", "[", "'media_range'", "]", ";", "}", "}", "return", "false", ";", "}" ]
Returns the best format out of a list of supplied formats. @param array $formats @return string|boolean
[ "Returns", "the", "best", "format", "out", "of", "a", "list", "of", "supplied", "formats", "." ]
a77bf8b7492dfbfb720b201f7ec91a4f03417b5c
https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Content/Negotiation/MediaTypeList.php#L83-L92
train
praxigento/mobi_mod_pv
Repo/Dao/Sale/Item.php
Item.getItemsByOrderId
public function getItemsByOrderId($orderId) { $result = []; /* aliases and tables */ $asOrder = 'sale'; $asPvItem = 'pv'; $tblOrder = [$asOrder => $this->resource->getTableName(Cfg::ENTITY_MAGE_SALES_ORDER_ITEM)]; $tblPvItem = [$asPvItem => $this->resource->getTableName(Entity::ENTITY_NAME)]; /* SELECT FROM sales_order_item */ $query = $this->conn->select(); $cols = []; $query->from($tblOrder, $cols); /* LEFT JOIN prxgt_pv_sale_item pwq */ $on = $asPvItem . '.' . Entity::A_ITEM_REF . '=' . $asOrder . '.' . Cfg::E_SALE_ORDER_ITEM_A_ITEM_ID; $cols = '*'; // get all columns $query->joinLeft($tblPvItem, $on, $cols); /* WHERE */ $where = $asOrder . '.' . Cfg::E_SALE_ORDER_ITEM_A_ORDER_ID . '=' . (int)$orderId; $query->where($where); /* fetch data */ $rows = $this->conn->fetchAll($query); foreach ($rows as $row) { /** @var Entity $item */ $item = new Entity($row); $result[$item->getItemRef()] = $item; } return $result; }
php
public function getItemsByOrderId($orderId) { $result = []; /* aliases and tables */ $asOrder = 'sale'; $asPvItem = 'pv'; $tblOrder = [$asOrder => $this->resource->getTableName(Cfg::ENTITY_MAGE_SALES_ORDER_ITEM)]; $tblPvItem = [$asPvItem => $this->resource->getTableName(Entity::ENTITY_NAME)]; /* SELECT FROM sales_order_item */ $query = $this->conn->select(); $cols = []; $query->from($tblOrder, $cols); /* LEFT JOIN prxgt_pv_sale_item pwq */ $on = $asPvItem . '.' . Entity::A_ITEM_REF . '=' . $asOrder . '.' . Cfg::E_SALE_ORDER_ITEM_A_ITEM_ID; $cols = '*'; // get all columns $query->joinLeft($tblPvItem, $on, $cols); /* WHERE */ $where = $asOrder . '.' . Cfg::E_SALE_ORDER_ITEM_A_ORDER_ID . '=' . (int)$orderId; $query->where($where); /* fetch data */ $rows = $this->conn->fetchAll($query); foreach ($rows as $row) { /** @var Entity $item */ $item = new Entity($row); $result[$item->getItemRef()] = $item; } return $result; }
[ "public", "function", "getItemsByOrderId", "(", "$", "orderId", ")", "{", "$", "result", "=", "[", "]", ";", "/* aliases and tables */", "$", "asOrder", "=", "'sale'", ";", "$", "asPvItem", "=", "'pv'", ";", "$", "tblOrder", "=", "[", "$", "asOrder", "=>", "$", "this", "->", "resource", "->", "getTableName", "(", "Cfg", "::", "ENTITY_MAGE_SALES_ORDER_ITEM", ")", "]", ";", "$", "tblPvItem", "=", "[", "$", "asPvItem", "=>", "$", "this", "->", "resource", "->", "getTableName", "(", "Entity", "::", "ENTITY_NAME", ")", "]", ";", "/* SELECT FROM sales_order_item */", "$", "query", "=", "$", "this", "->", "conn", "->", "select", "(", ")", ";", "$", "cols", "=", "[", "]", ";", "$", "query", "->", "from", "(", "$", "tblOrder", ",", "$", "cols", ")", ";", "/* LEFT JOIN prxgt_pv_sale_item pwq */", "$", "on", "=", "$", "asPvItem", ".", "'.'", ".", "Entity", "::", "A_ITEM_REF", ".", "'='", ".", "$", "asOrder", ".", "'.'", ".", "Cfg", "::", "E_SALE_ORDER_ITEM_A_ITEM_ID", ";", "$", "cols", "=", "'*'", ";", "// get all columns", "$", "query", "->", "joinLeft", "(", "$", "tblPvItem", ",", "$", "on", ",", "$", "cols", ")", ";", "/* WHERE */", "$", "where", "=", "$", "asOrder", ".", "'.'", ".", "Cfg", "::", "E_SALE_ORDER_ITEM_A_ORDER_ID", ".", "'='", ".", "(", "int", ")", "$", "orderId", ";", "$", "query", "->", "where", "(", "$", "where", ")", ";", "/* fetch data */", "$", "rows", "=", "$", "this", "->", "conn", "->", "fetchAll", "(", "$", "query", ")", ";", "foreach", "(", "$", "rows", "as", "$", "row", ")", "{", "/** @var Entity $item */", "$", "item", "=", "new", "Entity", "(", "$", "row", ")", ";", "$", "result", "[", "$", "item", "->", "getItemRef", "(", ")", "]", "=", "$", "item", ";", "}", "return", "$", "result", ";", "}" ]
Get array of the PvSaleItems entities by Magento order ID. @param int $orderId @return Entity[] index is a $saleItemId
[ "Get", "array", "of", "the", "PvSaleItems", "entities", "by", "Magento", "order", "ID", "." ]
d1540b7e94264527006e8b9fa68904a72a63928e
https://github.com/praxigento/mobi_mod_pv/blob/d1540b7e94264527006e8b9fa68904a72a63928e/Repo/Dao/Sale/Item.php#L71-L98
train
Vibius/Facade
src/AliasManager.php
AliasManager.registerAutoloader
public function registerAutoloader(){ $aliasManager = $this; spl_autoload_register(function($class) use($aliasManager) { $class = strtolower($class); if( !$aliasManager->checkIfAliasExists($class) ){ if( !$aliasManager->findAlias($class) ){ throw new Exception("Class was not found! ($class)"); } } $aliasManager->loadAlias($class); }); }
php
public function registerAutoloader(){ $aliasManager = $this; spl_autoload_register(function($class) use($aliasManager) { $class = strtolower($class); if( !$aliasManager->checkIfAliasExists($class) ){ if( !$aliasManager->findAlias($class) ){ throw new Exception("Class was not found! ($class)"); } } $aliasManager->loadAlias($class); }); }
[ "public", "function", "registerAutoloader", "(", ")", "{", "$", "aliasManager", "=", "$", "this", ";", "spl_autoload_register", "(", "function", "(", "$", "class", ")", "use", "(", "$", "aliasManager", ")", "{", "$", "class", "=", "strtolower", "(", "$", "class", ")", ";", "if", "(", "!", "$", "aliasManager", "->", "checkIfAliasExists", "(", "$", "class", ")", ")", "{", "if", "(", "!", "$", "aliasManager", "->", "findAlias", "(", "$", "class", ")", ")", "{", "throw", "new", "Exception", "(", "\"Class was not found! ($class)\"", ")", ";", "}", "}", "$", "aliasManager", "->", "loadAlias", "(", "$", "class", ")", ";", "}", ")", ";", "}" ]
This method is used to register an alias autoloader, as an addition to composer.
[ "This", "method", "is", "used", "to", "register", "an", "alias", "autoloader", "as", "an", "addition", "to", "composer", "." ]
2dac08bae098c436031b70f5a09abc365740aee0
https://github.com/Vibius/Facade/blob/2dac08bae098c436031b70f5a09abc365740aee0/src/AliasManager.php#L40-L52
train
Vibius/Facade
src/AliasManager.php
AliasManager.checkIfAliasExists
public function checkIfAliasExists($name){ if( isset($this->aliases[$name]) ){ return true; } $aliasPath = vibius_BASEPATH.$this->aliasCache.$name.".php"; if( file_exists($aliasPath) ){ $this->aliases[$name] = true; return true; } }
php
public function checkIfAliasExists($name){ if( isset($this->aliases[$name]) ){ return true; } $aliasPath = vibius_BASEPATH.$this->aliasCache.$name.".php"; if( file_exists($aliasPath) ){ $this->aliases[$name] = true; return true; } }
[ "public", "function", "checkIfAliasExists", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "aliases", "[", "$", "name", "]", ")", ")", "{", "return", "true", ";", "}", "$", "aliasPath", "=", "vibius_BASEPATH", ".", "$", "this", "->", "aliasCache", ".", "$", "name", ".", "\".php\"", ";", "if", "(", "file_exists", "(", "$", "aliasPath", ")", ")", "{", "$", "this", "->", "aliases", "[", "$", "name", "]", "=", "true", ";", "return", "true", ";", "}", "}" ]
This method is used to check if alias exists in the cache @param string $name Name of the alias to be checked @return boolean True if alias exists in the cache
[ "This", "method", "is", "used", "to", "check", "if", "alias", "exists", "in", "the", "cache" ]
2dac08bae098c436031b70f5a09abc365740aee0
https://github.com/Vibius/Facade/blob/2dac08bae098c436031b70f5a09abc365740aee0/src/AliasManager.php#L86-L97
train
Vibius/Facade
src/AliasManager.php
AliasManager.findAlias
public function findAlias($class){ $container = Container::open('aliases'); if( $container->exists($class) ){ $instance = $container->get($class); $config['provider'] = $instance; if( is_object($instance) ){ Container::open('instances')->add($class, $instance); $config['provider'] = 'PlaceHolderClass'; } $result = $this->createAlias($class, $config); return $result; } if( !isset($this->manifestResolver) ){ $psr4 = require vibius_BASEPATH.'vendor/composer/autoload_psr4.php'; $manifestResolver = new ManifestResolver($psr4); $this->manifestResolver = $manifestResolver; $manifestResolver->findManifests(); } $manifestResolver = $this->manifestResolver; foreach ($manifestResolver->manifests as $manifestName => $manifestSrc) { $manifest = $manifestResolver->getManifest($manifestSrc); if( $manifestData = $manifestResolver->verifyManifest($manifest) ){ foreach ($manifestData['components'] as $component => $componentConfig) { if( $manifestResolver->verifyComponent($componentConfig) ){ if( $class === $componentConfig['alias'] ){ $componentSrc = explode('../manifest.php',$manifestSrc)[0]; $result = $this->createAlias($class, $componentConfig); return $result; } } } } } }
php
public function findAlias($class){ $container = Container::open('aliases'); if( $container->exists($class) ){ $instance = $container->get($class); $config['provider'] = $instance; if( is_object($instance) ){ Container::open('instances')->add($class, $instance); $config['provider'] = 'PlaceHolderClass'; } $result = $this->createAlias($class, $config); return $result; } if( !isset($this->manifestResolver) ){ $psr4 = require vibius_BASEPATH.'vendor/composer/autoload_psr4.php'; $manifestResolver = new ManifestResolver($psr4); $this->manifestResolver = $manifestResolver; $manifestResolver->findManifests(); } $manifestResolver = $this->manifestResolver; foreach ($manifestResolver->manifests as $manifestName => $manifestSrc) { $manifest = $manifestResolver->getManifest($manifestSrc); if( $manifestData = $manifestResolver->verifyManifest($manifest) ){ foreach ($manifestData['components'] as $component => $componentConfig) { if( $manifestResolver->verifyComponent($componentConfig) ){ if( $class === $componentConfig['alias'] ){ $componentSrc = explode('../manifest.php',$manifestSrc)[0]; $result = $this->createAlias($class, $componentConfig); return $result; } } } } } }
[ "public", "function", "findAlias", "(", "$", "class", ")", "{", "$", "container", "=", "Container", "::", "open", "(", "'aliases'", ")", ";", "if", "(", "$", "container", "->", "exists", "(", "$", "class", ")", ")", "{", "$", "instance", "=", "$", "container", "->", "get", "(", "$", "class", ")", ";", "$", "config", "[", "'provider'", "]", "=", "$", "instance", ";", "if", "(", "is_object", "(", "$", "instance", ")", ")", "{", "Container", "::", "open", "(", "'instances'", ")", "->", "add", "(", "$", "class", ",", "$", "instance", ")", ";", "$", "config", "[", "'provider'", "]", "=", "'PlaceHolderClass'", ";", "}", "$", "result", "=", "$", "this", "->", "createAlias", "(", "$", "class", ",", "$", "config", ")", ";", "return", "$", "result", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "manifestResolver", ")", ")", "{", "$", "psr4", "=", "require", "vibius_BASEPATH", ".", "'vendor/composer/autoload_psr4.php'", ";", "$", "manifestResolver", "=", "new", "ManifestResolver", "(", "$", "psr4", ")", ";", "$", "this", "->", "manifestResolver", "=", "$", "manifestResolver", ";", "$", "manifestResolver", "->", "findManifests", "(", ")", ";", "}", "$", "manifestResolver", "=", "$", "this", "->", "manifestResolver", ";", "foreach", "(", "$", "manifestResolver", "->", "manifests", "as", "$", "manifestName", "=>", "$", "manifestSrc", ")", "{", "$", "manifest", "=", "$", "manifestResolver", "->", "getManifest", "(", "$", "manifestSrc", ")", ";", "if", "(", "$", "manifestData", "=", "$", "manifestResolver", "->", "verifyManifest", "(", "$", "manifest", ")", ")", "{", "foreach", "(", "$", "manifestData", "[", "'components'", "]", "as", "$", "component", "=>", "$", "componentConfig", ")", "{", "if", "(", "$", "manifestResolver", "->", "verifyComponent", "(", "$", "componentConfig", ")", ")", "{", "if", "(", "$", "class", "===", "$", "componentConfig", "[", "'alias'", "]", ")", "{", "$", "componentSrc", "=", "explode", "(", "'../manifest.php'", ",", "$", "manifestSrc", ")", "[", "0", "]", ";", "$", "result", "=", "$", "this", "->", "createAlias", "(", "$", "class", ",", "$", "componentConfig", ")", ";", "return", "$", "result", ";", "}", "}", "}", "}", "}", "}" ]
This method is used to find a component from composer's psr4, which serves requested alias. @param string $class Name of the alias to be looked for in psr4 autoloading array. @return boolean True if alias was found and created.
[ "This", "method", "is", "used", "to", "find", "a", "component", "from", "composer", "s", "psr4", "which", "serves", "requested", "alias", "." ]
2dac08bae098c436031b70f5a09abc365740aee0
https://github.com/Vibius/Facade/blob/2dac08bae098c436031b70f5a09abc365740aee0/src/AliasManager.php#L120-L163
train
Vibius/Facade
src/AliasManager.php
AliasManager.getAliasTemplate
public function getAliasTemplate(){ if( !isset($this->template) ){ $this->template = file_get_contents($this->path.'AliasTemplate.php'); } return $this->template; }
php
public function getAliasTemplate(){ if( !isset($this->template) ){ $this->template = file_get_contents($this->path.'AliasTemplate.php'); } return $this->template; }
[ "public", "function", "getAliasTemplate", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "template", ")", ")", "{", "$", "this", "->", "template", "=", "file_get_contents", "(", "$", "this", "->", "path", ".", "'AliasTemplate.php'", ")", ";", "}", "return", "$", "this", "->", "template", ";", "}" ]
Method is used to load a template for alias creation.
[ "Method", "is", "used", "to", "load", "a", "template", "for", "alias", "creation", "." ]
2dac08bae098c436031b70f5a09abc365740aee0
https://github.com/Vibius/Facade/blob/2dac08bae098c436031b70f5a09abc365740aee0/src/AliasManager.php#L168-L173
train
Vibius/Facade
src/AliasManager.php
AliasManager.createAlias
public function createAlias($name, $config){ $handle = fopen(vibius_BASEPATH.$this->aliasCache.$name.'.php','w+'); if(!$handle){ throw new Exception('Unable to create alias, fopen not successful'); } $template = $this->getAliasTemplate(); $template = str_replace('{$className}', $name, $template); $template = str_replace('{$providerName}', $config['provider'], $template); fwrite($handle, $template); fclose($handle); $this->aliases[$name] = true; return true; }
php
public function createAlias($name, $config){ $handle = fopen(vibius_BASEPATH.$this->aliasCache.$name.'.php','w+'); if(!$handle){ throw new Exception('Unable to create alias, fopen not successful'); } $template = $this->getAliasTemplate(); $template = str_replace('{$className}', $name, $template); $template = str_replace('{$providerName}', $config['provider'], $template); fwrite($handle, $template); fclose($handle); $this->aliases[$name] = true; return true; }
[ "public", "function", "createAlias", "(", "$", "name", ",", "$", "config", ")", "{", "$", "handle", "=", "fopen", "(", "vibius_BASEPATH", ".", "$", "this", "->", "aliasCache", ".", "$", "name", ".", "'.php'", ",", "'w+'", ")", ";", "if", "(", "!", "$", "handle", ")", "{", "throw", "new", "Exception", "(", "'Unable to create alias, fopen not successful'", ")", ";", "}", "$", "template", "=", "$", "this", "->", "getAliasTemplate", "(", ")", ";", "$", "template", "=", "str_replace", "(", "'{$className}'", ",", "$", "name", ",", "$", "template", ")", ";", "$", "template", "=", "str_replace", "(", "'{$providerName}'", ",", "$", "config", "[", "'provider'", "]", ",", "$", "template", ")", ";", "fwrite", "(", "$", "handle", ",", "$", "template", ")", ";", "fclose", "(", "$", "handle", ")", ";", "$", "this", "->", "aliases", "[", "$", "name", "]", "=", "true", ";", "return", "true", ";", "}" ]
Method is used to create an alias, from specified parameters. @param string $name Name of the alias to be created @param string $config Configuration array of created alias
[ "Method", "is", "used", "to", "create", "an", "alias", "from", "specified", "parameters", "." ]
2dac08bae098c436031b70f5a09abc365740aee0
https://github.com/Vibius/Facade/blob/2dac08bae098c436031b70f5a09abc365740aee0/src/AliasManager.php#L180-L193
train
dbisso/Hooker
src/Hooker.php
Hooker.hook
public function hook( $hooked_class = null, $hook_prefix = '' ) { $this->hooked_class = $hooked_class; $this->hook_prefix = $hook_prefix; $this->class_reflector = new \ReflectionClass( $this->hooked_class ); $methods = $this->class_reflector->getMethods(); foreach ( $methods as $method ) { $method_parts = $this->parse_method_name( $method->name ); // This method is not for hooking if ( ! $method_parts ) { continue; } $method_reflector = $this->class_reflector->getMethod( $method->name ); $statics = $method_reflector->getStaticVariables(); $defaults = array( 'wp_hook_override' => $method_parts['hook_name'], 'wp_hook_priority' => 10, 'wp_hook_args' => 99, 'hook_type' => $method_parts['hook_type'], 'method' => $method->name, ); $hook_data = array_merge( $defaults, $statics ); if ( isset( $hook_data['wp_shortcode_name'] ) ) { $hook_data['wp_shortcode_name'] = preg_replace( '|_|', '-', $hook_name ); } if ( $hook_data ){ extract( $hook_data ); $this->add_hook( $hook_type, $wp_hook_override, $method, $wp_hook_priority, $wp_hook_args ); } } add_action( 'after_setup_theme', array( $this, 'add_theme_hooks' ), 12 ); return $this; }
php
public function hook( $hooked_class = null, $hook_prefix = '' ) { $this->hooked_class = $hooked_class; $this->hook_prefix = $hook_prefix; $this->class_reflector = new \ReflectionClass( $this->hooked_class ); $methods = $this->class_reflector->getMethods(); foreach ( $methods as $method ) { $method_parts = $this->parse_method_name( $method->name ); // This method is not for hooking if ( ! $method_parts ) { continue; } $method_reflector = $this->class_reflector->getMethod( $method->name ); $statics = $method_reflector->getStaticVariables(); $defaults = array( 'wp_hook_override' => $method_parts['hook_name'], 'wp_hook_priority' => 10, 'wp_hook_args' => 99, 'hook_type' => $method_parts['hook_type'], 'method' => $method->name, ); $hook_data = array_merge( $defaults, $statics ); if ( isset( $hook_data['wp_shortcode_name'] ) ) { $hook_data['wp_shortcode_name'] = preg_replace( '|_|', '-', $hook_name ); } if ( $hook_data ){ extract( $hook_data ); $this->add_hook( $hook_type, $wp_hook_override, $method, $wp_hook_priority, $wp_hook_args ); } } add_action( 'after_setup_theme', array( $this, 'add_theme_hooks' ), 12 ); return $this; }
[ "public", "function", "hook", "(", "$", "hooked_class", "=", "null", ",", "$", "hook_prefix", "=", "''", ")", "{", "$", "this", "->", "hooked_class", "=", "$", "hooked_class", ";", "$", "this", "->", "hook_prefix", "=", "$", "hook_prefix", ";", "$", "this", "->", "class_reflector", "=", "new", "\\", "ReflectionClass", "(", "$", "this", "->", "hooked_class", ")", ";", "$", "methods", "=", "$", "this", "->", "class_reflector", "->", "getMethods", "(", ")", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "$", "method_parts", "=", "$", "this", "->", "parse_method_name", "(", "$", "method", "->", "name", ")", ";", "// This method is not for hooking", "if", "(", "!", "$", "method_parts", ")", "{", "continue", ";", "}", "$", "method_reflector", "=", "$", "this", "->", "class_reflector", "->", "getMethod", "(", "$", "method", "->", "name", ")", ";", "$", "statics", "=", "$", "method_reflector", "->", "getStaticVariables", "(", ")", ";", "$", "defaults", "=", "array", "(", "'wp_hook_override'", "=>", "$", "method_parts", "[", "'hook_name'", "]", ",", "'wp_hook_priority'", "=>", "10", ",", "'wp_hook_args'", "=>", "99", ",", "'hook_type'", "=>", "$", "method_parts", "[", "'hook_type'", "]", ",", "'method'", "=>", "$", "method", "->", "name", ",", ")", ";", "$", "hook_data", "=", "array_merge", "(", "$", "defaults", ",", "$", "statics", ")", ";", "if", "(", "isset", "(", "$", "hook_data", "[", "'wp_shortcode_name'", "]", ")", ")", "{", "$", "hook_data", "[", "'wp_shortcode_name'", "]", "=", "preg_replace", "(", "'|_|'", ",", "'-'", ",", "$", "hook_name", ")", ";", "}", "if", "(", "$", "hook_data", ")", "{", "extract", "(", "$", "hook_data", ")", ";", "$", "this", "->", "add_hook", "(", "$", "hook_type", ",", "$", "wp_hook_override", ",", "$", "method", ",", "$", "wp_hook_priority", ",", "$", "wp_hook_args", ")", ";", "}", "}", "add_action", "(", "'after_setup_theme'", ",", "array", "(", "$", "this", ",", "'add_theme_hooks'", ")", ",", "12", ")", ";", "return", "$", "this", ";", "}" ]
Parses the methods and kicks of the hooking process @param stdClass $hooked_class The class being hooked @param string $hook_prefix Optional prefix for custom theme or plugin hooks @return Hooker Returns the instance of the hooker class
[ "Parses", "the", "methods", "and", "kicks", "of", "the", "hooking", "process" ]
ecb6f0115e2d9932f16d004a17bca221918710a9
https://github.com/dbisso/Hooker/blob/ecb6f0115e2d9932f16d004a17bca221918710a9/src/Hooker.php#L61-L102
train
dbisso/Hooker
src/Hooker.php
Hooker.parse_method_name
private function parse_method_name( $name ){ if ( preg_match( '|^(_?[^_]+_)(.*)$|', $name, $matches ) ) { $hook_type = trim( $matches[1], '_' ); //Methods prefixed with _ are always hooked $hook_name = $matches[2]; if ( ! in_array( $hook_type , array( 'theme', 'action', 'filter', 'shortcode' ) ) ) { return false; } return compact( 'hook_type', 'hook_name' ); } return false; }
php
private function parse_method_name( $name ){ if ( preg_match( '|^(_?[^_]+_)(.*)$|', $name, $matches ) ) { $hook_type = trim( $matches[1], '_' ); //Methods prefixed with _ are always hooked $hook_name = $matches[2]; if ( ! in_array( $hook_type , array( 'theme', 'action', 'filter', 'shortcode' ) ) ) { return false; } return compact( 'hook_type', 'hook_name' ); } return false; }
[ "private", "function", "parse_method_name", "(", "$", "name", ")", "{", "if", "(", "preg_match", "(", "'|^(_?[^_]+_)(.*)$|'", ",", "$", "name", ",", "$", "matches", ")", ")", "{", "$", "hook_type", "=", "trim", "(", "$", "matches", "[", "1", "]", ",", "'_'", ")", ";", "//Methods prefixed with _ are always hooked", "$", "hook_name", "=", "$", "matches", "[", "2", "]", ";", "if", "(", "!", "in_array", "(", "$", "hook_type", ",", "array", "(", "'theme'", ",", "'action'", ",", "'filter'", ",", "'shortcode'", ")", ")", ")", "{", "return", "false", ";", "}", "return", "compact", "(", "'hook_type'", ",", "'hook_name'", ")", ";", "}", "return", "false", ";", "}" ]
Parse the method name to determine how to handle it @param string $name Method name @return mixed Array of hook type (action/filter/theme/shortcode) or false if not a valid hook method
[ "Parse", "the", "method", "name", "to", "determine", "how", "to", "handle", "it" ]
ecb6f0115e2d9932f16d004a17bca221918710a9
https://github.com/dbisso/Hooker/blob/ecb6f0115e2d9932f16d004a17bca221918710a9/src/Hooker.php#L110-L123
train
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/AbstractImage.php
AbstractImage.getUserColor
public final function getUserColor( string $name ) { if ( $this->disposed ) { return null; } if ( ! isset( $this->colors[ $name ] ) ) { throw new ArgumentError( '$name', $name, 'Drawing.Image', 'There is no user color with this name defined for this image!' ); } return $this->colors[ $name ]; }
php
public final function getUserColor( string $name ) { if ( $this->disposed ) { return null; } if ( ! isset( $this->colors[ $name ] ) ) { throw new ArgumentError( '$name', $name, 'Drawing.Image', 'There is no user color with this name defined for this image!' ); } return $this->colors[ $name ]; }
[ "public", "final", "function", "getUserColor", "(", "string", "$", "name", ")", "{", "if", "(", "$", "this", "->", "disposed", ")", "{", "return", "null", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "colors", "[", "$", "name", "]", ")", ")", "{", "throw", "new", "ArgumentError", "(", "'$name'", ",", "$", "name", ",", "'Drawing.Image'", ",", "'There is no user color with this name defined for this image!'", ")", ";", "}", "return", "$", "this", "->", "colors", "[", "$", "name", "]", ";", "}" ]
Returns the user defined color with defined name. @param string $name The user defined color name. @return \Beluga\Drawing\ColorGD @throws \Beluga\ArgumentError
[ "Returns", "the", "user", "defined", "color", "with", "defined", "name", "." ]
9c82874cf4ec68cb0af78757b65f19783540004a
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/AbstractImage.php#L153-L173
train
anime-db/catalog-bundle
src/Service/Storage/ScanExecutor.php
ScanExecutor.export
public function export(StorageEntity $storage) { $output = sprintf($this->output, $storage->getId()); $progress = sprintf($this->progress, $storage->getId()); $this->fs->mkdir([dirname($output), dirname($progress)], 0755); $this->fs->remove([$output, $progress]); $this->fs->dumpFile($output, ''); $this->fs->dumpFile($progress, '0%'); $this->command->send(sprintf( 'php app/console animedb:scan-storage --no-ansi --force --export=%s %s >%s 2>&1', $progress, $storage->getId(), $output )); }
php
public function export(StorageEntity $storage) { $output = sprintf($this->output, $storage->getId()); $progress = sprintf($this->progress, $storage->getId()); $this->fs->mkdir([dirname($output), dirname($progress)], 0755); $this->fs->remove([$output, $progress]); $this->fs->dumpFile($output, ''); $this->fs->dumpFile($progress, '0%'); $this->command->send(sprintf( 'php app/console animedb:scan-storage --no-ansi --force --export=%s %s >%s 2>&1', $progress, $storage->getId(), $output )); }
[ "public", "function", "export", "(", "StorageEntity", "$", "storage", ")", "{", "$", "output", "=", "sprintf", "(", "$", "this", "->", "output", ",", "$", "storage", "->", "getId", "(", ")", ")", ";", "$", "progress", "=", "sprintf", "(", "$", "this", "->", "progress", ",", "$", "storage", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "fs", "->", "mkdir", "(", "[", "dirname", "(", "$", "output", ")", ",", "dirname", "(", "$", "progress", ")", "]", ",", "0755", ")", ";", "$", "this", "->", "fs", "->", "remove", "(", "[", "$", "output", ",", "$", "progress", "]", ")", ";", "$", "this", "->", "fs", "->", "dumpFile", "(", "$", "output", ",", "''", ")", ";", "$", "this", "->", "fs", "->", "dumpFile", "(", "$", "progress", ",", "'0%'", ")", ";", "$", "this", "->", "command", "->", "send", "(", "sprintf", "(", "'php app/console animedb:scan-storage --no-ansi --force --export=%s %s >%s 2>&1'", ",", "$", "progress", ",", "$", "storage", "->", "getId", "(", ")", ",", "$", "output", ")", ")", ";", "}" ]
Scan storage in background and export progress and output. @param StorageEntity $storage
[ "Scan", "storage", "in", "background", "and", "export", "progress", "and", "output", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Service/Storage/ScanExecutor.php#L62-L78
train
geoffadams/bedrest-core
library/BedRest/Service/Mapping/ServiceMetadataFactory.php
ServiceMetadataFactory.getMetadataFor
public function getMetadataFor($className) { if (!$this->isService($className)) { throw Exception::classIsNotMappedService($className); } if (!isset($this->loadedMetadata[$className])) { $this->loadMetadata($className); } if ($this->cache) { $cacheId = $this->cachePrefix . $className . $this->cacheSuffix; if (($cached = $this->cache->fetch($cacheId)) !== false) { $this->loadedMetadata[$className] = $cached; } else { $this->loadMetadata($className); $this->cache->save($cacheId, $this->loadedMetadata[$className], null); } } else { $this->loadMetadata($className); } return $this->loadedMetadata[$className]; }
php
public function getMetadataFor($className) { if (!$this->isService($className)) { throw Exception::classIsNotMappedService($className); } if (!isset($this->loadedMetadata[$className])) { $this->loadMetadata($className); } if ($this->cache) { $cacheId = $this->cachePrefix . $className . $this->cacheSuffix; if (($cached = $this->cache->fetch($cacheId)) !== false) { $this->loadedMetadata[$className] = $cached; } else { $this->loadMetadata($className); $this->cache->save($cacheId, $this->loadedMetadata[$className], null); } } else { $this->loadMetadata($className); } return $this->loadedMetadata[$className]; }
[ "public", "function", "getMetadataFor", "(", "$", "className", ")", "{", "if", "(", "!", "$", "this", "->", "isService", "(", "$", "className", ")", ")", "{", "throw", "Exception", "::", "classIsNotMappedService", "(", "$", "className", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->", "loadedMetadata", "[", "$", "className", "]", ")", ")", "{", "$", "this", "->", "loadMetadata", "(", "$", "className", ")", ";", "}", "if", "(", "$", "this", "->", "cache", ")", "{", "$", "cacheId", "=", "$", "this", "->", "cachePrefix", ".", "$", "className", ".", "$", "this", "->", "cacheSuffix", ";", "if", "(", "(", "$", "cached", "=", "$", "this", "->", "cache", "->", "fetch", "(", "$", "cacheId", ")", ")", "!==", "false", ")", "{", "$", "this", "->", "loadedMetadata", "[", "$", "className", "]", "=", "$", "cached", ";", "}", "else", "{", "$", "this", "->", "loadMetadata", "(", "$", "className", ")", ";", "$", "this", "->", "cache", "->", "save", "(", "$", "cacheId", ",", "$", "this", "->", "loadedMetadata", "[", "$", "className", "]", ",", "null", ")", ";", "}", "}", "else", "{", "$", "this", "->", "loadMetadata", "(", "$", "className", ")", ";", "}", "return", "$", "this", "->", "loadedMetadata", "[", "$", "className", "]", ";", "}" ]
Returns ServiceMetadata for the specified class. @param string $className @throws \BedRest\Service\Mapping\Exception @return \BedRest\Service\Mapping\ServiceMetadata
[ "Returns", "ServiceMetadata", "for", "the", "specified", "class", "." ]
a77bf8b7492dfbfb720b201f7ec91a4f03417b5c
https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Service/Mapping/ServiceMetadataFactory.php#L110-L134
train
geoffadams/bedrest-core
library/BedRest/Service/Mapping/ServiceMetadataFactory.php
ServiceMetadataFactory.getAllMetadata
public function getAllMetadata() { foreach ($this->driver->getAllClassNames() as $className) { if (!isset($this->loadedMetadata[$className])) { $this->loadMetadata($className); } } return $this->loadedMetadata; }
php
public function getAllMetadata() { foreach ($this->driver->getAllClassNames() as $className) { if (!isset($this->loadedMetadata[$className])) { $this->loadMetadata($className); } } return $this->loadedMetadata; }
[ "public", "function", "getAllMetadata", "(", ")", "{", "foreach", "(", "$", "this", "->", "driver", "->", "getAllClassNames", "(", ")", "as", "$", "className", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "loadedMetadata", "[", "$", "className", "]", ")", ")", "{", "$", "this", "->", "loadMetadata", "(", "$", "className", ")", ";", "}", "}", "return", "$", "this", "->", "loadedMetadata", ";", "}" ]
Returns the entire collection of ServiceMetadata objects for all mapped services. @return array
[ "Returns", "the", "entire", "collection", "of", "ServiceMetadata", "objects", "for", "all", "mapped", "services", "." ]
a77bf8b7492dfbfb720b201f7ec91a4f03417b5c
https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Service/Mapping/ServiceMetadataFactory.php#L141-L150
train
geoffadams/bedrest-core
library/BedRest/Service/Mapping/ServiceMetadataFactory.php
ServiceMetadataFactory.loadMetadata
protected function loadMetadata($class) { // first run, we have no parent $parent = null; $parentClasses = $this->getParentClasses($class); $parentClasses[] = $class; // iterate through the list of mapped service parent classes foreach ($parentClasses as $parentClass) { // create an empty metadata class $class = new ServiceMetadata($class); // copy all data from the immediate parent, if present if ($parent) { $class->setClassName($parent->getClassName()); $class->setAllListeners($parent->getAllListeners()); } // now overlay the metadata from the class itself if (!isset($this->loadedMetadata[$parentClass])) { $this->driver->loadMetadataForClass($parentClass, $class); $this->loadedMetadata[$parentClass] = $class; } // the parent for the next iteration will be this iteration $parent = $class; } }
php
protected function loadMetadata($class) { // first run, we have no parent $parent = null; $parentClasses = $this->getParentClasses($class); $parentClasses[] = $class; // iterate through the list of mapped service parent classes foreach ($parentClasses as $parentClass) { // create an empty metadata class $class = new ServiceMetadata($class); // copy all data from the immediate parent, if present if ($parent) { $class->setClassName($parent->getClassName()); $class->setAllListeners($parent->getAllListeners()); } // now overlay the metadata from the class itself if (!isset($this->loadedMetadata[$parentClass])) { $this->driver->loadMetadataForClass($parentClass, $class); $this->loadedMetadata[$parentClass] = $class; } // the parent for the next iteration will be this iteration $parent = $class; } }
[ "protected", "function", "loadMetadata", "(", "$", "class", ")", "{", "// first run, we have no parent", "$", "parent", "=", "null", ";", "$", "parentClasses", "=", "$", "this", "->", "getParentClasses", "(", "$", "class", ")", ";", "$", "parentClasses", "[", "]", "=", "$", "class", ";", "// iterate through the list of mapped service parent classes", "foreach", "(", "$", "parentClasses", "as", "$", "parentClass", ")", "{", "// create an empty metadata class", "$", "class", "=", "new", "ServiceMetadata", "(", "$", "class", ")", ";", "// copy all data from the immediate parent, if present", "if", "(", "$", "parent", ")", "{", "$", "class", "->", "setClassName", "(", "$", "parent", "->", "getClassName", "(", ")", ")", ";", "$", "class", "->", "setAllListeners", "(", "$", "parent", "->", "getAllListeners", "(", ")", ")", ";", "}", "// now overlay the metadata from the class itself", "if", "(", "!", "isset", "(", "$", "this", "->", "loadedMetadata", "[", "$", "parentClass", "]", ")", ")", "{", "$", "this", "->", "driver", "->", "loadMetadataForClass", "(", "$", "parentClass", ",", "$", "class", ")", ";", "$", "this", "->", "loadedMetadata", "[", "$", "parentClass", "]", "=", "$", "class", ";", "}", "// the parent for the next iteration will be this iteration", "$", "parent", "=", "$", "class", ";", "}", "}" ]
Loads the ServiceMetadata for the supplied class. @param string $class
[ "Loads", "the", "ServiceMetadata", "for", "the", "supplied", "class", "." ]
a77bf8b7492dfbfb720b201f7ec91a4f03417b5c
https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Service/Mapping/ServiceMetadataFactory.php#L157-L185
train
geoffadams/bedrest-core
library/BedRest/Service/Mapping/ServiceMetadataFactory.php
ServiceMetadataFactory.getParentClasses
protected function getParentClasses($className) { $parents = array(); foreach (array_reverse(class_parents($className)) as $class) { if ($this->driver->isService($class)) { $parents[] = $class; } } return $parents; }
php
protected function getParentClasses($className) { $parents = array(); foreach (array_reverse(class_parents($className)) as $class) { if ($this->driver->isService($class)) { $parents[] = $class; } } return $parents; }
[ "protected", "function", "getParentClasses", "(", "$", "className", ")", "{", "$", "parents", "=", "array", "(", ")", ";", "foreach", "(", "array_reverse", "(", "class_parents", "(", "$", "className", ")", ")", "as", "$", "class", ")", "{", "if", "(", "$", "this", "->", "driver", "->", "isService", "(", "$", "class", ")", ")", "{", "$", "parents", "[", "]", "=", "$", "class", ";", "}", "}", "return", "$", "parents", ";", "}" ]
Returns the list of parent service classes for the specified class. @param string $className @return array
[ "Returns", "the", "list", "of", "parent", "service", "classes", "for", "the", "specified", "class", "." ]
a77bf8b7492dfbfb720b201f7ec91a4f03417b5c
https://github.com/geoffadams/bedrest-core/blob/a77bf8b7492dfbfb720b201f7ec91a4f03417b5c/library/BedRest/Service/Mapping/ServiceMetadataFactory.php#L204-L215
train
translationexchange/tml-php-clientsdk
library/Tr8n/Cache/Base.php
Base.version
function version() { if ($this->version == null) { $this->version = intval($this->fetch(self::TR8N_VERSION_KEY, Config::instance()->configValue("cache.version", 1))); } return $this->version; }
php
function version() { if ($this->version == null) { $this->version = intval($this->fetch(self::TR8N_VERSION_KEY, Config::instance()->configValue("cache.version", 1))); } return $this->version; }
[ "function", "version", "(", ")", "{", "if", "(", "$", "this", "->", "version", "==", "null", ")", "{", "$", "this", "->", "version", "=", "intval", "(", "$", "this", "->", "fetch", "(", "self", "::", "TR8N_VERSION_KEY", ",", "Config", "::", "instance", "(", ")", "->", "configValue", "(", "\"cache.version\"", ",", "1", ")", ")", ")", ";", "}", "return", "$", "this", "->", "version", ";", "}" ]
Returns current cache version @return integer
[ "Returns", "current", "cache", "version" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Cache/Base.php#L105-L110
train
translationexchange/tml-php-clientsdk
library/Tr8n/Cache/Base.php
Base.versionedKey
function versionedKey($key) { if ($key == self::TR8N_VERSION_KEY) return $key; return self::TR8N_KEY_PREFIX . $this->version() . "_" . $key; }
php
function versionedKey($key) { if ($key == self::TR8N_VERSION_KEY) return $key; return self::TR8N_KEY_PREFIX . $this->version() . "_" . $key; }
[ "function", "versionedKey", "(", "$", "key", ")", "{", "if", "(", "$", "key", "==", "self", "::", "TR8N_VERSION_KEY", ")", "return", "$", "key", ";", "return", "self", "::", "TR8N_KEY_PREFIX", ".", "$", "this", "->", "version", "(", ")", ".", "\"_\"", ".", "$", "key", ";", "}" ]
Appends version to a key @param string $key @return string
[ "Appends", "version", "to", "a", "key" ]
fe51473824e62cfd883c6aa0c6a3783a16ce8425
https://github.com/translationexchange/tml-php-clientsdk/blob/fe51473824e62cfd883c6aa0c6a3783a16ce8425/library/Tr8n/Cache/Base.php#L127-L130
train
froq/froq-validation
src/Validation.php
Validation.setFails
public function setFails(array $fails = null): void { if (!empty($fails)) { foreach ($fails as $fieldName => $fail) { $this->fails[$fieldName] = $fail; } } }
php
public function setFails(array $fails = null): void { if (!empty($fails)) { foreach ($fails as $fieldName => $fail) { $this->fails[$fieldName] = $fail; } } }
[ "public", "function", "setFails", "(", "array", "$", "fails", "=", "null", ")", ":", "void", "{", "if", "(", "!", "empty", "(", "$", "fails", ")", ")", "{", "foreach", "(", "$", "fails", "as", "$", "fieldName", "=>", "$", "fail", ")", "{", "$", "this", "->", "fails", "[", "$", "fieldName", "]", "=", "$", "fail", ";", "}", "}", "}" ]
Set fails. @param array $fails @return void
[ "Set", "fails", "." ]
42727e1f3655ec94266bc36dcb328455c4a9ee87
https://github.com/froq/froq-validation/blob/42727e1f3655ec94266bc36dcb328455c4a9ee87/src/Validation.php#L194-L201
train
covex-nn/TwigCallableBridgeBundle
src/Covex/TwigCallableBridgeBundle/DependencyInjection/Configuration.php
Configuration.createExtensionNode
private function createExtensionNode(ArrayNodeDefinition $rootNode, $name, $validator) { $rootNode ->children() /**/->arrayNode($name) /* */->addDefaultChildrenIfNoneSet(array()) /* */->requiresAtLeastOneElement() /* */->useAttributeAsKey('name') /* */->prototype('variable') /* */->validate() /* */->ifTrue($validator) /* */->thenInvalid('Configuration value must be callable') /* */->end() /* */->end() /**/->end() ->end(); }
php
private function createExtensionNode(ArrayNodeDefinition $rootNode, $name, $validator) { $rootNode ->children() /**/->arrayNode($name) /* */->addDefaultChildrenIfNoneSet(array()) /* */->requiresAtLeastOneElement() /* */->useAttributeAsKey('name') /* */->prototype('variable') /* */->validate() /* */->ifTrue($validator) /* */->thenInvalid('Configuration value must be callable') /* */->end() /* */->end() /**/->end() ->end(); }
[ "private", "function", "createExtensionNode", "(", "ArrayNodeDefinition", "$", "rootNode", ",", "$", "name", ",", "$", "validator", ")", "{", "$", "rootNode", "->", "children", "(", ")", "/**/", "->", "arrayNode", "(", "$", "name", ")", "/* */", "->", "addDefaultChildrenIfNoneSet", "(", "array", "(", ")", ")", "/* */", "->", "requiresAtLeastOneElement", "(", ")", "/* */", "->", "useAttributeAsKey", "(", "'name'", ")", "/* */", "->", "prototype", "(", "'variable'", ")", "/* */", "->", "validate", "(", ")", "/* */", "->", "ifTrue", "(", "$", "validator", ")", "/* */", "->", "thenInvalid", "(", "'Configuration value must be callable'", ")", "/* */", "->", "end", "(", ")", "/* */", "->", "end", "(", ")", "/**/", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Create configuration section @param ArrayNodeDefinition $rootNode Root node @param string $name New configuration section name @param callable $validator Config value validator @return null
[ "Create", "configuration", "section" ]
2e79f06158182522fd3c6b64c3ac907239a576bf
https://github.com/covex-nn/TwigCallableBridgeBundle/blob/2e79f06158182522fd3c6b64c3ac907239a576bf/src/Covex/TwigCallableBridgeBundle/DependencyInjection/Configuration.php#L47-L63
train
clacy-builders/graphics-php
src/Point.php
Point.rotate
public function rotate(Point $center, Angle $angle) { $x = $this->x - $center->x; $y = $this->y - $center->y; $this->x = $x * $angle->cos - $y * $angle->sin + $center->x; $this->y = $y * $angle->cos + $x * $angle->sin + $center->y; return $this; }
php
public function rotate(Point $center, Angle $angle) { $x = $this->x - $center->x; $y = $this->y - $center->y; $this->x = $x * $angle->cos - $y * $angle->sin + $center->x; $this->y = $y * $angle->cos + $x * $angle->sin + $center->y; return $this; }
[ "public", "function", "rotate", "(", "Point", "$", "center", ",", "Angle", "$", "angle", ")", "{", "$", "x", "=", "$", "this", "->", "x", "-", "$", "center", "->", "x", ";", "$", "y", "=", "$", "this", "->", "y", "-", "$", "center", "->", "y", ";", "$", "this", "->", "x", "=", "$", "x", "*", "$", "angle", "->", "cos", "-", "$", "y", "*", "$", "angle", "->", "sin", "+", "$", "center", "->", "x", ";", "$", "this", "->", "y", "=", "$", "y", "*", "$", "angle", "->", "cos", "+", "$", "x", "*", "$", "angle", "->", "sin", "+", "$", "center", "->", "y", ";", "return", "$", "this", ";", "}" ]
Rotates current point clockwise. @param Point $center @param Angle $angle @return Point
[ "Rotates", "current", "point", "clockwise", "." ]
c56556c9265ea4537efdc14ae89a8f36454812d9
https://github.com/clacy-builders/graphics-php/blob/c56556c9265ea4537efdc14ae89a8f36454812d9/src/Point.php#L33-L40
train
RichardTrujilloTorres/validators
src/Validators/Traits/NumericalComparisonsTrait.php
NumericalComparisonsTrait.min
public function min($limit) { $result = $this->compare($limit, '<'); $this->setValid($result); return $this; }
php
public function min($limit) { $result = $this->compare($limit, '<'); $this->setValid($result); return $this; }
[ "public", "function", "min", "(", "$", "limit", ")", "{", "$", "result", "=", "$", "this", "->", "compare", "(", "$", "limit", ",", "'<'", ")", ";", "$", "this", "->", "setValid", "(", "$", "result", ")", ";", "return", "$", "this", ";", "}" ]
Sets the minimum limit. @param numerical $limit The limit @return $self
[ "Sets", "the", "minimum", "limit", "." ]
e29ff479d816c3f8a931bfbefedd0642dc50ea91
https://github.com/RichardTrujilloTorres/validators/blob/e29ff479d816c3f8a931bfbefedd0642dc50ea91/src/Validators/Traits/NumericalComparisonsTrait.php#L17-L23
train
RichardTrujilloTorres/validators
src/Validators/Traits/NumericalComparisonsTrait.php
NumericalComparisonsTrait.max
public function max($limit) { $result = $this->compare($limit, '>'); $this->setValid($result); return $this; }
php
public function max($limit) { $result = $this->compare($limit, '>'); $this->setValid($result); return $this; }
[ "public", "function", "max", "(", "$", "limit", ")", "{", "$", "result", "=", "$", "this", "->", "compare", "(", "$", "limit", ",", "'>'", ")", ";", "$", "this", "->", "setValid", "(", "$", "result", ")", ";", "return", "$", "this", ";", "}" ]
Sets the maximum limit. @param numerical $limit The limit @return $self
[ "Sets", "the", "maximum", "limit", "." ]
e29ff479d816c3f8a931bfbefedd0642dc50ea91
https://github.com/RichardTrujilloTorres/validators/blob/e29ff479d816c3f8a931bfbefedd0642dc50ea91/src/Validators/Traits/NumericalComparisonsTrait.php#L32-L38
train
ARCANESOFT/Auth
src/Providers/RouteServiceProvider.php
RouteServiceProvider.mapAdminRoutes
protected function mapAdminRoutes() { Routes\Admin\ProfileRoutes::register(); $this->prefix($this->config()->get('arcanesoft.auth.route.prefix', 'authorization')) ->group(function () { Routes\Admin\StatsRoutes::register(); Routes\Admin\UsersRoutes::register(); Routes\Admin\RolesRoutes::register(); Routes\Admin\PermissionsRoutes::register(); Routes\Admin\PasswordResetsRoutes::register(); }); }
php
protected function mapAdminRoutes() { Routes\Admin\ProfileRoutes::register(); $this->prefix($this->config()->get('arcanesoft.auth.route.prefix', 'authorization')) ->group(function () { Routes\Admin\StatsRoutes::register(); Routes\Admin\UsersRoutes::register(); Routes\Admin\RolesRoutes::register(); Routes\Admin\PermissionsRoutes::register(); Routes\Admin\PasswordResetsRoutes::register(); }); }
[ "protected", "function", "mapAdminRoutes", "(", ")", "{", "Routes", "\\", "Admin", "\\", "ProfileRoutes", "::", "register", "(", ")", ";", "$", "this", "->", "prefix", "(", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'arcanesoft.auth.route.prefix'", ",", "'authorization'", ")", ")", "->", "group", "(", "function", "(", ")", "{", "Routes", "\\", "Admin", "\\", "StatsRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "UsersRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "RolesRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "PermissionsRoutes", "::", "register", "(", ")", ";", "Routes", "\\", "Admin", "\\", "PasswordResetsRoutes", "::", "register", "(", ")", ";", "}", ")", ";", "}" ]
Define the foundation routes for the application.
[ "Define", "the", "foundation", "routes", "for", "the", "application", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/Providers/RouteServiceProvider.php#L52-L64
train
sndsgd/error
src/Error.php
Error.createMessage
public static function createMessage(string $message): string { $lastErrorMessage = error_get_last(); if ($lastErrorMessage !== null) { $message .= "; ".$lastErrorMessage["message"]; } return $message; }
php
public static function createMessage(string $message): string { $lastErrorMessage = error_get_last(); if ($lastErrorMessage !== null) { $message .= "; ".$lastErrorMessage["message"]; } return $message; }
[ "public", "static", "function", "createMessage", "(", "string", "$", "message", ")", ":", "string", "{", "$", "lastErrorMessage", "=", "error_get_last", "(", ")", ";", "if", "(", "$", "lastErrorMessage", "!==", "null", ")", "{", "$", "message", ".=", "\"; \"", ".", "$", "lastErrorMessage", "[", "\"message\"", "]", ";", "}", "return", "$", "message", ";", "}" ]
Append a message with the message from the last encountered error @param string $message The message to append @return string
[ "Append", "a", "message", "with", "the", "message", "from", "the", "last", "encountered", "error" ]
5393b06cd654f826db2b0eb212ea0ae6f9365e56
https://github.com/sndsgd/error/blob/5393b06cd654f826db2b0eb212ea0ae6f9365e56/src/Error.php#L13-L20
train
dms-org/common.structure
src/DateTime/TimeOfDay.php
TimeOfDay.fromNative
public static function fromNative(\DateTimeInterface $dateTime) : TimeOfDay { return new self((int)$dateTime->format('H'), (int)$dateTime->format('i'), (int)$dateTime->format('s')); }
php
public static function fromNative(\DateTimeInterface $dateTime) : TimeOfDay { return new self((int)$dateTime->format('H'), (int)$dateTime->format('i'), (int)$dateTime->format('s')); }
[ "public", "static", "function", "fromNative", "(", "\\", "DateTimeInterface", "$", "dateTime", ")", ":", "TimeOfDay", "{", "return", "new", "self", "(", "(", "int", ")", "$", "dateTime", "->", "format", "(", "'H'", ")", ",", "(", "int", ")", "$", "dateTime", "->", "format", "(", "'i'", ")", ",", "(", "int", ")", "$", "dateTime", "->", "format", "(", "'s'", ")", ")", ";", "}" ]
Creates a time object from the time part of the supplied date time. @param \DateTimeInterface $dateTime @return TimeOfDay
[ "Creates", "a", "time", "object", "from", "the", "time", "part", "of", "the", "supplied", "date", "time", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/TimeOfDay.php#L48-L51
train
dms-org/common.structure
src/DateTime/TimeOfDay.php
TimeOfDay.fromFormat
public static function fromFormat(string $format, string $timeString) : TimeOfDay { return self::fromNative(\DateTimeImmutable::createFromFormat($format, $timeString)); }
php
public static function fromFormat(string $format, string $timeString) : TimeOfDay { return self::fromNative(\DateTimeImmutable::createFromFormat($format, $timeString)); }
[ "public", "static", "function", "fromFormat", "(", "string", "$", "format", ",", "string", "$", "timeString", ")", ":", "TimeOfDay", "{", "return", "self", "::", "fromNative", "(", "\\", "DateTimeImmutable", "::", "createFromFormat", "(", "$", "format", ",", "$", "timeString", ")", ")", ";", "}" ]
Creates a time object from the supplied format string @param string $format @param string $timeString @return TimeOfDay
[ "Creates", "a", "time", "object", "from", "the", "supplied", "format", "string" ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/TimeOfDay.php#L61-L64
train
dms-org/common.structure
src/DateTime/TimeOfDay.php
TimeOfDay.fromString
public static function fromString(string $timeString) : TimeOfDay { $parts = array_map('intval', explode(':', $timeString)) + [1 => 0, 2 => 0]; return new self($parts[0], $parts[1], $parts[2]); }
php
public static function fromString(string $timeString) : TimeOfDay { $parts = array_map('intval', explode(':', $timeString)) + [1 => 0, 2 => 0]; return new self($parts[0], $parts[1], $parts[2]); }
[ "public", "static", "function", "fromString", "(", "string", "$", "timeString", ")", ":", "TimeOfDay", "{", "$", "parts", "=", "array_map", "(", "'intval'", ",", "explode", "(", "':'", ",", "$", "timeString", ")", ")", "+", "[", "1", "=>", "0", ",", "2", "=>", "0", "]", ";", "return", "new", "self", "(", "$", "parts", "[", "0", "]", ",", "$", "parts", "[", "1", "]", ",", "$", "parts", "[", "2", "]", ")", ";", "}" ]
Creates a time object from the supplied 24 hour time string Expected format: HH[:MM[:SS]] @param string $timeString @return TimeOfDay
[ "Creates", "a", "time", "object", "from", "the", "supplied", "24", "hour", "time", "string" ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/TimeOfDay.php#L75-L79
train
dms-org/common.structure
src/DateTime/TimeOfDay.php
TimeOfDay.secondsBetween
public function secondsBetween(TimeOfDay $other) : int { return abs($this->dateTime->getTimestamp() - $other->dateTime->getTimestamp()); }
php
public function secondsBetween(TimeOfDay $other) : int { return abs($this->dateTime->getTimestamp() - $other->dateTime->getTimestamp()); }
[ "public", "function", "secondsBetween", "(", "TimeOfDay", "$", "other", ")", ":", "int", "{", "return", "abs", "(", "$", "this", "->", "dateTime", "->", "getTimestamp", "(", ")", "-", "$", "other", "->", "dateTime", "->", "getTimestamp", "(", ")", ")", ";", "}" ]
Returns the amount of seconds between the supplied times. @param TimeOfDay $other @return int
[ "Returns", "the", "amount", "of", "seconds", "between", "the", "supplied", "times", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/DateTime/TimeOfDay.php#L180-L183
train
hamlet-framework/http
src/Requests/RequestTrait.php
RequestTrait.matchTokens
protected function matchTokens(array $pathTokens, array $patternTokens) { $matches = []; for ($i = 1; $i < count($patternTokens); $i++) { $pathToken = $pathTokens[$i]; $patternToken = $patternTokens[$i]; if ($pathToken == '' && $patternToken != '') { return false; } if ($patternToken == '*') { continue; } if (substr($patternToken, 0, 1) == '{') { $matches[substr($patternToken, 1, -1)] = urldecode($pathToken); } else if (urldecode($pathToken) != $patternToken) { return false; } } if (empty($matches)) { return true; } return $matches; }
php
protected function matchTokens(array $pathTokens, array $patternTokens) { $matches = []; for ($i = 1; $i < count($patternTokens); $i++) { $pathToken = $pathTokens[$i]; $patternToken = $patternTokens[$i]; if ($pathToken == '' && $patternToken != '') { return false; } if ($patternToken == '*') { continue; } if (substr($patternToken, 0, 1) == '{') { $matches[substr($patternToken, 1, -1)] = urldecode($pathToken); } else if (urldecode($pathToken) != $patternToken) { return false; } } if (empty($matches)) { return true; } return $matches; }
[ "protected", "function", "matchTokens", "(", "array", "$", "pathTokens", ",", "array", "$", "patternTokens", ")", "{", "$", "matches", "=", "[", "]", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "count", "(", "$", "patternTokens", ")", ";", "$", "i", "++", ")", "{", "$", "pathToken", "=", "$", "pathTokens", "[", "$", "i", "]", ";", "$", "patternToken", "=", "$", "patternTokens", "[", "$", "i", "]", ";", "if", "(", "$", "pathToken", "==", "''", "&&", "$", "patternToken", "!=", "''", ")", "{", "return", "false", ";", "}", "if", "(", "$", "patternToken", "==", "'*'", ")", "{", "continue", ";", "}", "if", "(", "substr", "(", "$", "patternToken", ",", "0", ",", "1", ")", "==", "'{'", ")", "{", "$", "matches", "[", "substr", "(", "$", "patternToken", ",", "1", ",", "-", "1", ")", "]", "=", "urldecode", "(", "$", "pathToken", ")", ";", "}", "else", "if", "(", "urldecode", "(", "$", "pathToken", ")", "!=", "$", "patternToken", ")", "{", "return", "false", ";", "}", "}", "if", "(", "empty", "(", "$", "matches", ")", ")", "{", "return", "true", ";", "}", "return", "$", "matches", ";", "}" ]
Compare path tokens side by side. Returns false if no match, true if match without capture, and array with matched tokens if used with capturing pattern @param string[] $pathTokens @param string[] $patternTokens @return array<string,string>|bool
[ "Compare", "path", "tokens", "side", "by", "side", ".", "Returns", "false", "if", "no", "match", "true", "if", "match", "without", "capture", "and", "array", "with", "matched", "tokens", "if", "used", "with", "capturing", "pattern" ]
1d3f2a05d2914b678bf05bb53effccace82787c1
https://github.com/hamlet-framework/http/blob/1d3f2a05d2914b678bf05bb53effccace82787c1/src/Requests/RequestTrait.php#L94-L116
train
donbidon/lib-fs
src/Logger.php
Logger.setDefaults
public function setDefaults(array $options, bool $override = FALSE): void { $this->defaults = $options + ($override ? [] : [ 'path' => null, 'maxSize' => self::DEFAULT_MAX_SIZE, 'rotation' => 0, 'rights' => null, ]); }
php
public function setDefaults(array $options, bool $override = FALSE): void { $this->defaults = $options + ($override ? [] : [ 'path' => null, 'maxSize' => self::DEFAULT_MAX_SIZE, 'rotation' => 0, 'rights' => null, ]); }
[ "public", "function", "setDefaults", "(", "array", "$", "options", ",", "bool", "$", "override", "=", "FALSE", ")", ":", "void", "{", "$", "this", "->", "defaults", "=", "$", "options", "+", "(", "$", "override", "?", "[", "]", ":", "[", "'path'", "=>", "null", ",", "'maxSize'", "=>", "self", "::", "DEFAULT_MAX_SIZE", ",", "'rotation'", "=>", "0", ",", "'rights'", "=>", "null", ",", "]", ")", ";", "}" ]
Sets default options. @param array $options @param bool $override Flag specifying do override whole defaults @return void @see self::__construct() $options parameter description
[ "Sets", "default", "options", "." ]
f0f131f2b0c1c4c7fdf075869242619fe1dcaa51
https://github.com/donbidon/lib-fs/blob/f0f131f2b0c1c4c7fdf075869242619fe1dcaa51/src/Logger.php#L76-L85
train
donbidon/lib-fs
src/Logger.php
Logger.log
public function log(string $message, string $path = null, array $options = []): void { $options = $options + (is_null($path) ? [] : ['path' => $path]) + $this->defaults; $path = $options['path']; if (is_null($path)) { throw new \RuntimeException("Missing path"); } $realPath = realpath(dirname($path)); if (FALSE === $realPath) { throw new \RuntimeException(sprintf( "Invalid directory '%s'", $path )); } $path = sprintf( "%s/%s", $realPath, basename($path) ); clearstatcache(true, $path); if (file_exists($path) && (filesize($path) > $options['maxSize'])) { for ($i = $options['rotation']; $i > 0; --$i) { $destPath = sprintf("%s.%d", $path, $i); if (file_exists($destPath)) { unlink($destPath); } $sourcePath = $i > 1 ? sprintf("%s.%d", $path, $i - 1) : $path; if (file_exists($sourcePath)) { rename($sourcePath, $destPath); } } if (file_exists($path)) { unlink($path); } } file_put_contents($path, $message, FILE_APPEND); if (!is_null($options['rights'])) { chmod($path, $options['rights']); } }
php
public function log(string $message, string $path = null, array $options = []): void { $options = $options + (is_null($path) ? [] : ['path' => $path]) + $this->defaults; $path = $options['path']; if (is_null($path)) { throw new \RuntimeException("Missing path"); } $realPath = realpath(dirname($path)); if (FALSE === $realPath) { throw new \RuntimeException(sprintf( "Invalid directory '%s'", $path )); } $path = sprintf( "%s/%s", $realPath, basename($path) ); clearstatcache(true, $path); if (file_exists($path) && (filesize($path) > $options['maxSize'])) { for ($i = $options['rotation']; $i > 0; --$i) { $destPath = sprintf("%s.%d", $path, $i); if (file_exists($destPath)) { unlink($destPath); } $sourcePath = $i > 1 ? sprintf("%s.%d", $path, $i - 1) : $path; if (file_exists($sourcePath)) { rename($sourcePath, $destPath); } } if (file_exists($path)) { unlink($path); } } file_put_contents($path, $message, FILE_APPEND); if (!is_null($options['rights'])) { chmod($path, $options['rights']); } }
[ "public", "function", "log", "(", "string", "$", "message", ",", "string", "$", "path", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", ":", "void", "{", "$", "options", "=", "$", "options", "+", "(", "is_null", "(", "$", "path", ")", "?", "[", "]", ":", "[", "'path'", "=>", "$", "path", "]", ")", "+", "$", "this", "->", "defaults", ";", "$", "path", "=", "$", "options", "[", "'path'", "]", ";", "if", "(", "is_null", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Missing path\"", ")", ";", "}", "$", "realPath", "=", "realpath", "(", "dirname", "(", "$", "path", ")", ")", ";", "if", "(", "FALSE", "===", "$", "realPath", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"Invalid directory '%s'\"", ",", "$", "path", ")", ")", ";", "}", "$", "path", "=", "sprintf", "(", "\"%s/%s\"", ",", "$", "realPath", ",", "basename", "(", "$", "path", ")", ")", ";", "clearstatcache", "(", "true", ",", "$", "path", ")", ";", "if", "(", "file_exists", "(", "$", "path", ")", "&&", "(", "filesize", "(", "$", "path", ")", ">", "$", "options", "[", "'maxSize'", "]", ")", ")", "{", "for", "(", "$", "i", "=", "$", "options", "[", "'rotation'", "]", ";", "$", "i", ">", "0", ";", "--", "$", "i", ")", "{", "$", "destPath", "=", "sprintf", "(", "\"%s.%d\"", ",", "$", "path", ",", "$", "i", ")", ";", "if", "(", "file_exists", "(", "$", "destPath", ")", ")", "{", "unlink", "(", "$", "destPath", ")", ";", "}", "$", "sourcePath", "=", "$", "i", ">", "1", "?", "sprintf", "(", "\"%s.%d\"", ",", "$", "path", ",", "$", "i", "-", "1", ")", ":", "$", "path", ";", "if", "(", "file_exists", "(", "$", "sourcePath", ")", ")", "{", "rename", "(", "$", "sourcePath", ",", "$", "destPath", ")", ";", "}", "}", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "unlink", "(", "$", "path", ")", ";", "}", "}", "file_put_contents", "(", "$", "path", ",", "$", "message", ",", "FILE_APPEND", ")", ";", "if", "(", "!", "is_null", "(", "$", "options", "[", "'rights'", "]", ")", ")", "{", "chmod", "(", "$", "path", ",", "$", "options", "[", "'rights'", "]", ")", ";", "}", "}" ]
Rotate log files and logs message. @param string $message @param string $path If null passed will be used from options @param array $options @return void @throws \RuntimeException If path taken from args and options are missing. @throws \RuntimeException If directory from path is invalid. @see self::__construct() $options parameter description
[ "Rotate", "log", "files", "and", "logs", "message", "." ]
f0f131f2b0c1c4c7fdf075869242619fe1dcaa51
https://github.com/donbidon/lib-fs/blob/f0f131f2b0c1c4c7fdf075869242619fe1dcaa51/src/Logger.php#L101-L143
train
mossphp/moss-storage
Moss/Storage/Model/ModelBag.php
ModelBag.all
public function all($array = []) { if (!empty($array)) { foreach ($array as $key => $model) { $this->set($model, is_numeric($key) ? null : $key); } } return $this->byAlias; }
php
public function all($array = []) { if (!empty($array)) { foreach ($array as $key => $model) { $this->set($model, is_numeric($key) ? null : $key); } } return $this->byAlias; }
[ "public", "function", "all", "(", "$", "array", "=", "[", "]", ")", "{", "if", "(", "!", "empty", "(", "$", "array", ")", ")", "{", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "model", ")", "{", "$", "this", "->", "set", "(", "$", "model", ",", "is_numeric", "(", "$", "key", ")", "?", "null", ":", "$", "key", ")", ";", "}", "}", "return", "$", "this", "->", "byAlias", ";", "}" ]
Returns all options If array passed, becomes bag content @param array $array overwrites values @return ModelInterface[]
[ "Returns", "all", "options", "If", "array", "passed", "becomes", "bag", "content" ]
0d123e7ae6bbfce1e2a18e73bf70997277b430c1
https://github.com/mossphp/moss-storage/blob/0d123e7ae6bbfce1e2a18e73bf70997277b430c1/Moss/Storage/Model/ModelBag.php#L123-L132
train
FuzeWorks/Core
src/FuzeWorks/Logger.php
Logger.errorHandler
public static function errorHandler($type = E_USER_NOTICE, $error = 'Undefined Error', $errFile = null, $errLine = null, $context = null) { // Check type $thisType = self::getType($type); $LOG = array('type' => (!is_null($thisType) ? $thisType : 'ERROR'), 'message' => (!is_null($error) ? $error : ''), 'logFile' => (!is_null($errFile) ? $errFile : ''), 'logLine' => (!is_null($errLine) ? $errLine : ''), 'context' => (!is_null($context) ? $context : ''), 'runtime' => round(self::getRelativeTime(), 4),); self::$Logs[] = $LOG; }
php
public static function errorHandler($type = E_USER_NOTICE, $error = 'Undefined Error', $errFile = null, $errLine = null, $context = null) { // Check type $thisType = self::getType($type); $LOG = array('type' => (!is_null($thisType) ? $thisType : 'ERROR'), 'message' => (!is_null($error) ? $error : ''), 'logFile' => (!is_null($errFile) ? $errFile : ''), 'logLine' => (!is_null($errLine) ? $errLine : ''), 'context' => (!is_null($context) ? $context : ''), 'runtime' => round(self::getRelativeTime(), 4),); self::$Logs[] = $LOG; }
[ "public", "static", "function", "errorHandler", "(", "$", "type", "=", "E_USER_NOTICE", ",", "$", "error", "=", "'Undefined Error'", ",", "$", "errFile", "=", "null", ",", "$", "errLine", "=", "null", ",", "$", "context", "=", "null", ")", "{", "// Check type", "$", "thisType", "=", "self", "::", "getType", "(", "$", "type", ")", ";", "$", "LOG", "=", "array", "(", "'type'", "=>", "(", "!", "is_null", "(", "$", "thisType", ")", "?", "$", "thisType", ":", "'ERROR'", ")", ",", "'message'", "=>", "(", "!", "is_null", "(", "$", "error", ")", "?", "$", "error", ":", "''", ")", ",", "'logFile'", "=>", "(", "!", "is_null", "(", "$", "errFile", ")", "?", "$", "errFile", ":", "''", ")", ",", "'logLine'", "=>", "(", "!", "is_null", "(", "$", "errLine", ")", "?", "$", "errLine", ":", "''", ")", ",", "'context'", "=>", "(", "!", "is_null", "(", "$", "context", ")", "?", "$", "context", ":", "''", ")", ",", "'runtime'", "=>", "round", "(", "self", "::", "getRelativeTime", "(", ")", ",", "4", ")", ",", ")", ";", "self", "::", "$", "Logs", "[", "]", "=", "$", "LOG", ";", "}" ]
System that redirects the errors to the appropriate logging method. @param int $type Error-type, Pre defined PHP Constant @param string error. The error itself @param string File. The absolute path of the file @param int Line. The line on which the error occured. @param array context. Some of the error's relevant variables
[ "System", "that", "redirects", "the", "errors", "to", "the", "appropriate", "logging", "method", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Logger.php#L195-L206
train
FuzeWorks/Core
src/FuzeWorks/Logger.php
Logger.exceptionHandler
public static function exceptionHandler($exception) { $message = $exception->getMessage(); $code = $exception->getCode(); $file = $exception->getFile(); $line = $exception->getLine(); $context = $exception->getTraceAsString(); self::logError('Exception thrown: ' . $message . ' | ' . $code, null, $file, $line); // And return a 500 because this error was fatal self::http_error('500'); }
php
public static function exceptionHandler($exception) { $message = $exception->getMessage(); $code = $exception->getCode(); $file = $exception->getFile(); $line = $exception->getLine(); $context = $exception->getTraceAsString(); self::logError('Exception thrown: ' . $message . ' | ' . $code, null, $file, $line); // And return a 500 because this error was fatal self::http_error('500'); }
[ "public", "static", "function", "exceptionHandler", "(", "$", "exception", ")", "{", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ";", "$", "code", "=", "$", "exception", "->", "getCode", "(", ")", ";", "$", "file", "=", "$", "exception", "->", "getFile", "(", ")", ";", "$", "line", "=", "$", "exception", "->", "getLine", "(", ")", ";", "$", "context", "=", "$", "exception", "->", "getTraceAsString", "(", ")", ";", "self", "::", "logError", "(", "'Exception thrown: '", ".", "$", "message", ".", "' | '", ".", "$", "code", ",", "null", ",", "$", "file", ",", "$", "line", ")", ";", "// And return a 500 because this error was fatal", "self", "::", "http_error", "(", "'500'", ")", ";", "}" ]
Exception handler Will be triggered when an uncaught exception occures. This function shows the error-message, and shuts down the script. Please note that most of the user-defined exceptions will be caught in the router, and handled with the error-controller. @param Exception $exception The occured exception.
[ "Exception", "handler", "Will", "be", "triggered", "when", "an", "uncaught", "exception", "occures", ".", "This", "function", "shows", "the", "error", "-", "message", "and", "shuts", "down", "the", "script", ".", "Please", "note", "that", "most", "of", "the", "user", "-", "defined", "exceptions", "will", "be", "caught", "in", "the", "router", "and", "handled", "with", "the", "error", "-", "controller", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Logger.php#L215-L227
train
FuzeWorks/Core
src/FuzeWorks/Logger.php
Logger.logToScreen
public static function logToScreen() { // Send a screenLogEvent, allows for new screen log designs $event = Events::fireEvent('screenLogEvent'); if ($event->isCancelled()) { return false; } $logs = self::$Logs; require(dirname(__DIR__) . DS . 'Layout' . DS . 'layout.' . self::$logger_template . '.php'); }
php
public static function logToScreen() { // Send a screenLogEvent, allows for new screen log designs $event = Events::fireEvent('screenLogEvent'); if ($event->isCancelled()) { return false; } $logs = self::$Logs; require(dirname(__DIR__) . DS . 'Layout' . DS . 'layout.' . self::$logger_template . '.php'); }
[ "public", "static", "function", "logToScreen", "(", ")", "{", "// Send a screenLogEvent, allows for new screen log designs", "$", "event", "=", "Events", "::", "fireEvent", "(", "'screenLogEvent'", ")", ";", "if", "(", "$", "event", "->", "isCancelled", "(", ")", ")", "{", "return", "false", ";", "}", "$", "logs", "=", "self", "::", "$", "Logs", ";", "require", "(", "dirname", "(", "__DIR__", ")", ".", "DS", ".", "'Layout'", ".", "DS", ".", "'layout.'", ".", "self", "::", "$", "logger_template", ".", "'.php'", ")", ";", "}" ]
Output the entire log to the screen. Used for debugging problems with your code. @codeCoverageIgnore
[ "Output", "the", "entire", "log", "to", "the", "screen", ".", "Used", "for", "debugging", "problems", "with", "your", "code", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Logger.php#L245-L255
train
FuzeWorks/Core
src/FuzeWorks/Logger.php
Logger.logToFile
public static function logToFile() { ob_start(function () {}); $logs = self::$Logs; require(dirname(__DIR__) . DS . 'Layout' . DS . 'layout.logger_cli.php'); $contents = ob_get_clean(); $file = Core::$logDir . DS . 'Logs' . DS . 'log_latest.php'; if (is_writable($file)) { file_put_contents($file, '<?php ' . $contents); } }
php
public static function logToFile() { ob_start(function () {}); $logs = self::$Logs; require(dirname(__DIR__) . DS . 'Layout' . DS . 'layout.logger_cli.php'); $contents = ob_get_clean(); $file = Core::$logDir . DS . 'Logs' . DS . 'log_latest.php'; if (is_writable($file)) { file_put_contents($file, '<?php ' . $contents); } }
[ "public", "static", "function", "logToFile", "(", ")", "{", "ob_start", "(", "function", "(", ")", "{", "}", ")", ";", "$", "logs", "=", "self", "::", "$", "Logs", ";", "require", "(", "dirname", "(", "__DIR__", ")", ".", "DS", ".", "'Layout'", ".", "DS", ".", "'layout.logger_cli.php'", ")", ";", "$", "contents", "=", "ob_get_clean", "(", ")", ";", "$", "file", "=", "Core", "::", "$", "logDir", ".", "DS", ".", "'Logs'", ".", "DS", ".", "'log_latest.php'", ";", "if", "(", "is_writable", "(", "$", "file", ")", ")", "{", "file_put_contents", "(", "$", "file", ",", "'<?php '", ".", "$", "contents", ")", ";", "}", "}" ]
Output the entire log to a file. Used for debugging problems with your code. @codeCoverageIgnore
[ "Output", "the", "entire", "log", "to", "a", "file", ".", "Used", "for", "debugging", "problems", "with", "your", "code", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Logger.php#L261-L272
train
FuzeWorks/Core
src/FuzeWorks/Logger.php
Logger.mark
public static function mark($name) { $LOG = array('type' => 'BMARK', 'message' => (!is_null($name) ? $name : ''), 'logFile' => '', 'logLine' => '', 'context' => '', 'runtime' => round(self::getRelativeTime(), 4),); self::$Logs[] = $LOG; }
php
public static function mark($name) { $LOG = array('type' => 'BMARK', 'message' => (!is_null($name) ? $name : ''), 'logFile' => '', 'logLine' => '', 'context' => '', 'runtime' => round(self::getRelativeTime(), 4),); self::$Logs[] = $LOG; }
[ "public", "static", "function", "mark", "(", "$", "name", ")", "{", "$", "LOG", "=", "array", "(", "'type'", "=>", "'BMARK'", ",", "'message'", "=>", "(", "!", "is_null", "(", "$", "name", ")", "?", "$", "name", ":", "''", ")", ",", "'logFile'", "=>", "''", ",", "'logLine'", "=>", "''", ",", "'context'", "=>", "''", ",", "'runtime'", "=>", "round", "(", "self", "::", "getRelativeTime", "(", ")", ",", "4", ")", ",", ")", ";", "self", "::", "$", "Logs", "[", "]", "=", "$", "LOG", ";", "}" ]
Set a benchmark markpoint. Multiple calls to this function can be made so that several execution points can be timed. @param string $name Marker name @return void
[ "Set", "a", "benchmark", "markpoint", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Logger.php#L285-L295
train
FuzeWorks/Core
src/FuzeWorks/Logger.php
Logger.http_error
public static function http_error($errno = 500, $message = '', $layout = true): bool { $http_codes = array( 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 509 => 'Bandwidth Limit Exceeded', 510 => 'Not Extended', 511 => 'Network Authentication Required', ); self::logError('HTTP-error ' . $errno . ' called'); self::log('Sending header HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]); header('HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]); // Set the status code Core::$http_status_code = $errno; // Do we want the error-layout with it? if ($layout == false) { return false; } // Load the layout $layout = 'errors/' . $errno; self::log('Loading layout ' . $layout); // Try and load the layout, if impossible, load HTTP code instead. $factory = Factory::getInstance(); try { $factory->layout->reset(); $factory->layout->assign('httpErrorMessage', $message); $factory->layout->display($layout); } catch (LayoutException $exception) { // No error page could be found, just echo the result $factory->output->set_output("<h1>$errno</h1><h3>" . $http_codes[$errno] . '</h3><p>' . $message . '</p>'); } return true; }
php
public static function http_error($errno = 500, $message = '', $layout = true): bool { $http_codes = array( 400 => 'Bad Request', 401 => 'Unauthorized', 402 => 'Payment Required', 403 => 'Forbidden', 404 => 'Not Found', 405 => 'Method Not Allowed', 406 => 'Not Acceptable', 407 => 'Proxy Authentication Required', 408 => 'Request Timeout', 409 => 'Conflict', 410 => 'Gone', 411 => 'Length Required', 412 => 'Precondition Failed', 413 => 'Request Entity Too Large', 414 => 'Request-URI Too Long', 415 => 'Unsupported Media Type', 416 => 'Requested Range Not Satisfiable', 417 => 'Expectation Failed', 418 => 'I\'m a teapot', 426 => 'Upgrade Required', 428 => 'Precondition Required', 429 => 'Too Many Requests', 431 => 'Request Header Fields Too Large', 500 => 'Internal Server Error', 501 => 'Not Implemented', 502 => 'Bad Gateway', 503 => 'Service Unavailable', 504 => 'Gateway Timeout', 505 => 'HTTP Version Not Supported', 506 => 'Variant Also Negotiates', 509 => 'Bandwidth Limit Exceeded', 510 => 'Not Extended', 511 => 'Network Authentication Required', ); self::logError('HTTP-error ' . $errno . ' called'); self::log('Sending header HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]); header('HTTP/1.1 ' . $errno . ' ' . $http_codes[$errno]); // Set the status code Core::$http_status_code = $errno; // Do we want the error-layout with it? if ($layout == false) { return false; } // Load the layout $layout = 'errors/' . $errno; self::log('Loading layout ' . $layout); // Try and load the layout, if impossible, load HTTP code instead. $factory = Factory::getInstance(); try { $factory->layout->reset(); $factory->layout->assign('httpErrorMessage', $message); $factory->layout->display($layout); } catch (LayoutException $exception) { // No error page could be found, just echo the result $factory->output->set_output("<h1>$errno</h1><h3>" . $http_codes[$errno] . '</h3><p>' . $message . '</p>'); } return true; }
[ "public", "static", "function", "http_error", "(", "$", "errno", "=", "500", ",", "$", "message", "=", "''", ",", "$", "layout", "=", "true", ")", ":", "bool", "{", "$", "http_codes", "=", "array", "(", "400", "=>", "'Bad Request'", ",", "401", "=>", "'Unauthorized'", ",", "402", "=>", "'Payment Required'", ",", "403", "=>", "'Forbidden'", ",", "404", "=>", "'Not Found'", ",", "405", "=>", "'Method Not Allowed'", ",", "406", "=>", "'Not Acceptable'", ",", "407", "=>", "'Proxy Authentication Required'", ",", "408", "=>", "'Request Timeout'", ",", "409", "=>", "'Conflict'", ",", "410", "=>", "'Gone'", ",", "411", "=>", "'Length Required'", ",", "412", "=>", "'Precondition Failed'", ",", "413", "=>", "'Request Entity Too Large'", ",", "414", "=>", "'Request-URI Too Long'", ",", "415", "=>", "'Unsupported Media Type'", ",", "416", "=>", "'Requested Range Not Satisfiable'", ",", "417", "=>", "'Expectation Failed'", ",", "418", "=>", "'I\\'m a teapot'", ",", "426", "=>", "'Upgrade Required'", ",", "428", "=>", "'Precondition Required'", ",", "429", "=>", "'Too Many Requests'", ",", "431", "=>", "'Request Header Fields Too Large'", ",", "500", "=>", "'Internal Server Error'", ",", "501", "=>", "'Not Implemented'", ",", "502", "=>", "'Bad Gateway'", ",", "503", "=>", "'Service Unavailable'", ",", "504", "=>", "'Gateway Timeout'", ",", "505", "=>", "'HTTP Version Not Supported'", ",", "506", "=>", "'Variant Also Negotiates'", ",", "509", "=>", "'Bandwidth Limit Exceeded'", ",", "510", "=>", "'Not Extended'", ",", "511", "=>", "'Network Authentication Required'", ",", ")", ";", "self", "::", "logError", "(", "'HTTP-error '", ".", "$", "errno", ".", "' called'", ")", ";", "self", "::", "log", "(", "'Sending header HTTP/1.1 '", ".", "$", "errno", ".", "' '", ".", "$", "http_codes", "[", "$", "errno", "]", ")", ";", "header", "(", "'HTTP/1.1 '", ".", "$", "errno", ".", "' '", ".", "$", "http_codes", "[", "$", "errno", "]", ")", ";", "// Set the status code", "Core", "::", "$", "http_status_code", "=", "$", "errno", ";", "// Do we want the error-layout with it?", "if", "(", "$", "layout", "==", "false", ")", "{", "return", "false", ";", "}", "// Load the layout", "$", "layout", "=", "'errors/'", ".", "$", "errno", ";", "self", "::", "log", "(", "'Loading layout '", ".", "$", "layout", ")", ";", "// Try and load the layout, if impossible, load HTTP code instead.", "$", "factory", "=", "Factory", "::", "getInstance", "(", ")", ";", "try", "{", "$", "factory", "->", "layout", "->", "reset", "(", ")", ";", "$", "factory", "->", "layout", "->", "assign", "(", "'httpErrorMessage'", ",", "$", "message", ")", ";", "$", "factory", "->", "layout", "->", "display", "(", "$", "layout", ")", ";", "}", "catch", "(", "LayoutException", "$", "exception", ")", "{", "// No error page could be found, just echo the result", "$", "factory", "->", "output", "->", "set_output", "(", "\"<h1>$errno</h1><h3>\"", ".", "$", "http_codes", "[", "$", "errno", "]", ".", "'</h3><p>'", ".", "$", "message", ".", "'</p>'", ")", ";", "}", "return", "true", ";", "}" ]
Calls an HTTP error, sends it as a header, and loads a template if required to do so. @param int $errno HTTP error code @param string $message Message describing the reason for the HTTP error @param bool $layout true to layout error on website
[ "Calls", "an", "HTTP", "error", "sends", "it", "as", "a", "header", "and", "loads", "a", "template", "if", "required", "to", "do", "so", "." ]
051c64fdaa3a648174cbd54557d05ad553dd826b
https://github.com/FuzeWorks/Core/blob/051c64fdaa3a648174cbd54557d05ad553dd826b/src/FuzeWorks/Logger.php#L485-L551
train
gilbertsoft/typo3-gswarranty
Classes/Utility/Adapter.php
Adapter.getTypo3Version
protected static function getTypo3Version() { if (is_null(static::$version)) { static::$version = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch); } return static::$version; }
php
protected static function getTypo3Version() { if (is_null(static::$version)) { static::$version = \TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_branch); } return static::$version; }
[ "protected", "static", "function", "getTypo3Version", "(", ")", "{", "if", "(", "is_null", "(", "static", "::", "$", "version", ")", ")", "{", "static", "::", "$", "version", "=", "\\", "TYPO3", "\\", "CMS", "\\", "Core", "\\", "Utility", "\\", "VersionNumberUtility", "::", "convertVersionNumberToInteger", "(", "TYPO3_branch", ")", ";", "}", "return", "static", "::", "$", "version", ";", "}" ]
Returns the TYPO3 version as integer @return integer @api
[ "Returns", "the", "TYPO3", "version", "as", "integer" ]
2026dd04e6df9db61b56df3860e1f3462db54c69
https://github.com/gilbertsoft/typo3-gswarranty/blob/2026dd04e6df9db61b56df3860e1f3462db54c69/Classes/Utility/Adapter.php#L51-L57
train
gilbertsoft/typo3-gswarranty
Classes/Utility/Adapter.php
Adapter.adaptLogos
protected static function adaptLogos($extKey) { // Configure TBE_STYLES (TYPO3 = 7.6) if (static::isVersion('7.6')) { $GLOBALS['TBE_STYLES']['logo'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($extKey) . 'Resources/Public/Images/Backend/[email protected]'; } // Configure Backend Extension if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'])) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'] = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']); } // Login Logo (TYPO3 >= 7.6) if (static::isCompatVersion('7.6')) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['loginLogo'] = 'EXT:' . $extKey . '/Resources/Public/Images/Backend/gilbertsoft-t3-login.png'; $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['loginHighlightColor'] = '#004A99'; $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['loginBackgroundImage'] = 'EXT:' . $extKey . '/Resources/Public/Images/Backend/gilbertsoft-t3-background.jpg'; } // Backend Logo (TYPO3 >= 8.7) if (static::isCompatVersion('8.7')) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['backendLogo'] = 'EXT:' . $extKey . '/Resources/Public/Images/Backend/[email protected]'; } if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'])) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'] = serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']); } }
php
protected static function adaptLogos($extKey) { // Configure TBE_STYLES (TYPO3 = 7.6) if (static::isVersion('7.6')) { $GLOBALS['TBE_STYLES']['logo'] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath($extKey) . 'Resources/Public/Images/Backend/[email protected]'; } // Configure Backend Extension if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'])) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'] = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']); } // Login Logo (TYPO3 >= 7.6) if (static::isCompatVersion('7.6')) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['loginLogo'] = 'EXT:' . $extKey . '/Resources/Public/Images/Backend/gilbertsoft-t3-login.png'; $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['loginHighlightColor'] = '#004A99'; $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['loginBackgroundImage'] = 'EXT:' . $extKey . '/Resources/Public/Images/Backend/gilbertsoft-t3-background.jpg'; } // Backend Logo (TYPO3 >= 8.7) if (static::isCompatVersion('8.7')) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']['backendLogo'] = 'EXT:' . $extKey . '/Resources/Public/Images/Backend/[email protected]'; } if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'])) { $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend'] = serialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['backend']); } }
[ "protected", "static", "function", "adaptLogos", "(", "$", "extKey", ")", "{", "// Configure TBE_STYLES (TYPO3 = 7.6)\r", "if", "(", "static", "::", "isVersion", "(", "'7.6'", ")", ")", "{", "$", "GLOBALS", "[", "'TBE_STYLES'", "]", "[", "'logo'", "]", "=", "\\", "TYPO3", "\\", "CMS", "\\", "Core", "\\", "Utility", "\\", "ExtensionManagementUtility", "::", "extRelPath", "(", "$", "extKey", ")", ".", "'Resources/Public/Images/Backend/[email protected]'", ";", "}", "// Configure Backend Extension\r", "if", "(", "!", "is_array", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", ")", ")", "{", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", "=", "unserialize", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", ")", ";", "}", "// Login Logo (TYPO3 >= 7.6)\r", "if", "(", "static", "::", "isCompatVersion", "(", "'7.6'", ")", ")", "{", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", "[", "'loginLogo'", "]", "=", "'EXT:'", ".", "$", "extKey", ".", "'/Resources/Public/Images/Backend/gilbertsoft-t3-login.png'", ";", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", "[", "'loginHighlightColor'", "]", "=", "'#004A99'", ";", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", "[", "'loginBackgroundImage'", "]", "=", "'EXT:'", ".", "$", "extKey", ".", "'/Resources/Public/Images/Backend/gilbertsoft-t3-background.jpg'", ";", "}", "// Backend Logo (TYPO3 >= 8.7)\r", "if", "(", "static", "::", "isCompatVersion", "(", "'8.7'", ")", ")", "{", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", "[", "'backendLogo'", "]", "=", "'EXT:'", ".", "$", "extKey", ".", "'/Resources/Public/Images/Backend/[email protected]'", ";", "}", "if", "(", "is_array", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", ")", ")", "{", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", "=", "serialize", "(", "$", "GLOBALS", "[", "'TYPO3_CONF_VARS'", "]", "[", "'EXT'", "]", "[", "'extConf'", "]", "[", "'backend'", "]", ")", ";", "}", "}" ]
Adapt Backend Styling @param string $extKey Extension Key @return void
[ "Adapt", "Backend", "Styling" ]
2026dd04e6df9db61b56df3860e1f3462db54c69
https://github.com/gilbertsoft/typo3-gswarranty/blob/2026dd04e6df9db61b56df3860e1f3462db54c69/Classes/Utility/Adapter.php#L103-L130
train
gilbertsoft/typo3-gswarranty
Classes/Utility/Adapter.php
Adapter.tables
public static function tables($extKey) { if ((TYPO3_MODE === 'BE') && Provider::isGilbertsoft()) { static::registerIcons($extKey); static::adaptWarranty($extKey); static::adaptLogos($extKey); } }
php
public static function tables($extKey) { if ((TYPO3_MODE === 'BE') && Provider::isGilbertsoft()) { static::registerIcons($extKey); static::adaptWarranty($extKey); static::adaptLogos($extKey); } }
[ "public", "static", "function", "tables", "(", "$", "extKey", ")", "{", "if", "(", "(", "TYPO3_MODE", "===", "'BE'", ")", "&&", "Provider", "::", "isGilbertsoft", "(", ")", ")", "{", "static", "::", "registerIcons", "(", "$", "extKey", ")", ";", "static", "::", "adaptWarranty", "(", "$", "extKey", ")", ";", "static", "::", "adaptLogos", "(", "$", "extKey", ")", ";", "}", "}" ]
Adapts the backend @return void @api
[ "Adapts", "the", "backend" ]
2026dd04e6df9db61b56df3860e1f3462db54c69
https://github.com/gilbertsoft/typo3-gswarranty/blob/2026dd04e6df9db61b56df3860e1f3462db54c69/Classes/Utility/Adapter.php#L167-L175
train
covex-nn/JooS_Stream
src/JooS/Stream/Wrapper.php
Wrapper.unregister
public static function unregister($protocol) { $wrappers = stream_get_wrappers(); if (!in_array($protocol, $wrappers)) { throw new Wrapper_Exception( "Protocol '$protocol' has not been registered yet" ); } return stream_wrapper_unregister($protocol); }
php
public static function unregister($protocol) { $wrappers = stream_get_wrappers(); if (!in_array($protocol, $wrappers)) { throw new Wrapper_Exception( "Protocol '$protocol' has not been registered yet" ); } return stream_wrapper_unregister($protocol); }
[ "public", "static", "function", "unregister", "(", "$", "protocol", ")", "{", "$", "wrappers", "=", "stream_get_wrappers", "(", ")", ";", "if", "(", "!", "in_array", "(", "$", "protocol", ",", "$", "wrappers", ")", ")", "{", "throw", "new", "Wrapper_Exception", "(", "\"Protocol '$protocol' has not been registered yet\"", ")", ";", "}", "return", "stream_wrapper_unregister", "(", "$", "protocol", ")", ";", "}" ]
Unregister stream wrapper @param string $protocol Protocol name @throws Wrapper_Exception @return boolean
[ "Unregister", "stream", "wrapper" ]
e9841b804190a9f624b9e44caa0af7a18f3816d1
https://github.com/covex-nn/JooS_Stream/blob/e9841b804190a9f624b9e44caa0af7a18f3816d1/src/JooS/Stream/Wrapper.php#L52-L62
train
Sectorr/Core
Sectorr/Core/Database/Model.php
Model._find
protected function _find($id) { $data = $this->db->get($this->table, '*', ['id' => $id]); if (empty($data)) { return false; } return $this->setProperties($data); }
php
protected function _find($id) { $data = $this->db->get($this->table, '*', ['id' => $id]); if (empty($data)) { return false; } return $this->setProperties($data); }
[ "protected", "function", "_find", "(", "$", "id", ")", "{", "$", "data", "=", "$", "this", "->", "db", "->", "get", "(", "$", "this", "->", "table", ",", "'*'", ",", "[", "'id'", "=>", "$", "id", "]", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "setProperties", "(", "$", "data", ")", ";", "}" ]
Find item by ID. @param $id @return mixed
[ "Find", "item", "by", "ID", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Database/Model.php#L32-L41
train
Sectorr/Core
Sectorr/Core/Database/Model.php
Model._first
protected function _first($columns = '*') { $data = $this->db->get($this->table, $columns, $this->where); if (empty($data)) { return false; } return $this->setProperties($data); }
php
protected function _first($columns = '*') { $data = $this->db->get($this->table, $columns, $this->where); if (empty($data)) { return false; } return $this->setProperties($data); }
[ "protected", "function", "_first", "(", "$", "columns", "=", "'*'", ")", "{", "$", "data", "=", "$", "this", "->", "db", "->", "get", "(", "$", "this", "->", "table", ",", "$", "columns", ",", "$", "this", "->", "where", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "setProperties", "(", "$", "data", ")", ";", "}" ]
Get's the first result. @param string $columns @return bool
[ "Get", "s", "the", "first", "result", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Database/Model.php#L63-L72
train
Sectorr/Core
Sectorr/Core/Database/Model.php
Model._get
protected function _get($columns = '*') { $data = $this->db->select($this->table, $columns, $this->where); if (empty($data)) { return false; } return $this->getModelObjects($data); }
php
protected function _get($columns = '*') { $data = $this->db->select($this->table, $columns, $this->where); if (empty($data)) { return false; } return $this->getModelObjects($data); }
[ "protected", "function", "_get", "(", "$", "columns", "=", "'*'", ")", "{", "$", "data", "=", "$", "this", "->", "db", "->", "select", "(", "$", "this", "->", "table", ",", "$", "columns", ",", "$", "this", "->", "where", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getModelObjects", "(", "$", "data", ")", ";", "}" ]
Get all results filtered on set where. @param string $columns @return array|bool
[ "Get", "all", "results", "filtered", "on", "set", "where", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Database/Model.php#L80-L89
train
Sectorr/Core
Sectorr/Core/Database/Model.php
Model._all
protected function _all($columns = '*') { $data = $this->db->select($this->table, $columns); if (empty($data)) { return false; } return $this->getModelObjects($data); }
php
protected function _all($columns = '*') { $data = $this->db->select($this->table, $columns); if (empty($data)) { return false; } return $this->getModelObjects($data); }
[ "protected", "function", "_all", "(", "$", "columns", "=", "'*'", ")", "{", "$", "data", "=", "$", "this", "->", "db", "->", "select", "(", "$", "this", "->", "table", ",", "$", "columns", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "getModelObjects", "(", "$", "data", ")", ";", "}" ]
Get all results from table. @param string $columns @return array|bool
[ "Get", "all", "results", "from", "table", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Database/Model.php#L97-L106
train
Sectorr/Core
Sectorr/Core/Database/Model.php
Model._update
protected function _update($id, array $data) { return $this->db->update($this->table, $data, ['id' => $id]); }
php
protected function _update($id, array $data) { return $this->db->update($this->table, $data, ['id' => $id]); }
[ "protected", "function", "_update", "(", "$", "id", ",", "array", "$", "data", ")", "{", "return", "$", "this", "->", "db", "->", "update", "(", "$", "this", "->", "table", ",", "$", "data", ",", "[", "'id'", "=>", "$", "id", "]", ")", ";", "}" ]
Updates item in table. @param $id @param array $data @return bool|int
[ "Updates", "item", "in", "table", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Database/Model.php#L126-L129
train
Sectorr/Core
Sectorr/Core/Database/Model.php
Model.getProperty
private function getProperty($key) { return array_key_exists($key, $this->fields) ? $this->fields[$key] : null; }
php
private function getProperty($key) { return array_key_exists($key, $this->fields) ? $this->fields[$key] : null; }
[ "private", "function", "getProperty", "(", "$", "key", ")", "{", "return", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "fields", ")", "?", "$", "this", "->", "fields", "[", "$", "key", "]", ":", "null", ";", "}" ]
Get dynamic property. @param $key @return null
[ "Get", "dynamic", "property", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Database/Model.php#L175-L178
train
Sectorr/Core
Sectorr/Core/Database/Model.php
Model.setProperties
private function setProperties(array $data) { foreach ($data as $key => $value) { $this->setProperty($key, $value); } return $this; }
php
private function setProperties(array $data) { foreach ($data as $key => $value) { $this->setProperty($key, $value); } return $this; }
[ "private", "function", "setProperties", "(", "array", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "setProperty", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Go through array and set all dynamic properties. @param $data @return $this
[ "Go", "through", "array", "and", "set", "all", "dynamic", "properties", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Database/Model.php#L200-L207
train
PascalKleindienst/simple-api-client
src/Endpoint.php
Endpoint.getEndpointUrl
public function getEndpointUrl($path, $withTrailingSlash) { $url = $this->endpoint . '/' . $path; if ($withTrailingSlash) { $url = $url . '/'; } return $url; }
php
public function getEndpointUrl($path, $withTrailingSlash) { $url = $this->endpoint . '/' . $path; if ($withTrailingSlash) { $url = $url . '/'; } return $url; }
[ "public", "function", "getEndpointUrl", "(", "$", "path", ",", "$", "withTrailingSlash", ")", "{", "$", "url", "=", "$", "this", "->", "endpoint", ".", "'/'", ".", "$", "path", ";", "if", "(", "$", "withTrailingSlash", ")", "{", "$", "url", "=", "$", "url", ".", "'/'", ";", "}", "return", "$", "url", ";", "}" ]
Get the endpoint url for the request @param string $path @param bool $withTrailingSlash @return string
[ "Get", "the", "endpoint", "url", "for", "the", "request" ]
f4e20aa65bb9c340b8aff78acaede7dc62cd2105
https://github.com/PascalKleindienst/simple-api-client/blob/f4e20aa65bb9c340b8aff78acaede7dc62cd2105/src/Endpoint.php#L51-L60
train
rtens/mockster
src/Stub.php
Stub.will
public function will(Behaviour $behaviour = null) { if ($behaviour) { $this->behaviour = $behaviour; return $behaviour; } return new BehaviourFactory(function (Behaviour $behaviour) { $this->setStubbed(true); $this->behaviour = $behaviour; }); }
php
public function will(Behaviour $behaviour = null) { if ($behaviour) { $this->behaviour = $behaviour; return $behaviour; } return new BehaviourFactory(function (Behaviour $behaviour) { $this->setStubbed(true); $this->behaviour = $behaviour; }); }
[ "public", "function", "will", "(", "Behaviour", "$", "behaviour", "=", "null", ")", "{", "if", "(", "$", "behaviour", ")", "{", "$", "this", "->", "behaviour", "=", "$", "behaviour", ";", "return", "$", "behaviour", ";", "}", "return", "new", "BehaviourFactory", "(", "function", "(", "Behaviour", "$", "behaviour", ")", "{", "$", "this", "->", "setStubbed", "(", "true", ")", ";", "$", "this", "->", "behaviour", "=", "$", "behaviour", ";", "}", ")", ";", "}" ]
Sets the given Behaviour or returns a BehaviourFactory if non given @param behaviour\Behaviour $behaviour @return BehaviourFactory|Behaviour
[ "Sets", "the", "given", "Behaviour", "or", "returns", "a", "BehaviourFactory", "if", "non", "given" ]
712a8a8384d7bda03ca5dea2b82d7a7a47b131fe
https://github.com/rtens/mockster/blob/712a8a8384d7bda03ca5dea2b82d7a7a47b131fe/src/Stub.php#L75-L84
train
rtens/mockster
src/Stub.php
Stub.record
public function record($arguments, $returnValue, \Exception $thrown = null) { $this->history->add(new Call($this->named($arguments), $returnValue, $thrown)); if (!$this->checkReturnType) { return; } if ($thrown) { $this->checkException($thrown); } else { $this->checkReturnValue($returnValue); } }
php
public function record($arguments, $returnValue, \Exception $thrown = null) { $this->history->add(new Call($this->named($arguments), $returnValue, $thrown)); if (!$this->checkReturnType) { return; } if ($thrown) { $this->checkException($thrown); } else { $this->checkReturnValue($returnValue); } }
[ "public", "function", "record", "(", "$", "arguments", ",", "$", "returnValue", ",", "\\", "Exception", "$", "thrown", "=", "null", ")", "{", "$", "this", "->", "history", "->", "add", "(", "new", "Call", "(", "$", "this", "->", "named", "(", "$", "arguments", ")", ",", "$", "returnValue", ",", "$", "thrown", ")", ")", ";", "if", "(", "!", "$", "this", "->", "checkReturnType", ")", "{", "return", ";", "}", "if", "(", "$", "thrown", ")", "{", "$", "this", "->", "checkException", "(", "$", "thrown", ")", ";", "}", "else", "{", "$", "this", "->", "checkReturnValue", "(", "$", "returnValue", ")", ";", "}", "}" ]
Records the invocation of the method. @param array $arguments @param mixed $returnValue @param \Exception $thrown @throws \ReflectionException
[ "Records", "the", "invocation", "of", "the", "method", "." ]
712a8a8384d7bda03ca5dea2b82d7a7a47b131fe
https://github.com/rtens/mockster/blob/712a8a8384d7bda03ca5dea2b82d7a7a47b131fe/src/Stub.php#L175-L187
train
SagittariusX/Beluga.Core
src/Beluga/ArrayHelper.php
ArrayHelper.Remove
public static function Remove( array $array, int $index ) : array { if ( $index < 0 || $index >= \count( $array ) ) { return $array; } if ( $index == 0 ) { return \array_slice( $array, 1 ); } if ( $index + 1 == \count( $array ) ) { return \array_slice( $array, 0, -1 ); } $neu = \array_slice( $array, 0, $index ); return \array_merge( $neu, \array_slice( $array, $index + 1 ) ); }
php
public static function Remove( array $array, int $index ) : array { if ( $index < 0 || $index >= \count( $array ) ) { return $array; } if ( $index == 0 ) { return \array_slice( $array, 1 ); } if ( $index + 1 == \count( $array ) ) { return \array_slice( $array, 0, -1 ); } $neu = \array_slice( $array, 0, $index ); return \array_merge( $neu, \array_slice( $array, $index + 1 ) ); }
[ "public", "static", "function", "Remove", "(", "array", "$", "array", ",", "int", "$", "index", ")", ":", "array", "{", "if", "(", "$", "index", "<", "0", "||", "$", "index", ">=", "\\", "count", "(", "$", "array", ")", ")", "{", "return", "$", "array", ";", "}", "if", "(", "$", "index", "==", "0", ")", "{", "return", "\\", "array_slice", "(", "$", "array", ",", "1", ")", ";", "}", "if", "(", "$", "index", "+", "1", "==", "\\", "count", "(", "$", "array", ")", ")", "{", "return", "\\", "array_slice", "(", "$", "array", ",", "0", ",", "-", "1", ")", ";", "}", "$", "neu", "=", "\\", "array_slice", "(", "$", "array", ",", "0", ",", "$", "index", ")", ";", "return", "\\", "array_merge", "(", "$", "neu", ",", "\\", "array_slice", "(", "$", "array", ",", "$", "index", "+", "1", ")", ")", ";", "}" ]
Removes the element with defined index from array and reset the array element index after the removed element. @param array $array THe array. @param integer $index The index of the element to remove. @return array
[ "Removes", "the", "element", "with", "defined", "index", "from", "array", "and", "reset", "the", "array", "element", "index", "after", "the", "removed", "element", "." ]
51057b362707157a4b075df42bb49f397e2d310b
https://github.com/SagittariusX/Beluga.Core/blob/51057b362707157a4b075df42bb49f397e2d310b/src/Beluga/ArrayHelper.php#L287-L309
train
SagittariusX/Beluga.Core
src/Beluga/ArrayHelper.php
ArrayHelper.GetMaxDepth
public static function GetMaxDepth( array $array ) : int { if ( \count( $array ) < 1 ) { return 0; } $c = 1; foreach ( $array as $v ) { if ( \is_array( $v ) ) { $x = 1 + static::GetMaxDepth( $v ); if ( $x > $c ) { $c = $x; } } } return $c; }
php
public static function GetMaxDepth( array $array ) : int { if ( \count( $array ) < 1 ) { return 0; } $c = 1; foreach ( $array as $v ) { if ( \is_array( $v ) ) { $x = 1 + static::GetMaxDepth( $v ); if ( $x > $c ) { $c = $x; } } } return $c; }
[ "public", "static", "function", "GetMaxDepth", "(", "array", "$", "array", ")", ":", "int", "{", "if", "(", "\\", "count", "(", "$", "array", ")", "<", "1", ")", "{", "return", "0", ";", "}", "$", "c", "=", "1", ";", "foreach", "(", "$", "array", "as", "$", "v", ")", "{", "if", "(", "\\", "is_array", "(", "$", "v", ")", ")", "{", "$", "x", "=", "1", "+", "static", "::", "GetMaxDepth", "(", "$", "v", ")", ";", "if", "(", "$", "x", ">", "$", "c", ")", "{", "$", "c", "=", "$", "x", ";", "}", "}", "}", "return", "$", "c", ";", "}" ]
Returns the depth of permitted array. @param array $array The array to check @return integer Returns the depth.
[ "Returns", "the", "depth", "of", "permitted", "array", "." ]
51057b362707157a4b075df42bb49f397e2d310b
https://github.com/SagittariusX/Beluga.Core/blob/51057b362707157a4b075df42bb49f397e2d310b/src/Beluga/ArrayHelper.php#L360-L385
train
Waryway/PhpTraitsLibrary
src/Hydrator.php
Hydrator.hydrate
public function hydrate(stdClass $input, $strict = false) { $this->strict = $strict; $failedStrict = []; foreach($input as $name => $value) { if ($this->strict && !property_exists($this,$name)){ $failedStrict[$name] = $value; } else { $this->$name = $value; } } if (count($failedStrict)) { $this->strictError($failedStrict); } }
php
public function hydrate(stdClass $input, $strict = false) { $this->strict = $strict; $failedStrict = []; foreach($input as $name => $value) { if ($this->strict && !property_exists($this,$name)){ $failedStrict[$name] = $value; } else { $this->$name = $value; } } if (count($failedStrict)) { $this->strictError($failedStrict); } }
[ "public", "function", "hydrate", "(", "stdClass", "$", "input", ",", "$", "strict", "=", "false", ")", "{", "$", "this", "->", "strict", "=", "$", "strict", ";", "$", "failedStrict", "=", "[", "]", ";", "foreach", "(", "$", "input", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "this", "->", "strict", "&&", "!", "property_exists", "(", "$", "this", ",", "$", "name", ")", ")", "{", "$", "failedStrict", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "$", "this", "->", "$", "name", "=", "$", "value", ";", "}", "}", "if", "(", "count", "(", "$", "failedStrict", ")", ")", "{", "$", "this", "->", "strictError", "(", "$", "failedStrict", ")", ";", "}", "}" ]
Given a class object, hydrate it from a provided stdClass data object. @param $input stdClass - the data to dump into the class being hydrated. @param $strict bool - what to do if the data provided isn't an option in the class being hydrated.
[ "Given", "a", "class", "object", "hydrate", "it", "from", "a", "provided", "stdClass", "data", "object", "." ]
90c02e09b92e94664669b020b47a20a1590c4a4a
https://github.com/Waryway/PhpTraitsLibrary/blob/90c02e09b92e94664669b020b47a20a1590c4a4a/src/Hydrator.php#L46-L60
train
Wedeto/FileFormats
src/CSV/Writer.php
Writer.format
protected function format($data, $file_handle) { $header = false; foreach ($data as $idx => $row) { $row = WF::cast_array($row); $this->validateRow($row); if ($this->write_bom && ftell($file_handle) === 0) fwrite($file_handle, Encoding::getBOM('UTF8')); if (!$header && $this->write_header) { $keys = array_keys($row); fputcsv($file_handle, $keys, $this->delimiter, $this->enclosure, $this->escape_char); $header = true; } fputcsv($file_handle, $row, $this->delimiter, $this->enclosure, $this->escape_char); } }
php
protected function format($data, $file_handle) { $header = false; foreach ($data as $idx => $row) { $row = WF::cast_array($row); $this->validateRow($row); if ($this->write_bom && ftell($file_handle) === 0) fwrite($file_handle, Encoding::getBOM('UTF8')); if (!$header && $this->write_header) { $keys = array_keys($row); fputcsv($file_handle, $keys, $this->delimiter, $this->enclosure, $this->escape_char); $header = true; } fputcsv($file_handle, $row, $this->delimiter, $this->enclosure, $this->escape_char); } }
[ "protected", "function", "format", "(", "$", "data", ",", "$", "file_handle", ")", "{", "$", "header", "=", "false", ";", "foreach", "(", "$", "data", "as", "$", "idx", "=>", "$", "row", ")", "{", "$", "row", "=", "WF", "::", "cast_array", "(", "$", "row", ")", ";", "$", "this", "->", "validateRow", "(", "$", "row", ")", ";", "if", "(", "$", "this", "->", "write_bom", "&&", "ftell", "(", "$", "file_handle", ")", "===", "0", ")", "fwrite", "(", "$", "file_handle", ",", "Encoding", "::", "getBOM", "(", "'UTF8'", ")", ")", ";", "if", "(", "!", "$", "header", "&&", "$", "this", "->", "write_header", ")", "{", "$", "keys", "=", "array_keys", "(", "$", "row", ")", ";", "fputcsv", "(", "$", "file_handle", ",", "$", "keys", ",", "$", "this", "->", "delimiter", ",", "$", "this", "->", "enclosure", ",", "$", "this", "->", "escape_char", ")", ";", "$", "header", "=", "true", ";", "}", "fputcsv", "(", "$", "file_handle", ",", "$", "row", ",", "$", "this", "->", "delimiter", ",", "$", "this", "->", "enclosure", ",", "$", "this", "->", "escape_char", ")", ";", "}", "}" ]
Format the data into CSV @param mixed $data Traversable data
[ "Format", "the", "data", "into", "CSV" ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/CSV/Writer.php#L146-L165
train
Wedeto/FileFormats
src/CSV/Writer.php
Writer.validateRow
protected function validateRow(array $row) { foreach ($row as $k => $v) { if (WF::is_array_like($v)) throw new InvalidArgumentException("CSVWriter does not support nested arrays"); } }
php
protected function validateRow(array $row) { foreach ($row as $k => $v) { if (WF::is_array_like($v)) throw new InvalidArgumentException("CSVWriter does not support nested arrays"); } }
[ "protected", "function", "validateRow", "(", "array", "$", "row", ")", "{", "foreach", "(", "$", "row", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "WF", "::", "is_array_like", "(", "$", "v", ")", ")", "throw", "new", "InvalidArgumentException", "(", "\"CSVWriter does not support nested arrays\"", ")", ";", "}", "}" ]
Make sure that the data is not nested more than 1 level deep as CSV does not support that. @param array $row The row to validate @throws InvalidArgumentException When the array contains arrays
[ "Make", "sure", "that", "the", "data", "is", "not", "nested", "more", "than", "1", "level", "deep", "as", "CSV", "does", "not", "support", "that", "." ]
65b71fbd38a2ee6b504622aca4f4047ce9d31e9f
https://github.com/Wedeto/FileFormats/blob/65b71fbd38a2ee6b504622aca4f4047ce9d31e9f/src/CSV/Writer.php#L172-L179
train
codeblanche/Depend
src/Depend/Descriptor.php
Descriptor.addAction
public function addAction($action) { if (!$action instanceof ActionInterface) { return $this; } $name = $action->getIdentifier(); if (empty($name)) { return $this; } $this->actions[] = $action; return $this; }
php
public function addAction($action) { if (!$action instanceof ActionInterface) { return $this; } $name = $action->getIdentifier(); if (empty($name)) { return $this; } $this->actions[] = $action; return $this; }
[ "public", "function", "addAction", "(", "$", "action", ")", "{", "if", "(", "!", "$", "action", "instanceof", "ActionInterface", ")", "{", "return", "$", "this", ";", "}", "$", "name", "=", "$", "action", "->", "getIdentifier", "(", ")", ";", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "actions", "[", "]", "=", "$", "action", ";", "return", "$", "this", ";", "}" ]
Execute the given callback after class instance is created. @param ActionInterface $action @return Descriptor
[ "Execute", "the", "given", "callback", "after", "class", "instance", "is", "created", "." ]
6520d010ec71f5b2ea0d622b8abae2e029ef7f16
https://github.com/codeblanche/Depend/blob/6520d010ec71f5b2ea0d622b8abae2e029ef7f16/src/Depend/Descriptor.php#L93-L108
train
codeblanche/Depend
src/Depend/Descriptor.php
Descriptor.load
public function load(ReflectionClass $class) { $this->reset(); $this->reflectionClass = $class; $this->name = $this->reflectionClass->getName(); if (!$this->reflectionClass->isInstantiable()) { return $this; } $this->interfaces = $this->resolveInterfaces(); $this->parent = $this->resolveParent(); $this->reflectionConstructor = $this->reflectionClass->getConstructor(); if (is_null($this->reflectionConstructor)) { return $this; } $params = $this->reflectionConstructor->getParameters(); if (empty($params)) { return $this; } /** @var $param \ReflectionParameter */ foreach ($params as $param) { $paramName = $param->getName(); $this->params[$paramName] = $this->resolveArgumentValue($param); $this->paramNames[] = $paramName; } $this->constructorParams = $params; return $this; }
php
public function load(ReflectionClass $class) { $this->reset(); $this->reflectionClass = $class; $this->name = $this->reflectionClass->getName(); if (!$this->reflectionClass->isInstantiable()) { return $this; } $this->interfaces = $this->resolveInterfaces(); $this->parent = $this->resolveParent(); $this->reflectionConstructor = $this->reflectionClass->getConstructor(); if (is_null($this->reflectionConstructor)) { return $this; } $params = $this->reflectionConstructor->getParameters(); if (empty($params)) { return $this; } /** @var $param \ReflectionParameter */ foreach ($params as $param) { $paramName = $param->getName(); $this->params[$paramName] = $this->resolveArgumentValue($param); $this->paramNames[] = $paramName; } $this->constructorParams = $params; return $this; }
[ "public", "function", "load", "(", "ReflectionClass", "$", "class", ")", "{", "$", "this", "->", "reset", "(", ")", ";", "$", "this", "->", "reflectionClass", "=", "$", "class", ";", "$", "this", "->", "name", "=", "$", "this", "->", "reflectionClass", "->", "getName", "(", ")", ";", "if", "(", "!", "$", "this", "->", "reflectionClass", "->", "isInstantiable", "(", ")", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "interfaces", "=", "$", "this", "->", "resolveInterfaces", "(", ")", ";", "$", "this", "->", "parent", "=", "$", "this", "->", "resolveParent", "(", ")", ";", "$", "this", "->", "reflectionConstructor", "=", "$", "this", "->", "reflectionClass", "->", "getConstructor", "(", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "reflectionConstructor", ")", ")", "{", "return", "$", "this", ";", "}", "$", "params", "=", "$", "this", "->", "reflectionConstructor", "->", "getParameters", "(", ")", ";", "if", "(", "empty", "(", "$", "params", ")", ")", "{", "return", "$", "this", ";", "}", "/** @var $param \\ReflectionParameter */", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "paramName", "=", "$", "param", "->", "getName", "(", ")", ";", "$", "this", "->", "params", "[", "$", "paramName", "]", "=", "$", "this", "->", "resolveArgumentValue", "(", "$", "param", ")", ";", "$", "this", "->", "paramNames", "[", "]", "=", "$", "paramName", ";", "}", "$", "this", "->", "constructorParams", "=", "$", "params", ";", "return", "$", "this", ";", "}" ]
Load a class using its ReflectionClass object. @param ReflectionClass $class @throws \Exception|\ReflectionException @return Descriptor
[ "Load", "a", "class", "using", "its", "ReflectionClass", "object", "." ]
6520d010ec71f5b2ea0d622b8abae2e029ef7f16
https://github.com/codeblanche/Depend/blob/6520d010ec71f5b2ea0d622b8abae2e029ef7f16/src/Depend/Descriptor.php#L255-L290
train